Commit b0194eba authored by Pierre Kraemer's avatar Pierre Kraemer

petite refonte des Marks

parent c040b413
......@@ -42,8 +42,7 @@ namespace Algo
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
......@@ -326,7 +325,7 @@ public:
* mark all embedded vertices of the Polyhedron
* @param m the marker to use
*/
void markEmbVertices(Marker m);
// void markEmbVertices(Mark m);
/**
* test if a vertex is in the Polyhedron
......
......@@ -974,21 +974,21 @@ void Polyhedron<PFP>::transform(const Geom::Matrix44f& matrice)
template <typename PFP>
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);
}
}
template <typename PFP>
void Polyhedron<PFP>::markEmbVertices(Marker m)
{
AttributeHandler<Mark> markers(VERTEX<<24,m_map);
for(typename std::vector<Dart>::iterator di=m_tableVertDarts.begin(); di!=m_tableVertDarts.end(); ++di)
{
markers[*di].setMark(m);
}
}
//template <typename PFP>
//void Polyhedron<PFP>::markEmbVertices(Mark m)
//{
// AttributeHandler<Mark> markers(VERTEX << 24, m_map);
// for(typename std::vector<Dart>::iterator di = m_tableVertDarts.begin(); di != m_tableVertDarts.end(); ++di)
// {
// markers[*di].setMark(m);
// }
//}
......@@ -1018,7 +1018,7 @@ void Polyhedron<PFP>::embedTwistedStrip( float radius_min, float radius_max, fl
}
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 ;
......
......@@ -141,7 +141,7 @@ public:
* mark all darts of the primitive
* @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)
template <typename PFP>
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];
pos = Geom::transform(pos, matrice);
......@@ -226,14 +226,14 @@ void Primitive3D<PFP>::transform(const Geom::Matrix44f& matrice)
}
template <typename PFP>
void Primitive3D<PFP>::mark(Marker m)
{
for(typename std::vector<Dart>::iterator di=m_tableVertDarts.begin(); di!=m_tableVertDarts.end(); ++di)
{
m_map.markOrbit(0,*di,m);
}
}
//template <typename PFP>
//void Primitive3D<PFP>::mark(Mark m)
//{
// for(typename std::vector<Dart>::iterator di = m_tableVertDarts.begin(); di != m_tableVertDarts.end(); ++di)
// {
// m_map.markOrbit(0, *di, m);
// }
//}
}//end namespace
}//end namespace
......
......@@ -46,11 +46,11 @@ namespace Render
namespace GL1
{
/**
* Render darts of generalized map
*/
template <typename PFP>
void renderTopoGM2(typename PFP::MAP& the_map, Marker m);
///**
//* Render darts of generalized map
//*/
//template <typename PFP>
//void renderTopoGM2(typename PFP::MAP& the_map, Mark m);
/**
* Render darts of dual map
......@@ -83,11 +83,13 @@ void renderTopoMD3(typename PFP::MAP& the_map, const typename PFP::TVEC3& positi
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);
} // namespace GL1
} // namespace Render
} // namespace Algo
}// end namespace
}// end namespace
}// end namespace
}// end namespace
} // namespace CGoGN
#include "Algo/Render/GL1/topo_render.hpp"
......
......@@ -121,7 +121,7 @@ namespace GL1
//};
//
//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
}
} // namespace GL1
} // endnamespace
} // endnamespace
} // endnamespace
} // endnamespace
} // namespace Render
} // namespace Algo
} // namespace CGoGN
......@@ -47,7 +47,7 @@ enum Intersection
* test the intersection between a ray and a triangle
*/
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
......@@ -60,7 +60,7 @@ Intersection intersectionRayTriangle(const VEC3& P, const VEC3& Dir, const VEC3&
* @return the intersection
*/
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
......@@ -74,7 +74,7 @@ Intersection intersectionLineTriangle(const VEC3& P, const VEC3& Dir, const VEC3
* @return the intersection
*/
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
......@@ -87,13 +87,13 @@ Intersection intersectionLineTriangle2D(const VEC3& P, const VEC3& Dir, const VE
* @return the intersection
*/
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>
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>
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
......
......@@ -40,8 +40,9 @@ namespace CGoGN
class CellMarkerGen
{
protected:
Marker m_marker;
Mark m_mark;
AttribMap& m_map;
unsigned int m_cell;
unsigned int m_thread;
public:
......@@ -49,23 +50,17 @@ public:
* constructor
* @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,...
* \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))
map.addEmbedding(cell) ;
m_marker = map.getNewMarker(cell);
}
CellMarkerGen(AttribMap& map, unsigned int cell, unsigned int thread) : m_map(map), m_thread(thread)
{
m_marker = map.getNewMarker(cell, thread);
m_mark = map.getNewMark(cell, thread);
}
virtual ~CellMarkerGen()
{
m_map.releaseMarker(m_marker, m_thread);
m_map.releaseMark(m_mark, m_cell, m_thread);
}
protected:
......@@ -79,12 +74,11 @@ public:
*/
virtual void mark(Dart d)
{
unsigned int cell = m_marker.getCell() ;
unsigned int a = m_map.getEmbedding(cell, d);
unsigned int a = m_map.getEmbedding(m_cell, d);
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:
*/
virtual void unmark(Dart d)
{
unsigned int cell = m_marker.getCell() ;
unsigned int a = m_map.getEmbedding(cell, d);
unsigned int a = m_map.getEmbedding(m_cell, d);
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:
*/
virtual bool isMarked(Dart d)
{
unsigned int cell = m_marker.getCell() ;
unsigned int a = m_map.getEmbedding(cell, d);
unsigned int a = m_map.getEmbedding(m_cell, d);
if (a == EMBNULL)
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:
*/
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:
*/
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:
*/
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:
*/
virtual void markAll()
{
unsigned int cell = m_marker.getCell() ;
AttributeContainer& cont = m_map.getAttributeContainer(cell) ;
AttributeContainer& cont = m_map.getAttributeContainer(m_cell) ;
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:
class CellMarker : public CellMarkerGen
{
public:
CellMarker(AttribMap& map, unsigned int cell) : CellMarkerGen(map, cell)
{}
CellMarker(AttribMap& map, unsigned int cell, unsigned int thread) : CellMarkerGen(map, cell, thread)
CellMarker(AttribMap& map, unsigned int cell, unsigned int thread = 0) : CellMarkerGen(map, cell, thread)
{}
virtual ~CellMarker()
......@@ -179,10 +167,9 @@ protected:
public:
virtual void unmarkAll()
{
unsigned int cell = m_marker.getCell() ;
AttributeContainer& cont = m_map.getAttributeContainer(cell) ;
AttributeContainer& cont = m_map.getAttributeContainer(m_cell) ;
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:
std::vector<unsigned int> m_markedCells ;
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)
{}
~CellMarkerStore()
virtual ~CellMarkerStore()
{
unmarkAll() ;
}
......@@ -216,7 +200,7 @@ public:
void mark(Dart 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)
......@@ -227,9 +211,8 @@ public:
void unmarkAll()
{
unsigned int cell = m_marker.getCell() ;
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:
class CellMarkerNoUnmark: public CellMarkerGen
{
public:
CellMarkerNoUnmark(AttribMap& map, unsigned int cell) : CellMarkerGen(map, cell)
{}
CellMarkerNoUnmark(AttribMap& map, unsigned int cell, unsigned int thread) : CellMarkerGen(map, cell, thread)
{}
CellMarkerNoUnmark(AttribMap& map, unsigned int cell, unsigned int thread = 0) : CellMarkerGen(map, cell, thread)
{
std::cout << "CellMarkerNoUnmark.." << std::endl ;
}
~CellMarkerNoUnmark()
{}
virtual ~CellMarkerNoUnmark()
{
assert(isAllUnmarked());
}
protected:
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:
void unmarkAll()
{
unsigned int cell = m_marker.getCell() ;
AttributeContainer& cont = m_map.getAttributeContainer(cell) ;
AttributeContainer& cont = m_map.getAttributeContainer(m_cell) ;
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;
const unsigned int NB_ORBITS = 6;
const unsigned int NB_THREAD = 16;
const unsigned int VERTEX = 0;
const unsigned int EDGE = 1;
const unsigned int ORIENTED_FACE= 2;
const unsigned int FACE = 3;
const unsigned int VOLUME = 4;
const unsigned int DART = 5;
const unsigned int VERTEX = 0;
const unsigned int EDGE = 1;
const unsigned int ORIENTED_FACE = 2;
const unsigned int FACE = 3;
const unsigned int VOLUME = 4;
const unsigned int DART = 5;
struct Dart
{
......
......@@ -39,21 +39,23 @@ template <typename MAP>
class FunctorMarker : public FunctorMap<MAP>
{
protected:
Marker m_marker ;
AttributeMultiVector<Mark>* m_markerTable ;
Mark m_mark ;
AttributeMultiVector<Mark>* m_markTable ;
public:
FunctorMarker(MAP& map, Marker m, AttributeMultiVector<Mark>* mTable) : FunctorMap<MAP>(map), m_marker(m), m_markerTable(mTable) {}
Marker getMarker() { return m_marker ; }
FunctorMarker(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable) : FunctorMap<MAP>(map), m_mark(m), m_markTable(mTable)
{}
// Mark getMark() { return m_mark ; }
} ;
template <typename MAP>
class FunctorMark : public FunctorMarker<MAP>
{
public:
FunctorMark(MAP& map, Marker m, AttributeMultiVector<Mark>* mTable) : FunctorMarker<MAP>(map, m, mTable) {}
FunctorMark(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable) : FunctorMarker<MAP>(map, m, mTable)
{}
bool operator()(Dart d)
{
this->m_markerTable->operator[](d.index).setMark(this->m_marker) ;
this->m_markTable->operator[](d.index).setMark(this->m_mark) ;
return false ;
}
} ;
......@@ -64,13 +66,13 @@ class FunctorMarkStore : public FunctorMarker<MAP>
protected:
std::vector<unsigned int>& m_markedDarts ;
public:
FunctorMarkStore(MAP& map, Marker m, AttributeMultiVector<Mark>* mTable, std::vector<unsigned int>& marked) :
FunctorMarkStore(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable, std::vector<unsigned int>& marked) :
FunctorMarker<MAP>(map, m, mTable),
m_markedDarts(marked)
{}
bool operator()(Dart d)
{
this->m_markerTable->operator[](d.index).setMark(this->m_marker) ;
this->m_markTable->operator[](d.index).setMark(this->m_mark) ;
m_markedDarts.push_back(d.index) ;
return false ;
}
......@@ -80,10 +82,11 @@ template <typename MAP>
class FunctorUnmark : public FunctorMarker<MAP>
{
public:
FunctorUnmark(MAP& map, Marker m, AttributeMultiVector<Mark>* mTable) : FunctorMarker<MAP>(map, m, mTable) {}
FunctorUnmark(MAP& map, Mark m, AttributeMultiVector<Mark>* mTable) : FunctorMarker<MAP>(map, m, mTable)
{}
bool operator()(Dart d)
{
this->m_markerTable->operator[](d.index).unsetMark(this->m_marker) ;
this->m_markTable->operator[](d.index).unsetMark(this->m_mark) ;
return false ;
}
} ;
......@@ -95,7 +98,7 @@ public:
class DartMarkerGen
{
protected:
Marker m_marker;
Mark m_mark;
GenericMap& m_map;
unsigned int m_thread;
......@@ -106,17 +109,17 @@ public:
*/
DartMarkerGen(GenericMap& map): m_map(map), m_thread(0)
{
m_marker = map.getNewMarker(DART);
m_mark = map.getNewMark(DART);
}
DartMarkerGen(GenericMap& map, unsigned int thread): m_map(map), m_thread(thread)
{
m_marker = map.getNewMarker(DART, thread);
m_mark = map.getNewMark(DART, thread);
}
virtual ~DartMarkerGen()
{
m_map.releaseMarker(m_marker, m_thread);
m_map.releaseMark(m_mark, DART, m_thread);
}
protected:
......@@ -130,7 +133,7 @@ public:
*/
virtual void mark(Dart d)
{
m_map.getMarkerVector(DART, m_thread)->operator[](d.index).setMark(m_marker);
m_map.getMarkVector(DART, m_thread)->operator[](d.index).setMark(m_mark);
}
/**
......@@ -138,7 +141,7 @@ public:
*/
virtual void unmark(Dart d)
{
m_map.getMarkerVector(DART, m_thread)->operator[](d.index).unsetMark(m_marker);
m_map.getMarkVector(DART, m_thread)->operator[](d.index).unsetMark(m_mark);
}
/**
......@@ -146,7 +149,7 @@ public:
*/
virtual bool isMarked(Dart d)
{
return m_map.getMarkerVector(DART, m_thread)->operator[](d.index).testMark(m_marker);
return m_map.getMarkVector(DART, m_thread)->operator[](d.index).testMark(m_mark);
}
/**
......@@ -154,7 +157,7 @@ public:
*/
virtual void markOrbit(unsigned int orbit, Dart d)
{
FunctorMark<GenericMap> fm(m_map, m_marker, m_map.getMarkerVector(DART, m_thread)) ;
FunctorMark<GenericMap> fm(m_map, m_mark, m_map.getMarkVector(DART, m_thread)) ;
m_map.foreach_dart_of_orbit(orbit, d, fm, m_thread) ;
}
......@@ -163,7 +166,7 @@ public:
*/
virtual void unmarkOrbit(unsigned int orbit, Dart d)
{
FunctorUnmark<GenericMap> fm(m_map, m_marker, m_map.getMarkerVector(DART, m_thread)) ;
FunctorUnmark<GenericMap> fm(m_map, m_mark, m_map.getMarkVector(DART, m_thread)) ;
m_map.foreach_dart_of_orbit(orbit, d, fm, m_thread) ;
}
......@@ -173,7 +176,7 @@ public:
template <typename MAP>
void markOrbitInParent(unsigned int orbit, Dart d)
{
FunctorMark<GenericMap> fm(m_map, m_marker, m_map.getMarkerVector(DART, m_thread)) ;
FunctorMark<GenericMap> fm(m_map, m_mark, m_map.getMarkVector(DART, m_thread)) ;
foreach_dart_of_orbit_in_parent<MAP>(dynamic_cast<MAP*>(&m_map), orbit, d, fm, m_thread);
}
......@@ -183,7 +186,7 @@ public:
template <typename MAP>
void unmarkOrbitInParent(unsigned int orbit, Dart d)
{
FunctorUnmark<GenericMap> fm(m_map, m_marker, m_map.getMarkerVector(DART, m_thread)) ;
FunctorUnmark<GenericMap> fm(m_map, m_mark, m_map.getMarkVector(DART, m_thread)) ;
foreach_dart_of_orbit_in_parent<MAP>(dynamic_cast<MAP*>(&m_map), orbit, d, fm, m_thread);
}
......@@ -194,7 +197,7 @@ public:
{
AttributeContainer& cont = m_map.getAttributeContainer(DART) ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
m_map.getMarkerVector(DART, m_thread)->operator[](i).setMark(m_marker);
m_map.getMarkVector(DART, m_thread)->operator[](i).setMark(m_mark);
}
/**
......@@ -230,7 +233,7 @@ public:
{
AttributeContainer& cont = m_map.getAttributeContainer(DART) ;