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

orbit as template -> tutos OK

parent 9b825529
......@@ -47,25 +47,21 @@ int main(int argc, char **argv)
return app.exec();
}
void MyQT::createMap()
{
// creation of 2 new faces: 1 triangle and 1 square, sew and embed (see tuto1 for details)
Dart d1 = myMap.newFace(3);
Dart d2 = myMap.newFace(4);
myMap.sewFaces(d1, d2);
PFP::TVEC3 position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
AttributeHandler<VEC3, VERTEX> position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
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);
// create another attribute on vertices (for faces drawing)
AttributeHandler<Geom::Vec3f> colorF = myMap.addAttribute<PFP::VEC3>(VERTEX, "colorF");
AttributeHandler<VEC3, VERTEX> colorF = myMap.addAttribute<PFP::VEC3, VERTEX>("colorF");
colorF[d1] = Geom::Vec3f(1.0f,0.0f,0.0f);
colorF[PHI1(d1)] = Geom::Vec3f(0.0f,1.0f,0.0f);
......@@ -73,9 +69,8 @@ void MyQT::createMap()
colorF[PHI<11>(d2)] = Geom::Vec3f(1.0f,0.0f,1.0f);
colorF[PHI_1(d2)] = Geom::Vec3f(0.0f,1.0f,1.0f);
// create another attribute on vertices (for edges drawing)
AttributeHandler<Geom::Vec3f> colorE = myMap.addAttribute<PFP::VEC3>(VERTEX, "colorE");
AttributeHandler<VEC3, VERTEX> colorE = myMap.addAttribute<PFP::VEC3, VERTEX>("colorE");
colorE[d1] = Geom::Vec3f(0.0f,0.5f,0.5f);
colorE[PHI1(d1)] = Geom::Vec3f(0.5f,0.0f,0.5f);
......@@ -83,13 +78,11 @@ void MyQT::createMap()
colorE[PHI<11>(d2)] = Geom::Vec3f(0.0f,0.5f,0.0f);
colorE[PHI_1(d2)] = Geom::Vec3f(0.5f,0.0f,0.0f);
// example of attribute on face
// here for example we store the number of edges of faces at construction
AttributeHandler<int> side = myMap.addAttribute<int>(FACE, "nb_sides");
side[d1]=3;
side[d2]=4;
AttributeHandler<int, FACE> side = myMap.addAttribute<int, FACE>("nb_sides");
side[d1] = 3;
side[d2] = 4;
// bounding box of scene
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
......@@ -102,7 +95,6 @@ void MyQT::createMap()
// first show for be sure that GL context is binded
show();
// update of position VBO (context GL necessary)
m_positionVBO->updateData(position);
m_colorVBO1->updateData(colorF);
......@@ -113,7 +105,6 @@ void MyQT::createMap()
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS); // special primitive for boundary edges
// traverse of all dart of the map:
// and write informations
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
......@@ -129,12 +120,8 @@ void MyQT::createMap()
CGoGNout << " / numer of side of face "<< side[d] << CGoGNendl;
}
}
}
// initialization GL callback
void MyQT::cb_initGL()
{
......@@ -150,7 +137,6 @@ void MyQT::cb_initGL()
m_colorVBO1 = new Utils::VBO();
m_colorVBO2 = new Utils::VBO();
// using simple shader with color
m_shader = new Utils::ShaderSimpleColor();
m_shader->setAttributePosition(m_positionVBO);
......@@ -163,8 +149,6 @@ void MyQT::cb_initGL()
// m_shader2->setAttributeColor(m_colorVBO1);
// each shader must be registred to allow Qt interface to update matrices uniforms
registerShader(m_shader2);
}
// redraw GL callback (clear and swap already done)
......@@ -193,5 +177,3 @@ void MyQT::cb_redraw()
glDisable(GL_POLYGON_OFFSET_FILL);
}
......@@ -59,6 +59,9 @@ struct PFP: public PFP_STANDARD
#endif
};
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
class MyQT: public Utils::QT::SimpleQT
{
......@@ -71,7 +74,7 @@ public:
protected:
// declaration of the map
PFP::MAP myMap;
MAP myMap;
// render (for the topo)
// Algo::Render::GL2::TopoRenderMapD* m_render_topo;
......@@ -100,6 +103,4 @@ public:
void createMap();
};
#endif
......@@ -66,11 +66,11 @@ void MyQT::traverseMap()
m1.unmarkAll();
m1.markOrbit(VOLUME,xd1);
m1.markOrbit<VOLUME>(xd1);
// 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);
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
......@@ -143,23 +143,19 @@ void MyQT::traverseMap()
// // markers are cleaned and released at destruction of DartMarkers & CellMarkers
// // DartMarkerStore should be used if few darts are traversed
// // DartMarkerNoUnmark can be use if you want to manage unmarking yourself
}
void MyQT::createMap()
{
// Dart d1 = Algo::Modelisation::createTetrahedron<PFP>(myMap);
// Dart d2 = d1;
Dart d1 = Algo::Modelisation::createTetrahedron<PFP>(myMap);
Dart d2 = d1;
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
Algo::Modelisation::Polyhedron<PFP> prim1(myMap, position);
prim1.cylinder_topo(256,256, true, true); // topo of sphere is a closed cylinder
prim1.cylinder_topo(256, 256, true, true); // topo of sphere is a closed cylinder
prim1.embedSphere(2.0f);
// Dart d2 = d1;
......@@ -171,19 +167,17 @@ void MyQT::createMap()
// d2 = PHI<211>(d2);
// position[d2] = PFP::VEC3(0, 1, 2);
Algo::Modelisation::Polyhedron<PFP> prim2(myMap, position);
prim2.cylinder_topo(256,256, true, true); // topo of sphere is a closed cylinder
prim2.cylinder_topo(256, 256, true, true); // topo of sphere is a closed cylinder
prim2.embedSphere(2.0f);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(5.0f,0.0,0.0,trf);
Geom::translate<float>(5.0f, 0.0, 0.0, trf);
prim2.transform(trf);
xd1 = prim2.getDart();
// xd1 = Algo::Modelisation::Polyhedron<PFP>::createTetra(myMap);
// Dart xd2 = xd1;
//
......@@ -211,7 +205,6 @@ void MyQT::createMap()
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,nb);
}
// initialization GL callback
void MyQT::cb_initGL()
{
......@@ -224,7 +217,6 @@ void MyQT::cb_redraw()
if (dart_selected != NIL)
m_render_topo->overdrawDart(dart_selected, 5, 1.0f,0.0f,0.0f);
m_render_topo->drawTopo();
}
// mouse picking
......@@ -232,12 +224,11 @@ void MyQT::cb_mouseClick(int button, int x, int y)
{
if (button == Qt::LeftButton)
{
Dart d = m_render_topo->picking<PFP>(myMap,x,y);
Dart d = m_render_topo->picking<PFP>(myMap, x, y);
if (d != NIL)
CGoGNout << "Dart "<< d << CGoGNendl;
dart_selected=d;
updateGL();
}
}
......@@ -56,6 +56,9 @@ struct PFP: public PFP_STANDARD
#endif
};
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
class MyQT: public Utils::QT::SimpleQT
{
......@@ -69,10 +72,10 @@ public:
protected:
// declaration of the map
PFP::MAP myMap;
MAP myMap;
// attribute handler on position;
PFP::TVEC3 position;
AttributeHandler<VEC3, VERTEX> position;
// render (for the topo)
Algo::Render::GL2::TopoRender* m_render_topo;
......@@ -96,6 +99,4 @@ public:
void traverseMap();
};
#endif
......@@ -54,7 +54,6 @@ int main(int argc, char **argv)
return app.exec();
}
// example of usage of traversor for local traverse
void MyQT::cb_mouseClick(int button, int x, int y)
{
......@@ -91,14 +90,12 @@ void MyQT::cb_mouseClick(int button, int x, int y)
dart_selected.push_back(e);
CGoGNout << "traverse vertices adjacent to vertex by a face " << CGoGNendl;
color = Geom::Vec3f(1,1,0);
}
}
updateGL();
}
}
void MyQT::traverseMap()
{
//traverse cells with traversor
......@@ -117,12 +114,8 @@ void MyQT::traverseMap()
TraversorF<PFP::MAP> traF(myMap);
for (Dart d=traF.begin(); d!=traF.end(); d=traF.next())
CGoGNout << "Face of dart "<<d<< CGoGNendl;
}
void MyQT::createMap()
{
......@@ -130,7 +123,7 @@ void MyQT::createMap()
Dart d2 = d1;
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
position[d2] = PFP::VEC3(1, 0, 0);
d2 = PHI1(d2);
......@@ -161,7 +154,6 @@ void MyQT::createMap()
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f);
}
// initialization GL callback
void MyQT::cb_initGL()
{
......@@ -177,10 +169,4 @@ void MyQT::cb_redraw()
m_render_topo->overdrawDart(*it, 5, color[0],color[1],color[2]);
}
m_render_topo->drawTopo();
}
......@@ -44,6 +44,9 @@ struct PFP: public PFP_STANDARD
typedef EmbeddedMap2 MAP;
};
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
class MyQT: public Utils::QT::SimpleQT
{
......@@ -57,10 +60,10 @@ public:
protected:
// declaration of the map
PFP::MAP myMap;
MAP myMap;
// attribute handler on position;
PFP::TVEC3 position;
AttributeHandler<VEC3, VERTEX> position;
// render (for the topo)
Algo::Render::GL2::TopoRender* m_render_topo;
......
......@@ -22,11 +22,9 @@
* *
*******************************************************************************/
#include "tuto5.h"
#include <iostream>
#include "Algo/Modelisation/primitives3d.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Modelisation/subdivision.h"
......@@ -36,8 +34,8 @@
#include "Algo/Render/SVG/mapSVGRender.h"
PFP::MAP myMap;
PFP::TVEC3 position ;
MAP myMap;
AttributeHandler<VEC3, VERTEX> position ;
Dart dglobal;
void MyQT::balls_onoff(bool x)
......@@ -87,8 +85,6 @@ void MyQT::slider_text(int x)
updateGL();
}
void MyQT::animate()
{
// transfoMatrix() = glm::rotate(transfoMatrix(), 0.5f, glm::vec3(0.5773f,0.5773f,0.5773f));
......@@ -97,19 +93,17 @@ void MyQT::animate()
updateGL();
}
void MyQT::storeVerticesInfo()
{
CellMarker mv(myMap,VERTEX);
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
CellMarker<VERTEX> mv(myMap);
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (!mv.isMarked(d))
{
mv.mark(d);
std::stringstream ss;
ss << d << " : "<< position[d];
m_strings->addString(ss.str(),position[d]);
m_strings->addString(ss.str(), position[d]);
}
}
}
......@@ -171,7 +165,6 @@ void MyQT::cb_initGL()
SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, 0.9f, nb);
// timer example for animation
m_timer = new QTimer( this );
connect( m_timer, SIGNAL(timeout()), SLOT(animate()) );
......@@ -201,7 +194,6 @@ void MyQT::cb_redraw()
*/
m_render_topo->overdrawDart(m_selected, 5, 1.0f, 0.0f, 1.0f);
glDisable(GL_POLYGON_OFFSET_FILL);
if (render_text)
......@@ -245,13 +237,13 @@ void MyQT::cb_keyPress(int code)
if (code == 's')
{
std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
Utils::SVG::SVGOut svg(filename,modelViewMatrix(),projectionMatrix());
Utils::SVG::SVGOut svg(filename, modelViewMatrix(), projectionMatrix());
svg.setWidth(1.0f);
svg.setColor(Geom::Vec3f(0.0f,0.0f,0.5f));
Algo::Render::SVG::renderEdges<PFP>(svg,myMap,position);
Algo::Render::SVG::renderEdges<PFP>(svg, myMap, position);
svg.setColor(Geom::Vec3f(0.0f,0.8f,0.0f));
svg.setWidth(5.0f);
Algo::Render::SVG::renderVertices<PFP>(svg,myMap,position);
Algo::Render::SVG::renderVertices<PFP>(svg, myMap, position);
svg.setColor(Geom::Vec3f(1.0f,0.0f,0.0f));
m_strings->toSVG(svg);
//svg destruction close the file
......@@ -274,20 +266,16 @@ void MyQT::cb_keyPress(int code)
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, 0.9f, allDarts);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, 0.9f, allDarts);
}
}
int main(int argc, char **argv)
{
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
CGoGNout << 5.34 << " toto "<< Geom::Vec3f(2.5f, 2.2f, 4.3f) << CGoGNendl;
CGoGNout << 3 << " tutu "<< 4 <<CGoGNendl;
CGoGNout << 3 << " tutu "<< 4 << CGoGNendl;
Algo::Modelisation::Primitive3D<PFP> prim(myMap, position);
int nb=3;
......@@ -333,7 +321,6 @@ int main(int argc, char **argv)
sqt.setCallBack( dock.slider_vectors, SIGNAL(valueChanged(int)), SLOT(slider_vectors(int)) );
sqt.setCallBack( dock.slider_text, SIGNAL(valueChanged(int)), SLOT(slider_text(int)) );
sqt.m_selected = myMap.begin();
sqt.setGeometry(100,100,1024,1024);
......@@ -350,8 +337,6 @@ int main(int argc, char **argv)
CGoGNdbg << " TextureSize " << texSize << CGoGNendl;
CGoGNerr << " test ERROR " << 5*7 << CGoGNflush;
// et on attend la fin.
return app.exec();
}
......@@ -72,8 +72,8 @@ struct PFP: public PFP_STANDARD
#endif
};
using namespace CGoGN ;
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
/**
......
......@@ -773,8 +773,8 @@ void Polyhedron<PFP>::embedGrid(float x, float y, float z)
return;
}
float dx = x/float(m_nx);
float dy = y/float(m_ny);
float dx = x / float(m_nx);
float dy = y / float(m_ny);
for(unsigned int i = 0; i <= m_ny; ++i)
{
......@@ -783,7 +783,7 @@ void Polyhedron<PFP>::embedGrid(float x, float y, float z)
VEC3 pos(-x/2 + dx*float(j), -y/2 + dy*float(i), z);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[i*(m_nx+1)+j];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
}
}
......@@ -814,7 +814,7 @@ void Polyhedron<PFP>::embedCylinder(float bottom_radius, float top_radius, float
VEC3 pos(x, y, -height/2 + dz*float(i));
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[i*(m_nx)+j];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
}
......@@ -824,7 +824,7 @@ void Polyhedron<PFP>::embedCylinder(float bottom_radius, float top_radius, float
VEC3 pos(0.0f, 0.0f, -height/2 );
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[indexUmbrella++];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
if (m_top_closed)
......@@ -832,7 +832,7 @@ void Polyhedron<PFP>::embedCylinder(float bottom_radius, float top_radius, float
VEC3 pos(0.0f ,0.0f, height/2 );
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[indexUmbrella];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
}
......@@ -864,7 +864,7 @@ void Polyhedron<PFP>::embedCone(float radius, float height)
VEC3 pos(x, y, h);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[i*(m_nx)+j];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
}
......@@ -874,14 +874,14 @@ void Polyhedron<PFP>::embedCone(float radius, float height)
VEC3 pos(0.0f, 0.0f, -height/2 );
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[indexUmbrella++];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
// top always closed in cone
VEC3 pos(0.0f ,0.0f, height/2.0f );
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[indexUmbrella];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
template <typename PFP>
......@@ -910,7 +910,7 @@ void Polyhedron<PFP>::embedSphere(float radius)
VEC3 pos(x, y, h );
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[i*(m_nx)+j];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
}
......@@ -918,13 +918,13 @@ void Polyhedron<PFP>::embedSphere(float radius)
VEC3 pos(0.0f, 0.0f, -radius);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[m_nx*(m_nz+1)];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
// top pole
pos = VEC3(0.0f, 0.0f, radius);
em = m_positions.insert(pos);
d = m_tableVertDarts[m_nx*(m_nz+1)+1];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
template <typename PFP>
......@@ -952,7 +952,7 @@ void Polyhedron<PFP>::embedTore(float big_radius, float small_radius)
VEC3 pos(x, y, z);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[j*(m_nx)+i];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
}
}
......@@ -983,7 +983,7 @@ void Polyhedron<PFP>::embedCube(float sx, float sy, float sz)
VEC3 pos(x, -sy/2.0f, z);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[index++];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
for (unsigned int i = 0; i < m_ny; ++i)
{
......@@ -991,7 +991,7 @@ void Polyhedron<PFP>::embedCube(float sx, float sy, float sz)
VEC3 pos(sx/2.0f, y, z);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[index++];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
for (unsigned int i = 0; i < m_nx; ++i)
{
......@@ -999,7 +999,7 @@ void Polyhedron<PFP>::embedCube(float sx, float sy, float sz)
VEC3 pos(x, sy/2.0f, z);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[index++];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
for (unsigned int i = 0; i < m_ny ;++i)
{
......@@ -1007,7 +1007,7 @@ void Polyhedron<PFP>::embedCube(float sx, float sy, float sz)
VEC3 pos(-sx/2.0f, y, z);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[index++];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
}
......@@ -1019,7 +1019,7 @@ void Polyhedron<PFP>::embedCube(float sx, float sy, float sz)
VEC3 pos(-sx/2.0f+float(j)*dx, -sy/2.0f+float(i)*dy, sz/2.0f);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[index++];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
}
......@@ -1031,7 +1031,7 @@ void Polyhedron<PFP>::embedCube(float sx, float sy, float sz)
VEC3 pos(-sx/2.0f+float(j)*dx, sy/2.0f-float(i)*dy, -sz/2.0f);
unsigned int em = m_positions.insert(pos);
Dart d = m_tableVertDarts[index++];
m_map.embedOrbit<VERTEX>(d, em);
m_map.template embedOrbit<VERTEX>(d, em);
}
}
}
......@@ -1137,7 +1137,7 @@ void Polyhedron<PFP>::embedHelicoid(float radius_min, float radius_max, float ma
VEC3 pos(x, y, j*hS);
Dart d = m_tableVertDarts[i*(m_nx+1)+j];
m_positions[d]=pos;
m_positions[d] = pos;
}
}
}
......
......@@ -58,9 +58,9 @@ template <typename PFP, typename EMBV, typename EMB>
void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected= allDarts);
template <typename PFP>
void catmullClarkVol(typename PFP::MAP& map, typename PFP::TVEC3& position, const FunctorSelect& selected= allDarts)
void catmullClarkVol(typename PFP::MAP& map, AttributeHandler<typename PFP::VEC3, VERTEX>& position, const FunctorSelect& selected= allDarts)
{
catmullClarkVol<PFP,typename PFP::TVEC3, typename PFP::VEC3>(map, position, selected)