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)
target_link_libraries( Geom_intersectionD
${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)
QT4_WRAP_CPP(concave_rendering_moc concave_rendering.h)
......
......@@ -793,11 +793,8 @@ void Clipping::importMesh(std::string& filename)
{
std::vector<std::string> attrNames ;
std::string extension;
size_t pos;
pos = filename.rfind("."); // position of "." in filename
extension = filename.substr(pos);
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
if(extension == std::string(".tet"))
{
......
......@@ -184,6 +184,16 @@ void Viewer::importMesh(std::string& filename)
{
myMap.clear(true) ;
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
if (extension == std::string(".map"))
{
myMap.loadMapBin(filename);
position = myMap.getAttribute<PFP::VEC3>(VERTEX, "position") ;
}
else
{
std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
{
......@@ -191,6 +201,8 @@ void Viewer::importMesh(std::string& filename)
return;
}
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::LINES) ;
......
......@@ -385,6 +385,16 @@ public:
*/
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 *
****************************************/
......
......@@ -54,6 +54,8 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
......@@ -53,6 +53,8 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
......@@ -53,6 +53,8 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
......@@ -53,6 +53,8 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
......@@ -59,6 +59,8 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
......@@ -65,6 +65,8 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations( const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
......@@ -67,6 +67,8 @@ public:
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
......@@ -203,6 +203,7 @@ void AttributeContainer::compact(std::vector<unsigned int>& mapOldNew)
}
++nbb;
mapOldNew.clear();
mapOldNew.reserve(nbe);
// now get the holes
......
......@@ -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 *
****************************************/
......
......@@ -45,4 +45,15 @@ void GMap0::deleteEdge(Dart 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
......@@ -75,5 +75,24 @@ void GMap1::deleteFace(Dart 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
......@@ -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
......@@ -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
......@@ -84,4 +84,25 @@ void Map1::reverseCycle(Dart d)
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
......@@ -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
......@@ -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
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