Commit e017aa7e authored by Pierre Kraemer's avatar Pierre Kraemer

presque fini la passe sur Map1 et Map2

parent d7cd1625
......@@ -51,7 +51,7 @@ typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const typename
{
typedef typename PFP::VEC3 VEC3 ;
if(map.isFaceTriangle(d))
if(map.faceDegree(d) == 3)
return triangleArea<PFP>(map, d, position) ;
else
{
......
......@@ -69,7 +69,7 @@ typename PFP::VEC3 newellNormal(typename PFP::MAP& map, Dart d, const typename P
template <typename PFP>
typename PFP::VEC3 faceNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{
if(map.isFaceTriangle(d))
if(map.faceDegree(d) == 3)
return triangleNormal<PFP>(map, d, position) ;
else
return newellNormal<PFP>(map, d, position) ;
......
......@@ -423,7 +423,7 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c
if(m_map.closeHole(d,false))
{
d = m_map.phi2(d);
if(!m_map.isFaceTriangle(d))
if(m_map.faceDegree(d) > 3)
{
Algo::Modelisation::trianguleFace<PFP>(m_map,d);
......@@ -452,7 +452,7 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c
if(m_map.closeHole(d,true))
{
d = m_map.phi2(d);
if(!m_map.isFaceTriangle(d))
if(m_map.faceDegree(d) > 3)
{
Algo::Modelisation::trianguleFace<PFP>(m_map,d);
......
......@@ -50,12 +50,6 @@ public:
*/
virtual bool deleteVertex(Dart d) ;
/**
* No attribute is attached to the new edge
* The attributes attached to the face of dart d are kept on the resulting face
*/
virtual void linkVertices(Dart d, Dart e) ;
/**
* No attribute is attached to the new vertex
* The attributes attached to the old edge are duplicated on both resulting edges
......@@ -91,23 +85,23 @@ public:
*/
virtual bool flipBackEdge(Dart d) ;
/**
* The attributes attached to the vertex of dart d are kept on the resulting vertex
* The attributes attached to the face of dart d are overwritten on the face of dart e
*/
virtual void insertEdgeInVertex(Dart d, Dart e);
/**
* The attributes attached to the vertex of dart d are kept on the resulting vertex
* The attributes attached to the face of dart d are overwritten on the face of dart e
*/
virtual void removeEdgeFromVertex(Dart d);
// /**
// * The attributes attached to the vertex of dart d are kept on the resulting vertex
// * The attributes attached to the face of dart d are overwritten on the face of dart e
// */
// virtual void insertEdgeInVertex(Dart d, Dart e);
//
// /**
// * The attributes attached to the vertex of dart d are kept on the resulting vertex
// * The attributes attached to the face of dart d are overwritten on the face of dart e
// */
// virtual void removeEdgeFromVertex(Dart d);
/**
* The attributes attached to the vertices of the edge of d are kept on the vertices of the resulting edge
* The attributes attached to the edge of d are kept on the resulting edge
*/
virtual void sewFaces(Dart d, Dart e, bool withBoundary=true) ;
virtual void sewFaces(Dart d, Dart e, bool withBoundary = true) ;
/**
* The attributes attached to the vertices of the old edge of d are duplicated on the vertices of both resulting edges
......
......@@ -111,7 +111,7 @@ public:
/*! @param nbEdges the number of edges
* @return return a dart of the face
*/
Dart newBoundaryCycle(unsigned nbEdges);
Dart newBoundaryCycle(unsigned int nbEdges);
//! Delete an oriented face erasing all its darts
/*! @param d a dart of the face
......@@ -125,44 +125,43 @@ public:
*************************************************************************/
//@{
//! Cut an edge inserting a new dart between d and its successor in the face
//! Cut an edge inserting a new dart between d and its successor in the cycle
/*! @param d the edge to cut
* \image hmtl map1_cutEdge.png
*/
void cutEdge(Dart d);
//! Collapse an edge of a face
//! Collapse an edge of a cycle
/*! \warning Dart d no longer exists after the call
* @param d the edge
*/
void collapseEdge(Dart d);
//! Split a face between vertices d and e
//! Split a cycle between vertices d and e
/*! \pre Dart d and e MUST be different and belong to the same face
* @param d first dart in the face
* @param e second dart in the face
*/
void splitFace(Dart d, Dart e);
void splitCycle(Dart d, Dart e);
//! Link two vertices belonging to distinct faces (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
* @param d first dart in the face
* @param e second dart in the face
*/
void linkVertices(Dart d, Dart e);
//! Merge the two faces of d and e, darts d & e disappear
//! Merge two cycles on vertices d and e
/*! \pre Dart d and e MUST belong to distinct faces
* \warning Darts d and e no longer exist after the call
* @param d a dart in the first face
* @param e a dart in the second face
*/
void mergeFaces(Dart d, Dart e);
void mergeCycles(Dart d, Dart e);
//! Link two vertices belonging to distinct cycles (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
* @param d first dart in the face
* @param e second dart in the face
*/
void linkCycles(Dart d, Dart e);
//! reverse a face (phi1 become phi_1 and ...)
/*! @param d a dart of face
*/
void reverseFace(Dart d) ;
void reverseCycle(Dart d) ;
//@}
/*! @name Topological Queries
......@@ -170,29 +169,23 @@ public:
*************************************************************************/
//@{
//! Test if dart d and e belong to the same oriented face
//! Test if darts d and e belong to the same cycle
/*! @param d a dart
* @param e a dart
*/
bool sameOrientedFace(Dart d, Dart e) ;
bool sameCycle(Dart d, Dart e) ;
//! Test if dart d and e belong to the same face
/*! @param d a dart
* @param e a dart
//! Length of a cycle (its number of oriented edges)
/*! @param d a dart of the cycle
* @return the length of the cycle
*/
bool sameFace(Dart d, Dart e) ;
//! Length of a face (its number of oriented edges)
/*! @param d a dart of the face
* @return the length of the face
*/
unsigned int faceDegree(Dart d) ;
unsigned int cycleDegree(Dart d) ;
/**
* check if the face of d is a triangle
* @return a boolean indicating if the face is a triangle
* check if the cycle of d is a triangle
* @return a boolean indicating if the cycle is a triangle
*/
bool isFaceTriangle(Dart d);
bool isCycleTriangle(Dart d);
//@}
/*! @name Cell Functors
......@@ -204,33 +197,37 @@ public:
/*! @param d a dart of the vertex
* @param f the functor to apply
*/
bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread=0);
bool foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of an edge
/*! @param d a dart of the edge
* @param f the functor to apply
*/
bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread=0);
bool foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of an oriented face
/*! @param d a dart of the face
* @param f the functor to apply
*/
bool foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread=0) ;
bool foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread = 0) ;
bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread=0);
//! Apply a functor on every dart of a face
/*! @param d a dart of the face
* @param f the functor to apply
*/
bool foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of a volume
/*! @param d a dart of the volume
* @param f the functor to apply
*/
bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread=0);
bool foreach_dart_of_volume(Dart d, FunctorType& f, unsigned int thread = 0);
//! Apply a functor on every dart of a connected component
/*! @param d a dart of the onnected component
/*! @param d a dart of the connected component
* @param f the functor to apply
*/
bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread=0);
bool foreach_dart_of_cc(Dart d, FunctorType& f, unsigned int thread = 0);
//@}
} ;
......
......@@ -151,37 +151,57 @@ inline void Map1::collapseEdge(Dart d)
deleteDart(d) ; // Dart d is erased
}
inline void Map1::splitFace(Dart d, Dart e)
inline void Map1::splitCycle(Dart d, Dart e)
{
assert(d != e && sameOrientedFace(d, e)) ;
Map1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d)
Map1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart before e)
phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts
assert(d != e && sameCycle(d, e)) ;
phi1sew(phi_1(d), phi_1(e)) ;
}
inline void Map1::linkVertices(Dart d, Dart e)
inline void Map1::mergeCycles(Dart d, Dart e)
{
assert(d != e && !sameOrientedFace(d, e)) ;
Map1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d)
Map1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart before e)
phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts
assert(!sameCycle(d, e)) ;
phi1sew(phi_1(d), phi_1(e)) ;
}
inline void Map1::mergeFaces(Dart d, Dart e)
inline void Map1::linkCycles(Dart d, Dart e)
{
assert(!sameOrientedFace(d, e)) ;
phi1sew(d, phi_1(e)) ;
phi1sew(e, phi_1(d)) ;
deleteCycle(d) ;
assert(d != e && !sameCycle(d, e)) ;
Map1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d)
Map1::cutEdge(phi_1(e)); // cut the edge before e (insert a new dart before e)
phi1sew(phi_1(d), phi_1(e)) ; // phi1sew between the 2 new inserted darts
}
/*! @name Topological Queries
* Return or set various topological information
*************************************************************************/
inline bool Map1::sameFace(Dart d, Dart e)
inline bool Map1::sameCycle(Dart d, Dart e)
{
return sameOrientedFace(d, e) ;
Dart it = d ;
do
{
if(it == e)
return true ;
it = phi1(it) ;
} while(it != d) ;
return false ;
}
inline unsigned int Map1::cycleDegree(Dart d)
{
unsigned int count = 0 ;
Dart it = d ;
do
{
++count ;
it = phi1(it) ;
} while (it != d) ;
return count ;
}
inline bool Map1::isCycleTriangle(Dart d)
{
return (phi1(d) != d) && (phi1(phi1(phi1(d))) == d) ;
}
/*! @name Cell Functors
......@@ -198,6 +218,18 @@ inline bool Map1::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thre
return f(d) ;
}
inline bool Map1::foreach_dart_of_oriented_face(Dart d, FunctorType& f, unsigned int thread)
{
Dart it = d ;
do
{
if (f(it))
return true ;
it = phi1(it) ;
} while (it != d) ;
return false ;
}
inline bool Map1::foreach_dart_of_face(Dart d, FunctorType& f, unsigned int thread)
{
return foreach_dart_of_oriented_face(d, f, thread) ;
......
......@@ -99,15 +99,15 @@ protected:
* Function used to merge boundary faces properly
*************************************************************************/
//! merge a face that has been tag as boundary with existing boundary if needed
/* @param d a dart of the face
*/
void mergeFaceWithBoundary(Dart d);
// /**
// * merge two faces of boundary
// */
// void mergeBoundaryFaces(Dart dd, Dart ee);
/**
* merge two faces of boundary
*/
void mergeBoundaryFaces(Dart dd, Dart ee);
// //! merge a face that has been tag as boundary with existing boundary if needed
// /* @param d a dart of the face
// */
// void mergeFaceWithBoundary(Dart d);
/*! @name Generator and Deletor
* To generate or delete faces in a 2-map
......@@ -122,14 +122,18 @@ public:
* @param withBoudary create the face and its boundary (default true)
* @return return a dart of the face
*/
virtual Dart newFace(unsigned int nbEdges, bool withBoundary=true) ;
virtual Dart newFace(unsigned int nbEdges, bool withBoundary = true) ;
//! Delete an oriented face erasing all its darts (not really tags as boundary).
/*! The phi2-links around the face are removed
* @param d a dart of the face
//! Delete the face of d
/*! @param d a dart of the face
*/
virtual void deleteFace(Dart d) ;
//! Fill a hole with a face
/*! \pre Dart d is boundary marked
* @param d a dart of the face to fill
*/
virtual void fillHole(Dart d) ;
//@}
/*! @name Topological Operators
......@@ -152,13 +156,6 @@ public:
*/
virtual bool deleteVertex(Dart d);
//! Link two vertices belonging to distinct faces (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
* @param d first dart in the face
* @param e second dart in the face
*/
virtual void linkVertices(Dart d, Dart e); //TODO remove ??
//! Cut the edge of d by inserting a new vertex
/*! @param d a dart of the edge to cut
*/
......@@ -198,27 +195,28 @@ public:
*/
virtual bool flipBackEdge(Dart d);
//! Insert an edge after a dart in the vertex orbit
/*! \pre Dart d and e MUST be different and belong to distinct face
* \pre Dart e must be phi2-linked with its phi_1 dart
* @param d dart of the vertex
* @param e dart of the edge
*/
virtual void insertEdgeInVertex(Dart d, Dart e);
//! Remove an edge from a vertex orbit
/*! \pre Dart d must be phi2 sewn
* @param d the dart of the edge to remove from the vertex
*/
virtual void removeEdgeFromVertex(Dart d);
// //! Insert an edge after a dart in the vertex orbit
// /*! \pre Dart d and e MUST be different and belong to distinct face
// * \pre Dart e must be phi2-linked with its phi_1 dart
// * @param d dart of the vertex
// * @param e dart of the edge
// */
// virtual void insertEdgeInVertex(Dart d, Dart e);
//
// //! Remove an edge from a vertex orbit
// /*! \pre Dart d must be phi2 sewed
// * @param d the dart of the edge to remove from the vertex
// * @return true if the removal has been executed, false otherwise
// */
// virtual bool removeEdgeFromVertex(Dart d);
//! Sew two oriented faces along oriented edges
/*! \pre Edges of darts d & e MUST be boundary edges
* @param d a dart of the first face
* @param e a dart of the second face
* @param withBoundary: face have no fixed points (false only for construction: import/primitives)
* @param withBoundary: if false, faces have phi2 fixed points (only for construction: import/primitives)
*/
virtual void sewFaces(Dart d, Dart e, bool withBoundary=true);
virtual void sewFaces(Dart d, Dart e, bool withBoundary = true);
//! Unsew two oriented faces along oriented edges
/*! @param d a dart of one face
......@@ -262,19 +260,11 @@ public:
void insertTrianglePair(Dart d, Dart v1, Dart v2) ;
/**
* Unsew the faces consisting of the umbrella of a vertex
* \warning Darts may have
* Unsew the faces of the umbrella of the vertex of d
* @param d a dart from the vertex
*/
void unsewAroundVertex(Dart d) ;
/**
* Unsew the Umbrella aroud a vertex, close the hole and then
* create a symetric to construct a polyedron
* @param d a dart from the vertex
*/
// void explodPolyhedron(Dart d); //TODO modification for new boundary managing method ???
//! Merge two volumes along two faces.
/*! Works only if the two faces have the same number of edges.
* The faces adjacent to the two given faces are pairwise phi2-linked
......@@ -311,11 +301,22 @@ public:
*/
bool sameVertex(Dart d, Dart e) ;
//! Test if dart d and e belong to the same face
/*! @param d a dart
* @param e a dart
*/
bool sameFace(Dart d, Dart e) ;
/**
* compute the number of edges of the vertex of d
*/
unsigned int vertexDegree(Dart d) ;
/**
* compute the number of edges of the face of d
*/
unsigned int faceDegree(Dart d) ;
/**
* compute the number of faces in the volume of d
*/
......@@ -420,7 +421,7 @@ public:
* @param forboundary tag the created face as boundary (default is true)
* @return the degree of the created face
*/
virtual unsigned int closeHole(Dart d, bool forboundary=true);
virtual unsigned int closeHole(Dart d, bool forboundary = true);
//! Close the map removing topological holes: DO NOT USE, only for import algorithm
/*! Add faces to the map that close every existing hole.
......
......@@ -101,48 +101,11 @@ inline Dart Map2::alpha1(Dart d)
return phi2(phi_1(d)) ;
}
// alpha1 avec bord: bye bye
//inline Dart Map2::alpha1(Dart d)
//{
// Dart e = phi_1(d);
// Dart f = phi2(e);
//
// if (f != e)
// return f;
//
// f = d;
// e = phi2(f);
// while (e != f)
// {
// f = phi1(e);
// e = phi2(f);
// }
// return f;
//}
inline Dart Map2::alpha_1(Dart d)
{
return phi1(phi2(d)) ;
}
// alpha_1 avec bord : bye bye !!
//inline Dart Map2::alpha_1(Dart d)
//{
// Dart e = phi2(d);
//
// if (e != d)
// return phi1(e);
//
// e = d;
// Dart f = phi_1(d);
// while (phi2(f) != f)
// {
// e = phi2(f);
// f = phi_1(e);
// }
// return e;
//}
inline void Map2::phi2sew(Dart d, Dart e)
{
assert((*m_phi2)[d.index] == d) ;
......@@ -158,7 +121,6 @@ inline void Map2::phi2unsew(Dart d)
(*m_phi2)[e.index] = e ;
}
/*! @name Topological Queries
* Return or set various topological information
*************************************************************************/
......@@ -168,6 +130,16 @@ inline bool Map2::sameVertex(Dart d, Dart e)
return sameOrientedVertex(d, e) ;
}
inline bool Map2::sameFace(Dart d, Dart e)
{
return Map1::sameCycle(d, e) ;
}
inline unsigned int Map2::faceDegree(Dart d)
{
return Map1::cycleDegree(d) ;
}
/*! @name Cell Functors
* Apply functors to all darts of a cell
*************************************************************************/
......
......@@ -630,33 +630,14 @@ bool GenericMap::foreach_dart_of_orbit(unsigned int orbit, Dart d, FunctorType&
bool GenericMap::foreach_orbit(unsigned int orbit, FunctorType& fonct, const FunctorSelect& good, unsigned int thread)
{
TraversorCell<GenericMap> trav(*this, orbit, good, thread);
bool found = false; // Store the result
bool found = false;
for (Dart d = trav.begin(); !found && d != trav.end(); d = trav.next())
{
if ((fonct)(d)) // Apply functor
if ((fonct)(d))
found = true;
}
return found;
// DartMarker marker(*this, thread); // Lock a marker
// bool found = false; // Store the result
//
// // Scan all darts of the map
// for (Dart d = begin(); !found && d != end(); next(d))
// {
// if (good(d)) // If d is selected
// {
// if (!marker.isMarked(d)) // If d is in a not yet visited cell
// {
// if ((fonct)(d)) // Apply functor
// found = true;
// else
// marker.markOrbit(orbit, d); // Mark the cell as visited
// }
// }
// }
// return found;
}
unsigned int GenericMap::getNbOrbits(unsigned int orbit, const FunctorSelect& good)
......@@ -669,28 +650,27 @@ unsigned int GenericMap::getNbOrbits(unsigned int orbit, const FunctorSelect& go
void GenericMap::viewAttributesTables()
{
std::cout << "======================="<< std::endl;
for (unsigned int i=0; i< NB_ORBITS; ++i)
for (unsigned int i = 0; i < NB_ORBITS; ++i)
{
std::cout << "ATTRIBUTE_CONTAINER "<<i<< std::endl;
std::cout << "ATTRIBUTE_CONTAINER " << i << std::endl;
AttributeContainer& cont = m_attribs[i] ;
// get the list of attributes
std::vector<std::string> listeNames;
cont.getAttributesNames(listeNames);
for (std::vector<std::string>::iterator it=listeNames.begin(); it!=listeNames.end(); ++it)
std::cout<< " " << *it << std::endl;
std::cout << "-------------------------"<< std::endl;
for (std::vector<std::string>::iterator it = listeNames.begin(); it != listeNames.end(); ++it)
std::cout << " " << *it << std::endl;
std::cout << "-------------------------" << std::endl;
}
std::cout << "m_embeddings: "<<std::hex;
for (unsigned int i=0; i< NB_ORBITS; ++i)
std::cout << "m_embeddings: " << std::hex;
for (unsigned int i = 0; i < NB_ORBITS; ++i)
std::cout << (long)(m_embeddings[i]) << " / ";
std::cout << std::endl<< "-------------------------"<< std::endl;
std::cout << std::endl << "-------------------------" << std::endl;
std::cout << "m_markTables: ";
for (unsigned int i=0; i< NB_ORBITS; ++i)
for (unsigned int i = 0; i < NB_ORBITS; ++i)
std::cout << (long)(m_markTables[i][0]) << " / ";
std::cout << std::endl<< "-------------------------"<< std::endl<< std::dec;
std::cout << std::endl << "-------------------------" << std::endl << std::dec;
}
void GenericMap::boundaryMark(Dart d)
......@@ -708,21 +688,18 @@ bool GenericMap::isBoundaryMarked(Dart d)
return m_markTables[DART][0]->operator[](d.index).testMark(m_boundaryMarker);
}
void GenericMap::boundaryMarkOrbit(unsigned int orbit, Dart d)