Commit 549f0bff authored by Sylvain Thery's avatar Sylvain Thery

resolve bug of deleted marked darts

parent 09aaaf4e
......@@ -59,6 +59,7 @@ find_package(OpenGL REQUIRED)
find_package(Boost COMPONENTS regex REQUIRED)
find_package(ZLIB REQUIRED)
#find_package(LibXml2 REQUIRED)
find_package(TinyXml2 REQUIRED)
find_package(GLEW REQUIRED)
# MESSAGE HERE FOR MORE EASY USER READING
......@@ -98,7 +99,7 @@ SET (CGoGN_EXT_INCLUDES
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
# ${LIBXML2_INCLUDE_DIR}
${TINYXML2_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
)
......@@ -108,8 +109,7 @@ SET (CGoGN_EXT_LIBS
${OPENGL_LIBRARY}
${GLEW_LIBRARIES}
${ZLIB_LIBRARIES}
# ${LIBXML2_LIBRARIES}
tinyxml2
${TINYXML2_LIBRARY}
${Boost_REGEX_LIBRARY}
)
......
......@@ -38,7 +38,6 @@ namespace CGoGN
class RegisteredBaseAttribute;
class AttributeContainer;
class ContainerBrowser
{
public:
......@@ -73,6 +72,11 @@ protected:
*/
std::vector<AttributeMultiVectorGen*> m_tableAttribs;
/**
* vector of pointers to AttributeMultiVectors of MarkerBool
*/
std::vector<AttributeMultiVector<MarkerBool>*> m_tableMarkerAttribs;
/**
* vector of free indices in the vector of AttributeMultiVectors
*/
......@@ -158,6 +162,10 @@ public:
template <typename T>
AttributeMultiVector<T>* addAttribute(const std::string& attribName);
/// special version for marker
AttributeMultiVector<MarkerBool>* addMarkerAttribute(const std::string& attribName);
/**
* add a new attribute to the container
* @param typeName type of the new attribute in a string
......@@ -187,6 +195,8 @@ public:
template <typename T>
bool removeAttribute(const std::string& attribName);
bool removeMarkerAttribute(const std::string& attribName);
/**
* Remove an attribute (destroys data)
* @param index index of the attribute to remove
......@@ -322,6 +332,7 @@ public:
*/
unsigned int getAttributesNames(std::vector<std::string>& names) const;
/**
* fill a vector with attribute type names
* @param types vector of type names
......@@ -329,6 +340,8 @@ public:
*/
unsigned int getAttributesTypes(std::vector<std::string>& types);
std::vector<AttributeMultiVector<MarkerBool>*>& getMarkerAttributes();
/**************************************
* CONTAINER MANAGEMENT *
**************************************/
......@@ -444,6 +457,7 @@ public:
AttributeMultiVectorGen* getVirtualDataVector(unsigned int attrIndex);
/**
* get an AttributeMultiVector
* @param attribName name of the attribute
......
......@@ -43,6 +43,11 @@ inline void AttributeContainer::setOrbit(unsigned int orbit)
if (m_tableAttribs[i] != NULL)
m_tableAttribs[i]->setOrbit(orbit);
}
for(unsigned int i = 0; i < m_tableMarkerAttribs.size(); ++i)
{
m_tableMarkerAttribs[i]->setOrbit(orbit);
}
}
inline void AttributeContainer::setRegistry(std::map< std::string, RegisteredBaseAttribute* >* re)
......@@ -340,10 +345,9 @@ inline void AttributeContainer::initLine(unsigned int index)
inline void AttributeContainer::initMarkersOfLine(unsigned int index)
{
for(unsigned int i = 0; i < m_tableAttribs.size(); ++i)
for(unsigned int i = 0; i < m_tableMarkerAttribs.size(); ++i)
{
if ((m_tableAttribs[i] != NULL) && (m_tableAttribs[i]->isMarkerBool()))
m_tableAttribs[i]->initElt(index);
m_tableMarkerAttribs[i]->initElt(index);
}
}
......@@ -355,6 +359,12 @@ inline void AttributeContainer::copyLine(unsigned int dstIndex, unsigned int src
if (m_tableAttribs[i] != NULL)
m_tableAttribs[i]->copyElt(dstIndex, srcIndex);
}
for(unsigned int i = 0; i < m_tableMarkerAttribs.size(); ++i)
{
m_tableMarkerAttribs[i]->copyElt(dstIndex, srcIndex);
}
}
inline void AttributeContainer::refLine(unsigned int index)
......@@ -490,4 +500,12 @@ inline void AttributeContainer::setData(unsigned int attrIndex, unsigned int elt
atm->operator[](eltIndex) = data;
}
inline std::vector<AttributeMultiVector<MarkerBool>*>& AttributeContainer::getMarkerAttributes()
{
return m_tableMarkerAttribs;
}
} // namespace CGoGN
......@@ -211,7 +211,6 @@ inline unsigned int GenericMap::newCell()
unsigned int c = m_attribs[ORBIT].insertLine();
m_attribs[ORBIT].initMarkersOfLine(c);
return c;
// return m_attribs[ORBIT].insertLine();
}
template <unsigned int ORBIT>
......@@ -291,7 +290,7 @@ AttributeMultiVector<MarkerBool>* GenericMap::askMarkVector()
x = x/10;
number[0]= '0'+x%10;
AttributeMultiVector<MarkerBool>* amv = m_attribs[ORBIT].addAttribute<MarkerBool>("marker_" + orbitName(ORBIT) + number);
AttributeMultiVector<MarkerBool>* amv = m_attribs[ORBIT].addMarkerAttribute("marker_" + orbitName(ORBIT) + number);
return amv;
}
}
......
......@@ -49,7 +49,7 @@ inline std::string XMLAttribute(tinyxml2::XMLElement* node, const char* attName)
const char *ptr = node->Attribute(attName);
if (ptr == NULL)
{
CGoGNerr << "Warning attrbute "<< attName << " not found"<< CGoGNendl;
CGoGNerr << "Warning attribute "<< attName << " not found"<< CGoGNendl;
return "";
}
return std::string(ptr);
......
This diff is collapsed.
......@@ -235,8 +235,8 @@ void GenericMap::init(bool addBoundaryMarkers)
if (addBoundaryMarkers)
{
m_boundaryMarkers[0] = m_attribs[DART].addAttribute<MarkerBool>("BoundaryMark0") ;
m_boundaryMarkers[1] = m_attribs[DART].addAttribute<MarkerBool>("BoundaryMark1") ;
m_boundaryMarkers[0] = m_attribs[DART].addMarkerAttribute("BoundaryMark0") ;
m_boundaryMarkers[1] = m_attribs[DART].addMarkerAttribute("BoundaryMark1") ;
}
......@@ -405,17 +405,16 @@ void GenericMap::restore_shortcuts()
}
// MARKERS
m_attribs[DART].getAttributesNames(listeNames);
for (unsigned int i = 0; i < listeNames.size(); ++i)
std::vector<AttributeMultiVector<MarkerBool>*>& amvv = m_attribs[DART].getMarkerAttributes();
for (auto it=amvv.begin(); it != amvv.end(); ++it)
{
if (listeNames[i] == "BoundaryMark0")
m_boundaryMarkers[0] = cont.getDataVector<MarkerBool>(i);
if (listeNames[i] == "BoundaryMark1")
m_boundaryMarkers[1] = cont.getDataVector<MarkerBool>(i);
if ((*it)->getName() == "BoundaryMark0")
m_boundaryMarkers[0] = *it;
if ((*it)->getName() == "BoundaryMark1")
m_boundaryMarkers[1] = *it;
}
// QUICK TRAVERSAL
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
......@@ -603,17 +602,20 @@ void GenericMap::garbageMarkVectors()
for (unsigned int orbit=0; orbit<NB_ORBITS;++orbit)
{
std::vector<std::string> attNames;
m_attribs[orbit].getAttributesNames(attNames);
for (auto sit=attNames.begin(); sit!=attNames.end();++sit)
std::vector<AttributeMultiVector<MarkerBool>*>& amvv = m_attribs[orbit].getMarkerAttributes();
for (auto it = amvv.begin(); it != amvv.end(); ++it )
{
if (sit->substr(0,7) == "marker_")
AttributeMultiVector<MarkerBool>* amv = *it;
const std::string& name = amv->getName();
if (name.substr(0,7) == "marker_")
{
std::string num = sit->substr(sit->length()-3,3);
// store tne next free index for unique numbering
std::string num = name.substr(name.length()-3,3);
unsigned int id = 100*(num[0]-'0')+10*(num[1]-'0')+(num[2]-'0');
if (id > maxId)
maxId = id;
AttributeMultiVector<MarkerBool>* amv = m_attribs[orbit].getDataVector<MarkerBool>(*sit);
amv->allFalse();
m_markVectors_free[orbit][0].push_back(amv);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment