Commit c3f1a2f6 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'master' of ssh://cgogn/~cgogn/CGoGN

parents 50dba34d 4040a77e
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin)
SET (COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} gzstream AntTweakBar openctm assimp)
BOOST_LIBS(boost_regex_lib_lists "boost_regex-mt")
SET (COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} ${boost_regex_lib_lists} gzstream AntTweakBar openctm assimp)
SET(CGoGN_LIBS_R topology algo container utils)
......
......@@ -59,3 +59,9 @@ add_executable( viewerD ../viewer.cpp ${viewer_moc} ${viewer_ui})
target_link_libraries( viewerD
${CGoGN_LIBS_D} ${NUMERICAL_LIBS} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_UI( clipping_ui ../clipping.ui )
QT4_WRAP_CPP( clipping_moc ../clipping.h )
add_executable( clippingD ../clipping.cpp ${clipping_ui} ${clipping_moc})
target_link_libraries( clippingD
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
......@@ -63,3 +63,9 @@ add_executable( viewer ../viewer.cpp ${viewer_moc} ${viewer_ui})
target_link_libraries( viewer
${CGoGN_LIBS_R} ${NUMERICAL_LIBS} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_UI( clipping_ui ../clipping.ui )
QT4_WRAP_CPP( clipping_moc ../clipping.h )
add_executable( clipping ../clipping.cpp ${clipping_ui} ${clipping_moc})
target_link_libraries( clipping
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
This diff is collapsed.
......@@ -22,14 +22,15 @@
* *
*******************************************************************************/
#ifndef __STAGE_SHADER_H__
#define __STAGE_SHADER_H__
#ifndef __CLIPPING_H__
#define __CLIPPING_H__
#include <iostream>
#include "Utils/qtSimple.h"
#include "Utils/qtInputs.h"
#include "ui_stage_shader.h"
#include "ui_clipping.h"
// inclure qtui.h juste après le ui_xxx.h
#include "Utils/qtui.h"
......@@ -49,11 +50,16 @@
#include "Algo/Render/GL2/topo3Render.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/frameManipulator.h"
#include "Utils/clippingPresets.h"
#include "Utils/cgognStream.h"
#include "Utils/drawer.h"
#include <string>
#include <sstream>
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
......@@ -63,7 +69,7 @@ struct PFP: public PFP_STANDARD
};
class StageShader: public Utils::QT::SimpleQT
class Clipping: public Utils::QT::SimpleQT
{
Q_OBJECT
......@@ -80,12 +86,14 @@ public:
//Render
bool m_drawVertices;
bool m_drawLines;
bool m_drawFaces;
bool m_drawTopo;
bool m_drawFaces;
bool m_drawTopo;
Algo::Render::GL2::MapRender* m_render;
Algo::Render::GL2::Topo3RenderMapD* m_render_topo;
Geom::BoundingBox<PFP::VEC3> m_bb;
Utils::VBO* m_positionVBO;
Utils::ShaderSimpleColor* m_shader;
......@@ -94,13 +102,23 @@ public:
Utils::Drawer* chips_area;
Geom::Vec3f m_coeffTopoExplod;
Geom::Vec3f gPosObj ;
float gWidthObj ;
Geom::Vec3f gPosObj ;
float gWidthObj ;
//QT
Utils::QT::uiDockInterface dock;
//QT
Utils::QT::uiDockInterface dock;
// Picking
Utils::LineDrawable* m_planeDrawable;
Utils::LineDrawable* m_sphereDrawable;
Utils::FrameManipulator* m_frameManipulator;
unsigned int m_frameManipulatorPickedAxis;
std::vector<Utils::Pickable*> m_pickablePlanes;
std::vector<Utils::Pickable*> m_pickableSpheres;
Utils::Pickable* m_lastPickedObject;
int m_lastClickedX, m_lastClickedY;
StageShader();
Clipping();
void initGUI();
void cb_Open();
......@@ -108,6 +126,7 @@ public:
void cb_initGL();
void cb_redraw();
void cb_mousePress(int button, int x, int y);
void cb_mouseMove(int buttons, int x, int y);
void cb_keyPress(int code);
void importMesh(std::string& filename);
......@@ -121,7 +140,23 @@ public slots:
void slot_explodTopoPhi2(double c);
void slot_explodTopoPhi3(double c);
void dockWidget_topLevelChanged(bool isFloating);
void slot_pushButton_addPlane();
void slot_spinBox_GridResolution(int i);
void slot_pushButton_changePlanesColor();
void slot_pushButton_addSphere();
void slot_spinBox_SphereResolution(int i);
void slot_pushButton_changeSpheresColor();
void slot_doubleSpinBox_ColorAttenuationFactor(double c);
void slot_radioButton_ClippingMode(bool b);
void slot_radioButton_ColorAttenuationMode(bool b);
void slot_pushButton_deleteSelectedObject();
void slot_pushButton_applyClippingPreset();
void button_compile();
};
......
This diff is collapsed.
......@@ -47,7 +47,6 @@
#include "glm/gtc/type_precision.hpp"
#include "glm/gtc/type_ptr.hpp"
using namespace CGoGN;
struct PFP: public PFP_STANDARD
......
......@@ -66,13 +66,6 @@ target_link_libraries( tuto5
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_UI( stage_shader_ui stage_shader.ui )
QT4_WRAP_CPP(stage_shader_moc stage_shader.h)
add_executable( stage_shader stage_shader.cpp ${stage_shader_ui} ${stage_shader_moc})
target_link_libraries( stage_shader
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
#add_executable( tuto_subdivision tuto_subdivision.cpp)
#target_link_libraries( tuto_subdivision
# ${CGoGN_LIBS_D} ${COMMON_LIBS} )
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DockWidget</class>
<widget class="QDockWidget" name="DockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<height>473</height>
</rect>
</property>
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Interface</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="tabPosition">
<enum>QTabWidget::East</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Visualisation</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="checkBox_vertices">
<property name="text">
<string>Vertices</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_lines">
<property name="text">
<string>Lines</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_faces">
<property name="text">
<string>Faces</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_topo">
<property name="enabled">
<bool>true</bool>
</property>
<property name="title">
<string>Topo</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<layout class="QGridLayout" name="gridLayout_2">
<item row="3" column="2">
<widget class="QDoubleSpinBox" name="explod_phi2">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.900000000000000</double>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QDoubleSpinBox" name="explod_phi3">
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.900000000000000</double>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_faces">
<property name="text">
<string>Faces</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_volumes">
<property name="text">
<string>Volumes</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QDoubleSpinBox" name="explod_phi1">
<property name="prefix">
<string/>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="singleStep">
<double>0.100000000000000</double>
</property>
<property name="value">
<double>0.900000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_edges">
<property name="text">
<string>Edges</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_rotate">
<property name="title">
<string>Rotate</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Speed</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
</item>
</layout>
</item>
<item row="1" column="0">
<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>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>Shader</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Shader Editor</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="compileButton">
<property name="text">
<string>Recompile</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget_2">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Vertex</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_9">
<item row="0" column="0">
<widget class="QTextEdit" name="vertexEdit"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Fragment</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_10">
<item row="0" column="0">
<widget class="QTextEdit" name="fragmentEdit"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_5">
<attribute name="title">
<string>Geometry</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<widget class="QTextEdit" name="geometryEdit"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
......@@ -85,9 +85,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
++degree;
p += position[it] ;
if(!map.edgeIsSubdivided(it)) // first cut the edges (if they are not already)
{
Algo::IHM::subdivideEdge<PFP>(map, it, position) ; // and compute the degree of the face
}
it = map.phi1(it) ;
} while(it != old) ;
p /= typename PFP::REAL(degree) ;
......@@ -96,38 +94,38 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
Dart res;
// if(degree == 3 && sType == S_TRI) //subdiviser une face triangulaire
// {
// Dart dd = map.phi1(old) ;
// Dart e = map.phi1(map.phi1(dd)) ;
// map.splitFace(dd, e) ; // insert a new edge
// unsigned int id = map.getNewEdgeId() ;
// map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id
//
// unsigned int idface = map.getFaceId(old);
// map.setFaceId(dd, idface, FACE) ;
// map.setFaceId(e, idface, FACE) ;
//
// dd = e ;
// e = map.phi1(map.phi1(dd)) ;
// map.splitFace(dd, e) ;
// id = map.getNewEdgeId() ;
// map.setEdgeId(map.phi_1(dd), id, EDGE) ;
//
// map.setFaceId(dd, idface, FACE) ;
// map.setFaceId(e, idface, FACE) ;
//
// dd = e ;
// e = map.phi1(map.phi1(dd)) ;
// map.splitFace(dd, e) ;
// id = map.getNewEdgeId() ;
// map.setEdgeId(map.phi_1(dd), id, EDGE) ;
//
// map.setFaceId(dd, idface, FACE) ;
// map.setFaceId(e, idface, FACE) ;
// }
// else
// {
if(degree == 3 && sType == S_TRI) //subdiviser une face triangulaire
{
Dart dd = map.phi1(old) ;
Dart e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ; // insert a new edge
unsigned int id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id
unsigned int idface = map.getFaceId(old);
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
dd = e ;
e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ;
id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ;
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
dd = e ;
e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ;
id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ;
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
}
else
{
Dart dd = map.phi1(old) ;
map.splitFace(dd, map.phi1(map.phi1(dd))) ;
......@@ -164,7 +162,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
dd = map.phi2(map.phi1(dd));
}
while(dd != ne);
// }
}
map.setCurrentLevel(cur) ;
}
......@@ -182,8 +180,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.setCurrentLevel(vLevel);
std::cout << "vLevel = " << vLevel << std::endl;
/*
* au niveau du volume courant i
* stockage d'un brin de chaque face de celui-ci
......@@ -191,7 +187,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
*/
DartMarkerStore mf(map); // Lock a face marker to save one dart per face
//DartMarkerStore mv(map); // Lock a vertex marker to compute volume center
CellMarker mv(map, VERTEX);
typename PFP::VEC3 volCenter;
......@@ -217,7 +212,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
//compute volume centroid
if(!mv.isMarked(e))
{
//mv.markOrbit(VERTEX, e);
mv.mark(e);
volCenter += position[e];
++count;
......@@ -246,7 +240,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
std::vector<std::pair<Dart,Dart> > subdividedfaces;
subdividedfaces.reserve(25);
int i = 0;
//First step : subdivide edges and faces
//creates a i+1 edge level and i+1 face level
for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
......@@ -255,24 +248,12 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
//if needed subdivide face
if(!map.faceIsSubdivided(d))
{
++i;
Algo::IHM::subdivideFace<PFP>(map, d, position);
}
std::cout << "CHECK FACES " << std::endl;
map.check();
//save a dart from the subdivided face
unsigned int cur = map.getCurrentLevel() ;
map.setCurrentLevel(map.getMaxLevel());
Dart old = map.faceOldestDart(d);
std::cout << " Oldest dart Face = " << old << std::endl;
unsigned int fLevel = map.faceLevel(old); //puisque dans tous les cas, la face est subdivisee
std::cout << "FACE LEVEL = " << fLevel << std::endl;
unsigned int fLevel = map.faceLevel(d) + 1; //puisque dans tous les cas, la face est subdivisee
map.setCurrentLevel(fLevel) ;
......@@ -288,8 +269,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.setCurrentLevel(cur);
}
map.setCurrentLevel(vLevel + 1) ; // go to the next level to perform volume subdivision
std::vector<Dart> newEdges; //save darts from inner edges
......@@ -301,33 +280,21 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
Dart e = *edge;
Dart f1 = map.phi1(*edge);
int i = 0;
do
{
std::cout << "corner #" << i << " degree = " << map.faceDegree(e) << std::endl;
if(map.phi2(map.phi1(map.phi1(e))) != map.phi1(map.phi1(e)))
map.unsewFaces(map.phi1(map.phi1(e)));
map.unsewFaces(map.phi1(map.phi1(e)));
//TODO utile ?
if(map.phi2(map.phi1(e)) != map.phi1(e))
//if(map.phi2(map.phi1(e)) != map.phi1(e))
map.unsewFaces(map.phi1(e));
++i;
e = map.phi2(map.phi_1(e));
}
while(e != *edge);
map.closeHole(f1);
std::cout << "CHECK CLOSE HOLE " << std::endl;
map.check();
std::cout << "corner degree = " << i << std::endl;
std::cout << "face degree = " << map.faceDegree(map.phi2(f1)) << std::endl;
// if(map.faceDegree(map.phi2(f1)) > 6)
// return Dart::nil();
Dart old = map.phi2(map.phi1(e));
Dart dd = map.phi1(map.phi1(old)) ;
map.splitFace(old,dd) ;
......@@ -395,8 +362,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.setCurrentLevel(cur) ;
std::cout << std::endl;
return subdividedfaces.begin()->first;
}
......
......@@ -86,6 +86,12 @@ class BoundingBox
// fusion with the given bounding box
void fusion(const BoundingBox<VEC>& bb) ;
//return true if the vector belongs strictly to a bounding box
bool contains(const VEC& p);
//return true if the bounding box belongs strictly to a bounding box
bool contains(const BoundingBox<VEC> & bb);
/**********************************************/
/* STREAM OPERATORS */
/**********************************************/
......
......@@ -178,6 +178,30 @@ void BoundingBox<VEC>::fusion(const BoundingBox<VEC>& bb)
}
}
template <typename VEC>
bool BoundingBox<VEC>::contains(const VEC& p)
{
for(unsigned int i = 0; i < m_pMin.dimension(); ++i)
{
if(m_pMin[i] > p[i])
return false ;
if(p[i] > m_pMax[i])
return false ;
}
return true;
}
template <typename VEC>
bool BoundingBox<VEC>::contains(const BoundingBox<VEC>& bb)
{
return this->contains(bb.min()) && this->contains(bb.max());
}
//template <typename VEC>
//friend std::ostream& BoundingBox<VEC>::operator<<(std::ostream& out, const BoundingBox<VEC>& bb)
//{
......
......@@ -286,6 +286,9 @@ public:
*/
virtual void restoreUniformsAttribs() {CGoGNerr << "Warning restoreUniformsAttribs not implemented"<< CGoGNendl;}
virtual void updateClippingUniforms() {CGoGNerr << "Warning updateClippingUniforms not implemented"<< CGoGNendl;}
/**
*
*/
......
......@@ -26,6 +26,7 @@
#define __CGOGN_SHADER_CPV__
#include "Utils/GLSLShader.h"
#include "Utils/clippingShader.h"
#include "Geometry/vector_gen.h"
namespace CGoGN
......@@ -34,7 +35,7 @@ namespace CGoGN
namespace Utils
{
class ShaderColorPerVertex : public GLSLShader
class ShaderColorPerVertex : public ClippingShader
{
protected:
// shader sources
......
......@@ -17,8 +17,16 @@ void main()
float lambertTerm = dot(N,L);
vec4 finalColor = materialAmbient;
if(lambertTerm > 0.0)