diff --git a/SCHNApps/Plugins/surface_modelisation/forms/surface_modelisation.ui b/SCHNApps/Plugins/surface_modelisation/forms/surface_modelisation.ui
index 941c73cb915bc4285bb4528b3209cda7bae96de8..378583844776c6c04906e2c0b87142b18c16672b 100644
--- a/SCHNApps/Plugins/surface_modelisation/forms/surface_modelisation.ui
+++ b/SCHNApps/Plugins/surface_modelisation/forms/surface_modelisation.ui
@@ -14,43 +14,48 @@
Form
- -
-
+
-
+
- Position :
+ Accept
- -
-
-
-
-
- - select operation -
-
-
- -
-
- Cut edge
-
-
- -
-
- Uncut edge
-
-
- -
-
- Collapse edge
-
-
+ -
+
+
+ Operations :
+
+
+
+ -
+
-
- Flip edge
+ - select selector -
+
+
+ -
+
+
+ Apply vertex operation
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ -
+
-
- Flip back edge
+ - select selector -
@@ -77,21 +82,6 @@
Add cube
- -
-
- Fill hole
-
-
- -
-
- Delete connected component
-
-
- -
-
- Revolution
-
-
-
Merge volumes
@@ -109,13 +99,6 @@
- -
-
-
- Operations :
-
-
-
-
@@ -123,43 +106,51 @@
- -
-
+
-
+
- Apply vertex operation
+ Position :
- -
-
-
- Qt::Horizontal
+
-
+
+
+ Face selector :
- -
-
-
- Cancel
+
-
+
+
+ Qt::Horizontal
- -
-
-
- Apply edge operation
+
-
+
+
+
+ 0
+ 0
+
+
-
+
+ - select attribute -
+
+
-
-
+
- Start
+ Clicks :
- -
-
+
-
+
-
- select operation -
@@ -167,66 +158,55 @@
-
- Split vertex
+ Cut edge
-
- Delete vertex
+ Uncut edge
-
-
- -
-
-
- Edge selector :
-
-
-
- -
-
-
- - select selector -
+ Collapse edge
-
-
- -
-
-
- - select selector -
+ Flip edge
+
+
+ -
+
+ Flip back edge
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 40
-
-
-
-
- -
-
+
-
+
- Clicks :
+ Apply general operation
- -
-
-
- Qt::Horizontal
-
+
-
+
+
-
+
+ - select operation -
+
+
+ -
+
+ Split vertex
+
+
+ -
+
+ Delete vertex
+
+
-
@@ -236,33 +216,25 @@
- -
-
+
-
+
- Accept
+ Cancel
- -
-
+
-
+
- Apply general operation
+ Edge selector :
- -
-
-
-
- 0
- 0
-
+
-
+
+
+ Start
-
-
-
- - select attribute -
-
-
-
@@ -309,6 +281,13 @@
+ -
+
+
+ Apply edge operation
+
+
+
-
-
@@ -318,12 +297,18 @@
- -
-
-
- Face selector :
+
-
+
+
+ Qt::Vertical
-
+
+
+ 20
+ 40
+
+
+
diff --git a/SCHNApps/Plugins/surface_modelisation/include/surface_modelisation.h b/SCHNApps/Plugins/surface_modelisation/include/surface_modelisation.h
index 98e07ce40808c73c1dbb5dab3271e75b956f296d..64c7ac7f4baa956afa9b385d38bf9289141d268c 100644
--- a/SCHNApps/Plugins/surface_modelisation/include/surface_modelisation.h
+++ b/SCHNApps/Plugins/surface_modelisation/include/surface_modelisation.h
@@ -83,9 +83,6 @@ protected:
void createEmptyMap();
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);
@@ -112,9 +109,10 @@ protected:
Surface_Modelisation_DockTab* m_dockTab;
QHash h_parameterSet;
Utils::Drawer* m_drawer;
- bool collect;
- std::vector collectedVertices;
+ std::vector collectedVertices;
+ bool collect;
+ int mapNumber;
};
} // namespace SCHNApps
diff --git a/SCHNApps/Plugins/surface_modelisation/include/surface_modelisation_dockTab.h b/SCHNApps/Plugins/surface_modelisation/include/surface_modelisation_dockTab.h
index bd677d8a65bd508430e637065af7cde5ba5d8e3a..8231b451708a89a8a2a41a22effa4ad99ce14869 100644
--- a/SCHNApps/Plugins/surface_modelisation/include/surface_modelisation_dockTab.h
+++ b/SCHNApps/Plugins/surface_modelisation/include/surface_modelisation_dockTab.h
@@ -4,10 +4,6 @@
#include "ui_surface_modelisation.h"
#include "QString"
-//#include "mapHandler.h"
-//#include "Utils/drawer.h"
-//#include "Topology/map/map2.h"
-
namespace CGoGN
{
@@ -44,8 +40,6 @@ private slots:
void edgeSelectorChanged(int index);
void faceSelectorChanged(int index);
- //void operationChanged(const QString &text);
-
void applyGeneralOperationButtonClicked();
void applyVertexOperationButtonClicked();
void applyEdgeOperationButtonClicked();
diff --git a/SCHNApps/Plugins/surface_modelisation/src/surface_modelisation.cpp b/SCHNApps/Plugins/surface_modelisation/src/surface_modelisation.cpp
index 9f4aa84a1e7205ce1ef982b048243ac6529fc661..c0caf997ce3600b9d8835304d8d3786b4f30fb46 100644
--- a/SCHNApps/Plugins/surface_modelisation/src/surface_modelisation.cpp
+++ b/SCHNApps/Plugins/surface_modelisation/src/surface_modelisation.cpp
@@ -39,6 +39,8 @@ bool Surface_Modelisation_Plugin::enable()
m_drawer = new Utils::Drawer();
registerShader(m_drawer->getShader());
+ mapNumber = 1;
+
return true;
}
@@ -73,7 +75,7 @@ void Surface_Modelisation_Plugin::drawMap(View* view, MapHandlerGen* map)
void Surface_Modelisation_Plugin::mousePress(View* view, QMouseEvent* event)
{
- if(collect)
+ if(collect && (event->button() == Qt::LeftButton))
{
qglviewer::Vec point(event->x(), event->y(), 0.5);
qglviewer::Vec vertex = view->camera()->unprojectedCoordinatesOf(point);
@@ -207,16 +209,17 @@ void Surface_Modelisation_Plugin::changeFaceSelector(const QString& map, const Q
void Surface_Modelisation_Plugin::createEmptyMap()
{
- MapHandlerGen* mhg = m_schnapps->addMap("map", 2);
+ QString mapName = "map_" + QString::number(mapNumber);
+ MapHandlerGen* mhg = m_schnapps->addMap(mapName, 2);
if(mhg)
{
MapHandler* mh = static_cast*>(mhg);
// add vertex position attribute
VertexAttribute position = mh->addAttribute("position");
-
// update corresponding VBO & emit attribute update signal
mh->notifyAttributeModification(position);
+ mapNumber++;
}
}
@@ -241,7 +244,6 @@ void Surface_Modelisation_Plugin::createNewFace(MapHandlerGen* mhg)
mh->notifyConnectivityModification();
mh->notifyAttributeModification(position);
-
mh->updateBB(position);
collectedVertices.clear();
}
@@ -258,11 +260,10 @@ void Surface_Modelisation_Plugin::addCube(MapHandlerGen *mhg)
{
VertexAttribute& position = h_parameterSet[mhg].positionAttribute;
- Algo::Surface::Modelisation::embedPrism(*map, position, 4, false, 0.7f, 0.7f, 1.0f);
+ Algo::Surface::Modelisation::embedPrism(*map, position, 4, true, 0.7f, 0.7f, 1.0f);
mh->notifyAttributeModification(position);
mh->notifyConnectivityModification();
-
// compute map bounding box
mh->updateBB(position);
}
@@ -274,32 +275,61 @@ void Surface_Modelisation_Plugin::mergeVolumes(MapHandlerGen* mhg)
PFP2::MAP* map = mh->getMap();
const MapParameters& p = h_parameterSet[mhg];
- if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty() && (p.edgeSelector->getSelectedCells().size() == 2))
+ if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty() && (p.edgeSelector->getSelectedCells().size() == 2) &&
+ p.faceSelector && !p.faceSelector->getSelectedCells().empty() && (p.faceSelector->getSelectedCells().size() == 2))
{
const std::vector& selectedDarts = p.edgeSelector->getSelectedCells();
+ const std::vector& selectedFaces = p.faceSelector->getSelectedCells();
- Dart d = selectedDarts[0];
- Dart e = selectedDarts[1];
- int i = 1;
- int j =1;
+ Dart d1 = selectedDarts[0];
+ Dart d2 = selectedDarts[1];
+ Dart f1 = selectedFaces[0];
+ Dart f2 = selectedFaces[1];
+ int i = 1, j = 1;
+ bool isWellSelected = true;
- while(map->phi1(d) != selectedDarts[0])
+ if (!(map->sameFace(d1,f1) && (map->sameFace(d2,f2))))
{
- i++;
- d = map->phi1(d);
- }
- while(map->phi1(e) != selectedDarts[1])
- {
- j++;
- e = map->phi1(e);
+ if (!(map->sameFace(d1,f2) && (map->sameFace(d2,f1))))
+ {
+ if ((map->sameFace(map->phi2(d1),f1)) || (map->sameFace(map->phi2(d1),f2)))
+ d1 = map->phi2(d1);
+
+ if ((map->sameFace(map->phi2(d2),f1)) || (map->sameFace(map->phi2(d2),f2)))
+ d2 = map->phi2(d2);
+
+ if (map->sameFace(d1,d2) ||
+ !((map->sameFace(d1,f1) && (map->sameFace(d2,f2))) ||
+ (map->sameFace(d1,f2) && (map->sameFace(d2,f1)))))
+ isWellSelected = false;
+ }
}
- if(d == e)
+ if(isWellSelected)
{
- map->mergeVolumes(selectedDarts[0], selectedDarts[1]);
- mh->notifyConnectivityModification();
+ Dart it = map->phi1(d1);
+ do
+ {
+ it = map->phi1(it);
+ i++;
+ }
+ while(it != d1);
+
+ it = map->phi1(d2);
+ do
+ {
+ it = map->phi1(it);
+ j++;
+ }
+ while(it != d2);
+
+ if(i == j)
+ {
+ map->mergeVolumes(d1, d2);
+ mh->notifyConnectivityModification();
+ }
+ else QMessageBox::information(0, "Attention", "Selected faces should have the same number of edges");
}
- else QMessageBox::information(0, "Attention", "Selected faces should have the same number of edges");
}
}
@@ -308,17 +338,58 @@ void Surface_Modelisation_Plugin::splitSurface(MapHandlerGen* mhg)
MapHandler* mh = static_cast*>(mhg);
PFP2::MAP* map = mh->getMap();
- const MapParameters& p = h_parameterSet[mhg];
+ MapParameters& p = h_parameterSet[mhg];
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty())
{
std::vector selectedDarts = p.edgeSelector->getSelectedCells();
+ std::vector path = selectedDarts;
+ bool isPath = true;
+ unsigned int i = 0;
+
+ if (!(map->sameVertex(path[0], map->phi1(path[path.size()-1])) ||
+ map->sameVertex(path[0], map->phi_1(path[path.size()-1]))))
+ {
+ if (map->sameVertex(map->phi2(path[0]), map->phi1(path[path.size()-1])) ||
+ map->sameVertex(map->phi2(path[0]), map->phi_1(path[path.size()-1])))
+ path[0] = map->phi2(path[0]);
+ else isPath = false;
+ }
+
+ if (isPath)
+ {
+ for(std::vector::iterator it = path.begin() ; it != path.end()-1; ++it)
+ {
+ if (isPath)
+ {
+ CellMarker* vm = new CellMarker(*map);
+ if(vm->isMarked(*it))
+ isPath = false;
+ vm->mark(*it);
+
+ std::vector::iterator next;
+ next = it + 1 ;
+
+ if (!map->sameVertex(map->phi1(*it), *next))
+ {
+ if (map->sameVertex(map->phi1(*it), map->phi2(*next)))
+ {
+ path[i+1] = map->phi2(*next);
+ }
+ else isPath = false;
+ }
+ i++;
+ }
+ else break;
+ }
+ }
- if(map->checkSimpleOrientedPath(selectedDarts))
+ if(isPath)
{
- map->splitSurface(selectedDarts);
+ map->splitSurface(path);
mh->notifyConnectivityModification();
+ mh->notifyAttributeModification(p.positionAttribute);
}
- else QMessageBox::information(0, "Attention", "To split surface you need to select edges in order and first edge should be connected with last one");
+ else QMessageBox::information(0, "Attention", "To split surface you need to select edges in order without intersections and first edge should be connected with last one");
}
}
@@ -490,7 +561,6 @@ void Surface_Modelisation_Plugin::flipEdge(MapHandlerGen *mhg)
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty())
{
const std::vector& edge = p.edgeSelector->getSelectedCells();
-
map->flipEdge(edge[0]);
mh->notifyConnectivityModification();
}
@@ -672,41 +742,45 @@ void Surface_Modelisation_Plugin::pathExtrudeFace(MapHandlerGen *mhg)
if(p.faceSelector && !p.faceSelector->getSelectedCells().empty())
{
const std::vector& selectedDart = p.faceSelector->getSelectedCells();
- std::vector profile;
- PFP2::VEC3 centerProfile;
- Dart it = selectedDart[0];
- int n = 0;
- do
+ Dart d = selectedDart[0];
+ for (unsigned int i = 0; i < collectedVertices.size(); i++)
{
- profile.push_back(position[it]);
- centerProfile = centerProfile + position[it];
- it = map->phi1(it);
- n++;
- } while (it != selectedDart[0]);
- centerProfile = centerProfile / n;
+ Dart it = d;
+ PFP2::VEC3 center;
+ int n = 0;
+ do
+ {
+ center += position[it];
+ it = map->phi1(it);
+ n++;
+ } while (it != d);
+ center = center / n;
+ std::vector norms;
+ do
+ {
+ norms.push_back((center - position[it]));
+ it = map->phi1(it);
+ } while (it != d);
- std::vector scalePath;
- for (unsigned int i = 0; i < collectedVertices.size(); i++)
- {
- scalePath.push_back(1.0);
- }
+ PFP2::REAL dist = 0;
+ dist = (collectedVertices[i] - center).norm();
+ d = Algo::Surface::Modelisation::extrudeFace(*map, position, d, dist);
- PFP2::VEC3 normalProfile = Algo::Surface::Geometry::faceNormal(*map, selectedDart[0], position);
+ it = d;
+ n = 0;
+ do
+ {
+ position[it] = collectedVertices[i] - norms[n];
+ it = map->phi1(it);
+ n++;
+ } while (it != d);
+ }
- Algo::Surface::Modelisation::extrusion_scale(*map, position, profile, centerProfile, normalProfile, true, collectedVertices, true, scalePath);
mh->notifyConnectivityModification();
mh->notifyAttributeModification(position);
mh->updateBB(position);
collectedVertices.clear();
-
-
- /*Dart d = selectedDart[0];
- for(int i = 0; i < collectedVertices.size(); i++)
- {
- PFP2::VEC3 normal = collectedVertices[i];
- d = Algo::Surface::Modelisation::extrudeFace(*map, p.positionAttribute, d, normal);
- }*/
}
}
diff --git a/SCHNApps/Plugins/surface_modelisation/src/surface_modelisation_dockTab.cpp b/SCHNApps/Plugins/surface_modelisation/src/surface_modelisation_dockTab.cpp
index 77047825708d579debf372410d989d02bb05505b..3266e6827497b943b3b21b32c1f7a52fe4faaf62 100644
--- a/SCHNApps/Plugins/surface_modelisation/src/surface_modelisation_dockTab.cpp
+++ b/SCHNApps/Plugins/surface_modelisation/src/surface_modelisation_dockTab.cpp
@@ -16,8 +16,7 @@ Surface_Modelisation_DockTab::Surface_Modelisation_DockTab(SCHNApps* s, Surface_
{
setupUi(this);
- generalOperations << "Create empty map" << "Create new face" << "Add cube" << "Fill hole" << "Delete connected component"
- << "Revolution" << "Merge volumes" << "Split surface" << "Extrude region";
+ generalOperations << "Create empty map" << "Create new face" << "Add cube" << "Merge volumes" << "Split surface" << "Extrude region";
vertexOperations << "Split vertex" << "Delete vertex";
edgeOperations << "Cut edge" << "Uncut edge" << "Collapse edge" << "Flip edge" << "Flip back edge";
faceOperations << "Split face" << "Merge faces" << "Delete face" << "Sew faces" << "Unsew faces" << "Extrude face" << "Extrude face following a path";
@@ -26,7 +25,6 @@ Surface_Modelisation_DockTab::Surface_Modelisation_DockTab(SCHNApps* s, Surface_
connect(combo_vertexSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(vertexSelectorChanged(int)));
connect(combo_edgeSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(edgeSelectorChanged(int)));
connect(combo_faceSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(faceSelectorChanged(int)));
- //connect(combo_operation, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(operationChanged(const QString&)));
connect(button_applyGeneralOperation, SIGNAL(clicked()), this, SLOT(applyGeneralOperationButtonClicked()));
connect(button_applyVertexOperation, SIGNAL(clicked()), this, SLOT(applyVertexOperationButtonClicked()));
connect(button_applyEdgeOperation, SIGNAL(clicked()), this, SLOT(applyEdgeOperationButtonClicked()));
@@ -162,22 +160,13 @@ void Surface_Modelisation_DockTab::applyGeneralOperationButtonClicked()
case 2: // Add cube
m_plugin->addCube(map);
break;
- case 3: // Fill hole
- m_plugin->fillHole(map);
- break;
- case 4: // Delete connected component
- m_plugin->deleteCC(map);
- break;
- case 5: // Revolution
- m_plugin->revolution(map);
- break;
- case 6: // Merge volumes
+ case 3: // Merge volumes
m_plugin->mergeVolumes(map);
break;
- case 7: // Split surface
+ case 4: // Split surface
m_plugin->splitSurface(map);
break;
- case 8 : // Extrude region
+ case 5: // Extrude region
m_plugin->extrudeRegion(map);
break;
}
@@ -269,24 +258,6 @@ void Surface_Modelisation_DockTab::applyFaceOperationButtonClicked()
}
}
}
-
-
-/*
-void Surface_Modelisation_DockTab::operationChanged(const QString& text)
-{
- if(!b_updatingUI)
- {
- switch(operations.indexOf(text))
- {
- case 0: // Create empty map
- break;
- case 1: // Add cube
- break;
- }
- }
-}
-*/
-
/* -------------------------------- Clicks -----------------------------------------*/
void Surface_Modelisation_DockTab::startButtonClicked()
@@ -304,7 +275,6 @@ void Surface_Modelisation_DockTab::cancelButtonClicked()
m_plugin->collect = false;
m_plugin->collectedVertices.clear();
}
-
/* -------------------------------- Updates -----------------------------------------*/
void Surface_Modelisation_DockTab::updateMapParameters()
diff --git a/include/Topology/generic/genericmap.hpp b/include/Topology/generic/genericmap.hpp
index 386c48f84996a0d2abb1de1d960c5a1fd9b55b5b..c36ab8ad97768db359389b1e8d9c245b300d999b 100644
--- a/include/Topology/generic/genericmap.hpp
+++ b/include/Topology/generic/genericmap.hpp
@@ -432,7 +432,8 @@ inline void GenericMap::initCell(unsigned int i)
template
void GenericMap::initAllOrbitsEmbedding(bool realloc)
{
- assert(isOrbitEmbedded() || !"Invalid parameter: orbit not embedded") ;
+ if(!isOrbitEmbedded())
+ addEmbedding() ;
DartMarker mark(*this) ;
for(Dart d = begin(); d != end(); next(d))
{