Commit 82d8876f authored by Sylvain Thery's avatar Sylvain Thery

ajout fonction compact dans generic_map

+ test_compact dans Test
parent 639d734d
...@@ -35,6 +35,10 @@ add_executable( Geom_intersectionD ./Geom_intersection.cpp) ...@@ -35,6 +35,10 @@ add_executable( Geom_intersectionD ./Geom_intersection.cpp)
target_link_libraries( Geom_intersectionD target_link_libraries( Geom_intersectionD
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS})
add_executable( test_compactD ./test_compact.cpp)
target_link_libraries( test_compactD
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS})
IF (WITH_QT) IF (WITH_QT)
QT4_WRAP_CPP(concave_rendering_moc concave_rendering.h) QT4_WRAP_CPP(concave_rendering_moc concave_rendering.h)
......
...@@ -793,11 +793,8 @@ void Clipping::importMesh(std::string& filename) ...@@ -793,11 +793,8 @@ void Clipping::importMesh(std::string& filename)
{ {
std::vector<std::string> attrNames ; std::vector<std::string> attrNames ;
std::string extension; size_t pos = filename.rfind("."); // position of "." in filename
size_t pos; std::string extension = filename.substr(pos);
pos = filename.rfind("."); // position of "." in filename
extension = filename.substr(pos);
if(extension == std::string(".tet")) if(extension == std::string(".tet"))
{ {
......
...@@ -184,13 +184,25 @@ void Viewer::importMesh(std::string& filename) ...@@ -184,13 +184,25 @@ void Viewer::importMesh(std::string& filename)
{ {
myMap.clear(true) ; myMap.clear(true) ;
std::vector<std::string> attrNames ; size_t pos = filename.rfind("."); // position of "." in filename
if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames)) std::string extension = filename.substr(pos);
if (extension == std::string(".map"))
{
myMap.loadMapBin(filename);
position = myMap.getAttribute<PFP::VEC3>(VERTEX, "position") ;
}
else
{ {
CGoGNerr << "could not import " << filename << CGoGNendl ; std::vector<std::string> attrNames ;
return; if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
}
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
} }
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS) ; m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ; m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ;
......
...@@ -385,6 +385,16 @@ public: ...@@ -385,6 +385,16 @@ public:
*/ */
void dumpAttributesAndMarkers(); void dumpAttributesAndMarkers();
/**
* update topo relation after compacting the container:
*/
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew)=0;
/**
* compact the map
*/
void compact();
/**************************************** /****************************************
* DARTS TRAVERSALS * * DARTS TRAVERSALS *
****************************************/ ****************************************/
......
...@@ -54,6 +54,8 @@ public: ...@@ -54,6 +54,8 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
...@@ -53,6 +53,8 @@ public: ...@@ -53,6 +53,8 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
...@@ -53,6 +53,8 @@ public: ...@@ -53,6 +53,8 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
...@@ -53,6 +53,8 @@ public: ...@@ -53,6 +53,8 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
...@@ -59,6 +59,8 @@ public: ...@@ -59,6 +59,8 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
...@@ -65,6 +65,8 @@ public: ...@@ -65,6 +65,8 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations( const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
...@@ -67,6 +67,8 @@ public: ...@@ -67,6 +67,8 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
...@@ -203,6 +203,7 @@ void AttributeContainer::compact(std::vector<unsigned int>& mapOldNew) ...@@ -203,6 +203,7 @@ void AttributeContainer::compact(std::vector<unsigned int>& mapOldNew)
} }
++nbb; ++nbb;
mapOldNew.clear();
mapOldNew.reserve(nbe); mapOldNew.reserve(nbe);
// now get the holes // now get the holes
......
...@@ -514,6 +514,37 @@ void GenericMap::dumpAttributesAndMarkers() ...@@ -514,6 +514,37 @@ void GenericMap::dumpAttributesAndMarkers()
} }
} }
void GenericMap::compact()
{
std::vector<unsigned int> oldnew;
// compacting the orbits attributes
for (unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{
if ((orbit != DART) && (isOrbitEmbedded(orbit)))
{
m_attribs[orbit].compact(oldnew);
for (unsigned int i = m_attribs[DART].begin(); i!= m_attribs[DART].end(); m_attribs[DART].next(i))
{
unsigned int& idx = m_embeddings[orbit]->operator [](i);
unsigned int jdx = oldnew[idx];
if ((jdx != 0xffffffff) && (jdx!=idx))
idx = jdx;
}
}
}
//compacting the topo
m_attribs[DART].compact(oldnew);
// update topo relations: recurvise call from real map down to generic
compactTopoRelations(oldnew);
// dumpAttributesAndMarkers();
}
/**************************************** /****************************************
* DARTS TRAVERSALS * * DARTS TRAVERSALS *
****************************************/ ****************************************/
......
...@@ -45,4 +45,15 @@ void GMap0::deleteEdge(Dart d) ...@@ -45,4 +45,15 @@ void GMap0::deleteEdge(Dart d)
deleteDart(d); deleteDart(d);
} }
void GMap0::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for (unsigned int i = m_attribs[DART].begin(); i!= m_attribs[DART].end(); m_attribs[DART].next(i))
{
Dart& d = m_beta0->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
}
} // namespace CGoGN } // namespace CGoGN
...@@ -75,5 +75,24 @@ void GMap1::deleteFace(Dart d) ...@@ -75,5 +75,24 @@ void GMap1::deleteFace(Dart d)
deleteEdge(d); deleteEdge(d);
} }
void GMap1::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for (unsigned int i = m_attribs[DART].begin(); i!= m_attribs[DART].end(); m_attribs[DART].next(i))
{
{
Dart& d = m_beta0->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_beta1->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
}
}
} // namespace CGoGN } // namespace CGoGN
...@@ -895,4 +895,32 @@ void GMap2::closeMap() ...@@ -895,4 +895,32 @@ void GMap2::closeMap()
} }
} }
void GMap2::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for (unsigned int i = m_attribs[DART].begin(); i!= m_attribs[DART].end(); m_attribs[DART].next(i))
{
{
Dart& d = m_beta0->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_beta1->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_beta2->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
}
}
} // namespace CGoGN } // namespace CGoGN
...@@ -916,4 +916,36 @@ void GMap3::closeMap() ...@@ -916,4 +916,36 @@ void GMap3::closeMap()
} }
} }
inline void GMap3::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for (unsigned int i = m_attribs[DART].begin(); i!= m_attribs[DART].end(); m_attribs[DART].next(i))
{
{
Dart& d = m_beta0->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_beta1->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_beta2->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_beta3->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
}
}
} // namespace CGoGN } // namespace CGoGN
...@@ -84,4 +84,25 @@ void Map1::reverseCycle(Dart d) ...@@ -84,4 +84,25 @@ void Map1::reverseCycle(Dart d)
phi1sew(e, d) ; // Sew the last edge phi1sew(e, d) ; // Sew the last edge
} }
void Map1::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for (unsigned int i = m_attribs[DART].begin(); i!= m_attribs[DART].end(); m_attribs[DART].next(i))
{
{
Dart& d = m_phi1->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_phi_1->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
}
}
} // namespace CGoGN } // namespace CGoGN
...@@ -776,4 +776,30 @@ void Map2::closeMap() ...@@ -776,4 +776,30 @@ void Map2::closeMap()
} }
} }
void Map2::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for (unsigned int i = m_attribs[DART].begin(); i!= m_attribs[DART].end(); m_attribs[DART].next(i))
{
{
Dart& d = m_phi1->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_phi_1->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_phi2->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
}
}
} // namespace CGoGN } // namespace CGoGN
...@@ -821,4 +821,36 @@ void Map3::closeMap() ...@@ -821,4 +821,36 @@ void Map3::closeMap()
} }
} }
void Map3::compactTopoRelations(const std::vector<unsigned int>& oldnew)
{
for (unsigned int i = m_attribs[DART].begin(); i!= m_attribs[DART].end(); m_attribs[DART].next(i))
{
{
Dart& d = m_phi1->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_phi_1->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_phi2->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
{
Dart& d = m_phi3->operator [](i);
Dart e = Dart(oldnew[d.index]);
if (d!=e)
d = e;
}
}
}
} // namespace CGoGN } // namespace CGoGN
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