Commit 9de12949 authored by Thomas's avatar Thomas

Merge branch 'master' of cgogn.u-strasbg.fr:~untereiner/CGoGN

Conflicts:
	src/Topology/map/map3.cpp
parents 40d944d0 4d495942
......@@ -31,6 +31,7 @@
#include "Topology/generic/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Algo/Import/import.h"
#include "Algo/Geometry/boundingbox.h"
......
......@@ -26,6 +26,7 @@
#include "Topology/generic/parameters.h"
#include "Topology/map/map2.h"
#include "Topology/gmap/gmap2.h"
#include "Topology/generic/mapBrowser.h"
#include "Algo/Geometry/boundingbox.h"
......@@ -41,7 +42,7 @@ using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition de la carte
typedef Map2 MAP;
typedef GMap2 MAP;
};
PFP::MAP myMap;
......
......@@ -274,6 +274,10 @@ public:
*/
bool neighborhoodLevelDiffersByOne(Dart d);
/**
* wired !!!
*/
bool coarsenNeighborhoodLevelDiffersByOne(Dart d);
} ;
template <typename T>
......
......@@ -244,7 +244,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType
bool found = false; // Last functor return value
std::vector<Dart> darts_list; //Darts that are traversed
darts_list.reserve(50);
darts_list.reserve(512);
darts_list.push_back(d); //Start with the dart d
mv.mark(d);
......@@ -288,11 +288,8 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_edge(Dart d, FunctorType&
if (f(dNext))
return true;
Dart d2 = phi2(dNext);
if (d2 != dNext)
return f(d2);
else
return false;
if (f(phi2(dNext)))
return true;
dNext = alpha2(dNext);
} while (dNext != d);
......
......@@ -41,11 +41,15 @@ enum SubdivideType
S_QUAD
} ;
/***********************************************************************************
* Subdivision *
***********************************************************************************/
template <typename PFP>
void subdivideEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ;
template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType = S_TRI);
template <typename PFP>
Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
......@@ -54,16 +58,18 @@ template <typename PFP>
Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
Dart subdivideVolumeOld(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
//template <typename PFP>
//void subdivideLoop(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
/***********************************************************************************
* Simplification *
***********************************************************************************/
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType = S_TRI);
template <typename PFP>
void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
......@@ -77,27 +83,7 @@ void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
template <typename PFP>
void splitVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
/*******************************************************
*
*/
template <typename PFP>
void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType);
template <typename PFP>
Dart subdivideFaceTri(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void subdivideVolumeTri(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void macCrackenJoy(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void bajaj(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
typename PFP::VEC3 bajajMask(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
} //namespace IHM
......
......@@ -119,8 +119,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
}
}
std::cout << "test" << std::endl;
// mv.unmarkAll();
// first pass: cut edges
......@@ -235,7 +233,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
//close the generated hole and create the central vertex
unsigned int degree = map.closeHole(map.phi1(d));
std::cout << "degree " << degree << std::endl;
Dart dd = map.phi1(map.phi2(map.phi1(d)));
map.splitFace(map.phi_1(dd),map.phi1(dd));
......
......@@ -136,6 +136,15 @@ public:
* @param e a dart in the second face
*/
void mergeFaces(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);
//@}
/*! @name Topological Queries
......
......@@ -234,6 +234,14 @@ inline void GMap1::mergeFaces(Dart d, Dart e)
deleteEdge(e) ;
}
inline void GMap1::linkVertices(Dart d, Dart e)
{
assert(d != e && !sameOrientedFace(d, e)) ;
GMap1::cutEdge(phi_1(d)); // cut the edge before d (insert a new dart before d)
GMap1::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 Cell Functors
* Apply functors to all darts of a cell
*************************************************************************/
......
......@@ -116,6 +116,11 @@ public:
*/
virtual void cutEdge(Dart d);
//! Undo the cut of the edge of d and its opposite edge if it exists
/*! @param d a dart of the edge to uncut
*/
virtual void uncutEdge(Dart d);
//! Collapse an edge (that is deleted) possibly merging its vertices
/*! If delDegenerateFaces is true, the method checks that no degenerate
* faces are build (faces with less than 3 edges). If it occurs the faces
......@@ -126,7 +131,7 @@ public:
* @param delDegenerateFaces a boolean (default to true)
* @return a dart of the resulting vertex
*/
virtual Dart collapseEdge(Dart d, bool delDegenerateFaces);
virtual Dart collapseEdge(Dart d, bool delDegenerateFaces = true);
/**
* Flip the edge of d. (rotation in phi1 order)
......@@ -144,6 +149,20 @@ 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);
//! Sew two oriented faces along oriented edges (pay attention to the orientation !)
/*! \pre Darts d & e MUST be fixed point of phi2 relation
* @param d a dart of the first face
......
......@@ -222,7 +222,7 @@ public:
* @param d a dart in the first face
* @param e a dart in the second face
*/
virtual void mergeFaces(Dart d, Dart e);
virtual bool mergeFaces(Dart d, Dart e);
//!
/*!
......
......@@ -397,7 +397,7 @@ bool ImplicitHierarchicalMap3::volumeIsSubdivided(Dart d)
DartMarkerStore mark(*this); // Lock a marker
std::vector<Dart> visitedFaces; // Faces that are traversed
visitedFaces.reserve(16);
visitedFaces.reserve(512);
visitedFaces.push_back(d); // Start with the face of d
std::vector<Dart>::iterator face;
......@@ -455,6 +455,8 @@ bool ImplicitHierarchicalMap3::edgeCanBeCoarsened(Dart d)
Dart d2 = phi2(d) ;
++m_curLevel ;
std::cout << "vertex degree = " << vertexDegree(phi1(d)) << std::endl;
if(vertexDegree(phi1(d)) == 2)
{
degree2 = true ;
......@@ -553,6 +555,7 @@ bool ImplicitHierarchicalMap3::faceIsSubdividedOnce(Dart d)
bool ImplicitHierarchicalMap3:: volumeIsSubdividedOnce(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
return true;
}
......@@ -563,7 +566,7 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersByOne(Dart d)
bool found = false;
unsigned int vLevel = volumeLevel(d) + 1;
unsigned int vLevel = volumeLevel(d);// + 1;
Dart old = volumeOldestDart(d);
......@@ -571,7 +574,7 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersByOne(Dart d)
//Store faces that are traversed and start with the face of d
std::vector<Dart> visitedFaces;
visitedFaces.reserve(20);
visitedFaces.reserve(512);
visitedFaces.push_back(old);
mf.markOrbit(FACE, old) ;
......@@ -586,7 +589,8 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersByOne(Dart d)
if(phi3(e) != e)
{
Dart old = volumeOldestDart(phi3(e));
if((abs(volumeLevel(old) - vLevel) > 1))
//if((abs(volumeLevel(old) - vLevel) > 1))
if(volumeLevel(old) < vLevel)
found = true;
}
......@@ -604,6 +608,55 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersByOne(Dart d)
return found;
}
bool ImplicitHierarchicalMap3::coarsenNeighborhoodLevelDiffersByOne(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
bool found = false;
//unsigned int vLevel = volumeLevel(d);
Dart old = volumeOldestDart(d);
DartMarkerStore mf(*this); // Lock a face marker to save one dart per face
//Store faces that are traversed and start with the face of d
std::vector<Dart> visitedFaces;
visitedFaces.reserve(512);
visitedFaces.push_back(old);
mf.markOrbit(FACE, old) ;
for(std::vector<Dart>::iterator face = visitedFaces.begin(); !found && face != visitedFaces.end(); ++face)
{
Dart e = *face ;
do
{
// add all face neighbours to the table
if(faceIsSubdivided(e))
{
++m_curLevel;
if(faceIsSubdividedOnce(e))
found = true;
--m_curLevel;
}
Dart ee = phi2(e) ;
if(!mf.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mf.markOrbit(FACE, ee) ;
}
e = phi1(e) ;
} while(e != *face) ;
}
return found;
}
} //namespace IHM
} //namespace Algo
......
......@@ -86,7 +86,25 @@ void GMap2::cutEdge(Dart d)
}
}
Dart GMap2::collapseEdge(Dart d, bool delDegenerateFaces = true)
void GMap2::uncutEdge(Dart d)
{
assert(vertexDegree(phi1(d)) == 2) ;
Dart ne = phi2(d) ;
if(ne == d)
collapseEdge(d) ;
else
{
Dart nd = phi1(d) ;
Dart e = phi_1(ne) ;
phi2unsew(e) ;
phi2unsew(d) ;
GMap1::collapseEdge(nd) ;
GMap1::collapseEdge(ne) ;
phi2sew(d, e) ;
}
}
Dart GMap2::collapseEdge(Dart d, bool delDegenerateFaces)
{
Dart resV ;
......@@ -173,6 +191,20 @@ bool GMap2::flipBackEdge(Dart d)
return false ; // cannot flip a border edge
}
void GMap2::insertEdgeInVertex(Dart d, Dart e)
{
assert(!sameVertex(d,e) && phi2(e)==phi_1(e));
phi1sew(phi_1(d),phi_1(e));
}
void GMap2::removeEdgeFromVertex(Dart d)
{
assert(phi2(d)!=d);
phi1sew(phi_1(d),phi2(d));
}
void GMap2::sewFaces(Dart d, Dart e)
{
phi2sew(d, e);
......
......@@ -41,7 +41,7 @@ void Map3::deleteOrientedVolume(Dart d)
DartMarkerStore mark(*this); // Lock a marker
std::vector<Dart> visitedFaces; // Faces that are traversed
visitedFaces.reserve(16);
visitedFaces.reserve(512);
visitedFaces.push_back(d); // Start with the face of d
// // For every face added to the list
......@@ -207,14 +207,15 @@ bool Map3::deleteVertex(Dart d)
{
DartMarkerStore mv(*this); // Lock a marker
std::list<Dart> darts_list; //Darts that are traversed
std::vector<Dart> darts_list; //Darts that are traversed
darts_list.reserve(512);
darts_list.push_back(d); //Start with the dart d
std::list<Dart>::iterator darts;
std::vector<Dart>::iterator darts;
mv.mark(d);
std::list<Dart> unique_darts_list;
//unique_darts_list.reserve(30);
std::vector<Dart> unique_darts_list;
unique_darts_list.reserve(512);
unique_darts_list.push_back(d);
......@@ -546,10 +547,11 @@ void Map3::collapseVolume(Dart d, bool delDegenerateFaces,
//contracter toutes les faces de la liste
}
//TODO
void Map3::mergeFaces(Dart d, Dart e)
bool Map3::mergeFaces(Dart d, Dart e)
{
return false;
}
Dart Map3::cutSpike(Dart d)
......@@ -663,8 +665,6 @@ unsigned int Map3::vertexDegree(Dart d)
}
}
std::cout << "#darts = " << darts_list.size() << std::endl;
DartMarkerStore me(*this);
for(darts = darts_list.begin(); darts != darts_list.end() ; ++darts)
......@@ -810,7 +810,6 @@ bool Map3::foreach_dart_of_edge(Dart d, FunctorType& f, unsigned int thread)
bool Map3::foreach_dart_of_open_edge(Dart d, FunctorType& f, unsigned int thread)
{
DartMarkerStore mv(*this,thread); // Lock a marker
bool found = false; // Last functor return value
......
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