Commit 0ea6813e authored by Pierre Kraemer's avatar Pierre Kraemer

update load & save

parent cb65f5ab
...@@ -68,7 +68,7 @@ AttributeHandler_IHM<T, ORBIT> ImplicitHierarchicalMap3::getAttribute(const std: ...@@ -68,7 +68,7 @@ AttributeHandler_IHM<T, ORBIT> ImplicitHierarchicalMap3::getAttribute(const std:
inline void ImplicitHierarchicalMap3::update_topo_shortcuts() inline void ImplicitHierarchicalMap3::update_topo_shortcuts()
{ {
Map3::update_topo_shortcuts(); // Map3::update_topo_shortcuts();
m_dartLevel = Map3::getAttribute<unsigned int, DART>("dartLevel") ; m_dartLevel = Map3::getAttribute<unsigned int, DART>("dartLevel") ;
m_faceId = Map3::getAttribute<unsigned int, DART>("faceId") ; m_faceId = Map3::getAttribute<unsigned int, DART>("faceId") ;
m_edgeId = Map3::getAttribute<unsigned int, DART>("edgeId") ; m_edgeId = Map3::getAttribute<unsigned int, DART>("edgeId") ;
......
...@@ -344,17 +344,13 @@ public: ...@@ -344,17 +344,13 @@ public:
/**************************************** /****************************************
* SAVE & LOAD * * SAVE & LOAD *
****************************************/ ****************************************/
protected:
/**
* update the pointer of embedding vector after loading
*/
void update_m_emb_afterLoad();
/** /**
* update the markTables and recursively from real type the topo shortcut pointers * restore embedding / markers / quick traversal shortcuts
*/ */
virtual void update_topo_shortcuts(); void restore_shortcuts();
public:
/** /**
* Save map in a binary file * Save map in a binary file
* @param filename the file name * @param filename the file name
...@@ -379,11 +375,13 @@ public: ...@@ -379,11 +375,13 @@ public:
*/ */
void dumpAttributesAndMarkers() ; void dumpAttributesAndMarkers() ;
protected:
/** /**
* 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 ;
public:
/** /**
* compact the map * compact the map
*/ */
......
...@@ -70,6 +70,9 @@ protected: ...@@ -70,6 +70,9 @@ protected:
inline void addPermutation(); inline void addPermutation();
virtual unsigned int getNbInvolutions() const = 0;
virtual unsigned int getNbPermutations() const = 0;
template <int I> template <int I>
inline Dart getInvolution(Dart d) const; inline Dart getInvolution(Dart d) const;
...@@ -80,16 +83,16 @@ protected: ...@@ -80,16 +83,16 @@ protected:
inline Dart getPermutationInv(Dart d) const; inline Dart getPermutationInv(Dart d) const;
template <int I> template <int I>
inline void permutationSew(Dart d, Dart e); inline void involutionSew(Dart d, Dart e);
template <int I> template <int I>
inline void permutationUnsew(Dart d); inline void involutionUnsew(Dart d);
template <int I> template <int I>
inline void involutionSew(Dart d, Dart e); inline void permutationSew(Dart d, Dart e);
template <int I> template <int I>
inline void involutionUnsew(Dart d); inline void permutationUnsew(Dart d);
inline virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew); inline virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
...@@ -125,6 +128,8 @@ public: ...@@ -125,6 +128,8 @@ public:
bool loadMapBin(const std::string& filename); bool loadMapBin(const std::string& filename);
bool copyFrom(const GenericMap& map); bool copyFrom(const GenericMap& map);
void restore_topo_shortcuts();
} ; } ;
} //namespace CGoGN } //namespace CGoGN
......
...@@ -107,6 +107,23 @@ inline Dart MapMono::getPermutationInv(Dart d) const ...@@ -107,6 +107,23 @@ inline Dart MapMono::getPermutationInv(Dart d) const
return (*m_permutation_inv[I])[d.index]; return (*m_permutation_inv[I])[d.index];
} }
template <int I>
inline void MapMono::involutionSew(Dart d, Dart e)
{
assert((*m_involution[I])[d.index] == d) ;
assert((*m_involution[I])[e.index] == e) ;
(*m_involution[I])[d.index] = e ;
(*m_involution[I])[e.index] = d ;
}
template <int I>
inline void MapMono::involutionUnsew(Dart d)
{
Dart e = (*m_involution[I])[d.index] ;
(*m_involution[I])[d.index] = d ;
(*m_involution[I])[e.index] = e ;
}
template <int I> template <int I>
inline void MapMono::permutationSew(Dart d, Dart e) inline void MapMono::permutationSew(Dart d, Dart e)
{ {
...@@ -129,23 +146,6 @@ inline void MapMono::permutationUnsew(Dart d) ...@@ -129,23 +146,6 @@ inline void MapMono::permutationUnsew(Dart d)
(*m_permutation_inv[I])[e.index] = e ; (*m_permutation_inv[I])[e.index] = e ;
} }
template <int I>
inline void MapMono::involutionSew(Dart d, Dart e)
{
assert((*m_involution[I])[d.index] == d) ;
assert((*m_involution[I])[e.index] == e) ;
(*m_involution[I])[d.index] = e ;
(*m_involution[I])[e.index] = d ;
}
template <int I>
inline void MapMono::involutionUnsew(Dart d)
{
Dart e = (*m_involution[I])[d.index] ;
(*m_involution[I])[d.index] = d ;
(*m_involution[I])[e.index] = e ;
}
inline void MapMono::compactTopoRelations(const std::vector<unsigned int>& oldnew) inline void MapMono::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)) for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i))
......
...@@ -33,6 +33,7 @@ namespace CGoGN ...@@ -33,6 +33,7 @@ namespace CGoGN
class MapMulti : public GenericMap class MapMulti : public GenericMap
{ {
template<typename MAP> friend class DartMarkerTmpl ; template<typename MAP> friend class DartMarkerTmpl ;
template<typename MAP> friend class DartMarkerStore ;
public: public:
MapMulti() MapMulti()
...@@ -137,6 +138,9 @@ protected: ...@@ -137,6 +138,9 @@ protected:
inline void addPermutation(); inline void addPermutation();
virtual unsigned int getNbInvolutions() const = 0;
virtual unsigned int getNbPermutations() const = 0;
template <int I> template <int I>
inline Dart getInvolution(Dart d) const; inline Dart getInvolution(Dart d) const;
...@@ -147,16 +151,16 @@ protected: ...@@ -147,16 +151,16 @@ protected:
inline Dart getPermutationInv(Dart d) const; inline Dart getPermutationInv(Dart d) const;
template <int I> template <int I>
inline void permutationSew(Dart d, Dart e); inline void involutionSew(Dart d, Dart e);
template <int I> template <int I>
inline void permutationUnsew(Dart d); inline void involutionUnsew(Dart d);
template <int I> template <int I>
inline void involutionSew(Dart d, Dart e); inline void permutationSew(Dart d, Dart e);
template <int I> template <int I>
inline void involutionUnsew(Dart d); inline void permutationUnsew(Dart d);
inline virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew); inline virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
...@@ -283,6 +287,8 @@ public: ...@@ -283,6 +287,8 @@ public:
bool loadMapBin(const std::string& filename); bool loadMapBin(const std::string& filename);
bool copyFrom(const GenericMap& map); bool copyFrom(const GenericMap& map);
void restore_topo_shortcuts();
} ; } ;
} //namespace CGoGN } //namespace CGoGN
......
...@@ -224,6 +224,24 @@ inline Dart MapMulti::getPermutationInv(Dart d) const ...@@ -224,6 +224,24 @@ inline Dart MapMulti::getPermutationInv(Dart d) const
return (*m_permutation_inv[I])[dartIndex(d)]; return (*m_permutation_inv[I])[dartIndex(d)];
} }
template <int I>
inline void MapMulti::involutionSew(Dart d, Dart e)
{
assert((*m_involution[I])[dartIndex(d)] == d) ;
assert((*m_involution[I])[dartIndex(e)] == e) ;
(*m_involution[I])[dartIndex(d)] = e ;
(*m_involution[I])[dartIndex(e)] = d ;
}
template <int I>
inline void MapMulti::involutionUnsew(Dart d)
{
unsigned int d_index = dartIndex(d);
Dart e = (*m_involution[I])[d_index] ;
(*m_involution[I])[d_index] = d ;
(*m_involution[I])[dartIndex(e)] = e ;
}
template <int I> template <int I>
inline void MapMulti::permutationSew(Dart d, Dart e) inline void MapMulti::permutationSew(Dart d, Dart e)
{ {
...@@ -250,24 +268,6 @@ inline void MapMulti::permutationUnsew(Dart d) ...@@ -250,24 +268,6 @@ inline void MapMulti::permutationUnsew(Dart d)
(*m_permutation_inv[I])[e_index] = e ; (*m_permutation_inv[I])[e_index] = e ;
} }
template <int I>
inline void MapMulti::involutionSew(Dart d, Dart e)
{
assert((*m_involution[I])[dartIndex(d)] == d) ;
assert((*m_involution[I])[dartIndex(e)] == e) ;
(*m_involution[I])[dartIndex(d)] = e ;
(*m_involution[I])[dartIndex(e)] = d ;
}
template <int I>
inline void MapMulti::involutionUnsew(Dart d)
{
unsigned int d_index = dartIndex(d);
Dart e = (*m_involution[I])[d_index] ;
(*m_involution[I])[d_index] = d ;
(*m_involution[I])[dartIndex(e)] = e ;
}
inline void MapMulti::compactTopoRelations(const std::vector<unsigned int>& oldnew) inline void MapMulti::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)) for (unsigned int i = m_attribs[DART].begin(); i != m_attribs[DART].end(); m_attribs[DART].next(i))
......
...@@ -55,7 +55,8 @@ public: ...@@ -55,7 +55,8 @@ public:
virtual void clear(bool removeAttrib); virtual void clear(bool removeAttrib);
virtual void update_topo_shortcuts(); virtual unsigned int getNbInvolutions() const;
virtual unsigned int getNbPermutations() const;
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
......
...@@ -60,10 +60,15 @@ inline void GMap0<MAP_IMPL>::clear(bool removeAttrib) ...@@ -60,10 +60,15 @@ inline void GMap0<MAP_IMPL>::clear(bool removeAttrib)
} }
template <typename MAP_IMPL> template <typename MAP_IMPL>
inline void GMap0<MAP_IMPL>::update_topo_shortcuts() inline unsigned int GMap0<MAP_IMPL>::getNbInvolutions() const
{ {
MAP_IMPL::update_topo_shortcuts(); return 1;
// m_beta0 = getRelation("beta0"); }
template <typename MAP_IMPL>
inline unsigned int GMap0<MAP_IMPL>::getNbPermutations() const
{
return 0;
} }
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
......
...@@ -53,7 +53,8 @@ public: ...@@ -53,7 +53,8 @@ public:
virtual void clear(bool removeAttrib); virtual void clear(bool removeAttrib);
virtual void update_topo_shortcuts(); virtual unsigned int getNbInvolutions() const;
virtual unsigned int getNbPermutations() const;
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
......
...@@ -58,10 +58,15 @@ inline void GMap1<MAP_IMPL>::clear(bool removeAttrib) ...@@ -58,10 +58,15 @@ inline void GMap1<MAP_IMPL>::clear(bool removeAttrib)
} }
template <typename MAP_IMPL> template <typename MAP_IMPL>
inline void GMap1<MAP_IMPL>::update_topo_shortcuts() inline unsigned int GMap1<MAP_IMPL>::getNbInvolutions() const
{ {
ParentMap::update_topo_shortcuts(); return 1 + ParentMap::getNbInvolutions();
// m_beta1 = getRelation("beta1"); }
template <typename MAP_IMPL>
inline unsigned int GMap1<MAP_IMPL>::getNbPermutations() const
{
return ParentMap::getNbPermutations();
} }
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
......
...@@ -60,7 +60,8 @@ public: ...@@ -60,7 +60,8 @@ public:
virtual void clear(bool removeAttrib); virtual void clear(bool removeAttrib);
virtual void update_topo_shortcuts(); virtual unsigned int getNbInvolutions() const;
virtual unsigned int getNbPermutations() const;
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
......
...@@ -58,10 +58,15 @@ inline void GMap2<MAP_IMPL>::clear(bool removeAttrib) ...@@ -58,10 +58,15 @@ inline void GMap2<MAP_IMPL>::clear(bool removeAttrib)
} }
template <typename MAP_IMPL> template <typename MAP_IMPL>
inline void GMap2<MAP_IMPL>::update_topo_shortcuts() inline unsigned int GMap2<MAP_IMPL>::getNbInvolutions() const
{ {
ParentMap::update_topo_shortcuts(); return 1 + ParentMap::getNbInvolutions();
// m_beta2 = getRelation("beta2"); }
template <typename MAP_IMPL>
inline unsigned int GMap2<MAP_IMPL>::getNbPermutations() const
{
return ParentMap::getNbPermutations();
} }
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
......
...@@ -66,7 +66,8 @@ public: ...@@ -66,7 +66,8 @@ public:
virtual void clear(bool removeAttrib); virtual void clear(bool removeAttrib);
virtual void update_topo_shortcuts(); virtual unsigned int getNbInvolutions() const;
virtual unsigned int getNbPermutations() const;
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
......
...@@ -60,10 +60,15 @@ inline void GMap3<MAP_IMPL>::clear(bool removeAttrib) ...@@ -60,10 +60,15 @@ inline void GMap3<MAP_IMPL>::clear(bool removeAttrib)
} }
template <typename MAP_IMPL> template <typename MAP_IMPL>
inline void GMap3<MAP_IMPL>::update_topo_shortcuts() inline unsigned int GMap3<MAP_IMPL>::getNbInvolutions() const
{ {
ParentMap::update_topo_shortcuts(); return 1 + ParentMap::getNbInvolutions();
// m_beta3 = getRelation("beta3"); }
template <typename MAP_IMPL>
inline unsigned int GMap3<MAP_IMPL>::getNbPermutations() const
{
return ParentMap::getNbPermutations();
} }
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
......
...@@ -60,7 +60,7 @@ AttributeHandler_IHM<T, ORBIT> ImplicitHierarchicalMap2::getAttribute(const std: ...@@ -60,7 +60,7 @@ AttributeHandler_IHM<T, ORBIT> ImplicitHierarchicalMap2::getAttribute(const std:
inline void ImplicitHierarchicalMap2::update_topo_shortcuts() inline void ImplicitHierarchicalMap2::update_topo_shortcuts()
{ {
Map2::update_topo_shortcuts(); // Map2::update_topo_shortcuts();
m_dartLevel = Map2::getAttribute<unsigned int, DART>("dartLevel") ; m_dartLevel = Map2::getAttribute<unsigned int, DART>("dartLevel") ;
m_edgeId = Map2::getAttribute<unsigned int, DART>("edgeId") ; m_edgeId = Map2::getAttribute<unsigned int, DART>("edgeId") ;
......
...@@ -59,7 +59,8 @@ public: ...@@ -59,7 +59,8 @@ public:
virtual void clear(bool removeAttrib); virtual void clear(bool removeAttrib);
virtual void update_topo_shortcuts(); virtual unsigned int getNbInvolutions() const;
virtual unsigned int getNbPermutations() const;
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
......
...@@ -60,11 +60,15 @@ inline void Map1<MAP_IMPL>::clear(bool removeAttrib) ...@@ -60,11 +60,15 @@ inline void Map1<MAP_IMPL>::clear(bool removeAttrib)
} }
template <typename MAP_IMPL> template <typename MAP_IMPL>
inline void Map1<MAP_IMPL>::update_topo_shortcuts() inline unsigned int Map1<MAP_IMPL>::getNbInvolutions() const
{ {
MAP_IMPL::update_topo_shortcuts(); return 0;
// m_phi1 = MAP::getRelation("phi1"); }
// m_phi_1 = MAP::getRelation("phi_1");
template <typename MAP_IMPL>
inline unsigned int Map1<MAP_IMPL>::getNbPermutations() const
{
return 1;
} }
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
......
...@@ -72,7 +72,8 @@ public: ...@@ -72,7 +72,8 @@ public:
virtual void clear(bool removeAttrib); virtual void clear(bool removeAttrib);
virtual void update_topo_shortcuts(); virtual unsigned int getNbInvolutions() const;
virtual unsigned int getNbPermutations() const;
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
......
...@@ -58,10 +58,15 @@ inline void Map2<MAP_IMPL>::clear(bool removeAttrib) ...@@ -58,10 +58,15 @@ inline void Map2<MAP_IMPL>::clear(bool removeAttrib)
} }
template <typename MAP_IMPL> template <typename MAP_IMPL>
inline void Map2<MAP_IMPL>::update_topo_shortcuts() inline unsigned int Map2<MAP_IMPL>::getNbInvolutions() const
{ {
ParentMap::update_topo_shortcuts(); return 1 + ParentMap::getNbInvolutions();
// m_phi2 = getRelation("phi2"); }
template <typename MAP_IMPL>
inline unsigned int Map2<MAP_IMPL>::getNbPermutations() const
{
return ParentMap::getNbPermutations();
} }
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
......
...@@ -80,7 +80,8 @@ public: ...@@ -80,7 +80,8 @@ public:
virtual void clear(bool removeAttrib); virtual void clear(bool removeAttrib);
virtual void update_topo_shortcuts(); virtual unsigned int getNbInvolutions() const;
virtual unsigned int getNbPermutations() const;
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
* Access and Modification * Access and Modification
......
...@@ -60,10 +60,15 @@ inline void Map3<MAP_IMPL>::clear(bool removeAttrib) ...@@ -60,10 +60,15 @@ inline void Map3<MAP_IMPL>::clear(bool removeAttrib)
} }
template <typename MAP_IMPL> template <typename MAP_IMPL>
inline void Map3<MAP_IMPL>::update_topo_shortcuts() inline unsigned int Map3<MAP_IMPL>::getNbInvolutions() const
{ {
ParentMap::update_topo_shortcuts(); return 1 + ParentMap::getNbInvolutions();
// m_phi3 = getRelation("phi3"); }
template <typename MAP_IMPL>
inline unsigned int Map3<MAP_IMPL>::getNbPermutations() const
{
return ParentMap::getNbPermutations();
} }
/*! @name Basic Topological Operators /*! @name Basic Topological Operators
......
...@@ -324,8 +324,10 @@ void GenericMap::removeThreadMarker(unsigned int nb) ...@@ -324,8 +324,10 @@ void GenericMap::removeThreadMarker(unsigned int nb)
* SAVE & LOAD * * SAVE & LOAD *
****************************************/ ****************************************/
void GenericMap::update_m_emb_afterLoad() void GenericMap::restore_shortcuts()
{ {
// EMBEDDING
// get container of dart orbit // get container of dart orbit
AttributeContainer& cont = m_attribs[DART] ; AttributeContainer& cont = m_attribs[DART] ;
...@@ -344,15 +346,28 @@ void GenericMap::update_m_emb_afterLoad() ...@@ -344,15 +346,28 @@ void GenericMap::update_m_emb_afterLoad()
m_embeddings[orb] = amv ; m_embeddings[orb] = amv ;
} }
} }
}
void GenericMap::update_topo_shortcuts() // MARKERS & QUICK TRAVERSAL
{
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];
// get the list of attributes of orbit container // QUICK TRAVERSAL
m_quickTraversal[orbit] = cont.getDataVector<Dart>("quick_traversal") ;
for(unsigned int j = 0; j < NB_ORBITS; ++j)
{
std::stringstream ss;
ss << "quickLocalIncidentTraversal_" << j;
m_quickLocalIncidentTraversal[orbit][j] = cont.getDataVector< NoTypeNameAttribute<std::vector<Dart> > >(ss.str()) ;
std::stringstream ss2;
ss2 << "quickLocalAdjacentTraversal" << j;
m_quickLocalAdjacentTraversal[orbit][j] = cont.getDataVector< NoTypeNameAttribute<std::vector<Dart> > >(ss2.str()) ;
}
// MARKERS
std::vector<std::string> listeNames; std::vector<std::string> listeNames;
cont.getAttributesNames(listeNames); cont.getAttributesNames(listeNames);
...@@ -362,18 +377,16 @@ void GenericMap::update_topo_shortcuts() ...@@ -362,18 +377,16 @@ void GenericMap::update_topo_shortcuts()
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
{ {
// TODO Verifier ce qu fait exactement ce unsetMark sur m.invert ?? Mark m(m_boundaryMarkers[0] + m_boundaryMarkers[1]);
// Mark m(m_boundaryMarker);
Mark m(m_boundaryMarkers[0]+m_boundaryMarkers[1]);
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);
...@@ -387,39 +400,15 @@ void GenericMap::update_topo_shortcuts() ...@@ -387,39 +400,15 @@ void GenericMap::update_topo_shortcuts()
} }
} }
if (m_isMultiRes) // NB THREADS
{
std::vector<std::string> names;
m_mrattribs.getAttributesNames(names);
m_mrDarts.resize(names.size() - 1);
for (unsigned int i = 0; i < m_mrDarts.size(); ++i)
m_mrDarts[i] = NULL;
for (unsigned int i = 0; i < names.size(); ++i)
{
std::string sub = names[i].substr(0, 7);
if (sub == "MRLevel")
m_mrLevels = m_mrattribs.getDataVector<unsigned int>(i);