Commit a517c887 authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

update modelisation plugin & voxellisation file

parent 038b8c37
......@@ -42,4 +42,7 @@ TARGET_LINK_LIBRARIES( SCHNAppsD
ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/Plugins PluginsD)
ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/../../SCHNAppsPlugins ExtPluginsD)
IF(IS_DIRECTORY ${SCHNApps_ROOT_DIR}/../../Plugins)
ADD_SUBDIRECTORY(${SCHNApps_ROOT_DIR}/../../Plugins ExtPluginsD)
ENDIF(IS_DIRECTORY ${SCHNApps_ROOT_DIR}/../../Plugins)
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>345</width>
<width>385</width>
<height>600</height>
</rect>
</property>
......@@ -21,33 +21,158 @@
</property>
</widget>
</item>
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="8" column="0" colspan="3">
<widget class="QComboBox" name="combo_edgeOperation">
<item>
<property name="text">
<string>- select attribute -</string>
<string>- select operation -</string>
</property>
</item>
<item>
<property name="text">
<string>Cut edge</string>
</property>
</item>
<item>
<property name="text">
<string>Uncut edge</string>
</property>
</item>
<item>
<property name="text">
<string>Collapse edge</string>
</property>
</item>
<item>
<property name="text">
<string>Flip edge</string>
</property>
</item>
<item>
<property name="text">
<string>Flip back edge</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0" colspan="3">
<widget class="QComboBox" name="combo_generalOperation">
<item>
<property name="text">
<string>- select operation -</string>
</property>
</item>
<item>
<property name="text">
<string>Create empty map</string>
</property>
</item>
<item>
<property name="text">
<string>Create new face</string>
</property>
</item>
<item>
<property name="text">
<string>Add cube</string>
</property>
</item>
<item>
<property name="text">
<string>Fill hole</string>
</property>
</item>
<item>
<property name="text">
<string>Delete connected component</string>
</property>
</item>
<item>
<property name="text">
<string>Revolution</string>
</property>
</item>
<item>
<property name="text">
<string>Merge volumes</string>
</property>
</item>
<item>
<property name="text">
<string>Split surface</string>
</property>
</item>
<item>
<property name="text">
<string>Extrude region</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0" colspan="2">
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Operations :</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Vertex selector :</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QComboBox" name="combo_vertexSelector">
<item row="7" column="3">
<widget class="QPushButton" name="button_applyVertexOperation">
<property name="text">
<string>Apply vertex operation</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="4">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="12" column="3">
<widget class="QPushButton" name="button_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="8" column="3">
<widget class="QPushButton" name="button_applyEdgeOperation">
<property name="text">
<string>Apply edge operation</string>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QPushButton" name="button_start">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QComboBox" name="combo_vertexOperation">
<item>
<property name="text">
<string>- select selector -</string>
<string>- select operation -</string>
</property>
</item>
<item>
<property name="text">
<string>Split vertex</string>
</property>
</item>
<item>
<property name="text">
<string>Delete vertex</string>
</property>
</item>
</widget>
......@@ -59,8 +184,8 @@
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="combo_edgeSelector">
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="combo_vertexSelector">
<item>
<property name="text">
<string>- select selector -</string>
......@@ -68,15 +193,8 @@
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Face selector :</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QComboBox" name="combo_faceSelector">
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="combo_edgeSelector">
<item>
<property name="text">
<string>- select selector -</string>
......@@ -84,6 +202,26 @@
</item>
</widget>
</item>
<item row="13" column="1">
<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>
<item row="11" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Clicks :</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
......@@ -91,39 +229,101 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="4">
<widget class="QPushButton" name="button_createEmptyMap">
<item row="9" column="3">
<widget class="QPushButton" name="button_applyFaceOperation">
<property name="text">
<string>Create empty map</string>
<string>Apply face operation</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="4">
<widget class="QPushButton" name="button_addCube">
<item row="12" column="1" colspan="2">
<widget class="QPushButton" name="button_accept">
<property name="text">
<string>Add cube</string>
<string>Accept</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="4">
<widget class="QPushButton" name="button_flipEdge">
<item row="6" column="3">
<widget class="QPushButton" name="button_applyGeneralOperation">
<property name="text">
<string>Flip edge</string>
<string>Apply general operation</string>
</property>
</widget>
</item>
<item row="8" column="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="0" column="1" colspan="3">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
<item>
<property name="text">
<string>- select attribute -</string>
</property>
</item>
</widget>
</item>
<item row="9" column="0" colspan="3">
<widget class="QComboBox" name="combo_faceOperation">
<item>
<property name="text">
<string>- select operation -</string>
</property>
</item>
<item>
<property name="text">
<string>Split face</string>
</property>
</item>
<item>
<property name="text">
<string>Merge faces</string>
</property>
</item>
<item>
<property name="text">
<string>Delete face</string>
</property>
</item>
<item>
<property name="text">
<string>Sew faces</string>
</property>
</item>
<item>
<property name="text">
<string>Unsew faces</string>
</property>
</item>
<item>
<property name="text">
<string>Extrude face</string>
</property>
</item>
<item>
<property name="text">
<string>Extrude face following a path</string>
</property>
</item>
</widget>
</item>
<item row="3" column="1" colspan="3">
<widget class="QComboBox" name="combo_faceSelector">
<item>
<property name="text">
<string>- select selector -</string>
</property>
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Face selector :</string>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>
......
......@@ -5,6 +5,11 @@
#include "surface_modelisation_dockTab.h"
#include "mapHandler.h"
#include "Utils/drawer.h"
#include "Topology/map/map2.h"
#include <QVector>
#include "QGLViewer/camera.h"
#include "QGLViewer/vec.h"
namespace CGoGN
{
......@@ -43,12 +48,12 @@ public:
virtual bool enable();
virtual void disable();
virtual void draw(View *view) {}
virtual void drawMap(View* view, MapHandlerGen* map) {}
virtual void draw(View *view);
virtual void drawMap(View* view, MapHandlerGen* map);
virtual void keyPress(View* view, QKeyEvent* event) {}
virtual void keyRelease(View* view, QKeyEvent* event) {}
virtual void mousePress(View* view, QMouseEvent* event) {}
virtual void mousePress(View* view, QMouseEvent* event);
virtual void mouseRelease(View* view, QMouseEvent* event) {}
virtual void mouseMove(View* view, QMouseEvent* event) {}
virtual void wheelEvent(View* view, QWheelEvent* event) {}
......@@ -76,12 +81,40 @@ public slots:
protected:
void createEmptyMap();
void addCube(MapHandlerGen* mhg);
void createNewFace(MapHandlerGen* mhg);
void addCube(MapHandlerGen* mhg);
void fillHole(MapHandlerGen* mhg);
void deleteCC(MapHandlerGen* mhg);
void revolution(MapHandlerGen* mhg);
void mergeVolumes(MapHandlerGen* mhg);
void splitSurface(MapHandlerGen* mhg);
void extrudeRegion(MapHandlerGen* mhg);
void splitVertex(MapHandlerGen* mhg);
void deleteVertex(MapHandlerGen* mhg);
void cutEdge(MapHandlerGen* mhg);
void uncutEdge(MapHandlerGen* mhg);
void flipEdge(MapHandlerGen* mhg);
void flipBackEdge(MapHandlerGen* mhg);
void collapseEdge(MapHandlerGen* mhg);
void splitFace(MapHandlerGen* mhg);
void mergeFaces(MapHandlerGen* mhg);
void deleteFace(MapHandlerGen* mhg);
void sewFaces(MapHandlerGen* mhg);
void unsewFaces(MapHandlerGen* mhg);
void extrudeFace(MapHandlerGen* mhg);
void pathExtrudeFace(MapHandlerGen *mhg);
protected:
Surface_Modelisation_DockTab* m_dockTab;
QHash<MapHandlerGen*, MapParameters> h_parameterSet;
Utils::Drawer* m_drawer;
bool collect;
std::vector<PFP2::VEC3> collectedVertices;
};
} // namespace SCHNApps
......
......@@ -2,6 +2,11 @@
#define _SURFACE_MODELISATION_DOCK_TAB_H_
#include "ui_surface_modelisation.h"
#include "QString"
//#include "mapHandler.h"
//#include "Utils/drawer.h"
//#include "Topology/map/map2.h"
namespace CGoGN
{
......@@ -27,15 +32,27 @@ private:
Surface_Modelisation_Plugin* m_plugin;
bool b_updatingUI;
QStringList generalOperations;
QStringList vertexOperations;
QStringList edgeOperations;
QStringList faceOperations;
private slots:
void positionAttributeChanged(int index);
void vertexSelectorChanged(int index);
void edgeSelectorChanged(int index);
void faceSelectorChanged(int index);
void createEmptyMapButtonClicked();
void addCubeButtonClicked();
void flipEdgeButtonClicked();
//void operationChanged(const QString &text);
void applyGeneralOperationButtonClicked();
void applyVertexOperationButtonClicked();
void applyEdgeOperationButtonClicked();
void applyFaceOperationButtonClicked();
void startButtonClicked();
void acceptButtonClicked();
void cancelButtonClicked();
private:
void addVertexAttribute(const QString& name);
......
......@@ -5,6 +5,11 @@
#include "mapHandler.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Modelisation/extrusion.h"
#include <QMessageBox>
#include <QMouseEvent>
#include <iostream>
#include "Topology/generic/cellmarker.h"
namespace CGoGN
{
......@@ -13,7 +18,9 @@ namespace SCHNApps
{
Surface_Modelisation_Plugin::Surface_Modelisation_Plugin()
{}
{
collect = false;
}
bool Surface_Modelisation_Plugin::enable()
{
......@@ -29,17 +36,53 @@ bool Surface_Modelisation_Plugin::enable()
m_dockTab->updateMapParameters();
m_drawer = new Utils::Drawer();
registerShader(m_drawer->getShader());
return true;
}
void Surface_Modelisation_Plugin::disable()
{
disconnect(m_schnapps, SIGNAL(selectedMapChanged(MapHandlerGen*, MapHandlerGen*)), this, SLOT(selectedMapChanged(MapHandlerGen*, MapHandlerGen*)));
disconnect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(mapAdded(MapHandlerGen*)));
disconnect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(mapRemoved(MapHandlerGen*)));
delete m_drawer;
}
void Surface_Modelisation_Plugin::draw(View *view)
{
if(collect)
{
m_drawer->newList(GL_COMPILE_AND_EXECUTE);
m_drawer->pointSize(3.0f);
m_drawer->color3f(1.0f, 1.0f, 1.0f);
m_drawer->begin(GL_POINTS);
for (unsigned int i = 0; i < collectedVertices.size(); i++)
m_drawer->vertex(collectedVertices[i]);
m_drawer->end();
m_drawer->endList();
}
}
void Surface_Modelisation_Plugin::drawMap(View* view, MapHandlerGen* map)
{
}
void Surface_Modelisation_Plugin::mousePress(View* view, QMouseEvent* event)
{
if(collect)
{
qglviewer::Vec point(event->x(), event->y(), 0.5);
qglviewer::Vec vertex = view->camera()->unprojectedCoordinatesOf(point);
PFP2::VEC3 position(vertex.x, vertex.y, vertex.z);
collectedVertices.push_back(position);
view->updateGL();
}
}
void Surface_Modelisation_Plugin::selectedMapChanged(MapHandlerGen *prev, MapHandlerGen *cur)
{
......@@ -56,12 +99,10 @@ void Surface_Modelisation_Plugin::mapAdded(MapHandlerGen* map)
void Surface_Modelisation_Plugin::mapRemoved(MapHandlerGen* map)
{
disconnect(map, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(attributeAdded(unsigned int, const QString&)));
disconnect(map, SIGNAL(cellSelectorAdded(unsigned int, const QString&)), this, SLOT(cellSelectorAdded(unsigned int, const QString&)));
disconnect(map, SIGNAL(cellSelectorRemoved(unsigned int, const QString&)), this, SLOT(cellSelectorRemoved(unsigned int, const QString&)));
}
void Surface_Modelisation_Plugin::attributeAdded(unsigned int orbit, const QString& name)
{
MapHandlerGen* map = static_cast<MapHandlerGen*>(QObject::sender());
......@@ -111,10 +152,6 @@ void Surface_Modelisation_Plugin::cellSelectorRemoved(unsigned int orbit, const
}
}
void Surface_Modelisation_Plugin::changePositionAttribute(const QString& view, const QString& map, const QString& name)
{
MapHandlerGen* m = m_schnapps->getMap(map);
......@@ -162,9 +199,11 @@ void Surface_Modelisation_Plugin::changeFaceSelector(const QString& map, const Q
}
}
/*-------------------------------------------------------------------------------------*/
/* --------------------------------- OPERATIONS ---------------------------------------*/
/*-------------------------------------------------------------------------------------*/
/* --------------------------- general operations -------------------------------*/
void Surface_Modelisation_Plugin::createEmptyMap()
{
......@@ -181,20 +220,265 @@ void Surface_Modelisation_Plugin::createEmptyMap()
}
}
void Surface_Modelisation_Plugin::createNewFace(MapHandlerGen* mhg)