Commit 89786538 authored by Pierre Kraemer's avatar Pierre Kraemer

ajout fichiers Traversors

parent d27ef426
......@@ -60,7 +60,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
for (unsigned int j = 0; j < nbe; ++j)
{
unsigned int em = mts.getEmbIdx(index++);
if (em!=prec)
if (em != prec)
{
prec = em;
edgesBuffer.push_back(em);
......@@ -74,21 +74,21 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
nbe = edgesBuffer.size();
if (nbe > 2)
{
Dart d = map.newFace(nbe,false);
Dart d = map.newFace(nbe, false);
for (unsigned int j = 0; j < nbe; ++j)
{
unsigned int em = edgesBuffer[j]; // get embedding
map.setDartEmbedding(VERTEX, d, em); // associate to dart
vecDartsPerVertex[em].push_back(d); // store incident darts for fast phi2 reconstruction
map.embedOrbit(VERTEX, d, em) ;
// map.setDartEmbedding(VERTEX, d, em); // associate to dart
vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction
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
unsigned int nbnm = 0;
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (m.isMarked(d))
......@@ -97,7 +97,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(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)
{
if (map.getEmbedding(VERTEX, map.phi1(*it)) == embd)
......@@ -108,7 +108,7 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
{
if (good_dart == map.phi2(good_dart))
{
map.sewFaces(d, good_dart,false);
map.sewFaces(d, good_dart, false);
m.unmarkOrbit(EDGE, d);
}
}
......
......@@ -117,11 +117,11 @@ protected:
/**
* 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;
......@@ -151,14 +151,14 @@ public:
* @param idPositions id of attribute position
*/
Polyhedron(MAP& map, typename PFP::TVEC3& position):
m_map(map),
m_kind(NONE),
m_nx(-1), m_ny(-1), m_nz(-1),
m_top_closed(false), m_bottom_closed(false),
m_positions(position)
{
m_map(map),
m_kind(NONE),
m_nx(-1), m_ny(-1), m_nz(-1),
m_top_closed(false), m_bottom_closed(false),
m_positions(position)
{
computeCenter();
}
}
/**
* Polyhedron fusion: give a COMPOSED type
......@@ -170,7 +170,7 @@ public:
/**
* 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)
......@@ -225,7 +225,7 @@ public:
* @param bottom_closed close the bottom with triangles fan
* @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)
......@@ -234,7 +234,7 @@ public:
* @param bottom_closed close the bottom with triangles fan
* @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
......@@ -244,7 +244,7 @@ public:
* @param z nb of quads in z
* @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
......@@ -254,7 +254,7 @@ public:
* @param bottom_closed close the bottom with triangles fan
* @return the dart
*/
Dart tore_topo(int m, int n);
Dart tore_topo(unsigned int m, unsigned int n);
/**
* embed the topo grid Polyhedron
......@@ -262,7 +262,7 @@ public:
* @param x
* @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
......@@ -317,7 +317,7 @@ public:
* @param maxHeight height to reach
* @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
......
This diff is collapsed.
......@@ -53,7 +53,6 @@ class Primitive3D
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 EMB;
public:
enum {NONE,HEXAGRID};
......@@ -82,20 +81,18 @@ protected:
std::vector<Dart> m_tableVertDarts;
/**
* numbers that defined the subdivision of primitives
* numbers that defined the subdivision of primitives
*/
int m_nx;
int m_ny;
int m_nz;
unsigned int m_nx;
unsigned int m_ny;
unsigned int m_nz;
/**
* Create a 3D grid
* @param nx nb of cubes in x
* @return the dart of vertex (0,0,0) direction z
*/
Dart HexaGrid1Topo(int nx);
Dart HexaGrid1Topo(unsigned int nx);
/**
* Create a 3D grid
......@@ -103,11 +100,10 @@ protected:
* @param ny nb of cubes in y
* @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();
public:
/**
......@@ -130,7 +126,6 @@ public:
*/
Dart getDart() { return m_dart;}
/**
* transform the primitive with transformation matrice
* @param matrice
......@@ -143,7 +138,6 @@ public:
*/
// void mark(Mark m);
/**
* Create a 3D grid
* @param nx nb of cubes in x
......@@ -151,8 +145,7 @@ public:
* @param nz nb of cubes in 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
......@@ -162,7 +155,7 @@ public:
* @param z
* @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
......@@ -173,7 +166,6 @@ public:
*/
// Dart prismGrid_topo(int nx,int nz);
/**
* embed the topo grid primitive
* Grid has size x,y,z centered on 0
......@@ -182,16 +174,13 @@ public:
* @param z
*/
// void embedPrismGrid( float x, float z);
};
}//end namespace
}//end namespace
}//end namespace
} // namespace Modelisation
} // namespace Algo
} // namespace CGoGN
#include "primitives3d.hpp"
......
......@@ -35,52 +35,47 @@ namespace Modelisation
template <typename PFP>
Dart Primitive3D<PFP>::createHexa()
{
Dart base = m_map.newFace(4);
Dart base = m_map.newFace(4, false);
Dart side1 = m_map.newFace(4);
m_map.sewFaces(base,side1);
Dart side1 = m_map.newFace(4, false);
m_map.sewFaces(base, side1, false);
Dart side2 = m_map.newFace(4);
m_map.sewFaces(m_map.phi1(base),side2);
m_map.sewFaces(m_map.phi_1(side1), m_map.phi1(side2));
Dart side2 = m_map.newFace(4, false);
m_map.sewFaces(m_map.phi1(base), side2, false);
m_map.sewFaces(m_map.phi_1(side1), m_map.phi1(side2), false);
Dart side3 = m_map.newFace(4);
m_map.sewFaces(m_map.phi1(m_map.phi1(base)),side3);
m_map.sewFaces(m_map.phi_1(side2), m_map.phi1(side3));
Dart side3 = m_map.newFace(4, false);
m_map.sewFaces(m_map.phi1(m_map.phi1(base)), side3, false);
m_map.sewFaces(m_map.phi_1(side2), m_map.phi1(side3), false);
Dart side4 = m_map.newFace(4);
m_map.sewFaces(m_map.phi_1(base),side4);
m_map.sewFaces(m_map.phi_1(side3), m_map.phi1(side4));
Dart side4 = m_map.newFace(4, false);
m_map.sewFaces(m_map.phi_1(base), side4, false);
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);
m_map.sewFaces(top,m_map.phi1(m_map.phi1(side1)));
m_map.sewFaces(m_map.phi_1(top),m_map.phi1(m_map.phi1(side2)));
m_map.sewFaces(m_map.phi1(m_map.phi1(top)),m_map.phi1(m_map.phi1(side3)));
m_map.sewFaces(m_map.phi1(top),m_map.phi1(m_map.phi1(side4)));
Dart top = m_map.newFace(4, false);
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)), false);
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)), false);
return base;
}
template <typename PFP>
Dart Primitive3D<PFP>::HexaGrid1Topo(int nx)
Dart Primitive3D<PFP>::HexaGrid1Topo(unsigned int nx)
{
// 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();
m_tableVertDarts.push_back(d0);
>>>>>>> 9d09fe01ab3a12525ca57c400eb2777dfbc5b528
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();
m_tableVertDarts.push_back(d2);
m_map.sewVolumes(d1,d2);
m_map.sewVolumes(d1, d2);
d1 = m_map.template phi<2112>(d2);
}
......@@ -92,20 +87,20 @@ Dart Primitive3D<PFP>::HexaGrid1Topo(int nx)
}
template <typename PFP>
Dart Primitive3D<PFP>::HexaGrid2Topo( int nx, int ny)
Dart Primitive3D<PFP>::HexaGrid2Topo(unsigned int nx, unsigned int ny)
{
// creation premiere ligne
Dart d0 = HexaGrid1Topo(nx);
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
Dart d2 = HexaGrid1Topo(nx);
Dart d3 = m_map.phi2(d2);
Dart d3 = m_map.phi2(d2);
// 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);
d1 = m_map.template phi<11232>(d1);
......@@ -118,7 +113,7 @@ Dart Primitive3D<PFP>::HexaGrid2Topo( int nx, int ny)
// add last row of vertices (y = ny)
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++];
dd =m_map.template phi<112>(dd);
......@@ -129,13 +124,11 @@ Dart Primitive3D<PFP>::HexaGrid2Topo( int nx, int ny)
dd =m_map.template phi<211>(dd);
m_tableVertDarts.push_back(dd);
return d0;
}
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_nx = nx;
......@@ -143,23 +136,22 @@ Dart Primitive3D<PFP>::hexaGrid_topo( int nx, int ny, int nz)
m_nz = nz;
m_tableVertDarts.clear();
m_tableVertDarts.reserve((nx+1)*(ny+1)*(nz+1));
Dart d0 = HexaGrid2Topo(nx,ny);
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
Dart d2 = HexaGrid2Topo(nx,ny);
Dart d3 = m_map.phi2(m_map.phi_1(d2));
// 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 db = d3;
for (int k=0; k< nx; ++k)
for (unsigned int k = 0; k < nx; ++k)
{
m_map.sewVolumes(da,db);
da = m_map.template phi<11232>(da);
......@@ -175,21 +167,20 @@ Dart Primitive3D<PFP>::hexaGrid_topo( int nx, int ny, int nz)
}
// add last slice of vertices to the table
int nb = (nx+1)*(ny+1); // nb of vertices in one slice XY
int index = nb*(nz-1); // last slice
for (int i=0; i < nb; ++i)
unsigned int nb = (nx+1)*(ny+1); // nb of vertices in one slice XY
unsigned int index = nb*(nz-1); // last slice
for (unsigned int i = 0; i < nb; ++i)
{
Dart dd = m_tableVertDarts[index++];
dd =m_map.phi2(dd);
dd = m_map.phi2(dd);
m_tableVertDarts.push_back(dd);
}
return d0;
}
template <typename PFP>
void Primitive3D<PFP>::embedHexaGrid( float x, float y, float z)
void Primitive3D<PFP>::embedHexaGrid(float x, float y, float z)
{
if (m_kind != HEXAGRID)
{
......@@ -201,25 +192,24 @@ void Primitive3D<PFP>::embedHexaGrid( float x, float y, float z)
float dy = y/float(m_ny);
float dz = z/float(m_nz);
int nbs = (m_nx+1)*(m_ny+1);
unsigned int nbs = (m_nx+1)*(m_ny+1);
for(int i=0; i<=m_nz; ++i)
for(unsigned int i = 0; i <= m_nz; ++i)
{
for(int j=0; j<=m_ny; ++j)
for(unsigned int j = 0; j <= m_ny; ++j)
{
for(int k=0; k<=m_nx;++k)
for(unsigned int k = 0; k <= m_nx; ++k)
{
typename PFP::VEC3 pos(-x/2.0f + dx*float(k), -y/2.0f + dy*float(j), -z/2.0f + dz*float(i));
Dart d = m_tableVertDarts[ i*nbs+j*(m_nx+1)+k ];
m_map.embedNewCell(VERTEX,d);
m_map.embedNewCell(VERTEX, d);
m_positions[d] = pos;
}
}
}
}
template <typename PFP>
void Primitive3D<PFP>::transform(const Geom::Matrix44f& matrice)
{
......@@ -240,6 +230,8 @@ void Primitive3D<PFP>::transform(const Geom::Matrix44f& matrice)
// }
//}
}//end namespace
}//end namespace
}//end namespace
} // namespace Modelisation
} // namespace Algo
} // namespace CGoGN
......@@ -46,26 +46,11 @@ private:
Dart d2 ;
public:
Traversor1VE(MAP& map, Dart dart) : m(map), start(dart)
{
d2 = m.phi_1(start) ;
if(d2 == start) // 1 edge loop case
d2 = NIL ;
}
Dart begin() { current = start ; return current ; }
Dart end() { return NIL ; }
Dart next()
{
if(current != NIL)
{
if(current == start)
current = d2 ;
else
current = NIL ;
}
return current ;
}
Traversor1VE(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
// Traverse the vertices adjacent to a given vertex through sharing a common edge
......@@ -79,32 +64,11 @@ private:
Dart d2 ;
public:
Traversor1VVaE(MAP& map, Dart dart) : m(map)
{
start = m.phi_1(dart) ;
if(start == dart) // 1 edge loop case
start = NIL ;
else
{
d2 = m.phi1(dart) ;
if(d2 == start) // 2 edges loop case
d2 = NIL ;
}
}
Dart begin() { current = start ; return current ; }
Dart end() { return NIL ; }
Dart next()
{
if(current != NIL)
{
if(current == start)
current = d2 ;
else
current = NIL ;
}
return current ;
}
Traversor1VVaE(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
/*******************************************************************************
......@@ -123,26 +87,11 @@ private:
Dart d2 ;
public:
Traversor1EV(MAP& map, Dart dart) : m(map), start(dart)
{
d2 = m.phi1(start) ;
if(d2 == start) // 1 edge loop case
d2 = NIL ;
}
Dart begin() { current = start ; return current ; }
Dart end() { return NIL ; }
Dart next()
{
if(current != NIL)
{
if(current == start)
current = d2 ;
else
current = NIL ;
}
return current ;
}
Traversor1EV(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
// Traverse the edges adjacent to a given edge through sharing a common vertex
......@@ -156,34 +105,15 @@ private:
Dart d2 ;
public:
Traversor1EEaV(MAP& map, Dart dart) : m(map)
{
start = m.phi_1(dart) ;
if(start == dart) // 1 edge loop case
start = NIL ;
else
{
d2 = m.phi1(dart) ;
if(d2 == start) // 2 edges loop case
d2 = NIL ;
}
}
Dart begin() { current = start ; return current ; }
Dart end() { return NIL ; }
Dart next()
{
if(current != NIL)
{
if(current == start)
current = d2 ;
else
current = NIL ;
}
return current ;
}
Traversor1EEaV(MAP& map, Dart dart) ;
Dart begin() ;
Dart end() ;
Dart next() ;
} ;
} // namespace CGoGN
#include "Topology/generic/traversor1.hpp"
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
namespace CGoGN
{
/*******************************************************************************
VERTEX CENTERED TRAVERSALS
*******************************************************************************/
// Traversor1VE
template <typename MAP>
Traversor1VE<MAP>::Traversor1VE(MAP& map, Dart dart) : m(map), start(dart)
{
d2 = m.phi_1(start) ;
if(d2 == start) // 1 edge loop case
d2 = NIL ;
}
template <typename MAP>
Dart Traversor1VE<MAP>::begin()
{
current = start ;
return current ;
}
template <typename MAP>
Dart Traversor1VE<MAP>::end()
{
return NIL ;
}
template <typename MAP>
Dart Traversor1VE<MAP>::next()
{
if(current != NIL)
{
if(current == start)
current = d2 ;
else
current = NIL ;
}
return current ;
}
// Traversor1VVaE
template <typename MAP>
Traversor1VVaE<MAP>::Traversor1VVaE(MAP& map, Dart dart) : m(map)
{
start = m.phi_1(dart) ;
if(start == dart) // 1 edge loop case
start = NIL ;
else
{
d2 = m.phi1(dart) ;