Commit b8c1a242 authored by Pierre Kraemer's avatar Pierre Kraemer

update initAllOrbitsEmbedding to work on non-embedded orbit

parent 7825825d
......@@ -14,43 +14,48 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<item row="13" column="1" colspan="2">
<widget class="QPushButton" name="button_accept">
<property name="text">
<string>Position :</string>
<string>Accept</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="3">
<widget class="QComboBox" name="combo_edgeOperation">
<item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>- select operation -</string>
<string>Operations :</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="combo_vertexSelector">
<item>
<property name="text">
<string>Cut edge</string>
<string>- select selector -</string>
</property>
</item>
<item>
<property name="text">
<string>Uncut edge</string>
</property>
</widget>
</item>
<item>
<item row="7" column="3">
<widget class="QPushButton" name="button_applyVertexOperation">
<property name="text">
<string>Collapse edge</string>
<string>Apply vertex operation</string>
</property>
</widget>
</item>
<item>
<property name="text">
<string>Flip edge</string>
<item row="11" column="0" colspan="4">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="combo_edgeSelector">
<item>
<property name="text">
<string>Flip back edge</string>
<string>- select selector -</string>
</property>
</item>
</widget>
......@@ -77,21 +82,6 @@
<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>
......@@ -109,57 +99,58 @@
</item>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Operations :</string>
<string>Vertex selector :</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Vertex selector :</string>
<string>Position :</string>
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QPushButton" name="button_applyVertexOperation">
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Apply vertex operation</string>
<string>Face selector :</string>
</property>
</widget>
</item>
<item row="10" column="0" colspan="4">
<widget class="Line" name="line_2">
<item row="4" column="0" colspan="4">
<widget class="Line" name="line">
<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>
<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>
</widget>
</item>
<item row="8" column="3">
<widget class="QPushButton" name="button_applyEdgeOperation">
<item>
<property name="text">
<string>Apply edge operation</string>
<string>- select attribute -</string>
</property>
</item>
</widget>
</item>
<item row="12" column="0">
<widget class="QPushButton" name="button_start">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Start</string>
<string>Clicks :</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QComboBox" name="combo_vertexOperation">
<item row="8" column="0" colspan="3">
<widget class="QComboBox" name="combo_edgeOperation">
<item>
<property name="text">
<string>- select operation -</string>
......@@ -167,66 +158,55 @@
</item>
<item>
<property name="text">
<string>Split vertex</string>
<string>Cut edge</string>
</property>
</item>
<item>
<property name="text">
<string>Delete vertex</string>
<string>Uncut edge</string>
</property>
</item>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<item>
<property name="text">
<string>Edge selector :</string>
<string>Collapse edge</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QComboBox" name="combo_vertexSelector">
<item>
<property name="text">
<string>- select selector -</string>
<string>Flip edge</string>
</property>
</item>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QComboBox" name="combo_edgeSelector">
<item>
<property name="text">
<string>- select selector -</string>
<string>Flip back edge</string>
</property>
</item>
</widget>
</item>
<item row="13" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item row="6" column="3">
<widget class="QPushButton" name="button_applyGeneralOperation">
<property name="text">
<string>Apply general operation</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</widget>
</item>
<item row="7" column="0" colspan="3">
<widget class="QComboBox" name="combo_vertexOperation">
<item>
<property name="text">
<string>- select operation -</string>
</property>
</spacer>
</item>
<item row="11" column="0">
<widget class="QLabel" name="label_6">
<item>
<property name="text">
<string>Clicks :</string>
<string>Split vertex</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="4">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<item>
<property name="text">
<string>Delete vertex</string>
</property>
</item>
</widget>
</item>
<item row="9" column="3">
......@@ -236,33 +216,25 @@
</property>
</widget>
</item>
<item row="12" column="1" colspan="2">
<widget class="QPushButton" name="button_accept">
<item row="13" column="3">
<widget class="QPushButton" name="button_cancel">
<property name="text">
<string>Accept</string>
<string>Cancel</string>
</property>
</widget>
</item>
<item row="6" column="3">
<widget class="QPushButton" name="button_applyGeneralOperation">
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Apply general operation</string>
<string>Edge selector :</string>
</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>
<item row="13" column="0">
<widget class="QPushButton" name="button_start">
<property name="text">
<string>- select attribute -</string>
<string>Start</string>
</property>
</item>
</widget>
</item>
<item row="9" column="0" colspan="3">
......@@ -309,6 +281,13 @@
</item>
</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="3" column="1" colspan="3">
<widget class="QComboBox" name="combo_faceSelector">
<item>
......@@ -318,12 +297,18 @@
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Face selector :</string>
<item row="14" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
......
......@@ -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<MapHandlerGen*, MapParameters> h_parameterSet;
Utils::Drawer* m_drawer;
bool collect;
std::vector<PFP2::VEC3> collectedVertices;
std::vector<PFP2::VEC3> collectedVertices;
bool collect;
int mapNumber;
};
} // namespace SCHNApps
......
......@@ -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();
......
......@@ -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<PFP2>* mh = static_cast<MapHandler<PFP2>*>(mhg);
// add vertex position attribute
VertexAttribute<PFP2::VEC3> position = mh->addAttribute<PFP2::VEC3, VERTEX>("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<PFP2::VEC3>& position = h_parameterSet[mhg].positionAttribute;
Algo::Surface::Modelisation::embedPrism<PFP2>(*map, position, 4, false, 0.7f, 0.7f, 1.0f);
Algo::Surface::Modelisation::embedPrism<PFP2>(*map, position, 4, true, 0.7f, 0.7f, 1.0f);
mh->notifyAttributeModification(position);
mh->notifyConnectivityModification();
// compute map bounding box
mh->updateBB(position);
}
......@@ -274,33 +275,62 @@ 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<Dart>& selectedDarts = p.edgeSelector->getSelectedCells();
const std::vector<Dart>& 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))))
{
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(isWellSelected)
{
Dart it = map->phi1(d1);
do
{
it = map->phi1(it);
i++;
d = map->phi1(d);
}
while(map->phi1(e) != selectedDarts[1])
while(it != d1);
it = map->phi1(d2);
do
{
it = map->phi1(it);
j++;
e = map->phi1(e);
}
while(it != d2);
if(d == e)
if(i == j)
{
map->mergeVolumes(selectedDarts[0], selectedDarts[1]);
map->mergeVolumes(d1, d2);
mh->notifyConnectivityModification();
}
else QMessageBox::information(0, "Attention", "Selected faces should have the same number of edges");
}
}
}
void Surface_Modelisation_Plugin::splitSurface(MapHandlerGen* mhg)
......@@ -308,17 +338,58 @@ void Surface_Modelisation_Plugin::splitSurface(MapHandlerGen* mhg)
MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(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<Dart> selectedDarts = p.edgeSelector->getSelectedCells();
std::vector<Dart> 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<Dart>::iterator it = path.begin() ; it != path.end()-1; ++it)
{
if (isPath)
{
CellMarker<VERTEX>* vm = new CellMarker<VERTEX>(*map);
if(vm->isMarked(*it))
isPath = false;
vm->mark(*it);
std::vector<Dart>::iterator next;
next = it + 1 ;
if(map->checkSimpleOrientedPath(selectedDarts))
if (!map->sameVertex(map->phi1(*it), *next))
{
map->splitSurface(selectedDarts);
if (map->sameVertex(map->phi1(*it), map->phi2(*next)))
{
path[i+1] = map->phi2(*next);
}
else isPath = false;
}
i++;
}
else break;
}
}
if(isPath)
{
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<Dart>& 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<Dart>& selectedDart = p.faceSelector->getSelectedCells();
std::vector<PFP2::VEC3> profile;
PFP2::VEC3 centerProfile;
Dart it = selectedDart[0];
Dart d = selectedDart[0];
for (unsigned int i = 0; i < collectedVertices.size(); i++)
{
Dart it = d;
PFP2::VEC3 center;
int n = 0;
do
{
profile.push_back(position[it]);
centerProfile = centerProfile + position[it];
center += position[it];
it = map->phi1(it);
n++;
} while (it != selectedDart[0]);
centerProfile = centerProfile / n;
} while (it != d);
center = <