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

petite refonte des Marks

parent c040b413
...@@ -42,8 +42,7 @@ namespace Algo ...@@ -42,8 +42,7 @@ namespace Algo
namespace Modelisation namespace Modelisation
{ {
enum {NONE,GRID, CUBE, CYLINDER, CONE, SPHERE, TORE, COMPOSED}; enum { NONE,GRID, CUBE, CYLINDER, CONE, SPHERE, TORE, COMPOSED };
/** /**
* sudivide the all quads of primtive into 2 triangles * sudivide the all quads of primtive into 2 triangles
...@@ -326,7 +325,7 @@ public: ...@@ -326,7 +325,7 @@ public:
* mark all embedded vertices of the Polyhedron * mark all embedded vertices of the Polyhedron
* @param m the marker to use * @param m the marker to use
*/ */
void markEmbVertices(Marker m); // void markEmbVertices(Mark m);
/** /**
* test if a vertex is in the Polyhedron * test if a vertex is in the Polyhedron
......
...@@ -974,21 +974,21 @@ void Polyhedron<PFP>::transform(const Geom::Matrix44f& matrice) ...@@ -974,21 +974,21 @@ void Polyhedron<PFP>::transform(const Geom::Matrix44f& matrice)
template <typename PFP> template <typename PFP>
void Polyhedron<PFP>::mark(CellMarker& m) void Polyhedron<PFP>::mark(CellMarker& m)
{ {
for(typename std::vector<Dart>::iterator di=m_tableVertDarts.begin(); di!=m_tableVertDarts.end(); ++di) for(typename std::vector<Dart>::iterator di = m_tableVertDarts.begin(); di != m_tableVertDarts.end(); ++di)
{ {
m.mark(*di); m.mark(*di);
} }
} }
template <typename PFP> //template <typename PFP>
void Polyhedron<PFP>::markEmbVertices(Marker m) //void Polyhedron<PFP>::markEmbVertices(Mark m)
{ //{
AttributeHandler<Mark> markers(VERTEX<<24,m_map); // AttributeHandler<Mark> markers(VERTEX << 24, m_map);
for(typename std::vector<Dart>::iterator di=m_tableVertDarts.begin(); di!=m_tableVertDarts.end(); ++di) // for(typename std::vector<Dart>::iterator di = m_tableVertDarts.begin(); di != m_tableVertDarts.end(); ++di)
{ // {
markers[*di].setMark(m); // markers[*di].setMark(m);
} // }
} //}
...@@ -1018,7 +1018,7 @@ void Polyhedron<PFP>::embedTwistedStrip( float radius_min, float radius_max, fl ...@@ -1018,7 +1018,7 @@ void Polyhedron<PFP>::embedTwistedStrip( float radius_min, float radius_max, fl
} }
template <typename PFP> template <typename PFP>
void Polyhedron<PFP>::embedHelicoid( float radius_min, float radius_max, float maxHeight, float nbTurn, int orient) void Polyhedron<PFP>::embedHelicoid(float radius_min, float radius_max, float maxHeight, float nbTurn, int orient)
{ {
typedef typename PFP::VEC3 VEC3 ; typedef typename PFP::VEC3 VEC3 ;
......
...@@ -141,7 +141,7 @@ public: ...@@ -141,7 +141,7 @@ public:
* mark all darts of the primitive * mark all darts of the primitive
* @param m the marker to use * @param m the marker to use
*/ */
void mark(Marker m); // void mark(Mark m);
/** /**
......
...@@ -218,7 +218,7 @@ void Primitive3D<PFP>::embedHexaGrid( float x, float y, float z) ...@@ -218,7 +218,7 @@ void Primitive3D<PFP>::embedHexaGrid( float x, float y, float z)
template <typename PFP> template <typename PFP>
void Primitive3D<PFP>::transform(const Geom::Matrix44f& matrice) void Primitive3D<PFP>::transform(const Geom::Matrix44f& matrice)
{ {
for(typename std::vector<Dart>::iterator di=m_tableVertDarts.begin(); di!=m_tableVertDarts.end(); ++di) for(typename std::vector<Dart>::iterator di = m_tableVertDarts.begin(); di != m_tableVertDarts.end(); ++di)
{ {
typename PFP::VEC3& pos = m_positions[*di]; typename PFP::VEC3& pos = m_positions[*di];
pos = Geom::transform(pos, matrice); pos = Geom::transform(pos, matrice);
...@@ -226,14 +226,14 @@ void Primitive3D<PFP>::transform(const Geom::Matrix44f& matrice) ...@@ -226,14 +226,14 @@ void Primitive3D<PFP>::transform(const Geom::Matrix44f& matrice)
} }
template <typename PFP> //template <typename PFP>
void Primitive3D<PFP>::mark(Marker m) //void Primitive3D<PFP>::mark(Mark m)
{ //{
for(typename std::vector<Dart>::iterator di=m_tableVertDarts.begin(); di!=m_tableVertDarts.end(); ++di) // for(typename std::vector<Dart>::iterator di = m_tableVertDarts.begin(); di != m_tableVertDarts.end(); ++di)
{ // {
m_map.markOrbit(0,*di,m); // m_map.markOrbit(0, *di, m);
} // }
} //}
}//end namespace }//end namespace
}//end namespace }//end namespace
......
...@@ -46,11 +46,11 @@ namespace Render ...@@ -46,11 +46,11 @@ namespace Render
namespace GL1 namespace GL1
{ {
/** ///**
* Render darts of generalized map //* Render darts of generalized map
*/ //*/
template <typename PFP> //template <typename PFP>
void renderTopoGM2(typename PFP::MAP& the_map, Marker m); //void renderTopoGM2(typename PFP::MAP& the_map, Mark m);
/** /**
* Render darts of dual map * Render darts of dual map
...@@ -83,11 +83,13 @@ void renderTopoMD3(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi ...@@ -83,11 +83,13 @@ void renderTopoMD3(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
template <typename PFP> template <typename PFP>
void renderTopoMD3(typename PFP::MAP& map, typename PFP::TVEC3& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv); void renderTopoMD3(typename PFP::MAP& map, typename PFP::TVEC3& positions, bool drawPhi1, bool drawPhi2, bool drawPhi3, float ke, float kf, float kv);
} // namespace GL1
} // namespace Render
} // namespace Algo
}// end namespace } // namespace CGoGN
}// end namespace
}// end namespace
}// end namespace
#include "Algo/Render/GL1/topo_render.hpp" #include "Algo/Render/GL1/topo_render.hpp"
......
...@@ -121,7 +121,7 @@ namespace GL1 ...@@ -121,7 +121,7 @@ namespace GL1
//}; //};
// //
//template <typename PFP> //template <typename PFP>
//void renderTopoGM2(typename PFP::MAP& map, Marker m) //void renderTopoGM2(typename PFP::MAP& map, Mark m)
//{ //{
// //
// //
...@@ -642,9 +642,11 @@ void renderTopoMD3(typename PFP::MAP& map, typename PFP::TVEC3& positions, bool ...@@ -642,9 +642,11 @@ void renderTopoMD3(typename PFP::MAP& map, typename PFP::TVEC3& positions, bool
} }
} // namespace GL1
} // endnamespace } // namespace Render
} // endnamespace
} // endnamespace } // namespace Algo
} // endnamespace
} // namespace CGoGN
...@@ -47,7 +47,7 @@ enum Intersection ...@@ -47,7 +47,7 @@ enum Intersection
* test the intersection between a ray and a triangle * test the intersection between a ray and a triangle
*/ */
template <typename VEC3> template <typename VEC3>
Intersection intersectionRayTriangle(const VEC3& P, const VEC3& Dir, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ; Intersection intersectionRayTriangle(const VEC3& P, const VEC3& Dir, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ;
/** /**
* test the intersection between a line and a triangle * test the intersection between a line and a triangle
...@@ -60,7 +60,7 @@ Intersection intersectionRayTriangle(const VEC3& P, const VEC3& Dir, const VEC3& ...@@ -60,7 +60,7 @@ Intersection intersectionRayTriangle(const VEC3& P, const VEC3& Dir, const VEC3&
* @return the intersection * @return the intersection
*/ */
template <typename VEC3> template <typename VEC3>
Intersection intersectionLineTriangle(const VEC3& P, const VEC3& Dir, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ; Intersection intersectionLineTriangle(const VEC3& P, const VEC3& Dir, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ;
/** /**
* test the intersection between a line and a triangle the line MUST be in the plane of the triangle, assumed to be CCW * test the intersection between a line and a triangle the line MUST be in the plane of the triangle, assumed to be CCW
...@@ -74,7 +74,7 @@ Intersection intersectionLineTriangle(const VEC3& P, const VEC3& Dir, const VEC3 ...@@ -74,7 +74,7 @@ Intersection intersectionLineTriangle(const VEC3& P, const VEC3& Dir, const VEC3
* @return the intersection * @return the intersection
*/ */
template <typename VEC3> template <typename VEC3>
Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ; Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ;
/** /**
* test the intersection between a segment and a triangle * test the intersection between a segment and a triangle
...@@ -87,13 +87,13 @@ Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VE ...@@ -87,13 +87,13 @@ Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VE
* @return the intersection * @return the intersection
*/ */
template <typename VEC3> template <typename VEC3>
Intersection intersectionSegmentTriangle(const VEC3& PA, const VEC3& PB, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ; Intersection intersectionSegmentTriangle(const VEC3& PA, const VEC3& PB, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc, VEC3& Inter) ;
template <typename VEC3, typename PLANE3D> template <typename VEC3, typename PLANE3D>
Intersection intersectionPlaneRay(const PLANE3D& pl,const VEC3& p1,const VEC3& dir, VEC3& Inter); Intersection intersectionPlaneRay(const PLANE3D& pl,const VEC3& p1,const VEC3& dir, VEC3& Inter) ;
template <typename VEC3> template <typename VEC3>
Intersection intersection2DSegmentSegment(const VEC3& PA, const VEC3& PB, const VEC3& QA, const VEC3& QB, VEC3& Inter) ; Intersection intersection2DSegmentSegment(const VEC3& PA, const VEC3& PB, const VEC3& QA, const VEC3& QB, VEC3& Inter) ;
} // namespace Geom } // namespace Geom
......
...@@ -40,8 +40,9 @@ namespace CGoGN ...@@ -40,8 +40,9 @@ namespace CGoGN
class CellMarkerGen class CellMarkerGen
{ {
protected: protected:
Marker m_marker; Mark m_mark;
AttribMap& m_map; AttribMap& m_map;
unsigned int m_cell;
unsigned int m_thread; unsigned int m_thread;
public: public:
...@@ -49,23 +50,17 @@ public: ...@@ -49,23 +50,17 @@ public:
* constructor * constructor
* @param map the map on which we work (not stored use to get table of markers and new marker. * @param map the map on which we work (not stored use to get table of markers and new marker.
* @param cell the type of cell we want to mark VERTEX, EDGE,... * @param cell the type of cell we want to mark VERTEX, EDGE,...
* \pre the cell is embedded in the map
*/ */
CellMarkerGen(AttribMap& map, unsigned int cell) : m_map(map), m_thread(0) CellMarkerGen(AttribMap& map, unsigned int cell, unsigned int thread = 0) : m_map(map), m_cell(cell), m_thread(thread)
{ {
if(!map.isOrbitEmbedded(cell)) if(!map.isOrbitEmbedded(cell))
map.addEmbedding(cell) ; map.addEmbedding(cell) ;
m_marker = map.getNewMarker(cell); m_mark = map.getNewMark(cell, thread);
}
CellMarkerGen(AttribMap& map, unsigned int cell, unsigned int thread) : m_map(map), m_thread(thread)
{
m_marker = map.getNewMarker(cell, thread);
} }
virtual ~CellMarkerGen() virtual ~CellMarkerGen()
{ {
m_map.releaseMarker(m_marker, m_thread); m_map.releaseMark(m_mark, m_cell, m_thread);
} }
protected: protected:
...@@ -79,12 +74,11 @@ public: ...@@ -79,12 +74,11 @@ public:
*/ */
virtual void mark(Dart d) virtual void mark(Dart d)
{ {
unsigned int cell = m_marker.getCell() ; unsigned int a = m_map.getEmbedding(m_cell, d);
unsigned int a = m_map.getEmbedding(cell, d);
if (a == EMBNULL) if (a == EMBNULL)
a = m_map.embedNewCell(cell, d); a = m_map.embedNewCell(m_cell, d);
m_map.getMarkerVector(cell, m_thread)->operator[](a).setMark(m_marker); m_map.getMarkVector(m_cell, m_thread)->operator[](a).setMark(m_mark);
} }
/** /**
...@@ -92,12 +86,11 @@ public: ...@@ -92,12 +86,11 @@ public:
*/ */
virtual void unmark(Dart d) virtual void unmark(Dart d)
{ {
unsigned int cell = m_marker.getCell() ; unsigned int a = m_map.getEmbedding(m_cell, d);
unsigned int a = m_map.getEmbedding(cell, d);
if (a == EMBNULL) if (a == EMBNULL)
a = m_map.embedNewCell(cell, d); a = m_map.embedNewCell(m_cell, d);
m_map.getMarkerVector(cell, m_thread)->operator[](a).unsetMark(m_marker); m_map.getMarkVector(m_cell, m_thread)->operator[](a).unsetMark(m_mark);
} }
/** /**
...@@ -105,12 +98,11 @@ public: ...@@ -105,12 +98,11 @@ public:
*/ */
virtual bool isMarked(Dart d) virtual bool isMarked(Dart d)
{ {
unsigned int cell = m_marker.getCell() ; unsigned int a = m_map.getEmbedding(m_cell, d);
unsigned int a = m_map.getEmbedding(cell, d);
if (a == EMBNULL) if (a == EMBNULL)
return false; return false;
return m_map.getMarkerVector(cell, m_thread)->operator[](a).testMark(m_marker); return m_map.getMarkVector(m_cell, m_thread)->operator[](a).testMark(m_mark);
} }
/** /**
...@@ -118,7 +110,7 @@ public: ...@@ -118,7 +110,7 @@ public:
*/ */
virtual void mark(unsigned int em) virtual void mark(unsigned int em)
{ {
m_map.getMarkerVector(m_marker.getCell(), m_thread)->operator[](em).setMark(m_marker); m_map.getMarkVector(m_cell, m_thread)->operator[](em).setMark(m_mark);
} }
/** /**
...@@ -126,7 +118,7 @@ public: ...@@ -126,7 +118,7 @@ public:
*/ */
virtual void unmark(unsigned int em) virtual void unmark(unsigned int em)
{ {
m_map.getMarkerVector(m_marker.getCell(), m_thread)->operator[](em).unsetMark(m_marker); m_map.getMarkVector(m_cell, m_thread)->operator[](em).unsetMark(m_mark);
} }
/** /**
...@@ -134,7 +126,7 @@ public: ...@@ -134,7 +126,7 @@ public:
*/ */
virtual bool isMarked(unsigned int em) virtual bool isMarked(unsigned int em)
{ {
return m_map.getMarkerVector(m_marker.getCell(), m_thread)->operator[](em).testMark(m_marker); return m_map.getMarkVector(m_cell, m_thread)->operator[](em).testMark(m_mark);
} }
/** /**
...@@ -142,10 +134,9 @@ public: ...@@ -142,10 +134,9 @@ public:
*/ */
virtual void markAll() virtual void markAll()
{ {
unsigned int cell = m_marker.getCell() ; AttributeContainer& cont = m_map.getAttributeContainer(m_cell) ;
AttributeContainer& cont = m_map.getAttributeContainer(cell) ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i)) for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
m_map.getMarkerVector(cell,m_thread)->operator[](i).setMark(m_marker); m_map.getMarkVector(m_cell, m_thread)->operator[](i).setMark(m_mark);
} }
/** /**
...@@ -161,10 +152,7 @@ public: ...@@ -161,10 +152,7 @@ public:
class CellMarker : public CellMarkerGen class CellMarker : public CellMarkerGen
{ {
public: public:
CellMarker(AttribMap& map, unsigned int cell) : CellMarkerGen(map, cell) CellMarker(AttribMap& map, unsigned int cell, unsigned int thread = 0) : CellMarkerGen(map, cell, thread)
{}
CellMarker(AttribMap& map, unsigned int cell, unsigned int thread) : CellMarkerGen(map, cell, thread)
{} {}
virtual ~CellMarker() virtual ~CellMarker()
...@@ -179,10 +167,9 @@ protected: ...@@ -179,10 +167,9 @@ protected:
public: public:
virtual void unmarkAll() virtual void unmarkAll()
{ {
unsigned int cell = m_marker.getCell() ; AttributeContainer& cont = m_map.getAttributeContainer(m_cell) ;
AttributeContainer& cont = m_map.getAttributeContainer(cell) ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i)) for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
m_map.getMarkerVector(cell, m_thread)->operator[](i).unsetMark(m_marker) ; m_map.getMarkVector(m_cell, m_thread)->operator[](i).unsetMark(m_mark) ;
} }
}; };
...@@ -197,13 +184,10 @@ protected: ...@@ -197,13 +184,10 @@ protected:
std::vector<unsigned int> m_markedCells ; std::vector<unsigned int> m_markedCells ;
public: public:
CellMarkerStore(AttribMap& map, unsigned int cell) : CellMarkerGen(map, cell) CellMarkerStore(AttribMap& map, unsigned int cell, unsigned int thread = 0) : CellMarkerGen(map, cell, thread)
{} {}
CellMarkerStore(AttribMap& map, unsigned int cell, unsigned int thread) : CellMarkerGen(map, cell, thread) virtual ~CellMarkerStore()
{}
~CellMarkerStore()
{ {
unmarkAll() ; unmarkAll() ;
} }
...@@ -216,7 +200,7 @@ public: ...@@ -216,7 +200,7 @@ public:
void mark(Dart d) void mark(Dart d)
{ {
CellMarkerGen::mark(d) ; CellMarkerGen::mark(d) ;
m_markedCells.push_back(m_map.getEmbedding(m_marker.getCell(), d)) ; m_markedCells.push_back(m_map.getEmbedding(m_cell, d)) ;
} }
void mark(unsigned int em) void mark(unsigned int em)
...@@ -227,9 +211,8 @@ public: ...@@ -227,9 +211,8 @@ public:
void unmarkAll() void unmarkAll()
{ {
unsigned int cell = m_marker.getCell() ;
for (std::vector<unsigned int>::iterator it = m_markedCells.begin(); it != m_markedCells.end(); ++it) for (std::vector<unsigned int>::iterator it = m_markedCells.begin(); it != m_markedCells.end(); ++it)
m_map.getMarkerVector(cell,m_thread)->operator[](*it).unsetMark(m_marker) ; m_map.getMarkVector(m_cell, m_thread)->operator[](*it).unsetMark(m_mark) ;
} }
}; };
...@@ -241,27 +224,35 @@ public: ...@@ -241,27 +224,35 @@ public:
class CellMarkerNoUnmark: public CellMarkerGen class CellMarkerNoUnmark: public CellMarkerGen
{ {
public: public:
CellMarkerNoUnmark(AttribMap& map, unsigned int cell) : CellMarkerGen(map, cell) CellMarkerNoUnmark(AttribMap& map, unsigned int cell, unsigned int thread = 0) : CellMarkerGen(map, cell, thread)
{} {
std::cout << "CellMarkerNoUnmark.." << std::endl ;
}
CellMarkerNoUnmark(AttribMap& map, unsigned int cell, unsigned int thread) : CellMarkerGen(map, cell, thread)
{}
~CellMarkerNoUnmark() virtual ~CellMarkerNoUnmark()
{} {
assert(isAllUnmarked());
}
protected: protected:
CellMarkerNoUnmark(const CellMarkerNoUnmark& cm) : CellMarkerGen(cm) CellMarkerNoUnmark(const CellMarkerNoUnmark& cm) : CellMarkerGen(cm)
{} {}
bool isAllUnmarked()
{
AttributeContainer& cont = m_map.getAttributeContainer(m_cell) ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
if(m_map.getMarkVector(m_cell, m_thread)->operator[](i).testMark(m_mark))
return false ;
return true ;
}
public: public:
void unmarkAll() void unmarkAll()
{ {
unsigned int cell = m_marker.getCell() ; AttributeContainer& cont = m_map.getAttributeContainer(m_cell) ;
AttributeContainer& cont = m_map.getAttributeContainer(cell) ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i)) for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
m_map.getMarkerVector(cell, m_thread)->operator[](i).unsetMark(m_marker) ; m_map.getMarkVector(m_cell, m_thread)->operator[](i).unsetMark(m_mark) ;
} }
}; };
......
...@@ -35,13 +35,12 @@ const unsigned int EMBNULL = 0xffffffff; ...@@ -35,13 +35,12 @@ const unsigned int EMBNULL = 0xffffffff;
const unsigned int NB_ORBITS = 6; const unsigned int NB_ORBITS = 6;