Commit 3128828e authored by Pierre Kraemer's avatar Pierre Kraemer

orbit as template -> tuto_oper OK

parent 7e8be952
......@@ -170,9 +170,8 @@ void MyQT::operation(int x)
void MyQT::createMap(int n)
{
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
colorDarts = myMap.addAttribute<PFP::VEC3>(DART, "color");
position = myMap.addAttribute<VEC3, VERTEX>("position");
colorDarts = myMap.addAttribute<VEC3, DART>("color");
Algo::Modelisation::Polyhedron<PFP> grid(myMap,position);
grid.grid_topo(n,n);
......@@ -208,8 +207,6 @@ void MyQT::createMap(int n)
}
}
void MyQT::updateMap()
{
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,nb);
......@@ -272,7 +269,7 @@ void MyQT::cb_keyPress(int keycode)
switch(keycode)
{
case 'c':
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (!myMap.isBoundaryMarked(d))
{
......@@ -286,7 +283,7 @@ void MyQT::cb_keyPress(int keycode)
}
break;
case 'g':
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (!myMap.isBoundaryMarked(d))
{
......@@ -297,7 +294,7 @@ void MyQT::cb_keyPress(int keycode)
break;
case 'b':
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (!myMap.isBoundaryMarked(d))
{
......@@ -308,7 +305,7 @@ void MyQT::cb_keyPress(int keycode)
break;
case Qt::Key_Up:
if (m_selected!=NIL)
position[m_selected][1] +=m_shift;
position[m_selected][1] += m_shift;
updateMap();
updateGL();
break;
......@@ -370,7 +367,7 @@ void MyQT::importMesh(std::string& filename)
if (extension == std::string(".map"))
{
myMap.loadMapBin(filename);
position = myMap.getAttribute<PFP::VEC3>(VERTEX, "position") ;
position = myMap.getAttribute<VEC3, VERTEX>("position") ;
}
else
{
......@@ -380,13 +377,13 @@ void MyQT::importMesh(std::string& filename)
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
}
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
position = myMap.getAttribute<VEC3, VERTEX>(attrNames[0]) ;
}
colorDarts = myMap.getAttribute<PFP::VEC3>(DART, "color");
colorDarts = myMap.getAttribute<VEC3, DART>("color");
if (!colorDarts.isValid())
{
colorDarts = myMap.addAttribute<PFP::VEC3>(DART, "color");
colorDarts = myMap.addAttribute<VEC3, DART>("color");
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{
if (dm.isMarked(d) && (!myMap.isBoundaryMarked(d)))
......
......@@ -61,6 +61,8 @@ struct PFP: public PFP_STANDARD
#endif
};
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
class MyQT: public Utils::QT::SimpleQT
......@@ -80,10 +82,10 @@ public:
protected:
// declaration of the map
PFP::MAP myMap;
MAP myMap;
PFP::TVEC3 position;
AttributeHandler<Geom::Vec3f> colorDarts;
AttributeHandler<VEC3, VERTEX> position;
AttributeHandler<VEC3, DART> colorDarts;
SelectorDartNoBoundary<PFP::MAP> nb;
......@@ -113,6 +115,4 @@ public slots:
void width(int w);
};
#endif
......@@ -39,7 +39,6 @@ int main(int argc, char **argv)
QApplication app(argc, argv);
MyQT sqt;
sqt.setDock(& sqt.dock);
sqt.setCallBack( sqt.dock.listOper, SIGNAL(currentRowChanged(int)), SLOT(operation(int)) );
sqt.setCallBack( sqt.dock.svg, SIGNAL(clicked()), SLOT(svg()) );
......@@ -61,7 +60,6 @@ int main(int argc, char **argv)
return app.exec();
}
void MyQT::operation(int x)
{
switch(x)
......@@ -188,9 +186,9 @@ void MyQT::operation(int x)
void MyQT::createMap(int n)
{
myMap.clear(true);
position = myMap.getAttribute<PFP::VEC3>(VERTEX, "position");
position = myMap.getAttribute<VEC3, VERTEX>("position");
if (!position.isValid())
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
position = myMap.addAttribute<VEC3, VERTEX>("position");
Algo::Modelisation::Primitive3D<PFP> prim(myMap, position);
prim.hexaGrid_topo(n,n,n);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
......@@ -208,12 +206,8 @@ void MyQT::createMap(int n)
m_render_topo->setDartWidth(3.0f);
m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3, nb);
}
void MyQT::updateMap()
{
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3, nb);
......@@ -276,7 +270,6 @@ void MyQT::cb_mousePress(int button, int x, int y)
}
updateGL();
}
}
void MyQT::cb_keyPress(int keycode)
......@@ -324,7 +317,6 @@ void MyQT::cb_keyPress(int keycode)
m_selected = myMap.phi3(m_selected);
updateGL();
break;
case 'q':
m_selected2 = myMap.phi1(m_selected2);
updateGL();
......@@ -341,7 +333,6 @@ void MyQT::cb_keyPress(int keycode)
m_selected2 = myMap.phi3(m_selected2);
updateGL();
break;
case 'w':
m_ex1 = 0.99f;
m_ex2 = 0.99f;
......@@ -392,7 +383,7 @@ void MyQT::cb_keyPress(int keycode)
// break;
case Qt::Key_Up:
if (m_selected!=NIL)
position[m_selected][1] +=m_shift;
position[m_selected][1] += m_shift;
updateMap();
updateGL();
break;
......@@ -420,13 +411,13 @@ void MyQT::cb_keyPress(int keycode)
void MyQT::svg()
{
if (m_selected!=NIL)
m_render_topo->setDartColor(m_selected,0.8f,0.0f,0.0f);
if (m_selected2!=NIL)
m_render_topo->setDartColor(m_selected2,0.0f,0.8f,0.0f);
if (m_selected != NIL)
m_render_topo->setDartColor(m_selected, 0.8f, 0.0f, 0.0f);
if (m_selected2 != NIL)
m_render_topo->setDartColor(m_selected2, 0.0f, 0.8f, 0.0f);
std::string filename = selectFileSave("snapshot file", ".", "(*.svg)");
m_render_topo->svgout2D(filename, modelViewMatrix(),projectionMatrix());
m_render_topo->svgout2D(filename, modelViewMatrix(), projectionMatrix());
}
void MyQT::cb_Open()
......@@ -441,7 +432,7 @@ void MyQT::cb_Open()
void MyQT::cb_Save()
{
std::string filename = selectFileSave("Export SVG file ",".","(*.off)");
Algo::Export::exportOFF<PFP>(myMap,position,filename.c_str());
Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str());
}
void MyQT::importMesh(std::string& filename)
......@@ -454,7 +445,7 @@ void MyQT::importMesh(std::string& filename)
if (extension == std::string(".map"))
{
myMap.loadMapBin(filename);
position = myMap.getAttribute<PFP::VEC3>(VERTEX, "position") ;
position = myMap.getAttribute<VEC3, VERTEX>("position") ;
}
else if (extension == std::string(".node"))
{
......@@ -464,7 +455,7 @@ void MyQT::importMesh(std::string& filename)
std::cerr << "could not import " << filename << std::endl ;
return ;
}
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
position = myMap.getAttribute<VEC3, VERTEX>(attrNames[0]) ;
}
else if(extension == std::string(".tet"))
{
......@@ -474,7 +465,7 @@ void MyQT::importMesh(std::string& filename)
std::cerr << "could not import " << filename << std::endl ;
return ;
}
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
position = myMap.getAttribute<VEC3, VERTEX>(attrNames[0]) ;
}
else if(extension == std::string(".off"))
{
......@@ -484,7 +475,7 @@ void MyQT::importMesh(std::string& filename)
std::cerr << "could not import " << filename << std::endl ;
return ;
}
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
position = myMap.getAttribute<VEC3, VERTEX>(attrNames[0]) ;
}
else
{
......@@ -502,11 +493,9 @@ void MyQT::importMesh(std::string& filename)
updateGLMatrices() ;
}
void MyQT::width(int w)
{
m_ex3 = 0.9f - 0.025f*w;
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3, nb);
updateGL();
}
......@@ -61,6 +61,8 @@ struct PFP: public PFP_STANDARD
#endif
};
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
class MyQT: public Utils::QT::SimpleQT
......@@ -80,10 +82,9 @@ public:
protected:
// declaration of the map
PFP::MAP myMap;
MAP myMap;
PFP::TVEC3 position;
// AttributeHandler<Geom::Vec3f> colorDarts;
AttributeHandler<VEC3, VERTEX> position;
SelectorDartNoBoundary<PFP::MAP> nb;
......@@ -95,7 +96,7 @@ protected:
DartMarker dm;
float m_shift;
float m_ex1,m_ex2,m_ex3;
float m_ex1, m_ex2, m_ex3;
// just for more compact writing
inline Dart PHI1(Dart d) {return myMap.phi1(d);}
......@@ -117,6 +118,4 @@ public slots:
void width(int w);
};
#endif
......@@ -164,7 +164,7 @@ bool importNodeWithELERegions(typename PFP::MAP& map, const std::string& filenam
for(unsigned int j = 0 ; j < 3 ; ++j)
{
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, verticesID[pt[2-j]]);
map.foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
map.template foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
//store darts per vertices to optimize reconstruction
Dart dd = d;
......@@ -183,7 +183,7 @@ bool importNodeWithELERegions(typename PFP::MAP& map, const std::string& filenam
d = map.phi_1(map.phi2(d));
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, verticesID[pt[3]]);
map.foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
map.template foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
//store darts per vertices to optimize reconstruction
Dart dd = d;
......@@ -210,9 +210,9 @@ bool importNodeWithELERegions(typename PFP::MAP& map, const std::string& filenam
Dart good_dart = NIL;
for(typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{
if(map.getEmbedding<VERTEX>(map.phi1(*it)) == map.getEmbedding<VERTEX>(d) &&
map.getEmbedding<VERTEX>(map.phi_1(*it)) == map.getEmbedding<VERTEX>(map.phi_1(d)) /*&&
map.getEmbedding<VERTEX>(*it) == map.getEmbedding<VERTEX>(map.phi1(d)) */)
if(map.template getEmbedding<VERTEX>(map.phi1(*it)) == map.template getEmbedding<VERTEX>(d) &&
map.template getEmbedding<VERTEX>(map.phi_1(*it)) == map.template getEmbedding<VERTEX>(map.phi_1(d)) /*&&
map.template getEmbedding<VERTEX>(*it) == map.template getEmbedding<VERTEX>(map.phi1(d)) */)
{
good_dart = *it ;
}
......@@ -221,7 +221,7 @@ bool importNodeWithELERegions(typename PFP::MAP& map, const std::string& filenam
if (good_dart != NIL)
{
map.sewVolumes(d, good_dart, false);
m.unmarkOrbit<FACE>(d);
m.template unmarkOrbit<FACE>(d);
}
else
{
......
......@@ -159,7 +159,7 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename
for(unsigned int j = 0 ; j < 3 ; ++j)
{
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, verticesID[pt[2-j]]);
map.foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
map.template foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
//store darts per vertices to optimize reconstruction
Dart dd = d;
......@@ -178,7 +178,7 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename
d = map.phi_1(map.phi2(d));
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, verticesID[pt[3]]);
map.foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
map.template foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
//store darts per vertices to optimize reconstruction
Dart dd = d;
......@@ -205,9 +205,9 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename
Dart good_dart = NIL;
for(typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{
if(map.getEmbedding<VERTEX>(map.phi1(*it)) == map.getEmbedding<VERTEX>(d) &&
map.getEmbedding<VERTEX>(map.phi_1(*it)) == map.getEmbedding<VERTEX>(map.phi_1(d)) /*&&
map.getEmbedding<VERTEX>(*it) == map.getEmbedding<VERTEX>(map.phi1(d)) */)
if(map.template getEmbedding<VERTEX>(map.phi1(*it)) == map.template getEmbedding<VERTEX>(d) &&
map.template getEmbedding<VERTEX>(map.phi_1(*it)) == map.template getEmbedding<VERTEX>(map.phi_1(d)) /*&&
map.template getEmbedding<VERTEX>(*it) == map.template getEmbedding<VERTEX>(map.phi1(d)) */)
{
good_dart = *it ;
}
......@@ -216,11 +216,11 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename
if (good_dart != NIL)
{
map.sewVolumes(d, good_dart, false);
m.unmarkOrbit<FACE>(d);
m.template unmarkOrbit<FACE>(d);
}
else
{
m.unmarkOrbit<FACE + PFP::MAP::IN_PARENT>(d);
m.template unmarkOrbit<FACE + PFP::MAP::IN_PARENT>(d);
++nbBoundaryFaces;
}
}
......
......@@ -136,7 +136,7 @@ bool importTs(typename PFP::MAP& map, const std::string& filename, std::vector<s
for(unsigned int j = 0 ; j < 3 ; ++j)
{
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, verticesID[pt[2-j]]);
map.foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
map.template foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
//store darts per vertices to optimize reconstruction
Dart dd = d;
......@@ -154,7 +154,7 @@ bool importTs(typename PFP::MAP& map, const std::string& filename, std::vector<s
d = map.phi_1(map.phi2(d));
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, verticesID[pt[3]]);
map.foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
map.template foreach_dart_of_orbit<VERTEX + PFP::MAP::IN_PARENT>(d, fsetemb);
//store darts per vertices to optimize reconstruction
Dart dd = d;
......@@ -179,9 +179,9 @@ bool importTs(typename PFP::MAP& map, const std::string& filename, std::vector<s
Dart good_dart = NIL;
for(typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{
if(map.getEmbedding<VERTEX>(map.phi1(*it)) == map.getEmbedding<VERTEX>(d) &&
map.getEmbedding<VERTEX>(map.phi_1(*it)) == map.getEmbedding<VERTEX>(map.phi_1(d)) /*&&
map.getEmbedding<VERTEX>(*it) == map.getEmbedding<VERTEX>(map.phi1(d)) */)
if(map.template getEmbedding<VERTEX>(map.phi1(*it)) == map.template getEmbedding<VERTEX>(d) &&
map.template getEmbedding<VERTEX>(map.phi_1(*it)) == map.template getEmbedding<VERTEX>(map.phi_1(d)) /*&&
map.template getEmbedding<VERTEX>(*it) == map.template getEmbedding<VERTEX>(map.phi1(d)) */)
{
good_dart = *it ;
}
......@@ -190,7 +190,7 @@ bool importTs(typename PFP::MAP& map, const std::string& filename, std::vector<s
if (good_dart != NIL)
{
map.sewVolumes(d, good_dart, false);
m.unmarkOrbit<FACE>(d);
m.template unmarkOrbit<FACE>(d);
}
else
{
......
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