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

orbit as template -> tuto1 OK

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