Commit 921efcb1 authored by untereiner's avatar untereiner

some changes

parent 71e149b3
......@@ -29,6 +29,8 @@
#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"
......@@ -156,31 +158,42 @@ void MyQT::cb_mousePress(int /*button*/, int x, int y)
void MyQT::cb_Save()
{
// std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
// Utils::SVG::SVGOut svg(filename,modelViewMatrix(),projectionMatrix());
// m_drawer.toSVG(svg);
// m_render_topo->toSVG(svg);
std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
std::string filename1 = filename + std::string("Drawer") + std::string(".svg");
std::string filename2 = filename + std::string("Topo") + std::string(".svg");
Utils::SVG::SVGOut svg1(modelViewMatrix(), projectionMatrix());
// std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
// Utils::SVG::SVGOut svg(filename,modelViewMatrix(),projectionMatrix());
// m_drawer.toSVG(svg);
// m_render_topo->toSVG(svg);
Utils::SVG::SVGOut svg1(filename1, modelViewMatrix(), projectionMatrix());
m_drawer.toSVG(svg1);
// svg1.addOpacityAnimation(1.0f);
// svg1.addOpacityAnimation(1.0f);
// svg1.addOpacityAnimation(0.0f);
svg1.write();
// svg1.addOpacityAnimation(1.0f);
// svg1.addOpacityAnimation(1.0f);
// svg1.addOpacityAnimation(0.0f);
Utils::SVG::SVGOut svg2(modelViewMatrix(), projectionMatrix());
Utils::SVG::SVGOut svg2(filename2, modelViewMatrix(), projectionMatrix());
m_render_topo->toSVG(svg2);
// svg2.addOpacityAnimation(1.0f);
// svg2.addOpacityAnimation(0.0f);
// svg2.addOpacityAnimation(1.0f);
svg2.write();
// svg2.addOpacityAnimation(1.0f);
// svg2.addOpacityAnimation(0.0f);
// svg2.addOpacityAnimation(1.0f);
Utils::SVG::AnimatedSVGOut anim;
// Utils::SVG::AnimatedSVGOut anim;
// anim.add(&svg1);
// anim.add(&svg2);
// anim.write(filename, 2.0f);
anim.add(&svg1);
anim.add(&svg2);
std::string filename = selectFileSave("Export SVG file ",".","(*.svg)");
anim.write(filename, 2.0f);
}
template <unsigned int ORBIT>
......@@ -196,7 +209,7 @@ void MyQT::traverse2()
if (m_selected == NIL)
return;
m_last=2;
// int code = (m_ajd_or_inci2)*100+m_first2*10+m_second2;
// int code = (m_ajd_or_inci2)*100+m_first2*10+m_second2;
m_drawer.newList(GL_COMPILE);
m_drawer.lineWidth(7.0f);
......@@ -226,7 +239,7 @@ void MyQT::traverse2()
m_drawer.endList();
// SelectorMarked sm(*m_dm_topo);
// SelectorMarked sm(*m_dm_topo);
m_render_topo->updateData<PFP>(myMap, position, 0.95f, 0.9f, 0.8f);
updateGL();
......@@ -255,7 +268,6 @@ void MyQT::dynamicMarkOrbit(unsigned int orb)
}
}
void MyQT::traverse3()
{
if (m_selected == NIL)
......@@ -271,7 +283,7 @@ void MyQT::traverse3()
m_drawer.color3f(0.0f,0.7f,0.0f);
m_dm_topo->unmarkAll();
SelectorMarked sm(*m_dm_topo);
//SelectorMarked sm(*m_dm_topo);
if (m_ajd_or_inci3 == 0) // incident
{
......@@ -597,11 +609,61 @@ void MyQT::dyn_trav3XY(unsigned int first, unsigned int second)
int main(int argc, char **argv)
{
if(argc == 1)
{
position = myMap.addAttribute<VEC3, VERTEX>( "position");
Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position);
dglobal = prim.hexaGrid_topo(4,4,4);
dglobal = prim.hexaGrid_topo(3,3,3);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
}
else
{
std::string filename(argv[1]);
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
std::vector<std::string> attrNames ;
if(extension == std::string(".off"))
{
if(!Algo::Volume::Import::importMeshToExtrude<PFP>(myMap, filename, attrNames, 1.5, 2))
{
std::cerr << "could not import " << filename << std::endl ;
return -1;
}
myMap.closeMap();
}
// if(extension == std::string(".off"))
// {
// if(!Algo::Surface::Import::importMeshSAsV<PFP>(myMap, filename, attrNames))
// {
// std::cerr << "could not import " << std::endl ;
// return ;
// }
// /myMap.closeMap();
// }
else if(extension == std::string(".map"))
{
myMap.clear(true);
if(!myMap.loadMapBin(filename))
{
std::cout << "could not load file" << std::endl;
}
//myMap.dumpAttributesAndMarkers();
position = myMap.getAttribute<PFP::VEC3, VERTEX>("position");
}
else if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
{
std::cerr << "could not import " << filename << std::endl ;
return -1;
}
position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
}
// un peu d'interface
QApplication app(argc, argv);
......
......@@ -194,7 +194,12 @@ void MyQT::createMap(int n)
m_render_topo->setDartWidth(4.0f);
m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f);
m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true); // nb
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, 0.9);
#else
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true);
#endif
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{
......@@ -213,7 +218,12 @@ void MyQT::createMap(int n)
void MyQT::updateMap()
{
m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true); // nb
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, 0.9);
#else
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true);
#endif
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{
if (dm.isMarked(d) && (!myMap.isBoundaryMarked2(d)))
......@@ -229,7 +239,11 @@ void MyQT::updateMap()
void MyQT::cb_initGL()
{
glClearColor(1.0f,1.0f,1.0f,1.0f);
#ifdef PRIMAL_TOPO
m_render_topo = new Algo::Render::GL2::TopoPrimalRender() ;
#else
m_render_topo = new Algo::Render::GL2::TopoRender(0.01f) ;
#endif
}
// redraw GL callback (clear and swap already done)
......
......@@ -27,6 +27,7 @@
//#define USE_GMAP
//#define PRIMAL_TOPO 1
#include "Topology/generic/parameters.h"
......@@ -36,8 +37,11 @@
#include "Topology/map/embeddedMap2.h"
#endif
#include "Algo/Render/GL2/topoRender.h"
#ifdef PRIMAL_TOPO
#include "Algo/Render/GL2/topoPrimalRender.h"
#else
#include "Algo/Render/GL2/topoRender.h"
#endif
#include "ui_tuto_oper2.h"
#include "Utils/Qt/qtui.h"
......@@ -88,7 +92,11 @@ protected:
DartAttribute<VEC3> colorDarts;
// render (for the topo)
#ifdef PRIMAL_TOPO
Algo::Render::GL2::TopoPrimalRender* m_render_topo;
#else
Algo::Render::GL2::TopoRender* m_render_topo;
#endif
Dart m_selected;
Dart m_selected2;
DartMarker dm;
......
......@@ -110,7 +110,6 @@ void MyQT::operation(int x)
CGoGNout <<"delete vertex"<<CGoGNendl;
if (m_selected != NIL)
{
dm.markAll();
m_selected=myMap.deleteVertex(m_selected);
m_selected = NIL;
updateMap();
......@@ -120,7 +119,6 @@ void MyQT::operation(int x)
CGoGNout <<"cut edge"<<CGoGNendl;
if (m_selected != NIL)
{
dm.markAll();
PFP::VEC3 Q = position[myMap.phi1(m_selected)];
myMap.cutEdge(m_selected);
position[myMap.phi1(m_selected)] = (position[m_selected] + Q)/2.0f;
......@@ -131,7 +129,6 @@ void MyQT::operation(int x)
CGoGNout <<"uncut edge"<<CGoGNendl;
if (m_selected != NIL)
{
dm.markAll();
myMap.uncutEdge(m_selected);
updateMap();
}
......@@ -142,7 +139,6 @@ void MyQT::operation(int x)
{
if (myMap.deleteEdgePreCond(m_selected))
{
dm.markAll();
myMap.deleteEdge(m_selected);
m_selected = NIL;
updateMap();
......@@ -159,7 +155,6 @@ void MyQT::operation(int x)
{
PFP::VEC3 Q = (position[myMap.phi1(m_selected)] + position[m_selected])/2.0f;
Dart x = myMap.collapseEdge(m_selected);
dm.markAll();
position[x]= Q;
m_selected = NIL;
updateMap();
......@@ -170,7 +165,6 @@ void MyQT::operation(int x)
if (m_selected != NIL)
{
myMap.splitFace(m_selected,m_selected2);
dm.markAll();
updateMap();
}
break;
......@@ -179,7 +173,6 @@ void MyQT::operation(int x)
if (m_selected != NIL)
{
myMap.mergeVolumes(m_selected);
dm.markAll();
updateMap();
}
break;
......@@ -195,8 +188,6 @@ void MyQT::operation(int x)
myMap.splitVolume(m_selecteds);
m_selecteds.clear();
dm.markAll();
updateMap();
}
break;
......@@ -206,7 +197,6 @@ void MyQT::operation(int x)
{
PFP::VEC3 Q = Algo::Surface::Geometry::faceCentroid<PFP>(myMap,m_selected,position);
Dart x = myMap.collapseFace(m_selected);
dm.markAll();
position[x]= Q;
m_selected = NIL;
updateMap();
......@@ -218,7 +208,6 @@ void MyQT::operation(int x)
{
PFP::VEC3 Q = Algo::Surface::Geometry::volumeCentroid<PFP>(myMap,m_selected,position);
Dart x = myMap.collapseVolume(m_selected);
dm.markAll();
position[x]= Q;
m_selected = NIL;
updateMap();
......@@ -237,7 +226,6 @@ void MyQT::operation(int x)
//position[dit] = position[dit] - c1*0.5f;
m_selecteds.clear();
m_selected = NIL;
dm.markAll();
updateMap();
std::cout << "nb darts after = " << myMap.getNbDarts() << std::endl;
}
......@@ -247,7 +235,15 @@ void MyQT::operation(int x)
if (m_selected != NIL)
{
myMap.unsewVolumes(m_selected);
dm.markAll();
m_selected = NIL;
updateMap();
}
break;
case 12 :
CGoGNout <<"delete volume"<<CGoGNendl;
if (m_selected != NIL)
{
myMap.deleteVolume(m_selected);
m_selected = NIL;
updateMap();
}
......@@ -270,17 +266,17 @@ void MyQT::createMap(int n)
prim.hexaGrid_topo(n,n,n);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
// Algo::Surface::Modelisation::Polyhedron<PFP> poly(myMap, position);
// poly.cylinder_topo(6,1,true,true);
// poly.embedCylinder(6.0,6.0,5.0);
// Algo::Surface::Modelisation::Polyhedron<PFP> poly(myMap, position);
// poly.cylinder_topo(6,1,true,true);
// poly.embedCylinder(6.0,6.0,5.0);
myMap.closeMap();
// Dart d = Algo::Surface::Modelisation::embedPrism<PFP>(myMap, position, 5, true,6.0,6.0,5.0);
// Dart d2 = Algo::Surface::Modelisation::embedPyramid<PFP>(myMap, position, 4, true,6.0,5.0);
// Dart d = Algo::Surface::Modelisation::embedPrism<PFP>(myMap, position, 5, true,6.0,6.0,5.0);
// Dart d2 = Algo::Surface::Modelisation::embedPyramid<PFP>(myMap, position, 4, true,6.0,5.0);
// myMap.sewVolumes(myMap.phi2(d),d2);
// position[myMap.phi_1(myMap.phi2(d2))] += VEC3(9.0,-5.0,-2.5);
// myMap.sewVolumes(myMap.phi2(d),d2);
// position[myMap.phi_1(myMap.phi2(d2))] += VEC3(9.0,-5.0,-2.5);
myMap.check();
......@@ -301,7 +297,11 @@ void MyQT::createMap(int n)
void MyQT::updateMap()
{
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3/*, nb*/);
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, m_ex1, m_ex2);
#else
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3);
#endif
m_render_topo_boundary->updateDataBoundary<PFP>(myMap,position,m_ex1,m_ex2,m_shift);
}
......@@ -309,8 +309,12 @@ void MyQT::updateMap()
void MyQT::cb_initGL()
{
glClearColor(1.0f,1.0f,1.0f,1.0f);
m_render_topo = new Algo::Render::GL2::Topo3Render() ;
#ifdef PRIMAL_TOPO
m_render_topo = new Algo::Render::GL2::Topo3PrimalRender() ;
#else
m_render_topo = new Algo::Render::GL2::Topo3Render() ;
#endif
m_render_topo_boundary = new Algo::Render::GL2::TopoRender();
m_render_topo_boundary->setInitialDartsColor(0.0f,0.9f,0.0f);
......@@ -352,7 +356,7 @@ void MyQT::cb_redraw()
m_render_topo->drawTopo();
m_render_topo_boundary->drawTopo();
// m_render_topo_boundary->drawTopo();
glDisable( GL_POLYGON_OFFSET_FILL );
......@@ -417,15 +421,6 @@ void MyQT::cb_mousePress(int button, int x, int y)
if (Control())
{
// Dart d = m_render_topo->picking<PFP>(myMap, x,y/*, nb*/);
// if (button == Qt::LeftButton)
// {
// if (d != Dart::nil())
// m_selecteds.push_back(d);
// }
// updateGL();
if (button == Qt::LeftButton)
{
Dart d = m_render_topo_boundary->picking<PFP>(myMap, x,y,true);
......@@ -440,6 +435,7 @@ void MyQT::cb_mousePress(int button, int x, int y)
Dart d = m_render_topo->picking<PFP>(myMap, x,y/*, nb*/);
if (d != Dart::nil())
{
m_selecteds.push_back(d);
Dart e = myMap.phi2(d);
std::cout << "Dart "<< d.index << " / phi2:" << e.index << std::endl;
}
......@@ -586,51 +582,108 @@ void MyQT::cb_keyPress(int keycode)
case 'w':
m_ex1 = 0.99f;
m_ex2 = 0.99f;
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3/*, nb*/);
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, m_ex1, m_ex2);
#else
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3);
#endif
updateGL();
break;
case 'W':
m_ex1 = 0.95f;
m_ex2 = 0.95f;
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3/*, nb*/);
updateGL();
break;
// case 'c':
// for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
// {
// if (!myMap.isBoundaryMarked3(d))
// {
// int n = random();
// float r = float(n&0x7f)/255.0f + 0.25f;
// float g = float((n>>8)&0x7f)/255.0f + 0.25f;
// float b = float((n>>16)&0x7f)/255.0 + 0.25f;
// colorDarts[d] = Geom::Vec3f(r,g,b);
// m_render_topo->setDartColor(d,r,g,b);
// }
// }
// break;
// case 'g':
// for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
// {
// if (!myMap.isBoundaryMarked3(d))
// {
// colorDarts[d] = Geom::Vec3f(0.5f,0.5f,0.5f);
// m_render_topo->setDartColor(d,0.5f,0.5f,0.5f);
// }
// }
// break;
//
// case 'b':
// for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
// {
// if (!myMap.isBoundaryMarked3(d))
// {
// colorDarts[d] = Geom::Vec3f(0.0f,0.0f,0.0f);
// m_render_topo->setDartColor(d,0.0f,0.0f,0.0f);
// }
// }
// break;
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, m_ex1, m_ex2);
#else
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3);
#endif
updateGL();
break;
case '-':
if(Control())
m_ex2 -= 0.05f;
else
m_ex1 -= 0.05f;
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, m_ex1, m_ex2);
#else
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3);
#endif
updateGL();
break;
case '+':
if(Control())
m_ex2 += 0.05f;
else
m_ex1 += 0.05f;
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, m_ex1, m_ex2);
#else
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3);
#endif
updateGL();
break;
case '*':
{
m_selecteds.clear();
Dart d2 = myMap.phi_1(myMap.phi_1(m_selected));
myMap.splitFace(m_selected,d2);
Dart d3 = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(m_selected))));
myMap.splitFace(myMap.phi1(d3),myMap.phi_1(d3));
Dart dit = myMap.phi_1(m_selected);
m_selecteds.push_back(dit);
dit = myMap.phi1(myMap.phi2(myMap.phi1(dit)));
m_selecteds.push_back(dit);
dit = myMap.phi1(myMap.phi2(myMap.phi1(dit)));
m_selecteds.push_back(dit);
dit = myMap.phi1(myMap.phi2(myMap.phi1(dit)));
m_selecteds.push_back(dit);
myMap.splitVolume(m_selecteds);
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, m_ex1, m_ex2);
#else
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3);
#endif
updateGL();
}
break;
// case 'c':
// for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
// {
// if (!myMap.isBoundaryMarked3(d))
// {
// int n = random();
// float r = float(n&0x7f)/255.0f + 0.25f;
// float g = float((n>>8)&0x7f)/255.0f + 0.25f;
// float b = float((n>>16)&0x7f)/255.0 + 0.25f;
// colorDarts[d] = Geom::Vec3f(r,g,b);
// m_render_topo->setDartColor(d,r,g,b);
// }
// }
// break;
// case 'g':
// for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
// {
// if (!myMap.isBoundaryMarked3(d))
// {
// colorDarts[d] = Geom::Vec3f(0.5f,0.5f,0.5f);
// m_render_topo->setDartColor(d,0.5f,0.5f,0.5f);
// }
// }
// break;
//
// case 'b':
// for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
// {
// if (!myMap.isBoundaryMarked3(d))
// {
// colorDarts[d] = Geom::Vec3f(0.0f,0.0f,0.0f);
// m_render_topo->setDartColor(d,0.0f,0.0f,0.0f);
// }
// }
// break;
case Qt::Key_Up:
if (m_selected!=NIL)
position[m_selected][1] += m_shift;
......@@ -711,8 +764,8 @@ void MyQT::importMesh(std::string& filename)
m_selected = NIL;
m_selected2 = NIL;
// m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3/*, nb*/);
// m_render_topo_boundary->updateDataBoundary<PFP>(myMap,position,m_ex1,m_ex2,m_shift);
// m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3/*, nb*/);
// m_render_topo_boundary->updateDataBoundary<PFP>(myMap,position,m_ex1,m_ex2,m_shift);
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
setParamObject(bb.maxSize(), bb.center().data()) ;
......@@ -727,6 +780,10 @@ void MyQT::importMesh(std::string& filename)
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*/);
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, m_ex1, m_ex2);
#else
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3);
#endif
updateGL();
}
......@@ -27,6 +27,7 @@
//#define USE_GMAP
#define PRIMAL_TOPO 1
#include "Topology/generic/parameters.h"
......@@ -36,7 +37,12 @@
#include "Topology/map/embeddedMap3.h"
#endif
#include "Algo/Render/GL2/topo3Render.h"
#ifdef PRIMAL_TOPO
#include "Algo/Render/GL2/topo3PrimalRender.h"
#else
#include "Algo/Render/GL2/topo3Render.h"
#endif
#include "Algo/Render/GL2/topoRender.h"
#include "Algo/Geometry/boundingbox.h"
......@@ -71,7 +77,7 @@ class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MyQT():m_render_topo(NULL),m_selected(NIL),m_selected2(NIL),dm(myMap),m_shift(0.01f),m_ex1(0.9f),m_ex2(0.9f),m_ex3(0.9f), clip_volume(true) , hide_clipping(false) {}
MyQT():m_render_topo(NULL),m_selected(NIL),m_selected2(NIL),m_shift(0.01f),m_ex1(0.9f),m_ex2(0.9f),m_ex3(0.9f), clip_volume(true) , hide_clipping(false) {}
void cb_redraw();
void cb_initGL();
......@@ -95,12 +101,15 @@ protected:
Geom::BoundingBox<PFP::VEC3> bb;
// render (for the topo)
#ifdef PRIMAL_TOPO
Algo::Render::GL2::Topo3PrimalRender* m_render_topo;
#else
Algo::Render::GL2::Topo3Render* m_render_topo;