Commit 868dac79 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

merges

parent 2d3d9fcd
...@@ -301,8 +301,8 @@ protected: ...@@ -301,8 +301,8 @@ protected:
AttributeMultiVector<Dart>* addRelation(const std::string& name) ; AttributeMultiVector<Dart>* addRelation(const std::string& name) ;
/** /**
* Get attributeMultivector pointer of a relation attribute * Get AttributeMultivector pointer of a relation attribute
* @param anem name of relation * @param name name of the relation
* @return the attribute multi-vector pointer * @return the attribute multi-vector pointer
*/ */
AttributeMultiVector<Dart>* getRelation(const std::string& name); AttributeMultiVector<Dart>* getRelation(const std::string& name);
...@@ -388,7 +388,7 @@ public: ...@@ -388,7 +388,7 @@ public:
/** /**
* update topo relation after compacting the container: * update topo relation after compacting the container:
*/ */
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew)=0; virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew) = 0;
/** /**
* compact the map * compact the map
......
...@@ -218,6 +218,4 @@ inline AttributeMultiVector<Dart>* GenericMap::getRelation(const std::string& na ...@@ -218,6 +218,4 @@ inline AttributeMultiVector<Dart>* GenericMap::getRelation(const std::string& na
return amv ; return amv ;
} }
} //namespace CGoGN } //namespace CGoGN
...@@ -62,8 +62,6 @@ inline void Map1::update_topo_shortcuts() ...@@ -62,8 +62,6 @@ inline void Map1::update_topo_shortcuts()
m_phi_1 = getRelation("phi_1"); m_phi_1 = getRelation("phi_1");
} }
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
*************************************************************************/ *************************************************************************/
......
...@@ -65,7 +65,7 @@ public: ...@@ -65,7 +65,7 @@ public:
virtual void update_topo_shortcuts(); virtual void update_topo_shortcuts();
virtual void compactTopoRelations( const std::vector<unsigned int>& oldnew); virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
......
...@@ -54,7 +54,6 @@ inline void Map2::clear(bool removeAttrib) ...@@ -54,7 +54,6 @@ inline void Map2::clear(bool removeAttrib)
init() ; init() ;
} }
inline void Map2::update_topo_shortcuts() inline void Map2::update_topo_shortcuts()
{ {
Map1::update_topo_shortcuts(); Map1::update_topo_shortcuts();
......
...@@ -52,7 +52,6 @@ inline void Map3::clear(bool removeAttrib) ...@@ -52,7 +52,6 @@ inline void Map3::clear(bool removeAttrib)
init() ; init() ;
} }
inline void Map3::update_topo_shortcuts() inline void Map3::update_topo_shortcuts()
{ {
Map2::update_topo_shortcuts(); Map2::update_topo_shortcuts();
......
...@@ -305,8 +305,6 @@ void GenericMap::removeThreadMarker(unsigned int nb) ...@@ -305,8 +305,6 @@ void GenericMap::removeThreadMarker(unsigned int nb)
* SAVE & LOAD * * SAVE & LOAD *
****************************************/ ****************************************/
bool GenericMap::saveMapBin(const std::string& filename) bool GenericMap::saveMapBin(const std::string& filename)
{ {
CGoGNostream fs(filename.c_str(), std::ios::out|std::ios::binary); CGoGNostream fs(filename.c_str(), std::ios::out|std::ios::binary);
...@@ -318,28 +316,25 @@ bool GenericMap::saveMapBin(const std::string& filename) ...@@ -318,28 +316,25 @@ bool GenericMap::saveMapBin(const std::string& filename)
// Entete // Entete
char* buff = new char[256]; char* buff = new char[256];
for (int i=0; i< 256; ++i) for (int i = 0; i < 256; ++i)
buff[i] = char(255); buff[i] = char(255);
const char* cgogn = "CGoGN_Map"; const char* cgogn = "CGoGN_Map";
memcpy(buff,cgogn,10); memcpy(buff, cgogn, 10);
std::string mt = mapTypeName(); std::string mt = mapTypeName();
const char* mtc = mt.c_str(); const char* mtc = mt.c_str();
memcpy(buff+32,mtc,mt.size()+1); memcpy(buff+32, mtc, mt.size()+1);
unsigned int *buffi = reinterpret_cast<unsigned int*>(buff+64); unsigned int *buffi = reinterpret_cast<unsigned int*>(buff + 64);
*buffi = NB_ORBITS; *buffi = NB_ORBITS;
fs.write(reinterpret_cast<const char*>(buff), 256); fs.write(reinterpret_cast<const char*>(buff), 256);
delete buff; delete buff;
// save all attribs // save all attribs
for (unsigned int i=0; i<NB_ORBITS; ++i) for (unsigned int i = 0; i < NB_ORBITS; ++i)
{ m_attribs[i].saveBin(fs, i);
m_attribs[i].saveBin(fs,i);
}
return true; return true;
} }
bool GenericMap::loadMapBin(const std::string& filename) bool GenericMap::loadMapBin(const std::string& filename)
{ {
...@@ -365,7 +360,7 @@ bool GenericMap::loadMapBin(const std::string& filename) ...@@ -365,7 +360,7 @@ bool GenericMap::loadMapBin(const std::string& filename)
} }
// Check map type // Check map type
buff_str = std::string(buff+32); buff_str = std::string(buff + 32);
std::string localType = this->mapTypeName(); std::string localType = this->mapTypeName();
...@@ -373,12 +368,12 @@ bool GenericMap::loadMapBin(const std::string& filename) ...@@ -373,12 +368,12 @@ bool GenericMap::loadMapBin(const std::string& filename)
if (fileType != localType) if (fileType != localType)
{ {
CGoGNerr << "Not possible to load "<< fileType<< " into "<< localType << " object"<<CGoGNendl; CGoGNerr << "Not possible to load "<< fileType << " into " << localType << " object" << CGoGNendl;
return false; return false;
} }
// Check max nb orbit // Check max nb orbit
unsigned int *ptr_nbo = reinterpret_cast<unsigned int*>(buff+64); unsigned int *ptr_nbo = reinterpret_cast<unsigned int*>(buff + 64);
unsigned int nbo = *ptr_nbo; unsigned int nbo = *ptr_nbo;
if (nbo != NB_ORBITS) if (nbo != NB_ORBITS)
{ {
...@@ -387,7 +382,7 @@ bool GenericMap::loadMapBin(const std::string& filename) ...@@ -387,7 +382,7 @@ bool GenericMap::loadMapBin(const std::string& filename)
} }
// load attrib container // load attrib container
for (unsigned int i=0; i<NB_ORBITS; ++i) for (unsigned int i = 0; i < NB_ORBITS; ++i)
{ {
unsigned int id = AttributeContainer::loadBinId(fs); unsigned int id = AttributeContainer::loadBinId(fs);
m_attribs[id].loadBin(fs); m_attribs[id].loadBin(fs);
...@@ -395,14 +390,12 @@ bool GenericMap::loadMapBin(const std::string& filename) ...@@ -395,14 +390,12 @@ bool GenericMap::loadMapBin(const std::string& filename)
// retrieve m_embeddings (from m_attribs[DART] // retrieve m_embeddings (from m_attribs[DART]
update_m_emb_afterLoad(); update_m_emb_afterLoad();
// recursive call from real type of map (for topo relation attributes pointers) down to GenericMap ( for Marker_cleaning & pointers) // recursive call from real type of map (for topo relation attributes pointers) down to GenericMap (for Marker_cleaning & pointers)
update_topo_shortcuts(); update_topo_shortcuts();
return true; return true;
} }
void GenericMap::update_m_emb_afterLoad() void GenericMap::update_m_emb_afterLoad()
{ {
// get container of dart orbit // get container of dart orbit
...@@ -415,21 +408,18 @@ void GenericMap::update_m_emb_afterLoad() ...@@ -415,21 +408,18 @@ void GenericMap::update_m_emb_afterLoad()
// check if there are EMB_X attributes // check if there are EMB_X attributes
for (unsigned int i = 0; i < listeNames.size(); ++i) for (unsigned int i = 0; i < listeNames.size(); ++i)
{ {
std::string sub = listeNames[i].substr(0,listeNames[i].size()-1); std::string sub = listeNames[i].substr(0, listeNames[i].size() - 1);
if (sub == "EMB_") if (sub == "EMB_")
{ {
unsigned int orb = listeNames[i][4]-'0'; // easy atoi computation for one char; unsigned int orb = listeNames[i][4]-'0'; // easy atoi computation for one char;
AttributeMultiVector<unsigned int>* amv = cont.getDataVector<unsigned int>(i); AttributeMultiVector<unsigned int>* amv = cont.getDataVector<unsigned int>(i);
m_embeddings[orb] = amv ; m_embeddings[orb] = amv ;
} }
} }
} }
void GenericMap::update_topo_shortcuts() void GenericMap::update_topo_shortcuts()
{ {
for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit) for(unsigned int orbit = 0; orbit < NB_ORBITS; ++orbit)
{ {
AttributeContainer& cont = m_attribs[orbit]; AttributeContainer& cont = m_attribs[orbit];
...@@ -440,32 +430,28 @@ void GenericMap::update_topo_shortcuts() ...@@ -440,32 +430,28 @@ void GenericMap::update_topo_shortcuts()
for (unsigned int i = 0; i < listeNames.size(); ++i) for (unsigned int i = 0; i < listeNames.size(); ++i)
{ {
std::string sub = listeNames[i].substr(0,5); std::string sub = listeNames[i].substr(0, 5);
if (sub == "Mark_") if (sub == "Mark_")
{ {
// get thread number // get thread number
unsigned int thread = listeNames[i][5]-'0'; unsigned int thread = listeNames[i][5]-'0';
if (listeNames[i].size()>6) // thread number is >9 if (listeNames[i].size() > 6) // thread number is >9
thread = 10*thread + listeNames[i][6]-'0'; thread = 10*thread + listeNames[i][6]-'0';
AttributeMultiVector<Mark>* amvMark = cont.getDataVector<Mark>(i); AttributeMultiVector<Mark>* amvMark = cont.getDataVector<Mark>(i);
m_markTables[orbit][thread] = amvMark ; m_markTables[orbit][thread] = amvMark ;
if ((orbit == DART) && (thread==0)) // for Marker of dart of thread O keep the boundary marker if ((orbit == DART) && (thread == 0)) // for Marker of dart of thread O keep the boundary marker
{ {
Mark m(m_boundaryMarker); Mark m(m_boundaryMarker);
m.invert(); m.invert();
for (unsigned int i=cont.begin();i!= cont.end(); cont.next(i)) for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
{
amvMark->operator[](i).unsetMark(m); amvMark->operator[](i).unsetMark(m);
}
} }
else // for others clear all else // for others clear all
{ {
for (unsigned int i=cont.begin();i!= cont.end(); cont.next(i)) for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
{
amvMark->operator[](i).clear(); amvMark->operator[](i).clear();
}
} }
} }
} }
...@@ -474,38 +460,36 @@ void GenericMap::update_topo_shortcuts() ...@@ -474,38 +460,36 @@ void GenericMap::update_topo_shortcuts()
void GenericMap::dumpAttributesAndMarkers() void GenericMap::dumpAttributesAndMarkers()
{ {
for (unsigned int i = 0; i<NB_ORBITS; ++i) for (unsigned int i = 0; i < NB_ORBITS; ++i)
{ {
std::vector<std::string> names; std::vector<std::string> names;
names.reserve(32); //just tp limit reallocation names.reserve(32); //just to limit reallocation
m_attribs[i].getAttributesNames(names); m_attribs[i].getAttributesNames(names);
unsigned int nb = names.size(); unsigned int nb = names.size();
if (nb>0) if (nb > 0)
{ {
CGoGNout << "ORBIT "<< i<< CGoGNendl; CGoGNout << "ORBIT "<< i << CGoGNendl;
std::vector<std::string> types; std::vector<std::string> types;
types.reserve(nb); types.reserve(nb);
m_attribs[i].getAttributesTypes(types); m_attribs[i].getAttributesTypes(types);
for (unsigned int j=0; j<nb; ++j) for (unsigned int j = 0; j < nb; ++j)
{ CGoGNout << " " << j << " : " << types[j] << " " << names[j] << CGoGNendl;
CGoGNout << " "<< j << " : "<< types[j] << " "<< names[j]<< CGoGNendl;
}
} }
} }
CGoGNout << "RESERVED MARKERS "<< CGoGNendl; CGoGNout << "RESERVED MARKERS "<< CGoGNendl;
for (unsigned int i=0; i<NB_ORBITS; ++i) for (unsigned int i = 0; i < NB_ORBITS; ++i)
{ {
for (unsigned int j=0; j<NB_THREAD; ++j) for (unsigned int j = 0; j < NB_THREAD; ++j)
{ {
MarkSet ms = m_marksets[i][j]; MarkSet ms = m_marksets[i][j];
if (!ms.isClear()) if (!ms.isClear())
{ {
CGoGNout << "Orbit " << i << " thread "<<j<< " : "; CGoGNout << "Orbit " << i << " thread " << j << " : ";
Mark m(1); Mark m(1);
for (unsigned i = 0; i< Mark::getNbMarks(); ++i) for (unsigned i = 0; i < Mark::getNbMarks(); ++i)
{ {
if (ms.testMark(m)) if (ms.testMark(m))
CGoGNout << m.getMarkVal()<< ", "; CGoGNout << m.getMarkVal() << ", ";
m.setMarkVal(m.getMarkVal()<<1); m.setMarkVal(m.getMarkVal()<<1);
} }
CGoGNout << CGoGNendl; CGoGNout << CGoGNendl;
...@@ -514,7 +498,6 @@ void GenericMap::dumpAttributesAndMarkers() ...@@ -514,7 +498,6 @@ void GenericMap::dumpAttributesAndMarkers()
} }
} }
void GenericMap::compact() void GenericMap::compact()
{ {
std::vector<unsigned int> oldnew; std::vector<unsigned int> oldnew;
...@@ -526,11 +509,11 @@ void GenericMap::compact() ...@@ -526,11 +509,11 @@ void GenericMap::compact()
{ {
m_attribs[orbit].compact(oldnew); m_attribs[orbit].compact(oldnew);
for (unsigned int i = m_attribs[DART].begin(); i!= m_attribs[DART].end(); m_attribs[DART].next(i)) 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& idx = m_embeddings[orbit]->operator [](i);
unsigned int jdx = oldnew[idx]; unsigned int jdx = oldnew[idx];
if ((jdx != 0xffffffff) && (jdx!=idx)) if ((jdx != 0xffffffff) && (jdx != idx))
idx = jdx; idx = jdx;
} }
} }
...@@ -832,5 +815,3 @@ void GenericMap::boundaryUnmarkAll() ...@@ -832,5 +815,3 @@ void GenericMap::boundaryUnmarkAll()
// //
// return true ; // return true ;
//} //}
...@@ -27,6 +27,17 @@ ...@@ -27,6 +27,17 @@
namespace CGoGN namespace CGoGN
{ {
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;
}
}
/*! @name Constructors and Destructors /*! @name Constructors and Destructors
* To generate or delete edges in a 0-G-map * To generate or delete edges in a 0-G-map
*************************************************************************/ *************************************************************************/
...@@ -45,15 +56,4 @@ void GMap0::deleteEdge(Dart d) ...@@ -45,15 +56,4 @@ 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
...@@ -27,6 +27,25 @@ ...@@ -27,6 +27,25 @@
namespace CGoGN namespace CGoGN
{ {
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;
}
}
}
/*! @name Constructors and Destructors /*! @name Constructors and Destructors
* To generate or delete faces in a 1-G-map * To generate or delete faces in a 1-G-map
*************************************************************************/ *************************************************************************/
...@@ -75,24 +94,4 @@ void GMap1::deleteFace(Dart d) ...@@ -75,24 +94,4 @@ 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
...@@ -28,6 +28,31 @@ ...@@ -28,6 +28,31 @@
namespace CGoGN namespace CGoGN
{ {
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;
}
}
}
/*! @name Generator and Deletor /*! @name Generator and Deletor
* To generate or delete faces in a 2-G-map * To generate or delete faces in a 2-G-map
*************************************************************************/ *************************************************************************/
...@@ -895,32 +920,4 @@ void GMap2::closeMap() ...@@ -895,32 +920,4 @@ 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