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