diff --git a/.gitattributes b/.gitattributes
index 0f0624be90b..5fddd29d4ff 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1723,6 +1723,8 @@ Kernel_23/include/CGAL/internal/Projection_traits_3.h -text
Kernel_23/test/Kernel_23/CMakeLists.txt -text
Kernel_d/doc_tex/Kernel_d/hypercube.png -text
Kernel_d/doc_tex/Kernel_d_ref/Kernel_Compute_coordinate_d.tex -text
+Kernel_d/doc_tex/Kernel_d_ref/Kernel_Less_coordinate_d.tex -text
+Kernel_d/doc_tex/Kernel_d_ref/Kernel_Point_dimension_d.tex -text
Kernel_d/include/CGAL/Kernel_d/Cartesian_const_iterator_d.h -text
Kernel_d/test/Kernel_d/Linear_algebra-test.cmd eol=lf
Kinetic_data_structures/demo/Kinetic_data_structures/data/after002 -text
@@ -2860,6 +2862,7 @@ Polygon/doc_tex/Polygon/polygon.png -text
Polyhedron/demo/Polyhedron/MainWindow.ui -text
Polyhedron/demo/Polyhedron/Polyhedron_3.qrc -text
Polyhedron/demo/Polyhedron/Remeshing_dialog.ui -text
+Polyhedron/demo/Polyhedron/Show_point_dialog.ui -text
Polyhedron/demo/Polyhedron/cgal_test_with_cmake eol=lf
Polyhedron/demo/Polyhedron/data/anchor.off -text svneol=unset#application/octet-stream
Polyhedron/demo/Polyhedron/data/bones.off -text svneol=unset#application/octet-stream
@@ -3314,12 +3317,38 @@ Spatial_searching/doc_tex/Spatial_searching/windowQuery.png -text
Spatial_searching/include/CGAL/internal/K_neighbor_search.h -text
Spatial_searching/include/CGAL/internal/bounded_priority_queue.h -text
Spatial_searching/test/Spatial_searching/Compare_methods.cpp -text
+Spatial_sorting/doc_tex/Spatial_sorting/fig/Hilbert-median.gif -text
+Spatial_sorting/doc_tex/Spatial_sorting/fig/Hilbert-median.pdf -text
+Spatial_sorting/doc_tex/Spatial_sorting/fig/Hilbert-middle.gif -text
+Spatial_sorting/doc_tex/Spatial_sorting/fig/Hilbert-middle.pdf -text
+Spatial_sorting/doc_tex/Spatial_sorting/fig/Hilbert8.gif -text
+Spatial_sorting/doc_tex/Spatial_sorting/fig/Hilbert8.pdf -text
Spatial_sorting/doc_tex/Spatial_sorting/fig/hilbert.png -text
Spatial_sorting/doc_tex/Spatial_sorting/fig/hilbertLarge.jpg -text
-Spatial_sorting/dont_submit -text
-Spatial_sorting/examples/Spatial_sorting/data/input.cin -text
-Spatial_sorting/examples/Spatial_sorting/example_delaunay_2.cmd -text
-Spatial_sorting/examples/Spatial_sorting/sort_indices.cmd -text
+Spatial_sorting/doc_tex/Spatial_sorting_ref/Hilbert_policy_tags.tex -text
+Spatial_sorting/doc_tex/Spatial_sorting_ref/Hilbert_sort_d.tex -text
+Spatial_sorting/doc_tex/Spatial_sorting_ref/SpatialSortingTraits_d.tex -text
+Spatial_sorting/doc_tex/Spatial_sorting_ref/Spatial_sort_traits_adapter_2.tex -text
+Spatial_sorting/doc_tex/Spatial_sorting_ref/Spatial_sort_traits_adapter_3.tex -text
+Spatial_sorting/doc_tex/Spatial_sorting_ref/Spatial_sort_traits_adapter_d.tex -text
+Spatial_sorting/examples/Spatial_sorting/hilbert.cpp -text
+Spatial_sorting/examples/Spatial_sorting/hilbert_policies.cpp -text
+Spatial_sorting/examples/Spatial_sorting/small_example_delaunay_2.cpp -text
+Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_2.cpp -text
+Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_3.cpp -text
+Spatial_sorting/examples/Spatial_sorting/sp_sort_using_property_map_d.cpp -text
+Spatial_sorting/include/CGAL/Hilbert_policy_tags.h -text
+Spatial_sorting/include/CGAL/Hilbert_sort_d.h -text
+Spatial_sorting/include/CGAL/Hilbert_sort_median_2.h -text
+Spatial_sorting/include/CGAL/Hilbert_sort_median_3.h -text
+Spatial_sorting/include/CGAL/Hilbert_sort_median_d.h -text
+Spatial_sorting/include/CGAL/Hilbert_sort_middle_2.h -text
+Spatial_sorting/include/CGAL/Hilbert_sort_middle_3.h -text
+Spatial_sorting/include/CGAL/Hilbert_sort_middle_base.h -text
+Spatial_sorting/include/CGAL/Hilbert_sort_middle_d.h -text
+Spatial_sorting/include/CGAL/Spatial_sort_traits_adapter_2.h -text
+Spatial_sorting/include/CGAL/Spatial_sort_traits_adapter_3.h -text
+Spatial_sorting/include/CGAL/Spatial_sort_traits_adapter_d.h -text
Straight_skeleton_2/demo/Straight_skeleton_2/data/complex_0.poly -text svneol=unset#application/octet-stream
Straight_skeleton_2/demo/Straight_skeleton_2/data/complex_1.poly -text svneol=unset#application/octet-stream
Straight_skeleton_2/demo/Straight_skeleton_2/data/complex_2.poly -text svneol=unset#application/octet-stream
@@ -4106,7 +4135,7 @@ Triangulation_3/examples/Triangulation_3/info_insert_with_zip_iterator.cpp -text
Triangulation_3/include/CGAL/internal/Static_filters/Compare_weighted_squared_radius_3.h -text
Triangulation_3/include/CGAL/internal/Static_filters/Power_test_3.h -text
Triangulation_3/include/CGAL/internal/Static_filters/Regular_triangulation_static_filters_traits_3.h -text
-Triangulation_3/include/CGAL/internal/spatial_sorting_traits_with_indices.h -text
+Triangulation_3/include/CGAL/internal/info_check.h -text
Triangulation_3/test/Triangulation_3/include/CGAL/_test_remove_cluster.h -text
Triangulation_3/test/Triangulation_3/test_regular_insert_range_with_info.cpp -text
Triangulation_3/test/Triangulation_3/test_static_filters.cpp -text
diff --git a/CGALimageIO/demo/CGALimageIO/CMakeLists.txt b/CGALimageIO/demo/CGALimageIO/CMakeLists.txt
index bae0cdad183..0dbff9bf359 100644
--- a/CGALimageIO/demo/CGALimageIO/CMakeLists.txt
+++ b/CGALimageIO/demo/CGALimageIO/CMakeLists.txt
@@ -30,13 +30,17 @@ endforeach()
find_package(CGAL REQUIRED ImageIO)
include( ${CGAL_USE_FILE} )
find_package(VTK QUIET)
+find_package(Qt3-patched QUIET)
-if(VTK_FOUND)
+if(QT3_FOUND AND VTK_FOUND)
add_definitions(-DCGAL_USE_VTK)
include(${VTK_USE_FILE})
+ add_definitions(${QT3_DEFINITIONS})
+
if(VTK_USE_QVTK)
include_directories( ${VTK_QT_INCLUDE_DIR} )
+ include_directories( ${QT3_INCLUDE_DIR} )
add_executable( image_to_vtk_viewer image_to_vtk_viewer.cpp )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS image_to_vtk_viewer )
@@ -48,12 +52,16 @@ if(VTK_FOUND)
vtkCommon
${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}
${VTK_QT_QT_LIBRARY}
+ ${QT3_LIBRARIES}
)
else(VTK_USE_QVTK)
message(STATUS "NOTICE: This demo needs QVTK, and will not be compiled.")
endif(VTK_USE_QVTK)
-else(VTK_FOUND)
-
- message(STATUS "NOTICE: This demo needs VTK, and will not be compiled.")
-
-endif(VTK_FOUND)
+else()
+ if(NOT VTK_FOUND)
+ message(STATUS "NOTICE: This demo needs VTK, and will not be compiled.")
+ endif()
+ if(NOT QT3_FOUND)
+ message(STATUS "NOTICE: This demo needs Qt3, and will not be compiled.")
+ endif()
+endif()
diff --git a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_akl_toussaint_impl.h b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_akl_toussaint_impl.h
index 7e75eee7c84..76f7556f02e 100644
--- a/Convex_hull_2/include/CGAL/Convex_hull_2/ch_akl_toussaint_impl.h
+++ b/Convex_hull_2/include/CGAL/Convex_hull_2/ch_akl_toussaint_impl.h
@@ -98,9 +98,9 @@ ch_akl_toussaint(ForwardIterator first, ForwardIterator last,
std::sort( successor(region2.begin() ), region2.end(),
ch_traits.less_xy_2_object() );
std::sort( successor(region3.begin() ), region3.end(),
- bind(ch_traits.less_xy_2_object(), _2, _1) );
+ boost::bind(ch_traits.less_xy_2_object(), _2, _1) );
std::sort( successor(region4.begin() ), region4.end(),
- bind(ch_traits.less_xy_2_object(), _2, _1) );
+ boost::bind(ch_traits.less_xy_2_object(), _2, _1) );
if (! equal_points(*w,*s) )
{
diff --git a/GraphicsView/demo/Triangulation_2/include/CGAL/Lipschitz_sizing_field_criteria_2.h b/GraphicsView/demo/Triangulation_2/include/CGAL/Lipschitz_sizing_field_criteria_2.h
index 8085c29c27b..ad4da9f21bf 100644
--- a/GraphicsView/demo/Triangulation_2/include/CGAL/Lipschitz_sizing_field_criteria_2.h
+++ b/GraphicsView/demo/Triangulation_2/include/CGAL/Lipschitz_sizing_field_criteria_2.h
@@ -24,21 +24,27 @@ public:
protected:
Sizing_field* sizing_field;
+
+ typedef typename CDT::Geom_traits Geom_traits;
+ Geom_traits traits;
public:
typedef Delaunay_mesh_criteria_2 Base;
Lipschitz_sizing_field_criteria_2(const double aspect_bound = 0.125,
- Sizing_field* sf = 0)
- : Base(aspect_bound), sizing_field(sf)
+ Sizing_field* sf = 0,
+ const Geom_traits& traits = Geom_traits())
+ : Base(aspect_bound), sizing_field(sf), traits(traits)
{}
Lipschitz_sizing_field_criteria_2& operator =(const Lipschitz_sizing_field_criteria_2& c)
{
+ if(&c == this) return *this;
this->sizing_field = c.sizing_field;
+ this->traits = c.traits;
return *this;
- }
+ }
inline const Sizing_field* sizing_field_object()
{
@@ -81,8 +87,9 @@ public:
typedef typename Base::Is_bad::Point_2 Point_2;
- Is_bad(const double aspect_bound, Sizing_field* sf)
- : Base::Is_bad(aspect_bound), sizing_field(sf)
+ Is_bad(const double aspect_bound, Sizing_field* sf,
+ const Geom_traits& traits)
+ : Base::Is_bad(aspect_bound, traits), sizing_field(sf)
{
}
@@ -189,7 +196,7 @@ public:
Is_bad is_bad_object() const
{
- return Is_bad(this->bound(), sizing_field);
+ return Is_bad(this->bound(), sizing_field, traits);
}
};
diff --git a/Installation/changes.html b/Installation/changes.html
index c1b213e0c4e..48c2733bb31 100644
--- a/Installation/changes.html
+++ b/Installation/changes.html
@@ -114,6 +114,16 @@ CGAL 3.9 offers the following improvements and new functionality :
Various fixes in the manual.
+ dD Kernel
+ The d-dimensional kernel concept and models have been modified
+ to additionally provide two new functors Less_coordinate_d and Point_dimension_d.
+ Spatial_sorting (major new feature added)
+
+ - General dimension is now supported.
+ - Hilbert sorting admits now two policies: splitting at
+ median or at middle (see user manual).
+ - Using a property map, sorting on keys instead of points is now easier
+
Release 3.8
diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Kernel.tex b/Kernel_d/doc_tex/Kernel_d_ref/Kernel.tex
index ecdd47bdf6f..00116ee1002 100644
--- a/Kernel_d/doc_tex/Kernel_d_ref/Kernel.tex
+++ b/Kernel_d/doc_tex/Kernel_d_ref/Kernel.tex
@@ -108,6 +108,8 @@ replacing operators, especially for equality testing.
\ccGlue
\ccNestedType{Less_or_equal_lexicographically_d}{}
\ccGlue
+\ccNestedType{Less_coordinate_d}{}
+\ccGlue
\ccNestedType{Lift_to_paraboloid_d}{}
\ccGlue
\ccNestedType{Linear_base_d}{}
@@ -124,6 +126,8 @@ replacing operators, especially for equality testing.
\ccGlue
\ccNestedType{Orthogonal_vector_d}{}
\ccGlue
+\ccNestedType{Point_dimension_d}{}
+\ccGlue
\ccNestedType{Point_of_sphere_d}{}
\ccGlue
\ccNestedType{Point_to_vector_d}{}
diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Kernel_Less_coordinate_d.tex b/Kernel_d/doc_tex/Kernel_d_ref/Kernel_Less_coordinate_d.tex
new file mode 100755
index 00000000000..b47f0e2b256
--- /dev/null
+++ b/Kernel_d/doc_tex/Kernel_d_ref/Kernel_Less_coordinate_d.tex
@@ -0,0 +1,13 @@
+\begin{ccRefFunctionObjectConcept}{Kernel::Less_coordinate_d}
+A model for this must provide:
+
+\ccCreationVariable{fo}
+
+\ccMemberFunction{ bool operator()(const Kernel::Point_d&
+ p,const Kernel::Point_d&
+ q, int i);} {returns \ccc{true} iff the $i$th cartesian coordinate
+ of \ccc{p} is
+ smaller than the $i$th cartesian coordinate of \ccc{q}. \ccPrecond \ccc{p} and \ccc{q} have
+ the same dimension.}
+
+\end{ccRefFunctionObjectConcept}
diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Kernel_Point_dimension_d.tex b/Kernel_d/doc_tex/Kernel_d_ref/Kernel_Point_dimension_d.tex
new file mode 100644
index 00000000000..29b8b175a19
--- /dev/null
+++ b/Kernel_d/doc_tex/Kernel_d_ref/Kernel_Point_dimension_d.tex
@@ -0,0 +1,9 @@
+\begin{ccRefFunctionObjectConcept}{Kernel::Point_dimension_d}
+A model for this must provide:
+
+\ccCreationVariable{fo}
+
+\ccMemberFunction{ int operator()(const Kernel::Point_d&
+ p);} {returns the dimension of $p$}
+
+\end{ccRefFunctionObjectConcept}
diff --git a/Kernel_d/doc_tex/Kernel_d_ref/main.tex b/Kernel_d/doc_tex/Kernel_d_ref/main.tex
index 8bd81972aa0..9ad0cc9a3d7 100644
--- a/Kernel_d/doc_tex/Kernel_d_ref/main.tex
+++ b/Kernel_d/doc_tex/Kernel_d_ref/main.tex
@@ -88,6 +88,7 @@
\input{Kernel_d_ref/Kernel_Intersect_d.tex}
\input{Kernel_d_ref/Kernel_Less_lexicographically_d.tex}
\input{Kernel_d_ref/Kernel_Less_or_equal_lexicographically_d.tex}
+\input{Kernel_d_ref/Kernel_Less_coordinate_d.tex}
\input{Kernel_d_ref/Kernel_Lift_to_paraboloid_d.tex}
\input{Kernel_d_ref/Kernel_Linearly_independent_d.tex}
\input{Kernel_d_ref/Kernel_Linear_base_d.tex}
@@ -96,6 +97,7 @@
\input{Kernel_d_ref/Kernel_Orientation_d.tex}
\input{Kernel_d_ref/Kernel_Oriented_side_d.tex}
\input{Kernel_d_ref/Kernel_Orthogonal_vector_d.tex}
+\input{Kernel_d_ref/Kernel_Point_dimension_d.tex}
\input{Kernel_d_ref/Kernel_Point_of_sphere_d.tex}
\input{Kernel_d_ref/Kernel_Point_to_vector_d.tex}
\input{Kernel_d_ref/Kernel_Project_along_d_axis_d.tex}
diff --git a/Kernel_d/include/CGAL/Cartesian_d.h b/Kernel_d/include/CGAL/Cartesian_d.h
index 6d889e0116d..52097613d40 100644
--- a/Kernel_d/include/CGAL/Cartesian_d.h
+++ b/Kernel_d/include/CGAL/Cartesian_d.h
@@ -251,6 +251,8 @@ public:
typedef Compare_lexicographicallyCd
Compare_lexicographically_d;
typedef Lt_from_compare Less_lexicographically_d;
typedef Le_from_compare Less_or_equal_lexicographically_d;
+ typedef Less_coordinateCd Less_coordinate_d;
+ typedef Point_dimensionCd Point_dimension_d;
typedef Eq_from_method Equal_d;
typedef Center_of_sphereCd Center_of_sphere_d;
typedef Contained_in_linear_hullCd Contained_in_linear_hull_d;
@@ -260,6 +262,10 @@ public:
Compute_coordinate_d compute_coordinate_d_object() const
{ return Compute_coordinate_d(); }
+ Point_dimension_d point_dimension_d_object() const
+ { return Point_dimension_d(); }
+ Less_coordinate_d less_coordinate_d_object() const
+ { return Less_coordinate_d(); }
Lift_to_paraboloid_d lift_to_paraboloid_d_object() const
{ return Lift_to_paraboloid_d(); }
Project_along_d_axis_d project_along_d_axis_d_object() const
diff --git a/Kernel_d/include/CGAL/Homogeneous_d.h b/Kernel_d/include/CGAL/Homogeneous_d.h
index 994abdfbc5d..d968a94c4f5 100644
--- a/Kernel_d/include/CGAL/Homogeneous_d.h
+++ b/Kernel_d/include/CGAL/Homogeneous_d.h
@@ -253,6 +253,8 @@ public:
typedef Compare_lexicographicallyHd Compare_lexicographically_d;
typedef Lt_from_compare Less_lexicographically_d;
typedef Le_from_compare Less_or_equal_lexicographically_d;
+ typedef Less_coordinateHd Less_coordinate_d;
+ typedef Point_dimensionHd Point_dimension_d;
typedef Eq_from_method Equal_d;
typedef Center_of_sphereHd Center_of_sphere_d;
typedef Contained_in_linear_hullHd Contained_in_linear_hull_d;
@@ -262,6 +264,10 @@ public:
Compute_coordinate_d compute_coordinate_d_object() const
{ return Compute_coordinate_d(); }
+ Point_dimension_d point_dimension_d_object() const
+ { return Point_dimension_d(); }
+ Less_coordinate_d less_coordinate_d_object() const
+ { return Less_coordinate_d(); }
Lift_to_paraboloid_d lift_to_paraboloid_d_object() const
{ return Lift_to_paraboloid_d(); }
Project_along_d_axis_d project_along_d_axis_d_object() const
diff --git a/Kernel_d/include/CGAL/Kernel_d/function_objectsCd.h b/Kernel_d/include/CGAL/Kernel_d/function_objectsCd.h
index 69edd4b09e0..ae5887d33f1 100644
--- a/Kernel_d/include/CGAL/Kernel_d/function_objectsCd.h
+++ b/Kernel_d/include/CGAL/Kernel_d/function_objectsCd.h
@@ -42,13 +42,39 @@ class Compute_coordinateCd {
typedef typename K::Point_d Point_d;
public:
typedef FT result_type;
- const result_type
+ result_type
operator()(const Point_d& p, int i) const
{
return p.cartesian(i);
}
};
+template
+class Point_dimensionCd {
+ typedef typename K::FT FT;
+ typedef typename K::Point_d Point_d;
+ public:
+ typedef int result_type;
+ result_type
+ operator()(const Point_d& p) const
+ {
+ return p.dimension();
+ }
+};
+
+template
+class Less_coordinateCd {
+ typedef typename K::FT FT;
+ typedef typename K::Point_d Point_d;
+ public:
+ typedef bool result_type;
+ result_type
+ operator()(const Point_d& p, const Point_d& q, int i) const
+ {
+ return p.cartesian(i)
struct Lift_to_paraboloidCd {
typedef typename R::Point_d Point_d;
diff --git a/Kernel_d/include/CGAL/Kernel_d/function_objectsHd.h b/Kernel_d/include/CGAL/Kernel_d/function_objectsHd.h
index eaedbc5ec1e..2e719d9b6b8 100644
--- a/Kernel_d/include/CGAL/Kernel_d/function_objectsHd.h
+++ b/Kernel_d/include/CGAL/Kernel_d/function_objectsHd.h
@@ -41,13 +41,41 @@ class Compute_coordinateHd {
typedef typename K::Point_d Point_d;
public:
typedef FT result_type;
- const result_type
+ result_type
operator()(const Point_d& p, int i) const
{
return p.cartesian(i);
}
};
+template
+class Point_dimensionHd {
+ typedef typename K::RT RT;
+ typedef typename K::Point_d Point_d;
+ public:
+ typedef int result_type;
+ result_type
+ operator()(const Point_d& p) const
+ {
+ return p.dimension();
+ }
+};
+
+template
+class Less_coordinateHd {
+ typedef typename K::RT RT;
+ typedef typename K::Point_d Point_d;
+ public:
+ typedef bool result_type;
+ result_type
+ operator()(const Point_d& p, const Point_d& q, int i) const
+ {
+ int d = p.dimension();
+ return p.cartesian(i)*q.homogeneous(d)
struct Lift_to_paraboloidHd {
typedef typename R::Point_d Point_d;
diff --git a/Maintenance/test_handling/candidate_branches b/Maintenance/test_handling/candidate_branches
index 207a38270ad..6ad05bd1130 100644
--- a/Maintenance/test_handling/candidate_branches
+++ b/Maintenance/test_handling/candidate_branches
@@ -1,3 +1,2 @@
Combinatorial_map-gdamiand
unique_sqrt_extension-sloriot
-spatial_sorting-increase_dim_and_add_info-sloriot
diff --git a/Manual/doc_tex/Manual/geom.bib b/Manual/doc_tex/Manual/geom.bib
index f2f52a5f4ea..aa71e56cfe3 100644
--- a/Manual/doc_tex/Manual/geom.bib
+++ b/Manual/doc_tex/Manual/geom.bib
@@ -1755,7 +1755,7 @@ cell neighborhood in $O(m)$ time."
@inproceedings{acr-icb-03
, author = "Nina Amenta and Sunghee Choi and G{\"u}nter Rote"
-, title = "Incremental constructions con BRIO"
+, title = "Incremental constructions con {BRIO}"
, booktitle = "Proc. 19th Annu. Sympos. Comput. Geom."
, year = 2003
, pages = "211-219"
diff --git a/Mesh_2/include/CGAL/Delaunay_mesh_area_criteria_2.h b/Mesh_2/include/CGAL/Delaunay_mesh_area_criteria_2.h
index 4dadb89309f..1d99ea90c93 100644
--- a/Mesh_2/include/CGAL/Delaunay_mesh_area_criteria_2.h
+++ b/Mesh_2/include/CGAL/Delaunay_mesh_area_criteria_2.h
@@ -32,6 +32,10 @@ class Delaunay_mesh_area_criteria_2
Delaunay_mesh_size_criteria_2. Delaunay_mesh_criteria_2
is a
virtual base class of Delaunay_mesh_size_criteria_2
. */
{
+ typedef typename Tr::Geom_traits Geom_traits;
+
+protected:
+ Geom_traits traits;
public:
typedef Delaunay_mesh_criteria_2
Base;
typedef Delaunay_mesh_size_criteria_2
Private_base;
@@ -39,8 +43,9 @@ public:
typedef typename Delaunay_mesh_size_criteria_2
::Quality Quality;
Delaunay_mesh_area_criteria_2(const double aspect_bound = 0.125,
- const double area_bound = 0)
- : Private_base(aspect_bound, area_bound) {}
+ const double area_bound = 0,
+ const Geom_traits& traits = Geom_traits())
+ : Private_base(aspect_bound, area_bound, traits), traits(traits) {}
inline
double area_bound() const { return this->sizebound; }
@@ -58,8 +63,9 @@ public:
typedef typename Tr::Face_handle Face_handle;
Is_bad(const double aspect_bound,
- const double area_bound)
- : Is_bad_base(aspect_bound, area_bound) {}
+ const double area_bound,
+ const Geom_traits& traits)
+ : Is_bad_base(aspect_bound, area_bound, traits) {}
Mesh_2::Face_badness operator()(Quality q)
{
@@ -126,7 +132,7 @@ public:
}; // end class Is_bad
Is_bad is_bad_object() const
- { return Is_bad(this->bound(), area_bound()); }
+ { return Is_bad(this->bound(), area_bound(), traits); }
};
} //end namespace
diff --git a/Mesh_2/include/CGAL/Delaunay_mesh_criteria_2.h b/Mesh_2/include/CGAL/Delaunay_mesh_criteria_2.h
index 7a29d19c50c..c67a13fed72 100644
--- a/Mesh_2/include/CGAL/Delaunay_mesh_criteria_2.h
+++ b/Mesh_2/include/CGAL/Delaunay_mesh_criteria_2.h
@@ -31,7 +31,7 @@ class Delaunay_mesh_criteria_2
protected:
typedef typename Tr::Geom_traits Geom_traits;
- const Geom_traits& traits;
+ Geom_traits traits;
public:
typedef typename Tr::Face_handle Face_handle;
diff --git a/Mesh_2/include/CGAL/Delaunay_mesh_local_size_criteria_2.h b/Mesh_2/include/CGAL/Delaunay_mesh_local_size_criteria_2.h
index 1fde2bbbf27..a8ae1d36fc7 100644
--- a/Mesh_2/include/CGAL/Delaunay_mesh_local_size_criteria_2.h
+++ b/Mesh_2/include/CGAL/Delaunay_mesh_local_size_criteria_2.h
@@ -41,13 +41,16 @@ public:
private:
bool local;
Segment _s;
+ Geom_traits traits;
public:
Delaunay_mesh_local_size_criteria_2(const double aspect_bound = 0.125,
const double size_bound = 0,
const bool is_local_size = false,
- const Segment s = Segment())
- : Base(aspect_bound, size_bound), local(is_local_size), _s(s) {}
+ const Segment s = Segment(),
+ const Geom_traits& traits = Geom_traits())
+ : Base(aspect_bound, size_bound), local(is_local_size), _s(s)
+ , traits(traits) {}
inline
Segment segment() const { return _s; }
@@ -82,8 +85,9 @@ public:
Is_bad(const double aspect_bound,
const double size_bound,
const bool l,
- const Segment_2 _s)
- : Base::Is_bad(aspect_bound, size_bound), local(l), s(_s) {}
+ const Segment_2 _s,
+ const Geom_traits& traits)
+ : Base::Is_bad(aspect_bound, size_bound, traits), local(l), s(_s) {}
Mesh_2::Face_badness operator()(Quality q) const
{
@@ -119,7 +123,7 @@ public:
};
Is_bad is_bad_object() const
- { return Is_bad(this->bound(), this->size_bound(), local, segment()); }
+ { return Is_bad(this->bound(), this->size_bound(), local, segment(), traits); }
};
} //end namespace
diff --git a/Mesh_3/demo/Mesh_3/CMakeLists.txt b/Mesh_3/demo/Mesh_3/CMakeLists.txt
index 13e544eab66..545ad51d313 100644
--- a/Mesh_3/demo/Mesh_3/CMakeLists.txt
+++ b/Mesh_3/demo/Mesh_3/CMakeLists.txt
@@ -11,6 +11,9 @@ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)
endif()
endif()
+# Let plugins be compiled in the same directory as the executable.
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
+
#option(MESH_3_DEMO_ENABLE_FORWARD_DECL "In the Mesh_3 demo, enable " OFF)
#mark_as_advanced(MESH_3_DEMO_ENABLE_FORWARD_DECL)
diff --git a/Mesh_3/demo/Mesh_3/implicit_functions/CMakeLists.txt b/Mesh_3/demo/Mesh_3/implicit_functions/CMakeLists.txt
index 4f9b7ebcfb1..3a08b852110 100644
--- a/Mesh_3/demo/Mesh_3/implicit_functions/CMakeLists.txt
+++ b/Mesh_3/demo/Mesh_3/implicit_functions/CMakeLists.txt
@@ -11,6 +11,9 @@ if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 2.6)
endif()
endif()
+# Let plugins be compiled in the same directory as the executable.
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
+
# Include directory of demo includes
include_directories( BEFORE ${Mesh_3_implicit_functions_BINARY_DIR} ../include )
diff --git a/Nef_3/doc_tex/Nef_3_ref/Nef_polyhedron_3.tex b/Nef_3/doc_tex/Nef_3_ref/Nef_polyhedron_3.tex
index 662a3a2a9d3..9e2822b0909 100644
--- a/Nef_3/doc_tex/Nef_3_ref/Nef_polyhedron_3.tex
+++ b/Nef_3/doc_tex/Nef_3_ref/Nef_polyhedron_3.tex
@@ -105,7 +105,7 @@ template parameters.
\ccGlue
\ccNestedType{SHalfedge_around_sface_const_circulator}{non-mutable circulator of shalfedges around a sface (ccw).}
\ccGlue
-\ccNestedType{SHalfedge_aroud_facet_const_circulator}{non-mutable circulator of shalfedges around a halffacet (ccw).}
+\ccNestedType{SHalfedge_around_facet_const_circulator}{non-mutable circulator of shalfedges around a halffacet (ccw).}
\ccGlue
\ccNestedType{SFace_cycle_const_iterator}{non-mutable iterator over the cylces of a sface.}
\ccGlue
diff --git a/Nef_3/doc_tex/Nef_3_ref/Nef_polyhedron_3_Halfedge.tex b/Nef_3/doc_tex/Nef_3_ref/Nef_polyhedron_3_Halfedge.tex
index d79b00da4a9..b4ecd69a550 100644
--- a/Nef_3/doc_tex/Nef_3_ref/Nef_polyhedron_3_Halfedge.tex
+++ b/Nef_3/doc_tex/Nef_3_ref/Nef_polyhedron_3_Halfedge.tex
@@ -91,7 +91,7 @@ class \ccc{Nef_polyhedron_3} manages the needed halfedges internally.
\ccMethod{Halfedge_const_handle twin() const;}{the twin of \ccVar\ .}
\ccMethod{SHalfedge_const_handle out_sedge() const;}
-{the first out sedege of \ccVar\ .}
+{the first out sedge of \ccVar\ .}
\ccMethod{SFace_const_handle incident_sface() const;}
{the incident sface of \ccVar\ .}
diff --git a/Nef_S2/doc_tex/Nef_S2_ref/Nef_polyhedron_S2_SVertex.tex b/Nef_S2/doc_tex/Nef_S2_ref/Nef_polyhedron_S2_SVertex.tex
index e93bec58c52..075a5376472 100644
--- a/Nef_S2/doc_tex/Nef_S2_ref/Nef_polyhedron_S2_SVertex.tex
+++ b/Nef_S2/doc_tex/Nef_S2_ref/Nef_polyhedron_S2_SVertex.tex
@@ -60,7 +60,7 @@ class \ccc{Nef_polyhedron_S2} manages the needed svertices internally.
\ccMethod{SVertex_const_handle twin() const;}{the twin of \ccVar\ .}
\ccMethod{SHalfedge_const_handle out_sedge() const;}
-{the first out sedege of \ccVar\ .}
+{the first out sedge of \ccVar\ .}
\ccMethod{SFace_const_handle incident_sface() const;}
{the incident sface of \ccVar\ .}
diff --git a/Nef_S2/include/CGAL/Nef_S2/SM_point_locator.h b/Nef_S2/include/CGAL/Nef_S2/SM_point_locator.h
index 69f54b2ebe1..494cd701075 100644
--- a/Nef_S2/include/CGAL/Nef_S2/SM_point_locator.h
+++ b/Nef_S2/include/CGAL/Nef_S2/SM_point_locator.h
@@ -92,9 +92,8 @@ public:
typedef typename Decorator_traits::SVertex_handle SVertex_handle;
typedef typename Decorator_traits::SHalfedge_handle SHalfedge_handle;
typedef typename Decorator_traits::SHalfloop_handle SHalfloop_handle;
- typedef typename Decorator_traits::SHalfloop_const_handle SHalfloop_const_handle;
typedef typename Decorator_traits::SFace_handle SFace_handle;
- typedef typename Decorator_traits::SFace_const_handle SFace_const_handle;
+
typedef typename Decorator_traits::SVertex_iterator SVertex_iterator;
typedef typename Decorator_traits::SHalfedge_iterator SHalfedge_iterator;
@@ -182,7 +181,7 @@ public:
enum SOLUTION { is_vertex_, is_edge_, is_loop_ };
// enumeration for internal use
- Object_handle locate(const Sphere_point& p, bool skipVEL = false) const
+ Object_handle locate(const Sphere_point& p, bool skipVEL = false)
/*{\Mop returns a generic handle |h| to an object (vertex, halfedge,
face) of the underlying plane map |P| which contains the point |p =
s.source()| in its relative interior. |s.target()| must be a point
@@ -209,7 +208,7 @@ public:
if ( this->has_shalfloop() && this->shalfloop()->circle().has_on(p)) {
CGAL_NEF_TRACEN( " on loop");
- return make_object(SHalfloop_const_handle(this->shalfloop()));
+ return make_object(SHalfloop_handle(this->shalfloop()));
}
}
@@ -224,7 +223,7 @@ public:
SVertex_handle v_res;
SHalfedge_handle e_res;
- SHalfloop_const_handle l_res(this->shalfloop());
+ SHalfloop_handle l_res(this->shalfloop());
SOLUTION solution;
CGAL_NEF_TRACEN(" on face...");
@@ -312,7 +311,7 @@ public:
case is_edge_:
return make_object(SFace_handle(e_res->incident_sface()));
case is_loop_:
- return make_object(SFace_const_handle(l_res->incident_sface()));
+ return make_object(SFace_handle(l_res->incident_sface()));
case is_vertex_:
return make_object(SFace_handle(v_res->incident_sface()));
default: CGAL_error_msg("missing solution.");
@@ -320,6 +319,7 @@ public:
return Object_handle(); // never reached!
}
+#if 0 //THIS CODE DOES NOT SEEM TO BE USED
template
Object_handle ray_shoot(const Sphere_point& p,
const Sphere_direction& d,
@@ -336,7 +336,7 @@ public:
{
Sphere_circle c(d.circle());
Sphere_segment s;
- Object_handle h = this->locate(p);
+ Object_handle h = locate(p);
SVertex_handle v;
SHalfedge_handle e;
SHalfloop_handle l;
@@ -404,7 +404,8 @@ public:
CGAL_error_msg("not yet correct");
return h;
}
-
+#endif
+
Object_handle ray_shoot(const Sphere_point& p,
const Sphere_circle& c,
Sphere_point& ip,
diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt
index 076e343bed6..c482d9904bb 100644
--- a/Polyhedron/demo/Polyhedron/CMakeLists.txt
+++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt
@@ -36,11 +36,17 @@ include_directories( BEFORE ./ ./include ../../include )
find_package(CGAL COMPONENTS Qt4)
include( ${CGAL_USE_FILE} )
+option( POLYHEDRON_QTSCRIPT_DEBUGGER
+ "Activate the use of Qt Script Debugger in Polyhedron_3 demo" OFF)
+
# Find Qt4 itself
set( QT_USE_QTXML TRUE )
set( QT_USE_QTMAIN TRUE )
set( QT_USE_QTSCRIPT TRUE )
set( QT_USE_QTOPENGL TRUE )
+if( POLYHEDRON_QTSCRIPT_DEBUGGER)
+ set( QT_USE_QTSCRIPTTOOLS TRUE )
+endif()
find_package(Qt4)
# Find OpenGL
@@ -49,6 +55,7 @@ find_package(OpenGL)
# Find QGLViewer
if(QT4_FOUND)
include(${QT_USE_FILE})
+ include_directories( ${QT_INCLUDE_DIR}/QtScriptTools )
find_package(QGLViewer )
endif(QT4_FOUND)
@@ -80,9 +87,10 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
message(STATUS "NOTICE: LAPACK is not found. curvatures estimation will not be available.")
endif(LAPACK_FOUND)
- qt4_wrap_ui( UI_FILES MainWindow.ui )
-
+ qt4_wrap_ui( MainWindowUI_files MainWindow.ui )
+ qt4_wrap_ui( Show_point_dialogUI_FILES Show_point_dialog.ui )
qt4_wrap_ui( remeshingUI_FILES Remeshing_dialog.ui)
+ qt4_wrap_ui( meshingUI_FILES Meshing_dialog.ui Meshing_pause_widget.ui )
include(AddFileDependencies)
@@ -92,62 +100,80 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
qt4_generate_moc( "Viewer.h" "${CMAKE_CURRENT_BINARY_DIR}/Viewer_moc.cpp" )
add_file_dependencies( Viewer_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Viewer.h" )
- qt4_generate_moc( "Scene.h" "${CMAKE_CURRENT_BINARY_DIR}/Scene_moc.cpp" )
- add_file_dependencies( Scene_moc.cpp "${CMAKE_CURRENT_SOURCE_DIR}/Scene.h" )
-
-
qt4_generate_moc( "Polyhedron_demo_remeshing_plugin_cgal_code.cpp" "${CMAKE_CURRENT_BINARY_DIR}/Polyhedron_demo_remeshing_plugin_cgal_code.moc" )
qt4_add_resources ( RESOURCE_FILES Polyhedron_3.qrc )
- qt4_automoc(Scene_item.cpp
+ qt4_automoc(Scene.cpp
+ Scene_item.cpp
Scene_plane_item.cpp
Scene_polygon_soup.cpp
Scene_polyhedron_item.cpp
Scene_textured_polyhedron_item.cpp
Scene_c2t3_item.cpp
- Scene_nef_polyhedron_item.cpp)
+ Scene_nef_polyhedron_item.cpp
+ Show_point_dialog.cpp
+ )
# AUXILIARY LIBRARIES
# put plugins (which are shared libraries) at the same location as
# executable files
-
set(LIBRARY_OUTPUT_PATH ${RUNTIME_OUTPUT_PATH})
- add_library(scene_item SHARED
+ add_library(demo_framework SHARED
+ Scene.cpp
+ Viewer.cpp Viewer_moc.cpp
Scene_item.cpp Scene_item.moc
Scene_item_with_display_list.cpp
Polyhedron_demo_plugin_helper.cpp)
+ target_link_libraries(demo_framework
+ ${QGLVIEWER_LIBRARIES}
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+ )
+
add_library(scene_basic_objects SHARED
Scene_plane_item.cpp Scene_plane_item.moc)
- target_link_libraries(scene_basic_objects scene_item ${QGLVIEWER_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY})
+ target_link_libraries(scene_basic_objects
+ demo_framework
+ ${QGLVIEWER_LIBRARIES}
+ ${OPENGL_gl_LIBRARY}
+ ${OPENGL_glu_LIBRARY}
+ )
+
+ add_library(point_dialog SHARED Show_point_dialog.cpp Show_point_dialog.ui ${Show_point_dialogUI_FILES} )
add_library(scene_c2t3_item SHARED
Scene_c2t3_item.cpp Scene_c2t3_item.moc)
- target_link_libraries(scene_c2t3_item scene_item)
+ target_link_libraries(scene_c2t3_item demo_framework)
add_library(scene_polyhedron_item SHARED
Scene_polyhedron_item.cpp Scene_polyhedron_item.moc)
- target_link_libraries(scene_polyhedron_item scene_item)
+ target_link_libraries(scene_polyhedron_item demo_framework)
if(TAUCS_FOUND)
add_library(scene_textured_polyhedron_item SHARED
Scene_textured_polyhedron_item.cpp texture.cpp Scene_textured_polyhedron_item.moc)
- target_link_libraries(scene_textured_polyhedron_item scene_item)
+ target_link_libraries(scene_textured_polyhedron_item demo_framework)
endif(TAUCS_FOUND)
- add_library(polygon_soup SHARED
+ add_library(scene_polygon_soup_item SHARED
Scene_polygon_soup.cpp Scene_polygon_soup.moc)
- target_link_libraries(polygon_soup scene_item)
+ target_link_libraries(scene_polygon_soup_item demo_framework scene_polyhedron_item)
add_library(scene_nef_polyhedron_item SHARED
Scene_nef_polyhedron_item.cpp Scene_nef_polyhedron_item.moc
Scene_nef_rendering.cpp)
- target_link_libraries(scene_nef_polyhedron_item scene_polyhedron_item)
+ target_link_libraries(scene_nef_polyhedron_item demo_framework scene_polyhedron_item)
- foreach( lib scene_item scene_basic_objects scene_polyhedron_item polygon_soup scene_nef_polyhedron_item )
+ foreach( lib
+ demo_framework
+ scene_basic_objects
+ scene_polyhedron_item
+ scene_polygon_soup_item
+ scene_nef_polyhedron_item )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${lib} )
endforeach()
@@ -156,13 +182,12 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
add_definitions(-DUSE_FORWARD_DECL)
add_executable ( Polyhedron_3 MainWindow.cpp
Polyhedron_3.cpp
- Viewer.cpp
- Scene.cpp
+# Viewer.cpp
+# Scene.cpp
# MainWindow_curvature_estimation.cpp
MainWindow_moc.cpp
- Scene_moc.cpp
- Viewer_moc.cpp
- ${UI_FILES} ${RESOURCE_FILES} )
+# Viewer_moc.cpp
+ ${MainWindowUI_files} ${RESOURCE_FILES} )
add_to_cached_list( CGAL_EXECUTABLE_TARGETS Polyhedron_3 )
if(TAUCS_FOUND)
# add_executable( Polyhedron_3 Scene_tex_rendering.cpp Scene_tex_polyhedron_operations.cpp )
@@ -176,7 +201,13 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
# Link with Qt libraries
+ if( POLYHEDRON_QTSCRIPT_DEBUGGER )
+ add_definitions( -DQT_SCRIPTTOOLS_LIB )
+ target_link_libraries( Polyhedron_3 QtScriptTools )
+ endif()
target_link_libraries( Polyhedron_3 ${QT_LIBRARIES} )
+ target_link_libraries( Polyhedron_3 demo_framework )
+ target_link_libraries( Polyhedron_3 point_dialog )
# Link with CGAL
target_link_libraries( Polyhedron_3 ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
@@ -184,9 +215,6 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
# Link with libQGLViewer, OpenGL
target_link_libraries( Polyhedron_3 ${QGLVIEWER_LIBRARIES} ${OPENGL_gl_LIBRARY} ${OPENGL_glu_LIBRARY} )
- # Link with the scene_item library.
-# target_link_libraries( Polyhedron_3 scene_item )
-
add_to_cached_list( CGAL_EXECUTABLE_TARGETS Polyhedron_3 )
@@ -198,26 +226,37 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
macro(polyhedron_demo_plugin plugin_name plugin_implementation_base_name)
list_split(option ARGN_TAIL ${ARGN} )
if(NOT ${option} STREQUAL "EXCLUDE_FROM_ALL")
- set(other_sources ${ARGN})
- set(option "")
+ if(NOT ${option} STREQUAL "NO_MOC")
+ set(other_sources ${ARGN})
+ set(option "")
+ else()
+ set(other_sources ${ARGN_TAIL})
+ endif()
else()
set(other_sources ${ARGN_TAIL})
endif()
- qt4_generate_moc( ${plugin_implementation_base_name}.cpp "${CMAKE_CURRENT_BINARY_DIR}/${plugin_implementation_base_name}.moc" )
- add_file_dependencies( ${plugin_implementation_base_name}.moc "${CMAKE_CURRENT_SOURCE_DIR}/${plugin_implementation_base_name}.cpp" )
+ if("${option}" STREQUAL "NO_MOC")
+ set(option "")
+ set(moc_file_name "")
+ else()
+ set(moc_file_name ${plugin_implementation_base_name}.moc )
+ qt4_generate_moc( ${plugin_implementation_base_name}.cpp "${CMAKE_CURRENT_BINARY_DIR}/${moc_file_name}" )
+ add_file_dependencies( ${moc_file_name} "${CMAKE_CURRENT_SOURCE_DIR}/${plugin_implementation_base_name}.cpp" )
+ endif()
- add_library(${plugin_name} MODULE ${option} ${plugin_implementation_base_name}.moc ${plugin_implementation_base_name}.cpp ${other_sources})
+ add_library(${plugin_name} MODULE ${option} ${moc_file_name} ${plugin_implementation_base_name}.cpp ${other_sources})
add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${plugin_name} )
# Link with Qt
target_link_libraries( ${plugin_name} ${QT_LIBRARIES} )
- # Link with scene_item
- target_link_libraries( ${plugin_name} scene_item)
+ # Link with the demo_framework
+ target_link_libraries( ${plugin_name} demo_framework)
# Link with CGAL
target_link_libraries( ${plugin_name} ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
+ add_dependencies( ${plugin_name} Polyhedron_3 )
endmacro(polyhedron_demo_plugin)
polyhedron_demo_plugin(remeshing_plugin Polyhedron_demo_remeshing_plugin Polyhedron_demo_remeshing_plugin_cgal_code.cpp Polyhedron_demo_remeshing_plugin_cgal_code.moc ${remeshingUI_FILES})
- target_link_libraries(remeshing_plugin scene_polyhedron_item polygon_soup scene_c2t3_item)
+ target_link_libraries(remeshing_plugin scene_polyhedron_item scene_polygon_soup_item scene_c2t3_item)
if ( Boost_VERSION GREATER 103400 )
qt4_generate_moc( "Polyhedron_demo_mesh_3_plugin_cgal_code.cpp" "${CMAKE_CURRENT_BINARY_DIR}/Scene_c3t3_item.moc" )
@@ -230,13 +269,13 @@ if(CGAL_Qt4_FOUND AND QT4_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
endif( Boost_VERSION GREATER 103400 )
polyhedron_demo_plugin(inside_out_plugin Polyhedron_demo_inside_out_plugin)
- target_link_libraries(inside_out_plugin scene_polyhedron_item polygon_soup)
+ target_link_libraries(inside_out_plugin scene_polyhedron_item scene_polygon_soup_item)
polyhedron_demo_plugin(off_plugin Polyhedron_demo_off_plugin)
- target_link_libraries(off_plugin scene_polyhedron_item polygon_soup)
+ target_link_libraries(off_plugin scene_polyhedron_item scene_polygon_soup_item)
polyhedron_demo_plugin(orient_soup_plugin Polyhedron_demo_orient_soup_plugin)
- target_link_libraries(orient_soup_plugin polygon_soup)
+ target_link_libraries(orient_soup_plugin scene_polygon_soup_item scene_polyhedron_item)
polyhedron_demo_plugin(triangulate_facets_plugin Polyhedron_demo_triangulate_facets_plugin)
target_link_libraries(triangulate_facets_plugin scene_polyhedron_item)
diff --git a/Polyhedron/demo/Polyhedron/Color_map.h b/Polyhedron/demo/Polyhedron/Color_map.h
new file mode 100644
index 00000000000..fb89f4d2c3f
--- /dev/null
+++ b/Polyhedron/demo/Polyhedron/Color_map.h
@@ -0,0 +1,26 @@
+#ifndef _COLOR_MAP_H
+#define _COLOR_MAP_H
+
+#include
+
+template
+Output_color_iterator
+compute_color_map(QColor base_color,
+ unsigned nb_of_colors,
+ Output_color_iterator out)
+{
+ qreal hue = base_color.hueF();
+ const qreal step = ((qreal)1) / nb_of_colors;
+
+ qreal h = hue;
+ for(unsigned i = 0; i < nb_of_colors; ++i) {
+ h += step;
+ if ( h > 1 ) { h -= 1; }
+ *out++ = QColor::fromHsvF(h,
+ base_color.saturationF(),
+ base_color.valueF());
+ }
+ return out;
+}
+
+#endif
diff --git a/Polyhedron/demo/Polyhedron/Kernel_type.h b/Polyhedron/demo/Polyhedron/Kernel_type.h
new file mode 100644
index 00000000000..6da8cc541a5
--- /dev/null
+++ b/Polyhedron/demo/Polyhedron/Kernel_type.h
@@ -0,0 +1,13 @@
+#ifndef KERNEL_TYPE_H
+#define KERNEL_TYPE_H
+
+#include
+#include
+
+namespace kernel_type_h {
+ typedef CGAL::Exact_predicates_inexact_constructions_kernel K1;
+}
+
+typedef CGAL::Mesh_3::Robust_intersection_traits_3 Kernel;
+
+#endif // KERNEL_TYPE_H
diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp
index 6dee0b44be5..a63d0e00fc4 100644
--- a/Polyhedron/demo/Polyhedron/MainWindow.cpp
+++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp
@@ -10,17 +10,94 @@
#include
#include
#include
+#include
+#include
#include
#include
#include
#include
#include
+#include
+#include
+#include
+#include
+
+#ifdef QT_SCRIPT_LIB
+# include
+# ifdef QT_SCRIPTTOOLS_LIB
+# include
+# endif
+#endif
#include "Polyhedron_demo_plugin_interface.h"
#include "Polyhedron_demo_io_plugin_interface.h"
#include "ui_MainWindow.h"
+#include "Show_point_dialog.h"
+
+#ifdef QT_SCRIPT_LIB
+# include
+# include
+
+QScriptValue
+myScene_itemToScriptValue(QScriptEngine *engine,
+ Scene_item* const &in)
+{
+ return engine->newQObject(in);
+}
+
+void myScene_itemFromScriptValue(const QScriptValue &object,
+ Scene_item* &out)
+{
+ out = qobject_cast(object.toQObject());
+}
+#endif // QT_SCRIPT_LIB
+
+#ifdef QT_SCRIPT_LIB
+# ifdef QT_SCRIPTTOOLS_LIB
+
+const QScriptEngineDebugger::DebuggerWidget debug_widgets[9] = {
+ QScriptEngineDebugger::ConsoleWidget,
+ QScriptEngineDebugger::StackWidget,
+ QScriptEngineDebugger::ScriptsWidget,
+ QScriptEngineDebugger::LocalsWidget,
+ QScriptEngineDebugger::CodeWidget,
+ QScriptEngineDebugger::CodeFinderWidget,
+ QScriptEngineDebugger::BreakpointsWidget,
+ QScriptEngineDebugger::DebugOutputWidget,
+ QScriptEngineDebugger::ErrorLogWidget
+};
+const QString debug_widgets_names[9] = {
+ "Script console",
+ "Stack",
+ "Scripts",
+ "Locals",
+ "Code",
+ "CodeFinder",
+ "Breakpoints",
+ "DebugOutput",
+ "ErrorLog"
+};
+
+# endif
+#endif
+
+QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine)
+{
+ MainWindow* mw = qobject_cast(engine->parent());
+ QString result;
+ for (int i = 0; i < context->argumentCount(); ++i) {
+ if (i > 0)
+ result.append(" ");
+ result.append(context->argument(i).toString());
+ }
+
+ if(mw) mw->message(QString("QtScript: ") + result, "");
+
+ return engine->undefinedValue();
+}
+
MainWindow::~MainWindow()
{
delete ui;
@@ -70,6 +147,10 @@ MainWindow::MainWindow(QWidget* parent)
connect(scene, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex & )),
this, SLOT(updateInfo()));
+
+ connect(scene, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex & )),
+ this, SLOT(updateDisplayInfo()));
+
connect(scene, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex & )),
viewer, SLOT(updateGL()));
@@ -86,12 +167,37 @@ MainWindow::MainWindow(QWidget* parent)
SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & ) ),
this, SLOT(updateInfo()));
+ connect(treeView->selectionModel(),
+ SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & ) ),
+ this, SLOT(updateDisplayInfo()));
+
connect(treeView->selectionModel(),
SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & ) ),
this, SLOT(selectionChanged()));
+ treeView->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(treeView, SIGNAL(customContextMenuRequested(const QPoint & )),
+ this, SLOT(showSceneContextMenu(const QPoint &)));
+
connect(viewer, SIGNAL(selected(int)),
this, SLOT(selectSceneItem(int)));
+ connect(viewer, SIGNAL(selectedPoint(double, double, double)),
+ this, SLOT(showSelectedPoint(double, double, double)));
+
+ connect(viewer, SIGNAL(selectionRay(double, double, double,
+ double, double, double)),
+ scene, SIGNAL(selectionRay(double, double, double,
+ double, double, double)));
+
+ connect(viewer, SIGNAL(requestContextMenu(QPoint)),
+ this, SLOT(contextMenuRequested(QPoint)));
+ connect(ui->infoLabel, SIGNAL(customContextMenuRequested(const QPoint & )),
+ this, SLOT(showSceneContextMenu(const QPoint &)));
+
+ connect(ui->actionRecenterScene, SIGNAL(triggered()),
+ viewer->camera(), SLOT(interpolateToFitScene()));
+ connect(ui->actionRecenterScene, SIGNAL(triggered()),
+ viewer, SLOT(update()));
connect(ui->actionAntiAliasing, SIGNAL(toggled(bool)),
viewer, SLOT(setAntiAliasing(bool)));
@@ -100,7 +206,7 @@ MainWindow::MainWindow(QWidget* parent)
viewer, SLOT(setTwoSides(bool)));
// enable anti-aliasing by default
- ui->actionAntiAliasing->setChecked(true);
+ // ui->actionAntiAliasing->setChecked(true);
// add the "About CGAL..." and "About demo..." entries
this->addAboutCGAL();
@@ -116,6 +222,10 @@ MainWindow::MainWindow(QWidget* parent)
connect(ui->actionQuit, SIGNAL(triggered()),
this, SLOT(quit()));
+ // Connect "Select all items"
+ connect(ui->actionSelect_all_items, SIGNAL(triggered()),
+ this, SLOT(selectAll()));
+
// Recent files menu
this->addRecentFiles(ui->menuFile, ui->actionQuit);
connect(this, SIGNAL(openRecentFile(QString)),
@@ -124,10 +234,118 @@ MainWindow::MainWindow(QWidget* parent)
// Reset the "Operation menu"
clearMenu(ui->menuOperations);
+#ifdef QT_SCRIPT_LIB
+ std::cerr << "Enable scripts.\n";
+ script_engine = new QScriptEngine(this);
+ qScriptRegisterMetaType(script_engine,
+ myScene_itemToScriptValue,
+ myScene_itemFromScriptValue);
+# ifdef QT_SCRIPTTOOLS_LIB
+ QScriptEngineDebugger* debugger = new QScriptEngineDebugger(this);
+ debugger->setObjectName("qt script debugger");
+ QAction* debuggerMenuAction =
+ menuBar()->addMenu(debugger->createStandardMenu());
+ debuggerMenuAction->setText(tr("Qt Script &debug"));
+ for(unsigned int i = 0; i < 9; ++i)
+ {
+ QDockWidget* dock = new QDockWidget(debug_widgets_names[i], this);
+ dock->setObjectName(debug_widgets_names[i]);
+ dock->setWidget(debugger->widget(debug_widgets[i]));
+ this->addDockWidget(Qt::BottomDockWidgetArea, dock);
+ dock->hide();
+ }
+ debugger->setAutoShowStandardWindow(false);
+ debugger->attachTo(script_engine);
+# endif // QT_SCRIPTTOOLS_LIB
+ QScriptValue fun = script_engine->newFunction(myPrintFunction);
+ script_engine->globalObject().setProperty("print", fun);
+
+ evaluate_script("print('hello', 'world', 'from QtScript!')");
+ QScriptValue mainWindowObjectValue = script_engine->newQObject(this);
+ script_engine->globalObject().setProperty("main_window", mainWindowObjectValue);
+
+ QScriptValue sceneObjectValue = script_engine->newQObject(scene);
+ mainWindowObjectValue.setProperty("scene", sceneObjectValue);
+ script_engine->globalObject().setProperty("scene", sceneObjectValue);
+
+ QScriptValue viewerObjectValue = script_engine->newQObject(viewer);
+ mainWindowObjectValue.setProperty("viewer", viewerObjectValue);
+ script_engine->globalObject().setProperty("viewer", viewerObjectValue);
+
+ QScriptValue cameraObjectValue = script_engine->newQObject(viewer->camera());
+ viewerObjectValue.setProperty("camera", cameraObjectValue);
+ script_engine->globalObject().setProperty("camera", cameraObjectValue);
+
+ evaluate_script("var plugins = new Array();");
+# ifdef QT_SCRIPTTOOLS_LIB
+ QScriptValue debuggerObjectValue = script_engine->newQObject(debugger);
+ script_engine->globalObject().setProperty("debugger", debuggerObjectValue);
+# endif
+#endif
+
// Load plugins, and re-enable actions that need it.
loadPlugins();
readSettings(); // Among other things, the column widths are stored.
+
+#ifdef QT_SCRIPT_LIB
+ // evaluate_script("print(plugins);");
+ Q_FOREACH(QAction* action, findChildren()) {
+ if(action->objectName() != "") {
+ QScriptValue objectValue = script_engine->newQObject(action);
+ script_engine->globalObject().setProperty(action->objectName(),
+ objectValue);
+ }
+ }
+ // debugger->action(QScriptEngineDebugger::InterruptAction)->trigger();
+#endif
+}
+
+#ifdef QT_SCRIPT_LIB
+void MainWindow::evaluate_script(QString script,
+ const QString& filename,
+ const bool quiet) {
+ QScriptValue value = script_engine->evaluate(script);
+ if(script_engine->hasUncaughtException()) {
+ QTextStream err(stderr);
+ err << "Qt Script exception:\n"
+ << script_engine->uncaughtException().toString()
+ << "\nBacktrace:\n";
+ Q_FOREACH(QString line, script_engine->uncaughtExceptionBacktrace()) {
+ err << " " << line << "\n";
+ }
+ }
+ else if(!quiet && !value.isNull() && !value.isUndefined()) {
+ QTextStream(stderr) << "Qt Script evaluated to \""
+ << value.toString() << "\"\n";
+ }
+}
+
+void MainWindow::evaluate_script_quiet(QString script,
+ const QString& filename)
+{
+ evaluate_script(script, filename, true);
+}
+#endif
+
+void MainWindow::enableScriptDebugger(bool b /* = true */)
+{
+ Q_UNUSED(b);
+#ifdef QT_SCRIPT_LIB
+# ifdef QT_SCRIPTTOOLS_LIB
+ QScriptEngineDebugger* debugger =
+ findChild("qt script debugger");
+ if(debugger) {
+ if(b) {
+ debugger->action(QScriptEngineDebugger::InterruptAction)->trigger();
+ }
+ }
+ return;
+# endif
+#endif
+ // If we are here, then the debugger is not available
+ this->error(tr("Your version of Qt is too old, and for that reason"
+ "the Qt Script Debugger is not available."));
}
void MainWindow::loadPlugins()
@@ -140,7 +358,7 @@ void MainWindow::loadPlugins()
QList plugins_directories;
plugins_directories << qApp->applicationDirPath();
- QString env_path = ::getenv("POLYHEDRON_DEMO_PLUGINS_PATH");
+ QString env_path = qgetenv("POLYHEDRON_DEMO_PLUGINS_PATH");
if(!env_path.isEmpty()) {
Q_FOREACH (QString pluginsDir,
env_path.split(":", QString::SkipEmptyParts)) {
@@ -154,11 +372,15 @@ void MainWindow::loadPlugins()
qPrintable(pluginsDir.absolutePath()));
Q_FOREACH (QString fileName, pluginsDir.entryList(QDir::Files)) {
if(fileName.contains("plugin") && QLibrary::isLibrary(fileName)) {
- qDebug("### Loading \"%s\"...", fileName.toUtf8().data());
+ qDebug("### Loading \"%s\"...", qPrintable(fileName));
QPluginLoader loader;
loader.setFileName(pluginsDir.absoluteFilePath(fileName));
QObject *obj = loader.instance();
if(obj) {
+ QString name = fileName;
+ name.remove(QRegExp("^lib"));
+ name.remove(QRegExp("\\..*"));
+ obj->setObjectName(name);
initPlugin(obj);
initIOPlugin(obj);
}
@@ -172,6 +394,11 @@ void MainWindow::loadPlugins()
}
}
+bool MainWindow::hasPlugin(QString pluginName)
+{
+ return plugins.contains(pluginName);
+}
+
bool MainWindow::initPlugin(QObject* obj)
{
QObjectList childs = this->children();
@@ -180,6 +407,13 @@ bool MainWindow::initPlugin(QObject* obj)
if(plugin) {
// Call plugin's init() method
plugin->init(this, this->scene, this);
+ plugins << obj->objectName();
+#ifdef QT_SCRIPT_LIB
+ QScriptValue objectValue =
+ script_engine->newQObject(obj);
+ script_engine->globalObject().setProperty(obj->objectName(), objectValue);
+ evaluate_script_quiet(QString("plugins.push(%1);").arg(obj->objectName()));
+#endif
Q_FOREACH(QAction* action, plugin->actions()) {
// If action does not belong to the menus, add it to "Operations" menu
@@ -201,6 +435,7 @@ bool MainWindow::initIOPlugin(QObject* obj)
qobject_cast(obj);
if(plugin) {
// std::cerr << "I/O plugin\n";
+ plugins << obj->objectName();
io_plugins << plugin;
return true;
}
@@ -240,12 +475,51 @@ void MainWindow::addAction(QAction* action)
}
}
+void MainWindow::addAction(QString actionName,
+ QString actionText,
+ QString menuName) {
+ QMenu* menu = 0;
+ Q_FOREACH(QAction* action, findChildren()) {
+ if(!action->menu()) continue;
+ QString menuText = action->menu()->title();
+ if(menuText != menuName) continue;
+ menu = action->menu();
+ }
+ if(menu == 0) {
+ menu = new QMenu(menuName, this);
+ menuBar()->insertMenu(ui->menuView->menuAction(), menu);
+ }
+ QAction* action = new QAction(actionText, this);
+ action->setObjectName(actionName);
+ menu->addAction(action);
+#ifdef QT_SCRIPT_LIB
+ QScriptValue objectValue = script_engine->newQObject(action);
+ script_engine->globalObject().setProperty(action->objectName(),
+ objectValue);
+#endif
+}
+
+void MainWindow::viewerShow(float x, float y, float z) {
+ viewer->camera()->setRevolveAroundPoint(qglviewer::Vec(x, y, z));
+ // viewer->camera()->lookAt(qglviewer::Vec(x, y, z));
+
+ qglviewer::ManipulatedCameraFrame backup_frame(*viewer->camera()->frame());
+ viewer->camera()->fitSphere(qglviewer::Vec(x, y, z),
+ viewer->camera()->sceneRadius()/100);
+ qglviewer::ManipulatedCameraFrame new_frame(*viewer->camera()->frame());
+ *viewer->camera()->frame() = backup_frame;
+ viewer->camera()->interpolateTo(new_frame, 1.f);
+ viewer->setVisualHintsMask(1);
+}
+
void MainWindow::message(QString message, QString colorName, QString font) {
if (message.endsWith('\n')) {
message.remove(message.length()-1, 1);
}
+ std::cerr << qPrintable(message) << std::endl;
statusBar()->showMessage(message, 5000);
- message = "" + message + "
";
+ message = "" +
+ message + "
";
message = "[" + QTime::currentTime().toString() + "] " + message;
ui->consoleTextEdit->insertHtml(message);
ui->consoleTextEdit->verticalScrollBar()->setValue(ui->consoleTextEdit->verticalScrollBar()->maximum());
@@ -282,21 +556,101 @@ void MainWindow::updateViewerBBox()
viewer->camera()->showEntireScene();
}
-void MainWindow::open(QString filename)
+void MainWindow::reload_item() {
+ QAction* sender_action = qobject_cast(sender());
+ if(!sender_action) return;
+
+ bool ok;
+ int item_index = sender_action->data().toInt(&ok);
+ QObject* item_object = scene->item(item_index);
+ if(!ok || !item_object || sender_action->data().type() != QVariant::Int) {
+ std::cerr << "Cannot reload item: "
+ << "the reload action has not item attached\n";
+ return;
+ }
+ Scene_item* item = qobject_cast(item_object);
+ if(!item) {
+ std::cerr << "Cannot reload item: "
+ << "the reload action has a QObject* pointer attached\n"
+ << "that is not a Scene_item*\n";
+ return;
+ }
+ QString filename = item->property("source filename").toString();
+ if(filename.isEmpty()) {
+ std::cerr << "Cannot reload item: "
+ << "the item has not filename attached\n";
+ return;
+ }
+ QFileInfo fileinfo(filename);
+ if(! (fileinfo.isFile() && fileinfo.isReadable()) ) {
+ std::cerr << "Cannot reload item: "
+ << "cannot read file " << qPrintable(filename) << " \n";
+ return;
+ }
+ Scene_item* new_item = load_item(fileinfo);
+ if(!new_item) {
+ std::cerr << "Cannot reload item: "
+ << "file " << qPrintable(filename) << " is not an item\n";
+ return;
+ }
+ new_item->setName(item->name());
+ new_item->setColor(item->color());
+ new_item->setRenderingMode(item->renderingMode());
+ new_item->setVisible(item->visible());
+ new_item->setProperty("source filename", item->property("source filename"));
+ new_item->changed();
+ scene->replaceItem(item_index, new_item);
+ delete item;
+}
+
+Scene_item* MainWindow::load_item(QFileInfo fileinfo) const {
+ Scene_item* item = 0;
+ Q_FOREACH(Polyhedron_demo_io_plugin_interface* plugin,
+ io_plugins)
+ {
+ if(plugin->canLoad()) {
+ item = plugin->load(fileinfo);
+ if(item) break; // go out of the loop
+ }
+ }
+ return item;
+}
+
+void MainWindow::open(QString filename, bool no_popup)
{
+#ifdef QT_SCRIPT_LIB
+ QString program;
+ if(filename.startsWith("javascript:")) {
+ program=filename.right(filename.size() - 11);
+ }
+ if(filename.startsWith("qtscript:")) {
+ program=filename.right(filename.size() - 9);
+ }
+ if(filename.endsWith(".js")) {
+ QFile script_file(filename);
+ script_file.open(QIODevice::ReadOnly);
+ program = script_file.readAll();
+ }
+ if(!program.isEmpty())
+ {
+ {
+ QTextStream(stderr) << "Execution of script \""
+ << filename << "\"\n";
+ // << filename << "\", with following content:\n"
+ // << program;
+ }
+ evaluate_script(program, filename);
+ return;
+ }
+#endif
+
QFileInfo fileinfo(filename);
Scene_item* item = 0;
if(fileinfo.isFile() && fileinfo.isReadable()) {
- Q_FOREACH(Polyhedron_demo_io_plugin_interface* plugin,
- io_plugins)
- {
- if(plugin->canLoad()) {
- item = plugin->load(fileinfo);
- if(item) break; // go out of the loop
- }
- }
+ item = load_item(fileinfo);
if(item) {
Scene::Item_id index = scene->addItem(item);
+ item->setProperty("source filename", fileinfo.absoluteFilePath());
QSettings settings;
settings.setValue("OFF open directory",
fileinfo.absoluteDir().absolutePath());
@@ -304,6 +658,7 @@ void MainWindow::open(QString filename)
selectSceneItem(index);
}
else {
+ if(no_popup) return;
QMessageBox::critical(this,
tr("Cannot open file"),
tr("File %1 has not a known file format.")
@@ -311,6 +666,7 @@ void MainWindow::open(QString filename)
}
}
else {
+ if(no_popup) return;
QMessageBox::critical(this,
tr("Cannot open file"),
tr("File %1 is not a readable file.")
@@ -321,24 +677,68 @@ void MainWindow::open(QString filename)
void MainWindow::selectSceneItem(int i)
{
if(i < 0) return;
- if((unsigned int)i >= scene->numberOfEntries()) return;
+ if(i >= scene->numberOfEntries()) return;
treeView->selectionModel()->select(scene->createSelection(i),
QItemSelectionModel::ClearAndSelect);
}
+void MainWindow::showSelectedPoint(double x, double y, double z)
+{
+ information(QString("Selected point: (%1, %2, %3)").
+ arg(x, 0, 'g', 10).
+ arg(y, 0, 'g', 10).
+ arg(z, 0, 'g', 10));
+}
+
+void MainWindow::unSelectSceneItem(int i)
+{
+ removeSceneItemFromSelection(i);
+}
+
+void MainWindow::addSceneItemInSelection(int i)
+{
+ treeView->selectionModel()->select(scene->createSelection(i),
+ QItemSelectionModel::Select);
+ scene->itemChanged(i);
+}
+
+void MainWindow::removeSceneItemFromSelection(int i)
+{
+ treeView->selectionModel()->select(scene->createSelection(i),
+ QItemSelectionModel::Deselect);
+ scene->itemChanged(i);
+}
+
+void MainWindow::selectAll()
+{
+ treeView->selectionModel()->select(scene->createSelectionAll(),
+ QItemSelectionModel::ClearAndSelect);
+}
+
int MainWindow::getSelectedSceneItemIndex() const
{
QModelIndexList selectedRows = treeView->selectionModel()->selectedRows();
- if(selectedRows.empty())
+ if(selectedRows.size() != 1)
return -1;
else
return selectedRows.first().row();
}
+QList MainWindow::getSelectedSceneItemIndices() const
+{
+ QModelIndexList selectedRows = treeView->selectionModel()->selectedRows();
+ QList result;
+ Q_FOREACH(QModelIndex index, selectedRows) {
+ result << index.row();
+ }
+ return result;
+}
+
void MainWindow::selectionChanged()
{
scene->setSelectedItem(getSelectedSceneItemIndex());
+ scene->setSelectedItemsList(getSelectedSceneItemIndices());
Scene_item* item = scene->item(getSelectedSceneItemIndex());
if(item != NULL && item->manipulatable()) {
viewer->setManipulatedFrame(item->manipulatedFrame());
@@ -349,6 +749,53 @@ void MainWindow::selectionChanged()
viewer->updateGL();
}
+void MainWindow::contextMenuRequested(const QPoint& global_pos) {
+ int index = scene->mainSelectionIndex();
+ showSceneContextMenu(index, global_pos);
+}
+
+void MainWindow::showSceneContextMenu(int selectedItemIndex,
+ const QPoint& global_pos)
+{
+ Scene_item* item = scene->item(selectedItemIndex);
+ if(!item) return;
+
+ const char* prop_name = "Menu modified by MainWindow.";
+
+ QMenu* menu = item->contextMenu();
+ if(menu && !item->property("source filename").toString().isEmpty()) {
+ bool menuChanged = menu->property(prop_name).toBool();
+ if(!menuChanged) {
+ menu->addSeparator();
+ QAction* reload = menu->addAction(tr("Reload item from file"));
+ reload->setData(qVariantFromValue(selectedItemIndex));
+ connect(reload, SIGNAL(triggered()),
+ this, SLOT(reload_item()));
+ menu->setProperty(prop_name, true);
+ }
+ }
+ if(menu)
+ menu->exec(global_pos);
+}
+
+void MainWindow::showSceneContextMenu(const QPoint& p) {
+ QWidget* sender = qobject_cast(this->sender());
+ if(!sender) return;
+
+ int index = -1;
+ if(sender == treeView) {
+ QModelIndex modelIndex = treeView->indexAt(p);
+ if(!modelIndex.isValid()) return;
+
+ index = modelIndex.row();
+ }
+ else {
+ index = scene->mainSelectionIndex();
+ }
+
+ showSceneContextMenu(index, sender->mapToGlobal(p));
+}
+
void MainWindow::removeManipulatedFrame(Scene_item* item)
{
if(item->manipulatable() &&
@@ -359,12 +806,26 @@ void MainWindow::removeManipulatedFrame(Scene_item* item)
void MainWindow::updateInfo() {
Scene_item* item = scene->item(getSelectedSceneItemIndex());
- if(item)
- ui->infoLabel->setText(item->toolTip());
+ if(item) {
+ QString item_text = item->toolTip();
+ QString item_filename = item->property("source filename").toString();
+ if(!item_filename.isEmpty()) {
+ item_text += QString("
File: %1").arg(item_filename);
+ }
+ ui->infoLabel->setText(item_text);
+ }
else
ui->infoLabel->clear();
}
+void MainWindow::updateDisplayInfo() {
+ Scene_item* item = scene->item(getSelectedSceneItemIndex());
+ if(item)
+ ui->displayLabel->setPixmap(item->graphicalToolTip());
+ else
+ ui->displayLabel->clear();
+}
+
void MainWindow::readSettings()
{
this->readState("MainWindow", Size|State);
@@ -390,12 +851,25 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::on_actionLoad_triggered()
{
QStringList filters;
+ QStringList extensions;
Q_FOREACH(Polyhedron_demo_io_plugin_interface* plugin, io_plugins) {
if(plugin->canLoad()) {
- filters += plugin->nameFilters();
+ Q_FOREACH(QString filter, plugin->nameFilters()) {
+ if(!filter.isEmpty()) {
+ QRegExp re1("\\((.+)\\)");
+ if(re1.indexIn(filter) != -1) {
+ QString filter_extensions = re1.cap(1);
+ extensions += filter_extensions.simplified().split(" ");
+ }
+ filters << filter;
+ }
+ }
}
}
+ QStringList sorted_extensions = extensions.toSet().toList();
filters << tr("All files (*)");
+ filters.push_front(QString("All know files (%1)")
+ .arg(sorted_extensions.join(" ")));
QSettings settings;
QString directory = settings.value("OFF open directory",
@@ -444,19 +918,15 @@ void MainWindow::on_actionSaveAs_triggered()
QFileDialog::getSaveFileName(this,
tr("Save to File..."),
QString(),
- tr("OFF files (*.off)\n"
- "All files (*)"));
- QFileInfo fileinfo(filename);
- if(!fileinfo.isFile() ||
- QMessageBox::warning(this,
- tr("File exists"),
- tr("The file %1 already exists! Continue?")
- .arg(filename),
- QMessageBox::Yes|QMessageBox::No) ==
- QMessageBox::Yes)
- {
+ filters.join(";;"));
+ save(filename, item);
+}
- Q_FOREACH(Polyhedron_demo_io_plugin_interface* plugin, canSavePlugins) {
+void MainWindow::save(QString filename, Scene_item* item) {
+ QFileInfo fileinfo(filename);
+
+ Q_FOREACH(Polyhedron_demo_io_plugin_interface* plugin, io_plugins) {
+ if(plugin->canSave(item)) {
if(plugin->save(item, fileinfo))
break;
}
@@ -465,9 +935,9 @@ void MainWindow::on_actionSaveAs_triggered()
bool MainWindow::on_actionErase_triggered()
{
- int index = scene->erase(getSelectedSceneItemIndex());
- selectSceneItem(index);
- return index >= 0;
+ int next_index = scene->erase(scene->selectionIndices());
+ selectSceneItem(next_index);
+ return next_index >= 0;
}
void MainWindow::on_actionEraseAll_triggered()
@@ -505,6 +975,49 @@ void MainWindow::on_actionSetPolyhedronB_triggered()
scene->setItemB(i);
}
+void MainWindow::on_actionSetBackgroundColor_triggered()
+{
+ QColor c = QColorDialog::getColor();
+ if(c.isValid()) {
+ viewer->setBackgroundColor(c);
+ }
+}
+
+void MainWindow::on_action_Look_at_triggered()
+{
+ Show_point_dialog dialog(this);
+ int i = dialog.exec();
+ if( i == QDialog::Accepted &&
+ dialog.has_correct_coordinates() )
+ {
+ viewerShow((float)dialog.get_x(),
+ (float)dialog.get_y(),
+ (float)dialog.get_z());
+ }
+}
+
+QString MainWindow::camera_string() const
+{
+ return viewer->dumpCameraCoordinates();
+}
+
+void MainWindow::on_actionDumpCamera_triggered()
+{
+ information(QString("Camera: %1")
+ .arg(camera_string()));
+}
+
+void MainWindow::on_action_Copy_camera_triggered()
+{
+ qApp->clipboard()->setText(this->camera_string());
+}
+
+void MainWindow::on_action_Paste_camera_triggered()
+{
+ QString s = qApp->clipboard()->text();
+ viewer->moveCameraToCoordinates(s, 0.5f);
+}
+
void MainWindow::setAddKeyFrameKeyboardModifiers(::Qt::KeyboardModifiers m)
{
viewer->setAddKeyFrameKeyboardModifiers(m);
diff --git a/Polyhedron/demo/Polyhedron/MainWindow.h b/Polyhedron/demo/Polyhedron/MainWindow.h
index d6d13bfe50e..e030162fa8f 100644
--- a/Polyhedron/demo/Polyhedron/MainWindow.h
+++ b/Polyhedron/demo/Polyhedron/MainWindow.h
@@ -4,8 +4,14 @@
#include
#include
+#ifdef QT_SCRIPT_LIB
+# include
+#endif
#include
+#include
+#include
+#include
class Scene;
class Viewer;
@@ -35,22 +41,44 @@ public:
public slots:
void updateViewerBBox();
- void open(QString filename);
+ void open(QString filename, bool no_popup = false);
+ Scene_item* load_item(QFileInfo) const;
+ void reload_item();
void selectSceneItem(int i);
+ void showSelectedPoint(double, double, double);
+ void unSelectSceneItem(int i);
+ void selectAll();
+ void addSceneItemInSelection(int i);
+ void removeSceneItemFromSelection(int i); // same as unSelectSceneItem
void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers);
void clearMenu(QMenu*);
void addAction(QAction*);
+ void addAction(QString actionName,
+ QString actionText,
+ QString menuName);
+ void viewerShow(float, float, float);
void information(QString);
void warning(QString);
void error(QString);
+ void message(QString, QString, QString = QString("normal"));
+
+ bool hasPlugin(QString);
+ void enableScriptDebugger(bool = true);
protected slots:
void selectionChanged();
+
+ void contextMenuRequested(const QPoint& global_pos);
+ void showSceneContextMenu(int selectedItemIndex,
+ const QPoint& global_pos);
+ void showSceneContextMenu(const QPoint& local_pos_of_treeview);
+
void updateInfo();
+ void updateDisplayInfo();
void removeManipulatedFrame(Scene_item*);
// settings
@@ -73,9 +101,18 @@ protected slots:
// save as...
void on_actionSaveAs_triggered();
+ void save(QString filename, Scene_item* item);
+
+ void on_actionSetBackgroundColor_triggered();
+
+ void on_action_Look_at_triggered();
+
+ QString camera_string() const;
+ void on_actionDumpCamera_triggered();
+ void on_action_Copy_camera_triggered();
+ void on_action_Paste_camera_triggered();
protected:
- void message(QString, QString, QString = QString("normal"));
void loadPlugins();
bool initPlugin(QObject*);
bool initIOPlugin(QObject*);
@@ -84,6 +121,7 @@ protected:
bool onePolygonIsSelected() const;
int getSelectedSceneItemIndex() const;
+ QList getSelectedSceneItemIndices() const;
private:
QString strippedName(const QString &fullFileName);
@@ -93,6 +131,16 @@ private:
QTreeView* treeView;
Ui::MainWindow* ui;
QVector io_plugins;
+ QStringList plugins;
+#ifdef QT_SCRIPT_LIB
+ QScriptEngine* script_engine;
+public:
+ void evaluate_script(QString script,
+ const QString & fileName = QString(),
+ const bool quiet = false);
+ void evaluate_script_quiet(QString script,
+ const QString & fileName = QString());
+#endif
};
#endif // ifndef MAINWINDOW_H
diff --git a/Polyhedron/demo/Polyhedron/MainWindow.ui b/Polyhedron/demo/Polyhedron/MainWindow.ui
index f48127f67a7..85fe822068d 100644
--- a/Polyhedron/demo/Polyhedron/MainWindow.ui
+++ b/Polyhedron/demo/Polyhedron/MainWindow.ui
@@ -1,4 +1,3 @@
-
MainWindow
@@ -29,9 +28,6 @@
- -
-
-
@@ -139,7 +148,7 @@
- Polyhedra
+ Geometric Objects
1
@@ -206,6 +215,9 @@
true
+
+ QAbstractItemView::ExtendedSelection
+
0
@@ -238,6 +250,45 @@
+
+
+ Infos
+
+
+ 1
+
+
+
+ -
+
+
+ 0
+
+
-
+
+
+ Qt::CustomContextMenu
+
+
+ 0
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
&Quit
@@ -431,17 +482,11 @@
Set polyhedron A
-
- Ctrl+A
-
Set polyhedron B
-
- Ctrl+B
-
@@ -453,6 +498,11 @@
&Remeshing
+
+
+ Convex Decomposition
+
+
Mean &value coordinates
@@ -489,6 +539,19 @@
Ctrl+T
+
+
+ Re¢er scene
+
+
+ Ctrl+C
+
+
+
+
+ Change &background color...
+
+
&Minkowski sum
@@ -497,9 +560,32 @@
Ctrl+O, M
-
+
- Convex Decomposition
+ &Look at...
+
+
+
+
+ &Dump camera coordinates
+
+
+
+
+ &Copy camera
+
+
+
+
+ &Paste camera
+
+
+
+
+ Select all items
+
+
+ Ctrl+A
diff --git a/Polyhedron/demo/Polyhedron/Point_dialog_config.h b/Polyhedron/demo/Polyhedron/Point_dialog_config.h
new file mode 100644
index 00000000000..4133f9776b6
--- /dev/null
+++ b/Polyhedron/demo/Polyhedron/Point_dialog_config.h
@@ -0,0 +1,12 @@
+#ifndef POINT_DIALOG_CONFIG_H
+#define POINT_DIALOG_CONFIG_H
+
+#include
+
+#ifdef point_dialog_EXPORTS
+# define POINT_DIALOG_EXPORT Q_DECL_EXPORT
+#else
+# define POINT_DIALOG_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // POINT_DIALOG_CONFIG_H
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_3.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_3.cpp
index c03c4b22ffc..ba0eb98f23e 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_3.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_3.cpp
@@ -25,11 +25,26 @@ int main(int argc, char **argv)
mainWindow.setAddKeyFrameKeyboardModifiers(::Qt::MetaModifier);
args.removeAt(0);
}
-
+#ifdef QT_SCRIPT_LIB
+ if(!args.empty() && args[0] == "--debug-scripts")
+ {
+ mainWindow.enableScriptDebugger();
+ args.removeAt(0);
+ }
+ mainWindow.open("autostart.js", true);
+#endif
Q_FOREACH(QString filename, args) {
mainWindow.open(filename);
}
- return app.exec();
+
+ // A Qt Script may have closed the main window
+ // The following loop launch app.exec() only if there is a visible
+ // window.
+ Q_FOREACH (QWidget *widget, QApplication::topLevelWidgets()) {
+ if(widget->isVisible())
+ return app.exec();
+ }
+ return 0;
}
#ifndef USE_FORWARD_DECL
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_kernel_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_kernel_plugin.cpp
index 3e3d15629f7..d4403303f8b 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_kernel_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_kernel_plugin.cpp
@@ -17,6 +17,13 @@
#include
#include
+#include "Kernel_type.h"
+typedef Kernel::Triangle_3 Triangle;
+typedef Kernel::Point_3 Point;
+typedef Kernel::Vector_3 Vector;
+typedef Kernel::Plane_3 Plane;
+typedef Kernel::FT FT;
+
class Polyhedron_demo_kernel_plugin :
public QObject,
public Polyhedron_demo_plugin_helper
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp
index 5dc9fba218b..d21a51808e1 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_plugin.cpp
@@ -32,7 +32,7 @@ bool Polyhedron_demo_off_plugin::canLoad() const {
Scene_item*
Polyhedron_demo_off_plugin::load(QFileInfo fileinfo) {
-
+ if(fileinfo.suffix().toLower() != "off") return 0;
// Open file
std::ifstream in(fileinfo.filePath().toUtf8());
if(!in) {
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_to_nef_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_to_nef_plugin.cpp
index 77874a6951e..4016bfffddd 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_to_nef_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_off_to_nef_plugin.cpp
@@ -36,7 +36,7 @@ Polyhedron_demo_off_to_nef_plugin::load(QFileInfo fileinfo) {
std::cerr << "Error!\n";
Scene_nef_polyhedron_item* item = new Scene_nef_polyhedron_item();
- if(!item->load(in))
+ if(!item->load_from_off(in))
{
delete item;
return 0;
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_orient_soup_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_orient_soup_plugin.cpp
index eab5c9d82d7..555917c4ddc 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_orient_soup_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_orient_soup_plugin.cpp
@@ -6,6 +6,7 @@
#include
#include "Scene_polygon_soup.h"
+#include "Scene_polyhedron_item.h"
#include "Polyhedron_demo_plugin_interface.h"
#include "Messages_interface.h"
@@ -46,6 +47,7 @@ void Polyhedron_demo_orient_soup_plugin::init(QMainWindow* mainWindow,
mw = mainWindow;
messages = m;
actionOrient = new QAction(tr("Orient polygon soup"), mainWindow);
+ actionOrient->setObjectName("actionOrient");
connect(actionOrient, SIGNAL(triggered()),
this, SLOT(orient()));
@@ -67,26 +69,41 @@ QList Polyhedron_demo_orient_soup_plugin::actions() const {
void Polyhedron_demo_orient_soup_plugin::orient()
{
- const Scene_interface::Item_id index = scene->mainSelectionIndex();
-
- Scene_polygon_soup* item =
- qobject_cast(scene->item(index));
-
- if(item)
+ Q_FOREACH(Scene_interface::Item_id index, scene->selectionIndices())
{
-// qDebug() << tr("I have the item %1\n").arg(item->name());
- QApplication::setOverrideCursor(Qt::WaitCursor);
- if(!item->orient())
- messages->warning(tr("The polygon soup \"%1\" is not orientable.")
- .arg(item->name()));
- // QMessageBox::information(mw, tr("Not orientable"),
-// tr("The polygon soup \"%1\" is not orientable.")
-// .arg(item->name()));
+ Scene_polygon_soup* item =
+ qobject_cast(scene->item(index));
- scene->itemChanged(item);
-
- QApplication::restoreOverrideCursor();
+ if(item)
+ {
+ // qDebug() << tr("I have the item %1\n").arg(item->name());
+ QApplication::setOverrideCursor(Qt::WaitCursor);
+ if(!item->orient()) {
+ messages->warning(tr("The polygon soup \"%1\" is not orientable.")
+ .arg(item->name()));
+ // QMessageBox::information(mw, tr("Not orientable"),
+ // tr("The polygon soup \"%1\" is not orientable.")
+ // .arg(item->name()));
+ scene->itemChanged(item);
+ } else {
+
+ Scene_polyhedron_item* poly_item = new Scene_polyhedron_item();
+ if(item->exportAsPolyhedron(poly_item->polyhedron())) {
+ poly_item->setName(item->name());
+ poly_item->setColor(item->color());
+ poly_item->setRenderingMode(item->renderingMode());
+ poly_item->setVisible(item->visible());
+ poly_item->changed();
+ poly_item->setProperty("source filename", item->property("source filename"));
+ scene->replaceItem(index, poly_item);
+ delete item;
+ } else {
+ scene->itemChanged(item);
+ }
+ }
+ }
}
+ QApplication::restoreOverrideCursor();
}
void Polyhedron_demo_orient_soup_plugin::shuffle()
@@ -96,9 +113,26 @@ void Polyhedron_demo_orient_soup_plugin::shuffle()
Scene_polygon_soup* item =
qobject_cast(scene->item(index));
- if(item)
+ if(item) {
item->shuffle_orientations();
- scene->itemChanged(item);
+ scene->itemChanged(item);
+ }
+ else {
+ Scene_polyhedron_item* poly_item =
+ qobject_cast(scene->item(index));
+ if(poly_item) {
+ item = new Scene_polygon_soup();
+ item->setName(poly_item->name());
+ item->setColor(poly_item->color());
+ item->setRenderingMode(poly_item->renderingMode());
+ item->setVisible(poly_item->visible());
+ item->setProperty("source filename", poly_item->property("source filename"));
+ item->load(poly_item);
+ item->shuffle_orientations();
+ scene->replaceItem(index, item);
+ delete poly_item;
+ }
+ }
}
void Polyhedron_demo_orient_soup_plugin::displayNonManifoldEdges()
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp
index d1b0c5880b6..3291389b87f 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_parameterization_plugin.cpp
@@ -5,6 +5,7 @@
#include "Scene_polyhedron_item.h"
#include "Scene_textured_polyhedron_item.h"
#include "Textured_polyhedron_type.h"
+#include "Polyhedron_type.h"
#include
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp
index ae758e747d6..3560a5ea981 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_pca_plugin.cpp
@@ -14,6 +14,16 @@
#include // output for plane fitting
#include // output for line fitting
+#include "Kernel_type.h"
+typedef Kernel::Plane_3 Plane;
+typedef Kernel::Iso_cuboid_3 Iso_cuboid;
+typedef Kernel::Triangle_3 Triangle;
+typedef Kernel::Line_3 Line;
+typedef Kernel::Vector_3 Vector;
+typedef Kernel::Point_3 Point;
+typedef Kernel::FT FT;
+
+
class Polyhedron_demo_pca_plugin :
public QObject,
public Polyhedron_demo_plugin_helper
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp
index 3985513e9ea..a5aaa911898 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_remeshing_plugin_cgal_code.cpp
@@ -296,6 +296,8 @@ Scene_item* cgal_code_remesh(QWidget* parent,
{ // new scope for the initialization, so that the vector
// polyhedron_points is destroyed as soon as the initialization is
// finished
+ typedef Kernel::Point_3 Point;
+
std::vector polyhedron_points;
polyhedron_points.reserve(pMesh->size_of_vertices());
std::copy(pMesh->points_begin(), pMesh->points_end(),
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp
index cd35942c854..5df1f10acd2 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_self_intersection_plugin.cpp
@@ -1,6 +1,7 @@
#include
#include
#include
+#include "Kernel_type.h"
#include "Polyhedron_type.h"
#include "Scene_polyhedron_item.h"
@@ -14,6 +15,8 @@
#include
#include
+typedef Kernel::Triangle_3 Triangle;
+
class Polyhedron_demo_self_intersection_plugin :
public QObject,
public Polyhedron_demo_plugin_helper
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp
index f1198a7013b..ddf73011158 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_triangulate_facets_plugin.cpp
@@ -6,125 +6,9 @@
#include "Polyhedron_demo_plugin_helper.h"
#include "Scene_polyhedron_item.h"
#include "Polyhedron_type.h"
-#include
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
#include "CGAL/compute_normal.h"
-
-#include
-
-typedef Polyhedron::Halfedge_handle Halfedge_handle;
-
-typedef CGAL::Triangulation_2_filtered_projection_traits_3 Traits;
-
-typedef CGAL::Triangulation_vertex_base_with_info_2 Vb;
-
-struct Face_info {
- Halfedge_handle e[3];
- bool is_external;
-};
-
-typedef CGAL::Triangulation_face_base_with_info_2 Fb1;
-
-typedef CGAL::Constrained_triangulation_face_base_2 Fb;
-typedef CGAL::Triangulation_data_structure_2 TDS;
-typedef CGAL::No_intersection_tag Itag;
-typedef CGAL::Constrained_Delaunay_triangulation_2 CDTbase;
-typedef CGAL::Constrained_triangulation_plus_2 CDT;
-
-typedef Polyhedron::HalfedgeDS HDS;
-
-class Triangulate_modifier : public CGAL::Modifier_base {
- CDT* cdt;
- Polyhedron::Facet_handle fh;
-
-public:
- Triangulate_modifier(CDT* cdt,
- Polyhedron::Facet_handle fh)
- : cdt(cdt), fh(fh)
- {
- }
-
- bool is_external(CDT::Face_handle fh) const {
- return fh->info().is_external;
- }
-
- void operator()(HDS& hds) {
- CGAL::HalfedgeDS_decorator decorator(hds);
- typedef Polyhedron::Halfedge Halfedge;
-
- decorator.make_hole(fh->halfedge());
- for(CDT::Finite_edges_iterator
- eit = cdt->finite_edges_begin(),
- end = cdt->finite_edges_end();
- eit != end; ++eit)
- {
- CDT::Face_handle fh = eit->first;
- const int index = eit->second;
- CDT::Face_handle opposite_fh = fh->neighbor(eit->second);
- const int opposite_index = opposite_fh->index(fh);
- const CDT::Vertex_handle va = fh->vertex(cdt-> cw(index));
- const CDT::Vertex_handle vb = fh->vertex(cdt->ccw(index));
-
- if( ! (is_external(fh) && is_external(opposite_fh)) &&
- ! cdt->is_constrained(*eit) )
- {
- // strictly internal edge
- Halfedge_handle h = hds.edges_push_back(Halfedge(),
- Halfedge());
- fh->info().e[index] = h;
- opposite_fh->info().e[opposite_index] = h->opposite();
-
- decorator.set_vertex(h, va->info()->vertex());
- decorator.set_vertex(h->opposite(), vb->info()->vertex());
- }
- if( cdt->is_constrained(*eit) )
- {
- if(!is_external(fh)) {
- fh->info().e[index] = va->info();
- }
- if(!is_external(opposite_fh)) {
- opposite_fh->info().e[opposite_index] = vb->info();
- }
- }
- }
- for(CDT::Finite_faces_iterator
- fit = cdt->finite_faces_begin(),
- end = cdt->finite_faces_end();
- fit != end; ++fit)
- {
- if(!is_external(fit))
- {
- Halfedge_handle h0 = fit->info().e[0];
- Halfedge_handle h1 = fit->info().e[1];
- Halfedge_handle h2 = fit->info().e[2];
- CGAL_assertion( h0 != Halfedge_handle() );
- CGAL_assertion( h1 != Halfedge_handle() );
- CGAL_assertion( h2 != Halfedge_handle() );
-
- typedef Halfedge::Base HBase;
- h0->HBase::set_next(h1);
- decorator.set_prev(h1, h0);
- h1->HBase::set_next(h2);
- decorator.set_prev(h2, h1);
- h2->HBase::set_next(h0);
- decorator.set_prev(h0, h2);
-
- decorator.fill_hole(h0);
- }
- }
- }
-};
+#include "CGAL/triangulate_polyhedron.h"
class Polyhedron_demo_triangulate_facets_plugin :
public QObject,
@@ -159,7 +43,6 @@ public:
public slots:
void untriangulate() {
- CGAL::set_error_behaviour(CGAL::ABORT);
const Scene_interface::Item_id index = scene->mainSelectionIndex();
Scene_polyhedron_item* item =
@@ -187,7 +70,7 @@ public slots:
!eit_copy->vertex()->is_bivalent() &&
!eit_copy->opposite()->vertex()->is_bivalent())
{
- Kernel::Vector_3 v1 = compute_facet_normal(*fh1);
+ Kernel::Vector_3 v1 = compute_facet_normal(*fh1);
Kernel::Vector_3 v2 = compute_facet_normal(*fh2);
if(v1 * v2 > 0.99) {
std::cerr << "join\n";
@@ -206,103 +89,35 @@ public slots:
}
void triangulate() {
- CGAL::set_error_behaviour(CGAL::ABORT);
- const Scene_interface::Item_id index = scene->mainSelectionIndex();
-
+ Q_FOREACH(Scene_interface::Item_id index, scene->selectionIndices()) {
+
Scene_polyhedron_item* item =
qobject_cast(scene->item(index));
if(item)
{
Polyhedron* pMesh = item->polyhedron();
- if(!pMesh) return;
+ if(!pMesh) continue;
if(pMesh->is_pure_triangle()) {
messages->warning(tr("The polyhedron \"%1\" is already triangulated.")
.arg(item->name()));
- return;
+ continue;
}
QApplication::setOverrideCursor(Qt::WaitCursor);
- typedef Polyhedron::Facet Facet;
- typedef Polyhedron::Facet_iterator Facet_iterator;
- typedef Polyhedron::Facet_handle Facet_handle;
+ CGAL::triangulate_polyhedron(*pMesh);
- // One need to store facet handles into a vector, because the list of
- // facets of the polyhedron will be modified during the loop, and
- // that invalidates the range [facets_begin(), facets_end()[.
- std::vector facets;
- facets.reserve(pMesh->size_of_facets());
- for(Facet_iterator
- fit = pMesh->facets_begin(),
- end = pMesh->facets_end();
- fit != end; ++fit) {
- facets.push_back(fit);
- }
-
- // Iterates on the vector of facet handles
- for(std::vector::iterator
- fit_it = facets.begin(),
- end = facets.end();
- fit_it != end; ++fit_it)
- {
- Facet_handle fit = *fit_it;
- Kernel::Vector_3 normal = compute_facet_normal(*fit);
-
- Traits cdt_traits(normal);
- CDT cdt(cdt_traits);
-
- Facet::Halfedge_around_facet_circulator
- he_circ = fit->facet_begin(),
- he_circ_end(he_circ);
- CDT::Vertex_handle previous, first;
- do {
- CDT::Vertex_handle vh = cdt.insert(he_circ->vertex()->point());
- if(first == 0) {
- first = vh;
- }
- vh->info() = he_circ;
- if(previous != 0 && previous != vh) {
- cdt.insert_constraint(previous, vh);
- }
- previous = vh;
- } while( ++he_circ != he_circ_end );
- cdt.insert_constraint(previous, first);
-
- // sets mark is_external
- for(CDT::Finite_faces_iterator
- fit = cdt.finite_faces_begin(),
- end = cdt.finite_faces_end();
- fit != end; ++fit)
- {
- fit->info().is_external = false;
- }
- std::queue face_queue;
- face_queue.push(cdt.infinite_vertex()->face());
- while(! face_queue.empty() ) {
- CDT::Face_handle fh = face_queue.front();
- face_queue.pop();
- CGAL_assertion(cdt.is_infinite(fh));
- if(fh->info().is_external) continue;
- std::cerr << (void*)(&*fh) << std::endl;
- fh->info().is_external = true;
- for(int i = 0; i <3; ++i) {
- if(!cdt.is_constrained(std::make_pair(fh, i)))
- {
- face_queue.push(fh->neighbor(i));
- }
- }
- }
- // then modify the polyhedron
- Triangulate_modifier modifier(&cdt, fit);
- pMesh->delegate(modifier);
- }
CGAL_assertion_code(pMesh->normalize_border());
CGAL_assertion(pMesh->is_valid(false, 3));
+
scene->itemChanged(item);
- // default cursor
- QApplication::restoreOverrideCursor();
- }
+
+ } // end of if(item)
+
+ } // end of the loop on the selected items
+ // default cursor
+ QApplication::restoreOverrideCursor();
}
private:
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_demo_trivial_plugin.cpp b/Polyhedron/demo/Polyhedron/Polyhedron_demo_trivial_plugin.cpp
index 3f1912c073f..c81ca089e55 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_demo_trivial_plugin.cpp
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_demo_trivial_plugin.cpp
@@ -125,7 +125,7 @@ QList Polyhedron_demo_trivial_plugin::actions() const {
void Polyhedron_demo_trivial_plugin::bbox()
{
- for(size_t i = 0, end = scene->numberOfEntries();
+ for(int i = 0, end = scene->numberOfEntries();
i < end; ++i)
{
if(qobject_cast(scene->item(i)))
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_type.h b/Polyhedron/demo/Polyhedron/Polyhedron_type.h
index a1785386f9a..feaf36eda34 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_type.h
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_type.h
@@ -3,27 +3,126 @@
// CGAL
// kernel
-#include
-
-typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
+#include "Kernel_type.h"
// surface mesh
#include
+#include
+
+#include
+
+template
+class Polyhedron_demo_vertex :
+ public CGAL::HalfedgeDS_vertex_base
+{
+public:
+ typedef std::set Set_of_indices;
+
+private:
+ typedef CGAL::HalfedgeDS_vertex_base Pdv_base;
+
+ Set_of_indices indices;
+public:
+ int nb_of_feature_edges;
+
+ bool is_corner() const {
+ return nb_of_feature_edges > 2;
+ }
+
+ bool is_feature_vertex() const {
+ return nb_of_feature_edges != 0;
+ }
+
+ void add_incident_patch(const Patch_id i) {
+ indices.insert(i);
+ }
+
+ const Set_of_indices&
+ incident_patches_ids_set() const {
+ return indices;
+ }
+
+ Polyhedron_demo_vertex() : Pdv_base(), nb_of_feature_edges(0) {}
+ Polyhedron_demo_vertex(const Point& p) : Pdv_base(p), nb_of_feature_edges(0) {}
+};
+
+template
+class Polyhedron_demo_halfedge :
+ public CGAL::HalfedgeDS_halfedge_base
+{
+private:
+ bool feature_edge;
+public:
+
+ Polyhedron_demo_halfedge()
+ : feature_edge(false) {};
+
+ bool is_feature_edge() const {
+ return feature_edge;
+ }
+
+ void set_feature_edge(const bool b) {
+ feature_edge = b;
+ this->opposite()->feature_edge = b;
+ }
+};
+
+template
+class Polyhedron_demo_face :
+ public CGAL::HalfedgeDS_face_base
+{
+private:
+ Patch_id_ patch_id_;
+public:
+ typedef Patch_id_ Patch_id;
+
+ Polyhedron_demo_face()
+ : patch_id_(1) {}
+
+ int patch_id() const {
+ return patch_id_;
+ }
+
+ void set_patch_id(const int i) {
+ patch_id_ = i;
+ }
+};
+
+template
+class Polyhedron_demo_items : public CGAL::Polyhedron_items_3 {
+public:
+ // wrap vertex
+ template struct Vertex_wrapper
+ {
+ typedef typename Traits::Point_3 Point;
+ typedef Polyhedron_demo_vertex Vertex;
+ };
+
+ // wrap face
+ template struct Face_wrapper
+ {
+ typedef Polyhedron_demo_face Face;
+ };
+
+ // wrap halfedge
+ template struct Halfedge_wrapper
+ {
+ typedef Polyhedron_demo_halfedge Halfedge;
+ };
+};
#include "Polyhedron_type_fwd.h"
-// simple geometric types
-typedef Kernel::FT FT;
-typedef Kernel::Line_3 Line;
-typedef Kernel::Point_3 Point;
-typedef Kernel::Plane_3 Plane;
-typedef Kernel::Sphere_3 Sphere;
-typedef Kernel::Vector_3 Vector;
-typedef Kernel::Triangle_3 Triangle;
-typedef Kernel::Iso_cuboid_3 Iso_cuboid;
-typedef Kernel::Plane_3 Plane_3;
-
// surface mesh
-typedef CGAL::Polyhedron_3 Polyhedron;
+typedef CGAL::Polyhedron_3 > Polyhedron;
#endif // POLYHEDRON_TYPE_H
diff --git a/Polyhedron/demo/Polyhedron/Polyhedron_type_fwd.h b/Polyhedron/demo/Polyhedron/Polyhedron_type_fwd.h
index b950b1ed784..294e96bdf5b 100644
--- a/Polyhedron/demo/Polyhedron/Polyhedron_type_fwd.h
+++ b/Polyhedron/demo/Polyhedron/Polyhedron_type_fwd.h
@@ -8,8 +8,16 @@
#include
+template
+class Polyhedron_demo_items;
+
namespace CGAL {
+ namespace Mesh_3 {
+ template
+ struct Robust_intersection_traits_3;
+ }
+
template < typename FT_ >
struct Simple_cartesian;
@@ -32,15 +40,27 @@ namespace CGAL {
>
class Polyhedron_3;
+// changed since CGAL-3.8-Ic-8
+#if CGAL_VERSION_NR > 1030800008
+ class Epick;
+#endif
} // end namespace CGAL
// kernel
-
-typedef CGAL::Epick Kernel;
+namespace polyhedron_type_fwd_h {
+// changed since CGAL-3.8-Ic-8
+#if CGAL_VERSION_NR > 1030800008
+ typedef CGAL::Epick K1;
+#else
+ typedef CGAL::Filtered_kernel< CGAL::Simple_cartesian, true > K1;
+#endif
+ typedef CGAL::Mesh_3::Robust_intersection_traits_3 Kernel;
+}
// surface mesh
-typedef CGAL::Polyhedron_3,
+ // CGAL::Polyhedron_items_3,
CGAL::HalfedgeDS_default,
std::allocator > Polyhedron;
diff --git a/Polyhedron/demo/Polyhedron/Scene.cpp b/Polyhedron/demo/Polyhedron/Scene.cpp
index a53badda303..04a501d3f7d 100644
--- a/Polyhedron/demo/Polyhedron/Scene.cpp
+++ b/Polyhedron/demo/Polyhedron/Scene.cpp
@@ -2,6 +2,8 @@
#include "Scene.h"
#include "Scene_item.h"
+#include
+#include
#include
#include
#include
@@ -10,11 +12,12 @@
#include
#include
#include
+#include
namespace {
void CGALglcolor(QColor c)
{
- ::glColor4f(c.red()/255.0, c.green()/255.0, c.blue()/255.0, c.alpha()/255.0);
+ ::glColor4d(c.red()/255.0, c.green()/255.0, c.blue()/255.0, c.alpha()/255.0);
}
}
@@ -24,29 +27,54 @@ Scene::Scene(QObject* parent)
item_A(-1),
item_B(-1)
{
+ connect(this, SIGNAL(selectionRay(double, double, double,
+ double, double, double)),
+ this, SLOT(setSelectionRay(double, double, double,
+ double, double, double)));
}
Scene::Item_id
Scene::addItem(Scene_item* item)
{
- entries.push_back(item);
+ m_entries.push_back(item);
+ connect(item, SIGNAL(itemChanged()),
+ this, SLOT(itemChanged()));
emit updated_bbox();
emit updated();
QAbstractListModel::reset();
- return entries.size() - 1;
+ Item_id id = m_entries.size() - 1;
+ emit newItem(id);
+ return id;
+}
+
+Scene_item*
+Scene::replaceItem(Scene::Item_id index, Scene_item* item)
+{
+ if(index < 0 || index >= m_entries.size())
+ return 0;
+
+ connect(item, SIGNAL(itemChanged()),
+ this, SLOT(itemChanged()));
+ std::swap(m_entries[index], item);
+
+ emit updated_bbox();
+ emit updated();
+ itemChanged(index);
+ QAbstractListModel::reset();
+ return item;
}
int
Scene::erase(int index)
{
- if(index < 0 || index >= entries.size())
+ if(index < 0 || index >= m_entries.size())
return -1;
- Scene_item* item = entries[index];
+ Scene_item* item = m_entries[index];
emit itemAboutToBeDestroyed(item);
delete item;
- entries.removeAt(index);
+ m_entries.removeAt(index);
selected_item = -1;
emit updated();
@@ -54,30 +82,62 @@ Scene::erase(int index)
if(--index >= 0)
return index;
- if(!entries.isEmpty())
+ if(!m_entries.isEmpty())
+ return 0;
+ return -1;
+}
+
+int
+Scene::erase(QList indices)
+{
+ QList to_be_removed;
+
+ int max_index = -1;
+ Q_FOREACH(int index, indices) {
+ if(index < 0 || index >= m_entries.size())
+ continue;
+ max_index = (std::max)(max_index, index);
+ Scene_item* item = m_entries[index];
+ to_be_removed.push_back(item);
+ emit itemAboutToBeDestroyed(item);
+ delete item;
+ }
+
+ Q_FOREACH(Scene_item* item, to_be_removed) {
+ m_entries.removeAll(item);
+ }
+
+ selected_item = -1;
+ emit updated();
+ QAbstractListModel::reset();
+
+ int index = max_index + 1 - indices.size();
+ if(index >= 0)
+ return index;
+ if(!m_entries.isEmpty())
return 0;
return -1;
}
Scene::~Scene()
{
- Q_FOREACH(Scene_item* item_ptr, entries)
+ Q_FOREACH(Scene_item* item_ptr, m_entries)
{
delete item_ptr;
}
- entries.clear();
+ m_entries.clear();
}
Scene_item*
Scene::item(Item_id index) const
{
- return entries.value(index); // QList::value checks bounds
+ return m_entries.value(index); // QList::value checks bounds
}
-size_t
+int
Scene::numberOfEntries() const
{
- return entries.size();
+ return m_entries.size();
}
// Duplicate a scene item.
@@ -85,17 +145,17 @@ Scene::numberOfEntries() const
Scene::Item_id
Scene::duplicate(Item_id index)
{
- if(index < 0 || index >= entries.size())
+ if(index < 0 || index >= m_entries.size())
return -1;
- const Scene_item* item = entries[index];
+ const Scene_item* item = m_entries[index];
Scene_item* new_item = item->clone();
if(new_item) {
new_item->setName(tr("%1 (copy)").arg(item->name()));
new_item->setColor(item->color());
new_item->setVisible(item->visible());
addItem(new_item);
- return entries.size() - 1;
+ return m_entries.size() - 1;
}
else
return -1;
@@ -125,12 +185,12 @@ void
Scene::draw_aux(bool with_names)
{
// Flat/Gouraud OpenGL drawing
- for(int index = 0; index < entries.size(); ++index)
+ for(int index = 0; index < m_entries.size(); ++index)
{
if(with_names) {
::glPushName(index);
}
- Scene_item& item = *entries[index];
+ Scene_item& item = *m_entries[index];
if(item.visible())
{
if(item.renderingMode() == Flat || item.renderingMode() == FlatPlusEdges || item.renderingMode() == Gouraud)
@@ -157,12 +217,12 @@ Scene::draw_aux(bool with_names)
}
// Wireframe OpenGL drawing
- for(int index = 0; index < entries.size(); ++index)
+ for(int index = 0; index < m_entries.size(); ++index)
{
if(with_names) {
::glPushName(index);
}
- Scene_item& item = *entries[index];
+ Scene_item& item = *m_entries[index];
if(item.visible())
{
if(item.renderingMode() == FlatPlusEdges || item.renderingMode() == Wireframe)
@@ -185,12 +245,12 @@ Scene::draw_aux(bool with_names)
}
// Points OpenGL drawing
- for(int index = 0; index < entries.size(); ++index)
+ for(int index = 0; index < m_entries.size(); ++index)
{
if(with_names) {
::glPushName(index);
}
- Scene_item& item = *entries[index];
+ Scene_item& item = *m_entries[index];
if(item.visible())
{
if(item.renderingMode() == Points)
@@ -222,7 +282,7 @@ Scene::rowCount(const QModelIndex & parent) const
if (parent.isValid())
return 0;
else
- return entries.size();
+ return m_entries.size();
}
int
@@ -240,33 +300,33 @@ Scene::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
- if(index.row() < 0 || index.row() >= entries.size())
+ if(index.row() < 0 || index.row() >= m_entries.size())
return QVariant();
if(role == ::Qt::ToolTipRole)
{
- return entries[index.row()]->toolTip();
+ return m_entries[index.row()]->toolTip();
}
switch(index.column())
{
case ColorColumn:
if(role == ::Qt::DisplayRole || role == ::Qt::EditRole)
- return entries.value(index.row())->color();
+ return m_entries.value(index.row())->color();
else if(role == ::Qt::DecorationRole)
- return entries.value(index.row())->color();
+ return m_entries.value(index.row())->color();
break;
case NameColumn:
if(role == ::Qt::DisplayRole || role == ::Qt::EditRole)
- return entries.value(index.row())->name();
+ return m_entries.value(index.row())->name();
if(role == ::Qt::FontRole)
- return entries.value(index.row())->font();
+ return m_entries.value(index.row())->font();
break;
case RenderingModeColumn:
if(role == ::Qt::DisplayRole) {
- return entries.value(index.row())->renderingModeName();
+ return m_entries.value(index.row())->renderingModeName();
}
else if(role == ::Qt::EditRole) {
- return static_cast(entries.value(index.row())->renderingMode());
+ return static_cast(m_entries.value(index.row())->renderingMode());
}
else if(role == ::Qt::TextAlignmentRole) {
return ::Qt::AlignCenter;
@@ -285,7 +345,7 @@ Scene::data(const QModelIndex &index, int role) const
break;
case VisibleColumn:
if(role == ::Qt::DisplayRole || role == ::Qt::EditRole)
- return entries.value(index.row())->visible();
+ return m_entries.value(index.row())->visible();
break;
default:
return QVariant();
@@ -350,10 +410,10 @@ Scene::setData(const QModelIndex &index,
if( role != ::Qt::EditRole || !index.isValid() )
return false;
- if(index.row() < 0 || index.row() >= entries.size())
+ if(index.row() < 0 || index.row() >= m_entries.size())
return false;
- Scene_item* item = entries[index.row()];
+ Scene_item* item = m_entries[index.row()];
if(!item) return false;
switch(index.column())
{
@@ -397,6 +457,10 @@ Scene::Item_id Scene::mainSelectionIndex() const {
return selected_item;
}
+QList Scene::selectionIndices() const {
+ return selected_items_list;
+}
+
int Scene::selectionAindex() const {
return item_A;
}
@@ -411,12 +475,25 @@ QItemSelection Scene::createSelection(int i)
QAbstractItemModel::createIndex(i, LastColumn));
}
+QItemSelection Scene::createSelectionAll()
+{
+ return QItemSelection(QAbstractItemModel::createIndex(0, 0),
+ QAbstractItemModel::createIndex(m_entries.size() - 1 , LastColumn));
+}
+
+void Scene::itemChanged()
+{
+ Scene_item* item = qobject_cast(sender());
+ if(item)
+ itemChanged(item);
+}
+
void Scene::itemChanged(Item_id i)
{
- if(i < 0 || i >= entries.size())
+ if(i < 0 || i >= m_entries.size())
return;
- entries[i]->changed();
+ m_entries[i]->changed();
emit dataChanged(QAbstractItemModel::createIndex(i, 0),
QAbstractItemModel::createIndex(i, LastColumn));
}
@@ -425,7 +502,7 @@ void Scene::itemChanged(Scene_item* item)
{
item->changed();
emit dataChanged(QAbstractItemModel::createIndex(0, 0),
- QAbstractItemModel::createIndex(entries.size() - 1, LastColumn));
+ QAbstractItemModel::createIndex(m_entries.size() - 1, LastColumn));
}
bool SceneDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
@@ -451,13 +528,16 @@ bool SceneDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
break;
case Scene::ColorColumn:
if (event->type() == QEvent::MouseButtonPress) {
- QColor color =
- QColorDialog::getColor(model->data(index).value(),
- 0/*,
- tr("Select color"),
- QColorDialog::ShowAlphaChannel*/);
- if (color.isValid()) {
- model->setData(index, color );
+ QMouseEvent *mouseEvent = static_cast(event);
+ if(mouseEvent->button() == ::Qt::LeftButton) {
+ QColor color =
+ QColorDialog::getColor(model->data(index).value(),
+ 0/*,
+ tr("Select color"),
+ QColorDialog::ShowAlphaChannel*/);
+ if (color.isValid()) {
+ model->setData(index, color );
+ }
}
}
else if(event->type() == QEvent::MouseButtonDblClick) {
@@ -467,10 +547,13 @@ bool SceneDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
break;
case Scene::RenderingModeColumn:
if (event->type() == QEvent::MouseButtonPress) {
- // Switch rendering mode
- /*RenderingMode*/int rendering_mode = model->data(index, ::Qt::EditRole).toInt();
- rendering_mode = (rendering_mode+1) % NumberOfRenderingMode;
- model->setData(index, rendering_mode);
+ QMouseEvent *mouseEvent = static_cast(event);
+ if(mouseEvent->button() == ::Qt::LeftButton) {
+ // Switch rendering mode
+ /*RenderingMode*/int rendering_mode = model->data(index, ::Qt::EditRole).toInt();
+ rendering_mode = (rendering_mode+1) % NumberOfRenderingMode;
+ model->setData(index, rendering_mode);
+ }
}
else if(event->type() == QEvent::MouseButtonDblClick) {
return true; // block double-click
@@ -538,13 +621,29 @@ void SceneDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
void Scene::setItemVisible(int index, bool b)
{
- if( index < 0 || index >= entries.size() )
+ if( index < 0 || index >= m_entries.size() )
return;
- entries[index]->setVisible(b);
+ m_entries[index]->setVisible(b);
emit dataChanged(QAbstractItemModel::createIndex(index, VisibleColumn),
QAbstractItemModel::createIndex(index, VisibleColumn));
}
+void Scene::setSelectionRay(double orig_x,
+ double orig_y,
+ double orig_z,
+ double dir_x,
+ double dir_y,
+ double dir_z)
+{
+ Scene_item* item = this->item(selected_item);
+ if(item) item->select(orig_x,
+ orig_y,
+ orig_z,
+ dir_x,
+ dir_y,
+ dir_z);
+}
+
void Scene::setItemA(int i)
{
item_A = i;
@@ -553,7 +652,7 @@ void Scene::setItemA(int i)
item_B = -1;
}
emit dataChanged(QAbstractItemModel::createIndex(0, ABColumn),
- QAbstractItemModel::createIndex(entries.size()-1, ABColumn));
+ QAbstractItemModel::createIndex(m_entries.size()-1, ABColumn));
}
void Scene::setItemB(int i)
@@ -565,17 +664,17 @@ void Scene::setItemB(int i)
}
emit updated();
emit dataChanged(QAbstractItemModel::createIndex(0, ABColumn),
- QAbstractItemModel::createIndex(entries.size()-1, ABColumn));
+ QAbstractItemModel::createIndex(m_entries.size()-1, ABColumn));
}
Scene::Bbox Scene::bbox() const
{
- if(entries.empty())
+ if(m_entries.empty())
return Bbox();
bool bbox_initialized = false;
Bbox bbox;
- Q_FOREACH(Scene_item* item, entries)
+ Q_FOREACH(Scene_item* item, m_entries)
{
if(item->isFinite() && !item->isEmpty()) {
if(bbox_initialized) {
@@ -589,3 +688,45 @@ Scene::Bbox Scene::bbox() const
}
return bbox;
}
+
+#include "Scene_find_items.h"
+
+namespace scene { namespace details {
+
+Q_DECL_EXPORT
+Scene_item*
+findItem(const Scene_interface* scene_interface,
+ const QMetaObject& metaobj,
+ QString name, Scene_item_name_fn_ptr fn) {
+ const Scene* scene = dynamic_cast(scene_interface);
+ if(!scene) return 0;
+ Q_FOREACH(Scene_item* item, scene->entries()) {
+ Scene_item* ptr = qobject_cast(metaobj.cast(item));
+ if(ptr && ((ptr->*fn)() == name)) return ptr;
+ }
+ return 0;
+}
+
+Q_DECL_EXPORT
+QList
+findItems(const Scene_interface* scene_interface,
+ const QMetaObject&,
+ QString name, Scene_item_name_fn_ptr fn)
+{
+ const Scene* scene = dynamic_cast(scene_interface);
+ QList list;
+ if(!scene) return list;
+
+ Q_FOREACH(Scene_item* item, scene->entries()) {
+ Scene_item* ptr = qobject_cast(item);
+ if(ptr && ((ptr->*fn)() == name)) {
+ list << ptr;
+ }
+ }
+ return list;
+}
+
+} // end namespace details
+} // end namespace scene
+
+#include "Scene.moc"
diff --git a/Polyhedron/demo/Polyhedron/Scene.h b/Polyhedron/demo/Polyhedron/Scene.h
index 3c08c03ccb5..a00a012eea1 100644
--- a/Polyhedron/demo/Polyhedron/Scene.h
+++ b/Polyhedron/demo/Polyhedron/Scene.h
@@ -1,6 +1,7 @@
#ifndef SCENE_H
#define SCENE_H
#include "config.h"
+#include "Scene_config.h"
#include "Scene_interface.h"
#include "Scene_draw_interface.h"
@@ -21,10 +22,11 @@
class QEvent;
class QMouseEvent;
-class Scene :
+class SCENE_EXPORT Scene :
public QAbstractListModel, public Scene_interface, public Scene_draw_interface
{
Q_OBJECT
+ Q_PROPERTY(int numberOfEntries READ numberOfEntries)
friend class SceneDelegate;
@@ -40,19 +42,24 @@ public:
Scene(QObject* parent);
~Scene();
- Item_id addItem(Scene_item* item);
+ int addItem(Scene_item* item);
+ Scene_item* replaceItem(int index, Scene_item* item);
- int erase(int); // Returns the index of the polyhedra just before the
- // one that is erased, or just after. Returns -1 if
- // the list is empty.
+ Q_INVOKABLE int erase(int);
+ int erase(QList);
+ // Returns the index of the polyhedra just before the
+ // one that is erased, or just after. Returns -1 if
+ // the list is empty.
// Duplicate a scene item. Return the ID of the new item (-1 on error).
- Item_id duplicate(Item_id index);
+ int duplicate(int index);
// Accessors (getters)
- size_t numberOfEntries() const;
- Scene_item* item(Item_id) const ;
- Item_id mainSelectionIndex() const;
+ int numberOfEntries() const;
+ const QList& entries() const { return m_entries; }
+ Q_INVOKABLE Scene_item* item(int) const ;
+ int mainSelectionIndex() const;
+ QList selectionIndices() const;
int selectionAindex() const;
int selectionBindex() const;
@@ -83,38 +90,51 @@ public:
// auxiliary public function for QMainWindow
QItemSelection createSelection(int i);
+ QItemSelection createSelectionAll();
public slots:
// Notify the scene that an item was modified
- void itemChanged(Item_id i);
+ void itemChanged(); // slots called by items themself
+ void itemChanged(int i);
void itemChanged(Scene_item*);
- void setSelectedItem(Item_id i )
+ void setSelectedItem(int i )
{
selected_item = i;
};
+ void setSelectedItemsList(QList l )
+ {
+ selected_items_list = l;
+ };
+
// Accessors (setters)
void setItemVisible(int, bool b);
void setItemA(int i);
void setItemB(int i);
signals:
+ void newItem(int);
void updated_bbox();
void updated();
void itemAboutToBeDestroyed(Scene_item*);
+ void selectionRay(double, double, double, double, double, double);
+
+private slots:
+ void setSelectionRay(double, double, double, double, double, double);
private:
void draw_aux(bool with_names);
typedef QList Entries;
- Entries entries;
+ Entries m_entries;
int selected_item;
+ QList selected_items_list;
int item_A;
int item_B;
}; // end class Scene
-class SceneDelegate : public QItemDelegate
+class SCENE_EXPORT SceneDelegate : public QItemDelegate
{
public:
SceneDelegate(QObject * parent = 0)
diff --git a/Polyhedron/demo/Polyhedron/Scene_config.h b/Polyhedron/demo/Polyhedron/Scene_config.h
new file mode 100644
index 00000000000..6c532250add
--- /dev/null
+++ b/Polyhedron/demo/Polyhedron/Scene_config.h
@@ -0,0 +1,16 @@
+#ifndef SCENE_CONFIG_H
+#define SCENE_CONFIG_H
+
+#include
+
+#ifdef demo_framework_EXPORTS
+# define scene_EXPORTS
+#endif
+
+#ifdef scene_EXPORTS
+# define SCENE_EXPORT Q_DECL_EXPORT
+#else
+# define SCENE_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // SCENE_CONFIG_H
diff --git a/Polyhedron/demo/Polyhedron/Scene_find_items.h b/Polyhedron/demo/Polyhedron/Scene_find_items.h
new file mode 100644
index 00000000000..00372aca9fb
--- /dev/null
+++ b/Polyhedron/demo/Polyhedron/Scene_find_items.h
@@ -0,0 +1,121 @@
+#ifndef SCENE_FIND_ITEMS
+#define SCENE_FIND_ITEMS
+
+#include
+#include
+#include "Scene_item.h" // required, to have &Scene_item::name
+#include "Scene_config.h"
+
+class Scene_interface;
+
+namespace scene {
+namespace details {
+
+typedef QString (Scene_item ::*Scene_item_name_fn_ptr)() const;
+
+// Declaration only (defined in Scene.cpp)
+SCENE_EXPORT
+Scene_item*
+findItem(const Scene_interface* scene_interface,
+ const QMetaObject& metaobj,
+ QString name, Scene_item_name_fn_ptr fn);
+
+// Declaration only (defined in Scene.cpp)
+SCENE_EXPORT
+QList
+findItems(const Scene_interface* scene_interface,
+ const QMetaObject& metaobj,
+ QString name, Scene_item_name_fn_ptr fn); // fwd declaration
+
+template
+T findItem(const Scene_interface* scene, QString name,
+ Scene_item_name_fn_ptr fn)
+{
+ return
+ static_cast(findItem(scene,
+ reinterpret_cast(0)->staticMetaObject,
+ name, fn));
+}
+
+template
+QList findItems(const Scene_interface* scene, QString name,
+ Scene_item_name_fn_ptr fn)
+{
+ QList void_list =
+ findItems(scene, reinterpret_cast(0)->staticMetaObject,
+ name, fn);
+ QList list;
+ Q_FOREACH(Scene_item* ptr, void_list) {
+ list << qobject_cast(ptr);
+ }
+ return list;
+}
+
+} // end namespace details
+
+// Searches
+
+/** Search the first item that can be cast to T (T must be a pointer
+ type), and called "name". If "name" is omitted, all names are
+ accepted.
+*/
+template
+T findItem(const Scene_interface* scene,
+ QString item_name = QString())
+{ return details::findItem(scene, item_name, &Scene_item::name); }
+
+/** Returns all items that can be cast to T (T must be a pointer
+ type), and called "name". If "name" is omitted, all names are
+ accepted.
+*/
+template
+QList findItems(const Scene_interface* scene,
+ QString item_name = QString())
+{ return details::findItems(scene, item_name, &Scene_item::name); }
+
+/** Search the first item that can be cast to T (T must be a pointer
+ type), and that has objectName() equal to "name". If "name" is
+ omitted, all names are accepted.
+*/
+template
+T findItemByObjectName(const Scene_interface* scene,
+ QString obj_name = QString())
+{ return details::findItem(scene, obj_name, &QObject::objectName); }
+
+/** Returns all items that can be cast to T (T must be a pointer type),
+ and have objectName() equal to "name". If "name" is omitted, all
+ names are accepted.
+*/
+template
+QList findItemsByObjectName(const Scene_interface* scene,
+ QString obj_name = QString())
+{ return details::findItems(scene, obj_name, &QObject::objectName); }
+
+
+// template
+// T scene_findItem(const Scene* scene, QString name, Scene_item_name_fn_ptr fn) {
+// return
+// static_cast(scene_findItem(scene, name, fn,
+// reinterpret_cast(0)->staticMetaObject()));
+// }
+
+// template
+// QList
+// scene_findItems(const Scene* scene, QString name, Scene_item_name_fn_ptr fn) {
+// QList void_list =
+// scene_findItems(scene, name, fn,
+// reinterpret_cast(0)->staticMetaObject());
+// QList list;
+// Q_FOREACH(void* ptr, void_list) {
+// list << static_cast(ptr);
+// }
+// return list;
+// }
+
+// } // end scene namespace
+
+} // end namespace scene
+
+
+
+#endif
diff --git a/Polyhedron/demo/Polyhedron/Scene_interface.h b/Polyhedron/demo/Polyhedron/Scene_interface.h
index 6c3b85c26d2..52e8be1bb50 100644
--- a/Polyhedron/demo/Polyhedron/Scene_interface.h
+++ b/Polyhedron/demo/Polyhedron/Scene_interface.h
@@ -3,6 +3,7 @@
#include
#include
+#include
#include
class Scene_item;
@@ -50,6 +51,7 @@ public:
virtual ~Scene_interface() {};
virtual Item_id addItem(Scene_item* item) = 0;
+ virtual Scene_item* replaceItem(Item_id, Scene_item*) = 0;
virtual Item_id erase(Item_id) = 0;
// Returns the index of the item just before the one that is erased,
@@ -61,9 +63,10 @@ public:
// clonable), returns -1.
// Accessors (getters)
- virtual size_t numberOfEntries() const = 0;
+ virtual int numberOfEntries() const = 0;
virtual Scene_item* item(Item_id) const = 0;
virtual Item_id mainSelectionIndex() const = 0;
+ virtual QList selectionIndices() const = 0;
virtual Item_id selectionAindex() const = 0;
virtual Item_id selectionBindex() const = 0;
@@ -75,6 +78,9 @@ public:
// Notify the scene that an item was modified
virtual void itemChanged(Item_id i) = 0;
virtual void itemChanged(Scene_item*) = 0;
+
+ // Select an item
+ virtual void setSelectedItem(Item_id) = 0;
}; // end interface Scene_interface
diff --git a/Polyhedron/demo/Polyhedron/Scene_item.cpp b/Polyhedron/demo/Polyhedron/Scene_item.cpp
index 8e8e7b2a9ad..7a4aedde781 100644
--- a/Polyhedron/demo/Polyhedron/Scene_item.cpp
+++ b/Polyhedron/demo/Polyhedron/Scene_item.cpp
@@ -1,34 +1,104 @@
#include "Scene_item.h"
+#include "Scene_interface.h"
+#include
const QColor Scene_item::defaultColor = QColor(100, 100, 255);
-Scene_item::~Scene_item() {}
+Scene_item::~Scene_item() {
+ delete defaultContextMenu;
+}
void Scene_item::itemAboutToBeDestroyed(Scene_item* item) {
if(this == item)
emit aboutToBeDestroyed();
}
+
+QString modeName(RenderingMode mode) {
+ switch(mode)
+ {
+ case Points:
+ return QObject::tr("points");
+ case Wireframe:
+ return QObject::tr("wire");
+ case Flat:
+ return QObject::tr("flat");
+ case FlatPlusEdges:
+ return QObject::tr("flat+edges");
+ case Gouraud:
+ return QObject::tr("Gouraud");
+ default:
+ Q_ASSERT(false);
+ return QObject::tr("unknown");
+ }
+}
+
+const char* slotName(RenderingMode mode) {
+ switch(mode)
+ {
+ case Points:
+ return SLOT(setPointsMode());
+ case Wireframe:
+ return SLOT(setWireframeMode());
+ case Flat:
+ return SLOT(setFlatMode());
+ case FlatPlusEdges:
+ return SLOT(setFlatPlusEdgesMode());
+ case Gouraud:
+ return SLOT(setGouraudMode());
+ default:
+ Q_ASSERT(false);
+ return "";
+ }
+}
+
// Rendering mode as a human readable string
QString Scene_item::renderingModeName() const
{
- switch(renderingMode())
- {
- case Points:
- return tr("points");
- case Wireframe:
- return tr("wire");
- case Flat:
- return tr("flat");
- case FlatPlusEdges:
- return tr("flat+edges");
- case Gouraud:
- return tr("Gouraud");
- default:
- Q_ASSERT(false);
- return tr("unknown");
- }
+ return modeName(renderingMode());
}
+QMenu* Scene_item::contextMenu()
+{
+ if(defaultContextMenu) {
+ defaultContextMenu->setTitle(name());
+ return defaultContextMenu;
+ }
+
+ defaultContextMenu = new QMenu(name());
+ // defaultContextMenu->addAction(name());
+ // defaultContextMenu->addSeparator();
+ // QMenu* modeMenu = new QMenu(QObject::tr("Rendering mode"),
+ // defaultContextMenu);
+ for(unsigned int mode = 0; mode < NumberOfRenderingMode;
+ ++mode)
+ {
+ if(!supportsRenderingMode(RenderingMode(mode))) continue;
+ QString mName = modeName(RenderingMode(mode));
+ QAction* action =
+ defaultContextMenu->addAction(tr("Set %1 mode")
+ .arg(mName),
+ this,
+ slotName(RenderingMode(mode)));
+ QObject::connect(action, SIGNAL(triggered()),
+ this, SIGNAL(itemChanged()));
+ }
+ // defaultContextMenu->addAction(modeMenu->menuAction());
+ return defaultContextMenu;
+}
+
+void Scene_item::changed() {
+ // emit itemChanged();
+}
+
+void Scene_item::select(double /*orig_x*/,
+ double /*orig_y*/,
+ double /*orig_z*/,
+ double /*dir_x*/,
+ double /*dir_y*/,
+ double /*dir_z*/)
+{
+}
+
#include "Scene_item.moc"
diff --git a/Polyhedron/demo/Polyhedron/Scene_item.h b/Polyhedron/demo/Polyhedron/Scene_item.h
index 63c9ded36d9..0463b4e3978 100644
--- a/Polyhedron/demo/Polyhedron/Scene_item.h
+++ b/Polyhedron/demo/Polyhedron/Scene_item.h
@@ -4,12 +4,15 @@
#include "Scene_item_config.h"
#include "Scene_interface.h"
#include
+#include
#include
namespace qglviewer {
class ManipulatedFrame;
}
+class QMenu;
+
// This class represents an object in the OpenGL scene
class SCENE_ITEM_EXPORT Scene_item : public QObject {
Q_OBJECT
@@ -28,7 +31,8 @@ public:
: name_("unamed"),
color_(defaultColor),
visible_(true),
- rendering_mode(FlatPlusEdges)
+ rendering_mode(FlatPlusEdges),
+ defaultContextMenu(0)
{};
virtual ~Scene_item();
virtual Scene_item* clone() const = 0;
@@ -44,6 +48,7 @@ public:
// Functions for displaying meta-data of the item
virtual QString toolTip() const = 0;
+ virtual QPixmap graphicalToolTip() const { return QPixmap(); }
virtual QFont font() const { return QFont(); }
// Functions that help the Scene to compute its bbox
@@ -60,25 +65,63 @@ public:
virtual QString name() const { return name_; }
virtual bool visible() const { return visible_; }
virtual RenderingMode renderingMode() const { return rendering_mode; }
- virtual QString renderingModeName() const; // Rendering mode as a human readable string
+ virtual QString renderingModeName() const; // Rendering mode as a human
+ // readable string
+
+ // Context menu
+ virtual QMenu* contextMenu();
public slots:
// Call that once you have finished changing something in the item
// (either the properties or internal data)
- virtual void changed() {}
+ virtual void changed();
// Setters for the four basic properties
virtual void setColor(QColor c) { color_ = c; }
+ void setRbgColor(int r, int g, int b) { setColor(QColor(r, g, b)); }
virtual void setName(QString n) { name_ = n; }
virtual void setVisible(bool b) { visible_ = b; }
virtual void setRenderingMode(RenderingMode m) {
if (supportsRenderingMode(m))
rendering_mode = m;
}
+ void setPointsMode() {
+ setRenderingMode(Points);
+ }
+
+ void setWireframeMode() {
+ setRenderingMode(Wireframe);
+ }
+ void setWireframe() {
+ setRenderingMode(Wireframe);
+ }
+
+ void setFlat() {
+ setRenderingMode(Flat);
+ }
+ void setFlatMode() {
+ setRenderingMode(Flat);
+ }
+
+ void setFlatPlusEdgesMode() {
+ setRenderingMode(FlatPlusEdges);
+ }
+
+ void setGouraudMode() {
+ setRenderingMode(Gouraud);
+ }
virtual void itemAboutToBeDestroyed(Scene_item*);
+ virtual void select(double orig_x,
+ double orig_y,
+ double orig_z,
+ double dir_x,
+ double dir_y,
+ double dir_z);
+
signals:
+ void itemChanged();
void aboutToBeDestroyed();
protected:
@@ -87,7 +130,12 @@ protected:
QColor color_;
bool visible_;
RenderingMode rendering_mode;
+ QMenu* defaultContextMenu;
}; // end class Scene_item
+
+#include
+Q_DECLARE_METATYPE(Scene_item*)
+
#endif // SCENE_ITEM_H
diff --git a/Polyhedron/demo/Polyhedron/Scene_item_config.h b/Polyhedron/demo/Polyhedron/Scene_item_config.h
index ac71781315e..08c864bdce5 100644
--- a/Polyhedron/demo/Polyhedron/Scene_item_config.h
+++ b/Polyhedron/demo/Polyhedron/Scene_item_config.h
@@ -3,6 +3,10 @@
#include
+#ifdef demo_framework_EXPORTS
+# define scene_item_EXPORTS
+#endif
+
#ifdef scene_item_EXPORTS
# define SCENE_ITEM_EXPORT Q_DECL_EXPORT
#else
diff --git a/Polyhedron/demo/Polyhedron/Scene_item_with_display_list.cpp b/Polyhedron/demo/Polyhedron/Scene_item_with_display_list.cpp
index 07be9511902..f77c1574962 100644
--- a/Polyhedron/demo/Polyhedron/Scene_item_with_display_list.cpp
+++ b/Polyhedron/demo/Polyhedron/Scene_item_with_display_list.cpp
@@ -69,4 +69,5 @@ void Scene_item_with_display_list::changed()
for(int i = 0; i < NB_OF_DISPLAY_LISTS; ++i) {
display_list_built[i] = false;
}
+ Scene_item::changed();
}
diff --git a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp
index 83fc94f3d77..16473326d78 100644
--- a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp
+++ b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.cpp
@@ -5,6 +5,7 @@
#include
// #include
#include
+#include
#include
#include
@@ -49,7 +50,7 @@ Scene_nef_polyhedron_item::clone() const {
}
bool
-Scene_nef_polyhedron_item::load(std::istream& in)
+Scene_nef_polyhedron_item::load_from_off(std::istream& in)
{
// const std::size_t discarded = CGAL::OFF_to_nef_3(in, *nef_poly);
// return discarded != 0;
@@ -71,6 +72,20 @@ Scene_nef_polyhedron_item::font() const {
return font;
}
+bool
+Scene_nef_polyhedron_item::load(std::istream& in)
+{
+ in >> *nef_poly;
+ return in;
+}
+
+bool
+Scene_nef_polyhedron_item::save(std::ostream& in) const
+{
+ in << *nef_poly;
+ return in;
+}
+
QString
Scene_nef_polyhedron_item::toolTip() const
{
diff --git a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h
index 974edfcf202..4e837aa9f8b 100644
--- a/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h
+++ b/Polyhedron/demo/Polyhedron/Scene_nef_polyhedron_item.h
@@ -20,7 +20,9 @@ public:
~Scene_nef_polyhedron_item();
Scene_nef_polyhedron_item* clone() const;
+ bool load_from_off(std::istream& in);
bool load(std::istream& in);
+ bool save(std::ostream& in) const;
QFont font() const;
QString toolTip() const;
diff --git a/Polyhedron/demo/Polyhedron/Scene_plane_item.h b/Polyhedron/demo/Polyhedron/Scene_plane_item.h
index 3f94f9db5ac..7d80c1c7ad3 100644
--- a/Polyhedron/demo/Polyhedron/Scene_plane_item.h
+++ b/Polyhedron/demo/Polyhedron/Scene_plane_item.h
@@ -12,8 +12,8 @@
#include
#include
-typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
-typedef Kernel::Plane_3 Plane_3;
+typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel_epic;
+typedef Kernel_epic::Plane_3 Plane_3;
class SCENE_BASIC_OBJECTS_EXPORT Scene_plane_item
: public Scene_item
diff --git a/Polyhedron/demo/Polyhedron/Scene_polygon_soup.cpp b/Polyhedron/demo/Polyhedron/Scene_polygon_soup.cpp
index 6f18f295557..f33e6dece1e 100644
--- a/Polyhedron/demo/Polyhedron/Scene_polygon_soup.cpp
+++ b/Polyhedron/demo/Polyhedron/Scene_polygon_soup.cpp
@@ -1,5 +1,8 @@
#include "Scene_polygon_soup.h"
+#include "Scene_polyhedron_item.h"
#include
+#include "Polyhedron_type.h"
+#include
#include
#include
@@ -12,11 +15,13 @@
#include
#include
+#include
-typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point_3;
-struct Polygon_soup {
+struct Polygon_soup :
+ public CGAL::Modifier_base
+{
typedef std::vector Points;
typedef std::vector Polygon_3;
typedef std::map, std::set > Edges_map;
@@ -86,8 +91,51 @@ struct Polygon_soup {
void inverse_orientation(const std::size_t index) {
std::reverse(polygons[index].begin(), polygons[index].end());
}
+
+ void operator()(Polyhedron::HalfedgeDS& out_hds);
};
+struct Polyhedron_to_polygon_soup_writer {
+ Polygon_soup* soup;
+ Polygon_soup::Polygon_3 polygon;
+
+ Polyhedron_to_polygon_soup_writer(Polygon_soup* soup) : soup(soup), polygon() {
+ }
+
+ void write_header( std::ostream&,
+ std::size_t vertices,
+ std::size_t halfedges,
+ std::size_t facets,
+ bool normals = false ) {
+ soup->clear();
+ }
+
+ void write_footer() {
+ }
+
+ void write_vertex( const double& x, const double& y, const double& z) {
+ soup->points.push_back(Point_3(x, y, z));
+ }
+
+ void write_normal( const double& x, const double& y, const double& z) {
+ }
+
+ void write_facet_header() {
+ }
+
+ void write_facet_begin( std::size_t no) {
+ polygon.clear();
+ polygon.reserve(no);
+ }
+ void write_facet_vertex_index( std::size_t index) {
+ polygon.push_back(index);
+ }
+ void write_facet_end() {
+ soup->polygons.push_back(polygon);
+ polygon.clear();
+ }
+}; // end struct Polyhedron_to_soup_writer
+
Scene_polygon_soup::Scene_polygon_soup()
: Scene_item_with_display_list(),
soup(0),
@@ -111,13 +159,18 @@ Scene_polygon_soup::clone() const {
bool
Scene_polygon_soup::load(std::istream& in)
{
+#if CGAL_VERSION_NR >= 1030700091
+ typedef std::size_t indices_t;
+#else
+ typedef CGAL::Integer32 indices_t;
+#endif
if(!soup)
soup = new Polygon_soup;
CGAL::File_scanner_OFF scanner(in);
soup->clear();
soup->points.resize(scanner.size_of_vertices());
soup->polygons.resize(scanner.size_of_facets());
- for (std::size_t i = 0; i < scanner.size_of_vertices(); ++i) {
+ for (indices_t i = 0; i < scanner.size_of_vertices(); ++i) {
double x, y, z, w;
scanner.scan_vertex( x, y, z, w);
soup->points[i] = Point_3(x, y, z, w);
@@ -126,12 +179,13 @@ Scene_polygon_soup::load(std::istream& in)
if(!in)
return false;
- for (std::size_t i = 0; i < scanner.size_of_facets(); ++i) {
- std::size_t no;
+ for (indices_t i = 0; i < scanner.size_of_facets(); ++i) {
+ indices_t no;
+
scanner.scan_facet( no, i);
soup->polygons[i].resize(no);
- for(std::size_t j = 0; j < no; ++j) {
- std::size_t id;
+ for(indices_t j = 0; j < no; ++j) {
+ indices_t id;
scanner.scan_facet_vertex_index(id, i);
if(id < scanner.size_of_vertices())
{
@@ -146,6 +200,24 @@ Scene_polygon_soup::load(std::istream& in)
return in;
}
+
+#include
+#include
+
+void Scene_polygon_soup::load(Scene_polyhedron_item* poly_item) {
+ if(!poly_item) return;
+ if(!poly_item->polyhedron()) return;
+
+ if(!soup)
+ soup = new Polygon_soup;
+
+ Polyhedron_to_polygon_soup_writer writer(soup);
+ CGAL::generic_print_polyhedron(std::cerr,
+ *poly_item->polyhedron(),
+ writer);
+ emit changed();
+}
+
void
Scene_polygon_soup::setDisplayNonManifoldEdges(const bool b)
{
@@ -321,6 +393,44 @@ Scene_polygon_soup::save(std::ostream& out) const
return out;
}
+void
+Polygon_soup::operator()(Polyhedron::HalfedgeDS& out_hds)
+{
+ typedef Polyhedron::HalfedgeDS Output_HDS;
+
+ CGAL::Polyhedron_incremental_builder_3 builder(out_hds);
+
+ typedef Polygon_soup::size_type size_type;
+ builder.begin_surface(points.size(),
+ polygons.size(),
+ edges.size() * 2);
+ for(size_type i = 0, end = points.size();
+ i < end; ++i)
+ {
+ builder.add_vertex(points[i]);
+ }
+ for(size_type i = 0, end = polygons.size();
+ i < end; ++i)
+ {
+ const Polygon_soup::Polygon_3& polygon = polygons[i];
+ const size_type size = polygon.size();
+ builder.begin_facet();
+ for(size_type j = 0; j < size; ++j) {
+ builder.add_vertex_to_facet(polygon[j]);
+ }
+ builder.end_facet();
+ }
+ builder.end_surface();
+}
+
+bool
+Scene_polygon_soup::exportAsPolyhedron(Polyhedron* out_polyhedron)
+{
+ orient();
+ out_polyhedron->delegate(*soup);
+ return out_polyhedron->size_of_vertices() > 0;
+}
+
QString
Scene_polygon_soup::toolTip() const
{
@@ -363,8 +473,11 @@ Scene_polygon_soup::direct_draw() const {
}
if(soup->display_non_manifold_edges) {
double current_color[4];
+ GLboolean lightning;
::glGetDoublev(GL_CURRENT_COLOR, current_color);
::glColor3d(1., 0., 0.); // red
+ ::glGetBooleanv(GL_LIGHTING, &lightning);
+ ::glDisable(GL_LIGHTING);
for(Polygon_soup::size_type
i = 0,
@@ -379,10 +492,24 @@ Scene_polygon_soup::direct_draw() const {
::glVertex3d(b.x(), b.y(), b.z());
::glEnd();
}
+ if(lightning) glEnable(GL_LIGHTING);
::glColor4dv(current_color);
}
}
+void
+Scene_polygon_soup::draw_points() const {
+ if(soup == 0) return;
+ ::glBegin(GL_POINTS);
+ for(Polygon_soup::Points::const_iterator pit = soup->points.begin(),
+ end = soup->points.end();
+ pit != end; ++pit)
+ {
+ ::glVertex3d(pit->x(), pit->y(), pit->z());
+ }
+ ::glEnd();
+}
+
bool
Scene_polygon_soup::isEmpty() const {
return (soup == 0 || soup->points.empty());
@@ -401,4 +528,24 @@ Scene_polygon_soup::bbox() const {
bbox.xmax(),bbox.ymax(),bbox.zmax());
}
+void
+Scene_polygon_soup::new_vertex(const double& x,
+ const double& y,
+ const double& z)
+{
+ soup->points.push_back(Point_3(x, y, z));
+}
+
+void
+Scene_polygon_soup::new_triangle(const std::size_t i,
+ const std::size_t j,
+ const std::size_t k)
+{
+ Polygon_soup::Polygon_3 new_polygon(3);
+ new_polygon[0] = i;
+ new_polygon[1] = j;
+ new_polygon[2] = k;
+ soup->polygons.push_back(new_polygon);
+}
+
#include "Scene_polygon_soup.moc"
diff --git a/Polyhedron/demo/Polyhedron/Scene_polygon_soup.h b/Polyhedron/demo/Polyhedron/Scene_polygon_soup.h
index 154b09bc71f..016b327cfc5 100644
--- a/Polyhedron/demo/Polyhedron/Scene_polygon_soup.h
+++ b/Polyhedron/demo/Polyhedron/Scene_polygon_soup.h
@@ -5,7 +5,10 @@
#include "Scene_item_with_display_list.h"
#include
+#include "Polyhedron_type_fwd.h"
+
struct Polygon_soup;
+class Scene_polyhedron_item;
class SCENE_POLYGON_SOUP_EXPORT Scene_polygon_soup
: public Scene_item_with_display_list
@@ -17,6 +20,7 @@ public:
Scene_polygon_soup* clone() const;
bool load(std::istream& in);
+ void load(Scene_polyhedron_item*);
bool save(std::ostream& out) const;
QString toolTip() const;
@@ -25,17 +29,24 @@ public:
virtual bool supportsRenderingMode(RenderingMode m) const { return m != Gouraud; } // CHECK THIS!
// OpenGL drawing in a display list
void direct_draw() const;
+ void draw_points() const;
bool isFinite() const { return true; }
bool isEmpty() const;
Bbox bbox() const;
+ void new_vertex(const double&, const double&, const double&);
+ void new_triangle(const std::size_t, const std::size_t, const std::size_t);
+
+public slots:
void shuffle_orientations();
bool orient();
+ bool exportAsPolyhedron(Polyhedron*);
void inside_out();
void setDisplayNonManifoldEdges(const bool);
bool displayNonManifoldEdges() const;
+
private:
Polygon_soup* soup;
bool oriented;
diff --git a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_config.h b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_config.h
index 5a568ac4da0..47898403aaa 100644
--- a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_config.h
+++ b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_config.h
@@ -1,7 +1,7 @@
#ifndef SCENE_POLYGON_SOUP_CONFIG_H
#define SCENE_POLYGON_SOUP_CONFIG_H
-#ifdef polygon_soup_EXPORTS
+#ifdef scene_polygon_soup_item_EXPORTS
# define SCENE_POLYGON_SOUP_EXPORT Q_DECL_EXPORT
#else
# define SCENE_POLYGON_SOUP_EXPORT Q_DECL_IMPORT
diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp
index 795e0ea5ca7..52a051f87bc 100644
--- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp
+++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_item.cpp
@@ -1,39 +1,127 @@
+#include
#include "Scene_polyhedron_item.h"
+#include "Kernel_type.h"
#include "Polyhedron_type.h"
#include
+#include
+#include
+#include
+
+#include