Commit 89786538 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

ajout fichiers Traversors

parent d27ef426
...@@ -60,7 +60,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts) ...@@ -60,7 +60,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
for (unsigned int j = 0; j < nbe; ++j) for (unsigned int j = 0; j < nbe; ++j)
{ {
unsigned int em = mts.getEmbIdx(index++); unsigned int em = mts.getEmbIdx(index++);
if (em!=prec) if (em != prec)
{ {
prec = em; prec = em;
edgesBuffer.push_back(em); edgesBuffer.push_back(em);
...@@ -74,21 +74,21 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts) ...@@ -74,21 +74,21 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
nbe = edgesBuffer.size(); nbe = edgesBuffer.size();
if (nbe > 2) if (nbe > 2)
{ {
Dart d = map.newFace(nbe,false); Dart d = map.newFace(nbe, false);
for (unsigned int j = 0; j < nbe; ++j) for (unsigned int j = 0; j < nbe; ++j)
{ {
unsigned int em = edgesBuffer[j]; // get embedding unsigned int em = edgesBuffer[j]; // get embedding
map.setDartEmbedding(VERTEX, d, em); // associate to dart map.embedOrbit(VERTEX, d, em) ;
vecDartsPerVertex[em].push_back(d); // store incident darts for fast phi2 reconstruction // map.setDartEmbedding(VERTEX, d, em); // associate to dart
vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction
d = map.phi1(d); d = map.phi1(d);
} }
m.markOrbit(FACE, d); // mark on the fly to unmark on second loop m.markOrbit(ORIENTED_FACE, d); // mark on the fly to unmark on second loop
} }
} }
unsigned int nbnm = 0;
// reconstruct neighbourhood // reconstruct neighbourhood
unsigned int nbnm = 0;
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
{ {
if (m.isMarked(d)) if (m.isMarked(d))
...@@ -97,7 +97,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts) ...@@ -97,7 +97,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)]; std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];
unsigned int embd = map.getEmbedding(VERTEX, d); unsigned int embd = map.getEmbedding(VERTEX, d);
Dart good_dart=NIL; Dart good_dart = NIL;
for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it) for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{ {
if (map.getEmbedding(VERTEX, map.phi1(*it)) == embd) if (map.getEmbedding(VERTEX, map.phi1(*it)) == embd)
...@@ -108,7 +108,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts) ...@@ -108,7 +108,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
{ {
if (good_dart == map.phi2(good_dart)) if (good_dart == map.phi2(good_dart))
{ {
map.sewFaces(d, good_dart,false); map.sewFaces(d, good_dart, false);
m.unmarkOrbit(EDGE, d); m.unmarkOrbit(EDGE, d);
} }
} }
......
...@@ -117,11 +117,11 @@ protected: ...@@ -117,11 +117,11 @@ protected:
/** /**
* numbers that defined the subdivision of Polyhedron * numbers that defined the subdivision of Polyhedron
*/ */
int m_nx; unsigned int m_nx;
int m_ny; unsigned int m_ny;
int m_nz; unsigned int m_nz;
bool m_top_closed; bool m_top_closed;
...@@ -151,14 +151,14 @@ public: ...@@ -151,14 +151,14 @@ public:
* @param idPositions id of attribute position * @param idPositions id of attribute position
*/ */
Polyhedron(MAP& map, typename PFP::TVEC3& position): Polyhedron(MAP& map, typename PFP::TVEC3& position):
m_map(map), m_map(map),
m_kind(NONE), m_kind(NONE),
m_nx(-1), m_ny(-1), m_nz(-1), m_nx(-1), m_ny(-1), m_nz(-1),
m_top_closed(false), m_bottom_closed(false), m_top_closed(false), m_bottom_closed(false),
m_positions(position) m_positions(position)
{ {
computeCenter(); computeCenter();
} }
/** /**
* Polyhedron fusion: give a COMPOSED type * Polyhedron fusion: give a COMPOSED type
...@@ -170,7 +170,7 @@ public: ...@@ -170,7 +170,7 @@ public:
/** /**
* create simple simple polyhedron (not handled by Polyhedron object) * create simple simple polyhedron (not handled by Polyhedron object)
*/ */
static Dart createPolyhedron(typename PFP::MAP& the_map, int nbFaces); static Dart createPolyhedron(typename PFP::MAP& the_map, unsigned int nbFaces);
/** /**
* create simple simple tetrahedron (not handled by Polyhedron object) * create simple simple tetrahedron (not handled by Polyhedron object)
...@@ -225,7 +225,7 @@ public: ...@@ -225,7 +225,7 @@ public:
* @param bottom_closed close the bottom with triangles fan * @param bottom_closed close the bottom with triangles fan
* @return the dart * @return the dart
*/ */
Dart cylinder_topo(int n, int z, bool top_closed, bool bottom_closed); Dart cylinder_topo(unsigned int n, unsigned int z, bool top_closed, bool bottom_closed);
/** /**
* Create a subdivided (surface) cone (with param 1,3,true create tetrahedron) * Create a subdivided (surface) cone (with param 1,3,true create tetrahedron)
...@@ -234,7 +234,7 @@ public: ...@@ -234,7 +234,7 @@ public:
* @param bottom_closed close the bottom with triangles fan * @param bottom_closed close the bottom with triangles fan
* @return the dart * @return the dart
*/ */
Dart cone_topo(int n, int z, bool bottom_closed); Dart cone_topo(unsigned int n, unsigned int z, bool bottom_closed);
/** /**
* Create a subdived (surface) cube * Create a subdived (surface) cube
...@@ -244,7 +244,7 @@ public: ...@@ -244,7 +244,7 @@ public:
* @param z nb of quads in z * @param z nb of quads in z
* @return the dart * @return the dart
*/ */
Dart cube_topo(int x, int y, int z); Dart cube_topo(unsigned int x, unsigned int y, unsigned int z);
/** /**
* Create a subdivided (surface) cylinder * Create a subdivided (surface) cylinder
...@@ -254,7 +254,7 @@ public: ...@@ -254,7 +254,7 @@ public:
* @param bottom_closed close the bottom with triangles fan * @param bottom_closed close the bottom with triangles fan
* @return the dart * @return the dart
*/ */
Dart tore_topo(int m, int n); Dart tore_topo(unsigned int m, unsigned int n);
/** /**
* embed the topo grid Polyhedron * embed the topo grid Polyhedron
...@@ -262,7 +262,7 @@ public: ...@@ -262,7 +262,7 @@ public:
* @param x * @param x
* @param y * @param y
*/ */
void embedGrid(float x, float y, float z=0.0f); void embedGrid(float x, float y, float z = 0.0f);
/** /**
* embed the topo cylinder Polyhedron * embed the topo cylinder Polyhedron
...@@ -317,7 +317,7 @@ public: ...@@ -317,7 +317,7 @@ public:
* @param maxHeight height to reach * @param maxHeight height to reach
* @param turns number of turn * @param turns number of turn
*/ */
void embedHelicoid( float radius_min, float radius_max, float maxHeight, float nbTurn, int orient=1); void embedHelicoid( float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1);
/** /**
* transform the Polyhedron with transformation matrice * transform the Polyhedron with transformation matrice
......
...@@ -37,27 +37,23 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 positi ...@@ -37,27 +37,23 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 positi
map.unsewVertexUmbrella(d); map.unsewVertexUmbrella(d);
unsigned int newFaceDegree = map.closeHole(map.phi1(d)); unsigned int newFaceDegree = map.closeHole(map.phi1(d));
if(newFaceDegree != 3) if(newFaceDegree != 3)
{ {
//chercher le brin ou demarer // chercher le brin ou demarrer
std::multimap<Dart, int> edges ; std::multimap<Dart, int> edges ;
typename std::multimap<Dart, int>::iterator it ; typename std::multimap<Dart, int>::iterator it ;
Dart d12 = map.phi2(map.phi1(d)); Dart d12 = map.phi2(map.phi1(d));
Dart fit = d12; Dart fit = d12;
int i; unsigned int i;
do do
{ {
i = map.faceDegree(map.phi2(fit)); i = map.faceDegree(map.phi2(fit));
std::cout << "edge(" << fit << "," << i << ")" << std::endl; std::cout << "edge(" << fit << "," << i << ")" << std::endl;
edges.insert(std::make_pair(fit, i)); edges.insert(std::make_pair(fit, i));
fit = map.phi1(fit);
fit = map.phi1(fit);
} }
while(fit != d12); while(fit != d12);
...@@ -108,8 +104,6 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 positi ...@@ -108,8 +104,6 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 positi
std::cout << "flip cas quad tri" << std::endl; std::cout << "flip cas quad tri" << std::endl;
} }
fit = map.phi1(fit); fit = map.phi1(fit);
} }
while(map.faceDegree(fit) > 4 && fit != d12); while(map.faceDegree(fit) > 4 && fit != d12);
...@@ -118,13 +112,13 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 positi ...@@ -118,13 +112,13 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 positi
} }
template <typename PFP> template <typename PFP>
Polyhedron<PFP>::Polyhedron(const Polyhedron<PFP>& p1, const Polyhedron<PFP>& p2): Polyhedron<PFP>::Polyhedron(const Polyhedron<PFP>& p1, const Polyhedron<PFP>& p2) :
m_map(p1.m_map), m_map(p1.m_map),
m_dart(p1.m_dart), m_dart(p1.m_dart),
m_kind(COMPOSED), m_kind(COMPOSED),
m_nx(-1), m_ny(-1), m_nz(-1), m_nx(-1), m_ny(-1), m_nz(-1),
m_top_closed(false), m_bottom_closed(false), m_top_closed(false), m_bottom_closed(false),
m_positions(p1.m_positions) m_positions(p1.m_positions)
{ {
if (&(p1.map) != &(p2.map)) if (&(p1.map) != &(p2.map))
{ {
...@@ -135,23 +129,23 @@ m_positions(p1.m_positions) ...@@ -135,23 +129,23 @@ m_positions(p1.m_positions)
typename PFP::VEC3 center(0); typename PFP::VEC3 center(0);
for(typename std::vector<Dart>::const_iterator di=p1.m_tableVertDarts.begin(); di!=p1.m_tableVertDarts.end(); ++di) for(typename std::vector<Dart>::const_iterator di = p1.m_tableVertDarts.begin(); di != p1.m_tableVertDarts.end(); ++di)
{ {
m_tableVertDarts.push_back(*di); m_tableVertDarts.push_back(*di);
center += m_positions[*di]; center += m_positions[*di];
} }
// O(n2) pas terrible !! // O(n2) pas terrible !!
for(typename std::vector<Dart>::const_iterator di=p2.m_tableVertDarts.begin(); di!=p2.m_tableVertDarts.end(); ++di) for(typename std::vector<Dart>::const_iterator di = p2.m_tableVertDarts.begin(); di != p2.m_tableVertDarts.end(); ++di)
{ {
unsigned int em = m_map.getEmbedding(*di,VERTEX); unsigned int em = m_map.getEmbedding(*di, VERTEX);
typename std::vector<Dart>::const_iterator dj=p1.m_tableVertDarts.begin(); typename std::vector<Dart>::const_iterator dj=p1.m_tableVertDarts.begin();
bool found = false; bool found = false;
while ((dj !=p1.m_tableVertDarts.end()) && (!found)) while ((dj !=p1.m_tableVertDarts.end()) && (!found))
{ {
unsigned int xm = m_map.getEmbedding(*dj,VERTEX); unsigned int xm = m_map.getEmbedding(*dj, VERTEX);
if ( xm == em) if (xm == em)
found = true; found = true;
else else
++dj; ++dj;
...@@ -270,7 +264,7 @@ Dart Polyhedron<PFP>::createPrism(typename PFP::MAP& the_map) ...@@ -270,7 +264,7 @@ Dart Polyhedron<PFP>::createPrism(typename PFP::MAP& the_map)
} }
template <typename PFP> template <typename PFP>
Dart Polyhedron<PFP>::createPolyhedron(typename PFP::MAP& the_map, int n) Dart Polyhedron<PFP>::createPolyhedron(typename PFP::MAP& the_map, unsigned int n)
{ {
Dart d; Dart d;
switch (n) switch (n)
...@@ -352,7 +346,7 @@ Dart Polyhedron<PFP>::grid_topo(unsigned int x, unsigned int y) ...@@ -352,7 +346,7 @@ Dart Polyhedron<PFP>::grid_topo(unsigned int x, unsigned int y)
} }
template <typename PFP> template <typename PFP>
Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_closed) Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_closed, bool bottom_closed)
{ {
if (m_kind != NONE) return m_dart; if (m_kind != NONE) return m_dart;
...@@ -360,8 +354,8 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c ...@@ -360,8 +354,8 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c
m_nx = n; m_nx = n;
m_nz = z; m_nz = z;
m_bottom_closed=bottom_closed; m_bottom_closed = bottom_closed;
m_top_closed=top_closed; m_top_closed = top_closed;
int nb = (n)*(z+1); int nb = (n)*(z+1);
if (bottom_closed) nb++; if (bottom_closed) nb++;
...@@ -371,40 +365,40 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c ...@@ -371,40 +365,40 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c
m_tableVertDarts.reserve(nb); m_tableVertDarts.reserve(nb);
// creation of quads and storing vertices // creation of quads and storing vertices
for (int i=0;i<z;++i) for (unsigned int i = 0; i < z; ++i)
{ {
for (int j=0;j<n;++j) for (unsigned int j = 0; j < n; ++j)
{ {
Dart d = m_map.newFace(4,false); Dart d = m_map.newFace(4, false);
m_tableVertDarts.push_back(d); m_tableVertDarts.push_back(d);
} }
} }
for (int i=0;i<n;++i) for (unsigned int i = 0; i < n; ++i)
{ {
m_tableVertDarts.push_back( m_map.phi_1(m_tableVertDarts[(z-1)*n+i]) ); m_tableVertDarts.push_back( m_map.phi_1(m_tableVertDarts[(z-1)*n+i]) );
} }
//sewing the quads //sewing the quads
for (int i=0;i<z;++i) for (unsigned int i = 0; i < z; ++i)
{ {
for (int j=0;j<n;++j) for (unsigned int j = 0; j < n; ++j)
{ {
if (i>0) // sew with preceeding row if (i > 0) // sew with preceeding row
{ {
int pos = i*n+j; int pos = i*n+j;
Dart d = m_tableVertDarts[pos]; Dart d = m_tableVertDarts[pos];
Dart e = m_tableVertDarts[pos-n]; Dart e = m_tableVertDarts[pos-n];
e = m_map.phi1(m_map.phi1(e)); e = m_map.phi1(m_map.phi1(e));
m_map.sewFaces(d,e,false); m_map.sewFaces(d, e, false);
} }
if (j>0) // sew with preceeding column if (j > 0) // sew with preceeding column
{ {
int pos = i*n+j; int pos = i*n+j;
Dart d = m_tableVertDarts[pos]; Dart d = m_tableVertDarts[pos];
d = m_map.phi_1(d); d = m_map.phi_1(d);
Dart e = m_tableVertDarts[pos-1]; Dart e = m_tableVertDarts[pos-1];
e = m_map.phi1(e); e = m_map.phi1(e);
m_map.sewFaces(d,e,false); m_map.sewFaces(d, e, false);
} }
else else
{ {
...@@ -413,7 +407,7 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c ...@@ -413,7 +407,7 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c
d = m_map.phi_1(d); d = m_map.phi_1(d);
Dart e = m_tableVertDarts[pos+(n-1)]; Dart e = m_tableVertDarts[pos+(n-1)];
e = m_map.phi1(e); e = m_map.phi1(e);
m_map.sewFaces(d,e,false); m_map.sewFaces(d, e, false);
} }
} }
} }
...@@ -450,7 +444,7 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c ...@@ -450,7 +444,7 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c
if (top_closed) if (top_closed)
{ {
Dart d = m_map.phi_1(m_tableVertDarts[n*z]); Dart d = m_map.phi_1(m_tableVertDarts[n*z]);
if(m_map.closeHole(d,true)) if(m_map.closeHole(d, true))
{ {
d = m_map.phi2(d); d = m_map.phi2(d);
if(m_map.faceDegree(d) > 3) if(m_map.faceDegree(d) > 3)
...@@ -626,7 +620,7 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c ...@@ -626,7 +620,7 @@ Dart Polyhedron<PFP>::cylinder_topo(int n, int z, bool top_closed, bool bottom_c
// } // }
template <typename PFP> template <typename PFP>
Dart Polyhedron<PFP>::cube_topo(int x, int y,int z) Dart Polyhedron<PFP>::cube_topo(unsigned int x, unsigned int y, unsigned int z)
{ {
if (m_kind != NONE) return m_dart; if (m_kind != NONE) return m_dart;
...@@ -646,31 +640,31 @@ Dart Polyhedron<PFP>::cube_topo(int x, int y,int z) ...@@ -646,31 +640,31 @@ Dart Polyhedron<PFP>::cube_topo(int x, int y,int z)
std::vector<Dart>& tableTop = primTop.getVertexDarts(); std::vector<Dart>& tableTop = primTop.getVertexDarts();
int index_side = 2*(x+y)*z; int index_side = 2*(x+y)*z;
for(int i=0;i<x;++i) for(unsigned int i = 0; i < x; ++i)
{ {
Dart d = m_map.phi_1(m_tableVertDarts[index_side++]); Dart d = m_map.phi_1(m_tableVertDarts[index_side++]);
Dart e = tableTop[i]; Dart e = tableTop[i];
m_map.sewFaces(d,e,false); m_map.sewFaces(d, e, false);
} }
for(int i=0;i<y;++i) for(unsigned int i = 0; i < y; ++i)
{ {
Dart d = m_map.phi_1(m_tableVertDarts[index_side++]); Dart d = m_map.phi_1(m_tableVertDarts[index_side++]);
Dart e = tableTop[x+i*(x+1)]; Dart e = tableTop[x+i*(x+1)];
m_map.sewFaces(d,e,false); m_map.sewFaces(d, e, false);
} }
for(int i=0;i<x;++i) for(unsigned int i = 0; i < x; ++i)
{ {
Dart d = m_map.phi_1(m_tableVertDarts[index_side++]); Dart d = m_map.phi_1(m_tableVertDarts[index_side++]);
Dart e = tableTop[(x+1)*(y+1)-2 - i]; Dart e = tableTop[(x+1)*(y+1)-2 - i];
e = m_map.phi_1(e); e = m_map.phi_1(e);
m_map.sewFaces(d,e,false); m_map.sewFaces(d, e, false);
} }
for(int i=0;i<y;++i) for(unsigned int i = 0; i < y; ++i)
{ {
Dart d = m_map.phi_1(m_tableVertDarts[index_side++]); Dart d = m_map.phi_1(m_tableVertDarts[index_side++]);
Dart e = tableTop[(y-1-i)*(x+1)]; Dart e = tableTop[(y-1-i)*(x+1)];
e = m_map.phi_1(e); e = m_map.phi_1(e);
m_map.sewFaces(d,e,false); m_map.sewFaces(d, e, false);
} }
// the bottom // the bottom
...@@ -679,57 +673,53 @@ Dart Polyhedron<PFP>::cube_topo(int x, int y,int z) ...@@ -679,57 +673,53 @@ Dart Polyhedron<PFP>::cube_topo(int x, int y,int z)
std::vector<Dart>& tableBottom = primBottom.getVertexDarts(); std::vector<Dart>& tableBottom = primBottom.getVertexDarts();
index_side = 3*(x+y)+(x-1); index_side = 3*(x+y)+(x-1);
for(int i=0;i<x;++i) for(unsigned int i = 0; i < x; ++i)
{ {
Dart d = m_tableVertDarts[(index_side--)%(2*(x+y))]; Dart d = m_tableVertDarts[(index_side--)%(2*(x+y))];
Dart e = tableBottom[i]; Dart e = tableBottom[i];
m_map.sewFaces(d,e,false); m_map.sewFaces(d, e, false);
} }
for(int i=0;i<y;++i) for(unsigned int i = 0; i < y; ++i)
{ {
Dart d = m_tableVertDarts[(index_side--)%(2*(x+y))]; Dart d = m_tableVertDarts[(index_side--)%(2*(x+y))];
Dart e = tableBottom[x+i*(x+1)]; Dart e = tableBottom[x+i*(x+1)];
m_map.sewFaces(d,e,false); m_map.sewFaces(d, e, false);
} }
for(int i=0;i<x;++i)