Commit 7b39d3ef authored by Pierre Kraemer's avatar Pierre Kraemer

Merge branch 'no_boundary' of cgogn:~thery/CGoGN into no_boundary

parents 31c3e326 935a7816
......@@ -92,6 +92,9 @@ void MyQT::cb_redraw()
m_render->draw(m_shader, Algo::Render::GL2::BOUNDARY);
glPointSize(7.0f);
m_shader->setColor(Geom::Vec4f(1.,1.,1.,0.));
m_render->draw(m_shader, Algo::Render::GL2::POINTS);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f);
......@@ -123,6 +126,8 @@ void MyQT::cb_keyPress(int code)
}
}
int main(int argc, char **argv)
{
......@@ -174,9 +179,19 @@ int main(int argc, char **argv)
// update des primitives du renderer
SelectorEdgeNoBoundary<PFP::MAP> insideEdges(myMap);// just to draw only inside edges
DartMarker dm(myMap);
dm.markOrbit(VERTEX,d2);
dm.markOrbit(VERTEX,d1);
CellMarker cm(myMap,FACE);
cm.mark(d2);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
sqt.m_render->initPrimitives<PFP>(myMap, insideEdges, Algo::Render::GL2::LINES);
sqt.m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::BOUNDARY); // special primitive for boundary edges
// example of using boolean operator on Selectors
sqt.m_render->initPrimitives<PFP>(myMap, ( SelectorFalse() || ( SelectorTrue() && (SelectorMarked(dm) && SelectorCellMarked(cm)))) , Algo::Render::GL2::POINTS); // special primitive for boundary edges
// show final pour premier redraw
sqt.show();
......
......@@ -48,19 +48,29 @@ void SVGOut::renderPointsToSVG(typename PFP::MAP& map, const typename PFP::TVEC3
SvgPoints* points = new SvgPoints();
points->setColor(global_color);
points->setWidth(global_width);
DartMarker m(map, thread);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!m.isMarked(d) && good(d))
// DartMarker m(map, thread);
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if(!m.isMarked(d) && good(d))
// {
// const Geom::Vec3f& P = position[d];
// glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
// glm::vec3 R = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,glm::mat4(1.0),viewport);
// points->addVertex(Geom::Vec3f(Q[0],float(viewport[3])-Q[1],Q[2]));
// m.markOrbit(VERTEX, d);
// }
// }
// m_objs.push_back(points);
TraversorV<typename PFP::MAP> trav(map,good,thread);
for(Dart d = trav.begin(); d != trav.end(); d=trav.next())
{
const Geom::Vec3f& P = position[d];
glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
glm::vec3 R = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,glm::mat4(1.0),viewport);
points->addVertex(Geom::Vec3f(Q[0],float(viewport[3])-Q[1],Q[2]));
m.markOrbit(VERTEX, d);
}
}
m_objs.push_back(points);
}
......@@ -70,12 +80,38 @@ void SVGOut::renderLinesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3&
glm::i32vec4 viewport;
glGetIntegerv(GL_VIEWPORT, &(viewport[0]));
DartMarker m(map, thread);
for(Dart d = map.begin(); d != map.end(); map.next(d))
// DartMarker m(map, thread);
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if(!m.isMarked(d) && good(d))
// {
//
// const Geom::Vec3f& P = position[d];
// glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
// glm::vec3 R = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,glm::mat4(1.0),viewport);
//
// const Geom::Vec3f& P2 = position[map.phi1(d)];
// glm::vec3 Q2 = glm::project(glm::vec3(P2[0],P2[1],P2[2]),m_model,m_proj,viewport);
// glm::vec3 R2 = glm::project(glm::vec3(P2[0],P2[1],P2[2]),m_model,glm::mat4(1.0),viewport);
//
// SvgPolyline* pol = new SvgPolyline();
// pol->addVertex(Geom::Vec3f(Q[0],float(viewport[3])-Q[1],Q[2]));
// pol->addVertex(Geom::Vec3f(Q2[0],float(viewport[3])-Q2[1],Q2[2]));
//
// pol->addVertex3D(Geom::Vec3f(R[0],float(viewport[3])-R[1],R[2]));
// pol->addVertex3D(Geom::Vec3f(R2[0],float(viewport[3])-R2[1],R2[2]));
//
// pol->setColor(global_color);
// pol->setWidth(global_width);
// m_objs.push_back(pol);
// m.markOrbit(EDGE, d);
// }
// }
TraversorE<typename PFP::MAP> trav(map,good,thread);
for(Dart d = trav.begin(); d != trav.end(); d=trav.next())
{
if(!m.isMarked(d) && good(d))
{
const Geom::Vec3f& P = position[d];
glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
glm::vec3 R = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,glm::mat4(1.0),viewport);
......@@ -94,8 +130,6 @@ void SVGOut::renderLinesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3&
pol->setColor(global_color);
pol->setWidth(global_width);
m_objs.push_back(pol);
m.markOrbit(EDGE, d);
}
}
}
......@@ -106,10 +140,55 @@ void SVGOut::renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3&
glm::i32vec4 viewport;
glGetIntegerv(GL_VIEWPORT, &(viewport[0]));
DartMarker m(map, thread);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!m.isMarked(d) && good(d))
// DartMarker m(map, thread);
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if(!m.isMarked(d) && good(d))
// {
// bool cullFace=false;
// if (cull)
// {
// const Geom::Vec3f& P = position[d];
//
// glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
// const Geom::Vec3f& P2 = position[map.phi1(d)];
// glm::vec3 R = glm::project(glm::vec3(P2[0],P2[1],P2[2]),m_model,m_proj,viewport);
// const Geom::Vec3f& P3 = position[map.phi1(map.phi1(d))];
// glm::vec3 S = glm::project(glm::vec3(P3[0],P3[1],P3[2]),m_model,m_proj,viewport);
// glm::vec3 N = glm::cross(S-R,Q-R);
// if (N[2]<0.0f)
// cullFace=true;
// }
//
// if (!cullFace)
// {
// typename PFP::VEC3 center = Algo::Geometry::faceCentroid<PFP>(map,d,position);
// SvgPolygon* pol = new SvgPolygon();
// Dart dd = d;
// do
// {
// Geom::Vec3f P = position[d];
// P = P*shrink + center*(1.0f-shrink);
// glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
// glm::vec3 R = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,glm::mat4(1.0),viewport);
// pol->addVertex(Geom::Vec3f(Q[0],float(viewport[3])-Q[1],Q[2]));
// pol->addVertex3D(Geom::Vec3f(R[0],R[1],R[2]));
// d = map.phi1(d);
// }while (d!=dd);
//
// pol->close();
// pol->setColor(global_color);
// pol->setWidth(global_width);
// m_objs.push_back(pol);
// }
// m.markOrbit(FACE, d);
// }
// }
TraversorF<typename PFP::MAP> trav(map,good,thread);
for(Dart d = trav.begin(); d != trav.end(); d=trav.next())
{
bool cullFace=false;
if (cull)
......@@ -147,9 +226,8 @@ void SVGOut::renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3&
pol->setWidth(global_width);
m_objs.push_back(pol);
}
m.markOrbit(FACE, d);
}
}
}
......
......@@ -103,7 +103,7 @@ public:
/**
* test if cell of dart is marked
*/
virtual bool isMarked(Dart d)
virtual bool isMarked(Dart d) const
{
assert(m_map.getMarkerSet(m_cell,m_thread).testMark(m_mark));
assert(m_map.getMarkVector(m_cell, m_thread) != NULL);
......@@ -140,7 +140,7 @@ public:
/**
* test if cell is marked
*/
virtual bool isMarked(unsigned int em)
virtual bool isMarked(unsigned int em) const
{
assert(m_map.getMarkerSet(m_cell,m_thread).testMark(m_mark));
assert(m_map.getMarkVector(m_cell, m_thread) != NULL);
......@@ -305,29 +305,31 @@ public:
class SelectorCellMarked : public FunctorSelect
{
protected:
CellMarkerGen& m_cmarker ;
const CellMarkerGen& m_cmarker ;
public:
SelectorCellMarked(CellMarkerGen& cm) : m_cmarker(cm) {}
SelectorCellMarked(const CellMarkerGen& cm) : m_cmarker(cm) {}
bool operator()(Dart d) const
{
if (m_cmarker.isMarked(d))
return true ;
return false ;
}
FunctorSelect* copy() const { return new SelectorCellMarked(m_cmarker);}
};
class SelectorCellUnmarked : public FunctorSelect
{
protected:
CellMarkerGen& m_cmarker ;
const CellMarkerGen& m_cmarker ;
public:
SelectorCellUnmarked(CellMarkerGen& cm) : m_cmarker(cm) {}
SelectorCellUnmarked(const CellMarkerGen& cm) : m_cmarker(cm) {}
bool operator()(Dart d) const
{
if (!m_cmarker.isMarked(d))
return true ;
return false ;
}
FunctorSelect* copy() const { return new SelectorCellUnmarked(m_cmarker);}
};
// Functor version (needed for use with foreach_xxx)
......
......@@ -90,7 +90,7 @@ public:
/**
* test if dart is marked
*/
virtual bool isMarked(Dart d)
virtual bool isMarked(Dart d) const
{
assert(m_map.getMarkerSet(DART, m_thread).testMark(m_mark));
return m_map.getMarkVector(DART, m_thread)->operator[](d.index).testMark(m_mark);
......@@ -294,6 +294,7 @@ public:
{
return m_marker.isMarked(d);
}
FunctorSelect* copy() const { return new SelectorMarked(m_marker);}
};
class SelectorUnmarked : public FunctorSelect
......@@ -306,6 +307,7 @@ public:
{
return !m_marker.isMarked(d);
}
FunctorSelect* copy() const { return new SelectorUnmarked(m_marker);}
};
// Functor version (needed for use with foreach_xxx)
......
......@@ -27,6 +27,7 @@
#include "Topology/generic/dart.h"
#include "Topology/generic/marker.h"
#include "Container/attributeMultiVector.h"
#include <vector>
......@@ -62,32 +63,63 @@ public:
FunctorSelect() {}
virtual ~FunctorSelect() {}
virtual bool operator()(Dart d) const = 0 ;
virtual FunctorSelect* copy() const = 0;
};
class SelectorTrue : public FunctorSelect
{
public:
bool operator()(Dart) const { return true; }
FunctorSelect* copy() const { return new SelectorTrue();}
};
class SelectorFalse : public FunctorSelect
{
public:
bool operator()(Dart) const { return false; }
FunctorSelect* copy() const { return new SelectorFalse();}
};
const SelectorTrue allDarts = SelectorTrue() ;
//template <typename MAP>
//class SelectorNoBoundary : public FunctorSelect
//{
//public:
//protected:
// MAP& m_map;
//public:
// SelectorNoBoundary(MAP& m): m_map(m) {}
// bool operator()(Dart d) const { return !m_map.isBoundaryMarked(d); }
//};
class SelectorAnd : public FunctorSelect
{
protected:
const FunctorSelect* m_sel1;
const FunctorSelect* m_sel2;
public:
SelectorAnd(const FunctorSelect& fs1, const FunctorSelect& fs2) { m_sel1 = fs1.copy(); m_sel2 = fs2.copy();}
bool operator()(Dart d) const { return m_sel1->operator()(d) && m_sel2->operator()(d); }
~SelectorAnd() { delete m_sel1; delete m_sel2;}
FunctorSelect* copy() const { return new SelectorAnd(*m_sel1,*m_sel2);}
};
class SelectorOr : public FunctorSelect
{
protected:
const FunctorSelect* m_sel1;
const FunctorSelect* m_sel2;
public:
SelectorOr(const FunctorSelect& fs1, const FunctorSelect& fs2) { m_sel1 = fs1.copy(); m_sel2 = fs2.copy();}
bool operator()(Dart d) const { return m_sel1->operator()(d) || m_sel2->operator()(d); }
~SelectorOr() { delete m_sel1; delete m_sel2;}
FunctorSelect* copy() const { return new SelectorOr(*m_sel1,*m_sel2);}
};
inline SelectorAnd operator&&(const FunctorSelect& fs1, const FunctorSelect& fs2)
{
return SelectorAnd(fs1,fs2);
}
inline SelectorOr operator||(const FunctorSelect& fs1, const FunctorSelect& fs2)
{
return SelectorOr(fs1,fs2);
}
template <typename MAP>
class SelectorEdgeBoundary : public FunctorSelect
......@@ -98,6 +130,7 @@ protected:
public:
SelectorEdgeBoundary(MAP& m): m_map(m) {}
bool operator()(Dart d) const { return m_map.isBoundaryEdge(d); }
FunctorSelect* copy() const { return new SelectorEdgeBoundary(m_map);}
};
......@@ -110,8 +143,53 @@ protected:
public:
SelectorEdgeNoBoundary(MAP& m): m_map(m) {}
bool operator()(Dart d) const { return !m_map.isBoundaryEdge(d); }
FunctorSelect* copy() const { return new SelectorEdgeNoBoundary(m_map);}
};
//
//class SelectorDartMarked : public FunctorSelect
//{
//public:
//protected:
// const DartMarker& m_dm;
//public:
// SelectorDartMarked(const DartMarker& dm): m_dm(dm) {}
// bool operator()(Dart d) const { return m_dm.isMarked(d); }
//};
//
//
//class SelectorCellMarked : public FunctorSelect
//{
//public:
//protected:
// const CellMarker& m_cm;
//public:
// SelectorCellMarked(const CellMarker& cm): m_cm(cm) {}
// bool operator()(Dart d) const { return m_cm.isMarked(d); }
//};
//
//class SelectorDartNotMarked : public FunctorSelect
//{
//public:
//protected:
// const DartMarker& m_dm;
//public:
// SelectorDartNotMarked(const DartMarker& dm): m_dm(dm) {}
// bool operator()(Dart d) const { return !m_dm.isMarked(d); }
//};
//
//
//template <typename MAP>
//class SelectorCellNotMarked : public FunctorSelect
//{
//public:
//protected:
// const CellMarker& m_cm;
//public:
// SelectorCellNotMarked(const CellMarker& cm): m_cm(cm) {}
// bool operator()(Dart d) const { return !m_cm.isMarked(d); }
//};
// Counting Functors : increment its value every time it is applied
/********************************************************/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment