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
......
This diff is collapsed.
...@@ -53,7 +53,6 @@ class Primitive3D ...@@ -53,7 +53,6 @@ class Primitive3D
typedef typename PFP::MAP MAP; typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 EMB; typedef typename PFP::VEC3 EMB;
public: public:
enum {NONE,HEXAGRID}; enum {NONE,HEXAGRID};
...@@ -82,20 +81,18 @@ protected: ...@@ -82,20 +81,18 @@ protected:
std::vector<Dart> m_tableVertDarts; std::vector<Dart> m_tableVertDarts;
/** /**
* numbers that defined the subdivision of primitives * numbers that defined the subdivision of primitives
*/ */
int m_nx; unsigned int m_nx;
unsigned int m_ny;
int m_ny; unsigned int m_nz;
int m_nz;
/** /**
* Create a 3D grid * Create a 3D grid
* @param nx nb of cubes in x * @param nx nb of cubes in x
* @return the dart of vertex (0,0,0) direction z * @return the dart of vertex (0,0,0) direction z
*/ */
Dart HexaGrid1Topo(int nx); Dart HexaGrid1Topo(unsigned int nx);
/** /**
* Create a 3D grid * Create a 3D grid
...@@ -103,11 +100,10 @@ protected: ...@@ -103,11 +100,10 @@ protected:
* @param ny nb of cubes in y * @param ny nb of cubes in y
* @return the dart of vertex (0,0,0) direction z * @return the dart of vertex (0,0,0) direction z
*/ */
Dart HexaGrid2Topo(int nx, int ny); Dart HexaGrid2Topo(unsigned int nx, unsigned int ny);
Dart createHexa(); Dart createHexa();
public: public:
/** /**
...@@ -130,7 +126,6 @@ public: ...@@ -130,7 +126,6 @@ public:
*/ */
Dart getDart() { return m_dart;} Dart getDart() { return m_dart;}
/** /**
* transform the primitive with transformation matrice * transform the primitive with transformation matrice
* @param matrice * @param matrice
...@@ -143,7 +138,6 @@ public: ...@@ -143,7 +138,6 @@ public:
*/ */
// void mark(Mark m); // void mark(Mark m);
/** /**
* Create a 3D grid * Create a 3D grid
* @param nx nb of cubes in x * @param nx nb of cubes in x
...@@ -151,8 +145,7 @@ public: ...@@ -151,8 +145,7 @@ public:
* @param nz nb of cubes in z * @param nz nb of cubes in z
* @return the dart of vertex (0,0,0) direction z * @return the dart of vertex (0,0,0) direction z
*/ */
Dart hexaGrid_topo(int nx, int ny, int nz); Dart hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned int nz);
/** /**
* embed the topo grid primitive * embed the topo grid primitive
...@@ -162,7 +155,7 @@ public: ...@@ -162,7 +155,7 @@ public:
* @param z * @param z
* @param positions handler of position attribute * @param positions handler of position attribute
*/ */
void embedHexaGrid( float x, float y, float z); void embedHexaGrid(float x, float y, float z);
/** /**
* Create a 3D grid * Create a 3D grid
...@@ -173,7 +166,6 @@ public: ...@@ -173,7 +166,6 @@ public:
*/ */
// Dart prismGrid_topo(int nx,int nz); // Dart prismGrid_topo(int nx,int nz);
/** /**
* embed the topo grid primitive * embed the topo grid primitive
* Grid has size x,y,z centered on 0 * Grid has size x,y,z centered on 0
...@@ -182,16 +174,13 @@ public: ...@@ -182,16 +174,13 @@ public:
* @param z * @param z
*/ */
// void embedPrismGrid( float x, float z); // void embedPrismGrid( float x, float z);
}; };
}//end namespace } // namespace Modelisation
}//end namespace
}//end namespace
} // namespace Algo
} // namespace CGoGN
#include "primitives3d.hpp" #include "primitives3d.hpp"
......
...@@ -35,52 +35,47 @@ namespace Modelisation ...@@ -35,52 +35,47 @@ namespace Modelisation
template <typename PFP> template <typename PFP>
Dart Primitive3D<PFP>::createHexa() Dart Primitive3D<PFP>::createHexa()
{ {
Dart base = m_map.newFace(4); Dart base = m_map.newFace(4, false);
Dart side1 = m_map.newFace(4); Dart side1 = m_map.newFace(4, false);
m_map.sewFaces(base,side1); m_map.sewFaces(base, side1, false);
Dart side2 = m_map.newFace(4); Dart side2 = m_map.newFace(4, false);
m_map.sewFaces(m_map.phi1(base),side2); m_map.sewFaces(m_map.phi1(base), side2, false);
m_map.sewFaces(m_map.phi_1(side1), m_map.phi1(side2)); m_map.sewFaces(m_map.phi_1(side1), m_map.phi1(side2), false);
Dart side3 = m_map.newFace(4); Dart side3 = m_map.newFace(4, false);
m_map.sewFaces(m_map.phi1(m_map.phi1(base)),side3); m_map.sewFaces(m_map.phi1(m_map.phi1(base)), side3, false);
m_map.sewFaces(m_map.phi_1(side2), m_map.phi1(side3)); m_map.sewFaces(m_map.phi_1(side2), m_map.phi1(side3), false);
Dart side4 = m_map.newFace(4); Dart side4 = m_map.newFace(4, false);
m_map.sewFaces(m_map.phi_1(base),side4); m_map.sewFaces(m_map.phi_1(base), side4, false);
m_map.sewFaces(m_map.phi_1(side3), m_map.phi1(side4)); m_map.sewFaces(m_map.phi_1(side3), m_map.phi1(side4), false);
m_map.sewFaces(m_map.phi_1(side4), m_map.phi1(side1)); m_map.sewFaces(m_map.phi_1(side4), m_map.phi1(side1), false);
Dart top = m_map.newFace(4); Dart top = m_map.newFace(4, false);
m_map.sewFaces(top,m_map.phi1(m_map.phi1(side1))); m_map.sewFaces(top, m_map.phi1(m_map.phi1(side1)), false);
m_map.sewFaces(m_map.phi_1(top),m_map.phi1(m_map.phi1(side2))); m_map.sewFaces(m_map.phi_1(top), m_map.phi1(m_map.phi1(side2)), false);
m_map.sewFaces(m_map.phi1(m_map.phi1(top)),m_map.phi1(m_map.phi1(side3))); m_map.sewFaces(m_map.phi1(m_map.phi1(top)), m_map.phi1(m_map.phi1(side3)), false);
m_map.sewFaces(m_map.phi1(top),m_map.phi1(m_map.phi1(side4))); m_map.sewFaces(m_map.phi1(top), m_map.phi1(m_map.phi1(side4)), false);
return base; return base;
} }
template <typename PFP> template <typename PFP>
Dart Primitive3D<PFP>::HexaGrid1Topo(int nx) Dart Primitive3D<PFP>::HexaGrid1Topo(unsigned int nx)
{ {
// first cube // first cube
<<<<<<< HEAD
Dart d0 = createOrientedHexa(); //return a dart from the base of the cube
m_tableVertDarts.push_back(d0); //push_back darts frome the base of cubes
=======
Dart d0 = createHexa(); Dart d0 = createHexa();
m_tableVertDarts.push_back(d0); m_tableVertDarts.push_back(d0);
>>>>>>> 9d09fe01ab3a12525ca57c400eb2777dfbc5b528
Dart d1 = m_map.template phi<2112>(d0); Dart d1 = m_map.template phi<2112>(d0);
for (int i=1; i< nx; ++i) for (unsigned int i = 1; i < nx; ++i)
{ {
Dart d2 = createHexa(); Dart d2 = createHexa();
m_tableVertDarts.push_back(d2); m_tableVertDarts.push_back(d2);
m_map.sewVolumes(d1,d2); m_map.sewVolumes(d1, d2);
d1 = m_map.template phi<2112>(d2); d1 = m_map.template phi<2112>(d2);
} }
...@@ -92,20 +87,20 @@ Dart Primitive3D<PFP>::HexaGrid1Topo(int nx) ...@@ -92,20 +87,20 @@ Dart Primitive3D<PFP>::HexaGrid1Topo(int nx)
} }
template <typename PFP> template <typename PFP>
Dart Primitive3D<PFP>::HexaGrid2Topo( int nx, int ny) Dart Primitive3D<PFP>::HexaGrid2Topo(unsigned int nx, unsigned int ny)
{ {
// creation premiere ligne // creation premiere ligne
Dart d0 = HexaGrid1Topo(nx); Dart d0 = HexaGrid1Topo(nx);
Dart d1 = m_map.template phi<112>(d0); Dart d1 = m_map.template phi<112>(d0);
for (int i=1; i< ny; ++i) for (unsigned int i = 1; i < ny; ++i)
{ {
// creation ligne suivante // creation ligne suivante
Dart d2 = HexaGrid1Topo(nx); Dart d2 = HexaGrid1Topo(nx);
Dart d3 = m_map.phi2(d2); Dart d3 = m_map.phi2(d2);
// couture des deux lignes de cubes // couture des deux lignes de cubes
for (int i=0; i< nx; ++i) for (unsigned int i = 0; i < nx; ++i)
{ {
m_map.sewVolumes(d1,d3); m_map.sewVolumes(d1,d3);
d1 = m_map.template phi<11232>(d1); d1 = m_map.template phi<11232>(d1);
...@@ -118,7 +113,7 @@ Dart Primitive3D<PFP>::HexaGrid2Topo( int nx, int ny) ...@@ -118,7 +113,7 @@ Dart Primitive3D<PFP>::HexaGrid2Topo( int nx, int ny)
// add last row of vertices (y = ny) // add last row of vertices (y = ny)
int index = m_tableVertDarts.size()-(nx+1); // pos of last inserted row of dart int index = m_tableVertDarts.size()-(nx+1); // pos of last inserted row of dart
for (int i = 0; i< nx; ++i) for (unsigned int i = 0; i < nx; ++i)
{ {
Dart dd = m_tableVertDarts[index++]; Dart dd = m_tableVertDarts[index++];
dd =m_map.template phi<112>(dd); dd =m_map.template phi<112>(dd);
...@@ -129,13 +124,11 @@ Dart Primitive3D<PFP>::HexaGrid2Topo( int nx, int ny) ...@@ -129,13 +124,11 @@ Dart Primitive3D<PFP>::HexaGrid2Topo( int nx, int ny)
dd =m_map.template phi<211>(dd); dd =m_map.template phi<211>(dd);
m_tableVertDarts.push_back(dd); m_tableVertDarts.push_back(dd);
return d0; return d0;
} }
template <typename PFP> template <typename PFP>
Dart Primitive3D<PFP>::hexaGrid_topo( int nx, int ny, int nz) Dart Primitive3D<PFP>::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned int nz)
{ {
m_kind = HEXAGRID; m_kind = HEXAGRID;
m_nx = nx; m_nx = nx;
...@@ -143,23 +136,22 @@ Dart Primitive3D<PFP>::hexaGrid_topo( int nx, int ny, int nz) ...@@ -143,23 +136,22 @@ Dart Primitive3D<PFP>::hexaGrid_topo( int nx, int ny, int nz)
m_nz = nz; m_nz = nz;
m_tableVertDarts.clear(); m_tableVertDarts.clear();
m_tableVertDarts.reserve((nx+1)*(ny+1)*(nz+1)); m_tableVertDarts.reserve((nx+1)*(ny+1)*(nz+1));
Dart d0 = HexaGrid2Topo(nx,ny); Dart d0 = HexaGrid2Topo(nx,ny);
Dart d1 = m_map.template phi<12>(d0); Dart d1 = m_map.template phi<12>(d0);
for (int i=1; i< nz; ++i) for (unsigned int i = 1; i < nz; ++i)
{ {
// creation grille suivante // creation grille suivante
Dart d2 = HexaGrid2Topo(nx,ny); Dart d2 = HexaGrid2Topo(nx,ny);
Dart d3 = m_map.phi2(m_map.phi_1(d2)); Dart d3 = m_map.phi2(m_map.phi_1(d2));
// couture des deux grilles 2D de cubes // couture des deux grilles 2D de cubes
for (int j=0; j< ny; ++j) for (unsigned int j = 0; j < ny; ++j)
{ {
Dart da = d1; Dart da = d1;
Dart db = d3; Dart db = d3;
for (int k=0; k< nx; ++k) for (unsigned int k = 0; k < nx; ++k)
{ {
m_map.sewVolumes(da,db); m_map.sewVolumes(da,db);
da = m_map.template phi<11232>(da); da = m_map.template phi<11232>(da);
...@@ -175,21 +167,20 @@ Dart Primitive3D<PFP>::hexaGrid_topo( int nx, int ny, int nz) ...@@ -175,21 +167,20 @@ Dart Primitive3D<PFP>::hexaGrid_topo( int nx, int ny, int nz)
} }
// add last slice of vertices to the table // add last slice of vertices to the table
int nb = (nx+1)*(ny+1); // nb of vertices in one slice XY unsigned int nb = (nx+1)*(ny+1); // nb of vertices in one slice XY
int index = nb*(nz-1); // last slice unsigned int index = nb*(nz-1); // last slice
for (int i=0; i < nb; ++i) for (unsigned int i = 0; i < nb; ++i)
{ {
Dart dd = m_tableVertDarts[index++]; Dart dd = m_tableVertDarts[index++];
dd