Commit ab764478 authored by Pierre Kraemer's avatar Pierre Kraemer

new plugin : surface subdivision

parent 353f07b8
......@@ -4,3 +4,4 @@ ADD_SUBDIRECTORY(surface_import)
ADD_SUBDIRECTORY(surface_render)
ADD_SUBDIRECTORY(surface_renderVector)
ADD_SUBDIRECTORY(surface_differentialProperties)
ADD_SUBDIRECTORY(surface_subdivision)
......@@ -25,8 +25,8 @@ private:
public slots:
void selectedMapChanged();
void addMapToList(MapHandlerGen* m);
void removeMapFromList(MapHandlerGen* m);
void addMapToList(MapHandlerGen* map);
void removeMapFromList(MapHandlerGen* map);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
};
......
......@@ -54,7 +54,6 @@ void Dialog_ComputeNormal::selectedMapChanged()
{
combo_positionAttribute->addItem(i.key());
combo_normalAttribute->addItem(i.key());
++j;
}
}
......@@ -66,19 +65,19 @@ void Dialog_ComputeNormal::selectedMapChanged()
m_selectedMap = NULL;
}
void Dialog_ComputeNormal::addMapToList(MapHandlerGen* m)
void Dialog_ComputeNormal::addMapToList(MapHandlerGen* map)
{
QListWidgetItem* item = new QListWidgetItem(m->getName(), list_maps);
QListWidgetItem* item = new QListWidgetItem(map->getName(), list_maps);
item->setCheckState(Qt::Unchecked);
}
void Dialog_ComputeNormal::removeMapFromList(MapHandlerGen* m)
void Dialog_ComputeNormal::removeMapFromList(MapHandlerGen* map)
{
QList<QListWidgetItem*> items = list_maps->findItems(m->getName(), Qt::MatchExactly);
QList<QListWidgetItem*> items = list_maps->findItems(map->getName(), Qt::MatchExactly);
if(!items.empty())
delete items[0];
if(m_selectedMap == m)
if(m_selectedMap == map)
{
disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
m_selectedMap = NULL;
......
......@@ -125,7 +125,7 @@ void Surface_RenderVector_DockTab::updateMapParameters()
{
const MapParameters& p = m_plugin->h_viewParameterSet[view][map];
unsigned int i = 0;
unsigned int i = 1;
foreach(Utils::VBO* vbo, map->getVBOSet().values())
{
if(vbo->dataSize() == 3)
......
cmake_minimum_required(VERSION 2.8)
SET( PLUGIN_NAME SubdivideSurface )
SET( PLUGIN_NAME Surface_Subdivision )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/subdivideSurface )
SET( PLUGIN_ROOT_DIR ${SCHNApps_ROOT_DIR}/Plugins/surface_subdivision )
INCLUDE_DIRECTORIES(
${PLUGIN_ROOT_DIR}/include
......@@ -25,8 +25,8 @@ file(
SET(
PLUGIN_QOBJECT_FILES
${PLUGIN_ROOT_DIR}/include/subdivideSurface.h
${PLUGIN_ROOT_DIR}/include/subdivideSurfaceDialog.h
${PLUGIN_ROOT_DIR}/include/surface_subdivision.h
${PLUGIN_ROOT_DIR}/include/dialog_surface_subdivision.h
)
include( ${SCHNApps_ROOT_DIR}/Plugins/plugins_cmake.txt )
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog_Surface_Subdivision</class>
<widget class="QDialog" name="Dialog_Surface_Subdivision">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>314</width>
<height>230</height>
</rect>
</property>
<property name="windowTitle">
<string>Subdivide surface</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="5">
<widget class="QListWidget" name="list_maps"/>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position attribute :</string>
</property>
</widget>
</item>
<item row="1" column="3" colspan="2">
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="radio_Loop">
<property name="text">
<string>Loop</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QRadioButton" name="radio_CC">
<property name="text">
<string>Catmull-Clark</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QRadioButton" name="radio_trianguleFaces">
<property name="text">
<string>Triangule faces</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="button_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="3" column="2" colspan="2">
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QPushButton" name="button_ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SubdivideSurfaceDialog</class>
<widget class="QDialog" name="SubdivideSurfaceDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>314</width>
<height>230</height>
</rect>
</property>
<property name="windowTitle">
<string>Subdivide surface</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="mapList"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position attribute :</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="combo_positionAttribute">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="radio_Loop">
<property name="text">
<string>Loop</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_CC">
<property name="text">
<string>Catmull-Clark</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_trianguleFaces">
<property name="text">
<string>Triangule faces</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QPushButton" name="button_cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_apply">
<property name="text">
<string>Apply</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_ok">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
#ifndef _SUBDIVIDESURFACE_DIALOG_H_
#define _SUBDIVIDESURFACE_DIALOG_H_
#ifndef _DIALOG_SURFACE_SUBDIVISION_H_
#define _DIALOG_SURFACE_SUBDIVISION_H_
#include "ui_subdivideSurfaceDialog.h"
#include "ui_dialog_surface_subdivision.h"
namespace CGoGN
{
......@@ -9,25 +9,25 @@ namespace CGoGN
namespace SCHNApps
{
class Window;
class SCHNApps;
class MapHandlerGen;
class SubdivideSurfaceDialog : public QDialog, public Ui::SubdivideSurfaceDialog
class Dialog_Surface_Subdivision : public QDialog, public Ui::Dialog_Surface_Subdivision
{
Q_OBJECT
public:
SubdivideSurfaceDialog(Window* w);
Dialog_Surface_Subdivision(SCHNApps* s);
private:
Window* m_window;
SCHNApps* m_schnapps;
MapHandlerGen* m_selectedMap;
public slots:
void selectedMapChanged();
void addMapToList(MapHandlerGen* m);
void removeMapFromList(MapHandlerGen* m);
void addAttributeToList(unsigned int orbit, const QString& name);
void addMapToList(MapHandlerGen* map);
void removeMapFromList(MapHandlerGen* map);
void addAttributeToList(unsigned int orbit, const QString& nameAttr);
};
} // namespace SCHNApps
......
#ifndef _SUBDIVIDESURFACE_PLUGIN_H_
#define _SUBDIVIDESURFACE_PLUGIN_H_
#ifndef _SURFACE_SUBDIVISION_PLUGIN_H_
#define _SURFACE_SUBDIVISION_PLUGIN_H_
#include "plugin.h"
#include "subdivideSurfaceDialog.h"
#include "plugin_processing.h"
#include "dialog_surface_subdivision.h"
namespace CGoGN
{
......@@ -10,36 +11,26 @@ namespace CGoGN
namespace SCHNApps
{
class SubdivideSurfacePlugin : public Plugin
class Surface_Subdivision_Plugin : public Plugin
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
public:
SubdivideSurfacePlugin()
{
setProvidesRendering(false);
}
Surface_Subdivision_Plugin()
{}
~SubdivideSurfacePlugin()
~Surface_Subdivision_Plugin()
{}
virtual bool enable();
virtual void disable() {}
virtual void redraw(View *view) {}
virtual void keyPress(View* view, QKeyEvent* event) {}
virtual void keyRelease(View* view, QKeyEvent* 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) {}
private slots:
void openSubdivisionDialog();
void subdivideFromDialog();
public slots:
void openSubdivideSurfaceDialog();
void subdivideSurfaceFromDialog();
void loopSubdivision(
const QString& mapName,
const QString& positionAttributeName = "position"
......@@ -54,9 +45,9 @@ public slots:
);
private:
SubdivideSurfaceDialog* m_subdivideSurfaceDialog;
Dialog_Surface_Subdivision* m_subdivisionDialog;
QAction* m_subdivideSurfaceAction;
QAction* m_subdivisionAction;
};
} // namespace SCHNApps
......
#include "subdivideSurfaceDialog.h"
#include "dialog_surface_subdivision.h"
#include "subdivideSurface.h"
#include "window.h"
#include "surface_subdivision.h"
#include "schnapps.h"
#include "mapHandler.h"
namespace CGoGN
......@@ -10,47 +10,43 @@ namespace CGoGN
namespace SCHNApps
{
SubdivideSurfaceDialog::SubdivideSurfaceDialog(Window* w) :
m_window(w),
Dialog_Surface_Subdivision::Dialog_Surface_Subdivision(SCHNApps* s) :
m_schnapps(s),
m_selectedMap(NULL)
{
setupUi(this);
connect(m_window, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(addMapToList(MapHandlerGen*)));
connect(m_window, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(removeMapFromList(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapAdded(MapHandlerGen*)), this, SLOT(addMapToList(MapHandlerGen*)));
connect(m_schnapps, SIGNAL(mapRemoved(MapHandlerGen*)), this, SLOT(removeMapFromList(MapHandlerGen*)));
connect(mapList, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
connect(list_maps, SIGNAL(itemSelectionChanged()), this, SLOT(selectedMapChanged()));
const QList<MapHandlerGen*>& maps = m_window->getMapsList();
foreach(MapHandlerGen* map, maps)
mapList->addItem(map->getName());
foreach(MapHandlerGen* map, m_schnapps->getMapSet().values())
list_maps->addItem(map->getName());
}
void SubdivideSurfaceDialog::selectedMapChanged()
void Dialog_Surface_Subdivision::selectedMapChanged()
{
if(m_selectedMap)
disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
QList<QListWidgetItem*> currentItems = mapList->selectedItems();
QList<QListWidgetItem*> currentItems = list_maps->selectedItems();
if(!currentItems.empty())
{
combo_positionAttribute->clear();
const QString& mapname = currentItems[0]->text();
MapHandlerGen* mh = m_window->getMap(mapname);
MapHandlerGen* mh = m_schnapps->getMap(mapname);
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
unsigned int j = 0;
const AttributeHash& attribs = mh->getAttributesList(VERTEX);
for(AttributeHash::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
const AttributeSet& attribs = mh->getAttributeSet(VERTEX);
for(AttributeSet::const_iterator i = attribs.constBegin(); i != attribs.constEnd(); ++i)
{
if(i.value() == vec3TypeName)
{
combo_positionAttribute->addItem(i.key());
if(i.key() == "position") // try to select a position attribute named "position"
combo_positionAttribute->setCurrentIndex(j);
++j;
}
}
......@@ -62,25 +58,25 @@ void SubdivideSurfaceDialog::selectedMapChanged()
m_selectedMap = NULL;
}
void SubdivideSurfaceDialog::addMapToList(MapHandlerGen* m)
void Dialog_Surface_Subdivision::addMapToList(MapHandlerGen* map)
{
mapList->addItem(m->getName());
list_maps->addItem(map->getName());
}
void SubdivideSurfaceDialog::removeMapFromList(MapHandlerGen* m)
void Dialog_Surface_Subdivision::removeMapFromList(MapHandlerGen* map)
{
QList<QListWidgetItem*> items = mapList->findItems(m->getName(), Qt::MatchExactly);
QList<QListWidgetItem*> items = list_maps->findItems(map->getName(), Qt::MatchExactly);
if(!items.empty())
delete items[0];
if(m_selectedMap == m)
if(m_selectedMap == map)
{
disconnect(m_selectedMap, SIGNAL(attributeAdded(unsigned int, const QString&)), this, SLOT(addAttributeToList(unsigned int, const QString&)));
m_selectedMap = NULL;
}
}
void SubdivideSurfaceDialog::addAttributeToList(unsigned int orbit, const QString& nameAttr)
void Dialog_Surface_Subdivision::addAttributeToList(unsigned int orbit, const QString& nameAttr)
{
QString vec3TypeName = QString::fromStdString(nameOfType(PFP2::VEC3()));
......
#include "subdivideSurface.h"
#include "surface_subdivision.h"
#include "mapHandler.h"
......@@ -10,49 +10,49 @@ namespace CGoGN
namespace SCHNApps
{
bool SubdivideSurfacePlugin::enable()
bool Surface_Subdivision_Plugin::enable()
{
m_subdivideSurfaceDialog = new SubdivideSurfaceDialog(m_window);
m_subdivisionDialog = new Dialog_Surface_Subdivision(m_schnapps);
m_subdivideSurfaceAction = new QAction("Subdivide surface", this);
m_subdivisionAction = new QAction("Subdivide surface", this);
addMenuAction("Surface;Subdivide", m_subdivideSurfaceAction);
m_schnapps->addMenuAction(this, "Surface;Subdivision", m_subdivisionAction);
connect(m_subdivideSurfaceAction, SIGNAL(triggered()), this, SLOT(openSubdivideSurfaceDialog()));
connect(m_subdivisionAction, SIGNAL(triggered()), this, SLOT(openSubdivisionDialog()));
connect(m_subdivideSurfaceDialog, SIGNAL(accepted()), this, SLOT(subdivideSurfaceFromDialog()));
connect(m_subdivideSurfaceDialog->button_apply, SIGNAL(clicked()), this, SLOT(subdivideSurfaceFromDialog()));
connect(m_subdivisionDialog, SIGNAL(accepted()), this, SLOT(subdivideFromDialog()));
connect(m_subdivisionDialog->button_apply, SIGNAL(clicked()), this, SLOT(subdivideFromDialog()));
return true;
}
void SubdivideSurfacePlugin::openSubdivideSurfaceDialog()
void Surface_Subdivision_Plugin::openSubdivisionDialog()
{
m_subdivideSurfaceDialog->show();
m_subdivisionDialog->show();
}
void SubdivideSurfacePlugin::subdivideSurfaceFromDialog()
void Surface_Subdivision_Plugin::subdivideFromDialog()
{
QList<QListWidgetItem*> currentItems = m_subdivideSurfaceDialog->mapList->selectedItems();
QList<QListWidgetItem*> currentItems = m_subdivisionDialog->list_maps->selectedItems();
if(!currentItems.empty())
{
const QString& mapName = currentItems[0]->text();
const QString& positionName = m_subdivideSurfaceDialog->combo_positionAttribute->currentText();
const QString& positionName = m_subdivisionDialog->combo_positionAttribute->currentText();
if(m_subdivideSurfaceDialog->radio_Loop->isChecked())
if(m_subdivisionDialog->radio_Loop->isChecked())
loopSubdivision(mapName, positionName);
else if(m_subdivideSurfaceDialog->radio_CC->isChecked())
else if(m_subdivisionDialog->radio_CC->isChecked())
CCSubdivision(mapName, positionName);
else if(m_subdivideSurfaceDialog->radio_trianguleFaces->isChecked())
else if(m_subdivisionDialog->radio_trianguleFaces->isChecked())
trianguleFaces(mapName, positionName);
}
}
void SubdivideSurfacePlugin::loopSubdivision(
void Surface_Subdivision_Plugin::loopSubdivision(
const QString& mapName,
const QString& positionAttributeName)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName));
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
if(mh == NULL)
return;
......@@ -66,16 +66,15 @@ void SubdivideSurfacePlugin::loopSubdivision(
mh->notifyAttributeModification(position);
mh->notifyConnectivityModification();
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
foreach(View* view, mh->getLinkedViews())
view->updateGL();
}
void SubdivideSurfacePlugin::CCSubdivision(
void Surface_Subdivision_Plugin::CCSubdivision(
const QString& mapName,
const QString& positionAttributeName)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName));
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
if(mh == NULL)
return;
......@@ -89,16 +88,15 @@ void SubdivideSurfacePlugin::CCSubdivision(
mh->notifyAttributeModification(position);
mh->notifyConnectivityModification();
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
foreach(View* view, mh->getLinkedViews())
view->updateGL();
}
void SubdivideSurfacePlugin::trianguleFaces(
void Surface_Subdivision_Plugin::trianguleFaces(
const QString& mapName,
const QString& positionAttributeName)
{
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapName));
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_schnapps->getMap(mapName));
if(mh == NULL)
return;
......@@ -112,15 +110,14 @@ void SubdivideSurfacePlugin::trianguleFaces(
mh->notifyAttributeModification(position);
mh->notifyConnectivityModification();
QList<View*> views = mh->getLinkedViews();
foreach(View* view, views)
foreach(View* view, mh->getLinkedViews())
view->updateGL();
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(SubdivideSurfacePlugin, SubdivideSurfacePlugin)
Q_EXPORT_PLUGIN2(Surface_Subdivision_Plugin, Surface_Subdivision_Plugin)
#else
Q_EXPORT_PLUGIN2(SubdivideSurfacePluginD, SubdivideSurfacePlugin)
Q_EXPORT_PLUGIN2(Surface_Subdivision_PluginD, Surface_Subdivision_Plugin)
#endif
} // namespace SCHNApps
......
......@@ -55,8 +55,8 @@ Dart trianguleFace(typename PFP::MAP& map, Dart d);
template <typename PFP, typename EMBV, typename EMB>
void trianguleFaces(typename PFP::MAP& map, EMBV& attributs) ;
template <typename PFP>
void trianguleFaces(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position) ;
//template <typename PFP>
//void trianguleFaces(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position) ;
/**
* Triangule all the faces of the mesh
......
......@@ -92,8 +92,10 @@ void trianguleFaces(typename PFP::MAP& map, EMBV& attributs)
template <typename PFP>
void trianguleFaces(
typename PFP::MAP& map,
VertexAttribute<typename PFP::VEC3>& position, const FaceAttribute<typename PFP::VEC3>& positionF)
typename PFP::MAP& map,
VertexAttribute<typename PFP::VEC3>& position,
const FaceAttribute<typename PFP::VEC3>& positionF
)
{
TraversorF<typename PFP::MAP> t(map) ;
for (Dart d = t.begin(); d != t.end(); d = t.next())
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment