Commit e5f58387 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'master' of cgogn:CGoGN

parents a319729c 7677a0f3
......@@ -34,27 +34,31 @@ SimpleGMap3::SimpleGMap3()
normal = myMap.addAttribute<VEC3, VERTEX>("normal");
volume = myMap.addAttribute<VEC3, VOLUME>("volume");
CellMarker<EDGE> mE(myMap);
Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(3,1,1);
primCat.embedHexaGrid(2,1,1);
std::cout << "AAA"<< std::endl;
myMap.check();
std::cout << "AAA"<< std::endl;
DartMarker markOrient(myMap);
std::vector<Dart> orient;
FunctorStore fs(orient);
// DartMarker markOrient(myMap);
// std::vector<Dart> orient;
// FunctorStore fs(orient);
d = 49;
myMap.foreach_dart_of_oriented_volume(d, fs);
// d = 49;
// myMap.foreach_dart_of_oriented_volume(d, fs);
// for(std::vector<Dart>::iterator it = orient.begin() ; it != orient.end() ; ++it)
// markOrient.mark(*it);
std::cout << "AAA"<< std::endl;
// SelectorMarked sm(markOrient);
// std::cout << "AAA"<< std::endl;
// Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap, position, sm);
for(std::vector<Dart>::iterator it = orient.begin() ; it != orient.end() ; ++it)
markOrient.mark(*it);
// Geom::Plane3D<PFP::REAL> pl(VEC3(0.5,0.14,0.5),VEC3(1.5,0.45,0.5),VEC3(0.5,0.15,1.5));
Geom::Plane3D<PFP::REAL> pl(VEC3(-1,-0.5,-0.5),VEC3(-1,-0.5,0.5),VEC3(1,0.5,0.5));
Algo::Modelisation::sliceConvexVolume<PFP>(myMap, position, d, pl);
SelectorMarked sm(markOrient);
std::cout << "AAA"<< std::endl;
//Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap, position, sm);
myMap.check();
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(2,0,0);
......@@ -77,6 +81,10 @@ SimpleGMap3::SimpleGMap3()
myMap.cutEdge(d);
position[myMap.phi1(d)] = mid;
myMap.splitFace(d,myMap.phi1(myMap.phi1(myMap.phi1(d))));
myMap.check();
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(0,2,0);
......@@ -112,12 +120,13 @@ void SimpleGMap3::cb_redraw()
glDisable(GL_LIGHTING);
glLineWidth(1.0f);
Algo::Render::GL1::renderTopoGMD3<PFP>(myMap, position, true, true, true, true, 0.9f, 0.9f, 0.9f, 0.9f);
// Algo::Render::GL1::renderTopoMD3<PFP>(myMap, position, true, true, true, 0.9f, 0.9f, 0.9f);
glDisable(GL_LIGHTING);
glColor3f(1.0f, 1.0f, 1.0f);
glLineWidth(1.0f);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
Algo::Render::GL1::renderTriQuadPoly<PFP>(myMap, Algo::Render::GL1::LINE, 1.0,position, normal);
// glDisable(GL_LIGHTING);
// glColor3f(1.0f, 1.0f, 1.0f);
// glLineWidth(1.0f);
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// Algo::Render::GL1::renderTriQuadPoly<PFP>(myMap, Algo::Render::GL1::LINE, 1.0,position, normal);
}
/**********************************************************************************************
......
......@@ -28,6 +28,7 @@
#include "Topology/generic/parameters.h"
#include "Topology/gmap/embeddedGMap3.h"
//#include "Topology/map/embeddedMap3.h"
#include "Geometry/vector_gen.h"
......@@ -40,6 +41,7 @@ struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedGMap3 MAP ;
// typedef EmbeddedMap3 MAP ;
};
typedef PFP::MAP MAP ;
......
......@@ -27,7 +27,7 @@
#include <iostream>
#define WITH_GMAP 1
// #define WITH_GMAP 1
#include "Topology/generic/parameters.h"
#ifdef WITH_GMAP
......
......@@ -34,7 +34,7 @@ QT4_WRAP_UI( tuto2_ui tuto2.ui )
QT4_WRAP_CPP(tuto2_moc tuto2.h)
add_executable( tuto2 tuto2.cpp tuto2.h ${tuto2_ui} ${tuto2_moc})
target_link_libraries( tuto2
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} QtSvg)
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
QT4_WRAP_CPP(tuto3_moc tuto3.h)
add_executable( tuto3 tuto3.cpp ${tuto3_moc})
......@@ -89,7 +89,7 @@ target_link_libraries( tp_master
QT4_WRAP_CPP(tuto_histo_moc tuto_histo.h)
add_executable( tuto_histo tuto_histo.cpp tuto_histo.h ${tuto_histo_ui} ${tuto_histo_moc})
target_link_libraries( tuto_histo
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} QtSvg)
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
#BOOST_LIBS macro: allow using compiled boost in windows (see readme)
......
......@@ -173,12 +173,16 @@ void MyQT::cb_keyPress(int keycode)
l_nbc++;
l_histo->populateHisto(l_nbc);
l_histodraw->repaint();
l_histo->histoColorizeVBO(*m_colorVBO2);
updateGL();
break;
case '-' :
if (l_nbc>0)
l_nbc--;
l_histo->populateHisto(l_nbc);
l_histodraw->repaint();
l_histo->histoColorizeVBO(*m_colorVBO2);
updateGL();
break;
case 'p' :
......@@ -205,6 +209,8 @@ void MyQT::cb_keyPress(int keycode)
l_histo->centerOnZero();
l_histo->populateHisto(l_nbc);
l_histodraw->repaint();
l_histo->histoColorizeVBO(*m_colorVBO2);
updateGL();
break;
case 'w' :
......@@ -214,6 +220,8 @@ void MyQT::cb_keyPress(int keycode)
l_histo->setMax(av*0.1 + l_histo->getMax()*0.9);
l_histo->populateHisto(l_nbc);
l_histodraw->repaint();
l_histo->histoColorizeVBO(*m_colorVBO2);
updateGL();
}
break;
case 'x' :
......@@ -223,6 +231,8 @@ void MyQT::cb_keyPress(int keycode)
l_histo->setMax(-0.1*av + l_histo->getMax()*1.1);
l_histo->populateHisto(l_nbc);
l_histodraw->repaint();
l_histo->histoColorizeVBO(*m_colorVBO2);
updateGL();
}
break;
......
......@@ -45,6 +45,8 @@ int main(int argc, char **argv)
sqt.setCallBack( sqt.dock.listOper, SIGNAL(currentRowChanged(int)), SLOT(operation(int)) );
sqt.setCallBack( sqt.dock.svg, SIGNAL(clicked()), SLOT(svg()) );
sqt.setCallBack( sqt.dock.widthSlider, SIGNAL(valueChanged(int)), SLOT(width(int)) );
sqt.setCallBack( sqt.dock.checkBox_hide, SIGNAL(toggled(bool)), SLOT(hide_onoff(bool)) );
sqt.setCallBack( sqt.dock.checkBox_plane, SIGNAL(toggled(bool)), SLOT(clipping_onoff(bool)) );
int n=3;
if (argc==2)
n = atoi(argv[1]);
......@@ -62,6 +64,36 @@ int main(int argc, char **argv)
return app.exec();
}
void MyQT::clipping_onoff(bool x)
{
clip_volume = x;
if (clip_volume)
{
Geom::Vec3f pos = m_PlanePick->getPosition();
float pipo;
Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, normal, pos);
m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, normal, pos);
}
else
{
m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), Geom::Vec3f(0,0,999999.9f));
m_render_topo->shader1()->setClipColorAttenuationFactorRelative(0.0f,0.0f);
m_render_topo->shader2()->setClipColorAttenuationFactorRelative(0.0f,0.0f);
}
updateMap();
updateGL();
}
void MyQT::hide_onoff(bool x)
{
hide_clipping = !hide_clipping;
updateMap();
updateGL();
}
void MyQT::operation(int x)
{
switch(x)
......@@ -191,8 +223,8 @@ void MyQT::operation(int x)
Dart dit = m_selecteds.front();
PFP::VEC3 Q = (position[myMap.phi1(m_selected)] + position[m_selected])/2.0f;
//PFP::VEC3 c1 = Algo::Geometry::volumeCentroid<PFP>(myMap, dit, position);
//Dart dres = myMap.splitVertex(m_selecteds);
Dart dres = Algo::Modelisation::Tetrahedralization::splitVertex<PFP>(myMap, m_selecteds);
Dart dres = myMap.splitVertex(m_selecteds);
//Dart dres = Algo::Modelisation::Tetrahedralization::splitVertex<PFP>(myMap, m_selecteds);
position[dres] = position[dit] + Q*0.25f;
//position[dit] = position[dit] - c1*0.5f;
m_selecteds.clear();
......@@ -220,17 +252,8 @@ void MyQT::createMap(int n)
prim.hexaGrid_topo(n,n,n);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
// Dart d = Algo::Modelisation::createTetrahedron<PFP>(myMap);
// myMap.closeMap();
//
// position[d] = typename PFP::VEC3(0.0f, 0.0f, 0.0f);
// position[myMap.phi1(d)] = typename PFP::VEC3(0.0f, 1.0f, 0.0f);
// position[myMap.phi1(myMap.phi1(d))] = typename PFP::VEC3(1.0f, 0.5f, 0.0f);
// position[myMap.phi_1(myMap.phi2(d))] = typename PFP::VEC3(0.5f, 0.5f, 1.0f);
// bounding box of scene
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
setParamObject(bb.maxSize(), bb.center().data()) ;
m_shift = bb.maxSize()/200.0f;
......@@ -254,6 +277,20 @@ void MyQT::cb_initGL()
{
glClearColor(1.0f,1.0f,1.0f,1.0f);
m_render_topo = new Algo::Render::GL2::Topo3Render() ;
m_PlanePick = new Utils::Pickable(Utils::Pickable::GRID,1);
m_frame = new Utils::FrameManipulator();
m_frame->setSize(bb.maxSize());
m_render_topo->shader1()->insertClippingCode();
m_render_topo->shader2()->insertClippingCode();
clip_id1 = m_render_topo->shader1()->addClipPlane();
clip_id2 = m_render_topo->shader2()->addClipPlane();
m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, Geom::Vec3f(0,0,1), bb.center());
m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, Geom::Vec3f(0,0,1), bb.center());
}
// redraw GL callback (clear and swap already done)
......@@ -276,6 +313,12 @@ void MyQT::cb_redraw()
{
m_render_topo->overdrawDart(*it, 11, 0.0f, 0.0f, 1.0f);
}
if (clip_volume && !hide_clipping)
{
m_frame->draw();
m_PlanePick->draw();
}
}
void MyQT::cb_mousePress(int button, int x, int y)
......@@ -294,6 +337,29 @@ void MyQT::cb_mousePress(int button, int x, int y)
m_selected2 = d;
}
updateGL();
if (hide_clipping || !clip_volume)
return;
m_begX = x;
m_begY = y;
// get ray of selection
Geom::Vec3f rayA,rayB;
float dist = getOrthoScreenRay(x,y,rayA,rayB);
Geom::Vec3f AB = rayB-rayA;
unsigned int fr_picked =0;
// picking the frame -> axis
fr_picked = m_frame->pick(rayA,AB,dist);
if (fr_picked != 0)
{
m_pickedAxis=fr_picked;
m_frame->highlight(m_pickedAxis);
m_frame->storeProjection(m_pickedAxis);
updateGL();
}
}
if (Control())
......@@ -308,6 +374,74 @@ void MyQT::cb_mousePress(int button, int x, int y)
}
}
void MyQT::cb_mouseRelease(int button, int x, int y)
{
if (hide_clipping || !clip_volume)
return;
m_pickedAxis=0;
m_frame->highlight(m_pickedAxis);
updateGL();
}
void MyQT::cb_mouseMove(int buttons, int x, int y)
{
if (!Shift())
return;
if (hide_clipping || !clip_volume)
return;
// rotation selected ?
if (Utils::FrameManipulator::rotationAxis(m_pickedAxis))
{
if (buttons&1)
{
float angle = m_frame->angleFromMouse(x,y,x-m_begX, y-m_begY);
m_frame->rotate(m_pickedAxis, angle);
}
else if (buttons&2)
m_frame->rotateInScreen(x-m_begX, y-m_begY);
m_PlanePick->transfo() = m_frame->transfo();
}
// translation selected
else if (Utils::FrameManipulator::translationAxis(m_pickedAxis))
{
if (buttons&1)
{
float dist = m_frame->distanceFromMouse(x-m_begX, y-m_begY);
m_frame->translate(m_pickedAxis, dist);
}
else if (buttons&2)
m_frame->translateInScreen(x-m_begX, y-m_begY);
m_PlanePick->transfo() = m_frame->transfo();
}
// scale selected
else if (Utils::FrameManipulator::scaleAxis(m_pickedAxis) )
{
float scale = m_frame->scaleFromMouse(x-m_begX, y-m_begY);
m_frame->scale(m_pickedAxis, scale );
m_PlanePick->transfo() = m_frame->transfo();
}
Geom::Vec3f pos = m_PlanePick->getPosition();
float pipo;
Geom::Vec3f normal = m_PlanePick->getAxisScale(2, pipo); // 2 = Z axis = plane normal
m_render_topo->shader1()->setClipPlaneParamsAll(clip_id1, normal, pos);
m_render_topo->shader2()->setClipPlaneParamsAll(clip_id2, normal, pos);
m_begX = x;
m_begY = y;
updateGL();
return;
}
void MyQT::cb_keyPress(int keycode)
{
switch(keycode)
......@@ -521,10 +655,12 @@ void MyQT::importMesh(std::string& filename)
m_selected = NIL;
m_selected2 = NIL;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
setParamObject(bb.maxSize(), bb.center().data()) ;
m_shift = bb.maxSize()/200.0f;
m_frame->setSize(bb.maxSize());
updateMap();
updateGLMatrices() ;
}
......
......@@ -37,12 +37,13 @@
#endif
#include "Algo/Render/GL2/topo3Render.h"
#include "Algo/Geometry/boundingbox.h"
#include "ui_tuto_oper3.h"
#include "Utils/Qt/qtui.h"
#include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h"
#include "Utils/frameManipulator.h"
using namespace CGoGN ;
......@@ -69,11 +70,13 @@ class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MyQT():nb(myMap),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) {}
MyQT():nb(myMap),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) {}
void cb_redraw();
void cb_initGL();
void cb_mousePress(int button, int x, int y);
void cb_mouseRelease(int button, int x, int y);
void cb_mouseMove(int button, int x, int y);
void cb_keyPress(int code);
void cb_Open();
void cb_Save();
......@@ -88,6 +91,8 @@ protected:
SelectorDartNoBoundary<PFP::MAP> nb;
Geom::BoundingBox<PFP::VEC3> bb;
// render (for the topo)
Algo::Render::GL2::Topo3Render* m_render_topo;
Dart m_selected;
......@@ -98,6 +103,17 @@ protected:
float m_ex1, m_ex2, m_ex3;
// for clipping plane manipulation
bool clip_volume;
bool hide_clipping;
Utils::Pickable* m_PlanePick;
Utils::FrameManipulator* m_frame;
unsigned int m_pickedAxis;
int m_begX;
int m_begY;
int clip_id1;
int clip_id2;
// 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);}
......@@ -116,6 +132,9 @@ public slots:
void operation(int x);
void svg();
void width(int w);
void clipping_onoff(bool x);
void hide_onoff(bool x);
};
#endif
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>227</width>
<height>369</height>
<width>215</width>
<height>481</height>
</rect>
</property>
<property name="minimumSize">
......@@ -36,116 +36,129 @@
</size>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>2</number>
</property>
<property name="spacing">
<number>4</number>
</property>
<item row="1" column="0">
<widget class="QSlider" name="widthSlider">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="singleStep">
<number>0</number>
</property>
<property name="value">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>113</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="svg">
<property name="text">
<string>SnapshotSVG</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QCheckBox" name="checkBox_hide">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>hide clipping plane</string>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<widget class="QListWidget" name="listOper">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<item>
<property name="text">
<string>deleteVertex</string>
</property>
</item>
<item>
<property name="text">
<string>cutEdge</string>
</property>
</item>
<item>
<property name="text">
<string>uncutEdge</string>
</property>
</item>
<item>
<widget class="QListWidget" name="listOper">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<item>
<property name="text">
<string>deleteVertex</string>
</property>
</item>
<item>
<property name="text">
<string>cutEdge</string>
</property>
</item>
<item>
<property name="text">
<string>uncutEdge</string>
</property>
</item>
<item>
<property name="text">
<string>deleteEdge</string>
</property>
</item>
<item>
<property name="text">
<string>collapseEdge</string>
</property>
</item>
<item>
<property name="text">
<string>splitFace</string>
</property>
</item>
<item>
<property name="text">
<string>mergeVolume</string>
</property>
</item>
<item>
<property name="text">
<string>splitVolume</string>
</property>
</item>
<item>
<property name="text">
<string>collapseFace</string>
</property>
</item>
<item>
<property name="text">
<string>collapseVolume</string>
</property>
</item>
<item>
<property name="text">
<string>splitVertex</string>
</property>
</item>
</widget>
<property name="text">
<string>deleteEdge</string>
</property>
</item>
<item>
<widget class="QSlider" name="widthSlider">
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="singleStep">
<number>0</number>
</property>
<property name="value">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
<property name="text">
<string>collapseEdge</string>
</property>
</item>
<item>
<widget class="QPushButton" name="svg">
<property name="text">
<string>SnapshotSVG</string>
</property>
</widget>
<property name="text">
<string>splitFace</string>
</property>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
<property name="text">
<string>mergeVolume</string>
</property>
</item>
</layout>
<item>
<property name="text">
<string>splitVolume</string>
</property>
</item>
<item>
<property name="text">
<string>collapseFace</string>
</property>
</item>
<item>
<property name="text">
<string>collapseVolume</string>
</property>
</item>
<item>
<property name="text">
<string>splitVertex</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
<widget class="QCheckBox" name="checkBox_plane">
<property name="text">
<string>clipping</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
......
......@@ -129,15 +129,15 @@ int main(int argc, char **argv)
prim3.transform(trf);
// create a subdivided cube
Algo::Modelisation::Polyhedron<PFP> prim4(myMap, position);
prim4.cube_topo(4, 5, 6);
prim4.embedCube(50.0f,50.0f, 50.0f);
// Algo::Modelisation::Polyhedron<PFP> prim4(myMap, position);
// prim4.cube_topo(4, 5, 6);
// prim4.embedCube(50.0f,50.0f, 50.0f);