mirror of https://github.com/CGAL/cgal
Move SMesh definition and its property_maps to a dedicated header.
This commit is contained in:
parent
298bed08c1
commit
ca23909bb1
|
|
@ -51,8 +51,6 @@ public:
|
|||
|
||||
CGAL::Three::Scene_item* Surf_io_plugin::load(QFileInfo fileinfo)
|
||||
{
|
||||
typedef Scene_surface_mesh_item::SMesh SMesh;
|
||||
typedef Scene_surface_mesh_item::Point Point;
|
||||
// Open file
|
||||
std::ifstream in(fileinfo.filePath().toUtf8());
|
||||
if(!in) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
Scene_surface_mesh_item::SMesh *surface_mesh = new Scene_surface_mesh_item::SMesh();
|
||||
SMesh *surface_mesh = new SMesh();
|
||||
in >> *surface_mesh;
|
||||
if(!in || surface_mesh->is_empty())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -93,9 +93,9 @@ QList<QAction*> Polyhedron_demo_orient_soup_plugin::actions() const {
|
|||
<< actionDisplayNonManifoldEdges;
|
||||
}
|
||||
|
||||
void set_vcolors(Scene_surface_mesh_item::SMesh* smesh, std::vector<CGAL::Color> colors)
|
||||
void set_vcolors(SMesh* smesh, std::vector<CGAL::Color> colors)
|
||||
{
|
||||
typedef Scene_surface_mesh_item::SMesh SMesh;
|
||||
typedef SMesh SMesh;
|
||||
typedef boost::graph_traits<SMesh>::vertex_descriptor vertex_descriptor;
|
||||
SMesh::Property_map<vertex_descriptor, CGAL::Color> vcolors =
|
||||
smesh->property_map<vertex_descriptor, CGAL::Color >("v:color").first;
|
||||
|
|
@ -107,9 +107,9 @@ void set_vcolors(Scene_surface_mesh_item::SMesh* smesh, std::vector<CGAL::Color>
|
|||
vcolors[vd] = colors[color_id++];
|
||||
}
|
||||
|
||||
void set_fcolors(Scene_surface_mesh_item::SMesh* smesh, std::vector<CGAL::Color> colors)
|
||||
void set_fcolors(SMesh* smesh, std::vector<CGAL::Color> colors)
|
||||
{
|
||||
typedef Scene_surface_mesh_item::SMesh SMesh;
|
||||
typedef SMesh SMesh;
|
||||
typedef boost::graph_traits<SMesh>::face_descriptor face_descriptor;
|
||||
SMesh::Property_map<face_descriptor, CGAL::Color> fcolors =
|
||||
smesh->property_map<face_descriptor, CGAL::Color >("f:color").first;
|
||||
|
|
@ -179,7 +179,7 @@ void Polyhedron_demo_orient_soup_plugin::orientSM()
|
|||
.arg(item->name()));
|
||||
}
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
Scene_surface_mesh_item::SMesh* smesh = new Scene_surface_mesh_item::SMesh();
|
||||
SMesh* smesh = new SMesh();
|
||||
if(item->exportAsSurfaceMesh(smesh)) {
|
||||
if(!item->getVColors().empty())
|
||||
set_vcolors(smesh,item->getVColors());
|
||||
|
|
|
|||
|
|
@ -26,17 +26,17 @@
|
|||
|
||||
#ifdef USE_SURFACE_MESH
|
||||
typedef Scene_surface_mesh_item Scene_facegraph_item;
|
||||
typedef Scene_surface_mesh_item::Kernel FG_Traits;
|
||||
typedef EPICK FG_Traits;
|
||||
#else
|
||||
typedef Scene_polyhedron_item Scene_facegraph_item;
|
||||
typedef Kernel FG_Traits;
|
||||
#endif
|
||||
|
||||
typedef Scene_facegraph_item::FaceGraph FaceGraph;
|
||||
typedef boost::graph_traits<FaceGraph>::vertex_descriptor vertex_descriptor;
|
||||
typedef boost::graph_traits<FaceGraph>::edge_descriptor edge_descriptor;
|
||||
typedef boost::graph_traits<FaceGraph>::face_descriptor face_descriptor;
|
||||
typedef boost::graph_traits<FaceGraph>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef boost::graph_traits<FaceGraph>::vertex_descriptor fg_vertex_descriptor;
|
||||
typedef boost::graph_traits<FaceGraph>::edge_descriptor fg_edge_descriptor;
|
||||
typedef boost::graph_traits<FaceGraph>::face_descriptor fg_face_descriptor;
|
||||
typedef boost::graph_traits<FaceGraph>::halfedge_descriptor fg_halfedge_descriptor;
|
||||
|
||||
struct FG_is_selected_edge_property_map{
|
||||
typedef boost::property_map<FaceGraph,boost::edge_index_t>::type EImap;
|
||||
|
|
@ -49,17 +49,17 @@ struct FG_is_selected_edge_property_map{
|
|||
: is_selected_ptr( &is_selected), edge_index_map(map)
|
||||
{}
|
||||
|
||||
std::size_t id(edge_descriptor ed) {
|
||||
std::size_t id(fg_edge_descriptor ed) {
|
||||
return get(*edge_index_map, ed);
|
||||
}
|
||||
|
||||
friend bool get(FG_is_selected_edge_property_map map, edge_descriptor ed)
|
||||
friend bool get(FG_is_selected_edge_property_map map, fg_edge_descriptor ed)
|
||||
{
|
||||
CGAL_assertion(map.is_selected_ptr!=NULL);
|
||||
return (*map.is_selected_ptr)[map.id(ed)];
|
||||
}
|
||||
|
||||
friend void put(FG_is_selected_edge_property_map map, edge_descriptor ed, bool b)
|
||||
friend void put(FG_is_selected_edge_property_map map, fg_edge_descriptor ed, bool b)
|
||||
{
|
||||
CGAL_assertion(map.is_selected_ptr!=NULL);
|
||||
(*map.is_selected_ptr)[map.id(ed)]=b;
|
||||
|
|
@ -155,7 +155,7 @@ public Q_SLOTS:
|
|||
{
|
||||
#ifdef USE_SURFACE_MESH
|
||||
std::size_t h = reinterpret_cast<std::size_t>(void_ptr);
|
||||
process_selection( static_cast<vertex_descriptor>(h) );
|
||||
process_selection( static_cast<fg_vertex_descriptor>(h) );
|
||||
#else
|
||||
process_selection( static_cast<Polyhedron::Vertex*>(void_ptr)->halfedge()->vertex() );
|
||||
#endif
|
||||
|
|
@ -170,7 +170,7 @@ public Q_SLOTS:
|
|||
{
|
||||
#ifdef USE_SURFACE_MESH
|
||||
std::size_t h = reinterpret_cast<std::size_t>(void_ptr);
|
||||
process_selection( static_cast<face_descriptor>(h) );
|
||||
process_selection( static_cast<fg_face_descriptor>(h) );
|
||||
#else
|
||||
process_selection( static_cast<Polyhedron::Facet*>(void_ptr)->halfedge()->facet() );
|
||||
#endif
|
||||
|
|
@ -184,7 +184,7 @@ public Q_SLOTS:
|
|||
{
|
||||
#ifdef USE_SURFACE_MESH
|
||||
std::size_t h = reinterpret_cast<std::size_t>(void_ptr);
|
||||
process_selection( static_cast<edge_descriptor>(h) );
|
||||
process_selection( static_cast<fg_edge_descriptor>(h) );
|
||||
#else
|
||||
process_selection( edge(static_cast<Polyhedron::Halfedge*>(void_ptr)->opposite()->opposite(), *poly_item->polyhedron()) );
|
||||
#endif
|
||||
|
|
@ -221,12 +221,12 @@ public Q_SLOTS:
|
|||
qglviewer::Camera* camera = viewer->camera();
|
||||
const FaceGraph& poly = *poly_item->polyhedron();
|
||||
|
||||
std::set<face_descriptor> face_sel;
|
||||
std::set<fg_face_descriptor> face_sel;
|
||||
boost::property_map<FaceGraph,CGAL::vertex_point_t>::const_type vpmap = get(boost::vertex_point, poly);
|
||||
//select all faces if their screen projection is inside the lasso
|
||||
BOOST_FOREACH(face_descriptor f, faces(poly))
|
||||
BOOST_FOREACH(fg_face_descriptor f, faces(poly))
|
||||
{
|
||||
BOOST_FOREACH(vertex_descriptor v, CGAL::vertices_around_face(halfedge(f, poly), poly))
|
||||
BOOST_FOREACH(fg_vertex_descriptor v, CGAL::vertices_around_face(halfedge(f, poly), poly))
|
||||
{
|
||||
FG_Traits::Point_3 p = get(vpmap, v);
|
||||
qglviewer::Vec vp(p.x(), p.y(), p.z());
|
||||
|
|
@ -244,13 +244,13 @@ public Q_SLOTS:
|
|||
return;
|
||||
}
|
||||
//get border edges of the selected patches
|
||||
std::vector<halfedge_descriptor> boundary_edges;
|
||||
std::vector<fg_halfedge_descriptor> boundary_edges;
|
||||
CGAL::Polygon_mesh_processing::border_halfedges(face_sel, poly, std::back_inserter(boundary_edges));
|
||||
std::vector<bool> mark(edges(poly).size(), false);
|
||||
boost::property_map<FaceGraph, boost::edge_index_t>::type edge_index
|
||||
= get(boost::edge_index, poly);
|
||||
FG_is_selected_edge_property_map spmap(mark, &edge_index);
|
||||
BOOST_FOREACH(halfedge_descriptor h, boundary_edges)
|
||||
BOOST_FOREACH(fg_halfedge_descriptor h, boundary_edges)
|
||||
put(spmap, edge(h, poly), true);
|
||||
|
||||
boost::vector_property_map<int,
|
||||
|
|
@ -258,14 +258,14 @@ public Q_SLOTS:
|
|||
fccmap;
|
||||
|
||||
//get connected componant from the picked face
|
||||
std::set<face_descriptor> final_sel;
|
||||
std::set<fg_face_descriptor> final_sel;
|
||||
//std::vector<Polyhedron::Face_handle> cc;
|
||||
std::size_t nb_cc = CGAL::Polygon_mesh_processing::connected_components(poly
|
||||
, fccmap
|
||||
, CGAL::Polygon_mesh_processing::parameters::edge_is_constrained_map(spmap));
|
||||
std::vector<bool> is_cc_done(nb_cc, false);
|
||||
|
||||
BOOST_FOREACH(face_descriptor f, face_sel)
|
||||
BOOST_FOREACH(fg_face_descriptor f, face_sel)
|
||||
{
|
||||
|
||||
int cc_id = get(fccmap, f);
|
||||
|
|
@ -299,7 +299,7 @@ public Q_SLOTS:
|
|||
is_cc_done[cc_id] = true;
|
||||
}
|
||||
}
|
||||
BOOST_FOREACH(face_descriptor f, faces(poly))
|
||||
BOOST_FOREACH(fg_face_descriptor f, faces(poly))
|
||||
{
|
||||
if(is_cc_done[get(fccmap, f)])
|
||||
final_sel.insert(f);
|
||||
|
|
@ -311,10 +311,10 @@ public Q_SLOTS:
|
|||
break;
|
||||
case Active_handle::EDGE:
|
||||
{
|
||||
std::set<edge_descriptor> e_sel;
|
||||
BOOST_FOREACH(face_descriptor f, final_sel)
|
||||
std::set<fg_edge_descriptor> e_sel;
|
||||
BOOST_FOREACH(fg_face_descriptor f, final_sel)
|
||||
{
|
||||
BOOST_FOREACH(halfedge_descriptor h, CGAL::halfedges_around_face(halfedge(f, poly), poly))
|
||||
BOOST_FOREACH(fg_halfedge_descriptor h, CGAL::halfedges_around_face(halfedge(f, poly), poly))
|
||||
{
|
||||
FG_Traits::Point_3 p = get(vpmap, target(h, poly));
|
||||
qglviewer::Vec vp1(p.x(), p.y(), p.z());
|
||||
|
|
@ -331,10 +331,10 @@ public Q_SLOTS:
|
|||
}
|
||||
case Active_handle::VERTEX:
|
||||
{
|
||||
std::set<vertex_descriptor> v_sel;
|
||||
BOOST_FOREACH(face_descriptor f, final_sel)
|
||||
std::set<fg_vertex_descriptor> v_sel;
|
||||
BOOST_FOREACH(fg_face_descriptor f, final_sel)
|
||||
{
|
||||
BOOST_FOREACH(vertex_descriptor v, CGAL::vertices_around_face(halfedge(f, poly), poly))
|
||||
BOOST_FOREACH(fg_vertex_descriptor v, CGAL::vertices_around_face(halfedge(f, poly), poly))
|
||||
{
|
||||
FG_Traits::Point_3 p = get(vpmap, v);
|
||||
qglviewer::Vec vp(p.x(), p.y(), p.z());
|
||||
|
|
@ -379,12 +379,12 @@ public Q_SLOTS:
|
|||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void selected(const std::set<vertex_descriptor>&);
|
||||
void selected(const std::set<face_descriptor>&);
|
||||
void selected(const std::set<edge_descriptor>&);
|
||||
void selected_HL(const std::set<vertex_descriptor>&);
|
||||
void selected_HL(const std::set<face_descriptor>&);
|
||||
void selected_HL(const std::set<edge_descriptor>&);
|
||||
void selected(const std::set<fg_vertex_descriptor>&);
|
||||
void selected(const std::set<fg_face_descriptor>&);
|
||||
void selected(const std::set<fg_edge_descriptor>&);
|
||||
void selected_HL(const std::set<fg_vertex_descriptor>&);
|
||||
void selected_HL(const std::set<fg_face_descriptor>&);
|
||||
void selected_HL(const std::set<fg_edge_descriptor>&);
|
||||
void toogle_insert(const bool);
|
||||
void endSelection();
|
||||
void resetIsTreated();
|
||||
|
|
@ -436,47 +436,47 @@ protected:
|
|||
}
|
||||
};
|
||||
|
||||
std::set<vertex_descriptor>
|
||||
extract_k_ring(vertex_descriptor clicked, unsigned int k)
|
||||
std::set<fg_vertex_descriptor>
|
||||
extract_k_ring(fg_vertex_descriptor clicked, unsigned int k)
|
||||
{
|
||||
std::set<vertex_descriptor> selection;
|
||||
std::set<fg_vertex_descriptor> selection;
|
||||
selection.insert(clicked);
|
||||
if (k>0)
|
||||
CGAL::expand_vertex_selection(CGAL::make_array(clicked),
|
||||
*poly_item->polyhedron(),
|
||||
k,
|
||||
Is_selected_from_set<vertex_descriptor>(selection),
|
||||
Is_selected_from_set<fg_vertex_descriptor>(selection),
|
||||
CGAL::Emptyset_iterator());
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
std::set<face_descriptor>
|
||||
extract_k_ring(face_descriptor clicked, unsigned int k)
|
||||
std::set<fg_face_descriptor>
|
||||
extract_k_ring(fg_face_descriptor clicked, unsigned int k)
|
||||
{
|
||||
std::set<face_descriptor> selection;
|
||||
std::set<fg_face_descriptor> selection;
|
||||
selection.insert(clicked);
|
||||
if (k>0)
|
||||
CGAL::expand_face_selection(CGAL::make_array(clicked),
|
||||
*poly_item->polyhedron(),
|
||||
k,
|
||||
Is_selected_from_set<face_descriptor>(selection),
|
||||
Is_selected_from_set<fg_face_descriptor>(selection),
|
||||
CGAL::Emptyset_iterator());
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
std::set<edge_descriptor>
|
||||
extract_k_ring(edge_descriptor clicked, unsigned int k)
|
||||
std::set<fg_edge_descriptor>
|
||||
extract_k_ring(fg_edge_descriptor clicked, unsigned int k)
|
||||
{
|
||||
std::set<edge_descriptor> selection;
|
||||
std::set<fg_edge_descriptor> selection;
|
||||
selection.insert(clicked);
|
||||
|
||||
if (k>0)
|
||||
CGAL::expand_edge_selection(CGAL::make_array(clicked),
|
||||
*poly_item->polyhedron(),
|
||||
k,
|
||||
Is_selected_from_set<edge_descriptor>(selection),
|
||||
Is_selected_from_set<fg_edge_descriptor>(selection),
|
||||
CGAL::Emptyset_iterator());
|
||||
return selection;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ bool selfIntersect(Mesh* mesh, std::vector<std::pair<typename boost::graph_trait
|
|||
|
||||
void Polyhedron_demo_self_intersection_plugin::on_actionSelfIntersection_triggered()
|
||||
{
|
||||
typedef Scene_surface_mesh_item::SMesh Surface_mesh;
|
||||
typedef SMesh Surface_mesh;
|
||||
typedef boost::graph_traits<Surface_mesh>::face_descriptor Face_descriptor;
|
||||
typedef boost::graph_traits<Surface_mesh>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef Surface_mesh::Vertex_index Vertex_index;
|
||||
|
|
|
|||
|
|
@ -530,12 +530,12 @@ void Polyhedron_demo_edit_polyhedron_plugin::importSelection(Scene_polyhedron_se
|
|||
{
|
||||
|
||||
//converts the selection in selected points
|
||||
QVector<Scene_polyhedron_selection_item::vertex_descriptor> sel_to_import;
|
||||
Q_FOREACH(Scene_polyhedron_selection_item::vertex_descriptor vh, selection_item->selected_vertices)
|
||||
QVector<Scene_polyhedron_selection_item::fg_vertex_descriptor> sel_to_import;
|
||||
Q_FOREACH(Scene_polyhedron_selection_item::fg_vertex_descriptor vh, selection_item->selected_vertices)
|
||||
sel_to_import.push_back(vh);
|
||||
Q_FOREACH(Scene_polyhedron_selection_item::edge_descriptor ed, selection_item->selected_edges)
|
||||
Q_FOREACH(Scene_polyhedron_selection_item::fg_edge_descriptor ed, selection_item->selected_edges)
|
||||
{
|
||||
Scene_polyhedron_selection_item::vertex_descriptor vh = source(halfedge(ed, *selection_item->polyhedron()),*selection_item->polyhedron());
|
||||
Scene_polyhedron_selection_item::fg_vertex_descriptor vh = source(halfedge(ed, *selection_item->polyhedron()),*selection_item->polyhedron());
|
||||
if(!sel_to_import.contains(vh))
|
||||
sel_to_import.push_back(vh);
|
||||
|
||||
|
|
@ -544,7 +544,7 @@ void Polyhedron_demo_edit_polyhedron_plugin::importSelection(Scene_polyhedron_se
|
|||
sel_to_import.push_back(vh);
|
||||
}
|
||||
|
||||
Q_FOREACH(Scene_polyhedron_selection_item::face_descriptor fh, selection_item->selected_facets)
|
||||
Q_FOREACH(Scene_polyhedron_selection_item::fg_face_descriptor fh, selection_item->selected_facets)
|
||||
{
|
||||
CGAL::Halfedge_around_face_circulator<Scene_facegraph_item::FaceGraph> hafc(halfedge(fh, *selection_item->polyhedron()), *selection_item->polyhedron());
|
||||
CGAL::Halfedge_around_face_circulator<Scene_facegraph_item::FaceGraph> end = hafc;
|
||||
|
|
@ -556,7 +556,7 @@ void Polyhedron_demo_edit_polyhedron_plugin::importSelection(Scene_polyhedron_se
|
|||
}
|
||||
|
||||
//makes the selected points ROI
|
||||
Q_FOREACH(Scene_polyhedron_selection_item::vertex_descriptor vh, sel_to_import)
|
||||
Q_FOREACH(Scene_polyhedron_selection_item::fg_vertex_descriptor vh, sel_to_import)
|
||||
{
|
||||
edit_item->insert_roi_vertex(vh);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
#include <QGLShader>
|
||||
#include <QGLShaderProgram>
|
||||
|
||||
typedef Scene_surface_mesh_item::SMesh SMesh;
|
||||
|
||||
typedef boost::graph_traits<SMesh>::vertex_descriptor sm_vertex_descriptor;
|
||||
typedef boost::graph_traits<SMesh>::edge_descriptor sm_edge_descriptor;
|
||||
typedef boost::graph_traits<SMesh>::face_descriptor sm_face_descriptor;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
#ifndef SMESH_TYPE_H
|
||||
#define SMESH_TYPE_H
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <CGAL/Surface_mesh/Surface_mesh_fwd.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/properties.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Polygon_mesh_processing/properties.h>
|
||||
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel EPICK;
|
||||
typedef EPICK::Point_3 Point_3;
|
||||
typedef CGAL::Surface_mesh<Point_3> SMesh;
|
||||
typedef boost::graph_traits<SMesh>::face_descriptor face_descriptor;
|
||||
typedef boost::graph_traits<SMesh>::vertex_descriptor vertex_descriptor;
|
||||
typedef boost::graph_traits<SMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
|
||||
|
||||
|
||||
namespace CGAL{
|
||||
SMesh::Property_map<boost::graph_traits<SMesh>::halfedge_descriptor,bool>
|
||||
inline get(CGAL::halfedge_is_feature_t, SMesh& smesh)
|
||||
{
|
||||
typedef boost::graph_traits<SMesh >::halfedge_descriptor halfedge_descriptor;
|
||||
return smesh.add_property_map<halfedge_descriptor,bool>("h:is_feature").first;
|
||||
}
|
||||
|
||||
|
||||
SMesh::Property_map< boost::graph_traits<SMesh >::face_descriptor,int>
|
||||
inline get(CGAL::face_patch_id_t, SMesh& smesh)
|
||||
{
|
||||
typedef boost::graph_traits<SMesh >::face_descriptor face_descriptor;
|
||||
return smesh.add_property_map<face_descriptor,int>("f:patch_id").first;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SMesh::Property_map< boost::graph_traits<SMesh >::face_descriptor,int>
|
||||
inline get(CGAL::face_selection_t, SMesh& smesh)
|
||||
{
|
||||
typedef boost::graph_traits<SMesh >::face_descriptor face_descriptor;
|
||||
return smesh.add_property_map<face_descriptor,int>("f:selection").first;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SMesh::Property_map< boost::graph_traits<SMesh >::vertex_descriptor,int>
|
||||
inline get(CGAL::vertex_selection_t, SMesh& smesh)
|
||||
{
|
||||
typedef boost::graph_traits<SMesh >::vertex_descriptor vertex_descriptor;
|
||||
return smesh.add_property_map<vertex_descriptor,int>("v:selection").first;
|
||||
}
|
||||
|
||||
|
||||
SMesh::Property_map< boost::graph_traits<SMesh >::vertex_descriptor,int>
|
||||
inline get(CGAL::vertex_num_feature_edges_t, SMesh& smesh)
|
||||
{
|
||||
typedef boost::graph_traits<SMesh >::vertex_descriptor vertex_descriptor;
|
||||
return smesh.add_property_map<vertex_descriptor,int>("v:nfe").first;
|
||||
}
|
||||
}
|
||||
namespace boost
|
||||
{
|
||||
template<>
|
||||
struct property_map<SMesh, CGAL::halfedge_is_feature_t>
|
||||
{
|
||||
typedef boost::graph_traits<SMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
|
||||
typedef SMesh::Property_map<halfedge_descriptor, bool> type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct property_map<SMesh, CGAL::face_patch_id_t>
|
||||
{
|
||||
typedef boost::graph_traits<SMesh>::face_descriptor face_descriptor;
|
||||
|
||||
typedef SMesh::Property_map<face_descriptor, int> type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct property_map<SMesh, CGAL::vertex_selection_t>
|
||||
{
|
||||
|
||||
typedef boost::graph_traits<SMesh>::vertex_descriptor vertex_descriptor;
|
||||
|
||||
typedef SMesh::Property_map<vertex_descriptor, int> type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct property_map<SMesh, CGAL::face_selection_t>
|
||||
{
|
||||
|
||||
typedef boost::graph_traits<SMesh>::face_descriptor face_descriptor;
|
||||
|
||||
typedef SMesh::Property_map<face_descriptor, int> type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct property_map<SMesh, CGAL::vertex_num_feature_edges_t>
|
||||
{
|
||||
|
||||
typedef boost::graph_traits<SMesh>::vertex_descriptor vertex_descriptor;
|
||||
|
||||
typedef SMesh::Property_map<vertex_descriptor, int> type;
|
||||
};
|
||||
} //boost
|
||||
|
||||
|
||||
#endif // SMESH_TYPE_H
|
||||
|
|
@ -639,7 +639,7 @@ Scene_polygon_soup_item::exportAsPolyhedron(Polyhedron* out_polyhedron)
|
|||
}
|
||||
|
||||
bool
|
||||
Scene_polygon_soup_item::exportAsSurfaceMesh(CGAL::Surface_mesh<Point_3> *out_surface_mesh)
|
||||
Scene_polygon_soup_item::exportAsSurfaceMesh(SMesh *out_surface_mesh)
|
||||
{
|
||||
orient();
|
||||
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh< CGAL::Surface_mesh<Point_3> >(
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include <CGAL/Three/Scene_item.h>
|
||||
#include "Polyhedron_type.h"
|
||||
|
||||
#include "CGAL/Surface_mesh/Surface_mesh.h"
|
||||
#include "SMesh_type.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/array.hpp>
|
||||
|
|
@ -147,7 +147,7 @@ public Q_SLOTS:
|
|||
void shuffle_orientations();
|
||||
bool orient();
|
||||
bool exportAsPolyhedron(Polyhedron*);
|
||||
bool exportAsSurfaceMesh(CGAL::Surface_mesh<Point_3>*);
|
||||
bool exportAsSurfaceMesh(SMesh*);
|
||||
void inside_out();
|
||||
|
||||
void setDisplayNonManifoldEdges(const bool);
|
||||
|
|
|
|||
|
|
@ -918,12 +918,13 @@ invalidate_stats()
|
|||
genus = -1;
|
||||
}
|
||||
|
||||
//vertex_index is the storage for selection
|
||||
Scene_polyhedron_item::Vertex_selection_map
|
||||
Scene_polyhedron_item::vertex_selection_map()
|
||||
{
|
||||
return get(boost::vertex_index,*d->poly);
|
||||
}
|
||||
|
||||
//face_index is the storage for selection
|
||||
Scene_polyhedron_item::Face_selection_map
|
||||
Scene_polyhedron_item::face_selection_map()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ public:
|
|||
typedef boost::graph_traits<Polyhedron>::edge_descriptor poly_edge_descriptor;
|
||||
typedef boost::graph_traits<Polyhedron>::face_descriptor poly_face_descriptor;
|
||||
typedef boost::graph_traits<Polyhedron>::vertex_descriptor poly_vertex_descriptor;
|
||||
typedef Scene_surface_mesh_item::SMesh SMesh;
|
||||
typedef boost::graph_traits<SMesh>::vertex_descriptor sm_vertex_descriptor;
|
||||
typedef boost::graph_traits<SMesh>::face_descriptor sm_face_descriptor;
|
||||
typedef boost::graph_traits<SMesh>::edge_descriptor sm_edge_descriptor;
|
||||
|
|
|
|||
|
|
@ -32,20 +32,20 @@ typedef boost::property_map<Face_graph,CGAL::vertex_point_t>::const_type constVP
|
|||
|
||||
typedef Scene_face_graph_item::Vertex_selection_map Vertex_selection_map;
|
||||
|
||||
typedef boost::graph_traits<Face_graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::face_descriptor face_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::edge_descriptor edge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::vertex_descriptor fg_vertex_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::face_descriptor fg_face_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::edge_descriptor fg_edge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::halfedge_descriptor fg_halfedge_descriptor;
|
||||
|
||||
struct Scene_polyhedron_selection_item_priv{
|
||||
|
||||
typedef Scene_facegraph_item_k_ring_selection::Active_handle Active_handle;
|
||||
typedef boost::unordered_set<vertex_descriptor, CGAL::Handle_hash_function> Selection_set_vertex;
|
||||
typedef boost::unordered_set<face_descriptor, CGAL::Handle_hash_function> Selection_set_facet;
|
||||
typedef boost::unordered_set<edge_descriptor, CGAL::Handle_hash_function> Selection_set_edge;
|
||||
typedef boost::unordered_set<fg_vertex_descriptor, CGAL::Handle_hash_function> Selection_set_vertex;
|
||||
typedef boost::unordered_set<fg_face_descriptor, CGAL::Handle_hash_function> Selection_set_facet;
|
||||
typedef boost::unordered_set<fg_edge_descriptor, CGAL::Handle_hash_function> Selection_set_edge;
|
||||
struct vertex_on_path
|
||||
{
|
||||
vertex_descriptor vertex;
|
||||
fg_vertex_descriptor vertex;
|
||||
bool is_constrained;
|
||||
};
|
||||
|
||||
|
|
@ -62,12 +62,12 @@ struct Scene_polyhedron_selection_item_priv{
|
|||
const Selection_set_vertex& p_sel_vertex, const Selection_set_facet &p_sel_facet, const Selection_set_edge &p_sel_edges) const;
|
||||
void compute_temp_elements() const;
|
||||
void compute_HL_elements() const;
|
||||
void triangulate_facet(face_descriptor, Kernel::Vector_3 normal,
|
||||
void triangulate_facet(fg_face_descriptor, Kernel::Vector_3 normal,
|
||||
std::vector<float> &p_facets,std::vector<float> &p_normals) const;
|
||||
void tempInstructions(QString s1, QString s2);
|
||||
|
||||
void computeAndDisplayPath();
|
||||
void addVertexToPath(vertex_descriptor, vertex_on_path &);
|
||||
void addVertexToPath(fg_vertex_descriptor, vertex_on_path &);
|
||||
|
||||
enum VAOs{
|
||||
Facets = 0,
|
||||
|
|
@ -101,7 +101,7 @@ struct Scene_polyhedron_selection_item_priv{
|
|||
};
|
||||
|
||||
QList<vertex_on_path> path;
|
||||
QList<vertex_descriptor> constrained_vertices;
|
||||
QList<fg_vertex_descriptor> constrained_vertices;
|
||||
bool is_path_selecting;
|
||||
bool poly_need_update;
|
||||
mutable bool are_temp_buffers_filled;
|
||||
|
|
@ -110,17 +110,17 @@ struct Scene_polyhedron_selection_item_priv{
|
|||
int operation_mode;
|
||||
QString m_temp_instructs;
|
||||
bool is_treated;
|
||||
vertex_descriptor to_split_vh;
|
||||
face_descriptor to_split_fh;
|
||||
edge_descriptor to_join_ed;
|
||||
fg_vertex_descriptor to_split_vh;
|
||||
fg_face_descriptor to_split_fh;
|
||||
fg_edge_descriptor to_join_ed;
|
||||
Active_handle::Type original_sel_mode;
|
||||
//Only needed for the triangulation
|
||||
Face_graph* poly;
|
||||
CGAL::Unique_hash_map<face_descriptor, Kernel::Vector_3> face_normals_map;
|
||||
CGAL::Unique_hash_map<vertex_descriptor, Kernel::Vector_3> vertex_normals_map;
|
||||
boost::associative_property_map< CGAL::Unique_hash_map<face_descriptor, Kernel::Vector_3> >
|
||||
CGAL::Unique_hash_map<fg_face_descriptor, Kernel::Vector_3> face_normals_map;
|
||||
CGAL::Unique_hash_map<fg_vertex_descriptor, Kernel::Vector_3> vertex_normals_map;
|
||||
boost::associative_property_map< CGAL::Unique_hash_map<fg_face_descriptor, Kernel::Vector_3> >
|
||||
nf_pmap;
|
||||
boost::associative_property_map< CGAL::Unique_hash_map<vertex_descriptor, Kernel::Vector_3> >
|
||||
boost::associative_property_map< CGAL::Unique_hash_map<fg_vertex_descriptor, Kernel::Vector_3> >
|
||||
nv_pmap;
|
||||
Scene_face_graph_item::ManipulatedFrame *manipulated_frame;
|
||||
bool ready_to_move;
|
||||
|
|
@ -133,8 +133,8 @@ struct Scene_polyhedron_selection_item_priv{
|
|||
Face_graph* polyhedron() { return poly; }
|
||||
const Face_graph* polyhedron()const { return poly; }
|
||||
|
||||
bool canAddFace(halfedge_descriptor hc, Scene_polyhedron_selection_item::halfedge_descriptor t);
|
||||
bool canAddFaceAndVertex(Scene_polyhedron_selection_item::halfedge_descriptor hc, Scene_polyhedron_selection_item::halfedge_descriptor t);
|
||||
bool canAddFace(fg_halfedge_descriptor hc, Scene_polyhedron_selection_item::fg_halfedge_descriptor t);
|
||||
bool canAddFaceAndVertex(Scene_polyhedron_selection_item::fg_halfedge_descriptor hc, Scene_polyhedron_selection_item::fg_halfedge_descriptor t);
|
||||
|
||||
mutable std::vector<float> positions_facets;
|
||||
mutable std::vector<float> normals;
|
||||
|
|
@ -424,10 +424,10 @@ typedef Traits::Point_3 Point;
|
|||
typedef Traits::Vector_3 Vector;
|
||||
|
||||
void
|
||||
Scene_polyhedron_selection_item_priv::triangulate_facet(face_descriptor fit,const Vector normal,
|
||||
Scene_polyhedron_selection_item_priv::triangulate_facet(fg_face_descriptor fit,const Vector normal,
|
||||
std::vector<float> &p_facets,std::vector<float> &p_normals ) const
|
||||
{
|
||||
typedef FacetTriangulator<Face_graph, Kernel, vertex_descriptor> FT;
|
||||
typedef FacetTriangulator<Face_graph, Kernel, fg_vertex_descriptor> FT;
|
||||
double diagonal;
|
||||
if(item->poly_item->diagonalBbox() != std::numeric_limits<double>::infinity())
|
||||
diagonal = item->poly_item->diagonalBbox();
|
||||
|
|
@ -474,7 +474,7 @@ void Scene_polyhedron_selection_item_priv::compute_any_elements(std::vector<floa
|
|||
end = p_sel_facets.end();
|
||||
it != end; it++)
|
||||
{
|
||||
face_descriptor f = (*it);
|
||||
fg_face_descriptor f = (*it);
|
||||
if (f == boost::graph_traits<Face_graph>::null_face())
|
||||
continue;
|
||||
Vector nf = get(nf_pmap, f);
|
||||
|
|
@ -493,7 +493,7 @@ void Scene_polyhedron_selection_item_priv::compute_any_elements(std::vector<floa
|
|||
p_normals.push_back(nf.z());
|
||||
|
||||
|
||||
BOOST_FOREACH(halfedge_descriptor he, halfedges_around_face(halfedge(f,*polyhedron()), *polyhedron()))
|
||||
BOOST_FOREACH(fg_halfedge_descriptor he, halfedges_around_face(halfedge(f,*polyhedron()), *polyhedron()))
|
||||
{
|
||||
const Point& p = get(vpm,target(he,*poly));
|
||||
p_facets.push_back(p.x()+offset.x);
|
||||
|
|
@ -826,7 +826,7 @@ void Scene_polyhedron_selection_item::inverse_selection()
|
|||
{
|
||||
Selection_set_vertex temp_select = selected_vertices;
|
||||
select_all();
|
||||
Q_FOREACH(vertex_descriptor vh, temp_select)
|
||||
Q_FOREACH(fg_vertex_descriptor vh, temp_select)
|
||||
{
|
||||
selected_vertices.erase(vh);
|
||||
}
|
||||
|
|
@ -836,7 +836,7 @@ void Scene_polyhedron_selection_item::inverse_selection()
|
|||
{
|
||||
Selection_set_edge temp_select = selected_edges;
|
||||
select_all();
|
||||
Q_FOREACH(edge_descriptor ed , temp_select)
|
||||
Q_FOREACH(fg_edge_descriptor ed , temp_select)
|
||||
selected_edges.erase(ed);
|
||||
break;
|
||||
}
|
||||
|
|
@ -844,7 +844,7 @@ void Scene_polyhedron_selection_item::inverse_selection()
|
|||
{
|
||||
Selection_set_facet temp_select = selected_facets;
|
||||
select_all();
|
||||
Q_FOREACH(face_descriptor fh, temp_select)
|
||||
Q_FOREACH(fg_face_descriptor fh, temp_select)
|
||||
selected_facets.erase(fh);
|
||||
break;
|
||||
}
|
||||
|
|
@ -964,13 +964,13 @@ bool Scene_polyhedron_selection_item::treat_classic_selection(const HandleRange&
|
|||
return any_change;
|
||||
}
|
||||
|
||||
bool Scene_polyhedron_selection_item::treat_selection(const std::set<vertex_descriptor>& selection)
|
||||
bool Scene_polyhedron_selection_item::treat_selection(const std::set<fg_vertex_descriptor>& selection)
|
||||
{
|
||||
VPmap vpm = get(CGAL::vertex_point, *polyhedron());
|
||||
if(!d->is_treated)
|
||||
{
|
||||
vertex_descriptor vh = *selection.begin();
|
||||
Selection_traits<vertex_descriptor, Scene_polyhedron_selection_item> tr(this);
|
||||
fg_vertex_descriptor vh = *selection.begin();
|
||||
Selection_traits<fg_vertex_descriptor, Scene_polyhedron_selection_item> tr(this);
|
||||
switch(d->operation_mode)
|
||||
{
|
||||
//classic selection
|
||||
|
|
@ -1008,13 +1008,13 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set<vertex_desc
|
|||
//Split face
|
||||
case 4:
|
||||
{
|
||||
static vertex_descriptor s;
|
||||
static halfedge_descriptor h1,h2;
|
||||
static fg_vertex_descriptor s;
|
||||
static fg_halfedge_descriptor h1,h2;
|
||||
static bool found_h1(false), found_h2(false);
|
||||
if(!d->first_selected)
|
||||
{
|
||||
//Is the vertex on the face ?
|
||||
BOOST_FOREACH(halfedge_descriptor hafc, halfedges_around_face(halfedge(d->to_split_fh,*polyhedron()), *polyhedron()))
|
||||
BOOST_FOREACH(fg_halfedge_descriptor hafc, halfedges_around_face(halfedge(d->to_split_fh,*polyhedron()), *polyhedron()))
|
||||
{
|
||||
if(target(hafc,*polyhedron())==vh)
|
||||
{
|
||||
|
|
@ -1043,7 +1043,7 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set<vertex_desc
|
|||
for(int i=0; i<1; i++) //seems useless but allow the use of break.
|
||||
{
|
||||
//Is the vertex on the face ?
|
||||
BOOST_FOREACH(halfedge_descriptor hafc, halfedges_around_face(halfedge(d->to_split_fh,*polyhedron()), *polyhedron()))
|
||||
BOOST_FOREACH(fg_halfedge_descriptor hafc, halfedges_around_face(halfedge(d->to_split_fh,*polyhedron()), *polyhedron()))
|
||||
if(target(hafc,*polyhedron())==vh)
|
||||
{
|
||||
h2 = hafc;
|
||||
|
|
@ -1100,7 +1100,7 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set<vertex_desc
|
|||
case 8:
|
||||
{
|
||||
bool has_hole = false;
|
||||
BOOST_FOREACH(halfedge_descriptor hc, halfedges_around_target(vh,*polyhedron()))
|
||||
BOOST_FOREACH(fg_halfedge_descriptor hc, halfedges_around_target(vh,*polyhedron()))
|
||||
{
|
||||
if(is_border(hc,*polyhedron()))
|
||||
{
|
||||
|
|
@ -1154,18 +1154,18 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set<vertex_desc
|
|||
|
||||
//returns true if halfedge's facet's degree >= degree
|
||||
/*
|
||||
std::size_t facet_degree(halfedge_descriptor h, const Face_graph& polyhedron)
|
||||
std::size_t facet_degree(fg_halfedge_descriptor h, const Face_graph& polyhedron)
|
||||
{
|
||||
return degree(h,polyhedron);
|
||||
}
|
||||
*/
|
||||
bool Scene_polyhedron_selection_item:: treat_selection(const std::set<edge_descriptor>& selection)
|
||||
bool Scene_polyhedron_selection_item:: treat_selection(const std::set<fg_edge_descriptor>& selection)
|
||||
{
|
||||
VPmap vpm = get(CGAL::vertex_point, *polyhedron());
|
||||
edge_descriptor ed = *selection.begin();
|
||||
fg_edge_descriptor ed = *selection.begin();
|
||||
if(!d->is_treated)
|
||||
{
|
||||
Selection_traits<edge_descriptor, Scene_polyhedron_selection_item> tr(this);
|
||||
Selection_traits<fg_edge_descriptor, Scene_polyhedron_selection_item> tr(this);
|
||||
switch(d->operation_mode)
|
||||
{
|
||||
//classic selection
|
||||
|
|
@ -1185,7 +1185,7 @@ bool Scene_polyhedron_selection_item:: treat_selection(const std::set<edge_descr
|
|||
}
|
||||
else
|
||||
{
|
||||
halfedge_descriptor targt = halfedge(ed, *polyhedron());
|
||||
fg_halfedge_descriptor targt = halfedge(ed, *polyhedron());
|
||||
Point S,T;
|
||||
S = get(vpm, source(targt, *polyhedron()));
|
||||
T = get(vpm, target(targt, *polyhedron()));
|
||||
|
|
@ -1203,7 +1203,7 @@ bool Scene_polyhedron_selection_item:: treat_selection(const std::set<edge_descr
|
|||
|
||||
Point_3 a(get(vpm,target(halfedge(ed, *polyhedron()),*polyhedron()))),
|
||||
b(get(vpm,target(opposite(halfedge(ed, *polyhedron()),*polyhedron()),*polyhedron())));
|
||||
halfedge_descriptor hhandle = CGAL::Euler::split_edge(halfedge(ed, *polyhedron()),*polyhedron());
|
||||
fg_halfedge_descriptor hhandle = CGAL::Euler::split_edge(halfedge(ed, *polyhedron()),*polyhedron());
|
||||
Point_3 p((b.x()+a.x())/2.0, (b.y()+a.y())/2.0,(b.z()+a.z())/2.0);
|
||||
|
||||
put(vpm, target(hhandle,*polyhedron()), p);
|
||||
|
|
@ -1241,7 +1241,7 @@ bool Scene_polyhedron_selection_item:: treat_selection(const std::set<edge_descr
|
|||
}
|
||||
else
|
||||
{
|
||||
halfedge_descriptor targt = halfedge(ed, *polyhedron());
|
||||
fg_halfedge_descriptor targt = halfedge(ed, *polyhedron());
|
||||
Point S,T;
|
||||
S = get(vpm, source(targt, *polyhedron()));
|
||||
T = get(vpm, target(targt, *polyhedron()));
|
||||
|
|
@ -1274,11 +1274,11 @@ bool Scene_polyhedron_selection_item:: treat_selection(const std::set<edge_descr
|
|||
//Add vertex and face to border
|
||||
case 9:
|
||||
{
|
||||
static halfedge_descriptor t;
|
||||
static fg_halfedge_descriptor t;
|
||||
if(!d->first_selected)
|
||||
{
|
||||
bool found = false;
|
||||
halfedge_descriptor hc = halfedge(ed, *polyhedron());
|
||||
fg_halfedge_descriptor hc = halfedge(ed, *polyhedron());
|
||||
if(is_border(hc,*polyhedron()))
|
||||
{
|
||||
t = hc;
|
||||
|
|
@ -1305,7 +1305,7 @@ bool Scene_polyhedron_selection_item:: treat_selection(const std::set<edge_descr
|
|||
}
|
||||
else
|
||||
{
|
||||
halfedge_descriptor hc = halfedge(ed, *polyhedron());
|
||||
fg_halfedge_descriptor hc = halfedge(ed, *polyhedron());
|
||||
if(d->canAddFaceAndVertex(hc, t))
|
||||
{
|
||||
d->first_selected = false;
|
||||
|
|
@ -1325,11 +1325,11 @@ bool Scene_polyhedron_selection_item:: treat_selection(const std::set<edge_descr
|
|||
//Add face to border
|
||||
case 10:
|
||||
{
|
||||
static halfedge_descriptor t;
|
||||
static fg_halfedge_descriptor t;
|
||||
if(!d->first_selected)
|
||||
{
|
||||
bool found = false;
|
||||
halfedge_descriptor hc = halfedge(ed, *polyhedron());
|
||||
fg_halfedge_descriptor hc = halfedge(ed, *polyhedron());
|
||||
if(is_border(hc,*polyhedron()))
|
||||
{
|
||||
t = hc;
|
||||
|
|
@ -1357,7 +1357,7 @@ bool Scene_polyhedron_selection_item:: treat_selection(const std::set<edge_descr
|
|||
}
|
||||
else
|
||||
{
|
||||
halfedge_descriptor hc = halfedge(ed, *polyhedron());
|
||||
fg_halfedge_descriptor hc = halfedge(ed, *polyhedron());
|
||||
if(d->canAddFace(hc, t))
|
||||
{
|
||||
d->first_selected = false;
|
||||
|
|
@ -1380,18 +1380,18 @@ bool Scene_polyhedron_selection_item:: treat_selection(const std::set<edge_descr
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Scene_polyhedron_selection_item::treat_selection(const std::vector<face_descriptor>& selection)
|
||||
bool Scene_polyhedron_selection_item::treat_selection(const std::vector<fg_face_descriptor>& selection)
|
||||
{
|
||||
return treat_classic_selection(selection);
|
||||
}
|
||||
|
||||
bool Scene_polyhedron_selection_item::treat_selection(const std::set<face_descriptor>& selection)
|
||||
bool Scene_polyhedron_selection_item::treat_selection(const std::set<fg_face_descriptor>& selection)
|
||||
{
|
||||
VPmap vpm = get(CGAL::vertex_point,*polyhedron());
|
||||
if(!d->is_treated)
|
||||
{
|
||||
face_descriptor fh = *selection.begin();
|
||||
Selection_traits<face_descriptor, Scene_polyhedron_selection_item> tr(this);
|
||||
fg_face_descriptor fh = *selection.begin();
|
||||
Selection_traits<fg_face_descriptor, Scene_polyhedron_selection_item> tr(this);
|
||||
switch(d->operation_mode)
|
||||
{
|
||||
//classic selection
|
||||
|
|
@ -1403,13 +1403,13 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set<face_descri
|
|||
//Split vertex
|
||||
case 1:
|
||||
{
|
||||
static halfedge_descriptor h1;
|
||||
static fg_halfedge_descriptor h1;
|
||||
//stores first fh and emit change label
|
||||
if(!d->first_selected)
|
||||
{
|
||||
bool found = false;
|
||||
//test preco
|
||||
BOOST_FOREACH(halfedge_descriptor hafc, halfedges_around_face(halfedge(fh,*polyhedron()),*polyhedron()))
|
||||
BOOST_FOREACH(fg_halfedge_descriptor hafc, halfedges_around_face(halfedge(fh,*polyhedron()),*polyhedron()))
|
||||
{
|
||||
if(target(hafc,*polyhedron())==d->to_split_vh)
|
||||
{
|
||||
|
|
@ -1433,9 +1433,9 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set<face_descri
|
|||
else
|
||||
{
|
||||
//get the right halfedges
|
||||
halfedge_descriptor h2;
|
||||
fg_halfedge_descriptor h2;
|
||||
bool found = false;
|
||||
BOOST_FOREACH(halfedge_descriptor hafc, halfedges_around_face(halfedge(fh,*polyhedron()),*polyhedron()))
|
||||
BOOST_FOREACH(fg_halfedge_descriptor hafc, halfedges_around_face(halfedge(fh,*polyhedron()),*polyhedron()))
|
||||
{
|
||||
if(target(hafc,*polyhedron())==d->to_split_vh)
|
||||
{
|
||||
|
|
@ -1447,7 +1447,7 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set<face_descri
|
|||
|
||||
if(found &&(h1 != h2))
|
||||
{
|
||||
halfedge_descriptor hhandle = CGAL::Euler::split_vertex(h1,h2,*polyhedron());
|
||||
fg_halfedge_descriptor hhandle = CGAL::Euler::split_vertex(h1,h2,*polyhedron());
|
||||
|
||||
temp_selected_facets.clear();
|
||||
Point_3 p1t = get(vpm, target(h1,*polyhedron()));
|
||||
|
|
@ -1506,14 +1506,14 @@ bool Scene_polyhedron_selection_item::treat_selection(const std::set<face_descri
|
|||
double x(0), y(0), z(0);
|
||||
int total(0);
|
||||
|
||||
BOOST_FOREACH(halfedge_descriptor hafc, halfedges_around_face(halfedge(fh,*polyhedron()),*polyhedron()))
|
||||
BOOST_FOREACH(fg_halfedge_descriptor hafc, halfedges_around_face(halfedge(fh,*polyhedron()),*polyhedron()))
|
||||
{
|
||||
vertex_descriptor vd = target(hafc,*polyhedron());
|
||||
fg_vertex_descriptor vd = target(hafc,*polyhedron());
|
||||
Point_3& p = get(vpm,vd);
|
||||
x+= p.x(); y+=p.y(); z+=p.z();
|
||||
total++;
|
||||
}
|
||||
halfedge_descriptor hhandle = CGAL::Euler::add_center_vertex(halfedge(fh,*polyhedron()), *polyhedron());
|
||||
fg_halfedge_descriptor hhandle = CGAL::Euler::add_center_vertex(halfedge(fh,*polyhedron()), *polyhedron());
|
||||
if(total !=0)
|
||||
put(vpm, target(hhandle,*polyhedron()), Point_3(x/(double)total, y/(double)total, z/(double)total));
|
||||
compute_normal_maps();
|
||||
|
|
@ -1556,20 +1556,20 @@ class Dijkstra_end_exception : public std::exception
|
|||
/// the shortest path is thus known.
|
||||
class Stop_at_target_Dijkstra_visitor : boost::default_dijkstra_visitor
|
||||
{
|
||||
vertex_descriptor destination_vd;
|
||||
fg_vertex_descriptor destination_vd;
|
||||
|
||||
public:
|
||||
Stop_at_target_Dijkstra_visitor(vertex_descriptor destination_vd)
|
||||
Stop_at_target_Dijkstra_visitor(fg_vertex_descriptor destination_vd)
|
||||
: destination_vd(destination_vd)
|
||||
{ }
|
||||
|
||||
void initialize_vertex(const vertex_descriptor& /*s*/, const Face_graph& /*mesh*/) const { }
|
||||
void examine_vertex(const vertex_descriptor& /*s*/, const Face_graph& /*mesh*/) const { }
|
||||
void examine_edge(const edge_descriptor& /*e*/, const Face_graph& /*mesh*/) const { }
|
||||
void edge_relaxed(const edge_descriptor& /*e*/, const Face_graph& /*mesh*/) const { }
|
||||
void discover_vertex(const vertex_descriptor& /*s*/, const Face_graph& /*mesh*/) const { }
|
||||
void edge_not_relaxed(const edge_descriptor& /*e*/, const Face_graph& /*mesh*/) const { }
|
||||
void finish_vertex(const vertex_descriptor &vd, const Face_graph& /* mesh*/) const
|
||||
void initialize_vertex(const fg_vertex_descriptor& /*s*/, const Face_graph& /*mesh*/) const { }
|
||||
void examine_vertex(const fg_vertex_descriptor& /*s*/, const Face_graph& /*mesh*/) const { }
|
||||
void examine_edge(const fg_edge_descriptor& /*e*/, const Face_graph& /*mesh*/) const { }
|
||||
void edge_relaxed(const fg_edge_descriptor& /*e*/, const Face_graph& /*mesh*/) const { }
|
||||
void discover_vertex(const fg_vertex_descriptor& /*s*/, const Face_graph& /*mesh*/) const { }
|
||||
void edge_not_relaxed(const fg_edge_descriptor& /*e*/, const Face_graph& /*mesh*/) const { }
|
||||
void finish_vertex(const fg_vertex_descriptor &vd, const Face_graph& /* mesh*/) const
|
||||
{
|
||||
if(vd == destination_vd)
|
||||
throw Dijkstra_end_exception();
|
||||
|
|
@ -1581,17 +1581,17 @@ void Scene_polyhedron_selection_item_priv::computeAndDisplayPath()
|
|||
item->temp_selected_edges.clear();
|
||||
path.clear();
|
||||
|
||||
typedef boost::unordered_map<vertex_descriptor, vertex_descriptor> Pred_umap;
|
||||
typedef boost::unordered_map<fg_vertex_descriptor, fg_vertex_descriptor> Pred_umap;
|
||||
typedef boost::associative_property_map<Pred_umap> Pred_pmap;
|
||||
|
||||
Pred_umap predecessor;
|
||||
Pred_pmap pred_pmap(predecessor);
|
||||
|
||||
vertex_on_path vop;
|
||||
QList<vertex_descriptor>::iterator it;
|
||||
QList<fg_vertex_descriptor>::iterator it;
|
||||
for(it = constrained_vertices.begin(); it!=constrained_vertices.end()-1; ++it)
|
||||
{
|
||||
vertex_descriptor t(*it), s(*(it+1));
|
||||
fg_vertex_descriptor t(*it), s(*(it+1));
|
||||
Stop_at_target_Dijkstra_visitor vis(t);
|
||||
|
||||
try
|
||||
|
|
@ -1629,13 +1629,13 @@ void Scene_polyhedron_selection_item_priv::computeAndDisplayPath()
|
|||
QList<vertex_on_path>::iterator path_it;
|
||||
for(path_it = path.begin(); path_it!=path.end()-1; ++path_it)
|
||||
{
|
||||
std::pair<halfedge_descriptor, bool> h = halfedge((path_it+1)->vertex,path_it->vertex,*item->polyhedron());
|
||||
std::pair<fg_halfedge_descriptor, bool> h = halfedge((path_it+1)->vertex,path_it->vertex,*item->polyhedron());
|
||||
if(h.second)
|
||||
item->temp_selected_edges.insert(edge(h.first, *item->polyhedron()));
|
||||
}
|
||||
}
|
||||
|
||||
void Scene_polyhedron_selection_item_priv::addVertexToPath(vertex_descriptor vh, vertex_on_path &first)
|
||||
void Scene_polyhedron_selection_item_priv::addVertexToPath(fg_vertex_descriptor vh, vertex_on_path &first)
|
||||
{
|
||||
vertex_on_path source;
|
||||
source.vertex = vh;
|
||||
|
|
@ -1643,7 +1643,7 @@ void Scene_polyhedron_selection_item_priv::addVertexToPath(vertex_descriptor vh,
|
|||
path.append(source);
|
||||
first = source;
|
||||
}
|
||||
void Scene_polyhedron_selection_item::selectPath(vertex_descriptor vh)
|
||||
void Scene_polyhedron_selection_item::selectPath(fg_vertex_descriptor vh)
|
||||
{
|
||||
|
||||
bool replace = !temp_selected_edges.empty();
|
||||
|
|
@ -1904,7 +1904,7 @@ void Scene_polyhedron_selection_item::setPathSelection(bool b) {
|
|||
int ind = 0;
|
||||
boost::property_map<Face_graph,CGAL::vertex_selection_t>::type vsm =
|
||||
get(CGAL::vertex_selection,*polyhedron());
|
||||
BOOST_FOREACH(vertex_descriptor vd, vertices(*polyhedron())){
|
||||
BOOST_FOREACH(fg_vertex_descriptor vd, vertices(*polyhedron())){
|
||||
put(vsm,vd, ind++);
|
||||
}
|
||||
}
|
||||
|
|
@ -1930,7 +1930,7 @@ void Scene_polyhedron_selection_item::invalidateOpenGLBuffers() {
|
|||
|
||||
void Scene_polyhedron_selection_item::add_to_selection()
|
||||
{
|
||||
Q_FOREACH(edge_descriptor ed, temp_selected_edges)
|
||||
Q_FOREACH(fg_edge_descriptor ed, temp_selected_edges)
|
||||
{
|
||||
selected_edges.insert(ed);
|
||||
temp_selected_edges.erase(ed);
|
||||
|
|
@ -1952,8 +1952,8 @@ void Scene_polyhedron_selection_item::compute_normal_maps()
|
|||
|
||||
d->face_normals_map.clear();
|
||||
d->vertex_normals_map.clear();
|
||||
d->nf_pmap = boost::associative_property_map< CGAL::Unique_hash_map<face_descriptor, Kernel::Vector_3> >(d->face_normals_map);
|
||||
d->nv_pmap = boost::associative_property_map< CGAL::Unique_hash_map<vertex_descriptor, Kernel::Vector_3> >(d->vertex_normals_map);
|
||||
d->nf_pmap = boost::associative_property_map< CGAL::Unique_hash_map<fg_face_descriptor, Kernel::Vector_3> >(d->face_normals_map);
|
||||
d->nv_pmap = boost::associative_property_map< CGAL::Unique_hash_map<fg_vertex_descriptor, Kernel::Vector_3> >(d->vertex_normals_map);
|
||||
PMP::compute_normals(*d->poly, d->nv_pmap, d->nf_pmap);
|
||||
}
|
||||
|
||||
|
|
@ -1969,7 +1969,7 @@ void Scene_polyhedron_selection_item::moveVertex()
|
|||
if(d->ready_to_move)
|
||||
{
|
||||
const qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
vertex_descriptor vh = *temp_selected_vertices.begin();
|
||||
fg_vertex_descriptor vh = *temp_selected_vertices.begin();
|
||||
|
||||
VPmap vpm = get(CGAL::vertex_point,*polyhedron());
|
||||
put(vpm, vh, Point_3(d->manipulated_frame->position().x-offset.x,
|
||||
|
|
@ -1992,7 +1992,7 @@ void Scene_polyhedron_selection_item::validateMoveVertex()
|
|||
}
|
||||
|
||||
|
||||
bool Scene_polyhedron_selection_item_priv::canAddFace(halfedge_descriptor hc, halfedge_descriptor t)
|
||||
bool Scene_polyhedron_selection_item_priv::canAddFace(fg_halfedge_descriptor hc, fg_halfedge_descriptor t)
|
||||
{
|
||||
bool found(false), is_border_h(false);
|
||||
|
||||
|
|
@ -2026,13 +2026,13 @@ bool Scene_polyhedron_selection_item_priv::canAddFace(halfedge_descriptor hc, ha
|
|||
}
|
||||
|
||||
//if the halfedges are not on the same border, stop and signal it.
|
||||
halfedge_descriptor iterator = next(t, *item->polyhedron());
|
||||
fg_halfedge_descriptor iterator = next(t, *item->polyhedron());
|
||||
while(iterator != t)
|
||||
{
|
||||
if(iterator == hc)
|
||||
{
|
||||
found = true;
|
||||
halfedge_descriptor res =
|
||||
fg_halfedge_descriptor res =
|
||||
CGAL::Euler::add_face_to_border(t,hc, *item->polyhedron());
|
||||
|
||||
if(CGAL::is_degenerate_triangle_face(res, *item->polyhedron(), get(CGAL::vertex_point, *item->polyhedron()), Kernel()))
|
||||
|
|
@ -2055,7 +2055,7 @@ bool Scene_polyhedron_selection_item_priv::canAddFace(halfedge_descriptor hc, ha
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Scene_polyhedron_selection_item_priv::canAddFaceAndVertex(halfedge_descriptor hc, halfedge_descriptor t)
|
||||
bool Scene_polyhedron_selection_item_priv::canAddFaceAndVertex(fg_halfedge_descriptor hc, fg_halfedge_descriptor t)
|
||||
{
|
||||
bool found(false), is_border_h(false);
|
||||
|
||||
|
|
@ -2082,7 +2082,7 @@ bool Scene_polyhedron_selection_item_priv::canAddFaceAndVertex(halfedge_descript
|
|||
}
|
||||
|
||||
//if the halfedges are not on the same border, stop and signal it.
|
||||
halfedge_descriptor iterator = next(t, *item->polyhedron());
|
||||
fg_halfedge_descriptor iterator = next(t, *item->polyhedron());
|
||||
while(iterator != t)
|
||||
{
|
||||
if(iterator == hc)
|
||||
|
|
@ -2110,7 +2110,7 @@ void Scene_polyhedron_selection_item::clearHL()
|
|||
d->are_HL_buffers_filled = false;
|
||||
Q_EMIT itemChanged();
|
||||
}
|
||||
void Scene_polyhedron_selection_item::selected_HL(const std::set<vertex_descriptor>& m)
|
||||
void Scene_polyhedron_selection_item::selected_HL(const std::set<fg_vertex_descriptor>& m)
|
||||
{
|
||||
HL_selected_edges.clear();
|
||||
HL_selected_facets.clear();
|
||||
|
|
@ -2121,7 +2121,7 @@ void Scene_polyhedron_selection_item::selected_HL(const std::set<vertex_descript
|
|||
Q_EMIT itemChanged();
|
||||
}
|
||||
|
||||
void Scene_polyhedron_selection_item::selected_HL(const std::set<face_descriptor>& m)
|
||||
void Scene_polyhedron_selection_item::selected_HL(const std::set<fg_face_descriptor>& m)
|
||||
{
|
||||
HL_selected_edges.clear();
|
||||
HL_selected_facets.clear();
|
||||
|
|
@ -2131,7 +2131,7 @@ void Scene_polyhedron_selection_item::selected_HL(const std::set<face_descriptor
|
|||
Q_EMIT itemChanged();
|
||||
}
|
||||
|
||||
void Scene_polyhedron_selection_item::selected_HL(const std::set<edge_descriptor>& m)
|
||||
void Scene_polyhedron_selection_item::selected_HL(const std::set<fg_edge_descriptor>& m)
|
||||
{
|
||||
HL_selected_edges.clear();
|
||||
HL_selected_facets.clear();
|
||||
|
|
@ -2147,23 +2147,23 @@ void Scene_polyhedron_selection_item::init(Scene_face_graph_item* poly_item, QMa
|
|||
d->poly =poly_item->polyhedron();
|
||||
connect(poly_item, SIGNAL(item_is_about_to_be_changed()), this, SLOT(poly_item_changed()));
|
||||
//parameters type must be of the same name here and there, so they must be hardcoded.
|
||||
connect(&k_ring_selector, SIGNAL(selected(const std::set<vertex_descriptor>&)), this,
|
||||
SLOT(selected(const std::set<vertex_descriptor>&)));
|
||||
connect(&k_ring_selector, SIGNAL(selected(const std::set<fg_vertex_descriptor>&)), this,
|
||||
SLOT(selected(const std::set<fg_vertex_descriptor>&)));
|
||||
|
||||
connect(&k_ring_selector, SIGNAL(selected(const std::set<face_descriptor>&)), this,
|
||||
SLOT(selected(const std::set<face_descriptor>&)));
|
||||
connect(&k_ring_selector, SIGNAL(selected(const std::set<fg_face_descriptor>&)), this,
|
||||
SLOT(selected(const std::set<fg_face_descriptor>&)));
|
||||
|
||||
connect(&k_ring_selector, SIGNAL(selected(const std::set<edge_descriptor>&)), this,
|
||||
SLOT(selected(const std::set<edge_descriptor>&)));
|
||||
connect(&k_ring_selector, SIGNAL(selected(const std::set<fg_edge_descriptor>&)), this,
|
||||
SLOT(selected(const std::set<fg_edge_descriptor>&)));
|
||||
|
||||
connect(&k_ring_selector, SIGNAL(selected_HL(const std::set<vertex_descriptor>&)), this,
|
||||
SLOT(selected_HL(const std::set<vertex_descriptor>&)));
|
||||
connect(&k_ring_selector, SIGNAL(selected_HL(const std::set<fg_vertex_descriptor>&)), this,
|
||||
SLOT(selected_HL(const std::set<fg_vertex_descriptor>&)));
|
||||
|
||||
connect(&k_ring_selector, SIGNAL(selected_HL(const std::set<face_descriptor>&)), this,
|
||||
SLOT(selected_HL(const std::set<face_descriptor>&)));
|
||||
connect(&k_ring_selector, SIGNAL(selected_HL(const std::set<fg_face_descriptor>&)), this,
|
||||
SLOT(selected_HL(const std::set<fg_face_descriptor>&)));
|
||||
|
||||
connect(&k_ring_selector, SIGNAL(selected_HL(const std::set<edge_descriptor>&)), this,
|
||||
SLOT(selected_HL(const std::set<edge_descriptor>&)));
|
||||
connect(&k_ring_selector, SIGNAL(selected_HL(const std::set<fg_edge_descriptor>&)), this,
|
||||
SLOT(selected_HL(const std::set<fg_edge_descriptor>&)));
|
||||
connect(&k_ring_selector, SIGNAL(clearHL()), this,
|
||||
SLOT(clearHL()));
|
||||
connect(poly_item, SIGNAL(selection_done()), this, SLOT(update_poly()));
|
||||
|
|
@ -2180,7 +2180,7 @@ void Scene_polyhedron_selection_item::init(Scene_face_graph_item* poly_item, QMa
|
|||
|
||||
void Scene_polyhedron_selection_item::select_all_NT()
|
||||
{
|
||||
BOOST_FOREACH(face_descriptor fd, faces(*polyhedron())){
|
||||
BOOST_FOREACH(fg_face_descriptor fd, faces(*polyhedron())){
|
||||
if(! is_triangle(halfedge(fd,*polyhedron()), *polyhedron()))
|
||||
selected_facets.insert(fd);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,10 +47,10 @@ typedef boost::property_map<Face_graph,CGAL::vertex_point_t>::const_type constVP
|
|||
typedef Scene_face_graph_item::Vertex_selection_map Vertex_selection_map;
|
||||
typedef Scene_face_graph_item::Face_selection_map Face_selection_map;
|
||||
|
||||
typedef boost::graph_traits<Face_graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::edge_descriptor edge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::face_descriptor face_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::vertex_descriptor fg_vertex_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::halfedge_descriptor fg_halfedge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::edge_descriptor fg_edge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::face_descriptor fg_face_descriptor;
|
||||
|
||||
typedef boost::graph_traits<Face_graph>::vertex_iterator vertex_iterator;
|
||||
typedef boost::graph_traits<Face_graph>::halfedge_iterator halfedge_iterator;
|
||||
|
|
@ -61,7 +61,7 @@ template<class HandleType, class SelectionItem>
|
|||
struct Selection_traits {};
|
||||
|
||||
template<class SelectionItem>
|
||||
struct Selection_traits<typename SelectionItem::vertex_descriptor, SelectionItem>
|
||||
struct Selection_traits<typename SelectionItem::fg_vertex_descriptor, SelectionItem>
|
||||
{
|
||||
typedef typename SelectionItem::Selection_set_vertex Container;
|
||||
typedef vertex_iterator Iterator;
|
||||
|
|
@ -73,7 +73,7 @@ struct Selection_traits<typename SelectionItem::vertex_descriptor, SelectionItem
|
|||
Iterator iterator_end() { return vertices(*item->polyhedron()).second; }
|
||||
std::size_t size() { return num_vertices(*item->polyhedron()); }
|
||||
void update_indices() { item->polyhedron_item()->update_vertex_indices(); }
|
||||
std::size_t id(typename SelectionItem::vertex_descriptor vh)
|
||||
std::size_t id(typename SelectionItem::fg_vertex_descriptor vh)
|
||||
{
|
||||
return get(get(CGAL::vertex_selection, *item->polyhedron()), vh);
|
||||
}
|
||||
|
|
@ -107,7 +107,7 @@ struct Selection_traits<typename SelectionItem::vertex_descriptor, SelectionItem
|
|||
};
|
||||
|
||||
template<class SelectionItem>
|
||||
struct Selection_traits<typename SelectionItem::face_descriptor, SelectionItem>
|
||||
struct Selection_traits<typename SelectionItem::fg_face_descriptor, SelectionItem>
|
||||
{
|
||||
typedef typename SelectionItem::Selection_set_facet Container;
|
||||
typedef face_iterator Iterator;
|
||||
|
|
@ -118,7 +118,7 @@ struct Selection_traits<typename SelectionItem::face_descriptor, SelectionItem>
|
|||
Iterator iterator_end() { return faces(*item->polyhedron()).second; }
|
||||
std::size_t size() { return num_faces(*item->polyhedron()); }
|
||||
void update_indices() { item->polyhedron_item()->update_facet_indices(); }
|
||||
std::size_t id(typename SelectionItem::face_descriptor fh)
|
||||
std::size_t id(typename SelectionItem::fg_face_descriptor fh)
|
||||
{
|
||||
return get(get(CGAL::face_selection, *item->polyhedron()), fh);
|
||||
}
|
||||
|
|
@ -152,7 +152,7 @@ struct Selection_traits<typename SelectionItem::face_descriptor, SelectionItem>
|
|||
};
|
||||
|
||||
template<class SelectionItem>
|
||||
struct Selection_traits<typename SelectionItem::edge_descriptor, SelectionItem>
|
||||
struct Selection_traits<typename SelectionItem::fg_edge_descriptor, SelectionItem>
|
||||
{
|
||||
typedef typename SelectionItem::Selection_set_edge Container;
|
||||
typedef edge_iterator Iterator;
|
||||
|
|
@ -206,10 +206,10 @@ class SCENE_POLYHEDRON_SELECTION_ITEM_EXPORT Scene_polyhedron_selection_item
|
|||
friend class Polyhedron_demo_selection_plugin;
|
||||
|
||||
public:
|
||||
typedef boost::graph_traits<Face_graph>::face_descriptor face_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::edge_descriptor edge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::vertex_descriptor vertex_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::face_descriptor fg_face_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::edge_descriptor fg_edge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::halfedge_descriptor fg_halfedge_descriptor;
|
||||
typedef boost::graph_traits<Face_graph>::vertex_descriptor fg_vertex_descriptor;
|
||||
|
||||
typedef Scene_facegraph_item_k_ring_selection::Active_handle Active_handle;
|
||||
|
||||
|
|
@ -235,9 +235,9 @@ protected:
|
|||
void set_is_insert(bool i) { is_insert = i; }
|
||||
|
||||
public:
|
||||
typedef boost::unordered_set<vertex_descriptor, CGAL::Handle_hash_function> Selection_set_vertex;
|
||||
typedef boost::unordered_set<face_descriptor, CGAL::Handle_hash_function> Selection_set_facet;
|
||||
typedef boost::unordered_set<edge_descriptor, CGAL::Handle_hash_function> Selection_set_edge;
|
||||
typedef boost::unordered_set<fg_vertex_descriptor, CGAL::Handle_hash_function> Selection_set_vertex;
|
||||
typedef boost::unordered_set<fg_face_descriptor, CGAL::Handle_hash_function> Selection_set_facet;
|
||||
typedef boost::unordered_set<fg_edge_descriptor, CGAL::Handle_hash_function> Selection_set_edge;
|
||||
|
||||
Vertex_selection_map vertex_selection_map()
|
||||
{
|
||||
|
|
@ -296,8 +296,8 @@ public:
|
|||
|
||||
for(Selection_set_facet::const_iterator f_it = selected_facets.begin();
|
||||
f_it != selected_facets.end(); ++f_it) {
|
||||
face_descriptor fd = *f_it;
|
||||
BOOST_FOREACH(halfedge_descriptor he, halfedges_around_face(halfedge(fd,*polyhedron()),*polyhedron())){
|
||||
fg_face_descriptor fd = *f_it;
|
||||
BOOST_FOREACH(fg_halfedge_descriptor he, halfedges_around_face(halfedge(fd,*polyhedron()),*polyhedron())){
|
||||
if(item_bbox) { *item_bbox = *item_bbox + get(vpm,target(he,*polyhedron())).bbox(); }
|
||||
else { item_bbox = get(vpm,target(he,*polyhedron())).bbox(); }
|
||||
|
||||
|
|
@ -329,7 +329,7 @@ public:
|
|||
|
||||
for(Selection_set_edge::const_iterator it = selected_edges.begin(); it != selected_edges.end(); ++it)
|
||||
{
|
||||
edge_descriptor ed = *it;
|
||||
fg_edge_descriptor ed = *it;
|
||||
out << get(boost::vertex_index, *polyhedron(), source(ed,*polyhedron())) << " "
|
||||
<< get(boost::vertex_index, *polyhedron(),target(ed,*polyhedron())) << " ";
|
||||
}
|
||||
|
|
@ -352,18 +352,18 @@ public:
|
|||
|
||||
init(poly_item, mw);
|
||||
|
||||
std::vector<vertex_descriptor> all_vertices;
|
||||
std::vector<fg_vertex_descriptor> all_vertices;
|
||||
all_vertices.reserve(num_vertices(*polyhedron()));
|
||||
|
||||
BOOST_FOREACH(vertex_descriptor vb, vertices(*polyhedron()))
|
||||
BOOST_FOREACH(fg_vertex_descriptor vb, vertices(*polyhedron()))
|
||||
{ all_vertices.push_back(vb); }
|
||||
|
||||
std::vector<face_descriptor> all_facets;
|
||||
std::vector<fg_face_descriptor> all_facets;
|
||||
all_facets.reserve(num_faces(*polyhedron()));
|
||||
BOOST_FOREACH(face_descriptor fb, faces(*polyhedron()))
|
||||
BOOST_FOREACH(fg_face_descriptor fb, faces(*polyhedron()))
|
||||
{ all_facets.push_back(fb); }
|
||||
|
||||
std::vector<edge_descriptor> all_edges(edges(*polyhedron()).first, edges(*polyhedron()).second);
|
||||
std::vector<fg_edge_descriptor> all_edges(edges(*polyhedron()).first, edges(*polyhedron()).second);
|
||||
|
||||
std::ifstream in(file_name_holder.c_str());
|
||||
if(!in) { return false; }
|
||||
|
|
@ -389,9 +389,9 @@ public:
|
|||
std::istringstream edge_line(line);
|
||||
while(edge_line >> id >> id2) {
|
||||
if(id >= all_edges.size() || id2 >= all_edges.size()) { return false; }
|
||||
vertex_descriptor s = all_vertices[id];
|
||||
vertex_descriptor t = all_vertices[id2];
|
||||
halfedge_descriptor hd;
|
||||
fg_vertex_descriptor s = all_vertices[id];
|
||||
fg_vertex_descriptor t = all_vertices[id2];
|
||||
fg_halfedge_descriptor hd;
|
||||
bool exists;
|
||||
boost::tie(hd,exists) = halfedge(s,t,*polyhedron());
|
||||
if(! exists) { return false; }
|
||||
|
|
@ -407,10 +407,10 @@ public:
|
|||
void select_all() {
|
||||
switch(get_active_handle_type()) {
|
||||
case Active_handle::VERTEX:
|
||||
select_all<vertex_descriptor>(); break;
|
||||
select_all<fg_vertex_descriptor>(); break;
|
||||
case Active_handle::FACET:
|
||||
case Active_handle::CONNECTED_COMPONENT:
|
||||
select_all<face_descriptor>(); break;
|
||||
select_all<fg_face_descriptor>(); break;
|
||||
case Active_handle::EDGE:
|
||||
case Active_handle::PATH:
|
||||
selected_edges.insert(edges(*polyhedron()).first, edges(*polyhedron()).second);
|
||||
|
|
@ -421,7 +421,7 @@ public:
|
|||
}
|
||||
}
|
||||
void select_all_NT();
|
||||
// select all of vertex, facet or edge (use vertex_descriptor, face_descriptor, edge_descriptor as template argument)
|
||||
// select all of vertex, facet or edge (use fg_vertex_descriptor, fg_face_descriptor, fg_edge_descriptor as template argument)
|
||||
template<class HandleType>
|
||||
void select_all() {
|
||||
typedef Selection_traits<HandleType, Scene_polyhedron_selection_item> Tr;
|
||||
|
|
@ -437,16 +437,16 @@ public:
|
|||
void clear() {
|
||||
switch(get_active_handle_type()) {
|
||||
case Active_handle::VERTEX:
|
||||
clear<vertex_descriptor>(); break;
|
||||
clear<fg_vertex_descriptor>(); break;
|
||||
case Active_handle::FACET:
|
||||
case Active_handle::CONNECTED_COMPONENT:
|
||||
clear<face_descriptor>(); break;
|
||||
clear<fg_face_descriptor>(); break;
|
||||
case Active_handle::EDGE:
|
||||
case Active_handle::PATH:
|
||||
clear<edge_descriptor>(); break;
|
||||
clear<fg_edge_descriptor>(); break;
|
||||
}
|
||||
}
|
||||
// select all of vertex, facet or edge (use vertex_descriptor, face_descriptor, edge_descriptor as template argument)
|
||||
// select all of vertex, facet or edge (use fg_vertex_descriptor, fg_face_descriptor, fg_edge_descriptor as template argument)
|
||||
template<class HandleType>
|
||||
void clear() {
|
||||
|
||||
|
|
@ -457,22 +457,22 @@ public:
|
|||
}
|
||||
|
||||
void clear_all(){
|
||||
clear<vertex_descriptor>();
|
||||
clear<face_descriptor>();
|
||||
clear<edge_descriptor>();
|
||||
clear<fg_vertex_descriptor>();
|
||||
clear<fg_face_descriptor>();
|
||||
clear<fg_edge_descriptor>();
|
||||
}
|
||||
|
||||
boost::optional<std::size_t> get_minimum_isolated_component() {
|
||||
switch(get_active_handle_type()) {
|
||||
case Active_handle::VERTEX:
|
||||
return get_minimum_isolated_component<vertex_descriptor>();
|
||||
return get_minimum_isolated_component<fg_vertex_descriptor>();
|
||||
case Active_handle::FACET:
|
||||
return get_minimum_isolated_component<face_descriptor>();
|
||||
return get_minimum_isolated_component<fg_face_descriptor>();
|
||||
default:
|
||||
return get_minimum_isolated_component<edge_descriptor>();
|
||||
return get_minimum_isolated_component<fg_edge_descriptor>();
|
||||
}
|
||||
}
|
||||
template<class HandleType> // use vertex_descriptor, face_descriptor, edge_descriptor
|
||||
template<class HandleType> // use fg_vertex_descriptor, fg_face_descriptor, fg_edge_descriptor
|
||||
boost::optional<std::size_t> get_minimum_isolated_component() {
|
||||
Selection_traits<HandleType, Scene_polyhedron_selection_item> tr(this);
|
||||
tr.update_indices();
|
||||
|
|
@ -485,14 +485,14 @@ public:
|
|||
boost::optional<std::size_t> select_isolated_components(std::size_t threshold) {
|
||||
switch(get_active_handle_type()) {
|
||||
case Active_handle::VERTEX:
|
||||
return select_isolated_components<vertex_descriptor>(threshold);
|
||||
return select_isolated_components<fg_vertex_descriptor>(threshold);
|
||||
case Active_handle::FACET:
|
||||
return select_isolated_components<face_descriptor>(threshold);
|
||||
return select_isolated_components<fg_face_descriptor>(threshold);
|
||||
default:
|
||||
return select_isolated_components<edge_descriptor>(threshold);
|
||||
return select_isolated_components<fg_edge_descriptor>(threshold);
|
||||
}
|
||||
}
|
||||
template<class HandleType> // use vertex_descriptor, face_descriptor, edge_descriptor
|
||||
template<class HandleType> // use fg_vertex_descriptor, fg_face_descriptor, fg_edge_descriptor
|
||||
boost::optional<std::size_t> select_isolated_components(std::size_t threshold) {
|
||||
typedef Selection_traits<HandleType, Scene_polyhedron_selection_item> Tr;
|
||||
Tr tr(this);
|
||||
|
|
@ -513,14 +513,14 @@ public:
|
|||
{
|
||||
switch(get_active_handle_type()) {
|
||||
case Active_handle::VERTEX:
|
||||
expand_selection<vertex_descriptor, boost::vertex_index_t>(steps);
|
||||
expand_selection<fg_vertex_descriptor, boost::vertex_index_t>(steps);
|
||||
break;
|
||||
case Active_handle::FACET:
|
||||
case Active_handle::CONNECTED_COMPONENT:
|
||||
expand_selection<face_descriptor, boost::face_index_t>(steps);
|
||||
expand_selection<fg_face_descriptor, boost::face_index_t>(steps);
|
||||
break;
|
||||
case Active_handle::EDGE:
|
||||
expand_selection<edge_descriptor, boost::edge_index_t>(steps);
|
||||
expand_selection<fg_edge_descriptor, boost::edge_index_t>(steps);
|
||||
break;
|
||||
case Active_handle::PATH:
|
||||
break;
|
||||
|
|
@ -530,14 +530,14 @@ public:
|
|||
{
|
||||
switch(get_active_handle_type()) {
|
||||
case Active_handle::VERTEX:
|
||||
reduce_selection<vertex_descriptor, boost::vertex_index_t>(-steps);
|
||||
reduce_selection<fg_vertex_descriptor, boost::vertex_index_t>(-steps);
|
||||
break;
|
||||
case Active_handle::FACET:
|
||||
case Active_handle::CONNECTED_COMPONENT:
|
||||
reduce_selection<face_descriptor, boost::face_index_t>(-steps);
|
||||
reduce_selection<fg_face_descriptor, boost::face_index_t>(-steps);
|
||||
break;
|
||||
case Active_handle::EDGE:
|
||||
reduce_selection<edge_descriptor, boost::edge_index_t>(-steps);
|
||||
reduce_selection<fg_edge_descriptor, boost::edge_index_t>(-steps);
|
||||
break;
|
||||
case Active_handle::PATH:
|
||||
break;
|
||||
|
|
@ -691,7 +691,7 @@ public:
|
|||
&& (selected_facets.find(face(halfedge(*eit,*polyhedron()),*polyhedron())) != selected_facets.end()
|
||||
|| selected_facets.find(face(opposite(halfedge(*eit,*polyhedron()),*polyhedron()),*polyhedron())) != selected_facets.end())))
|
||||
{
|
||||
edge_descriptor tmp = *eit;
|
||||
fg_edge_descriptor tmp = *eit;
|
||||
++eit;
|
||||
selected_edges.erase(tmp);
|
||||
}
|
||||
|
|
@ -713,9 +713,9 @@ public:
|
|||
void keep_connected_components() {
|
||||
if (selected_facets.empty()) { return; }
|
||||
|
||||
Selection_traits<face_descriptor, Scene_polyhedron_selection_item> trf(this);
|
||||
Selection_traits<fg_face_descriptor, Scene_polyhedron_selection_item> trf(this);
|
||||
trf.update_indices();
|
||||
Selection_traits<vertex_descriptor, Scene_polyhedron_selection_item> trv(this);
|
||||
Selection_traits<fg_vertex_descriptor, Scene_polyhedron_selection_item> trv(this);
|
||||
trv.update_indices();
|
||||
|
||||
PMP::keep_connected_components(*polyhedron(), trf.container());
|
||||
|
|
@ -726,7 +726,7 @@ public:
|
|||
// Note: might be a more performance wise solution
|
||||
// assign sequential id to vertices neighbor to selected facets
|
||||
for(Selection_set_facet::iterator fb = selected_facets.begin(); fb != selected_facets.end(); ++fb) {
|
||||
BOOST_FOREACH(halfedge_descriptor hb, halfedges_around_face(halfedge(*fb,*polyhedron()),*polyhedron())){
|
||||
BOOST_FOREACH(fg_halfedge_descriptor hb, halfedges_around_face(halfedge(*fb,*polyhedron()),*polyhedron())){
|
||||
put(vertex_selection_map(),target(hb,*polyhedron()), 0);
|
||||
}
|
||||
}
|
||||
|
|
@ -736,7 +736,7 @@ public:
|
|||
VPmap vpm = get(CGAL::vertex_point, *polyhedron());
|
||||
std::size_t counter = 1;
|
||||
for(Selection_set_facet::iterator fb = selected_facets.begin(); fb != selected_facets.end(); ++fb) {
|
||||
BOOST_FOREACH(halfedge_descriptor hb, halfedges_around_face(halfedge(*fb,*polyhedron()),*polyhedron())){
|
||||
BOOST_FOREACH(fg_halfedge_descriptor hb, halfedges_around_face(halfedge(*fb,*polyhedron()),*polyhedron())){
|
||||
if(get(vertex_selection_map(), target(hb,*polyhedron())) == 0) {
|
||||
put(vertex_selection_map(),target(hb,*polyhedron()), counter++);
|
||||
points.push_back(get(vpm,target(hb,*polyhedron())));
|
||||
|
|
@ -747,7 +747,7 @@ public:
|
|||
std::vector<std::vector<std::size_t> > polygons(selected_facets.size());
|
||||
counter = 0;
|
||||
for(Selection_set_facet::iterator fb = selected_facets.begin(); fb != selected_facets.end(); ++fb, ++counter) {
|
||||
BOOST_FOREACH(halfedge_descriptor hb, halfedges_around_face(halfedge(*fb,*polyhedron()),*polyhedron()))
|
||||
BOOST_FOREACH(fg_halfedge_descriptor hb, halfedges_around_face(halfedge(*fb,*polyhedron()),*polyhedron()))
|
||||
{
|
||||
polygons[counter].push_back(get(vertex_selection_map(),target(hb,*polyhedron())) -1);
|
||||
}
|
||||
|
|
@ -763,9 +763,9 @@ public:
|
|||
CGAL::detect_sharp_edges(polyhedron(), angle);
|
||||
|
||||
boost::property_map<Face_graph,CGAL::halfedge_is_feature_t>::type is_feature = get(CGAL::halfedge_is_feature,*polyhedron());
|
||||
BOOST_FOREACH(edge_descriptor e, edges(*polyhedron()))
|
||||
BOOST_FOREACH(fg_edge_descriptor e, edges(*polyhedron()))
|
||||
{
|
||||
halfedge_descriptor h = halfedge(e, *polyhedron());
|
||||
fg_halfedge_descriptor h = halfedge(e, *polyhedron());
|
||||
if (get(is_feature,h))
|
||||
selected_edges.insert(e);
|
||||
}
|
||||
|
|
@ -804,20 +804,20 @@ public Q_SLOTS:
|
|||
void clearHL();
|
||||
|
||||
// slots are called by signals of polyhedron_k_ring_selector
|
||||
void selected(const std::set<vertex_descriptor>& m)
|
||||
void selected(const std::set<fg_vertex_descriptor>& m)
|
||||
{ has_been_selected(m); }
|
||||
void selected(const std::set<face_descriptor>& m)
|
||||
void selected(const std::set<fg_face_descriptor>& m)
|
||||
{ has_been_selected(m); }
|
||||
void selected(const std::set<edge_descriptor>& m)
|
||||
void selected(const std::set<fg_edge_descriptor>& m)
|
||||
{ has_been_selected(m); }
|
||||
|
||||
void selected_HL(const std::set<vertex_descriptor>& m);
|
||||
void selected_HL(const std::set<face_descriptor>& m);
|
||||
void selected_HL(const std::set<edge_descriptor>& m);
|
||||
void selected_HL(const std::set<fg_vertex_descriptor>& m);
|
||||
void selected_HL(const std::set<fg_face_descriptor>& m);
|
||||
void selected_HL(const std::set<fg_edge_descriptor>& m);
|
||||
void poly_item_changed() {
|
||||
remove_erased_handles<vertex_descriptor>();
|
||||
remove_erased_handles<edge_descriptor>();
|
||||
remove_erased_handles<face_descriptor>();
|
||||
remove_erased_handles<fg_vertex_descriptor>();
|
||||
remove_erased_handles<fg_edge_descriptor>();
|
||||
remove_erased_handles<fg_face_descriptor>();
|
||||
}
|
||||
void endSelection(){
|
||||
Q_EMIT simplicesSelected(this);
|
||||
|
|
@ -868,13 +868,13 @@ protected:
|
|||
tr.container().insert(*it);
|
||||
}
|
||||
}
|
||||
void join_vertex(Scene_polyhedron_selection_item::edge_descriptor ed)
|
||||
void join_vertex(Scene_polyhedron_selection_item::fg_edge_descriptor ed)
|
||||
{
|
||||
CGAL::Euler::join_vertex(halfedge(ed, *polyhedron()),*polyhedron());
|
||||
}
|
||||
|
||||
|
||||
void selectPath(vertex_descriptor vh);
|
||||
void selectPath(fg_vertex_descriptor vh);
|
||||
|
||||
//Generic class
|
||||
template<typename HandleRange>
|
||||
|
|
@ -886,17 +886,17 @@ protected:
|
|||
|
||||
template<typename HandleRange>
|
||||
bool treat_classic_selection(const HandleRange& selection);
|
||||
//Specialization for set<vertex_descriptor>
|
||||
bool treat_selection(const std::set<vertex_descriptor>& selection);
|
||||
bool treat_selection(const std::set<edge_descriptor>& selection);
|
||||
bool treat_selection(const std::set<face_descriptor>& selection);
|
||||
bool treat_selection(const std::vector<face_descriptor>& selection);
|
||||
//Specialization for set<fg_vertex_descriptor>
|
||||
bool treat_selection(const std::set<fg_vertex_descriptor>& selection);
|
||||
bool treat_selection(const std::set<fg_edge_descriptor>& selection);
|
||||
bool treat_selection(const std::set<fg_face_descriptor>& selection);
|
||||
bool treat_selection(const std::vector<fg_face_descriptor>& selection);
|
||||
|
||||
face_descriptor get_face(face_descriptor fh)
|
||||
fg_face_descriptor get_face(fg_face_descriptor fh)
|
||||
{ return fh; }
|
||||
face_descriptor get_face(vertex_descriptor)
|
||||
fg_face_descriptor get_face(fg_vertex_descriptor)
|
||||
{ return boost::graph_traits<Face_graph>::null_face(); }
|
||||
face_descriptor get_face(edge_descriptor)
|
||||
fg_face_descriptor get_face(fg_edge_descriptor)
|
||||
{ return boost::graph_traits<Face_graph>::null_face(); }
|
||||
|
||||
template<class HandleType>
|
||||
|
|
@ -907,20 +907,20 @@ template<typename HandleRange>
|
|||
|
||||
if (get_active_handle_type() == Active_handle::CONNECTED_COMPONENT)
|
||||
{
|
||||
Selection_traits<edge_descriptor,
|
||||
Selection_traits<fg_edge_descriptor,
|
||||
Scene_polyhedron_selection_item> tr(this);
|
||||
tr.update_indices();
|
||||
std::vector<bool> mark(tr.size(), false);
|
||||
BOOST_FOREACH(edge_descriptor e, selected_edges)
|
||||
BOOST_FOREACH(fg_edge_descriptor e, selected_edges)
|
||||
mark[tr.id(e)] = true;
|
||||
std::vector<face_descriptor> selected_cc;
|
||||
std::vector<fg_face_descriptor> selected_cc;
|
||||
typedef typename boost::property_map<Face_graph,boost::edge_index_t>::type PM;
|
||||
CGAL::Polygon_mesh_processing::connected_component(
|
||||
get_face(*selection.begin()),
|
||||
*polyhedron(),
|
||||
std::back_inserter(selected_cc),
|
||||
CGAL::Polygon_mesh_processing::parameters::edge_is_constrained_map(
|
||||
Is_selected_property_map<edge_descriptor,PM>(mark, get(boost::edge_index,*polyhedron()))));
|
||||
Is_selected_property_map<fg_edge_descriptor,PM>(mark, get(boost::edge_index,*polyhedron()))));
|
||||
treat_selection(selected_cc);
|
||||
}
|
||||
else
|
||||
|
|
@ -932,20 +932,20 @@ template<typename HandleRange>
|
|||
typedef boost::property_map<Face_graph,boost::edge_index_t>::type Face_graph_edge_index_pm;
|
||||
|
||||
public:
|
||||
Is_selected_property_map<edge_descriptor, Face_graph_edge_index_pm>
|
||||
Is_selected_property_map<fg_edge_descriptor, Face_graph_edge_index_pm>
|
||||
selected_edges_pmap(std::vector<bool>& mark)
|
||||
{
|
||||
Selection_traits<edge_descriptor,
|
||||
Selection_traits<fg_edge_descriptor,
|
||||
Scene_polyhedron_selection_item> tr(this);
|
||||
tr.update_indices();
|
||||
|
||||
for (unsigned int i = 0; i < mark.size(); ++i)
|
||||
mark[i] = false;
|
||||
|
||||
BOOST_FOREACH(edge_descriptor e, selected_edges)
|
||||
BOOST_FOREACH(fg_edge_descriptor e, selected_edges)
|
||||
mark[tr.id(e)] = true;
|
||||
|
||||
return Is_selected_property_map<edge_descriptor, Face_graph_edge_index_pm>(mark, get(boost::edge_index,*polyhedron()));
|
||||
return Is_selected_property_map<fg_edge_descriptor, Face_graph_edge_index_pm>(mark, get(boost::edge_index,*polyhedron()));
|
||||
}
|
||||
|
||||
Is_constrained_map<Selection_set_edge> constrained_edges_pmap()
|
||||
|
|
|
|||
|
|
@ -19,17 +19,14 @@
|
|||
#include "triangulate_primitive.h"
|
||||
|
||||
|
||||
typedef boost::graph_traits<Scene_surface_mesh_item::SMesh>::face_descriptor face_descriptor;
|
||||
typedef boost::graph_traits<Scene_surface_mesh_item::SMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef boost::graph_traits<Scene_surface_mesh_item::SMesh>::vertex_descriptor vertex_descriptor;
|
||||
//Used to triangulate the AABB_Tree
|
||||
class Primitive
|
||||
{
|
||||
public:
|
||||
// types
|
||||
typedef face_descriptor Id; // Id type
|
||||
typedef Scene_surface_mesh_item::Point Point; // point type
|
||||
typedef Scene_surface_mesh_item::Kernel::Triangle_3 Datum; // datum type
|
||||
typedef Point_3 Point; // point type
|
||||
typedef EPICK::Triangle_3 Datum; // datum type
|
||||
|
||||
private:
|
||||
// member data
|
||||
|
|
@ -54,13 +51,13 @@ public:
|
|||
};
|
||||
|
||||
|
||||
typedef CGAL::AABB_traits<Scene_surface_mesh_item::Kernel, Primitive> AABB_traits;
|
||||
typedef CGAL::AABB_traits<EPICK, Primitive> AABB_traits;
|
||||
typedef CGAL::AABB_tree<AABB_traits> Input_facets_AABB_tree;
|
||||
|
||||
struct Scene_surface_mesh_item_priv{
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef Kernel::Point_3 Point;
|
||||
typedef EPICK::Point_3 Point;
|
||||
typedef CGAL::Surface_mesh<Point> SMesh;
|
||||
typedef boost::graph_traits<SMesh>::face_descriptor face_descriptor;
|
||||
|
||||
|
|
@ -91,10 +88,10 @@ struct Scene_surface_mesh_item_priv{
|
|||
|
||||
void initialize_colors();
|
||||
void initializeBuffers(CGAL::Three::Viewer_interface *) const;
|
||||
void addFlatData(Point, Kernel::Vector_3, CGAL::Color *) const;
|
||||
void addFlatData(Point, EPICK::Vector_3, CGAL::Color *) const;
|
||||
void* get_aabb_tree();
|
||||
QList<Kernel::Triangle_3> triangulate_primitive(face_descriptor fit,
|
||||
Kernel::Vector_3 normal);
|
||||
QList<EPICK::Triangle_3> triangulate_primitive(face_descriptor fit,
|
||||
EPICK::Vector_3 normal);
|
||||
|
||||
//! \brief triangulate_facet Triangulates a facet.
|
||||
//! \param fd a face_descriptor of the facet that needs to be triangulated.
|
||||
|
|
@ -105,7 +102,7 @@ struct Scene_surface_mesh_item_priv{
|
|||
//! fill the flat data vectors.
|
||||
void
|
||||
triangulate_facet(face_descriptor fd,
|
||||
SMesh::Property_map<face_descriptor, Kernel::Vector_3 > *fnormals,
|
||||
SMesh::Property_map<face_descriptor, EPICK::Vector_3 > *fnormals,
|
||||
SMesh::Property_map<face_descriptor, CGAL::Color> *fcolors,
|
||||
boost::property_map< SMesh, boost::vertex_index_t >::type* im,
|
||||
bool index) const;
|
||||
|
|
@ -228,7 +225,16 @@ Scene_surface_mesh_item::color_vector()
|
|||
}
|
||||
|
||||
|
||||
void Scene_surface_mesh_item_priv::addFlatData(Point p, Kernel::Vector_3 n, CGAL::Color *c) const
|
||||
int
|
||||
Scene_surface_mesh_item::patch_id(SMesh::Face_index f)const
|
||||
{
|
||||
if(! d->has_fpatch_id){
|
||||
return -1;
|
||||
}
|
||||
return d->fpatch_id_map[f];
|
||||
}
|
||||
|
||||
void Scene_surface_mesh_item_priv::addFlatData(Point p, EPICK::Vector_3 n, CGAL::Color *c) const
|
||||
{
|
||||
const qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
|
||||
|
|
@ -261,11 +267,11 @@ void Scene_surface_mesh_item_priv::compute_elements()
|
|||
idx_data_.clear();
|
||||
idx_data_.shrink_to_fit();
|
||||
|
||||
SMesh::Property_map<vertex_descriptor, Kernel::Vector_3 > vnormals =
|
||||
smesh_->add_property_map<vertex_descriptor, Kernel::Vector_3 >("v:normal").first;
|
||||
SMesh::Property_map<vertex_descriptor, EPICK::Vector_3 > vnormals =
|
||||
smesh_->add_property_map<vertex_descriptor, EPICK::Vector_3 >("v:normal").first;
|
||||
|
||||
SMesh::Property_map<face_descriptor, Kernel::Vector_3 > fnormals =
|
||||
smesh_->add_property_map<face_descriptor, Kernel::Vector_3 >("f:normal").first;
|
||||
SMesh::Property_map<face_descriptor, EPICK::Vector_3 > fnormals =
|
||||
smesh_->add_property_map<face_descriptor, EPICK::Vector_3 >("f:normal").first;
|
||||
CGAL::Polygon_mesh_processing::compute_face_normals(*smesh_,fnormals);
|
||||
|
||||
typedef boost::graph_traits<SMesh>::face_descriptor face_descriptor;
|
||||
|
|
@ -357,7 +363,7 @@ void Scene_surface_mesh_item_priv::compute_elements()
|
|||
flat_vertices.push_back((cgal_gl_data)p.y()+offset.y);
|
||||
flat_vertices.push_back((cgal_gl_data)p.z()+offset.z);
|
||||
|
||||
Kernel::Vector_3 n = fnormals[fd];
|
||||
EPICK::Vector_3 n = fnormals[fd];
|
||||
flat_normals.push_back((cgal_gl_data)n.x());
|
||||
flat_normals.push_back((cgal_gl_data)n.y());
|
||||
flat_normals.push_back((cgal_gl_data)n.z());
|
||||
|
|
@ -383,7 +389,7 @@ void Scene_surface_mesh_item_priv::compute_elements()
|
|||
//1st half
|
||||
halfedge_descriptor hd = halfedge(fd, *smesh_);
|
||||
Point p = positions[source(hd, *smesh_)];
|
||||
Kernel::Vector_3 n = fnormals[fd];
|
||||
EPICK::Vector_3 n = fnormals[fd];
|
||||
CGAL::Color *c;
|
||||
if(has_fcolors)
|
||||
c= &fcolors[fd];
|
||||
|
|
@ -442,7 +448,7 @@ void Scene_surface_mesh_item_priv::compute_elements()
|
|||
smooth_vertices.push_back((cgal_gl_data)p.y()+offset.y);
|
||||
smooth_vertices.push_back((cgal_gl_data)p.z()+offset.z);
|
||||
|
||||
Kernel::Vector_3 n = vnormals[vd];
|
||||
EPICK::Vector_3 n = vnormals[vd];
|
||||
smooth_normals.push_back((cgal_gl_data)n.x());
|
||||
smooth_normals.push_back((cgal_gl_data)n.y());
|
||||
smooth_normals.push_back((cgal_gl_data)n.z());
|
||||
|
|
@ -472,8 +478,8 @@ void Scene_surface_mesh_item_priv::initializeBuffers(CGAL::Three::Viewer_interfa
|
|||
{
|
||||
SMesh::Property_map<vertex_descriptor, SMesh::Point> positions =
|
||||
smesh_->points();
|
||||
SMesh::Property_map<vertex_descriptor, Kernel::Vector_3 > vnormals =
|
||||
smesh_->property_map<vertex_descriptor, Kernel::Vector_3 >("v:normal").first;
|
||||
SMesh::Property_map<vertex_descriptor, EPICK::Vector_3 > vnormals =
|
||||
smesh_->property_map<vertex_descriptor, EPICK::Vector_3 >("v:normal").first;
|
||||
//vao containing the data for the flat facets
|
||||
|
||||
program = item->getShaderProgram(Scene_surface_mesh_item::PROGRAM_WITH_LIGHT, viewer);
|
||||
|
|
@ -706,13 +712,13 @@ void Scene_surface_mesh_item_priv::checkFloat()const
|
|||
|
||||
void
|
||||
Scene_surface_mesh_item_priv::triangulate_facet(face_descriptor fd,
|
||||
SMesh::Property_map<face_descriptor, Kernel::Vector_3> *fnormals,
|
||||
SMesh::Property_map<face_descriptor, EPICK::Vector_3> *fnormals,
|
||||
SMesh::Property_map<face_descriptor, CGAL::Color> *fcolors,
|
||||
boost::property_map< SMesh, boost::vertex_index_t >::type *im,
|
||||
bool index) const
|
||||
{
|
||||
//Computes the normal of the facet
|
||||
Kernel::Vector_3 normal = get(*fnormals, fd);
|
||||
EPICK::Vector_3 normal = get(*fnormals, fd);
|
||||
|
||||
//check if normal contains NaN values
|
||||
if (normal.x() != normal.x() || normal.y() != normal.y() || normal.z() != normal.z())
|
||||
|
|
@ -786,12 +792,12 @@ Scene_surface_mesh_item::~Scene_surface_mesh_item()
|
|||
delete_aabb_tree(this);
|
||||
delete d;
|
||||
}
|
||||
Scene_surface_mesh_item::SMesh* Scene_surface_mesh_item::polyhedron() { return d->smesh_; }
|
||||
const Scene_surface_mesh_item::SMesh* Scene_surface_mesh_item::polyhedron() const { return d->smesh_; }
|
||||
SMesh* Scene_surface_mesh_item::polyhedron() { return d->smesh_; }
|
||||
const SMesh* Scene_surface_mesh_item::polyhedron() const { return d->smesh_; }
|
||||
|
||||
void Scene_surface_mesh_item::compute_bbox()const
|
||||
{
|
||||
SMesh::Property_map<vertex_descriptor, Point> pprop = d->smesh_->points();
|
||||
SMesh::Property_map<vertex_descriptor, Point_3> pprop = d->smesh_->points();
|
||||
CGAL::Bbox_3 bbox;
|
||||
|
||||
BOOST_FOREACH(vertex_descriptor vd,vertices(*d->smesh_))
|
||||
|
|
@ -833,9 +839,9 @@ void* Scene_surface_mesh_item_priv::get_aabb_tree()
|
|||
//if face not triangle, triangulate corresponding primitive before adding it to the tree
|
||||
if(!CGAL::is_triangle(halfedge(f, *sm), *sm))
|
||||
{
|
||||
Kernel::Vector_3 normal = CGAL::Polygon_mesh_processing::compute_face_normal(f, *sm);
|
||||
EPICK::Vector_3 normal = CGAL::Polygon_mesh_processing::compute_face_normal(f, *sm);
|
||||
index +=3;
|
||||
Q_FOREACH(Kernel::Triangle_3 triangle, triangulate_primitive(f,normal))
|
||||
Q_FOREACH(EPICK::Triangle_3 triangle, triangulate_primitive(f,normal))
|
||||
{
|
||||
Primitive primitive(triangle, f);
|
||||
tree->insert(primitive);
|
||||
|
|
@ -843,7 +849,7 @@ void* Scene_surface_mesh_item_priv::get_aabb_tree()
|
|||
}
|
||||
else
|
||||
{
|
||||
Kernel::Triangle_3 triangle(
|
||||
EPICK::Triangle_3 triangle(
|
||||
sm->point(target(halfedge(f, *sm), *sm)),
|
||||
sm->point(target(next(halfedge(f, *sm), *sm), *sm)),
|
||||
sm->point(target(next(next(halfedge(f, *sm), *sm), *sm), *sm))
|
||||
|
|
@ -873,14 +879,14 @@ Scene_surface_mesh_item::select(double orig_x,
|
|||
SMesh *sm = d->smesh_;
|
||||
std::size_t vertex_to_emit = 0;
|
||||
typedef Input_facets_AABB_tree Tree;
|
||||
typedef Tree::Intersection_and_primitive_id<Kernel::Ray_3>::Type Object_and_primitive_id;
|
||||
typedef Tree::Intersection_and_primitive_id<EPICK::Ray_3>::Type Object_and_primitive_id;
|
||||
|
||||
Tree* aabb_tree = static_cast<Tree*>(d->get_aabb_tree());
|
||||
if(aabb_tree)
|
||||
{
|
||||
const Kernel::Point_3 ray_origin(orig_x, orig_y, orig_z);
|
||||
const Kernel::Vector_3 ray_dir(dir_x, dir_y, dir_z);
|
||||
const Kernel::Ray_3 ray(ray_origin, ray_dir);
|
||||
const EPICK::Point_3 ray_origin(orig_x, orig_y, orig_z);
|
||||
const EPICK::Vector_3 ray_dir(dir_x, dir_y, dir_z);
|
||||
const EPICK::Ray_3 ray(ray_origin, ray_dir);
|
||||
typedef std::list<Object_and_primitive_id> Intersections;
|
||||
Intersections intersections;
|
||||
aabb_tree->all_intersections(ray, std::back_inserter(intersections));
|
||||
|
|
@ -888,8 +894,8 @@ Scene_surface_mesh_item::select(double orig_x,
|
|||
if(closest != intersections.end())
|
||||
{
|
||||
|
||||
const Kernel::Point_3* closest_point =
|
||||
boost::get<Kernel::Point_3>(&(closest->first));
|
||||
const EPICK::Point_3* closest_point =
|
||||
boost::get<EPICK::Point_3>(&(closest->first));
|
||||
for(Intersections::iterator
|
||||
it = boost::next(intersections.begin()),
|
||||
end = intersections.end();
|
||||
|
|
@ -899,8 +905,8 @@ Scene_surface_mesh_item::select(double orig_x,
|
|||
closest = it;
|
||||
}
|
||||
else {
|
||||
const Kernel::Point_3* it_point =
|
||||
boost::get<Kernel::Point_3>(&it->first);
|
||||
const EPICK::Point_3* it_point =
|
||||
boost::get<EPICK::Point_3>(&it->first);
|
||||
if(it_point &&
|
||||
(ray_dir * (*it_point - *closest_point)) < 0)
|
||||
{
|
||||
|
|
@ -922,11 +928,11 @@ Scene_surface_mesh_item::select(double orig_x,
|
|||
|
||||
vertex_descriptor v = sm->target(*he_it), nearest_v = v;
|
||||
|
||||
Kernel::FT sq_dist = CGAL::squared_distance(*closest_point,
|
||||
EPICK::FT sq_dist = CGAL::squared_distance(*closest_point,
|
||||
sm->point(v));
|
||||
while(++he_it != around_end) {
|
||||
v = sm->target(*he_it);
|
||||
Kernel::FT new_sq_dist = CGAL::squared_distance(*closest_point,
|
||||
EPICK::FT new_sq_dist = CGAL::squared_distance(*closest_point,
|
||||
sm->point(v));
|
||||
if(new_sq_dist < sq_dist) {
|
||||
sq_dist = new_sq_dist;
|
||||
|
|
@ -943,18 +949,18 @@ Scene_surface_mesh_item::select(double orig_x,
|
|||
SMesh::Halfedge_around_face_circulator he_it(sm->halfedge(selected_face),*sm), around_end(he_it);
|
||||
|
||||
halfedge_descriptor nearest_h = *he_it;
|
||||
Kernel::FT sq_dist =
|
||||
EPICK::FT sq_dist =
|
||||
CGAL::squared_distance(*closest_point,
|
||||
Kernel::Segment_3(sm->point(sm->target(*he_it)),
|
||||
EPICK::Segment_3(sm->point(sm->target(*he_it)),
|
||||
sm->point(
|
||||
sm->target(
|
||||
sm->opposite(*he_it)))));
|
||||
|
||||
while(++he_it != around_end)
|
||||
{
|
||||
Kernel::FT new_sq_dist =
|
||||
EPICK::FT new_sq_dist =
|
||||
CGAL::squared_distance(*closest_point,
|
||||
Kernel::Segment_3(sm->point(sm->target(*he_it)),
|
||||
EPICK::Segment_3(sm->point(sm->target(*he_it)),
|
||||
sm->point(
|
||||
sm->target(
|
||||
sm->opposite(*he_it)))));
|
||||
|
|
@ -987,17 +993,17 @@ void Scene_surface_mesh_item::invalidateOpenGLBuffers()
|
|||
}
|
||||
|
||||
|
||||
QList<Scene_surface_mesh_item::Kernel::Triangle_3> Scene_surface_mesh_item_priv::triangulate_primitive(face_descriptor fit,
|
||||
Scene_surface_mesh_item::Kernel::Vector_3 normal)
|
||||
QList<EPICK::Triangle_3> Scene_surface_mesh_item_priv::triangulate_primitive(face_descriptor fit,
|
||||
EPICK::Vector_3 normal)
|
||||
{
|
||||
typedef FacetTriangulator<SMesh, Kernel, boost::graph_traits<SMesh>::vertex_descriptor> FT;
|
||||
//The output list
|
||||
QList<Kernel::Triangle_3> res;
|
||||
QList<EPICK::Triangle_3> res;
|
||||
//check if normal contains NaN values
|
||||
if (normal.x() != normal.x() || normal.y() != normal.y() || normal.z() != normal.z())
|
||||
{
|
||||
qDebug()<<"Warning in triangulation of the selection item: normal contains NaN values and is not valid.";
|
||||
return QList<Kernel::Triangle_3>();
|
||||
return QList<EPICK::Triangle_3>();
|
||||
}
|
||||
double diagonal;
|
||||
if(item->diagonalBbox() != std::numeric_limits<double>::infinity())
|
||||
|
|
@ -1016,7 +1022,7 @@ QList<Scene_surface_mesh_item::Kernel::Triangle_3> Scene_surface_mesh_item_priv:
|
|||
continue;
|
||||
|
||||
|
||||
res << Kernel::Triangle_3(ffit->vertex(0)->point(),
|
||||
res << EPICK::Triangle_3(ffit->vertex(0)->point(),
|
||||
ffit->vertex(1)->point(),
|
||||
ffit->vertex(2)->point());
|
||||
|
||||
|
|
@ -1044,17 +1050,17 @@ bool Scene_surface_mesh_item::intersect_face(double orig_x,
|
|||
Tree* aabb_tree = static_cast<Tree*>(d->get_aabb_tree());
|
||||
if(aabb_tree)
|
||||
{
|
||||
const Kernel::Point_3 ray_origin(orig_x, orig_y, orig_z);
|
||||
const Kernel::Vector_3 ray_dir(dir_x, dir_y, dir_z);
|
||||
const Kernel::Ray_3 ray(ray_origin, ray_dir);
|
||||
const EPICK::Point_3 ray_origin(orig_x, orig_y, orig_z);
|
||||
const EPICK::Vector_3 ray_dir(dir_x, dir_y, dir_z);
|
||||
const EPICK::Ray_3 ray(ray_origin, ray_dir);
|
||||
typedef std::list<Object_and_primitive_id> Intersections;
|
||||
Intersections intersections;
|
||||
aabb_tree->all_intersections(ray, std::back_inserter(intersections));
|
||||
Intersections::iterator closest = intersections.begin();
|
||||
if(closest != intersections.end())
|
||||
{
|
||||
const Kernel::Point_3* closest_point =
|
||||
CGAL::object_cast<Kernel::Point_3>(&closest->first);
|
||||
const EPICK::Point_3* closest_point =
|
||||
CGAL::object_cast<EPICK::Point_3>(&closest->first);
|
||||
for(Intersections::iterator
|
||||
it = boost::next(intersections.begin()),
|
||||
end = intersections.end();
|
||||
|
|
@ -1064,8 +1070,8 @@ bool Scene_surface_mesh_item::intersect_face(double orig_x,
|
|||
closest = it;
|
||||
}
|
||||
else {
|
||||
const Kernel::Point_3* it_point =
|
||||
CGAL::object_cast<Kernel::Point_3>(&it->first);
|
||||
const EPICK::Point_3* it_point =
|
||||
CGAL::object_cast<EPICK::Point_3>(&it->first);
|
||||
if(it_point &&
|
||||
(ray_dir * (*it_point - *closest_point)) < 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,23 +6,15 @@
|
|||
#define CGAL_IS_FLOAT 1
|
||||
|
||||
#include "Scene_surface_mesh_item_config.h"
|
||||
#include "SMesh_type.h"
|
||||
#include <CGAL/Three/Scene_item.h>
|
||||
#include <CGAL/Three/Viewer_interface.h>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/array.hpp>
|
||||
|
||||
#include <CGAL/Surface_mesh/Surface_mesh_fwd.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/properties.h>
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <QColor>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/properties.h>
|
||||
|
||||
struct Scene_surface_mesh_item_priv;
|
||||
|
||||
class SCENE_SURFACE_MESH_ITEM_EXPORT Scene_surface_mesh_item
|
||||
|
|
@ -39,7 +31,7 @@ public:
|
|||
typedef boost::graph_traits<SMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef SMesh::Property_map<vertex_descriptor,int> Vertex_selection_map;
|
||||
typedef SMesh::Property_map<face_descriptor,int> Face_selection_map;
|
||||
|
||||
typedef SMesh FaceGraph;
|
||||
Scene_surface_mesh_item();
|
||||
// Takes ownership of the argument.
|
||||
Scene_surface_mesh_item(SMesh*);
|
||||
|
|
@ -113,93 +105,4 @@ protected:
|
|||
Scene_surface_mesh_item_priv* d;
|
||||
};
|
||||
|
||||
typedef Scene_surface_mesh_item::SMesh SMesh;
|
||||
namespace CGAL{
|
||||
SMesh::Property_map<boost::graph_traits<SMesh>::halfedge_descriptor,bool>
|
||||
inline get(CGAL::halfedge_is_feature_t, SMesh& smesh)
|
||||
{
|
||||
typedef boost::graph_traits<SMesh >::halfedge_descriptor halfedge_descriptor;
|
||||
return smesh.add_property_map<halfedge_descriptor,bool>("h:is_feature").first;
|
||||
}
|
||||
|
||||
|
||||
SMesh::Property_map< boost::graph_traits<SMesh >::face_descriptor,int>
|
||||
inline get(CGAL::face_patch_id_t, SMesh& smesh)
|
||||
{
|
||||
typedef boost::graph_traits<SMesh >::face_descriptor face_descriptor;
|
||||
return smesh.add_property_map<face_descriptor,int>("f:patch_id").first;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SMesh::Property_map< boost::graph_traits<SMesh >::face_descriptor,int>
|
||||
inline get(CGAL::face_selection_t, SMesh& smesh)
|
||||
{
|
||||
typedef boost::graph_traits<SMesh >::face_descriptor face_descriptor;
|
||||
return smesh.add_property_map<face_descriptor,int>("f:selection").first;
|
||||
}
|
||||
|
||||
|
||||
|
||||
SMesh::Property_map< boost::graph_traits<SMesh >::vertex_descriptor,int>
|
||||
inline get(CGAL::vertex_selection_t, SMesh& smesh)
|
||||
{
|
||||
typedef boost::graph_traits<SMesh >::vertex_descriptor vertex_descriptor;
|
||||
return smesh.add_property_map<vertex_descriptor,int>("v:selection").first;
|
||||
}
|
||||
|
||||
|
||||
SMesh::Property_map< boost::graph_traits<SMesh >::vertex_descriptor,int>
|
||||
inline get(CGAL::vertex_num_feature_edges_t, SMesh& smesh)
|
||||
{
|
||||
typedef boost::graph_traits<SMesh >::vertex_descriptor vertex_descriptor;
|
||||
return smesh.add_property_map<vertex_descriptor,int>("v:nfe").first;
|
||||
}
|
||||
}
|
||||
namespace boost
|
||||
{
|
||||
template<>
|
||||
struct property_map<SMesh, CGAL::halfedge_is_feature_t>
|
||||
{
|
||||
typedef boost::graph_traits<SMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
|
||||
typedef SMesh::Property_map<halfedge_descriptor, bool> type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct property_map<SMesh, CGAL::face_patch_id_t>
|
||||
{
|
||||
typedef boost::graph_traits<SMesh>::face_descriptor face_descriptor;
|
||||
|
||||
typedef SMesh::Property_map<face_descriptor, int> type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct property_map<SMesh, CGAL::vertex_selection_t>
|
||||
{
|
||||
|
||||
typedef boost::graph_traits<SMesh>::vertex_descriptor vertex_descriptor;
|
||||
|
||||
typedef SMesh::Property_map<vertex_descriptor, int> type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct property_map<SMesh, CGAL::face_selection_t>
|
||||
{
|
||||
|
||||
typedef boost::graph_traits<SMesh>::face_descriptor face_descriptor;
|
||||
|
||||
typedef SMesh::Property_map<face_descriptor, int> type;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct property_map<SMesh, CGAL::vertex_num_feature_edges_t>
|
||||
{
|
||||
|
||||
typedef boost::graph_traits<SMesh>::vertex_descriptor vertex_descriptor;
|
||||
|
||||
typedef SMesh::Property_map<vertex_descriptor, int> type;
|
||||
};
|
||||
} //boost
|
||||
|
||||
#endif /* CGAL_SCENE_SURFACE_MESH_ITEM_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue