Commit 9b825529 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

orbit as template -> tuto1 OK

parent 273fc127
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
using namespace CGoGN ; using namespace CGoGN ;
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
// // interface // // interface
...@@ -45,8 +44,6 @@ int main(int argc, char **argv) ...@@ -45,8 +44,6 @@ int main(int argc, char **argv)
return app.exec(); return app.exec();
} }
void MyQT::createMap() void MyQT::createMap()
{ {
// creation of 2 new faces: 1 triangle and 1 square // creation of 2 new faces: 1 triangle and 1 square
...@@ -57,16 +54,15 @@ void MyQT::createMap() ...@@ -57,16 +54,15 @@ void MyQT::createMap()
myMap.sewFaces(d1, d2); myMap.sewFaces(d1, d2);
// creation of a new attribute on vertices of type 3D vector for position. // creation of a new attribute on vertices of type 3D vector for position.
// a handler to this attribute is returned (TVEC3 is a typdef of AttributeHandler<PFP::VEC3>) // a handler to this attribute is returned
PFP::TVEC3 position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position"); position = myMap.addAttribute<VEC3, VERTEX>("position");
//warning: at the end of scope of variable position, handler is destroyed but attribute stay
// affect position by moving in the map // affect position by moving in the map
position[d1] = PFP::VEC3(0, 0, 0); position[d1] = VEC3(0, 0, 0);
position[PHI1(d1)] = PFP::VEC3(2, 0, 0); position[PHI1(d1)] = VEC3(2, 0, 0);
position[PHI_1(d1)] = PFP::VEC3(1, 2, 0); position[PHI_1(d1)] = VEC3(1, 2, 0);
position[PHI<11>(d2)] = PFP::VEC3(0, -2, 0); position[PHI<11>(d2)] = VEC3(0, -2, 0);
position[PHI_1(d2)] = PFP::VEC3(2, -2, 0); position[PHI_1(d2)] = VEC3(2, -2, 0);
// bounding box of scene // bounding box of scene
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position); Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
...@@ -81,10 +77,9 @@ void MyQT::createMap() ...@@ -81,10 +77,9 @@ void MyQT::createMap()
// render the topo of the map without boundary darts // render the topo of the map without boundary darts
SelectorDartNoBoundary<PFP::MAP> nb(myMap); SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,nb); m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, nb);
} }
// initialization GL callback // initialization GL callback
void MyQT::cb_initGL() void MyQT::cb_initGL()
{ {
...@@ -96,5 +91,3 @@ void MyQT::cb_redraw() ...@@ -96,5 +91,3 @@ void MyQT::cb_redraw()
{ {
m_render_topo->drawTopo(); m_render_topo->drawTopo();
} }
...@@ -56,9 +56,10 @@ struct PFP: public PFP_STANDARD ...@@ -56,9 +56,10 @@ struct PFP: public PFP_STANDARD
#endif #endif
}; };
typedef PFP::MAP MAP;
typedef PFP::VEC3 VEC3;
class MyQT : public Utils::QT::SimpleQT
class MyQT: public Utils::QT::SimpleQT
{ {
Q_OBJECT Q_OBJECT
public: public:
...@@ -69,23 +70,24 @@ public: ...@@ -69,23 +70,24 @@ public:
protected: protected:
// declaration of the map // declaration of the map
PFP::MAP myMap; MAP myMap;
// attribute for vertices positions
AttributeHandler<VEC3, VERTEX> position;
// render (for the topo) // render (for the topo)
Algo::Render::GL2::TopoRender* m_render_topo; Algo::Render::GL2::TopoRender* m_render_topo;
// just for more compact writing // just for more compact writing
inline Dart PHI1(Dart d) {return myMap.phi1(d);} inline Dart PHI1(Dart d) { return myMap.phi1(d); }
inline Dart PHI_1(Dart d) {return myMap.phi_1(d);} inline Dart PHI_1(Dart d) { return myMap.phi_1(d); }
inline Dart PHI2(Dart d) {return myMap.phi2(d);} inline Dart PHI2(Dart d) { return myMap.phi2(d); }
template<int X> template<int X>
Dart PHI(Dart d) {return myMap.phi<X>(d);} Dart PHI(Dart d) { return myMap.phi<X>(d); }
public: public:
// example of simple map creation // example of simple map creation
void createMap(); void createMap();
}; };
#endif #endif
...@@ -86,7 +86,6 @@ protected: ...@@ -86,7 +86,6 @@ protected:
*/ */
GLuint m_nbRel2; GLuint m_nbRel2;
/** /**
* width of lines use to draw darts * width of lines use to draw darts
*/ */
...@@ -102,7 +101,6 @@ protected: ...@@ -102,7 +101,6 @@ protected:
*/ */
Geom::Vec3f m_dartsColor; Geom::Vec3f m_dartsColor;
float *m_color_save; float *m_color_save;
/** /**
...@@ -113,7 +111,6 @@ protected: ...@@ -113,7 +111,6 @@ protected:
Utils::ShaderSimpleColor* m_shader1; Utils::ShaderSimpleColor* m_shader1;
Utils::ShaderColorPerVertex* m_shader2; Utils::ShaderColorPerVertex* m_shader2;
/** /**
* compute color from dart index (for color picking) * compute color from dart index (for color picking)
*/ */
...@@ -258,7 +255,6 @@ public: ...@@ -258,7 +255,6 @@ public:
typedef TopoRender TopoRenderMapD; typedef TopoRender TopoRenderMapD;
typedef TopoRender TopoRenderGMap; typedef TopoRender TopoRenderGMap;
} // namespace GL2 } // namespace GL2
} // namespace Render } // namespace Render
......
...@@ -48,12 +48,14 @@ void TopoRender::updateData(typename PFP::MAP& map, const AttributeHandler<typen ...@@ -48,12 +48,14 @@ void TopoRender::updateData(typename PFP::MAP& map, const AttributeHandler<typen
Map2* ptrMap2 = dynamic_cast<Map2*>(&map); Map2* ptrMap2 = dynamic_cast<Map2*>(&map);
if (ptrMap2 != NULL) if (ptrMap2 != NULL)
{ {
updateDataMap<PFP>(map,positions,ke,kf,good); updateDataMap<PFP>(map, positions, ke, kf, good);
return;
} }
GMap2* ptrGMap2 = dynamic_cast<GMap2*>(&map); GMap2* ptrGMap2 = dynamic_cast<GMap2*>(&map);
if (ptrGMap2 != NULL) if (ptrGMap2 != NULL)
{ {
updateDataGMap<PFP>(map,positions,ke,kf,good); updateDataGMap<PFP>(map, positions, ke, kf, good);
return;
} }
} }
......
...@@ -58,10 +58,9 @@ template <typename T, unsigned int ORBIT> ...@@ -58,10 +58,9 @@ template <typename T, unsigned int ORBIT>
AttributeHandler<T, ORBIT>::AttributeHandler(GenericMap* m, AttributeMultiVector<T>* amv) : AttributeHandler<T, ORBIT>::AttributeHandler(GenericMap* m, AttributeMultiVector<T>* amv) :
AttributeHandlerGen(m, false), m_attrib(amv) AttributeHandlerGen(m, false), m_attrib(amv)
{ {
assert(ORBIT == amv->getOrbit() || !"AttributeHandler: orbit incompatibility") ;
if(m != NULL && amv != NULL && amv->getIndex() != AttributeContainer::UNKNOWN) if(m != NULL && amv != NULL && amv->getIndex() != AttributeContainer::UNKNOWN)
{ {
assert(ORBIT == amv->getOrbit() || !"AttributeHandler: orbit incompatibility") ;
valid = true ; valid = true ;
registerInMap() ; registerInMap() ;
} }
......
...@@ -240,8 +240,8 @@ protected: ...@@ -240,8 +240,8 @@ protected:
public: public:
virtual void unmarkAll() virtual void unmarkAll()
{ {
assert(m_map.getMarkerSet(CELL, this->m_thread).testMark(this->m_mark)); assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(m_markVector != NULL); assert(this->m_markVector != NULL);
AttributeContainer& cont = this->m_map.template getAttributeContainer<CELL>() ; AttributeContainer& cont = this->m_map.template 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))
...@@ -269,7 +269,7 @@ public: ...@@ -269,7 +269,7 @@ public:
{ {
unmarkAll() ; unmarkAll() ;
// assert(isAllUnmarked); // assert(isAllUnmarked);
CGoGN_ASSERT(isAllUnmarked()) CGoGN_ASSERT(this->isAllUnmarked())
} }
protected: protected:
...@@ -291,8 +291,8 @@ public: ...@@ -291,8 +291,8 @@ public:
void unmarkAll() void unmarkAll()
{ {
assert(m_map.getMarkerSet(CELL, this->m_thread).testMark(this->m_mark)); assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(m_markVector != NULL); assert(this->m_markVector != NULL);
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)
this->m_markVector->operator[](*it).unsetMark(this->m_mark) ; this->m_markVector->operator[](*it).unsetMark(this->m_mark) ;
...@@ -314,7 +314,7 @@ public: ...@@ -314,7 +314,7 @@ public:
virtual ~CellMarkerNoUnmark() virtual ~CellMarkerNoUnmark()
{ {
// assert(isAllUnmarked()) ; // assert(isAllUnmarked()) ;
CGoGN_ASSERT(isAllUnmarked()) CGoGN_ASSERT(this->isAllUnmarked())
} }
protected: protected:
...@@ -324,8 +324,8 @@ protected: ...@@ -324,8 +324,8 @@ protected:
public: public:
void unmarkAll() void unmarkAll()
{ {
assert(m_map.getMarkerSet(CELL, this->m_thread).testMark(this->m_mark)); assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(m_markVector != NULL); assert(this->m_markVector != NULL);
AttributeContainer& cont = this->m_map.template getAttributeContainer<CELL>() ; AttributeContainer& cont = this->m_map.template 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))
......
...@@ -185,7 +185,7 @@ void TopoRender::drawTopo() ...@@ -185,7 +185,7 @@ void TopoRender::drawTopo()
void TopoRender::overdrawDart(Dart d, float width, float r, float g, float b) void TopoRender::overdrawDart(Dart d, float width, float r, float g, float b)
{ {
unsigned int indexDart = m_attIndex[d]; unsigned int indexDart = m_attIndex[d];
m_shader1->changeVA_VBO(m_vaId, m_vbo0); m_shader1->changeVA_VBO(m_vaId, m_vbo0);
m_shader1->setColor(Geom::Vec4f(r,g,b,0.0f)); m_shader1->setColor(Geom::Vec4f(r,g,b,0.0f));
......
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