Commit 4830f7f3 authored by Sylvain Thery's avatar Sylvain Thery

forgottent commited files for MR & new orbits

parent 10aeeaff
...@@ -72,3 +72,9 @@ QT4_WRAP_CPP( clipping_moc ../clipping.h ) ...@@ -72,3 +72,9 @@ QT4_WRAP_CPP( clipping_moc ../clipping.h )
add_executable( clippingD ../clipping.cpp ${clipping_ui} ${clipping_moc}) add_executable( clippingD ../clipping.cpp ${clipping_ui} ${clipping_moc})
target_link_libraries( clippingD target_link_libraries( clippingD
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
QT4_WRAP_UI( volumeExplorer_ui ../volumeExplorer.ui )
QT4_WRAP_CPP( volumeExplorer_moc ../volumeExplorer.h )
add_executable( volumeExplorerD ../volumeExplorer.cpp ${volumeExplorer_ui} ${volumeExplorer_moc})
target_link_libraries( volumeExplorerD
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
\ No newline at end of file
...@@ -64,3 +64,10 @@ QT4_WRAP_CPP( clipping_moc ../clipping.h ) ...@@ -64,3 +64,10 @@ QT4_WRAP_CPP( clipping_moc ../clipping.h )
add_executable( clipping ../clipping.cpp ${clipping_ui} ${clipping_moc}) add_executable( clipping ../clipping.cpp ${clipping_ui} ${clipping_moc})
target_link_libraries( clipping target_link_libraries( clipping
${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} ) ${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} )
QT4_WRAP_UI( volumeExplorer_ui ../volumeExplorer.ui )
QT4_WRAP_CPP( volumeExplorer_moc ../volumeExplorer.h )
add_executable( volumeExplorer ../volumeExplorer.cpp ${volumeExplorer_ui} ${volumeExplorer_moc})
target_link_libraries( volumeExplorer
${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} )
\ No newline at end of file
...@@ -37,9 +37,9 @@ SimpleGMap3::SimpleGMap3() ...@@ -37,9 +37,9 @@ SimpleGMap3::SimpleGMap3()
Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position); Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(3,1,1); Dart d = primCat.hexaGrid_topo(3,1,1);
primCat.embedHexaGrid(2,1,1); primCat.embedHexaGrid(2,1,1);
std::cout << "AAA"<< std::endl;
myMap.check(); myMap.check();
std::cout << "AAA"<< std::endl;
DartMarker markOrient(myMap); DartMarker markOrient(myMap);
std::vector<Dart> orient; std::vector<Dart> orient;
FunctorStore fs(orient); FunctorStore fs(orient);
...@@ -47,11 +47,13 @@ SimpleGMap3::SimpleGMap3() ...@@ -47,11 +47,13 @@ SimpleGMap3::SimpleGMap3()
d = 49; d = 49;
myMap.foreach_dart_of_oriented_volume(d, fs); myMap.foreach_dart_of_oriented_volume(d, fs);
std::cout << "AAA"<< std::endl;
for(std::vector<Dart>::iterator it = orient.begin() ; it != orient.end() ; ++it) for(std::vector<Dart>::iterator it = orient.begin() ; it != orient.end() ; ++it)
markOrient.mark(*it); markOrient.mark(*it);
SelectorMarked sm(markOrient); SelectorMarked sm(markOrient);
std::cout << "AAA"<< std::endl;
Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap, position, sm); Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap, position, sm);
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i)) for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
...@@ -86,6 +88,7 @@ SimpleGMap3::SimpleGMap3() ...@@ -86,6 +88,7 @@ SimpleGMap3::SimpleGMap3()
myMap.unsewVolumes(d); myMap.unsewVolumes(d);
myMap.check(); myMap.check();
} }
void SimpleGMap3::initGUI() void SimpleGMap3::initGUI()
......
...@@ -53,6 +53,12 @@ add_executable( tuto5 tuto5.cpp ${tuto5_ui} ${tuto5_moc}) ...@@ -53,6 +53,12 @@ add_executable( tuto5 tuto5.cpp ${tuto5_ui} ${tuto5_moc})
target_link_libraries( tuto5 target_link_libraries( tuto5
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} ) ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
QT4_WRAP_UI( tuto_orbits_ui tuto_orbits.ui )
QT4_WRAP_CPP(tuto_orbits_moc tuto_orbits.h)
add_executable( tuto_orbits tuto_orbits.cpp ${tuto_orbits_ui} ${tuto_orbits_moc})
target_link_libraries( tuto_orbits
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
#add_executable( tuto_subdivision tuto_subdivision.cpp) #add_executable( tuto_subdivision tuto_subdivision.cpp)
#target_link_libraries( tuto_subdivision #target_link_libraries( tuto_subdivision
......
...@@ -55,67 +55,94 @@ int main(int argc, char **argv) ...@@ -55,67 +55,94 @@ int main(int argc, char **argv)
return app.exec(); return app.exec();
} }
Dart xd1;
void MyQT::traverseMap() void MyQT::traverseMap()
{ {
DartMarker m1(myMap);
DartMarker m2(myMap);
myMap.rdfi(myMap.begin(),m1,m2);
//traverse cells of map using topological markers on darts m1.unmarkAll();
CGoGNout << "Traverse with DartMarkers:"<< CGoGNendl;
DartMarker dmV(myMap);
DartMarker dmE(myMap);
DartMarker dmF(myMap);
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (!dmV.isMarked(d))
{
CGoGNout << "Vertex of dart "<<d<<CGoGNendl;
dmV.markOrbit(VERTEX,d);
}
if (!dmE.isMarked(d))
{
CGoGNout << "Edgee of dart "<<d<<CGoGNendl;
dmE.markOrbit(EDGE,d);
}
if (!dmF.isMarked(d))
{
CGoGNout << "Face of dart "<<d<<CGoGNendl;
dmF.markOrbit(FACE,d);
}
}
m1.markOrbit(VOLUME,xd1);
// traverses cells of map with markers on embedded cells. // render the topo of the map without boundary darts
// More efficients but more memory costly if cells are not already embedded. SelectorDartNoBoundary<PFP::MAP> nb(myMap);
// Avoid using construction of objects not ell embedded m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,nb);
CGoGNout << "========================="<< CGoGNendl;
CGoGNout << "Traverse with CellMarkers:"<< CGoGNendl;
CellMarker cmV(myMap,VERTEX);
CellMarker cmE(myMap,EDGE);
CellMarker cmF(myMap,FACE);
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d)) for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{ {
if (!cmV.isMarked(d)) if (m2.isMarked(d))
{
CGoGNout << "Vertex of dart "<<d<<CGoGNendl;
cmV.mark(d);
}
if (!cmE.isMarked(d))
{ {
CGoGNout << "Edgee of dart "<<d<<CGoGNendl; m_render_topo->setDartColor(d,1.0f,0.0f,0.0f);
cmE.mark(d);
} }
if (!cmF.isMarked(d)) if (m1.isMarked(d))
{ {
CGoGNout << "Face of dart "<<d<<CGoGNendl; m_render_topo->setDartColor(d,0.0f,1.0f,0.0f);
cmF.mark(d);
} }
} }
// 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 // //traverse cells of map using topological markers on darts
//
// CGoGNout << "Traverse with DartMarkers:"<< CGoGNendl;
// DartMarker dmV(myMap);
// DartMarker dmE(myMap);
// DartMarker dmF(myMap);
// for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
// {
// if (!dmV.isMarked(d))
// {
// CGoGNout << "Vertex of dart "<<d<<CGoGNendl;
// dmV.markOrbit(VERTEX,d);
// }
// if (!dmE.isMarked(d))
// {
// CGoGNout << "Edgee of dart "<<d<<CGoGNendl;
// dmE.markOrbit(EDGE,d);
// }
// if (!dmF.isMarked(d))
// {
// CGoGNout << "Face of dart "<<d<<CGoGNendl;
// dmF.markOrbit(FACE,d);
// }
// }
//
//
// // traverses cells of map with markers on embedded cells.
// // More efficients but more memory costly if cells are not already embedded.
// // Avoid using construction of objects not ell embedded
//
// CGoGNout << "========================="<< CGoGNendl;
// CGoGNout << "Traverse with CellMarkers:"<< CGoGNendl;
// CellMarker cmV(myMap,VERTEX);
// CellMarker cmE(myMap,EDGE);
// CellMarker cmF(myMap,FACE);
// for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
// {
// if (!cmV.isMarked(d))
// {
// CGoGNout << "Vertex of dart "<<d<<CGoGNendl;
// cmV.mark(d);
// }
// if (!cmE.isMarked(d))
// {
// CGoGNout << "Edgee of dart "<<d<<CGoGNendl;
// cmE.mark(d);
// }
// if (!cmF.isMarked(d))
// {
// CGoGNout << "Face of dart "<<d<<CGoGNendl;
// cmF.mark(d);
// }
// }
//
// // 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
} }
...@@ -123,19 +150,46 @@ void MyQT::traverseMap() ...@@ -123,19 +150,46 @@ void MyQT::traverseMap()
void MyQT::createMap() void MyQT::createMap()
{ {
Dart d1 = Algo::Modelisation::Polyhedron<PFP>::createTetra(myMap); // Dart d1 = Algo::Modelisation::Polyhedron<PFP>::createTetra(myMap);
Dart d2 = d1;
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position"); position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
position[d2] = PFP::VEC3(1, 0, 0); Algo::Modelisation::Polyhedron<PFP> prim1(myMap, position);
d2 = PHI1(d2); prim1.cylinder_topo(256,256, true, true); // topo of sphere is a closed cylinder
position[d2] = PFP::VEC3(-1, 0, 0); prim1.embedSphere(2.0f);
d2 = PHI1(d2);
position[d2] = PFP::VEC3(0, 2, 0); // Dart d2 = d1;
d2 = PHI<211>(d2); // position[d2] = PFP::VEC3(1, 0, 0);
position[d2] = PFP::VEC3(0, 1, 2); // d2 = PHI1(d2);
// position[d2] = PFP::VEC3(-1, 0, 0);
// d2 = PHI1(d2);
// position[d2] = PFP::VEC3(0, 2, 0);
// 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.embedSphere(2.0f);
Geom::Matrix44f trf;
trf.identity();
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;
//
// position[xd2] = PFP::VEC3(5, 0, 0);
// xd2 = PHI1(xd2);
// position[xd2] = PFP::VEC3(3, 0, 0);
// xd2 = PHI1(xd2);
// position[xd2] = PFP::VEC3(4, 2, 0);
// xd2 = PHI<211>(xd2);
// position[xd2] = PFP::VEC3(4, 1, 2);
// 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);
......
...@@ -26,256 +26,298 @@ ...@@ -26,256 +26,298 @@
#include "tuto5.h" #include "tuto5.h"
#include <iostream> #include <iostream>
#include "Algo/Modelisation/primitives3d.h" #include "Algo/Modelisation/primitives3d.h"
#include "Algo/Modelisation/polyhedron.h" #include "Algo/Modelisation/polyhedron.h"
#include "Algo/Modelisation/subdivision.h" #include "Algo/Import/import.h"
#include "Algo/Render/GL2/topo3Render.h"
#include "Algo/Render/SVG/mapSVGRender.h"
PFP::MAP myMap; PFP::MAP myMap;
PFP::TVEC3 position ; PFP::TVEC3 position ;
Dart dglobal;
void MyQT::balls_onoff(bool x)
{
render_balls = !render_balls;
updateGL();
CGoGNerr << " balls_onoff "<< CGoGNendl;
}
void MyQT::vectors_onoff(bool x) void MyQT::volumes_onoff(bool x)
{ {
render_vectors = !render_vectors; render_volumes = !render_volumes;
updateGL(); updateGL();
CGoGNerr << " vectors_onoff "<< CGoGNflush;
} }
void MyQT::text_onoff(bool x) void MyQT::edges_onoff(bool x)
{ {
render_text = !render_text; render_edges = !render_edges;
updateGL(); updateGL();
CGoGNerr << " text_onoff " << CGoGNflush;
} }
void MyQT::topo_onoff(bool x) void MyQT::topo_onoff(bool x)
{ {
render_topo = !render_topo; render_topo = !render_topo;
if (render_topo)
{
SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_topo_render->updateData<PFP>(myMap, position, 0.8f, 0.8f, m_explode_factor, nb);
}
updateGL(); updateGL();
CGoGNerr << " topo_onoff " << CGoGNflush;
} }
void MyQT::slider_balls(int x) void MyQT::clipping_onoff(bool x)
{ {
m_sprite->setSize(0.05f*x); clip_volume = !clip_volume;
if (clip_volume)
{
Geom::Vec3f pos = m_PlanePick->getPosition();
float pipo;
Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
float d = -(pos*normal);
m_explode_render->setClippingPlane(Geom::Vec4f(normal[0],normal[1],normal[2],d));
m_topo_render->shader1()->setClipPlaneParamsAll(clip_id1, normal, pos);
m_topo_render->shader2()->setClipPlaneParamsAll(clip_id2, normal, pos);
}
else
{
m_explode_render->setNoClippingPlane();
m_topo_render->shader1()->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_topo_render->shader2()->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_topo_render->shader1()->setClipColorAttenuationFactorRelative(0.0f,0.0f);
m_topo_render->shader2()->setClipColorAttenuationFactorRelative(0.0f,0.0f);
}
updateGL(); updateGL();
} }
void MyQT::slider_vectors(int x) void MyQT::hide_onoff(bool x)
{ {
m_lines->setScale(0.02*x); hide_clipping = !hide_clipping;
updateGL(); updateGL();
} }
void MyQT::slider_text(int x)
void MyQT::slider_explode(int x)
{ {
m_strings->setScale(0.02f*x); m_explode_factor = 0.01f*x;
m_explode_render->setExplodeVolumes(m_explode_factor);
updateGL(); updateGL();
} }
void MyQT::slider_pressed()
void MyQT::animate()
{ {
// transfoMatrix() = glm::rotate(transfoMatrix(), 0.5f, glm::vec3(0.5773f,0.5773f,0.5773f)); render_topoTemp = render_topo;
transfoRotate( 0.5f, 0.5773f,0.5773f,0.5773f); render_topo = false;
updateGLMatrices(); updateGL();
} }
void MyQT::storeVerticesInfo() void MyQT::slider_released()
{ {
CellMarker mv(myMap,VERTEX); render_topo = render_topoTemp;
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d)) if (render_topo)
{ {
if (!mv.isMarked(d)) SelectorDartNoBoundary<PFP::MAP> nb(myMap);
{ m_topo_render->updateData<PFP>(myMap, position, 0.8f, 0.8f, m_explode_factor, nb);
mv.mark(d);
std::stringstream ss;
ss << d << " : "<< position[d];
m_strings->addString(ss.str(),position[d]);
}
} }
updateGL();
} }
void MyQT::cb_initGL() void MyQT::cb_initGL()
{ {
// choose to use GL version 2 // choose to use GL version 2
Utils::GLSLShader::setCurrentOGLVersion(2); Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render // create the renders
m_render = new Algo::Render::GL2::MapRender(); m_topo_render = new Algo::Render::GL2::Topo3Render();
m_explode_render = new Algo::Render::GL2::ExplodeVolumeRender();
m_render_topo = new Algo::Render::GL2::Topo3Render();
// create VBO for position
m_positionVBO = new Utils::VBO();
m_positionVBO->updateData(position);
// using simple shader with color SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_shader = new Utils::ShaderSimpleColor(); m_topo_render->updateData<PFP>(myMap, position, 0.8f, 0.8f, 0.8f, nb);
m_shader->setAttributePosition(m_positionVBO); m_explode_render->updateData<PFP>(myMap,position);
m_shader->setColor(Geom::Vec4f(0.,1.,0.,0.)); m_explode_render->setExplodeVolumes(0.8f);
m_explode_render->setColorLine(Geom::Vec4f(0.3f,0.3f,0.3f,1.0f));
m_sprite = new Utils::PointSprite();
m_sprite->setAttributePosition(m_positionVBO);
m_strings = new Utils::Strings3D(true, Geom::Vec3f(0.1f,0.0f,0.3f));
storeVerticesInfo();
m_strings->sendToVBO();
// copy de contenu de VBO a la creation registerShader(m_explode_render->shaderFaces());
m_dataVBO = new Utils::VBO(*m_positionVBO); registerShader(m_explode_render->shaderLines());
m_lines = new Utils::ShaderVectorPerVertex(); m_PlanePick = new Utils::Pickable(Utils::Pickable::GRID,1);
m_lines->setAttributePosition(m_positionVBO); m_frame = new Utils::FrameManipulator();
m_lines->setAttributeVector(m_dataVBO); m_frame->setSize(m_WidthObj/2.0f);
m_lines->setScale(0.2f);
m_lines->setColor(Geom::Vec4f(0.0f, 1.0f, 0.2f, 0.0f));
// accede au buffer du VBO pour modification
PFP::VEC3* data = static_cast<PFP::VEC3*>(m_dataVBO->lockPtr());
for (unsigned int i=0; i< m_dataVBO->nbElts(); ++i)
{
data[i].normalize();
}
m_dataVBO->releasePtr();
registerShader(m_shader); m_topo_render->shader1()->insertClippingCode();
registerShader(m_strings); m_topo_render->shader2()->insertClippingCode();
registerShader(m_sprite);
registerShader(m_lines);
SelectorTrue allDarts; clip_id1 = m_topo_render->shader1()->addClipPlane();
clip_id2 = m_topo_render->shader2()->addClipPlane();
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES); m_topo_render->shader1()->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), m_PosObj);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES); m_topo_render->shader2()->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), m_PosObj);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS); m_explode_render->setClippingPlane(Geom::Vec4f(0,0,1,m_PosObj*Geom::Vec3f(0,0,-1)));
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()) );
}
void MyQT::cb_redraw() void MyQT::cb_redraw()
{ {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
m_render->draw(m_shader, Algo::Render::GL2::POINTS);
glLineWidth(2.0f);
m_shader->setColor(Geom::Vec4f(1.,1.,0.,0.));
m_render->draw(m_shader, Algo::Render::GL2::LINES);
glEnable(GL_POLYGON_OFFSET_FILL); glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(1.0f, 1.0f); glPolygonOffset(1.0f, 1.0f);
if (render_topo) if (render_topo)
m_render_topo->drawTopo(); m_topo_render->drawTopo();
/* Dart d = myMap.phi2(myMap.begin()); if (render_edges)
m_render_topo->overdrawDart(d, 5, 1.0f, 0.0f, 1.0f); {
d = myMap.phi1(myMap.begin()); glLineWidth(1.0f);
m_render_topo->overdrawDart(d, 5, 1.0f, 0.0f, 1.0f); m_explode_render->drawEdges();
*/ }
m_render_topo->overdrawDart(m_selected, 5, 1.0f, 0.0f, 1.0f);
glDisable(GL_POLYGON_OFFSET_FILL); glDisable(GL_POLYGON_OFFSET_FILL);
if (render_text) if (render_volumes)
m_strings->drawAll(Geom::Vec3f(0.0f, 1.0f, 1.0f));
if (render_balls)
{ {
m_sprite->predraw(Geom::Vec3f(1.0f, 0.0f ,0.0f)); m_explode_render->drawFaces();
m_render->draw(m_sprite, Algo::Render::GL2::POINTS);
m_sprite->postdraw();
} }