Commit 3235b80c authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' of cgogn:~kraemer/CGoGN into develop

parents 068bbeba 2f294c4b
......@@ -376,7 +376,10 @@ void Viewer::importMesh(std::string& filename)
if(!normal.isValid())
normal = myMap.addAttribute<VEC3, VERTEX>("normal") ;
Utils::Chrono c;
c.start();
Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "compute normals -> " << c.elapsed() << std::endl;
m_positionVBO->updateData(position) ;
m_normalVBO->updateData(normal) ;
......@@ -385,8 +388,6 @@ void Viewer::importMesh(std::string& filename)
updateGLMatrices() ;
std::cout << "#vertices -> " << Algo::Topo::getNbOrbits<VERTEX>(myMap) << std::endl;
Vertex v(myMap.begin());
unsigned int e = myMap.getEmbedding(v);
}
void Viewer::exportMesh(std::string& filename, bool askExportMode)
......
......@@ -187,12 +187,12 @@ void Surface_Deformation_Plugin::mouseMove(View* view, QMouseEvent* event)
MapHandlerGen* mh = m_schnapps->getSelectedMap();
MapParameters& p = h_parameterSet[mh];
const std::vector<Dart>& handle = p.handleSelector->getSelectedCells();
const std::vector<Vertex>& handle = p.handleSelector->getSelectedCells();
if(!m_draginit)
{
m_dragZ = 0;
for(std::vector<Dart>::const_iterator it = handle.begin(); it != handle.end(); ++it)
for(std::vector<Vertex>::const_iterator it = handle.begin(); it != handle.end(); ++it)
{
const PFP2::VEC3& pp = p.positionAttribute[*it];
qglviewer::Vec q = view->camera()->projectedCoordinatesOf(qglviewer::Vec(pp[0],pp[1],pp[2]));
......@@ -212,7 +212,7 @@ void Surface_Deformation_Plugin::mouseMove(View* view, QMouseEvent* event)
qglviewer::Vec vec = qq - m_dragPrevious;
PFP2::VEC3 t(vec.x, vec.y, vec.z);
for(std::vector<Dart>::const_iterator it = handle.begin(); it != handle.end(); ++it)
for(std::vector<Vertex>::const_iterator it = handle.begin(); it != handle.end(); ++it)
p.positionAttribute[*it] += t;
m_dragPrevious = qq;
......
......@@ -279,8 +279,8 @@ void Surface_Modelisation_Plugin::mergeVolumes(MapHandlerGen* mhg)
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();
const std::vector<Edge>& selectedDarts = p.edgeSelector->getSelectedCells();
const std::vector<Face>& selectedFaces = p.faceSelector->getSelectedCells();
Dart d1 = selectedDarts[0];
Dart d2 = selectedDarts[1];
......@@ -342,8 +342,11 @@ void Surface_Modelisation_Plugin::splitSurface(MapHandlerGen* 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;
std::vector<Edge> selectedDarts = p.edgeSelector->getSelectedCells();
std::vector<Dart> path;
for (std::vector<Edge>::iterator it = selectedDarts.begin(); it != selectedDarts.end(); ++it)
path.push_back((*it).dart);
bool isPath = true;
unsigned int i = 0;
......@@ -360,7 +363,7 @@ void Surface_Modelisation_Plugin::splitSurface(MapHandlerGen* mhg)
if (isPath)
{
for(std::vector<Dart>::iterator it = path.begin() ; it != path.end()-1; ++it)
for(std::vector<Dart>::iterator it = path.begin() ; it != path.end()-1; ++it)
{
if (isPath)
{
......@@ -368,7 +371,7 @@ void Surface_Modelisation_Plugin::splitSurface(MapHandlerGen* mhg)
isPath = false;
vm.mark(*it);
std::vector<Dart>::iterator next;
std::vector<Dart>::iterator next;
next = it + 1 ;
if (!map->sameVertex(map->phi1(*it), *next))
......@@ -403,7 +406,7 @@ void Surface_Modelisation_Plugin::extrudeRegion(MapHandlerGen *mhg)
MapParameters& p = h_parameterSet[mhg];
if(p.faceSelector && !p.faceSelector->getSelectedCells().empty())
{
const std::vector<Dart>& selectedDarts = p.faceSelector->getSelectedCells();
const std::vector<Face>& selectedDarts = p.faceSelector->getSelectedCells();
Algo::Surface::Modelisation::extrudeRegion<PFP2>(*map, p.positionAttribute, selectedDarts[0], p.faceSelector->getMarker());
mh->notifyConnectivityModification();
......@@ -422,13 +425,13 @@ void Surface_Modelisation_Plugin::splitVertex(MapHandlerGen *mhg)
MapParameters& p = h_parameterSet[mhg];
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty() && (p.edgeSelector->getSelectedCells().size() == 2))
{
const std::vector<Dart>& selectedEdges = p.edgeSelector->getSelectedCells();
const std::vector<Edge>& selectedEdges = p.edgeSelector->getSelectedCells();
Dart d0, d1;
unsigned int v00 = map->getEmbedding<VERTEX>(selectedEdges[0]);
unsigned int v01 = map->getEmbedding<VERTEX>(map->phi2(selectedEdges[0]));
unsigned int v10 = map->getEmbedding<VERTEX>(selectedEdges[1]);
unsigned int v11 = map->getEmbedding<VERTEX>(map->phi2(selectedEdges[1]));
unsigned int v00 = map->getEmbedding<VERTEX>(selectedEdges[0].dart);
unsigned int v01 = map->getEmbedding<VERTEX>(map->phi2(selectedEdges[0].dart));
unsigned int v10 = map->getEmbedding<VERTEX>(selectedEdges[1].dart);
unsigned int v11 = map->getEmbedding<VERTEX>(map->phi2(selectedEdges[1].dart));
if (v00 == v10)
{
......@@ -497,7 +500,7 @@ void Surface_Modelisation_Plugin::deleteVertex(MapHandlerGen *mhg)
const MapParameters& p = h_parameterSet[mhg];
if(p.vertexSelector && !p.vertexSelector->getSelectedCells().empty())
{
const std::vector<Dart>& darts = p.vertexSelector->getSelectedCells();
const std::vector<Vertex>& darts = p.vertexSelector->getSelectedCells();
map->deleteVertex(darts[0]);
mh->notifyAttributeModification(p.positionAttribute);
mh->notifyConnectivityModification();
......@@ -514,10 +517,10 @@ void Surface_Modelisation_Plugin::cutEdge(MapHandlerGen *mhg)
MapParameters& p = h_parameterSet[mhg];
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty())
{
const std::vector<Dart>& edge = p.edgeSelector->getSelectedCells();
const std::vector<Edge>& edge = p.edgeSelector->getSelectedCells();
map->cutEdge(edge[0]);
p.positionAttribute[map->phi1(edge[0])] = (p.positionAttribute[edge[0]] + p.positionAttribute[map->phi1(map->phi1(edge[0]))]) / 2;
p.positionAttribute[map->phi1(edge[0].dart)] = (p.positionAttribute[edge[0].dart] + p.positionAttribute[map->phi1(map->phi1(edge[0].dart))]) / 2;
mh->notifyAttributeModification(p.positionAttribute);
mh->notifyConnectivityModification();
}
......@@ -531,7 +534,7 @@ void Surface_Modelisation_Plugin::uncutEdge(MapHandlerGen *mhg)
const MapParameters& p = h_parameterSet[mhg];
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty())
{
const std::vector<Dart>& edge = p.edgeSelector->getSelectedCells();
const std::vector<Edge>& edge = p.edgeSelector->getSelectedCells();
if (!map->uncutEdge(edge[0]))
map->uncutEdge(map->phi2(edge[0]));
mh->notifyAttributeModification(p.positionAttribute);
......@@ -547,7 +550,7 @@ void Surface_Modelisation_Plugin::collapseEdge(MapHandlerGen *mhg)
const MapParameters& p = h_parameterSet[mhg];
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty())
{
const std::vector<Dart>& edge = p.edgeSelector->getSelectedCells();
const std::vector<Edge>& edge = p.edgeSelector->getSelectedCells();
map->collapseEdge(edge[0]);
mh->notifyAttributeModification(p.positionAttribute);
mh->notifyConnectivityModification();
......@@ -562,7 +565,7 @@ void Surface_Modelisation_Plugin::flipEdge(MapHandlerGen *mhg)
const MapParameters& p = h_parameterSet[mhg];
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty())
{
const std::vector<Dart>& edge = p.edgeSelector->getSelectedCells();
const std::vector<Edge>& edge = p.edgeSelector->getSelectedCells();
map->flipEdge(edge[0]);
mh->notifyConnectivityModification();
}
......@@ -576,7 +579,7 @@ void Surface_Modelisation_Plugin::flipBackEdge(MapHandlerGen *mhg)
const MapParameters& p = h_parameterSet[mhg];
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty())
{
const std::vector<Dart>& edge = p.edgeSelector->getSelectedCells();
const std::vector<Edge>& edge = p.edgeSelector->getSelectedCells();
map->flipBackEdge(edge[0]);
mh->notifyConnectivityModification();
}
......@@ -592,7 +595,7 @@ void Surface_Modelisation_Plugin::splitFace(MapHandlerGen *mhg)
const MapParameters& p = h_parameterSet[mhg];
if(p.vertexSelector && !p.vertexSelector->getSelectedCells().empty() && (p.vertexSelector->getSelectedCells().size() == 2))
{
const std::vector<Dart>& selectedDarts = p.vertexSelector->getSelectedCells();
const std::vector<Vertex>& selectedDarts = p.vertexSelector->getSelectedCells();
bool sameFace = false;
Dart d = selectedDarts[0];
......@@ -633,7 +636,7 @@ void Surface_Modelisation_Plugin::mergeFaces(MapHandlerGen *mhg)
const MapParameters& p = h_parameterSet[mhg];
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty())
{
const std::vector<Dart>& edge = p.edgeSelector->getSelectedCells();
const std::vector<Edge>& edge = p.edgeSelector->getSelectedCells();
map->mergeFaces(edge[0]);
mh->notifyConnectivityModification();
}
......@@ -647,7 +650,7 @@ void Surface_Modelisation_Plugin::deleteFace(MapHandlerGen *mhg)
const MapParameters& p = h_parameterSet[mhg];
if(p.faceSelector && !p.faceSelector->getSelectedCells().empty())
{
const std::vector<Dart>& dart = p.faceSelector->getSelectedCells();
const std::vector<Face>& dart = p.faceSelector->getSelectedCells();
map->deleteFace(dart[0]);
mh->notifyConnectivityModification();
}
......@@ -661,7 +664,7 @@ void Surface_Modelisation_Plugin::sewFaces(MapHandlerGen *mhg)
const MapParameters& p = h_parameterSet[mhg];
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty() && (p.edgeSelector->getSelectedCells().size() == 2))
{
const std::vector<Dart>& selectedDarts = p.edgeSelector->getSelectedCells();
const std::vector<Edge>& selectedDarts = p.edgeSelector->getSelectedCells();
Dart d = selectedDarts[0];
Dart e = selectedDarts[1];
......@@ -683,7 +686,7 @@ void Surface_Modelisation_Plugin::unsewFaces(MapHandlerGen *mhg)
MapParameters& p = h_parameterSet[mhg];
if(p.edgeSelector && !p.edgeSelector->getSelectedCells().empty())
{
const std::vector<Dart>& dart = p.edgeSelector->getSelectedCells();
const std::vector<Edge>& dart = p.edgeSelector->getSelectedCells();
if (!map->isBoundaryEdge(dart[0]))
{
Dart d = dart[0];
......@@ -713,7 +716,7 @@ void Surface_Modelisation_Plugin::extrudeFace(MapHandlerGen *mhg)
MapParameters& p = h_parameterSet[mhg];
if(p.faceSelector && !p.faceSelector->getSelectedCells().empty())
{
const std::vector<Dart>& selectedDart = p.faceSelector->getSelectedCells();
const std::vector<Face>& selectedDart = p.faceSelector->getSelectedCells();
Dart d = selectedDart[0];
PFP2::REAL dist = 0;
......@@ -743,7 +746,7 @@ void Surface_Modelisation_Plugin::pathExtrudeFace(MapHandlerGen *mhg)
VertexAttribute<PFP2::VEC3, PFP2::MAP::IMPL>& position = p.positionAttribute;
if(p.faceSelector && !p.faceSelector->getSelectedCells().empty())
{
const std::vector<Dart>& selectedDart = p.faceSelector->getSelectedCells();
const std::vector<Face>& selectedDart = p.faceSelector->getSelectedCells();
Dart d = selectedDart[0];
for (unsigned int i = 0; i < collectedVertices.size(); i++)
{
......
......@@ -83,9 +83,9 @@ protected:
bool m_selecting;
// cell under the mouse when selecting
Dart m_selectingVertex;
Dart m_selectingEdge;
Dart m_selectingFace;
Vertex m_selectingVertex;
Edge m_selectingEdge;
Face m_selectingFace;
// selecting & selected cells drawing
Utils::PointSprite* m_pointSprite;
......
......@@ -88,7 +88,6 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
CellSelectorGen* selector = m_schnapps->getSelectedSelector(orbit);
if(selector)
{
const std::vector<Dart>& selectedCells = selector->getSelectedCells();
unsigned int nbCells = map->getGenericMap()->getNbCells(orbit);
switch(orbit)
{
......@@ -99,10 +98,10 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
m_pointSprite->setLightPosition(CGoGN::Geom::Vec3f(0.0f, 0.0f, 1.0f));
m_pointSprite->enableVertexAttribs();
glDrawArrays(GL_POINTS, 0, selectedCells.size());
glDrawArrays(GL_POINTS, 0, selector->getNbSelectedCells());
m_pointSprite->disableVertexAttribs();
if(m_selecting && m_selectingVertex != NIL)
if(m_selecting && m_selectingVertex.valid())
{
std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(p.positionAttribute[m_selectingVertex]);
......@@ -137,7 +136,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
case EDGE : {
m_selectedEdgesDrawer->callList();
if(m_selecting && m_selectingEdge != NIL)
if(m_selecting && m_selectingEdge.valid())
{
switch(p.selectionMethod)
{
......@@ -148,15 +147,15 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
m_selectingCellDrawer->lineWidth(6.0f);
m_selectingCellDrawer->color3f(0.0f, 0.0f, 1.0f);
m_selectingCellDrawer->begin(GL_LINES);
m_selectingCellDrawer->vertex(p.positionAttribute[m_selectingEdge]);
m_selectingCellDrawer->vertex(p.positionAttribute[m->phi1(m_selectingEdge)]);
m_selectingCellDrawer->vertex(p.positionAttribute[m_selectingEdge.dart]);
m_selectingCellDrawer->vertex(p.positionAttribute[m->phi1(m_selectingEdge.dart)]);
m_selectingCellDrawer->end();
m_selectingCellDrawer->endList();
break;
}
case WithinSphere : {
std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(p.positionAttribute[m_selectingEdge]);
selectionPoint.push_back(p.positionAttribute[m_selectingEdge.dart]);
m_selectionSphereVBO->updateData(selectionPoint);
m_pointSprite->setAttributePosition(m_selectionSphereVBO);
......@@ -179,7 +178,7 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
case FACE : {
m_selectedFacesDrawer->callList();
if(m_selecting && m_selectingFace != NIL)
if(m_selecting && m_selectingFace.valid())
{
switch(p.selectionMethod)
{
......@@ -189,16 +188,16 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
m_selectingCellDrawer->newList(GL_COMPILE_AND_EXECUTE);
m_selectingCellDrawer->color3f(0.0f, 0.0f, 1.0f);
m_selectingCellDrawer->begin(GL_TRIANGLES);
m_selectingCellDrawer->vertex(p.positionAttribute[m_selectingFace]);
m_selectingCellDrawer->vertex(p.positionAttribute[m->phi1(m_selectingFace)]);
m_selectingCellDrawer->vertex(p.positionAttribute[m->phi_1(m_selectingFace)]);
m_selectingCellDrawer->vertex(p.positionAttribute[m_selectingFace.dart]);
m_selectingCellDrawer->vertex(p.positionAttribute[m->phi1(m_selectingFace.dart)]);
m_selectingCellDrawer->vertex(p.positionAttribute[m->phi_1(m_selectingFace.dart)]);
m_selectingCellDrawer->end();
m_selectingCellDrawer->endList();
break;
}
case WithinSphere : {
std::vector<PFP2::VEC3> selectionPoint;
selectionPoint.push_back(p.positionAttribute[m_selectingFace]);
selectionPoint.push_back(p.positionAttribute[m_selectingFace.dart]);
m_selectionSphereVBO->updateData(selectionPoint);
m_pointSprite->setAttributePosition(m_selectionSphereVBO);
......@@ -261,24 +260,25 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
switch(orbit)
{
case VERTEX : {
if(m_selectingVertex != NIL)
CellSelector<PFP2::MAP, VERTEX>* cs = static_cast<CellSelector<PFP2::MAP, VERTEX>*>(selector);
if(m_selectingVertex.valid())
{
switch(p.selectionMethod)
{
case SingleCell : {
if(event->button() == Qt::LeftButton)
selector->select(m_selectingVertex);
cs->select(m_selectingVertex);
else if(event->button() == Qt::RightButton)
selector->unselect(m_selectingVertex);
cs->unselect(m_selectingVertex);
break;
}
case WithinSphere : {
Algo::Surface::Selection::Collector_WithinSphere<PFP2> neigh(*map, p.positionAttribute, m_selectionRadius);
neigh.collectAll(m_selectingVertex);
if(event->button() == Qt::LeftButton)
selector->select(neigh.getInsideVertices());
cs->select(neigh.getInsideVertices());
else if(event->button() == Qt::RightButton)
selector->unselect(neigh.getInsideVertices());
cs->unselect(neigh.getInsideVertices());
break;
}
case NormalAngle : {
......@@ -287,9 +287,9 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
Algo::Surface::Selection::Collector_NormalAngle<PFP2> neigh(*map, p.normalAttribute, m_normalAngleThreshold);
neigh.collectAll(m_selectingVertex);
if(event->button() == Qt::LeftButton)
selector->select(neigh.getInsideVertices());
cs->select(neigh.getInsideVertices());
else if(event->button() == Qt::RightButton)
selector->unselect(neigh.getInsideVertices());
cs->unselect(neigh.getInsideVertices());
}
break;
}
......@@ -299,24 +299,25 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
break;
}
case EDGE : {
if(m_selectingEdge != NIL)
CellSelector<PFP2::MAP, EDGE>* cs = static_cast<CellSelector<PFP2::MAP, EDGE>*>(selector);
if(m_selectingEdge.valid())
{
switch(p.selectionMethod)
{
case SingleCell : {
if(event->button() == Qt::LeftButton)
selector->select(m_selectingEdge);
cs->select(m_selectingEdge);
else if(event->button() == Qt::RightButton)
selector->unselect(m_selectingEdge);
cs->unselect(m_selectingEdge);
break;
}
case WithinSphere : {
Algo::Surface::Selection::Collector_WithinSphere<PFP2> neigh(*map, p.positionAttribute, m_selectionRadius);
neigh.collectAll(m_selectingEdge);
if(event->button() == Qt::LeftButton)
selector->select(neigh.getInsideEdges());
cs->select(neigh.getInsideEdges());
else if(event->button() == Qt::RightButton)
selector->unselect(neigh.getInsideEdges());
cs->unselect(neigh.getInsideEdges());
break;
}
case NormalAngle : {
......@@ -325,9 +326,9 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
Algo::Surface::Selection::Collector_NormalAngle<PFP2> neigh(*map, p.normalAttribute, m_normalAngleThreshold);
neigh.collectAll(m_selectingEdge);
if(event->button() == Qt::LeftButton)
selector->select(neigh.getInsideEdges());
cs->select(neigh.getInsideEdges());
else if(event->button() == Qt::RightButton)
selector->unselect(neigh.getInsideEdges());
cs->unselect(neigh.getInsideEdges());
}
break;
}
......@@ -337,24 +338,25 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
break;
}
case FACE : {
if(m_selectingFace != NIL)
CellSelector<PFP2::MAP, FACE>* cs = static_cast<CellSelector<PFP2::MAP, FACE>*>(selector);
if(m_selectingFace.valid())
{
switch(p.selectionMethod)
{
case SingleCell : {
if(event->button() == Qt::LeftButton)
selector->select(m_selectingFace);
cs->select(m_selectingFace);
else if(event->button() == Qt::RightButton)
selector->unselect(m_selectingFace);
cs->unselect(m_selectingFace);
break;
}
case WithinSphere : {
Algo::Surface::Selection::Collector_WithinSphere<PFP2> neigh(*map, p.positionAttribute, m_selectionRadius);
neigh.collectAll(m_selectingFace);
if(event->button() == Qt::LeftButton)
selector->select(neigh.getInsideFaces());
cs->select(neigh.getInsideFaces());
else if(event->button() == Qt::RightButton)
selector->unselect(neigh.getInsideFaces());
cs->unselect(neigh.getInsideFaces());
break;
}
case NormalAngle : {
......@@ -363,9 +365,9 @@ void Surface_Selection_Plugin::mousePress(View* view, QMouseEvent* event)
Algo::Surface::Selection::Collector_NormalAngle<PFP2> neigh(*map, p.normalAttribute, m_normalAngleThreshold);
neigh.collectAll(m_selectingFace);
if(event->button() == Qt::LeftButton)
selector->select(neigh.getInsideFaces());
cs->select(neigh.getInsideFaces());
else if(event->button() == Qt::RightButton)
selector->unselect(neigh.getInsideFaces());
cs->unselect(neigh.getInsideFaces());
}
break;
}
......@@ -496,27 +498,31 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering()
{
unsigned int orbit = m_schnapps->getCurrentOrbit();
CellSelectorGen* selector = m_schnapps->getSelectedSelector(orbit);
const std::vector<Dart>& selectedCells = selector->getSelectedCells();
switch(orbit)
{
case VERTEX : {
CellSelector<PFP2::MAP, VERTEX>* cs = static_cast<CellSelector<PFP2::MAP, VERTEX>*>(selector);
const std::vector<Vertex>& selectedCells = cs->getSelectedCells();
std::vector<PFP2::VEC3> selectedPoints;
for(std::vector<Dart>::const_iterator it = selectedCells.begin(); it != selectedCells.end(); ++it)
selectedPoints.push_back(p.positionAttribute[*it]);
for(std::vector<Vertex>::const_iterator v = selectedCells.begin(); v != selectedCells.end(); ++v)
selectedPoints.push_back(p.positionAttribute[*v]);
m_selectedVerticesVBO->updateData(selectedPoints);
break;
}
case EDGE : {
PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap();
CellSelector<PFP2::MAP, EDGE>* cs = static_cast<CellSelector<PFP2::MAP, EDGE>*>(selector);
const std::vector<Edge>& selectedCells = cs->getSelectedCells();
m_selectedEdgesDrawer->newList(GL_COMPILE);
m_selectedEdgesDrawer->lineWidth(3.0f);
m_selectedEdgesDrawer->color3f(1.0f, 0.0f, 0.0f);
m_selectedEdgesDrawer->begin(GL_LINES);
for(std::vector<Dart>::const_iterator it = selectedCells.begin(); it != selectedCells.end(); ++it)
for(std::vector<Edge>::const_iterator e = selectedCells.begin(); e != selectedCells.end(); ++e)
{
m_selectedEdgesDrawer->vertex(p.positionAttribute[*it]);
m_selectedEdgesDrawer->vertex(p.positionAttribute[m->phi1(*it)]);
m_selectedEdgesDrawer->vertex(p.positionAttribute[(*e).dart]);
m_selectedEdgesDrawer->vertex(p.positionAttribute[m->phi1((*e).dart)]);
}
m_selectedEdgesDrawer->end();
m_selectedEdgesDrawer->endList();
......@@ -525,14 +531,17 @@ void Surface_Selection_Plugin::updateSelectedCellsRendering()
case FACE : {
PFP2::MAP* m = static_cast<MapHandler<PFP2>*>(map)->getMap();
CellSelector<PFP2::MAP, FACE>* cs = static_cast<CellSelector<PFP2::MAP, FACE>*>(selector);
const std::vector<Face>& selectedCells = cs->getSelectedCells();
m_selectedFacesDrawer->newList(GL_COMPILE);
m_selectedFacesDrawer->color3f(1.0f, 0.0f, 0.0f);
m_selectedFacesDrawer->begin(GL_TRIANGLES);
for(std::vector<Dart>::const_iterator it = selectedCells.begin(); it != selectedCells.end(); ++it)
for(std::vector<Face>::const_iterator f = selectedCells.begin(); f != selectedCells.end(); ++f)
{
m_selectedFacesDrawer->vertex(p.positionAttribute[*it]);
m_selectedFacesDrawer->vertex(p.positionAttribute[m->phi1(*it)]);
m_selectedFacesDrawer->vertex(p.positionAttribute[m->phi_1(*it)]);
m_selectedFacesDrawer->vertex(p.positionAttribute[(*f).dart]);
m_selectedFacesDrawer->vertex(p.positionAttribute[m->phi1((*f).dart)]);
m_selectedFacesDrawer->vertex(p.positionAttribute[m->phi_1((*f).dart)]);
}
m_selectedFacesDrawer->end();
m_selectedFacesDrawer->endList();
......
......@@ -28,48 +28,12 @@ public:
inline const QString& getName() { return m_name; }
inline const std::vector<Dart>& getSelectedCells() { return m_cells; }
virtual inline unsigned int getOrbit() const = 0;
virtual unsigned int getOrbit() = 0;
virtual void select(Dart d, bool emitSignal = true) = 0;
virtual void unselect(Dart d, bool emitSignal = true) = 0;
inline void select(const std::vector<Dart>& d)
{
for(unsigned int i = 0; i < d.size(); ++i)
select(d[i], false);
checkChange();
if(m_isMutuallyExclusive && !m_mutuallyExclusive.empty())
{
foreach(CellSelectorGen* cs, m_mutuallyExclusive)
cs->checkChange();
}
}
inline void unselect(const std::vector<Dart>& d)
{
for(unsigned int i = 0; i < d.size(); ++i)
unselect(d[i], false);
checkChange();
}
virtual bool isSelected(Dart d) = 0;
virtual inline unsigned int getNbSelectedCells() const = 0;
virtual void rebuild() = 0;
inline void setMutuallyExclusive(bool b) { m_isMutuallyExclusive = b; }
inline bool isMutuallyExclusive() const { return m_isMutuallyExclusive; }
inline void setMutuallyExclusiveSet(const QList<CellSelectorGen*>& mex)
{
m_mutuallyExclusive.clear();
foreach(CellSelectorGen* cs, mex)
{
if(cs != this)
m_mutuallyExclusive.append(cs);
}
}
inline void checkChange()
{
if(m_selectionChanged)
......@@ -79,22 +43,25 @@ public:
}
}
inline void setMutuallyExclusive(bool b) { m_isMutuallyExclusive = b; }
inline bool isMutuallyExclusive() const { return m_isMutuallyExclusive; }
virtual inline void setMutuallyExclusiveSet(const QList<CellSelectorGen*>& mex) = 0;
signals:
void selectedCellsChanged();
protected:
QString m_name;
std::vector<Dart> m_cells;
bool m_selectionChanged;
bool m_isMutuallyExclusive;
QList<CellSelectorGen*> m_mutuallyExclusive;
bool m_selectionChanged;
};