Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

Commit d0e590fe authored by Thomas's avatar Thomas
Browse files

correcting comments and sliceConvexVolumes

parents b6a9b24e 04072a3b
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
#include <iostream> #include <iostream>
#include "Utils/Qt/qtSimple.h" #include "Utils/Qt/qtSimple.h"
#include "Utils/Qt/qtInputs.h" #include "Utils/qtInputs.h"
#include "ui_clipping.h" #include "ui_clipping.h"
// inclure qtui.h juste après le ui_xxx.h // inclure qtui.h juste après le ui_xxx.h
#include "Utils/Qt/qtui.h" #include "Utils/qtui.h"
#include "Topology/generic/parameters.h" #include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap3.h" #include "Topology/map/embeddedMap3.h"
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* * * *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ * * Web site: http://cgogn.unistra.fr *
* Contact information: cgogn@unistra.fr * * Contact information: cgogn@unistra.fr *
* * * *
*******************************************************************************/ *******************************************************************************/
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "Utils/Qt/qtSimple.h" #include "Utils/Qt/qtSimple.h"
#include "ui_mcmesh.h" #include "ui_mcmesh.h"
#include "Utils/Qt/qtui.h" #include "Utils/qtui.h"
#include "Topology/generic/parameters.h" #include "Topology/generic/parameters.h"
#include "Topology/map/map2.h" #include "Topology/map/map2.h"
......
...@@ -30,6 +30,7 @@ Viewer::Viewer() : ...@@ -30,6 +30,7 @@ Viewer::Viewer() :
m_drawEdges(false), m_drawEdges(false),
m_drawFaces(true), m_drawFaces(true),
m_drawNormals(false), m_drawNormals(false),
m_drawTopo(false),
m_render(NULL), m_render(NULL),
m_phongShader(NULL), m_phongShader(NULL),
m_flatShader(NULL), m_flatShader(NULL),
...@@ -68,6 +69,7 @@ void Viewer::initGUI() ...@@ -68,6 +69,7 @@ void Viewer::initGUI()
setCallBack( dock.check_drawEdges, SIGNAL(toggled(bool)), SLOT(slot_drawEdges(bool)) ) ; setCallBack( dock.check_drawEdges, SIGNAL(toggled(bool)), SLOT(slot_drawEdges(bool)) ) ;
setCallBack( dock.check_drawFaces, SIGNAL(toggled(bool)), SLOT(slot_drawFaces(bool)) ) ; setCallBack( dock.check_drawFaces, SIGNAL(toggled(bool)), SLOT(slot_drawFaces(bool)) ) ;
setCallBack( dock.combo_faceLighting, SIGNAL(currentIndexChanged(int)), SLOT(slot_faceLighting(int)) ) ; setCallBack( dock.combo_faceLighting, SIGNAL(currentIndexChanged(int)), SLOT(slot_faceLighting(int)) ) ;
setCallBack( dock.check_drawTopo, SIGNAL(toggled(bool)), SLOT(slot_drawTopo(bool)) ) ;
setCallBack( dock.check_drawNormals, SIGNAL(toggled(bool)), SLOT(slot_drawNormals(bool)) ) ; setCallBack( dock.check_drawNormals, SIGNAL(toggled(bool)), SLOT(slot_drawNormals(bool)) ) ;
setCallBack( dock.slider_normalsSize, SIGNAL(valueChanged(int)), SLOT(slot_normalsSize(int)) ) ; setCallBack( dock.slider_normalsSize, SIGNAL(valueChanged(int)), SLOT(slot_normalsSize(int)) ) ;
} }
...@@ -79,6 +81,9 @@ void Viewer::cb_initGL() ...@@ -79,6 +81,9 @@ void Viewer::cb_initGL()
setFocal(5.0f) ; setFocal(5.0f) ;
m_render = new Algo::Render::GL2::MapRender() ; m_render = new Algo::Render::GL2::MapRender() ;
m_topoRender = new Algo::Render::GL2::TopoRender() ;
m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ;
m_positionVBO = new Utils::VBO() ; m_positionVBO = new Utils::VBO() ;
m_normalVBO = new Utils::VBO() ; m_normalVBO = new Utils::VBO() ;
...@@ -119,7 +124,6 @@ void Viewer::cb_initGL() ...@@ -119,7 +124,6 @@ void Viewer::cb_initGL()
void Viewer::cb_redraw() void Viewer::cb_redraw()
{ {
//glClearColor(1,1,1,0);
if(m_drawVertices) if(m_drawVertices)
{ {
float size = vertexScaleFactor ; float size = vertexScaleFactor ;
...@@ -135,14 +139,6 @@ void Viewer::cb_redraw() ...@@ -135,14 +139,6 @@ void Viewer::cb_redraw()
m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ; m_render->draw(m_simpleColorShader, Algo::Render::GL2::LINES) ;
} }
if(m_drawNormals)
{
float size = normalBaseSize * normalScaleFactor ;
m_vectorShader->setScale(size) ;
glLineWidth(1.0f) ;
m_render->draw(m_vectorShader, Algo::Render::GL2::POINTS) ;
}
if(m_drawFaces) if(m_drawFaces)
{ {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ; glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) ;
...@@ -161,6 +157,19 @@ void Viewer::cb_redraw() ...@@ -161,6 +157,19 @@ void Viewer::cb_redraw()
} }
glDisable(GL_POLYGON_OFFSET_FILL) ; glDisable(GL_POLYGON_OFFSET_FILL) ;
} }
if(m_drawTopo)
{
m_topoRender->drawTopo() ;
}
if(m_drawNormals)
{
float size = normalBaseSize * normalScaleFactor ;
m_vectorShader->setScale(size) ;
glLineWidth(1.0f) ;
m_render->draw(m_vectorShader, Algo::Render::GL2::POINTS) ;
}
} }
void Viewer::cb_Open() void Viewer::cb_Open()
...@@ -209,6 +218,8 @@ void Viewer::importMesh(std::string& filename) ...@@ -209,6 +218,8 @@ void Viewer::importMesh(std::string& filename)
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ; m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ; m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ; bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ; normalBaseSize = bb.diagSize() / 100.0f ;
// vertexBaseSize = normalBaseSize / 5.0f ; // vertexBaseSize = normalBaseSize / 5.0f ;
...@@ -234,7 +245,11 @@ void Viewer::exportMesh(std::string& filename) ...@@ -234,7 +245,11 @@ void Viewer::exportMesh(std::string& filename)
if (extension == std::string(".off")) if (extension == std::string(".off"))
Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ; Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ;
else if (extension.compare(0, 4, std::string(".ply")) == 0) else if (extension.compare(0, 4, std::string(".ply")) == 0)
Algo::Export::exportPLY<PFP>(myMap, position, filename.c_str(), allDarts) ; {
std::vector<PFP::TVEC3*> attributes ;
attributes.push_back(&position) ;
Algo::Export::exportPLYnew<PFP>(myMap, attributes, filename.c_str(), true, allDarts) ;
}
else if (extension == std::string(".map")) else if (extension == std::string(".map"))
myMap.saveMapBin(filename) ; myMap.saveMapBin(filename) ;
else else
...@@ -271,6 +286,12 @@ void Viewer::slot_faceLighting(int i) ...@@ -271,6 +286,12 @@ void Viewer::slot_faceLighting(int i)
updateGL() ; updateGL() ;
} }
void Viewer::slot_drawTopo(bool b)
{
m_drawTopo = b ;
updateGL() ;
}
void Viewer::slot_drawNormals(bool b) void Viewer::slot_drawNormals(bool b)
{ {
m_drawNormals = b ; m_drawNormals = b ;
...@@ -280,6 +301,7 @@ void Viewer::slot_drawNormals(bool b) ...@@ -280,6 +301,7 @@ void Viewer::slot_drawNormals(bool b)
void Viewer::slot_normalsSize(int i) void Viewer::slot_normalsSize(int i)
{ {
normalScaleFactor = i / 50.0f ; normalScaleFactor = i / 50.0f ;
m_topoRender->updateData<PFP>(myMap, position, i / 100.0f, i / 100.0f) ;
updateGL() ; updateGL() ;
} }
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* along with this library; if not, write to the Free Software Foundation, * * along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* * * *
* Web site: http://cgogn.unistra.fr/ * * Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr * * Contact information: cgogn@unistra.fr *
* * * *
*******************************************************************************/ *******************************************************************************/
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "Utils/Qt/qtSimple.h" #include "Utils/Qt/qtSimple.h"
#include "ui_viewer.h" #include "ui_viewer.h"
#include "Utils/Qt/qtui.h" #include "Utils/qtui.h"
#include "Topology/generic/parameters.h" #include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h" #include "Topology/map/embeddedMap2.h"
...@@ -90,11 +90,13 @@ public: ...@@ -90,11 +90,13 @@ public:
bool m_drawEdges ; bool m_drawEdges ;
bool m_drawFaces ; bool m_drawFaces ;
bool m_drawNormals ; bool m_drawNormals ;
bool m_drawTopo ;
PFP::TVEC3 position ; PFP::TVEC3 position ;
PFP::TVEC3 normal ; PFP::TVEC3 normal ;
Algo::Render::GL2::MapRender* m_render ; Algo::Render::GL2::MapRender* m_render ;
Algo::Render::GL2::TopoRender* m_topoRender ;
Utils::VBO* m_positionVBO ; Utils::VBO* m_positionVBO ;
Utils::VBO* m_normalVBO ; Utils::VBO* m_normalVBO ;
...@@ -123,6 +125,7 @@ public slots: ...@@ -123,6 +125,7 @@ public slots:
void slot_drawEdges(bool b) ; void slot_drawEdges(bool b) ;
void slot_drawFaces(bool b) ; void slot_drawFaces(bool b) ;
void slot_faceLighting(int i) ; void slot_faceLighting(int i) ;
void slot_drawTopo(bool b) ;
void slot_drawNormals(bool b) ; void slot_drawNormals(bool b) ;
void slot_normalsSize(int i) ; void slot_normalsSize(int i) ;
}; };
...@@ -73,6 +73,13 @@ ...@@ -73,6 +73,13 @@
</item> </item>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="check_drawTopo">
<property name="text">
<string>draw topo</string>
</property>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="check_drawNormals"> <widget class="QCheckBox" name="check_drawNormals">
<property name="text"> <property name="text">
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#include "Utils/frameManipulator.h" #include "Utils/frameManipulator.h"
#include "ui_volumeExplorer.h" #include "ui_volumeExplorer.h"
#include "Utils/Qt/qtui.h" #include "Utils/qtui.h"
using namespace CGoGN ; using namespace CGoGN ;
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
#include "ui_show_traversors.h" #include "ui_show_traversors.h"
// inclure qtui.h juste après le ui_xxx.h // inclure qtui.h juste après le ui_xxx.h
#include "Utils/Qt/qtui.h" #include "Utils/qtui.h"
using namespace CGoGN ; using namespace CGoGN ;
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
#include "ui_tuto5.h" #include "ui_tuto5.h"
// inclure qtui.h juste après le ui_xxx.h // inclure qtui.h juste après le ui_xxx.h
#include "Utils/Qt/qtui.h" #include "Utils/qtui.h"
using namespace CGoGN ; using namespace CGoGN ;
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include "Algo/Parallel/parallel_foreach.h" #include "Algo/Parallel/parallel_foreach.h"
// for file input // for file input
#include "Utils/Qt/qtInputs.h" #include "Utils/qtInputs.h"
using namespace CGoGN ; using namespace CGoGN ;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include "ui_tuto_oper2.h" #include "ui_tuto_oper2.h"
#include "Utils/Qt/qtui.h" #include "Utils/qtui.h"
#include "Utils/Qt/qtSimple.h" #include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h" #include "Utils/cgognStream.h"
......
...@@ -92,7 +92,6 @@ void MyQT::operation(int x) ...@@ -92,7 +92,6 @@ void MyQT::operation(int x)
if (m_selected != NIL) if (m_selected != NIL)
{ {
dm.markAll(); dm.markAll();
PFP::VEC3 Q = position[myMap.phi1(m_selected)];
myMap.uncutEdge(m_selected); myMap.uncutEdge(m_selected);
updateMap(); updateMap();
} }
...@@ -104,7 +103,6 @@ void MyQT::operation(int x) ...@@ -104,7 +103,6 @@ void MyQT::operation(int x)
if (myMap.deleteEdgePreCond(m_selected)) if (myMap.deleteEdgePreCond(m_selected))
{ {
dm.markAll(); dm.markAll();
PFP::VEC3 Q = position[myMap.phi1(m_selected)];
myMap.deleteEdge(m_selected); myMap.deleteEdge(m_selected);
m_selected = NIL; m_selected = NIL;
updateMap(); updateMap();
...@@ -155,7 +153,30 @@ void MyQT::operation(int x) ...@@ -155,7 +153,30 @@ void MyQT::operation(int x)
updateMap(); updateMap();
} }
break; break;
case 8:
CGoGNout <<"collapse face"<<CGoGNendl;
if (m_selected != NIL)
{
PFP::VEC3 Q = Algo::Geometry::faceCentroid<PFP>(myMap,m_selected,position);
Dart x = myMap.collapseFace(m_selected);
dm.markAll();
position[x]= Q;
m_selected = NIL;
updateMap();
}
break;
case 9:
CGoGNout <<"collapse volume"<<CGoGNendl;
if (m_selected != NIL)
{
PFP::VEC3 Q = Algo::Geometry::volumeCentroid<PFP>(myMap,m_selected,position);
Dart x = myMap.collapseVolume(m_selected);
dm.markAll();
position[x]= Q;
m_selected = NIL;
updateMap();
}
break;
default: default:
break; break;
} }
...@@ -284,8 +305,9 @@ void MyQT::cb_keyPress(int keycode) ...@@ -284,8 +305,9 @@ void MyQT::cb_keyPress(int keycode)
updateMap(); updateMap();
updateGL(); updateGL();
break; break;
case 'c':
myMap.check();
break;
case 'a': case 'a':
m_selected = myMap.phi1(m_selected); m_selected = myMap.phi1(m_selected);
updateGL(); updateGL();
...@@ -409,7 +431,7 @@ void MyQT::svg() ...@@ -409,7 +431,7 @@ void MyQT::svg()
void MyQT::cb_Open() void MyQT::cb_Open()
{ {
std::string filters("all (*.*);; trian (*.trian);; off (*.off);; ply (*.ply);; map (*.map)") ; std::string filters("all (*.*);; map (*.map)") ;
std::string filename = selectFile("Open Mesh", "", filters) ; std::string filename = selectFile("Open Mesh", "", filters) ;
if (!filename.empty()) if (!filename.empty())
importMesh(filename); importMesh(filename);
...@@ -434,16 +456,40 @@ void MyQT::importMesh(std::string& filename) ...@@ -434,16 +456,40 @@ void MyQT::importMesh(std::string& filename)
myMap.loadMapBin(filename); myMap.loadMapBin(filename);
position = myMap.getAttribute<PFP::VEC3>(VERTEX, "position") ; position = myMap.getAttribute<PFP::VEC3>(VERTEX, "position") ;
} }
else else if (extension == std::string(".node"))
{
std::vector<std::string> attrNames ;
if(!Algo::Import::importMeshV<PFP>(myMap, filename, attrNames, Algo::Import::ImportVolumique::NODE))
{
std::cerr << "could not import " << filename << std::endl ;
return ;
}
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
}
else if(extension == std::string(".tet"))
{ {
std::vector<std::string> attrNames ; std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames)) if(!Algo::Import::importMeshV<PFP>(myMap, filename, attrNames, Algo::Import::ImportVolumique::TET))
{ {
CGoGNerr << "could not import " << filename << CGoGNendl ; std::cerr << "could not import " << filename << std::endl ;
return; return ;
} }
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ; position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
} }
else if(extension == std::string(".off"))
{
std::vector<std::string> attrNames ;
if(!Algo::Import::importMeshV<PFP>(myMap, filename, attrNames, Algo::Import::ImportVolumique::OFF))
{
std::cerr << "could not import " << filename << std::endl ;
return ;
}
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
}
else
{
std::cerr << "could not import " << filename << std::endl ;
}
m_selected = NIL; m_selected = NIL;
m_selected2 = NIL; m_selected2 = NIL;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
#include "ui_tuto_oper3.h" #include "ui_tuto_oper3.h"
#include "Utils/Qt/qtui.h" #include "Utils/qtui.h"
#include "Utils/Qt/qtSimple.h" #include "Utils/Qt/qtSimple.h"
#include "Utils/cgognStream.h" #include "Utils/cgognStream.h"
......
...@@ -89,6 +89,16 @@ ...@@ -89,6 +89,16 @@
<string>splitVolume</string> <string>splitVolume</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>collapseFace</string>
</property>
</item>
<item>
<property name="text">
<string>collapseVolume</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item> <item>
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
#include "ui_tuto_orbits.h" #include "ui_tuto_orbits.h"
// inclure qtui.h juste après le ui_xxx.h // inclure qtui.h juste après le ui_xxx.h
#include "Utils/Qt/qtui.h" #include "Utils/qtui.h"
using namespace CGoGN ; using namespace CGoGN ;
......
...@@ -207,7 +207,7 @@ void Approximator_MidEdge<PFP>::approximate(Dart d) ...@@ -207,7 +207,7 @@ void Approximator_MidEdge<PFP>::approximate(Dart d)
Dart d2 = m.phi2(m.phi_1(d)) ; Dart d2 = m.phi2(m.phi_1(d)) ;
Dart dd2 = m.phi2(m.phi_1(dd)) ; Dart dd2 = m.phi2(m.phi_1(dd)) ;
VEC3 v2 = this->m_attrV[dd] ; // VEC3 v2 = this->m_attrV[dd] ;
// temporary edge collapse // temporary edge collapse
m.extractTrianglePair(d) ; m.extractTrianglePair(d) ;
...@@ -297,9 +297,9 @@ void Approximator_CornerCutting<PFP>::approximate(Dart d) ...@@ -297,9 +297,9 @@ void Approximator_CornerCutting<PFP>::approximate(Dart d)
// get some darts // get some darts
Dart dd = m.phi2(d) ; Dart dd = m.phi2(d) ;
Dart d1 = m.phi2(m.phi1(d)) ; // Dart d1 = m.phi2(m.phi1(d)) ;
Dart d2 = m.phi2(m.phi_1(d)) ; Dart d2 = m.phi2(m.phi_1(d)) ;
Dart dd1 = m.phi2(m.phi1(dd)) ; // Dart dd1 = m.phi2(m.phi1(dd)) ;
Dart dd2 = m.phi2(m.phi_1(dd)) ; Dart dd2 = m.phi2(m.phi_1(dd)) ;
// get the contracted edge vertices positions // get the contracted edge vertices positions
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#define __EXPORT_H__ #define __EXPORT_H__
#include "Topology/generic/attributeHandler.h" #include "Topology/generic/attributeHandler.h"
#include <stdint.h>
namespace CGoGN namespace CGoGN
{ {
...@@ -39,11 +40,24 @@ namespace Export ...@@ -39,11 +40,24 @@ namespace Export
/** /**
* export the map into a PLY file * export the map into a PLY file
* @param the_map map to be exported * @param the_map map to be exported
* @param position the position container
* @param filename filename of ply file * @param filename filename of ply file
* @param binary write in binary mode
* @return true * @return true
*/ */