mirror of https://github.com/CGAL/cgal
Merge branch 'master' into BGL-LCC-gdamiand
This commit is contained in:
commit
013f447395
15
.travis.yml
15
.travis.yml
|
|
@ -43,8 +43,15 @@ env:
|
|||
- PACKAGE='TDS_3 Three Triangulation '
|
||||
- PACKAGE='Triangulation_2 Triangulation_3 Union_find '
|
||||
- PACKAGE='Visibility_2 Voronoi_diagram_2 '
|
||||
- PACKAGE='Polyhedron_demo'
|
||||
- PACKAGE='Polyhedron_demo'
|
||||
|
||||
|
||||
compiler:
|
||||
- clang-3.6
|
||||
- gcc
|
||||
install:
|
||||
- if [[ "$CXX" = "clang++" ]]; then export CXX=clang++-3.6 CC=clang-3.6; fi
|
||||
|
||||
before_script:
|
||||
- mkdir -p build
|
||||
- cd build
|
||||
|
|
@ -54,14 +61,12 @@ before_script:
|
|||
script:
|
||||
- cd ./.travis
|
||||
- bash -x -e ./build_package.sh $PACKAGE
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:ppsspp/cmake'
|
||||
packages:
|
||||
packages:
|
||||
- clang-3.6
|
||||
- zsh
|
||||
- cmake
|
||||
- libboost1.55-dev
|
||||
|
|
|
|||
|
|
@ -4,7 +4,12 @@ sudo: required
|
|||
env:
|
||||
matrix:
|
||||
PACKAGES_MATRIX
|
||||
compiler:
|
||||
- clang-3.6
|
||||
- gcc
|
||||
install:
|
||||
- if [[ "$CXX" = "clang++" ]]; then export CXX=clang++-3.6 CC=clang-3.6; fi
|
||||
|
||||
before_script:
|
||||
- mkdir -p build
|
||||
- cd build
|
||||
|
|
@ -14,14 +19,12 @@ before_script:
|
|||
script:
|
||||
- cd ./.travis
|
||||
- bash -x -e ./build_package.sh $PACKAGE
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:ppsspp/cmake'
|
||||
packages:
|
||||
packages:
|
||||
- clang-3.6
|
||||
- zsh
|
||||
- cmake
|
||||
- libboost1.55-dev
|
||||
|
|
|
|||
|
|
@ -8,12 +8,28 @@ INPUT += ${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Euler_operations.h \
|
|||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/split_graph_into_polylines.h \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/copy_face_graph.h \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Graph_with_descriptor_with_graph.h \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Face_filtered_graph.h \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/Dual.h \
|
||||
${CGAL_PACKAGE_INCLUDE_DIR}/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h
|
||||
EXAMPLE_PATH = ${CGAL_Surface_mesh_skeletonization_EXAMPLE_DIR} \
|
||||
${CGAL_Surface_mesh_segmentation_EXAMPLE_DIR} \
|
||||
${CGAL_Polygon_mesh_processing_EXAMPLE_DIR} \
|
||||
${CGAL_BGL_EXAMPLE_DIR}
|
||||
|
||||
ALIASES += "bgllink{1}=<a href=\"http://www.boost.org/libs/graph/doc/\1.html\"><code>\1</code></a>"
|
||||
ALIASES += "cgalNamedParamsBegin=<dl class=\"params\"><dt>Named Parameters</dt><dd> <table class=\"params\">"
|
||||
# macros to be used inside the code
|
||||
ALIASES += "cgalNamedParamsBegin=<dl class=\"params\"><dt>Named Parameters</dt><dd> <table class=\"params\">"
|
||||
ALIASES += "cgalNamedParamsEnd=</table> </dd> </dl>"
|
||||
ALIASES += "cgalParamBegin{1}=<tr><td class=\"paramname\">\1</td><td>"
|
||||
ALIASES += "cgalParamEnd=</td></tr>"
|
||||
|
||||
|
||||
EXTRACT_ALL=NO
|
||||
HIDE_UNDOC_MEMBERS = YES
|
||||
HIDE_UNDOC_CLASSES = YES
|
||||
|
||||
MACRO_EXPANSION = YES
|
||||
EXPAND_ONLY_PREDEF = YES
|
||||
EXPAND_AS_DEFINED = CGAL_BGL_NP_TEMPLATE_PARAMETERS \
|
||||
CGAL_BGL_NP_CLASS
|
||||
|
|
|
|||
|
|
@ -319,6 +319,7 @@ user might encounter.
|
|||
- `CGAL::Graph_with_descriptor_with_graph_property_map`
|
||||
- `CGAL::Linear_cell_complex_bgl_min_items`
|
||||
- `CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper`
|
||||
- `CGAL::Face_filtered_graph`
|
||||
|
||||
## Helper Functions ##
|
||||
- `CGAL::is_border()`
|
||||
|
|
@ -345,7 +346,6 @@ user might encounter.
|
|||
|
||||
- `CGAL::clear()`
|
||||
- `CGAL::copy_face_graph()`
|
||||
- `CGAL::reserve()`
|
||||
|
||||
## Iterators ##
|
||||
- `CGAL::Halfedge_around_source_iterator`
|
||||
|
|
|
|||
|
|
@ -17,4 +17,6 @@
|
|||
\example BGL_surface_mesh/prim.cpp
|
||||
\example BGL_surface_mesh/surface_mesh_dual.cpp
|
||||
\example Surface_mesh_skeletonization/simple_mcfskel_example.cpp
|
||||
\example Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp
|
||||
\example Polygon_mesh_processing/face_filtered_graph_example.cpp
|
||||
*/
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -23,6 +23,7 @@
|
|||
#include <CGAL/assertions.h>
|
||||
#include <CGAL/boost/graph/properties.h>
|
||||
#include <boost/graph/graph_traits.hpp>
|
||||
#include <CGAL/boost/graph/iterator.h>
|
||||
#include <boost/iterator/transform_iterator.hpp>
|
||||
|
||||
|
||||
|
|
@ -325,8 +326,7 @@ edge(typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::ver
|
|||
|
||||
|
||||
template <class Graph>
|
||||
std::pair<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::vertex_iterator,
|
||||
typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::vertex_iterator>
|
||||
CGAL::Iterator_range<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::vertex_iterator>
|
||||
vertices(const Graph_with_descriptor_with_graph<Graph> & w)
|
||||
{
|
||||
typename boost::graph_traits<Graph>::vertex_iterator b,e;
|
||||
|
|
@ -336,8 +336,7 @@ vertices(const Graph_with_descriptor_with_graph<Graph> & w)
|
|||
}
|
||||
|
||||
template <class Graph>
|
||||
std::pair<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::edge_iterator,
|
||||
typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::edge_iterator>
|
||||
CGAL::Iterator_range<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::edge_iterator>
|
||||
edges(const Graph_with_descriptor_with_graph<Graph> & w)
|
||||
{
|
||||
typename boost::graph_traits<Graph>::edge_iterator b,e;
|
||||
|
|
@ -347,8 +346,7 @@ edges(const Graph_with_descriptor_with_graph<Graph> & w)
|
|||
}
|
||||
|
||||
template <class Graph>
|
||||
std::pair<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::out_edge_iterator,
|
||||
typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::out_edge_iterator>
|
||||
CGAL::Iterator_range<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::out_edge_iterator>
|
||||
out_edges(typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::vertex_descriptor v,
|
||||
const Graph_with_descriptor_with_graph<Graph> & w)
|
||||
{
|
||||
|
|
@ -360,8 +358,7 @@ out_edges(typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >
|
|||
}
|
||||
|
||||
template <class Graph>
|
||||
std::pair<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::in_edge_iterator,
|
||||
typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::in_edge_iterator>
|
||||
CGAL::Iterator_range<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::in_edge_iterator>
|
||||
in_edges(typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::vertex_descriptor v,
|
||||
const Graph_with_descriptor_with_graph<Graph> & w)
|
||||
{
|
||||
|
|
@ -630,8 +627,7 @@ prev(typename boost::graph_traits< Graph_with_descriptor_with_graph<Graph> >::ha
|
|||
//
|
||||
|
||||
template <class Graph>
|
||||
std::pair<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::halfedge_iterator,
|
||||
typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::halfedge_iterator>
|
||||
CGAL::Iterator_range<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::halfedge_iterator>
|
||||
halfedges(const Graph_with_descriptor_with_graph<Graph> & w)
|
||||
{
|
||||
typename boost::graph_traits<Graph>::halfedge_iterator b,e;
|
||||
|
|
@ -671,8 +667,7 @@ halfedge(typename boost::graph_traits< Graph_with_descriptor_with_graph<Graph> >
|
|||
|
||||
|
||||
template <class Graph>
|
||||
std::pair<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::face_iterator,
|
||||
typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::face_iterator>
|
||||
CGAL::Iterator_range<typename boost::graph_traits<Graph_with_descriptor_with_graph<Graph> >::face_iterator>
|
||||
faces(const Graph_with_descriptor_with_graph<Graph> & w)
|
||||
{
|
||||
typename boost::graph_traits<Graph>::face_iterator b,e;
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ namespace boost{
|
|||
} //end of namespace boost
|
||||
#endif
|
||||
|
||||
#define CGAL_BGL_NP_TEMPLATE_PARAMETERS T, typename Tag, typename Base
|
||||
#define CGAL_BGL_NP_CLASS CGAL::cgal_bgl_named_params<T,Tag,Base>
|
||||
|
||||
namespace CGAL {
|
||||
namespace internal_np{
|
||||
|
|
@ -162,6 +164,68 @@ using boost::visitor;
|
|||
|
||||
} // namespace parameters
|
||||
|
||||
//helper classes
|
||||
template<typename PolygonMesh, typename PropertyTag>
|
||||
class property_map_selector
|
||||
{
|
||||
public:
|
||||
typedef typename boost::graph_has_property<PolygonMesh, PropertyTag>::type Has_internal_pmap;
|
||||
typedef typename boost::mpl::if_c< Has_internal_pmap::value
|
||||
, typename boost::property_map<PolygonMesh, PropertyTag>::type
|
||||
, typename boost::cgal_no_property::type
|
||||
>::type type;
|
||||
typedef typename boost::mpl::if_c< Has_internal_pmap::value
|
||||
, typename boost::property_map<PolygonMesh, PropertyTag>::const_type
|
||||
, typename boost::cgal_no_property::const_type
|
||||
>::type const_type;
|
||||
|
||||
type get_pmap(const PropertyTag& p, PolygonMesh& pmesh)
|
||||
{
|
||||
return get_impl(p, pmesh, Has_internal_pmap());
|
||||
}
|
||||
|
||||
const_type get_const_pmap(const PropertyTag& p, const PolygonMesh& pmesh)
|
||||
{
|
||||
return get_const_pmap_impl(p, pmesh, Has_internal_pmap());
|
||||
}
|
||||
|
||||
private:
|
||||
type get_impl(const PropertyTag&, PolygonMesh&, CGAL::Tag_false)
|
||||
{
|
||||
return type(); //boost::cgal_no_property::type
|
||||
}
|
||||
type get_impl(const PropertyTag& p, PolygonMesh& pmesh, CGAL::Tag_true)
|
||||
{
|
||||
return get(p, pmesh);
|
||||
}
|
||||
|
||||
const_type get_const_pmap_impl(const PropertyTag&
|
||||
, const PolygonMesh&, CGAL::Tag_false)
|
||||
{
|
||||
return const_type(); //boost::cgal_no_property::type
|
||||
}
|
||||
const_type get_const_pmap_impl(const PropertyTag& p
|
||||
, const PolygonMesh& pmesh, CGAL::Tag_true)
|
||||
{
|
||||
return get(p, pmesh);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename PolygonMesh, typename PropertyTag>
|
||||
typename property_map_selector<PolygonMesh, PropertyTag>::type
|
||||
get_property_map(const PropertyTag& p, PolygonMesh& pmesh)
|
||||
{
|
||||
property_map_selector<PolygonMesh, PropertyTag> pms;
|
||||
return pms.get_pmap(p, pmesh);
|
||||
}
|
||||
|
||||
template<typename PolygonMesh, typename PropertyTag>
|
||||
typename property_map_selector<PolygonMesh, PropertyTag>::const_type
|
||||
get_const_property_map(const PropertyTag& p, const PolygonMesh& pmesh)
|
||||
{
|
||||
property_map_selector<PolygonMesh, PropertyTag> pms;
|
||||
return pms.get_const_pmap(p, pmesh);
|
||||
}
|
||||
} //namespace CGAL
|
||||
|
||||
// partial specializations hate inheritance and we need to repeat
|
||||
|
|
|
|||
|
|
@ -89,6 +89,14 @@ create_single_source_cgal_program( "test_Has_member_id.cpp" )
|
|||
|
||||
create_single_source_cgal_program( "test_cgal_bgl_named_params.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "graph_concept_Face_filtered_graph.cpp" )
|
||||
|
||||
|
||||
create_single_source_cgal_program( "test_Face_filtered_graph.cpp" )
|
||||
if(OpenMesh_FOUND)
|
||||
target_link_libraries( test_Face_filtered_graph ${OPENMESH_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(OpenMesh_FOUND)
|
||||
target_link_libraries( test_clear ${OPENMESH_LIBRARIES})
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,53 @@
|
|||
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/Face_filtered_graph.h>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <boost/graph/graph_concepts.hpp>
|
||||
#include <CGAL/boost/graph/graph_concepts.h>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> K;
|
||||
typedef CGAL::Surface_mesh<K::Point_3> SM;
|
||||
typedef CGAL::Face_filtered_graph<SM, SM::Property_map<boost::graph_traits<SM>::face_descriptor , std::size_t> > Adapter;
|
||||
typedef boost::graph_traits< Adapter > Traits;
|
||||
typedef Traits::edge_descriptor edge_descriptor;
|
||||
typedef Traits::halfedge_descriptor halfedge_descriptor;
|
||||
typedef Traits::vertex_descriptor vertex_descriptor;
|
||||
typedef Traits::face_descriptor face_descriptor;
|
||||
|
||||
void concept_check_adapter()
|
||||
{
|
||||
boost::function_requires< boost::GraphConcept<Adapter> >();
|
||||
boost::function_requires< boost::VertexListGraphConcept<Adapter> >();
|
||||
boost::function_requires< boost::EdgeListGraphConcept<Adapter> >();
|
||||
boost::function_requires< boost::IncidenceGraphConcept<Adapter> >();
|
||||
boost::function_requires< boost::AdjacencyMatrixConcept<Adapter> >();
|
||||
boost::function_requires< boost::BidirectionalGraphConcept<Adapter> >();
|
||||
boost::function_requires< CGAL::HalfedgeGraphConcept<Adapter> >();
|
||||
boost::function_requires< CGAL::HalfedgeListGraphConcept<Adapter> >();
|
||||
boost::function_requires< CGAL::FaceGraphConcept<Adapter> >();
|
||||
boost::function_requires< CGAL::FaceListGraphConcept<Adapter> >();
|
||||
|
||||
boost::function_requires< boost::concepts::ReadablePropertyGraph<
|
||||
Adapter, halfedge_descriptor, CGAL::halfedge_index_t> >();
|
||||
boost::function_requires< boost::concepts::ReadablePropertyGraph<
|
||||
Adapter, edge_descriptor, boost::edge_index_t> >();
|
||||
boost::function_requires< boost::concepts::ReadablePropertyGraph<
|
||||
Adapter, edge_descriptor, boost::edge_weight_t> >();
|
||||
boost::function_requires< boost::concepts::PropertyGraph<
|
||||
Adapter, vertex_descriptor, CGAL::vertex_point_t> >();
|
||||
boost::function_requires< boost::concepts::ReadablePropertyGraph<
|
||||
Adapter, vertex_descriptor, boost::vertex_index_t> >();
|
||||
boost::function_requires< boost::concepts::ReadablePropertyGraph<
|
||||
Adapter, face_descriptor, CGAL::face_index_t> >();
|
||||
|
||||
// null
|
||||
boost::graph_traits<Adapter>::null_vertex();
|
||||
boost::graph_traits<Adapter>::null_face();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
concept_check_adapter();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -0,0 +1,466 @@
|
|||
#include <CGAL/boost/graph/Face_filtered_graph.h>
|
||||
#include <CGAL/Polygon_mesh_processing/connected_components.h>
|
||||
#include <CGAL/boost/graph/copy_face_graph.h>
|
||||
#include "test_Prefix.h"
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <CGAL/use.h>
|
||||
#include <fstream>
|
||||
|
||||
typedef boost::unordered_set<std::size_t> id_map;
|
||||
|
||||
template <typename Graph>
|
||||
void test_halfedge_around_vertex_iterator(const Graph& g)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor g_face_descriptor;
|
||||
typedef CGAL::Face_filtered_graph<Graph> Adapter;
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
boost::unordered_map<g_face_descriptor, std::size_t> map(num_faces(g));
|
||||
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
|
||||
|
||||
Adapter fg(g, 0, boost::make_assoc_property_map(map));
|
||||
typename boost::graph_traits<Adapter >::vertex_iterator vit, vend;
|
||||
for(boost::tie(vit, vend) = vertices(fg); vit != vend; ++vit) {
|
||||
halfedge_around_target_iterator havit, havend;
|
||||
for(boost::tie(havit, havend) = CGAL::halfedges_around_target(halfedge(*vit, fg), fg);
|
||||
havit != havend; ++havit) {
|
||||
assert(target(*havit, fg) == *vit);
|
||||
|
||||
// check if we are really moving clockwise
|
||||
halfedge_around_target_iterator step = boost::next(havit);
|
||||
if(step != havend) {
|
||||
halfedge_descriptor stepd = *step;
|
||||
assert(stepd == opposite(next(*havit, fg), fg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Graph>
|
||||
void test_halfedge_around_face_iterator(const Graph& g)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor g_face_descriptor;
|
||||
typedef CGAL::Face_filtered_graph<Graph> Adapter;
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
std::map<g_face_descriptor, std::size_t> map;
|
||||
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
Adapter fg(g, 0, boost::make_assoc_property_map(map));
|
||||
face_iterator fit, fend;
|
||||
for(boost::tie(fit, fend) = faces(fg); fit != fend; ++fit) {
|
||||
halfedge_around_face_iterator hafit, hafend;
|
||||
boost::tie(hafit, hafend) = CGAL::halfedges_around_face(halfedge(*fit, fg), fg);
|
||||
assert(std::distance(hafit, hafend) != 0);
|
||||
for(boost::tie(hafit, hafend) = CGAL::halfedges_around_face(halfedge(*fit, fg), fg); hafit != hafend; ++hafit) {
|
||||
assert(face(*hafit, fg) == *fit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Graph>
|
||||
void test_edge_iterators(const Graph& g)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor g_face_descriptor;
|
||||
typedef CGAL::Face_filtered_graph<Graph> Adapter;
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
std::map<g_face_descriptor, std::size_t> map;
|
||||
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
Adapter fg(g, 0, boost::make_assoc_property_map(map));
|
||||
|
||||
// do we iterate as many as that?
|
||||
edge_iterator eb, ee;
|
||||
boost::tie(eb, ee) = edges(fg);
|
||||
assert(boost::numeric_cast<edges_size_type>(std::distance(eb, ee)) == num_edges(g));
|
||||
id_map ids;
|
||||
unsigned int count = 0;
|
||||
for(boost::tie(eb, ee) = edges(fg); eb != ee; ++eb) {
|
||||
edge_descriptor e = *eb;
|
||||
std::pair<id_map::iterator, bool> r = ids.insert(get(boost::edge_index, g, e));
|
||||
// unique?
|
||||
assert(r.second);
|
||||
++count;
|
||||
}
|
||||
assert(count == num_edges(fg));
|
||||
}
|
||||
|
||||
template<typename Graph>
|
||||
void test_vertex_iterators(Graph& g)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor g_face_descriptor;
|
||||
typedef CGAL::Face_filtered_graph<Graph> Adapter;
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
std::map<g_face_descriptor, std::size_t> map;
|
||||
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
Adapter fg(g, 0, boost::make_assoc_property_map(map));
|
||||
vertex_iterator vb, ve;
|
||||
std::size_t count = 0;
|
||||
for(boost::tie(vb, ve) = vertices(fg); vb != ve; ++vb){
|
||||
++count;
|
||||
}
|
||||
|
||||
assert(count == num_vertices(fg));
|
||||
|
||||
// check that the iterators reach uniques
|
||||
id_map ids;
|
||||
|
||||
count = 0;
|
||||
for(boost::tie(vb, ve) = vertices(fg); vb != ve; ++vb) {
|
||||
std::pair<id_map::iterator, bool> r = ids.insert(get(boost::vertex_index, g, *vb));
|
||||
assert(r.second);
|
||||
++count;
|
||||
}
|
||||
assert(count == num_vertices(fg));
|
||||
}
|
||||
|
||||
|
||||
template<typename Graph>
|
||||
void test_out_edges(const Graph& g)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor g_face_descriptor;
|
||||
typedef CGAL::Face_filtered_graph<Graph> Adapter;
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
std::map<g_face_descriptor, std::size_t> map;
|
||||
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
Adapter fg(g, 0, boost::make_assoc_property_map(map));
|
||||
|
||||
vertex_iterator vb, ve;
|
||||
for(boost::tie(vb, ve) = vertices(fg); vb != ve; ++vb) {
|
||||
id_map v_ids;
|
||||
|
||||
vertex_descriptor around = *vb;
|
||||
out_edge_iterator oeb, oee;
|
||||
for(boost::tie(oeb, oee) = out_edges(*vb, fg); oeb != oee; ++oeb) {
|
||||
vertex_descriptor t = target(*oeb, fg);
|
||||
vertex_descriptor s = source(*oeb, fg);
|
||||
assert(s != t);
|
||||
assert(s == around);
|
||||
assert(t != around);
|
||||
std::pair<id_map::iterator, bool> r =
|
||||
v_ids.insert(get(boost::vertex_index, g, target(*oeb, fg)));
|
||||
assert(r.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Graph>
|
||||
void test_in_edges(const Graph& g)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor g_face_descriptor;
|
||||
typedef CGAL::Face_filtered_graph<Graph> Adapter;
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
std::map<g_face_descriptor, std::size_t> map;
|
||||
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
Adapter fg(g, 0, boost::make_assoc_property_map(map));
|
||||
|
||||
vertex_iterator vb, ve;
|
||||
for(boost::tie(vb, ve) = vertices(fg); vb != ve; ++vb) {
|
||||
id_map v_ids;
|
||||
vertex_descriptor around = *vb;
|
||||
in_edge_iterator ieb, iee;
|
||||
for(boost::tie(ieb, iee) = in_edges(*vb, fg); ieb != iee; ++ieb) {
|
||||
vertex_descriptor t = target(*ieb, fg);
|
||||
vertex_descriptor s = source(*ieb, fg);
|
||||
assert(t == around);
|
||||
assert(s != around);
|
||||
std::pair<id_map::iterator, bool> r =
|
||||
v_ids.insert(get(boost::vertex_index, g, source(*ieb, fg)));
|
||||
assert(r.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Graph>
|
||||
void test_in_out_edges(const Graph& g)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor g_face_descriptor;
|
||||
typedef CGAL::Face_filtered_graph<Graph> Adapter;
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
std::map<g_face_descriptor, std::size_t> map;
|
||||
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
Adapter fg(g, 0, boost::make_assoc_property_map(map));
|
||||
|
||||
// check that the sets of in out edges are the same
|
||||
vertex_iterator vb, ve;
|
||||
for(boost::tie(vb, ve) = vertices(fg); vb != ve; ++vb) {
|
||||
id_map v_ids;
|
||||
std::vector<vertex_descriptor> in, out;
|
||||
in_edge_iterator ieb, iee;
|
||||
for(boost::tie(ieb, iee) = in_edges(*vb, fg); ieb != iee; ++ieb) {
|
||||
std::pair<id_map::iterator, bool> r =
|
||||
v_ids.insert(get(boost::vertex_index, g, source(*ieb, fg)));
|
||||
assert(r.second);
|
||||
in.push_back(source(*ieb, fg));
|
||||
}
|
||||
out_edge_iterator oeb, oee;
|
||||
for(boost::tie(oeb, oee) = out_edges(*vb, fg); oeb != oee; ++oeb) {
|
||||
std::pair<id_map::iterator, bool> r =
|
||||
v_ids.insert(get(boost::vertex_index, g, target(*oeb, fg)));
|
||||
// insertion must fail
|
||||
assert(!r.second);
|
||||
out.push_back(target(*oeb, fg));
|
||||
}
|
||||
// did we walk the vertices in the same order?
|
||||
assert(in.size() == out.size());
|
||||
assert(std::equal(in.begin(), in.end(), out.begin()));
|
||||
assert(in.size() == in_degree(*vb, fg));
|
||||
assert(out.size() == out_degree(*vb, fg));
|
||||
assert(in.size() == degree(*vb, fg));
|
||||
assert(degree(*vb, fg) == in_degree(*vb, fg));
|
||||
assert(degree(*vb, fg) == out_degree(*vb, fg));
|
||||
}
|
||||
}
|
||||
|
||||
// check that every edge can be found through edge(u, v, g)
|
||||
template<typename Graph>
|
||||
void test_edge_find(const Graph& g)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor g_face_descriptor;
|
||||
typedef CGAL::Face_filtered_graph<Graph> Adapter;
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
std::map<g_face_descriptor, std::size_t> map;
|
||||
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
Adapter fg(g, 0, boost::make_assoc_property_map(map));
|
||||
typedef std::pair<edge_descriptor, bool> ret;
|
||||
|
||||
edge_iterator eb, ee;
|
||||
for(boost::tie(eb, ee) = edges(fg); eb != ee; ++eb) {
|
||||
vertex_descriptor s = source(*eb, fg);
|
||||
vertex_descriptor t = target(*eb, fg);
|
||||
ret found = edge(s, t, fg);
|
||||
ret found2 = edge(t, s, fg);
|
||||
assert(found.second);
|
||||
assert(found2.second);
|
||||
assert(found.first == *eb);
|
||||
assert(found2.first == *eb);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Graph>
|
||||
void test_faces(const Graph& g)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor g_face_descriptor;
|
||||
typedef CGAL::Face_filtered_graph<Graph> Adapter;
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
std::map<g_face_descriptor, std::size_t> map;
|
||||
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
Adapter fg(g, 0, boost::make_assoc_property_map(map));
|
||||
|
||||
unsigned int count = 0;
|
||||
face_iterator fb, fe;
|
||||
for(boost::tie(fb, fe) = faces(fg); fb != fe; ++fb) {
|
||||
++count;
|
||||
// reverse look-up
|
||||
halfedge_descriptor assoc = halfedge(*fb, fg);
|
||||
assert(face(assoc, fg) == *fb);
|
||||
// check the enclosure
|
||||
halfedge_around_face_iterator encb, ence;
|
||||
for(boost::tie(encb, ence) = CGAL::halfedges_around_face(halfedge(*fb, fg), fg); encb != ence; ++encb) {
|
||||
assert(face(*encb, fg) == *fb);
|
||||
}
|
||||
}
|
||||
assert(count == num_faces(fg));
|
||||
}
|
||||
|
||||
template<typename Graph>
|
||||
void test_read(const Graph& g)
|
||||
{
|
||||
typedef typename boost::graph_traits<Graph>::face_descriptor g_face_descriptor;
|
||||
typedef CGAL::Face_filtered_graph<Graph> Adapter;
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
std::map<g_face_descriptor, std::size_t> map;
|
||||
CGAL::Polygon_mesh_processing::connected_components(g, boost::make_assoc_property_map(map), CGAL::Polygon_mesh_processing::parameters::all_default());
|
||||
Adapter fg(g, 0, boost::make_assoc_property_map(map));
|
||||
assert(CGAL::is_valid(fg));
|
||||
}
|
||||
|
||||
template <typename Graph>
|
||||
void
|
||||
test(const std::vector<Graph>& graphs)
|
||||
{
|
||||
BOOST_FOREACH(Graph p, graphs){
|
||||
test_read(p);
|
||||
test_vertex_iterators(p);
|
||||
test_out_edges(p);
|
||||
test_in_edges(p);
|
||||
test_in_out_edges(p);
|
||||
test_edge_find(p);
|
||||
test_faces(p);
|
||||
test_edge_iterators(p);
|
||||
test_halfedge_around_face_iterator(p);
|
||||
test_halfedge_around_vertex_iterator(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef SM::Point Point_3;
|
||||
|
||||
template<class Mesh, typename VertexPointPMap>
|
||||
struct Constraint : public boost::put_get_helper<bool,Constraint<Mesh, VertexPointPMap> >
|
||||
{
|
||||
typedef typename boost::graph_traits<Mesh>::edge_descriptor edge_descriptor;
|
||||
typedef boost::readable_property_map_tag category;
|
||||
typedef bool value_type;
|
||||
typedef bool reference;
|
||||
typedef edge_descriptor key_type;
|
||||
|
||||
|
||||
Constraint()
|
||||
:g_(NULL)
|
||||
{}
|
||||
|
||||
Constraint(Mesh& g, VertexPointPMap vpp)
|
||||
: g_(&g), vppmap(vpp)
|
||||
{}
|
||||
|
||||
bool operator[](edge_descriptor e) const
|
||||
{
|
||||
const Mesh& g = *g_;
|
||||
if(
|
||||
((boost::get(vppmap, target(e, g)) == Point_3(1,1,1) ||
|
||||
boost::get(vppmap, source(e, g)) == Point_3(1,1,1)) &&
|
||||
(boost::get(vppmap, target(e, g)) == Point_3(0,0,0) ||
|
||||
boost::get(vppmap, source(e, g)) == Point_3(0,0,0)))
|
||||
||
|
||||
((boost::get(vppmap, target(e, g)) == Point_3(1,1,1) ||
|
||||
boost::get(vppmap, source(e, g)) == Point_3(1,1,1)) &&
|
||||
(boost::get(vppmap, target(e, g)) == Point_3(0,0,1) ||
|
||||
boost::get(vppmap, source(e, g)) == Point_3(0,0,1)))
|
||||
||
|
||||
((boost::get(vppmap, target(e, g)) == Point_3(0,0,1) ||
|
||||
boost::get(vppmap, source(e, g)) == Point_3(0,0,1)) &&
|
||||
(boost::get(vppmap, target(e, g)) == Point_3(0,0,0) ||
|
||||
boost::get(vppmap, source(e, g)) == Point_3(0,0,0)))
|
||||
||
|
||||
((boost::get(vppmap, target(e, g)) == Point_3(1,0,1) ||
|
||||
boost::get(vppmap, source(e, g)) == Point_3(1,0,1)) &&
|
||||
(boost::get(vppmap, target(e, g)) == Point_3(0,0,0) ||
|
||||
boost::get(vppmap, source(e, g)) == Point_3(0,0,0)))
|
||||
||
|
||||
((boost::get(vppmap, target(e, g)) == Point_3(1,1,1) ||
|
||||
boost::get(vppmap, source(e, g)) == Point_3(1,1,1)) &&
|
||||
(boost::get(vppmap, target(e, g)) == Point_3(1,0,1) ||
|
||||
boost::get(vppmap, source(e, g)) == Point_3(1,0,1)))
|
||||
)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
const Mesh* g_;
|
||||
VertexPointPMap vppmap;
|
||||
};
|
||||
template<class Mesh, class FCCMAP, class Adapter>
|
||||
void test_mesh(Adapter fga)
|
||||
{
|
||||
|
||||
CGAL_GRAPH_TRAITS_MEMBERS(Adapter);
|
||||
//check that there is the right number of simplices in fga
|
||||
CGAL_assertion(CGAL::is_valid(fga));
|
||||
CGAL_assertion(num_faces(fga) == 2);
|
||||
CGAL_assertion(num_edges(fga) == 5);
|
||||
CGAL_assertion(num_halfedges(fga) == 10);
|
||||
CGAL_assertion(num_vertices(fga) == 4);
|
||||
halfedge_descriptor h = halfedge(*faces(fga).first, fga);
|
||||
CGAL_assertion_code( vertex_descriptor v = source(h, fga) );
|
||||
//check that next() works inside the patch
|
||||
CGAL_assertion(
|
||||
next(next(next(h, fga), fga), fga) == h
|
||||
);
|
||||
//check that next() works on bordure of the patch
|
||||
h = opposite(h, fga);
|
||||
CGAL_assertion(
|
||||
next(next(next(next(h, fga), fga), fga), fga) == h
|
||||
);
|
||||
//check that prev() works inside the patch
|
||||
h = halfedge(*faces(fga).first, fga);
|
||||
CGAL_assertion(
|
||||
prev(prev(prev(h, fga), fga), fga) == h
|
||||
);
|
||||
//check that prev() works on bordure of the patch
|
||||
h = opposite(h, fga);
|
||||
CGAL_assertion(
|
||||
prev(prev(prev(prev(h, fga), fga), fga), fga) == h
|
||||
);
|
||||
//check degree
|
||||
CGAL_assertion(degree(v, fga) == 3);
|
||||
//check in_edges and out_edges
|
||||
CGAL_assertion(std::distance(in_edges(v, fga).first ,in_edges(v, fga).second) == 3 );
|
||||
CGAL_assertion(std::distance(out_edges(v, fga).first ,out_edges(v, fga).second) == 3 );
|
||||
|
||||
Mesh copy;
|
||||
CGAL::copy_face_graph(fga, copy);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
test(sm_data());
|
||||
#ifdef CGAL_USE_OPENMESH
|
||||
test(omesh_data());
|
||||
#endif
|
||||
//Make a tetrahedron and test the adapter for a patch that only contains 2 faces
|
||||
typedef CGAL::Face_filtered_graph<SM> SM_Adapter;
|
||||
typedef SM::Property_map<boost::graph_traits<SM>::face_descriptor , std::size_t> SM_FCCMap;
|
||||
SM* sm = new SM();
|
||||
CGAL::make_tetrahedron(
|
||||
Point_3(1,1,1),
|
||||
Point_3(0,0,0),
|
||||
Point_3(0,0,1),
|
||||
Point_3(1,0,1),
|
||||
*sm);
|
||||
SM_FCCMap fccmap =
|
||||
sm->add_property_map<boost::graph_traits<SM>::face_descriptor, std::size_t>("f:CC").first;
|
||||
SM::Property_map<boost::graph_traits<SM>::vertex_descriptor, SM::Point> positions =
|
||||
sm->points();
|
||||
CGAL::Polygon_mesh_processing::connected_components(*sm, fccmap, CGAL::Polygon_mesh_processing::parameters::
|
||||
edge_is_constrained_map(Constraint<SM, SM::Property_map<boost::graph_traits<SM>::vertex_descriptor,
|
||||
SM::Point> >(*sm, positions)));
|
||||
boost::unordered_set<long unsigned int> pids;
|
||||
pids.insert(0);
|
||||
pids.insert(2);
|
||||
SM_Adapter sm_adapter(*sm, pids, fccmap);
|
||||
test_mesh<SM,SM_FCCMap, SM_Adapter>(sm_adapter);
|
||||
|
||||
|
||||
|
||||
|
||||
typedef boost::graph_traits<Polyhedron> PolyTraits;
|
||||
typedef boost::property_map<Polyhedron, boost::vertex_point_t>::type VPMap;
|
||||
typedef PolyTraits::face_descriptor poly_face_descriptor;
|
||||
typedef boost::associative_property_map< std::map<poly_face_descriptor,
|
||||
PolyTraits::faces_size_type> > FCMap;
|
||||
typedef boost::property_map<Polyhedron, CGAL::face_external_index_t>::type FIMap;
|
||||
typedef boost::property_map<Polyhedron, CGAL::vertex_external_index_t>::type VIMap;
|
||||
typedef boost::property_map<Polyhedron, CGAL::halfedge_external_index_t>::type HIMap;
|
||||
typedef CGAL::Face_filtered_graph<Polyhedron, FIMap, VIMap, HIMap> Poly_Adapter;
|
||||
Polyhedron *poly = new Polyhedron();
|
||||
CGAL::make_tetrahedron(
|
||||
Point_3(1,1,1),
|
||||
Point_3(0,0,0),
|
||||
Point_3(0,0,1),
|
||||
Point_3(1,0,1),
|
||||
*poly);
|
||||
|
||||
|
||||
FIMap poly_fimap = get(CGAL::face_external_index, *poly);
|
||||
VIMap poly_vimap = get(CGAL::vertex_external_index, *poly);
|
||||
HIMap poly_himap = get(CGAL::halfedge_external_index, *poly);
|
||||
std::map<poly_face_descriptor,
|
||||
PolyTraits::faces_size_type> fc_map;
|
||||
FCMap poly_fccmap(fc_map);
|
||||
|
||||
VPMap vpmap = get(boost::vertex_point, *poly);
|
||||
CGAL::Polygon_mesh_processing::connected_components(*poly, poly_fccmap, CGAL::Polygon_mesh_processing::parameters::
|
||||
edge_is_constrained_map(Constraint<Polyhedron, VPMap >(*poly, vpmap)).
|
||||
face_index_map(poly_fimap));
|
||||
Poly_Adapter poly_adapter(*poly,
|
||||
pids,
|
||||
poly_fccmap,
|
||||
CGAL::parameters::face_index_map(poly_fimap).
|
||||
vertex_index_map(poly_vimap).
|
||||
halfedge_index_map(poly_himap));
|
||||
test_mesh<Polyhedron, FCMap, Poly_Adapter>(poly_adapter);
|
||||
}
|
||||
|
|
@ -289,7 +289,7 @@ namespace CGAL {
|
|||
CGAL::cpp11::tuple<> converters;
|
||||
Default_converter_dart_info<CMap2, Refs> dartinfoconverter;
|
||||
Default_converter_cmap_0attributes_with_point<CMap2, Refs> pointconverter;
|
||||
return copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
}
|
||||
|
||||
template <typename CMap2, typename Converters>
|
||||
|
|
@ -297,7 +297,7 @@ namespace CGAL {
|
|||
{
|
||||
Default_converter_cmap_0attributes_with_point<CMap2, Refs> pointconverter;
|
||||
Default_converter_dart_info<CMap2, Refs> dartinfoconverter;
|
||||
return copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
}
|
||||
|
||||
template <typename CMap2, typename Converters, typename DartInfoConverter>
|
||||
|
|
@ -305,7 +305,7 @@ namespace CGAL {
|
|||
const DartInfoConverter& dartinfoconverter)
|
||||
{
|
||||
Default_converter_cmap_0attributes_with_point<CMap2, Refs> pointconverter;
|
||||
return copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
}
|
||||
|
||||
// Copy constructor from a map having exactly the same type.
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ namespace CGAL {
|
|||
CGAL::cpp11::tuple<> converters;
|
||||
Default_converter_dart_info<GMap2, Refs> dartinfoconverter;
|
||||
Default_converter_cmap_0attributes_with_point<GMap2, Refs> pointconverter;
|
||||
return copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
}
|
||||
|
||||
template <typename GMap2, typename Converters>
|
||||
|
|
@ -274,7 +274,7 @@ namespace CGAL {
|
|||
{
|
||||
Default_converter_cmap_0attributes_with_point<GMap2, Refs> pointconverter;
|
||||
Default_converter_dart_info<GMap2, Refs> dartinfoconverter;
|
||||
return copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
}
|
||||
|
||||
template <typename GMap2, typename Converters, typename DartInfoConverter>
|
||||
|
|
@ -282,7 +282,7 @@ namespace CGAL {
|
|||
const DartInfoConverter& dartinfoconverter)
|
||||
{
|
||||
Default_converter_cmap_0attributes_with_point<GMap2, Refs> pointconverter;
|
||||
return copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
copy(amap, converters, dartinfoconverter, pointconverter);
|
||||
}
|
||||
|
||||
// Copy constructor from a map having exactly the same type.
|
||||
|
|
|
|||
|
|
@ -178,6 +178,14 @@ and <code>src/</code> directories).
|
|||
<!-- Interpolation -->
|
||||
<!-- Kinetic Data Structures -->
|
||||
<!-- Support Library -->
|
||||
<h3>CGAL and the Boost Graph Library (BGL)</h3>
|
||||
<ul>
|
||||
<li>
|
||||
Add class <code>CGAL::Face_filtered_graph</code> that
|
||||
wraps an existing graph and hide all simplices that are not
|
||||
in the selected connected components.
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Visualization -->
|
||||
|
||||
<!-- end of the div for 4.10 -->
|
||||
|
|
|
|||
|
|
@ -60,11 +60,15 @@ if(NOT USE_CGAL_FILE_INCLUDED)
|
|||
|
||||
if (CGAL_HEADER_ONLY)
|
||||
add_definitions(-DCGAL_HEADER_ONLY)
|
||||
link_directories ( ${CGAL_3RD_PARTY_LIBRARIES_DIRS} )
|
||||
link_libraries ( ${CGAL_3RD_PARTY_LIBRARIES} )
|
||||
if(NOT CGAL_NO_BLANKET_LINKING)
|
||||
link_directories ( ${CGAL_3RD_PARTY_LIBRARIES_DIRS} )
|
||||
link_libraries ( ${CGAL_3RD_PARTY_LIBRARIES} )
|
||||
endif()
|
||||
else()
|
||||
link_directories ( ${CGAL_LIBRARIES_DIR} ${CGAL_3RD_PARTY_LIBRARIES_DIRS} )
|
||||
link_libraries ( ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
|
||||
if(NOT CGAL_NO_BLANKET_LINKING)
|
||||
link_directories ( ${CGAL_LIBRARIES_DIR} ${CGAL_3RD_PARTY_LIBRARIES_DIRS} )
|
||||
link_libraries ( ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES} )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
// Tests if GMP is available.
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <cstddef>
|
||||
#include "gmp.h"
|
||||
|
||||
int main()
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
// Tests if MPFR is available.
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
#include <cstddef>
|
||||
#include "mpfr.h"
|
||||
|
||||
int main()
|
||||
|
|
|
|||
|
|
@ -49,20 +49,20 @@ public:
|
|||
/// @{
|
||||
|
||||
/*!
|
||||
Construction from a bouding polyhedral surface which should be closed, and free of intersections.
|
||||
Construction from a bouding polyhedral surface which must be closed, and free of intersections.
|
||||
The inside of `bounding_polyhedron` will be meshed.
|
||||
*/
|
||||
Polyhedral_mesh_domain_3(Polyhedron bounding_polyhedron);
|
||||
|
||||
/*!
|
||||
Construction from a polyhedral surface, and a bounding polyhedral surface,.
|
||||
The first polyhedron should be entirely included inside `bounding_polyhedron`, which has to be closed
|
||||
The first polyhedron must be entirely included inside `bounding_polyhedron`, which must be closed
|
||||
and free of intersections.
|
||||
Using this constructor allows to mesh a polyhedral surface which is not closed, or has holes.
|
||||
The inside of `bounding_polyhedron` will be meshed.
|
||||
*/
|
||||
Polyhedral_mesh_domain_3(Polyhedron polyhedron,
|
||||
Polyhedron bounding_polyhedron);
|
||||
Polyhedron bounding_polyhedron);
|
||||
|
||||
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -654,13 +654,27 @@ Right : the output mesh with added 1D-features at the intersection of subdomains
|
|||
\subsubsection Mesh_33DPolyhedralDomains 3D Polyhedral Domains
|
||||
|
||||
The following code produces a 3D mesh for a domain
|
||||
defined by polyhedral surfaces. \cgalFigureRef{figurepolyhedral_domain}
|
||||
defined by a polyhedral surface. \cgalFigureRef{figurepolyhedral_domain}
|
||||
shows the resulting mesh.
|
||||
|
||||
\cgalExample{Mesh_3/mesh_polyhedral_domain.cpp}
|
||||
|
||||
\cgalFigureBegin{figurepolyhedral_domain,polyhedral_domain.jpg,polyhedral_domain_2.jpg}
|
||||
View of 3D meshes produced from a polyhedral domain. (i) is a view of file out_1.mesh and (ii) is a view of file out_2.mesh. Code from subsection \ref Mesh_3_subsection_examples_polyhedral generates these files."
|
||||
View of 3D meshes produced from a polyhedral domain. (i) is a view of file out_1.mesh and (ii) is a view of file out_2.mesh. Code from subsection \ref Mesh_3_subsection_examples_polyhedral generates these files.
|
||||
\cgalFigureEnd
|
||||
|
||||
\subsubsection Mesh_33DSurfaceInsidePolyhedralDomain Remeshing a Polyhedral Domain with Surfaces
|
||||
|
||||
In the following example we have a "bounding polyhedron" which defines the meshing domain and two surfaces inside this domain.
|
||||
The surfaces inside the domain may be closed surfaces as well as surfaces with boundaries. In the case of a closed surface
|
||||
the volume delimited by this surface is also considered as inside the domain.
|
||||
previous subsection.
|
||||
|
||||
|
||||
\cgalExample{Mesh_3/mesh_polyhedral_domain_with_surface_inside.cpp}
|
||||
|
||||
\cgalFigureBegin{figurepolyhedral_domain_with_surface,polyhedral_domain_with_surface.jpg}
|
||||
View of 3D meshes produced from a polyhedral domain with a nested surface.
|
||||
\cgalFigureEnd
|
||||
|
||||
\subsubsection Mesh_3RemeshingPolyhedralSurface Remeshing a Polyhedral Surface
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
\example Mesh_3/mesh_polyhedral_domain.cpp
|
||||
\example Mesh_3/remesh_polyhedral_surface.cpp
|
||||
\example Mesh_3/mesh_polyhedral_domain_with_features.cpp
|
||||
\example Mesh_3/mesh_polyhedral_domain_with_surface_inside.cpp
|
||||
\example Mesh_3/mesh_polyhedral_domain_with_lipschitz_sizing.cpp
|
||||
\example Mesh_3/mesh_two_implicit_spheres_with_balls.cpp
|
||||
\example Mesh_3/mesh_3D_gray_image.cpp
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 85 KiB |
|
|
@ -73,6 +73,7 @@ if ( CGAL_FOUND )
|
|||
create_single_source_cgal_program( "mesh_cubes_intersection_with_features.cpp" )
|
||||
create_single_source_cgal_program( "mesh_implicit_domains.cpp" "implicit_functions.cpp" )
|
||||
create_single_source_cgal_program( "mesh_polyhedral_domain.cpp" )
|
||||
create_single_source_cgal_program( "mesh_polyhedral_domain_with_surface_inside.cpp" )
|
||||
create_single_source_cgal_program( "remesh_polyhedral_surface.cpp" )
|
||||
create_single_source_cgal_program( "mesh_polyhedral_domain_with_features.cpp" )
|
||||
create_single_source_cgal_program( "mesh_polyhedral_domain_with_lipschitz_sizing.cpp" )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
OFF
|
||||
8 12 0
|
||||
|
||||
-1.1855500570497703 -0.076163891881438378 -0.8013403915768772
|
||||
-1.1855500570497703 0.47597074519009164 -0.8013403915768772
|
||||
0.79704321809070222 0.47597074519009164 -0.8013403915768772
|
||||
0.79704321809070222 -0.076163891881438378 -0.8013403915768772
|
||||
-1.1855500570497703 -0.076163891881438378 1.0953134363531141
|
||||
-1.1855500570497703 0.47597074519009164 1.0953134363531141
|
||||
0.79704321809070222 0.47597074519009164 1.0953134363531141
|
||||
0.79704321809070222 -0.076163891881438378 1.0953134363531141
|
||||
3 0 1 3
|
||||
3 3 1 2
|
||||
3 0 4 1
|
||||
3 1 4 5
|
||||
3 3 2 7
|
||||
3 7 2 6
|
||||
3 4 0 3
|
||||
3 7 4 3
|
||||
3 6 4 7
|
||||
3 6 5 4
|
||||
3 1 5 6
|
||||
3 2 1 6
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,67 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Mesh_triangulation_3.h>
|
||||
#include <CGAL/Mesh_complex_3_in_triangulation_3.h>
|
||||
#include <CGAL/Mesh_criteria_3.h>
|
||||
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/Polyhedral_mesh_domain_with_features_3.h>
|
||||
#include <CGAL/make_mesh_3.h>
|
||||
#include <CGAL/Timer.h>
|
||||
|
||||
// Domain
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
|
||||
typedef CGAL::Mesh_polyhedron_3<K>::type Polyhedron;
|
||||
|
||||
typedef CGAL::Polyhedral_mesh_domain_with_features_3<K> Mesh_domain;
|
||||
|
||||
|
||||
// Triangulation
|
||||
typedef CGAL::Mesh_triangulation_3<Mesh_domain,CGAL::Default,CGAL::Sequential_tag>::type Tr;
|
||||
|
||||
typedef CGAL::Mesh_complex_3_in_triangulation_3<
|
||||
Tr,Mesh_domain::Corner_index,Mesh_domain::Curve_segment_index> C3t3;
|
||||
|
||||
// Criteria
|
||||
typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria;
|
||||
|
||||
// To avoid verbose function and named parameters call
|
||||
using namespace CGAL::parameters;
|
||||
|
||||
int main(int argc, char*argv[])
|
||||
{
|
||||
std::cout.precision(17);
|
||||
std::cerr.precision(17);
|
||||
const char* fname = (argc>1)?argv[1]:"data/horizons.off";
|
||||
std::ifstream input(fname);
|
||||
const char* fname2 = (argc>2)?argv[2]:"data/horizons-domain.off";
|
||||
std::ifstream input2(fname2);
|
||||
Polyhedron sm, smbounding;
|
||||
input >> sm;
|
||||
input2 >> smbounding;
|
||||
if(input.fail()){
|
||||
std::cerr << "Error: Cannot read file " << fname << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
CGAL::Timer t;
|
||||
t.start();
|
||||
// Create domain
|
||||
Mesh_domain domain(sm, smbounding);
|
||||
|
||||
// Get sharp features
|
||||
domain.detect_features();
|
||||
|
||||
// Mesh criteria
|
||||
Mesh_criteria criteria(edge_size = 0.025,
|
||||
facet_angle = 25, facet_size = 0.05, facet_distance = 0.005,
|
||||
cell_radius_edge_ratio = 3, cell_size = 0.05);
|
||||
|
||||
// Mesh generation
|
||||
C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria,
|
||||
no_perturb(), no_exude());
|
||||
|
||||
std::cerr << t.time() << " sec." << std::endl;
|
||||
// Output
|
||||
dump_c3t3(c3t3, "out");
|
||||
}
|
||||
|
|
@ -312,7 +312,11 @@ public:
|
|||
{
|
||||
this->add_primitives(p);
|
||||
this->add_primitives(bounding_polyhedron);
|
||||
this->add_primitives_to_bounding_tree(bounding_polyhedron);
|
||||
if(!bounding_polyhedron.empty()) {
|
||||
this->add_primitives_to_bounding_tree(bounding_polyhedron);
|
||||
} else {
|
||||
this->set_surface_only();
|
||||
}
|
||||
this->build();
|
||||
}
|
||||
|
||||
|
|
@ -341,7 +345,11 @@ public:
|
|||
}
|
||||
this->add_primitives(bounding_polyhedron);
|
||||
}
|
||||
this->add_primitives_to_bounding_tree(bounding_polyhedron);
|
||||
if(!bounding_polyhedron.empty()) {
|
||||
this->add_primitives_to_bounding_tree(bounding_polyhedron);
|
||||
} else {
|
||||
this->set_surface_only();
|
||||
}
|
||||
this->build();
|
||||
}
|
||||
|
||||
|
|
@ -682,8 +690,10 @@ protected:
|
|||
|
||||
void build() {
|
||||
tree_.build();
|
||||
CGAL_assertion(!tree_.empty());
|
||||
if(bounding_tree_ != &tree_ && bounding_tree_ != 0) {
|
||||
bounding_tree_->build();
|
||||
CGAL_assertion(!bounding_tree_->empty());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -284,7 +284,11 @@ public:
|
|||
stored_polyhedra[1] = bounding_p;
|
||||
this->add_primitives(stored_polyhedra[0]);
|
||||
this->add_primitives(stored_polyhedra[1]);
|
||||
this->add_primitives_to_bounding_tree(stored_polyhedra[1]);
|
||||
if(bounding_p.empty()) {
|
||||
this->set_surface_only();
|
||||
} else {
|
||||
this->add_primitives_to_bounding_tree(stored_polyhedra[1]);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename InputPolyhedraPtrIterator>
|
||||
|
|
@ -318,7 +322,11 @@ public:
|
|||
stored_polyhedra.push_back(bounding_polyhedron);
|
||||
this->add_primitives(stored_polyhedra.back());
|
||||
}
|
||||
this->add_primitives_to_bounding_tree(stored_polyhedra.back());
|
||||
if(bounding_polyhedron.empty()) {
|
||||
this->set_surface_only();
|
||||
} else {
|
||||
this->add_primitives_to_bounding_tree(stored_polyhedra.back());
|
||||
}
|
||||
this->build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,5 +10,6 @@ int main() {
|
|||
Nef_polyhedron N1(Nef_polyhedron::COMPLETE);
|
||||
|
||||
CGAL_assertion (N0 == N1.complement());
|
||||
CGAL_assertion (N0 != N1);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1416,6 +1416,10 @@ protected:
|
|||
intersection(const Nef_polyhedron_3<Kernel,Items, Mark>& N1) const
|
||||
/*{\Mop returns |\Mvar| $\cap$ |N1|. }*/ {
|
||||
CGAL_NEF_TRACEN(" intersection between nef3 "<<&*this<<" and "<<&N1);
|
||||
if (is_empty()) return *this;
|
||||
if (N1.is_empty()) return N1;
|
||||
if (is_space()) return N1;
|
||||
if (N1.is_space()) return *this;
|
||||
AND _and;
|
||||
SNC_structure rsnc;
|
||||
Nef_polyhedron_3<Kernel,Items, Mark> res(rsnc, new SNC_point_locator_default, false);
|
||||
|
|
@ -1440,6 +1444,10 @@ protected:
|
|||
join(const Nef_polyhedron_3<Kernel,Items, Mark>& N1) const
|
||||
/*{\Mop returns |\Mvar| $\cup$ |N1|. }*/ {
|
||||
CGAL_NEF_TRACEN(" join between nef3 "<<&*this<<" and "<<&N1);
|
||||
if (is_empty()) return N1;
|
||||
if (N1.is_empty()) return *this;
|
||||
if (is_space()) return *this;
|
||||
if (N1.is_space()) return N1;
|
||||
OR _or;
|
||||
//CGAL::binop_intersection_tests_allpairs<SNC_decorator, OR> tests_impl;
|
||||
SNC_structure rsnc;
|
||||
|
|
@ -1453,6 +1461,10 @@ protected:
|
|||
difference(const Nef_polyhedron_3<Kernel,Items, Mark>& N1) const
|
||||
/*{\Mop returns |\Mvar| $-$ |N1|. }*/ {
|
||||
CGAL_NEF_TRACEN(" difference between nef3 "<<&*this<<" and "<<&N1);
|
||||
if (is_empty()) return *this;
|
||||
if (N1.is_empty()) return *this;
|
||||
if (is_space()) return N1.complement();
|
||||
if (N1.is_space()) return Nef_polyhedron_3(EMPTY);
|
||||
DIFF _diff;
|
||||
//CGAL::binop_intersection_tests_allpairs<SNC_decorator, DIFF> tests_impl;
|
||||
SNC_structure rsnc;
|
||||
|
|
@ -1467,6 +1479,10 @@ protected:
|
|||
/*{\Mop returns the symmectric difference |\Mvar - T| $\cup$
|
||||
|T - \Mvar|. }*/ {
|
||||
CGAL_NEF_TRACEN(" symmetic difference between nef3 "<<&*this<<" and "<<&N1);
|
||||
if (is_empty()) return N1;
|
||||
if (N1.is_empty()) return *this;
|
||||
if (is_space()) return Nef_polyhedron_3(EMPTY);
|
||||
if (N1.is_space()) return Nef_polyhedron_3(EMPTY);
|
||||
XOR _xor;
|
||||
//CGAL::binop_intersection_tests_allpairs<SNC_decorator, XOR> tests_impl;
|
||||
SNC_structure rsnc;
|
||||
|
|
|
|||
|
|
@ -598,7 +598,7 @@ should be discarded in favour of major connected components.
|
|||
|
||||
\subsection CCExample Connected Components Example
|
||||
|
||||
The following example shows how to record the connected
|
||||
The first example shows how to record the connected
|
||||
components of a polygon mesh.
|
||||
In particular, we provide an example for the optional parameter \c EdgeConstraintMap,
|
||||
a property map that returns information about an edge being a \e constraint or not.
|
||||
|
|
@ -607,6 +607,12 @@ the propagation of a connected component index to cross it.
|
|||
|
||||
\cgalExample{Polygon_mesh_processing/connected_components_example.cpp}
|
||||
|
||||
The second example shows how to use the class template `Face_filtered_graph`
|
||||
which enables to treat one or several connected components as a face graph.
|
||||
|
||||
\cgalExample{Polygon_mesh_processing/face_filtered_graph_example.cpp}
|
||||
|
||||
|
||||
\section PMPDistance Approximate Hausdorff Distance
|
||||
|
||||
This package provides methods to compute (approximate) distances between meshes and point sets.
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
\example Polygon_mesh_processing/point_inside_example.cpp
|
||||
\example Polygon_mesh_processing/triangulate_faces_example.cpp
|
||||
\example Polygon_mesh_processing/connected_components_example.cpp
|
||||
\example Polygon_mesh_processing/face_filtered_graph_example.cpp
|
||||
\example Polygon_mesh_processing/polygon_soup_example.cpp
|
||||
\example Polygon_mesh_processing/triangulate_polyline_example.cpp
|
||||
\example Polygon_mesh_processing/refine_fair_example.cpp
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ create_single_source_cgal_program( "compute_normals_example.cpp" CXX_FEATURES cx
|
|||
create_single_source_cgal_program( "point_inside_example.cpp")
|
||||
create_single_source_cgal_program( "triangulate_faces_example.cpp")
|
||||
create_single_source_cgal_program( "connected_components_example.cpp")
|
||||
create_single_source_cgal_program( "face_filtered_graph_example.cpp")
|
||||
create_single_source_cgal_program( "polygon_soup_example.cpp")
|
||||
create_single_source_cgal_program( "triangulate_polyline_example.cpp")
|
||||
create_single_source_cgal_program( "mesh_slicer_example.cpp")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
|
||||
#include <CGAL/Polygon_mesh_processing/connected_components.h>
|
||||
#include <CGAL/boost/graph/Face_filtered_graph.h>
|
||||
|
||||
#include <boost/property_map/property_map.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef Kernel::Point_3 Point;
|
||||
|
||||
typedef CGAL::Surface_mesh<Point> Mesh;
|
||||
typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
|
||||
typedef boost::graph_traits<Mesh>::faces_size_type faces_size_type;
|
||||
|
||||
typedef Mesh::Property_map<face_descriptor, faces_size_type> FCCmap;
|
||||
typedef CGAL::Face_filtered_graph<Mesh> Filtered_graph;
|
||||
|
||||
namespace PMP = CGAL::Polygon_mesh_processing;
|
||||
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
std::ifstream input((argc > 1) ? argv[1] : "data/blobby_3cc.off");
|
||||
|
||||
Mesh mesh;
|
||||
if (!input || !(input >> mesh) || mesh.is_empty()) {
|
||||
std::cerr << "Not a valid off file." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
FCCmap fccmap = mesh.add_property_map<face_descriptor, faces_size_type>("f:CC").first;
|
||||
|
||||
faces_size_type num = PMP::connected_components(mesh,fccmap);
|
||||
|
||||
std::cerr << "- The graph has " << num << " connected components (face connectivity)" << std::endl;
|
||||
|
||||
Filtered_graph ffg(mesh, 0, fccmap);
|
||||
|
||||
std::cout << "The faces in component 0 are:" << std::endl;
|
||||
BOOST_FOREACH(boost::graph_traits<Filtered_graph>::face_descriptor f, faces(ffg)){
|
||||
std::cout << f << std::endl;
|
||||
}
|
||||
|
||||
if(num>1){
|
||||
std::vector<faces_size_type> components;
|
||||
components.push_back(0);
|
||||
components.push_back(1);
|
||||
|
||||
ffg.set_selected_faces(components, fccmap);
|
||||
|
||||
std::cout << "The faces in components 0 and 1 are:" << std::endl;
|
||||
BOOST_FOREACH(Filtered_graph::face_descriptor f, faces(ffg)){
|
||||
std::cout << f << std::endl;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -42,52 +42,6 @@ public:
|
|||
typedef typename boost::property_traits<PMap>::value_type type;
|
||||
};
|
||||
|
||||
template<typename PolygonMesh, typename PropertyTag>
|
||||
class property_map_selector
|
||||
{
|
||||
public:
|
||||
typedef typename boost::graph_has_property<PolygonMesh, PropertyTag>::type Has_internal_pmap;
|
||||
typedef typename boost::mpl::if_c< Has_internal_pmap::value
|
||||
, typename boost::property_map<PolygonMesh, PropertyTag>::type
|
||||
, typename boost::cgal_no_property::type
|
||||
>::type type;
|
||||
typedef typename boost::mpl::if_c< Has_internal_pmap::value
|
||||
, typename boost::property_map<PolygonMesh, PropertyTag>::const_type
|
||||
, typename boost::cgal_no_property::const_type
|
||||
>::type const_type;
|
||||
|
||||
type get_pmap(const PropertyTag& p, PolygonMesh& pmesh)
|
||||
{
|
||||
return get_impl(p, pmesh, Has_internal_pmap());
|
||||
}
|
||||
|
||||
const_type get_const_pmap(const PropertyTag& p, const PolygonMesh& pmesh)
|
||||
{
|
||||
return get_const_pmap_impl(p, pmesh, Has_internal_pmap());
|
||||
}
|
||||
|
||||
private:
|
||||
type get_impl(const PropertyTag&, PolygonMesh&, CGAL::Tag_false)
|
||||
{
|
||||
return type(); //boost::cgal_no_property::type
|
||||
}
|
||||
type get_impl(const PropertyTag& p, PolygonMesh& pmesh, CGAL::Tag_true)
|
||||
{
|
||||
return get(p, pmesh);
|
||||
}
|
||||
|
||||
const_type get_const_pmap_impl(const PropertyTag&
|
||||
, const PolygonMesh&, CGAL::Tag_false)
|
||||
{
|
||||
return const_type(); //boost::cgal_no_property::type
|
||||
}
|
||||
const_type get_const_pmap_impl(const PropertyTag& p
|
||||
, const PolygonMesh& pmesh, CGAL::Tag_true)
|
||||
{
|
||||
return get(p, pmesh);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename PolygonMesh, typename NamedParameters>
|
||||
class GetVertexPointMap
|
||||
{
|
||||
|
|
@ -138,22 +92,6 @@ public:
|
|||
> ::type type;
|
||||
};
|
||||
|
||||
template<typename PolygonMesh, typename PropertyTag>
|
||||
typename property_map_selector<PolygonMesh, PropertyTag>::type
|
||||
get_property_map(const PropertyTag& p, PolygonMesh& pmesh)
|
||||
{
|
||||
property_map_selector<PolygonMesh, PropertyTag> pms;
|
||||
return pms.get_pmap(p, pmesh);
|
||||
}
|
||||
|
||||
template<typename PolygonMesh, typename PropertyTag>
|
||||
typename property_map_selector<PolygonMesh, PropertyTag>::const_type
|
||||
get_const_property_map(const PropertyTag& p, const PolygonMesh& pmesh)
|
||||
{
|
||||
property_map_selector<PolygonMesh, PropertyTag> pms;
|
||||
return pms.get_const_pmap(p, pmesh);
|
||||
}
|
||||
|
||||
template<typename PolygonMesh, typename NamedParameters>
|
||||
class GetFaceIndexMap
|
||||
{
|
||||
|
|
|
|||
|
|
@ -141,9 +141,9 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
|
||||
// setup scene
|
||||
scene = new Scene(this);
|
||||
viewer->textRenderer->setScene(scene);
|
||||
viewer->textRenderer()->setScene(scene);
|
||||
viewer->setScene(scene);
|
||||
ui->actionMaxTextItemsDisplayed->setText(QString("Set Maximum Text Items Displayed : %1").arg(viewer->textRenderer->getMax_textItems()));
|
||||
ui->actionMaxTextItemsDisplayed->setText(QString("Set Maximum Text Items Displayed : %1").arg(viewer->textRenderer()->getMax_textItems()));
|
||||
{
|
||||
QShortcut* shortcut = new QShortcut(QKeySequence(Qt::ALT+Qt::Key_Q), this);
|
||||
connect(shortcut, SIGNAL(activated()),
|
||||
|
|
@ -754,6 +754,9 @@ void MainWindow::viewerShow(float xmin,
|
|||
qglviewer::Vec
|
||||
min_(xmin, ymin, zmin),
|
||||
max_(xmax, ymax, zmax);
|
||||
|
||||
if(min_ == max_) return viewerShow(xmin, ymin, zmin);
|
||||
|
||||
#if QGLVIEWER_VERSION >= 0x020502
|
||||
viewer->camera()->setPivotPoint((min_+max_)*0.5);
|
||||
#else
|
||||
|
|
@ -887,8 +890,8 @@ void MainWindow::reloadItem() {
|
|||
Scene_item_with_properties *property_item = dynamic_cast<Scene_item_with_properties*>(new_item);
|
||||
if(property_item)
|
||||
property_item->copyProperties(item);
|
||||
new_item->invalidateOpenGLBuffers();
|
||||
scene->replaceItem(scene->item_id(item), new_item, true);
|
||||
new_item->invalidateOpenGLBuffers();
|
||||
item->deleteLater();
|
||||
}
|
||||
|
||||
|
|
@ -1459,6 +1462,7 @@ void MainWindow::on_actionLoad_triggered()
|
|||
dialog.setFileMode(QFileDialog::ExistingFiles);
|
||||
|
||||
if(dialog.exec() != QDialog::Accepted) { return; }
|
||||
viewer->update();
|
||||
FilterPluginMap::iterator it =
|
||||
filterPluginMap.find(dialog.selectedNameFilter());
|
||||
|
||||
|
|
@ -1534,13 +1538,19 @@ void MainWindow::on_actionSaveAs_triggered()
|
|||
return;
|
||||
}
|
||||
QString caption = tr("Save %1 to File...%2").arg(item->name()).arg(ext);
|
||||
//remove `)`
|
||||
ext.chop(1);
|
||||
//remove `(*.`
|
||||
ext = ext.right(ext.size()-3);
|
||||
QString filename =
|
||||
QFileDialog::getSaveFileName(this,
|
||||
caption,
|
||||
QString(),
|
||||
QString("%1.%2").arg(item->name()).arg(ext),
|
||||
filters.join(";;"));
|
||||
if(filename.isEmpty())
|
||||
return;
|
||||
|
||||
viewer->update();
|
||||
save(filename, item);
|
||||
}
|
||||
|
||||
|
|
@ -1926,10 +1936,10 @@ void MainWindow::on_actionMaxTextItemsDisplayed_triggered()
|
|||
bool valid;
|
||||
QString text = QInputDialog::getText(this, tr("Maximum Number of Text Items"),
|
||||
tr("Maximum Text Items Diplayed:"), QLineEdit::Normal,
|
||||
QString("%1").arg(viewer->textRenderer->getMax_textItems()), &ok);
|
||||
QString("%1").arg(viewer->textRenderer()->getMax_textItems()), &ok);
|
||||
text.toInt(&valid);
|
||||
if (ok && valid){
|
||||
viewer->textRenderer->setMax(text.toInt());
|
||||
viewer->textRenderer()->setMax(text.toInt());
|
||||
ui->actionMaxTextItemsDisplayed->setText(QString("Set Maximum Text Items Displayed : %1").arg(text.toInt()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ namespace Ui {
|
|||
|
||||
/*!
|
||||
* \brief The main window of the applicatipon.
|
||||
*
|
||||
* It contains all the widgets, the menus and the elements of interface
|
||||
* of the application.*/
|
||||
|
||||
|
|
@ -61,40 +62,53 @@ public:
|
|||
POLYHEDRON
|
||||
};
|
||||
/*! \brief The constructor
|
||||
*
|
||||
* It links the class with its UI file and sets it up.
|
||||
* It also saves pointers to viewer and the sceneView.
|
||||
* It also saves pointers to viewer and the Geometric Objects view.
|
||||
* Then it creates and initializes the scene and do the
|
||||
* connexions with the UI. Finally it loads the plugins.*/
|
||||
|
||||
MainWindow(QWidget* parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
/*! Find an IO plugin.
|
||||
/*! Finds an IO plugin.
|
||||
* throws std::invalid_argument if no loader with that argument can be found
|
||||
@returns the IO plugin associated with `loader_name`*/
|
||||
CGAL::Three::Polyhedron_demo_io_plugin_interface* findLoader(const QString& loader_name) const;
|
||||
|
||||
/*! \brief Load an item with a given loader.
|
||||
/*! \brief Loads an item with a given loader.
|
||||
*
|
||||
* throws `std::logic_error` if loading does not succeed or
|
||||
* `std::invalid_argument` if `fileinfo` specifies an invalid file*/
|
||||
CGAL::Three::Scene_item* loadItem(QFileInfo fileinfo, CGAL::Three::Polyhedron_demo_io_plugin_interface*);
|
||||
|
||||
Q_SIGNALS:
|
||||
//! Is emitted when the Application is closed.
|
||||
void on_closure();
|
||||
//! Is emitted when a group is expanded.
|
||||
void expanded(QModelIndex);
|
||||
//! Is emitted when a group is collapsed.
|
||||
void collapsed(QModelIndex);
|
||||
|
||||
|
||||
public Q_SLOTS:
|
||||
//!Creates a new group and adds it to the scene.
|
||||
void makeNewGroup();
|
||||
//! Re-computes the viewer's Bbox
|
||||
void updateViewerBBox();
|
||||
//! Opens a script or a file with the default loader if there is.
|
||||
void open(QString);
|
||||
//! Is called when the up button is pressed.
|
||||
void on_upButton_pressed();
|
||||
//! Is called when the down button is pressed.
|
||||
void on_downButton_pressed();
|
||||
//! COllapses the groups that were before the Geometric Objects view was re-drawn.
|
||||
void restoreCollapseState();
|
||||
//! Expands a group
|
||||
void setExpanded(QModelIndex);
|
||||
//! Collapses a group.
|
||||
void setCollapsed(QModelIndex);
|
||||
//! checks if a file matches `filters`
|
||||
bool file_matches_filter(const QString& filters, const QString& filename);
|
||||
void reset_default_loaders();
|
||||
//!Prints a dialog containing statistics on the selected polyhedrons.
|
||||
|
|
@ -108,16 +122,10 @@ public Q_SLOTS:
|
|||
The index must identify a valid `Scene_item`.*/
|
||||
void reloadItem();
|
||||
|
||||
/*!
|
||||
* This is an overloaded function.
|
||||
* If QT_SCRIPT_LIB is defined, returns true if the script is valid.
|
||||
* If not, returns false.
|
||||
*/
|
||||
//! Loads a script. Returns true if it worked.
|
||||
bool loadScript(QString filename);
|
||||
|
||||
/*! If QT_SCRIPT_LIB is defined, returns true if the script is valid.
|
||||
* If not, returns false.
|
||||
*/
|
||||
//! Loads a script. Returns true if it worked.
|
||||
bool loadScript(QFileInfo);
|
||||
|
||||
/*!
|
||||
|
|
@ -126,8 +134,8 @@ public Q_SLOTS:
|
|||
void setFocusToQuickSearch();
|
||||
|
||||
/*!
|
||||
* Clears the current selection and select the scene_item with
|
||||
* the index i in the sceneView. Calls itemChanged(i) from the scene.
|
||||
* Clears the current selection and selects the scene_item with
|
||||
* the index i in the Geometric Objects view.
|
||||
*/
|
||||
void selectSceneItem(int i);
|
||||
/*!
|
||||
|
|
@ -136,32 +144,33 @@ public Q_SLOTS:
|
|||
*/
|
||||
void showSelectedPoint(double, double, double);
|
||||
/*!
|
||||
* Calls removeSceneItemFromSelection(i).
|
||||
* Removes an item from the current selection.
|
||||
*/
|
||||
void unSelectSceneItem(int i);
|
||||
/*!
|
||||
* Clears the current selection and select all the scene_items
|
||||
* in the sceneView.
|
||||
* in the Geometric Objects view.
|
||||
*/
|
||||
void selectAll();
|
||||
/*!
|
||||
* Assigns a different color to each selected item.
|
||||
*/
|
||||
void colorItems();
|
||||
|
||||
/*!
|
||||
* Adds the scene_item with the index i in the sceneView to the
|
||||
* Adds the scene_item with the index i in the Geometric Objects view to the
|
||||
* current selection. Calls itemChanged(i) from the scene.
|
||||
*/
|
||||
void addSceneItemInSelection(int i);
|
||||
|
||||
/*!
|
||||
* Removes the scene_item with the index i in the sceneView to the
|
||||
* current selection. Calls itemChanged(i) from the scene.
|
||||
* Removes the scene_item with the index i in the Geometric Objects view to the
|
||||
* current selection.
|
||||
*/
|
||||
void removeSceneItemFromSelection(int i);
|
||||
|
||||
/*!
|
||||
* Calls setAddKeyFrameKeyboardModifiers(m) from the viewer.
|
||||
* Sets the modifiers of the viewer.
|
||||
*/
|
||||
void setAddKeyFrameKeyboardModifiers(Qt::KeyboardModifiers);
|
||||
/*!
|
||||
|
|
@ -232,14 +241,14 @@ public Q_SLOTS:
|
|||
void set_face_graph_default_type(MainWindow::Face_graph_mode m);
|
||||
protected Q_SLOTS:
|
||||
|
||||
//!Gets the new selected item(s) from the sceneView and updates the scene
|
||||
//!Gets the new selected item(s) from the Geometric Objects view and updates the scene
|
||||
//!and viewer accordingly.
|
||||
/*!
|
||||
* Set the scene selected item or selected item list. Sets the manipulated
|
||||
* frame of the viewer to the new selected item's and calls updateGL().
|
||||
*/
|
||||
void selectionChanged();
|
||||
//! Scrolls to the new selected item.
|
||||
//! Scrolls to the new selected item from its name in the Geometric Objects list.
|
||||
void recenterSceneView(const QModelIndex &id);
|
||||
|
||||
/*!
|
||||
|
|
@ -257,9 +266,9 @@ protected Q_SLOTS:
|
|||
//!This is an overloaded function. Invoques a context menu at the requested
|
||||
//!position.
|
||||
/*!
|
||||
* If the widget which received the request is not the sceneView, the index
|
||||
* If the widget which received the request is not the Geometric Objects view, the index
|
||||
* chosen by default for the menu is the one of the currently selected item.
|
||||
* If it is the sceneView, then the index of the clicked item is collected.
|
||||
* If it is the Geometric Objects view, then the index of the clicked item is collected.
|
||||
* If this index is valid, then it is used for the menu. If not, the function
|
||||
* returns.
|
||||
*/
|
||||
|
|
@ -285,7 +294,7 @@ protected Q_SLOTS:
|
|||
void on_actionEraseAll_triggered();
|
||||
//!Opens a dialog to open one or several files.
|
||||
void on_actionLoad_triggered();
|
||||
//!Erases the selected items. Returns true if items remain in the sceneView.
|
||||
//!Erases the selected items. Returns true if items remain in the Geometric Objects view.
|
||||
bool on_actionErase_triggered();
|
||||
//!Duplicates the selected item and selects the new item.
|
||||
void on_actionDuplicate_triggered();
|
||||
|
|
@ -343,7 +352,7 @@ protected Q_SLOTS:
|
|||
|
||||
protected:
|
||||
QList<QAction*> createSubMenus(QList<QAction*>);
|
||||
/*! For each objects in the sceneView, loads the associated plugins.
|
||||
/*! For each objects in the Geometric Objects view, loads the associated plugins.
|
||||
* Gets the property "submenuName" of all the actions and creates submenus.
|
||||
* Sorts the Operations menu by name.
|
||||
* @see initPlugin(QObject*);
|
||||
|
|
@ -363,11 +372,11 @@ protected:
|
|||
* @see writeSettings()
|
||||
*/
|
||||
void closeEvent(QCloseEvent *event);
|
||||
/*! Returns the currently selected item in the sceneView. Returns -1
|
||||
/*! Returns the currently selected item in the Geometric Objects view. Returns -1
|
||||
* if none is selected.
|
||||
*/
|
||||
int getSelectedSceneItemIndex() const;
|
||||
//! Returns a list of the selected items in the sceneView.
|
||||
//! Returns a list of the selected items in the Geometric Objects view.
|
||||
QList<int> getSelectedSceneItemIndices() const;
|
||||
private:
|
||||
void updateMenus();
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ Polyhedron_demo_off_plugin::load_off(QFileInfo fileinfo) {
|
|||
if(fileinfo.size() > 100000000)//100 MB
|
||||
{
|
||||
item->set_flat_disabled(true);
|
||||
QApplication::restoreOverrideCursor();
|
||||
QMessageBox::warning((QWidget*)NULL,
|
||||
tr("The file seems to be very big."),
|
||||
tr("Flat shading has been disabled to gain memory. You can force it in the context menu of the item."));
|
||||
|
|
|
|||
|
|
@ -808,7 +808,7 @@ private Q_SLOTS:
|
|||
deletion.append(scene->item_id(child));
|
||||
}
|
||||
deletion.append(scene->item_id(group));
|
||||
static_cast<Scene*>(scene)->erase(deletion);
|
||||
scene->erase(deletion);
|
||||
}
|
||||
//try to re-connect to another group
|
||||
if(!group_map.isEmpty())
|
||||
|
|
|
|||
|
|
@ -183,10 +183,10 @@ void Polyhedron_demo_self_intersection_plugin::on_actionSelfIntersection_trigger
|
|||
found = true;
|
||||
}
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
if(!found)
|
||||
QMessageBox::information(mw, tr("No self intersection"),
|
||||
tr("None of the selected surfaces self-intersect."));
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
|
||||
#include "Self_intersection_plugin.moc"
|
||||
|
|
|
|||
|
|
@ -174,22 +174,27 @@ void Polyhedron_demo_point_set_shape_detection_plugin::on_actionDetect_triggered
|
|||
// Shapes to be searched for are registered by using the template Shape_factory
|
||||
if(dialog.detect_plane()){
|
||||
groups[0] = new Scene_group_item("Planes");
|
||||
groups[0]->setRenderingMode(Points);
|
||||
shape_detection.add_shape_factory<CGAL::Shape_detection_3::Plane<Traits> >();
|
||||
}
|
||||
if(dialog.detect_cylinder()){
|
||||
groups[1] = new Scene_group_item("Cylinders");
|
||||
groups[1]->setRenderingMode(Points);
|
||||
shape_detection.add_shape_factory<CGAL::Shape_detection_3::Cylinder<Traits> >();
|
||||
}
|
||||
if(dialog.detect_torus()){
|
||||
groups[2] = new Scene_group_item("Torus");
|
||||
groups[2]->setRenderingMode(Points);
|
||||
shape_detection.add_shape_factory< CGAL::Shape_detection_3::Torus<Traits> >();
|
||||
}
|
||||
if(dialog.detect_cone()){
|
||||
groups[3] = new Scene_group_item("Cones");
|
||||
groups[3]->setRenderingMode(Points);
|
||||
shape_detection.add_shape_factory< CGAL::Shape_detection_3::Cone<Traits> >();
|
||||
}
|
||||
if(dialog.detect_sphere()){
|
||||
groups[4] = new Scene_group_item("Spheres");
|
||||
groups[4]->setRenderingMode(Points);
|
||||
shape_detection.add_shape_factory< CGAL::Shape_detection_3::Sphere<Traits> >();
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +235,6 @@ void Polyhedron_demo_point_set_shape_detection_plugin::on_actionDetect_triggered
|
|||
}
|
||||
|
||||
Scene_points_with_normal_item *point_item = new Scene_points_with_normal_item;
|
||||
point_item->point_set()->add_normal_map();
|
||||
|
||||
BOOST_FOREACH(std::size_t i, shape->indices_of_assigned_points())
|
||||
point_item->point_set()->insert(points->point(*(points->begin()+i)));
|
||||
|
|
@ -315,8 +319,8 @@ void Polyhedron_demo_point_set_shape_detection_plugin::on_actionDetect_triggered
|
|||
}
|
||||
else if (dynamic_cast<CGAL::Shape_detection_3::Plane<Traits> *>(shape.get()))
|
||||
{
|
||||
point_item->point_set()->add_normal_map();
|
||||
CGAL::Shape_detection_3::Plane<Traits> * plane = dynamic_cast<CGAL::Shape_detection_3::Plane<Traits> *>(shape.get());
|
||||
|
||||
//set normals for point_item to the plane's normal
|
||||
for(Point_set::iterator it = point_item->point_set()->begin(); it != point_item->point_set()->end(); ++it)
|
||||
point_item->point_set()->normal(*it) = plane->plane_normal();
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ void Polyhedron_demo_parameterization_plugin::parameterize(const Parameterizatio
|
|||
return;
|
||||
poly_item->polyhedron()->normalize_border();
|
||||
if(poly_item->polyhedron()->size_of_border_halfedges()==0)
|
||||
message->warning("The polyhedorn has no border, therefore the Parameterization cannot apply.");
|
||||
message->warning("The polyhedron has no border, therefore the Parameterization cannot apply.");
|
||||
Polyhedron* pMesh = poly_item->polyhedron();
|
||||
if(!pMesh)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1486,7 +1486,7 @@ void Scene_edit_polyhedron_item::draw_ROI_and_control_vertices(CGAL::Three::View
|
|||
//Draw the points
|
||||
if(d->ui_widget->ShowROICheckBox->isChecked()) {
|
||||
|
||||
if(!d->ui_widget->ShowAsSphereCheckBox->isChecked() || !viewer->extension_is_found) {
|
||||
if(!d->ui_widget->ShowAsSphereCheckBox->isChecked() || !viewer->isExtensionFound()) {
|
||||
|
||||
vaos[Scene_edit_polyhedron_item_priv::Roi_points]->bind();
|
||||
d->program = getShaderProgram(PROGRAM_NO_SELECTION);
|
||||
|
|
@ -1505,13 +1505,13 @@ void Scene_edit_polyhedron_item::draw_ROI_and_control_vertices(CGAL::Three::View
|
|||
}
|
||||
else
|
||||
{
|
||||
if(d->ui_widget->ShowAsSphereCheckBox->isChecked() && viewer->extension_is_found) {
|
||||
if(d->ui_widget->ShowAsSphereCheckBox->isChecked() && viewer->isExtensionFound()) {
|
||||
d->spheres->setVisible(false);
|
||||
Scene_group_item::draw(viewer);
|
||||
}
|
||||
}
|
||||
|
||||
if(!d->ui_widget->ShowAsSphereCheckBox->isChecked() || !viewer->extension_is_found) {
|
||||
if(!d->ui_widget->ShowAsSphereCheckBox->isChecked() || !viewer->isExtensionFound()) {
|
||||
vaos[Scene_edit_polyhedron_item_priv::Control_points]->bind();
|
||||
d->program = getShaderProgram(PROGRAM_NO_SELECTION);
|
||||
attribBuffers(viewer,PROGRAM_NO_SELECTION);
|
||||
|
|
|
|||
|
|
@ -65,6 +65,14 @@ Polyhedron_demo::Polyhedron_demo(int& argc, char **argv,
|
|||
mainWindow.setWindowTitle(main_window_title);
|
||||
mainWindow.show();
|
||||
|
||||
// On Apple, the first time the application is launched, the menus are unclicable, and
|
||||
// the only way you can fix it is to unfocus and re-focus the application.
|
||||
// This is a hack that makes the application lose the focus after it is started, to force the user
|
||||
// to re-focus it. (source : http://www.alecjacobson.com/weblog/?p=3910)
|
||||
#ifdef __APPLE__
|
||||
system("osascript -e 'tell application \"System Events\" "
|
||||
"to keystroke tab using {command down, shift down}'");
|
||||
#endif
|
||||
if(parser.isSet(use_meta)) {
|
||||
mainWindow.setAddKeyFrameKeyboardModifiers(::Qt::MetaModifier);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,14 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "Scene.h"
|
||||
|
||||
#include <CGAL/Three/Scene_item.h>
|
||||
#include <CGAL/Three/Scene_print_interface_item.h>
|
||||
#include <CGAL/Three/Scene_zoomable_item_interface.h>
|
||||
|
||||
#include <CGAL/Three/Scene_item.h>
|
||||
#include <CGAL/Three/Scene_print_item_interface.h>
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QMetaObject>
|
||||
#include <QString>
|
||||
|
|
@ -107,6 +111,7 @@ Scene::replaceItem(Scene::Item_id index, CGAL::Three::Scene_item* item, bool emi
|
|||
erase(children);
|
||||
}
|
||||
std::swap(m_entries[index], item);
|
||||
Q_EMIT newItem(index);
|
||||
if ( item->isFinite() && !item->isEmpty() &&
|
||||
m_entries[index]->isFinite() && !m_entries[index]->isEmpty() &&
|
||||
item->bbox()!=m_entries[index]->bbox() )
|
||||
|
|
@ -855,7 +860,7 @@ void Scene::moveRowDown()
|
|||
}
|
||||
}
|
||||
Scene::Item_id Scene::mainSelectionIndex() const {
|
||||
return selected_item;
|
||||
return (selectionIndices().size() == 1) ? selected_item : -1;
|
||||
}
|
||||
|
||||
QList<int> Scene::selectionIndices() const {
|
||||
|
|
@ -897,10 +902,9 @@ void Scene::itemChanged(Item_id i)
|
|||
|
||||
Q_EMIT dataChanged(this->createIndex(i, 0),
|
||||
this->createIndex(i, LastColumn));
|
||||
// Q_EMIT restoreCollapsedState();
|
||||
}
|
||||
|
||||
void Scene::itemChanged(CGAL::Three::Scene_item* /* item */)
|
||||
void Scene::itemChanged(CGAL::Three::Scene_item*)
|
||||
{
|
||||
Q_EMIT dataChanged(this->createIndex(0, 0),
|
||||
this->createIndex(m_entries.size() - 1, LastColumn));
|
||||
|
|
@ -1133,18 +1137,13 @@ void Scene::changeGroup(Scene_item *item, CGAL::Three::Scene_group_item *target_
|
|||
Q_EMIT updated();
|
||||
}
|
||||
|
||||
float Scene::get_bbox_length() const
|
||||
{
|
||||
return bbox().ymax()-bbox().ymin();
|
||||
}
|
||||
|
||||
void Scene::printPrimitiveId(QPoint point, CGAL::Three::Viewer_interface* viewer)
|
||||
{
|
||||
Scene_item *it = item(mainSelectionIndex());
|
||||
if(it)
|
||||
{
|
||||
//Only call printPrimitiveId if the item is a Scene_print_interface_item
|
||||
Scene_print_interface_item* item= dynamic_cast<Scene_print_interface_item*>(it);
|
||||
//Only call printPrimitiveId if the item is a Scene_print_item_interface
|
||||
Scene_print_item_interface* item= qobject_cast<Scene_print_item_interface*>(it);
|
||||
if(item)
|
||||
item->printPrimitiveId(point, viewer);
|
||||
}
|
||||
|
|
@ -1154,8 +1153,8 @@ void Scene::printPrimitiveIds(CGAL::Three::Viewer_interface* viewer)
|
|||
Scene_item *it = item(mainSelectionIndex());
|
||||
if(it)
|
||||
{
|
||||
//Only call printPrimitiveIds if the item is a Scene_print_interface_item
|
||||
Scene_print_interface_item* item= dynamic_cast<Scene_print_interface_item*>(it);
|
||||
//Only call printPrimitiveIds if the item is a Scene_print_item_interface
|
||||
Scene_print_item_interface* item= qobject_cast<Scene_print_item_interface*>(it);
|
||||
if(item)
|
||||
item->printPrimitiveIds(viewer);
|
||||
}
|
||||
|
|
@ -1164,8 +1163,8 @@ void Scene::updatePrimitiveIds(CGAL::Three::Viewer_interface* viewer, CGAL::Thre
|
|||
{
|
||||
if(it)
|
||||
{
|
||||
//Only call printPrimitiveIds if the item is a Scene_print_interface_item
|
||||
Scene_print_interface_item* item= dynamic_cast<Scene_print_interface_item*>(it);
|
||||
//Only call printPrimitiveIds if the item is a Scene_print_item_interface
|
||||
Scene_print_item_interface* item= qobject_cast<Scene_print_item_interface*>(it);
|
||||
if(item)
|
||||
{
|
||||
//As this function works as a toggle, the first call hides the ids and the second one shows them again,
|
||||
|
|
@ -1178,9 +1177,12 @@ void Scene::updatePrimitiveIds(CGAL::Three::Viewer_interface* viewer, CGAL::Thre
|
|||
bool Scene::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer)
|
||||
{
|
||||
CGAL::Three::Scene_item *i = item(mainSelectionIndex());
|
||||
if(i && i->visible())
|
||||
if(!i)
|
||||
return false;
|
||||
Scene_print_item_interface* spit= qobject_cast<Scene_print_item_interface*>(i);
|
||||
if(spit && i->visible())
|
||||
{
|
||||
bool res = i->testDisplayId(x,y,z, viewer);
|
||||
bool res = spit->testDisplayId(x,y,z, viewer);
|
||||
return res;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ class QMouseEvent;
|
|||
namespace GlSplat { class SplatRenderer; }
|
||||
namespace CGAL { namespace Three{ class Viewer_interface;}}
|
||||
|
||||
|
||||
//! This class is not supposed to be used by Plugins, but sometimes you may need access to
|
||||
//! peculiar signals or slots.
|
||||
class SCENE_EXPORT Scene :
|
||||
public QStandardItemModel, public CGAL::Three::Scene_interface, public CGAL::Three::Scene_draw_interface
|
||||
|
||||
|
|
@ -49,43 +50,19 @@ public:
|
|||
NumberOfColumns = LastColumn + 1};
|
||||
Scene(QObject* parent);
|
||||
~Scene();
|
||||
|
||||
//!Adds item to the items list, gives it an ID and
|
||||
//!updates the bounding box if needed.
|
||||
int addItem(CGAL::Three::Scene_item* item) Q_DECL_OVERRIDE;
|
||||
|
||||
void changeGroup(CGAL::Three::Scene_item* item, CGAL::Three::Scene_group_item* target_group) Q_DECL_OVERRIDE;
|
||||
//!Sets item as the item at index and calls @ref Scene_item#changed().
|
||||
//!If emit_item_about_to_be_destroyed is set to true, emits
|
||||
//!an itemAboutToBeDestroyed signal.
|
||||
CGAL::Three::Scene_item* replaceItem(int index, CGAL::Three::Scene_item* item, bool emit_item_about_to_be_destroyed = false) Q_DECL_OVERRIDE;
|
||||
/*! Deletes the item with the target index.
|
||||
* @returns the index of the polyhedra just before the
|
||||
* one that is erased, or just after. -1 if
|
||||
* the list is empty.
|
||||
*/
|
||||
Q_INVOKABLE int erase(int) Q_DECL_OVERRIDE;
|
||||
|
||||
/*! Deletes the items with the target indexes.
|
||||
* @returns the index of the polyhedra just before the
|
||||
* one that is erased, or just after. Returns -1 if
|
||||
* the list is empty.
|
||||
*/
|
||||
int erase(QList<int>);
|
||||
|
||||
/*! Duplicate a scene item.
|
||||
* @returns the ID of the new item (-1 on error).
|
||||
*/
|
||||
int erase(QList<int>) Q_DECL_OVERRIDE;
|
||||
int duplicate(int index) Q_DECL_OVERRIDE;
|
||||
|
||||
// Accessors (getters)
|
||||
//! @returns the number of items.
|
||||
int numberOfEntries() const Q_DECL_OVERRIDE;
|
||||
//! @returns the list of items.
|
||||
// returns the list of items.
|
||||
const QList<CGAL::Three::Scene_item*>& entries() const { return m_entries; }
|
||||
//! @returns the item at the target index.
|
||||
Q_INVOKABLE CGAL::Three::Scene_item* item(int) const Q_DECL_OVERRIDE;
|
||||
//! @returns the id of the target item.
|
||||
int item_id(CGAL::Three::Scene_item*) const Q_DECL_OVERRIDE;
|
||||
|
||||
//! \todo Replace Index based selection functionality with those
|
||||
|
|
@ -97,42 +74,21 @@ public:
|
|||
QList<CGAL::Three::Scene_item*> selectionB() const;
|
||||
///@}
|
||||
|
||||
//!@returns the currently selected item's index.
|
||||
int mainSelectionIndex() const Q_DECL_OVERRIDE;
|
||||
//!@returns the list of currently selected items indices.
|
||||
QList<int> selectionIndices() const Q_DECL_OVERRIDE;
|
||||
//!@returns the index of the Item_A
|
||||
int selectionAindex() const Q_DECL_OVERRIDE;
|
||||
//!@returns the index of the Item_B
|
||||
int selectionBindex() const Q_DECL_OVERRIDE;
|
||||
|
||||
/*! Is called by Viewer::initializeGL(). Allows all the initialization
|
||||
* of OpenGL code that needs a context.
|
||||
*/
|
||||
void initializeGL() Q_DECL_OVERRIDE;
|
||||
/*! Sets the screen coordinates of the currently picked point.*/
|
||||
void setPickedPixel(const QPoint &p) Q_DECL_OVERRIDE {picked_pixel = p;}
|
||||
/*! Is called by Viewer::draw(Viewer_interface*). Calls draw_aux(false, viewer).
|
||||
* @see draw_aux(bool with_names, Viewer_interface).*/
|
||||
void draw(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
||||
/*! Is called by Viewer::drawWithNames(Viewer_interface*). Calls draw_aux(true, viewer).
|
||||
* @see draw_aux(bool with_names, Viewer_interface).*/
|
||||
void drawWithNames(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
||||
/*! Manages the key events.
|
||||
* @returns true if the keyEvent executed well.
|
||||
*/
|
||||
bool keyPressEvent(QKeyEvent* e) Q_DECL_OVERRIDE;
|
||||
|
||||
void printPrimitiveId(QPoint point,
|
||||
CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
||||
void printPrimitiveIds(CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
||||
//!Re-computes the primitiveIds for `item`
|
||||
void updatePrimitiveIds(Viewer_interface *, Scene_item *item) Q_DECL_OVERRIDE;
|
||||
bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer) Q_DECL_OVERRIDE;
|
||||
//!@returns the scene bounding box
|
||||
Bbox bbox() const Q_DECL_OVERRIDE;
|
||||
float get_bbox_length() const Q_DECL_OVERRIDE;
|
||||
//!@returns the length of the bounding box's diagonal.
|
||||
double len_diagonal() const Q_DECL_OVERRIDE
|
||||
{
|
||||
Bbox box = bbox();
|
||||
|
|
@ -142,73 +98,69 @@ public:
|
|||
return std::sqrt(dx*dx + dy*dy + dz*dz);
|
||||
}
|
||||
|
||||
|
||||
// QStandardItemModel functions
|
||||
//Moves a name up in the Geometric Objects view
|
||||
void moveRowUp();
|
||||
//Moves a name down in the Geometric Objects view
|
||||
void moveRowDown();
|
||||
// QStandardItemModel functions
|
||||
//Defines the behavior when a name is drag-and-dropped in the Geometric Objects view
|
||||
bool dropMimeData(const QMimeData *, Qt::DropAction, int, int,
|
||||
const QModelIndex &parent) Q_DECL_OVERRIDE;
|
||||
//Contains the text and icons of an item in the Geometric Objects view
|
||||
QVariant data ( const QModelIndex & index,
|
||||
int role = ::Qt::DisplayRole ) const Q_DECL_OVERRIDE;
|
||||
//!@returns the type of data correspondind to the role.
|
||||
//@returns the type of data correspondind to the role.
|
||||
QVariant headerData ( int section, ::Qt::Orientation orientation,
|
||||
int role = ::Qt::DisplayRole ) const Q_DECL_OVERRIDE;
|
||||
//!@returns the flags for the item at the target index.
|
||||
//@returns the flags for the item at the target index.
|
||||
::Qt::ItemFlags flags ( const QModelIndex & index ) const Q_DECL_OVERRIDE;
|
||||
/*! Sets the column data for the target index. Returns false if index is not valid and
|
||||
* if role is not EditRole.*/
|
||||
// Sets the column data for the target index. Returns false if index is not valid and
|
||||
// if role is not EditRole.
|
||||
bool setData(const QModelIndex &index, const QVariant &value,
|
||||
int role) Q_DECL_OVERRIDE;
|
||||
|
||||
//Returns a list of all the items.
|
||||
QList<CGAL::Three::Scene_item*> item_entries() const ;
|
||||
// auxiliary public function for QMainWindow
|
||||
//!Selects the row at index i in the sceneView.
|
||||
//Selects the row at index i in the sceneView.
|
||||
QItemSelection createSelection(int i);
|
||||
//!Selects all the rows in the sceneView.
|
||||
//Selects all the rows in the sceneView.
|
||||
QItemSelection createSelectionAll();
|
||||
//Connects specific signals to a group when it is added and
|
||||
// gives a reference to the scene to it.
|
||||
void addGroup(Scene_group_item* group);
|
||||
|
||||
void zoomToPosition(QPoint point,
|
||||
CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
||||
|
||||
public Q_SLOTS:
|
||||
//!Specifies a group as Expanded for the view
|
||||
//!Specifies a group as Expanded for the Geometric Objects view
|
||||
void setExpanded(QModelIndex);
|
||||
//!Specifies a group as Collapsed for the view
|
||||
//!Specifies a group as Collapsed for the Geometric Objects view
|
||||
void setCollapsed(QModelIndex);
|
||||
/*!
|
||||
*Calls itemChanged() on the sender if it's an item.
|
||||
|
||||
*/
|
||||
//!Transmits a CGAL::Three::Scene_item::itemChanged() signal to the scene.
|
||||
void itemChanged();
|
||||
/*! Notifies the scene that the item at index i was modified.
|
||||
* Called by the items. Calls @ref Scene_item#changed().
|
||||
* This function is called by the items.*/
|
||||
void itemChanged(int i) Q_DECL_OVERRIDE;
|
||||
/*! Notifies the scene that the item was modified.
|
||||
* Calls @ref Scene_item#changed().
|
||||
* This function is called by the items.*/
|
||||
void itemChanged(CGAL::Three::Scene_item*) Q_DECL_OVERRIDE;
|
||||
//!Removes item from all the groups of the scene.
|
||||
//!Removes `item` from all the groups of the scene.
|
||||
void remove_item_from_groups(CGAL::Three::Scene_item* item);
|
||||
|
||||
void addGroup(Scene_group_item* group) Q_DECL_OVERRIDE;
|
||||
//!Re-organizes the sceneView.
|
||||
void redraw_model();
|
||||
//! Sets the selected item to the target index. Emits a signal to notify
|
||||
//! that a new item is now selected.
|
||||
//! that a new item is now selected, but does not update the Geometric Objects view.
|
||||
//! Used in intern and by the mainwindow
|
||||
void setSelectedItemIndex(int i)
|
||||
{
|
||||
selected_item = i;
|
||||
Q_EMIT itemIndexSelected(i);
|
||||
}
|
||||
//! Clears the current selection then sets the selected item to the target index.
|
||||
//! Used to update the selection in the QTreeView.
|
||||
void setSelectedItem(int i ) Q_DECL_OVERRIDE
|
||||
{
|
||||
selected_item = i;
|
||||
Q_EMIT selectionChanged(i);
|
||||
}
|
||||
|
||||
//! Sets the target item as selected and emits setSelectedItem for its index.
|
||||
//! Does the same as setSelectedItem(int)
|
||||
void setSelectedItem(CGAL::Three::Scene_item* item_to_select)
|
||||
{
|
||||
int i=0;
|
||||
|
|
@ -216,7 +168,7 @@ public Q_SLOTS:
|
|||
{
|
||||
if (item==item_to_select)
|
||||
{
|
||||
Q_EMIT setSelectedItem(i);
|
||||
setSelectedItem(i);
|
||||
break;
|
||||
}
|
||||
++i;
|
||||
|
|
@ -252,20 +204,28 @@ public Q_SLOTS:
|
|||
|
||||
Q_SIGNALS:
|
||||
//generated automatically by moc
|
||||
void itemPicked(const QModelIndex &);
|
||||
//! Emit this to mark `modelindex` as selected in the Geometric Objects view.
|
||||
void itemPicked(const QModelIndex& modelindex);
|
||||
//! Is emitted when a new item is added to the scene.
|
||||
void newItem(int);
|
||||
//! Emit this to re-compute the viewer's Bbox;
|
||||
void updated_bbox();
|
||||
//! Emit this to redraw the scene.
|
||||
void updated();
|
||||
void itemAboutToBeDestroyed(CGAL::Three::Scene_item*);
|
||||
//! Is emitted when `item` is erased.
|
||||
void itemAboutToBeDestroyed(CGAL::Three::Scene_item* item);
|
||||
//! Is emitted when the selection ray is changed.
|
||||
void selectionRay(double, double, double, double, double, double);
|
||||
//! Used to update the selected item in the QTreeView.
|
||||
//! Used to update the selected item in the Geometric Objects view.
|
||||
void selectionChanged(int i);
|
||||
//! Used when you don't want to update the sleectedItem in the QTreeView.
|
||||
//! Used when you don't want to update the selectedItem in the Geometric Objects view.
|
||||
void itemIndexSelected(int i);
|
||||
//! Emit this to reset the collapsed state of all groups after the Geometric Objects view has been redrawn.
|
||||
void restoreCollapsedState();
|
||||
//! Is emitted when draw() is finished.
|
||||
void drawFinished();
|
||||
private Q_SLOTS:
|
||||
//! Casts a selection ray and calls the item function select.
|
||||
// Casts a selection ray and calls the item function select.
|
||||
void setSelectionRay(double, double, double, double, double, double);
|
||||
void callDraw(){ QGLViewer* viewer = *QGLViewer::QGLViewerPool().begin(); viewer->update();}
|
||||
void s_itemAboutToBeDestroyed(CGAL::Three::Scene_item *);
|
||||
|
|
@ -274,19 +234,19 @@ private:
|
|||
* to its current renderingMode. If with_names is true, uses
|
||||
* the OpenGL mode GL_WITH_NAMES, essentially used for the picking.*/
|
||||
void draw_aux(bool with_names, CGAL::Three::Viewer_interface*);
|
||||
//! Re-draw the hierarchy of the view.
|
||||
// Re-draw the hierarchy of the view.
|
||||
void organize_items(CGAL::Three::Scene_item* item, QStandardItem *root, int loop);
|
||||
//! List of Scene_items.
|
||||
// List of Scene_items.
|
||||
typedef QList<CGAL::Three::Scene_item*> Entries;
|
||||
//!List containing all the scene_items.
|
||||
//List containing all the scene_items.
|
||||
Entries m_entries;
|
||||
//! Index of the currently selected item.
|
||||
// Index of the currently selected item.
|
||||
int selected_item;
|
||||
//!List of indices of the currently selected items.
|
||||
//List of indices of the currently selected items.
|
||||
QList<int> selected_items_list;
|
||||
//!Index of the item_A.
|
||||
//Index of the item_A.
|
||||
int item_A;
|
||||
//!Index of the item_B.
|
||||
//Index of the item_B.
|
||||
int item_B;
|
||||
bool picked;
|
||||
QPoint picked_pixel;
|
||||
|
|
@ -301,10 +261,9 @@ public:
|
|||
}; // end class Scene
|
||||
|
||||
class QAbstractProxyModel;
|
||||
/*!
|
||||
* \brief The SceneDelegate class
|
||||
* Handles the columns of the sceneView
|
||||
*/
|
||||
|
||||
//\brief The SceneDelegate class
|
||||
//Handles the columns of the sceneView
|
||||
class SCENE_EXPORT SceneDelegate : public QItemDelegate
|
||||
{
|
||||
public:
|
||||
|
|
@ -314,11 +273,11 @@ public:
|
|||
checkOffPixmap(":/cgal/icons/check-off.png")
|
||||
{
|
||||
}
|
||||
//! Handles the clicks on the sceneView
|
||||
// Handles the clicks on the sceneView
|
||||
bool editorEvent(QEvent *event, QAbstractItemModel *model,
|
||||
const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index);
|
||||
//! Draws the content of the sceneView
|
||||
// Draws the content of the sceneView
|
||||
void paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const;
|
||||
void setProxy(QAbstractProxyModel* p_proxy){
|
||||
|
|
|
|||
|
|
@ -1497,7 +1497,18 @@ void Scene_c3t3_item_priv::computeSpheres()
|
|||
if(red)
|
||||
c = QColor(Qt::red);
|
||||
else
|
||||
c = spheres->color().darker(250);
|
||||
c = spheres->color();
|
||||
switch(vit->in_dimension())
|
||||
{
|
||||
case 0:
|
||||
c = QColor::fromHsv((c.hue()+120)%360, c.saturation(),c.lightness(), c.alpha());
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
c.setRgb(50,50,50,255);
|
||||
}
|
||||
|
||||
const qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
Kernel::Point_3 center(vit->point().point().x()+offset.x,
|
||||
vit->point().point().y()+offset.y,
|
||||
|
|
@ -1658,6 +1669,7 @@ void Scene_c3t3_item::show_spheres(bool b)
|
|||
d->spheres->setName("Protecting spheres");
|
||||
d->spheres->setRenderingMode(Gouraud);
|
||||
connect(d->spheres, SIGNAL(destroyed()), this, SLOT(reset_spheres()));
|
||||
connect(d->spheres, SIGNAL(on_color_changed()), this, SLOT(on_spheres_color_changed()));
|
||||
scene->addItem(d->spheres);
|
||||
scene->changeGroup(d->spheres, this);
|
||||
lockChild(d->spheres);
|
||||
|
|
@ -2031,5 +2043,12 @@ void Scene_c3t3_item::itemAboutToBeDestroyed(Scene_item *item)
|
|||
}
|
||||
|
||||
}
|
||||
void Scene_c3t3_item::on_spheres_color_changed()
|
||||
{
|
||||
if(!d->spheres)
|
||||
return;
|
||||
d->spheres->clear_spheres();
|
||||
d->computeSpheres();
|
||||
}
|
||||
|
||||
#include "Scene_c3t3_item.moc"
|
||||
|
|
|
|||
|
|
@ -125,6 +125,8 @@ public:
|
|||
float getShrinkFactor() const;
|
||||
bool keyPressEvent(QKeyEvent *) Q_DECL_OVERRIDE;
|
||||
public Q_SLOTS:
|
||||
|
||||
void on_spheres_color_changed();
|
||||
void export_facets_in_complex();
|
||||
|
||||
void data_item_destroyed();
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ void Scene_group_item::moveUp(int i)
|
|||
children.move(i, i-1);
|
||||
}
|
||||
|
||||
void Scene_group_item::draw(CGAL::Three::Viewer_interface* viewer) const {
|
||||
void Scene_group_item::draw(CGAL::Three::Viewer_interface* viewer) const {
|
||||
if(viewer->inDrawWithNames() || already_drawn ) return;
|
||||
Q_FOREACH(Scene_item* child, children) {
|
||||
if(!child->visible()) continue;
|
||||
|
|
@ -141,10 +141,13 @@ void Scene_group_item::draw(CGAL::Three::Viewer_interface* viewer) const {
|
|||
}
|
||||
switch(child->renderingMode()) {
|
||||
case Points:
|
||||
case ShadedPoints:
|
||||
case PointsPlusNormals:
|
||||
child->drawPoints(viewer); break;
|
||||
default: break;
|
||||
}
|
||||
if(child->renderingMode() == Splatting)
|
||||
child->drawSplats(viewer); break;
|
||||
}
|
||||
already_drawn = true;
|
||||
}
|
||||
|
|
@ -170,6 +173,7 @@ void Scene_group_item::drawEdges(CGAL::Three::Viewer_interface* viewer) const
|
|||
}
|
||||
switch(child->renderingMode()) {
|
||||
case Points:
|
||||
case ShadedPoints:
|
||||
case PointsPlusNormals:
|
||||
child->drawPoints(viewer); break;
|
||||
default: break;
|
||||
|
|
@ -185,6 +189,7 @@ void Scene_group_item::drawPoints(CGAL::Three::Viewer_interface* viewer) const
|
|||
if(!child->visible()) continue;
|
||||
switch(child->renderingMode()) {
|
||||
case Points:
|
||||
case ShadedPoints:
|
||||
case PointsPlusNormals:
|
||||
child->drawPoints(viewer); break;
|
||||
default: break;
|
||||
|
|
|
|||
|
|
@ -221,18 +221,6 @@ QString CGAL::Three::Scene_item::computeStats(int )
|
|||
return QString();
|
||||
}
|
||||
|
||||
void CGAL::Three::Scene_item::printPrimitiveId(QPoint, CGAL::Three::Viewer_interface*)
|
||||
{
|
||||
}
|
||||
|
||||
void CGAL::Three::Scene_item::printPrimitiveIds(CGAL::Three::Viewer_interface*)const
|
||||
{
|
||||
}
|
||||
bool CGAL::Three::Scene_item::testDisplayId(double, double, double, CGAL::Three::Viewer_interface*)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#include <CGAL/double.h>
|
||||
|
||||
void CGAL::Three::Scene_item::compute_diag_bbox()const
|
||||
|
|
|
|||
|
|
@ -99,7 +99,9 @@ struct Scene_points_with_normal_item_priv
|
|||
enum VAOs {
|
||||
Edges=0,
|
||||
ThePoints,
|
||||
TheShadedPoints,
|
||||
Selected_points,
|
||||
Selected_shaded_points,
|
||||
NbOfVaos
|
||||
};
|
||||
enum VBOs {
|
||||
|
|
@ -119,8 +121,6 @@ struct Scene_points_with_normal_item_priv
|
|||
QSlider* point_Slider;
|
||||
mutable bool is_point_slider_moving;
|
||||
mutable std::vector<CGAL_data_type> positions_lines;
|
||||
mutable std::vector<CGAL_data_type> positions_points;
|
||||
mutable std::vector<CGAL_data_type> positions_selected_points;
|
||||
mutable std::vector<CGAL_data_type> normals;
|
||||
mutable std::vector<CGAL_data_type> positions_normals;
|
||||
mutable std::vector<CGAL_data_type> positions_selected_normals;
|
||||
|
|
@ -185,6 +185,7 @@ void Scene_points_with_normal_item_priv::initializeBuffers(CGAL::Three::Viewer_i
|
|||
{
|
||||
compute_normals_and_vertices();
|
||||
//vao for the edges
|
||||
if(item->has_normals())
|
||||
{
|
||||
program = item->getShaderProgram(Scene_points_with_normal_item::PROGRAM_NO_SELECTION, viewer);
|
||||
program->bind();
|
||||
|
|
@ -208,38 +209,28 @@ void Scene_points_with_normal_item_priv::initializeBuffers(CGAL::Three::Viewer_i
|
|||
}
|
||||
|
||||
item->vaos[Edges]->release();
|
||||
|
||||
nb_lines = positions_lines.size();
|
||||
positions_lines.resize(0);
|
||||
std::vector<CGAL_data_type>(positions_lines).swap(positions_lines);
|
||||
program->release();
|
||||
}
|
||||
//vao for the points
|
||||
{
|
||||
if(item->has_normals() && !(m_points->has_colors()))
|
||||
program = item->getShaderProgram(Scene_points_with_normal_item::PROGRAM_WITH_LIGHT, viewer);
|
||||
else
|
||||
program = item->getShaderProgram(Scene_points_with_normal_item::PROGRAM_NO_SELECTION, viewer);
|
||||
program = item->getShaderProgram(Scene_points_with_normal_item::PROGRAM_NO_SELECTION, viewer);
|
||||
program->bind();
|
||||
|
||||
item->vaos[ThePoints]->bind();
|
||||
item->buffers[Points_vertices].bind();
|
||||
item->buffers[Points_vertices].allocate(positions_points.data(),
|
||||
static_cast<int>(positions_points.size()*sizeof(CGAL_data_type)));
|
||||
program->enableAttributeArray("vertex");
|
||||
program->setAttributeBuffer("vertex",CGAL_GL_data_type,0,3);
|
||||
item->buffers[Points_vertices].release();
|
||||
|
||||
if(item->has_normals() && !(m_points->has_colors()))
|
||||
{
|
||||
item->buffers[Points_normals].bind();
|
||||
item->buffers[Points_normals].allocate(positions_normals.data(),
|
||||
static_cast<int>(positions_normals.size()*sizeof(CGAL_data_type)));
|
||||
program->enableAttributeArray("normals");
|
||||
program->setAttributeBuffer("normals",CGAL_GL_data_type,0,3);
|
||||
item->buffers[Points_normals].release();
|
||||
positions_normals.resize(0);
|
||||
std::vector<CGAL_data_type>(positions_normals).swap(positions_normals);
|
||||
item->buffers[Edges_vertices].bind();
|
||||
if(!item->has_normals()) {
|
||||
item->buffers[Edges_vertices].allocate(positions_lines.data(),
|
||||
static_cast<int>(positions_lines.size()*sizeof(CGAL_data_type)));
|
||||
}
|
||||
program->enableAttributeArray("vertex");
|
||||
if(item->has_normals())
|
||||
program->setAttributeBuffer("vertex",CGAL_GL_data_type,0,3,
|
||||
static_cast<int>(6*sizeof(CGAL_GL_data_type)));
|
||||
else
|
||||
program->setAttributeBuffer("vertex",CGAL_GL_data_type,0,3);
|
||||
item->buffers[Edges_vertices].release();
|
||||
if (!(colors_points.empty()))
|
||||
{
|
||||
item->buffers[Points_colors].bind();
|
||||
|
|
@ -253,43 +244,88 @@ void Scene_points_with_normal_item_priv::initializeBuffers(CGAL::Three::Viewer_i
|
|||
}
|
||||
|
||||
item->vaos[ThePoints]->release();
|
||||
nb_points = positions_points.size();
|
||||
positions_points.resize(0);
|
||||
std::vector<CGAL_data_type>(positions_points).swap(positions_points);
|
||||
program->release();
|
||||
if(item->has_normals())
|
||||
{
|
||||
program = item->getShaderProgram(Scene_points_with_normal_item::PROGRAM_WITH_LIGHT, viewer);
|
||||
item->vaos[TheShadedPoints]->bind();
|
||||
item->buffers[Edges_vertices].bind();
|
||||
program->enableAttributeArray("vertex");
|
||||
program->setAttributeBuffer("vertex",CGAL_GL_data_type,0,3,
|
||||
static_cast<int>(6*sizeof(CGAL_GL_data_type)));
|
||||
item->buffers[Edges_vertices].release();
|
||||
item->buffers[Points_normals].bind();
|
||||
item->buffers[Points_normals].allocate(positions_normals.data(),
|
||||
static_cast<int>(positions_normals.size()*sizeof(CGAL_data_type)));
|
||||
program->enableAttributeArray("normals");
|
||||
program->setAttributeBuffer("normals",CGAL_GL_data_type,0,3);
|
||||
item->buffers[Points_normals].release();
|
||||
positions_normals.resize(0);
|
||||
std::vector<CGAL_data_type>(positions_normals).swap(positions_normals);
|
||||
item->vaos[TheShadedPoints]->release();
|
||||
program->release();
|
||||
}
|
||||
|
||||
|
||||
if(item->has_normals())
|
||||
nb_points = positions_lines.size()/2;
|
||||
else
|
||||
nb_points = positions_lines.size();
|
||||
}
|
||||
//vao for the selected points
|
||||
{
|
||||
if(item->has_normals())
|
||||
program = item->getShaderProgram(Scene_points_with_normal_item::PROGRAM_WITH_LIGHT, viewer);
|
||||
else
|
||||
program = item->getShaderProgram(Scene_points_with_normal_item::PROGRAM_NO_SELECTION, viewer);
|
||||
program->bind();
|
||||
item->vaos[Selected_points]->bind();
|
||||
item->buffers[Selected_points_vertices].bind();
|
||||
item->buffers[Selected_points_vertices].allocate(positions_selected_points.data(),
|
||||
static_cast<int>(positions_selected_points.size()*sizeof(CGAL_data_type)));
|
||||
program->enableAttributeArray("vertex");
|
||||
program->setAttributeBuffer("vertex",CGAL_GL_data_type,0,3);
|
||||
item->buffers[Selected_points_vertices].release();
|
||||
program = item->getShaderProgram(Scene_points_with_normal_item::PROGRAM_NO_SELECTION, viewer);
|
||||
program->bind();
|
||||
|
||||
if(item->has_normals())
|
||||
{
|
||||
item->buffers[Selected_points_normals].bind();
|
||||
item->buffers[Selected_points_normals].allocate(positions_selected_normals.data(),
|
||||
static_cast<int>(positions_selected_normals.size()*sizeof(CGAL_data_type)));
|
||||
program->enableAttributeArray("normals");
|
||||
program->setAttributeBuffer("normals",CGAL_GL_data_type,0,3);
|
||||
item->buffers[Selected_points_normals].release();
|
||||
positions_selected_normals.resize(0);
|
||||
std::vector<CGAL_data_type>(positions_selected_normals).swap(positions_selected_normals);
|
||||
}
|
||||
item->vaos[Selected_points]->release();
|
||||
nb_selected_points = positions_selected_points.size();
|
||||
positions_selected_points.resize(0);
|
||||
std::vector<CGAL_data_type>(positions_selected_points).swap(positions_selected_points);
|
||||
item->vaos[Selected_points]->bind();
|
||||
item->buffers[Edges_vertices].bind();
|
||||
program->enableAttributeArray("vertex");
|
||||
if(!item->has_normals())
|
||||
{
|
||||
program->setAttributeBuffer("vertex",CGAL_GL_data_type,
|
||||
static_cast<int>( 3*(m_points->size()-m_points->nb_selected_points())*sizeof(CGAL_data_type) ),
|
||||
3,
|
||||
0);
|
||||
}
|
||||
else
|
||||
{
|
||||
program->setAttributeBuffer("vertex",CGAL_GL_data_type,
|
||||
static_cast<int>( 6*(m_points->size()-m_points->nb_selected_points())*sizeof(CGAL_data_type) ),
|
||||
3,
|
||||
static_cast<int>(6*sizeof(CGAL_GL_data_type)));
|
||||
}
|
||||
item->buffers[Edges_vertices].release();
|
||||
item->vaos[Selected_points]->release();
|
||||
program->release();
|
||||
if(item->has_normals())
|
||||
{
|
||||
program = item->getShaderProgram(Scene_points_with_normal_item::PROGRAM_WITH_LIGHT, viewer);
|
||||
item->vaos[Selected_shaded_points]->bind();
|
||||
item->buffers[Edges_vertices].bind();
|
||||
program->enableAttributeArray("vertex");
|
||||
program->setAttributeBuffer("vertex",CGAL_GL_data_type,
|
||||
static_cast<int>( 6*(m_points->size()-m_points->nb_selected_points())*sizeof(CGAL_data_type) ),
|
||||
3,
|
||||
static_cast<int>(6*sizeof(CGAL_GL_data_type)));
|
||||
|
||||
item->buffers[Edges_vertices].release();
|
||||
|
||||
item->buffers[Selected_points_normals].bind();
|
||||
item->buffers[Selected_points_normals].allocate(positions_selected_normals.data(),
|
||||
static_cast<int>(positions_selected_normals.size()*sizeof(CGAL_data_type)));
|
||||
program->enableAttributeArray("normals");
|
||||
program->setAttributeBuffer("normals",CGAL_GL_data_type,0,3);
|
||||
item->buffers[Selected_points_normals].release();
|
||||
positions_selected_normals.resize(0);
|
||||
std::vector<CGAL_data_type>(positions_selected_normals).swap(positions_selected_normals);
|
||||
|
||||
item->vaos[Selected_shaded_points]->release();
|
||||
program->release();
|
||||
}
|
||||
nb_selected_points = 3*m_points->nb_selected_points();
|
||||
}
|
||||
positions_lines.resize(0);
|
||||
positions_lines.shrink_to_fit();
|
||||
item->are_buffers_filled = true;
|
||||
}
|
||||
|
||||
|
|
@ -297,103 +333,86 @@ void Scene_points_with_normal_item_priv::compute_normals_and_vertices() const
|
|||
{
|
||||
const qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
positions_points.resize(0);
|
||||
positions_lines.resize(0);
|
||||
positions_selected_points.resize(0);
|
||||
normals.resize(0);
|
||||
positions_normals.resize(0);
|
||||
positions_selected_normals.resize(0);
|
||||
normals.resize(0);
|
||||
colors_points.resize(0);
|
||||
|
||||
positions_points.reserve(m_points->size() * 3);
|
||||
positions_lines.reserve(m_points->size() * 3 * 2);
|
||||
|
||||
//Shuffle container to allow quick display random points
|
||||
std::random_shuffle (m_points->begin(), m_points->first_selected());
|
||||
if (m_points->nb_selected_points() != 0)
|
||||
std::random_shuffle (m_points->first_selected(), m_points->end());
|
||||
|
||||
|
||||
//The points
|
||||
{
|
||||
// The *non-selected* points
|
||||
for (Point_set::const_iterator it = m_points->begin();
|
||||
it != m_points->first_selected(); ++ it)
|
||||
{
|
||||
positions_points.push_back(m_points->point(*it).x()+offset.x);
|
||||
positions_points.push_back(m_points->point(*it).y()+offset.y);
|
||||
positions_points.push_back(m_points->point(*it).z()+offset.z);
|
||||
}
|
||||
|
||||
// Draw *selected* points
|
||||
for (Point_set::const_iterator it = m_points->first_selected();
|
||||
it != m_points->end(); ++ it)
|
||||
{
|
||||
positions_selected_points.push_back(m_points->point(*it).x()+offset.x);
|
||||
positions_selected_points.push_back(m_points->point(*it).y()+offset.y);
|
||||
positions_selected_points.push_back(m_points->point(*it).z()+offset.z);
|
||||
}
|
||||
}
|
||||
|
||||
//The lines
|
||||
//if item has normals, points will be one point out of two in the lines data.
|
||||
//else points will be lines and lines discarded.
|
||||
double average_spacing = 0;
|
||||
double normal_length =0;
|
||||
double length_factor =0;
|
||||
if (item->has_normals())
|
||||
{
|
||||
positions_lines.reserve(m_points->size() * 6);
|
||||
positions_normals.reserve((m_points->size() - m_points->nb_selected_points()) * 3);
|
||||
positions_selected_normals.reserve(m_points->nb_selected_points() * 3);
|
||||
|
||||
// Store normals
|
||||
Kernel::Sphere_3 region_of_interest = m_points->region_of_interest();
|
||||
|
||||
#ifdef LINK_WITH_TBB
|
||||
typedef CGAL::Parallel_tag Concurrency_tag;
|
||||
typedef CGAL::Parallel_tag Concurrency_tag;
|
||||
#else
|
||||
typedef CGAL::Sequential_tag Concurrency_tag;
|
||||
typedef CGAL::Sequential_tag Concurrency_tag;
|
||||
#endif
|
||||
|
||||
double average_spacing = CGAL::compute_average_spacing<Concurrency_tag>(
|
||||
m_points->begin(), m_points->end(), m_points->point_map(),
|
||||
6);
|
||||
|
||||
double normal_length = (std::min)(average_spacing, std::sqrt(region_of_interest.squared_radius() / 1000.));
|
||||
double length_factor = 5.0/100*normal_Slider->value();
|
||||
for (Point_set_3<Kernel>::const_iterator it = m_points->begin(); it != m_points->first_selected(); ++it)
|
||||
{
|
||||
const Kernel::Point_3& p = m_points->point(*it);
|
||||
const Kernel::Vector_3& n = m_points->normal(*it);
|
||||
Point_set_3<Kernel>::Point q = p + normal_length * length_factor* n;
|
||||
positions_lines.push_back(p.x()+offset.x);
|
||||
positions_lines.push_back(p.y()+offset.y);
|
||||
positions_lines.push_back(p.z()+offset.z);
|
||||
|
||||
positions_lines.push_back(q.x()+offset.x);
|
||||
positions_lines.push_back(q.y()+offset.y);
|
||||
positions_lines.push_back(q.z()+offset.z);
|
||||
// Store normals
|
||||
Kernel::Sphere_3 region_of_interest = m_points->region_of_interest();
|
||||
positions_lines.reserve(m_points->size() * 6);
|
||||
positions_normals.reserve((m_points->size() - m_points->nb_selected_points()) * 3);
|
||||
positions_selected_normals.reserve(m_points->nb_selected_points() * 3);
|
||||
average_spacing = CGAL::compute_average_spacing<Concurrency_tag>(
|
||||
m_points->begin(), m_points->end(), m_points->point_map(),
|
||||
6);
|
||||
normal_length = (std::min)(average_spacing, std::sqrt(region_of_interest.squared_radius() / 1000.));
|
||||
length_factor = 5.0/100*normal_Slider->value();
|
||||
}
|
||||
else
|
||||
{
|
||||
positions_lines.reserve(m_points->size() * 3);
|
||||
}
|
||||
|
||||
|
||||
positions_normals.push_back(n.x());
|
||||
positions_normals.push_back(n.y());
|
||||
positions_normals.push_back(n.z());
|
||||
}
|
||||
for (Point_set_3<Kernel>::const_iterator it = m_points->first_selected(); it != m_points->end(); ++it)
|
||||
{
|
||||
const Kernel::Point_3& p = m_points->point(*it);
|
||||
const Kernel::Vector_3& n = m_points->normal(*it);
|
||||
Point_set_3<Kernel>::Point q = p + normal_length * length_factor* n;
|
||||
positions_lines.push_back(p.x()+offset.x);
|
||||
positions_lines.push_back(p.y()+offset.y);
|
||||
positions_lines.push_back(p.z()+offset.z);
|
||||
|
||||
positions_lines.push_back(q.x()+offset.x);
|
||||
positions_lines.push_back(q.y()+offset.y);
|
||||
positions_lines.push_back(q.z()+offset.z);
|
||||
for (Point_set_3<Kernel>::const_iterator it = m_points->begin(); it != m_points->first_selected(); ++it)
|
||||
{
|
||||
const Kernel::Point_3& p = m_points->point(*it);
|
||||
positions_lines.push_back(p.x()+offset.x);
|
||||
positions_lines.push_back(p.y()+offset.y);
|
||||
positions_lines.push_back(p.z()+offset.z);
|
||||
if(item->has_normals())
|
||||
{
|
||||
const Kernel::Vector_3& n = m_points->normal(*it);
|
||||
Point_set_3<Kernel>::Point q = p + normal_length * length_factor* n;
|
||||
positions_lines.push_back(q.x()+offset.x);
|
||||
positions_lines.push_back(q.y()+offset.y);
|
||||
positions_lines.push_back(q.z()+offset.z);
|
||||
|
||||
|
||||
positions_selected_normals.push_back(n.x());
|
||||
positions_selected_normals.push_back(n.y());
|
||||
positions_selected_normals.push_back(n.z());
|
||||
}
|
||||
positions_normals.push_back(n.x());
|
||||
positions_normals.push_back(n.y());
|
||||
positions_normals.push_back(n.z());
|
||||
}
|
||||
}
|
||||
for (Point_set_3<Kernel>::const_iterator it = m_points->first_selected(); it != m_points->end(); ++it)
|
||||
{
|
||||
const Kernel::Point_3& p = m_points->point(*it);
|
||||
positions_lines.push_back(p.x()+offset.x);
|
||||
positions_lines.push_back(p.y()+offset.y);
|
||||
positions_lines.push_back(p.z()+offset.z);
|
||||
if(item->has_normals())
|
||||
{
|
||||
const Kernel::Vector_3& n = m_points->normal(*it);
|
||||
Point_set_3<Kernel>::Point q = p + normal_length * length_factor* n;
|
||||
positions_lines.push_back(q.x()+offset.x);
|
||||
positions_lines.push_back(q.y()+offset.y);
|
||||
positions_lines.push_back(q.z()+offset.z);
|
||||
|
||||
|
||||
positions_selected_normals.push_back(n.x());
|
||||
positions_selected_normals.push_back(n.y());
|
||||
positions_selected_normals.push_back(n.z());
|
||||
}
|
||||
}
|
||||
//The colors
|
||||
if (m_points->has_colors())
|
||||
|
|
@ -673,34 +692,44 @@ void Scene_points_with_normal_item::drawPoints(CGAL::Three::Viewer_interface* vi
|
|||
if ((viewer->inFastDrawing () || d->isPointSliderMoving())
|
||||
&&((d->nb_points + d->nb_selected_points)/3 > limit_fast_drawing)) // arbitrary large value
|
||||
ratio_displayed = 3 * limit_fast_drawing / (double)(d->nb_points + d->nb_selected_points);
|
||||
vaos[Scene_points_with_normal_item_priv::ThePoints]->bind();
|
||||
|
||||
// POINTS
|
||||
if(has_normals() && renderingMode() == ShadedPoints)
|
||||
{
|
||||
vaos[Scene_points_with_normal_item_priv::TheShadedPoints]->bind();
|
||||
d->program=getShaderProgram(PROGRAM_WITH_LIGHT);
|
||||
attribBuffers(viewer,PROGRAM_WITH_LIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
vaos[Scene_points_with_normal_item_priv::ThePoints]->bind();
|
||||
d->program=getShaderProgram(PROGRAM_NO_SELECTION);
|
||||
attribBuffers(viewer,PROGRAM_NO_SELECTION);
|
||||
}
|
||||
d->program->bind();
|
||||
if (!(d->m_points->has_colors()))
|
||||
if (!(d->m_points->has_colors()) || renderingMode() == ShadedPoints)
|
||||
d->program->setAttributeValue("colors", this->color());
|
||||
if(renderingMode() != ShadedPoints)
|
||||
d->program->setAttributeValue("normals", QVector3D(0,0,0));
|
||||
viewer->glDrawArrays(GL_POINTS, 0,
|
||||
static_cast<GLsizei>(((std::size_t)(ratio_displayed * d->nb_points)/3)));
|
||||
vaos[Scene_points_with_normal_item_priv::ThePoints]->release();
|
||||
|
||||
if(has_normals() && renderingMode() == ShadedPoints)
|
||||
vaos[Scene_points_with_normal_item_priv::TheShadedPoints]->release();
|
||||
else
|
||||
vaos[Scene_points_with_normal_item_priv::ThePoints]->release();
|
||||
d->program->release();
|
||||
|
||||
|
||||
// SELECTED POINTS
|
||||
vaos[Scene_points_with_normal_item_priv::Selected_points]->bind();
|
||||
if(has_normals() && renderingMode() == ShadedPoints)
|
||||
{
|
||||
vaos[Scene_points_with_normal_item_priv::Selected_shaded_points]->bind();
|
||||
d->program=getShaderProgram(PROGRAM_WITH_LIGHT);
|
||||
attribBuffers(viewer,PROGRAM_WITH_LIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
vaos[Scene_points_with_normal_item_priv::Selected_points]->bind();
|
||||
d->program=getShaderProgram(PROGRAM_NO_SELECTION);
|
||||
attribBuffers(viewer,PROGRAM_NO_SELECTION);
|
||||
}
|
||||
|
|
@ -708,7 +737,11 @@ void Scene_points_with_normal_item::drawPoints(CGAL::Three::Viewer_interface* vi
|
|||
d->program->setAttributeValue("colors", QColor(255,0,0));
|
||||
viewer->glDrawArrays(GL_POINTS, 0,
|
||||
static_cast<GLsizei>(((std::size_t)(ratio_displayed * d->nb_selected_points)/3)));
|
||||
vaos[Scene_points_with_normal_item_priv::Selected_points]->release();
|
||||
|
||||
if(has_normals() && renderingMode() == ShadedPoints)
|
||||
vaos[Scene_points_with_normal_item_priv::Selected_shaded_points]->bind();
|
||||
else
|
||||
vaos[Scene_points_with_normal_item_priv::Selected_points]->release();
|
||||
d->program->release();
|
||||
viewer->glPointSize(point_size);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -863,11 +863,11 @@ Scene_polyhedron_item::~Scene_polyhedron_item()
|
|||
|
||||
//Clears the targeted Id
|
||||
if(d)
|
||||
v->textRenderer->removeText(d->targeted_id);
|
||||
v->textRenderer()->removeText(d->targeted_id);
|
||||
//Remove textitems
|
||||
if(textItems)
|
||||
{
|
||||
v->textRenderer->removeTextList(textItems);
|
||||
v->textRenderer()->removeTextList(textItems);
|
||||
delete textItems;
|
||||
textItems=NULL;
|
||||
}
|
||||
|
|
@ -975,8 +975,10 @@ Scene_polyhedron_item::load_obj(std::istream& in)
|
|||
bool
|
||||
Scene_polyhedron_item::save(std::ostream& out) const
|
||||
{
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
out.precision(17);
|
||||
out << *(d->poly);
|
||||
QApplication::restoreOverrideCursor();
|
||||
return (bool) out;
|
||||
}
|
||||
|
||||
|
|
@ -1680,7 +1682,7 @@ CGAL::Three::Scene_item::Header_data Scene_polyhedron_item::header() const
|
|||
|
||||
void Scene_polyhedron_item::printPrimitiveId(QPoint point, CGAL::Three::Viewer_interface *viewer)
|
||||
{
|
||||
TextRenderer *renderer = viewer->textRenderer;
|
||||
TextRenderer *renderer = viewer->textRenderer();
|
||||
renderer->getLocalTextItems().removeAll(d->targeted_id);
|
||||
renderer->removeTextList(textItems);
|
||||
textItems->clear();
|
||||
|
|
@ -1802,7 +1804,7 @@ void Scene_polyhedron_item::printPrimitiveId(QPoint point, CGAL::Three::Viewer_i
|
|||
|
||||
void Scene_polyhedron_item::printPrimitiveIds(CGAL::Three::Viewer_interface *viewer) const
|
||||
{
|
||||
TextRenderer *renderer = viewer->textRenderer;
|
||||
TextRenderer *renderer = viewer->textRenderer();
|
||||
|
||||
|
||||
if(!d->all_ids_displayed)
|
||||
|
|
@ -1868,7 +1870,7 @@ void Scene_polyhedron_item::printPrimitiveIds(CGAL::Three::Viewer_interface *vie
|
|||
d->all_ids_displayed = !d->all_ids_displayed;
|
||||
}
|
||||
|
||||
bool Scene_polyhedron_item::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer)
|
||||
bool Scene_polyhedron_item::testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer)const
|
||||
{
|
||||
const qglviewer::Vec offset = static_cast<CGAL::Three::Viewer_interface*>(QGLViewer::QGLViewerPool().first())->offset();
|
||||
Kernel::Point_3 src(x - offset.x,
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
#define SCENE_POLYHEDRON_ITEM_H
|
||||
|
||||
#include "Scene_polyhedron_item_config.h"
|
||||
#include <CGAL/Three/Scene_item.h>
|
||||
#include <CGAL/Three/TextRenderer.h>
|
||||
#include <CGAL/Three/Scene_print_item_interface.h>
|
||||
#include <CGAL/Three/Scene_item.h>
|
||||
#include <CGAL/Three/TextRenderer.h>
|
||||
#include "Polyhedron_type_fwd.h"
|
||||
#include "Polyhedron_type.h"
|
||||
#include <iostream>
|
||||
|
|
@ -23,7 +24,10 @@ struct Scene_polyhedron_item_priv;
|
|||
// This class represents a polyhedron in the OpenGL scene
|
||||
class SCENE_POLYHEDRON_ITEM_EXPORT Scene_polyhedron_item
|
||||
: public CGAL::Three::Scene_item,
|
||||
public CGAL::Three::Scene_zoomable_item_interface{
|
||||
public CGAL::Three::Scene_zoomable_item_interface,
|
||||
public CGAL::Three::Scene_print_item_interface{
|
||||
Q_INTERFACES(CGAL::Three::Scene_print_item_interface)
|
||||
Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PrintInterface/1.0")
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(CGAL::Three::Scene_zoomable_item_interface)
|
||||
Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.ZoomInterface/1.0")
|
||||
|
|
@ -126,9 +130,10 @@ public:
|
|||
//! @returns `true` if the item has multiple colors at the same time.
|
||||
bool isItemMulticolor();
|
||||
|
||||
void printPrimitiveId(QPoint point, CGAL::Three::Viewer_interface*viewer) Q_DECL_OVERRIDE;
|
||||
void printPrimitiveId(QPoint point, CGAL::Three::Viewer_interface*viewer)Q_DECL_OVERRIDE;
|
||||
void printPrimitiveIds(CGAL::Three::Viewer_interface*viewer) const Q_DECL_OVERRIDE;
|
||||
bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface*) Q_DECL_OVERRIDE;
|
||||
bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface*)const Q_DECL_OVERRIDE;
|
||||
|
||||
|
||||
//! @returns `true` if `f` is the first facet intersected by a raytracing
|
||||
bool intersect_face(double orig_x,
|
||||
|
|
|
|||
|
|
@ -269,3 +269,9 @@ void Scene_spheres_item::setToolTip(QString s)
|
|||
{
|
||||
d->tooltip = s;
|
||||
}
|
||||
|
||||
void Scene_spheres_item::setColor(QColor c)
|
||||
{
|
||||
CGAL::Three::Scene_item::setColor(c);
|
||||
this->on_color_changed();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,25 +27,27 @@ public:
|
|||
|
||||
~Scene_spheres_item();
|
||||
|
||||
bool isFinite() const { return false; }
|
||||
bool isEmpty() const { return false; }
|
||||
Scene_item* clone() const {return 0;}
|
||||
QString toolTip() const;
|
||||
bool supportsRenderingMode(RenderingMode m) const {
|
||||
bool isFinite() const Q_DECL_OVERRIDE{ return false; }
|
||||
bool isEmpty() const Q_DECL_OVERRIDE{ return false; }
|
||||
Scene_item* clone() const Q_DECL_OVERRIDE{return 0;}
|
||||
QString toolTip() const Q_DECL_OVERRIDE;
|
||||
bool supportsRenderingMode(RenderingMode m) const Q_DECL_OVERRIDE{
|
||||
return (m == Gouraud || m == Wireframe);
|
||||
}
|
||||
void compute_bbox() const { _bbox = Bbox(); }
|
||||
void compute_bbox() const Q_DECL_OVERRIDE{ _bbox = Bbox(); }
|
||||
void add_sphere(const CGAL::Sphere_3<Kernel> &sphere, CGAL::Color = CGAL::Color(120,120,120));
|
||||
void clear_spheres();
|
||||
void setPrecision(int prec);
|
||||
|
||||
void draw(CGAL::Three::Viewer_interface* viewer) const;
|
||||
void drawEdges(CGAL::Three::Viewer_interface* viewer) const;
|
||||
void invalidateOpenGLBuffers();
|
||||
void draw(CGAL::Three::Viewer_interface* viewer) const Q_DECL_OVERRIDE;
|
||||
void drawEdges(CGAL::Three::Viewer_interface* viewer) const Q_DECL_OVERRIDE;
|
||||
void invalidateOpenGLBuffers() Q_DECL_OVERRIDE;
|
||||
void computeElements() const;
|
||||
void setPlane(Kernel::Plane_3 p_plane);
|
||||
void setToolTip(QString s);
|
||||
|
||||
void setColor(QColor c) Q_DECL_OVERRIDE;
|
||||
Q_SIGNALS:
|
||||
void on_color_changed();
|
||||
protected:
|
||||
friend struct Scene_spheres_item_priv;
|
||||
Scene_spheres_item_priv* d;
|
||||
|
|
|
|||
|
|
@ -78,6 +78,9 @@ public:
|
|||
qglviewer::Vec BPoint;
|
||||
qglviewer::Vec offset;
|
||||
bool is_d_pressed;
|
||||
bool extension_is_found;
|
||||
|
||||
TextRenderer *textRenderer;
|
||||
/*!
|
||||
* \brief makeArrow creates an arrow and stores it in a struct of vectors.
|
||||
* \param R the radius of the arrow.
|
||||
|
|
@ -112,8 +115,8 @@ Viewer::Viewer(QWidget* parent, bool antialiasing)
|
|||
d->inDrawWithNames = false;
|
||||
d->shader_programs.resize(NB_OF_PROGRAMS);
|
||||
d->offset = qglviewer::Vec(0,0,0);
|
||||
textRenderer = new TextRenderer();
|
||||
connect( textRenderer, SIGNAL(sendMessage(QString,int)),
|
||||
d->textRenderer = new TextRenderer();
|
||||
connect( d->textRenderer, SIGNAL(sendMessage(QString,int)),
|
||||
this, SLOT(printMessage(QString,int)) );
|
||||
connect(&d->messageTimer, SIGNAL(timeout()), SLOT(hideMessage()));
|
||||
setShortcut(EXIT_VIEWER, 0);
|
||||
|
|
@ -233,19 +236,19 @@ void Viewer::initializeGL()
|
|||
if(!glDrawArraysInstanced)
|
||||
{
|
||||
qDebug()<<"glDrawArraysInstancedARB : extension not found. Spheres will be displayed as points.";
|
||||
extension_is_found = false;
|
||||
d->extension_is_found = false;
|
||||
}
|
||||
else
|
||||
extension_is_found = true;
|
||||
d->extension_is_found = true;
|
||||
|
||||
glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORARBPROC)this->context()->getProcAddress("glVertexAttribDivisorARB");
|
||||
if(!glDrawArraysInstanced)
|
||||
{
|
||||
qDebug()<<"glVertexAttribDivisorARB : extension not found. Spheres will be displayed as points.";
|
||||
extension_is_found = false;
|
||||
d->extension_is_found = false;
|
||||
}
|
||||
else
|
||||
extension_is_found = true;
|
||||
d->extension_is_found = true;
|
||||
|
||||
|
||||
setBackgroundColor(::Qt::white);
|
||||
|
|
@ -261,10 +264,7 @@ void Viewer::initializeGL()
|
|||
"attribute highp vec3 normal;\n"
|
||||
"attribute highp vec4 colors;\n"
|
||||
"uniform highp mat4 mvp_matrix;\n"
|
||||
"uniform highp mat4 ortho_mat;\n"
|
||||
"uniform highp mat4 mv_matrix; \n"
|
||||
"uniform highp float width; \n"
|
||||
"uniform highp float height; \n"
|
||||
"varying highp vec4 fP; \n"
|
||||
"varying highp vec3 fN; \n"
|
||||
"varying highp vec4 color; \n"
|
||||
|
|
@ -273,10 +273,7 @@ void Viewer::initializeGL()
|
|||
" color = colors; \n"
|
||||
" fP = mv_matrix * vertex; \n"
|
||||
" fN = mat3(mv_matrix)* normal; \n"
|
||||
" vec4 temp = vec4(mvp_matrix * vertex); \n"
|
||||
" vec4 ort = ortho_mat * vec4(width-150, height-150, 0,0); \n"
|
||||
" float ratio = width/height; \n"
|
||||
" gl_Position = ort +vec4(temp.x, temp.y, temp.z, 1.0); \n"
|
||||
" gl_Position = vec4(mvp_matrix * vertex); \n"
|
||||
"} \n"
|
||||
"\n"
|
||||
};
|
||||
|
|
@ -333,6 +330,7 @@ void Viewer::initializeGL()
|
|||
{
|
||||
std::cerr<<"adding fragment shader FAILED"<<std::endl;
|
||||
}
|
||||
d->rendering_program.bindAttributeLocation("colors", 1);
|
||||
if(!d->rendering_program.link())
|
||||
{
|
||||
//std::cerr<<"linking Program FAILED"<<std::endl;
|
||||
|
|
@ -389,6 +387,41 @@ void Viewer::initializeGL()
|
|||
}
|
||||
}
|
||||
|
||||
Viewer_impl::AxisData data;
|
||||
d->v_Axis.resize(0);
|
||||
d->n_Axis.resize(0);
|
||||
d->c_Axis.resize(0);
|
||||
data.vertices = &d->v_Axis;
|
||||
data.normals = &d->n_Axis;
|
||||
data.colors = &d->c_Axis;
|
||||
GLdouble l = 1.0;
|
||||
d->makeArrow(0.06,10, qglviewer::Vec(0,0,0),qglviewer::Vec(l,0,0),qglviewer::Vec(1,0,0), data);
|
||||
d->makeArrow(0.06,10, qglviewer::Vec(0,0,0),qglviewer::Vec(0,l,0),qglviewer::Vec(0,1,0), data);
|
||||
d->makeArrow(0.06,10, qglviewer::Vec(0,0,0),qglviewer::Vec(0,0,l),qglviewer::Vec(0,0,1), data);
|
||||
|
||||
d->rendering_program.bind();
|
||||
d->vao[0].bind();
|
||||
d->buffers[0].bind();
|
||||
d->buffers[0].allocate(d->v_Axis.data(), static_cast<int>(d->v_Axis.size()) * sizeof(float));
|
||||
d->rendering_program.enableAttributeArray("vertex");
|
||||
d->rendering_program.setAttributeBuffer("vertex",GL_FLOAT,0,3);
|
||||
d->buffers[0].release();
|
||||
|
||||
d->buffers[1].bind();
|
||||
d->buffers[1].allocate(d->n_Axis.data(), static_cast<int>(d->n_Axis.size() * sizeof(float)));
|
||||
d->rendering_program.enableAttributeArray("normal");
|
||||
d->rendering_program.setAttributeBuffer("normal",GL_FLOAT,0,3);
|
||||
d->buffers[1].release();
|
||||
|
||||
d->buffers[2].bind();
|
||||
d->buffers[2].allocate(d->c_Axis.data(), static_cast<int>(d->c_Axis.size() * sizeof(float)));
|
||||
d->rendering_program.enableAttributeArray("colors");
|
||||
d->rendering_program.setAttributeBuffer("colors",GL_FLOAT,0,3);
|
||||
d->buffers[2].release();
|
||||
d->vao[0].release();
|
||||
|
||||
d->rendering_program.release();
|
||||
|
||||
d->painter = new QPainter(this);
|
||||
}
|
||||
|
||||
|
|
@ -937,24 +970,17 @@ void Viewer::drawVisualHints()
|
|||
QGLViewer::drawVisualHints();
|
||||
if(d->axis_are_displayed)
|
||||
{
|
||||
d->rendering_program.bind();
|
||||
SetOrthoProjection(true);
|
||||
QMatrix4x4 mvpMatrix;
|
||||
double mat[16];
|
||||
QMatrix4x4 mvMatrix;
|
||||
camera()->getModelViewProjectionMatrix(mat);
|
||||
//nullifies the translation
|
||||
mat[12]=0;
|
||||
mat[13]=0;
|
||||
mat[14]=0;
|
||||
for(int i=0; i < 16; i++)
|
||||
{
|
||||
mvpMatrix.data()[i] = (float)mat[i];
|
||||
mvMatrix.data()[i] = camera()->orientation().inverse().matrix()[i];
|
||||
}
|
||||
camera()->getModelViewMatrix(mat);
|
||||
for(int i=0; i < 16; i++)
|
||||
{
|
||||
mvMatrix.data()[i] = (float)mat[i];
|
||||
}
|
||||
|
||||
mvpMatrix.ortho(-1,1,-1,1,-1,1);
|
||||
mvpMatrix = mvpMatrix*mvMatrix;
|
||||
SetOrthoProjection(false);
|
||||
QVector4D position(0.0f,0.0f,1.0f,1.0f );
|
||||
// define material
|
||||
QVector4D ambient;
|
||||
|
|
@ -979,7 +1005,6 @@ void Viewer::drawVisualHints()
|
|||
// Shininess
|
||||
shininess = 51.2f;
|
||||
|
||||
d->rendering_program.bind();
|
||||
d->rendering_program.setUniformValue("light_pos", position);
|
||||
d->rendering_program.setUniformValue("mvp_matrix", mvpMatrix);
|
||||
d->rendering_program.setUniformValue("mv_matrix", mvMatrix);
|
||||
|
|
@ -987,13 +1012,26 @@ void Viewer::drawVisualHints()
|
|||
d->rendering_program.setUniformValue("light_spec", specular);
|
||||
d->rendering_program.setUniformValue("light_amb", ambient);
|
||||
d->rendering_program.setUniformValue("spec_power", shininess);
|
||||
d->rendering_program.release();
|
||||
|
||||
d->vao[0].bind();
|
||||
d->rendering_program.bind();
|
||||
int viewport[4];
|
||||
int scissor[4];
|
||||
|
||||
// The viewport and the scissor are changed to fit the upper right
|
||||
// corner. Original values are saved.
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
glGetIntegerv(GL_SCISSOR_BOX, scissor);
|
||||
|
||||
// Axis viewport size, in pixels
|
||||
const int size = 100;
|
||||
glViewport(width()*devicePixelRatio()-size, height()*devicePixelRatio()-size, size, size);
|
||||
glScissor (width()*devicePixelRatio()-size, height()*devicePixelRatio()-size, size, size);
|
||||
glDrawArrays(GL_TRIANGLES, 0, static_cast<GLsizei>(d->v_Axis.size() / 3));
|
||||
d->rendering_program.release();
|
||||
// The viewport and the scissor are restored.
|
||||
glScissor(scissor[0],scissor[1],scissor[2],scissor[3]);
|
||||
glViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
|
||||
d->vao[0].release();
|
||||
d->rendering_program.release();
|
||||
}
|
||||
|
||||
if(d->distance_is_displayed)
|
||||
|
|
@ -1034,7 +1072,7 @@ void Viewer::drawVisualHints()
|
|||
TextItem *fps_text = new TextItem(20, int(1.5*((QApplication::font().pixelSize()>0)?QApplication::font().pixelSize():QApplication::font().pointSize())),0,d->fpsString,false, QFont(), Qt::gray);
|
||||
if(FPSIsDisplayed())
|
||||
{
|
||||
textRenderer->addText(fps_text);
|
||||
d->textRenderer->addText(fps_text);
|
||||
}
|
||||
//Prints the displayMessage
|
||||
QFont font = QFont();
|
||||
|
|
@ -1042,75 +1080,18 @@ void Viewer::drawVisualHints()
|
|||
TextItem *message_text = new TextItem(10 + fm.width(d->message)/2, height()-20, 0, d->message, false, QFont(), Qt::gray );
|
||||
if (d->_displayMessage)
|
||||
{
|
||||
textRenderer->addText(message_text);
|
||||
d->textRenderer->addText(message_text);
|
||||
}
|
||||
textRenderer->draw(this);
|
||||
d->textRenderer->draw(this);
|
||||
if(FPSIsDisplayed())
|
||||
textRenderer->removeText(fps_text);
|
||||
d->textRenderer->removeText(fps_text);
|
||||
if (d->_displayMessage)
|
||||
textRenderer->removeText(message_text);
|
||||
d->textRenderer->removeText(message_text);
|
||||
}
|
||||
|
||||
void Viewer::resizeGL(int w, int h)
|
||||
{
|
||||
QGLViewer::resizeGL(w,h);
|
||||
qglviewer::Vec dim = qglviewer::Vec(w,h, 0) ;
|
||||
GLdouble ortho[16];
|
||||
QMatrix4x4 orthoMatrix;
|
||||
ortho[0] = 1.0/width(); ortho[1] = 0; ortho[2] = 0; ortho[3] = -0.0;
|
||||
ortho[4] = 0; ortho[5] = 1.0/height(); ortho[6] = 0; ortho[7] = -0.0;
|
||||
ortho[8] = 0; ortho[9] = 0; ortho[10] = 2.0/(camera()->zNear()-camera()->zFar()); ortho[11] = -(camera()->zNear()+camera()->zFar())/(-camera()->zNear()+camera()->zFar());
|
||||
ortho[12] = 0; ortho[13] = 0; ortho[14] = 0; ortho[15] = 1;
|
||||
for(int i=0; i < 16; i++)
|
||||
{
|
||||
orthoMatrix.data()[i] = (float)ortho[i];
|
||||
}
|
||||
|
||||
QVector4D length(60,60,60, 1.0);
|
||||
length = orthoMatrix * length;
|
||||
Viewer_impl::AxisData data;
|
||||
d->v_Axis.resize(0);
|
||||
d->n_Axis.resize(0);
|
||||
d->c_Axis.resize(0);
|
||||
data.vertices = &d->v_Axis;
|
||||
data.normals = &d->n_Axis;
|
||||
data.colors = &d->c_Axis;
|
||||
double l = length.x()*w/h;
|
||||
d->makeArrow(0.06,10, qglviewer::Vec(0,0,0),qglviewer::Vec(l,0,0),qglviewer::Vec(1,0,0), data);
|
||||
d->makeArrow(0.06,10, qglviewer::Vec(0,0,0),qglviewer::Vec(0,l,0),qglviewer::Vec(0,1,0), data);
|
||||
d->makeArrow(0.06,10, qglviewer::Vec(0,0,0),qglviewer::Vec(0,0,l),qglviewer::Vec(0,0,1), data);
|
||||
|
||||
|
||||
d->vao[0].bind();
|
||||
d->buffers[0].bind();
|
||||
d->buffers[0].allocate(d->v_Axis.data(), static_cast<int>(d->v_Axis.size()) * sizeof(float));
|
||||
d->rendering_program.enableAttributeArray("vertex");
|
||||
d->rendering_program.setAttributeBuffer("vertex",GL_FLOAT,0,3);
|
||||
d->buffers[0].release();
|
||||
|
||||
d->buffers[1].bind();
|
||||
d->buffers[1].allocate(d->n_Axis.data(), static_cast<int>(d->n_Axis.size() * sizeof(float)));
|
||||
d->rendering_program.enableAttributeArray("normal");
|
||||
d->rendering_program.setAttributeBuffer("normal",GL_FLOAT,0,3);
|
||||
d->buffers[1].release();
|
||||
|
||||
d->buffers[2].bind();
|
||||
d->buffers[2].allocate(d->c_Axis.data(), static_cast<int>(d->c_Axis.size() * sizeof(float)));
|
||||
d->rendering_program.enableAttributeArray("colors");
|
||||
d->rendering_program.setAttributeBuffer("colors",GL_FLOAT,0,3);
|
||||
d->buffers[2].release();
|
||||
|
||||
d->rendering_program.release();
|
||||
d->vao[0].release();
|
||||
|
||||
|
||||
|
||||
d->rendering_program.bind();
|
||||
d->rendering_program.setUniformValue("width", (float)dim.x);
|
||||
d->rendering_program.setUniformValue("height", (float)dim.y);
|
||||
d->rendering_program.setUniformValue("ortho_mat", orthoMatrix);
|
||||
d->rendering_program.release();
|
||||
|
||||
}
|
||||
QOpenGLShaderProgram* Viewer::declare_program(int name,
|
||||
const char* v_shader,
|
||||
|
|
@ -1336,7 +1317,7 @@ void Viewer_impl::showDistance(QPoint pixel)
|
|||
|
||||
distance_text.append(centerCoord);
|
||||
Q_FOREACH(TextItem* ti, distance_text)
|
||||
viewer->textRenderer->addText(ti);
|
||||
textRenderer->addText(ti);
|
||||
Q_EMIT(viewer->sendMessage(QString("First point : A(%1,%2,%3), second point : B(%4,%5,%6), distance between them : %7")
|
||||
.arg(APoint.x-offset.x)
|
||||
.arg(APoint.y-offset.y)
|
||||
|
|
@ -1354,7 +1335,7 @@ void Viewer_impl::clearDistancedisplay()
|
|||
distance_is_displayed = false;
|
||||
Q_FOREACH(TextItem* ti, distance_text)
|
||||
{
|
||||
viewer->textRenderer->removeText(ti);
|
||||
textRenderer->removeText(ti);
|
||||
delete ti;
|
||||
}
|
||||
distance_text.clear();
|
||||
|
|
@ -1607,4 +1588,14 @@ void Viewer::updateIds(CGAL::Three::Scene_item * item)
|
|||
d->scene->updatePrimitiveIds(this, item);
|
||||
d->scene->updatePrimitiveIds(this, item);
|
||||
}
|
||||
|
||||
TextRenderer* Viewer::textRenderer()
|
||||
{
|
||||
return d->textRenderer;
|
||||
}
|
||||
|
||||
bool Viewer::isExtensionFound()
|
||||
{
|
||||
return d->extension_is_found;
|
||||
}
|
||||
#include "Viewer.moc"
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@ class QKeyEvent;
|
|||
class QContextMenuEvent;
|
||||
|
||||
class Viewer_impl;
|
||||
//!The viewer class. Deals with all the openGL rendering and the mouse/keyboard events.
|
||||
//! The viewer class. Deals with all the openGL rendering and the mouse/keyboard events.
|
||||
//! It should not be needed in the plugin.
|
||||
class VIEWER_EXPORT Viewer : public CGAL::Three::Viewer_interface {
|
||||
|
||||
Q_OBJECT
|
||||
|
|
@ -35,92 +36,112 @@ class VIEWER_EXPORT Viewer : public CGAL::Three::Viewer_interface {
|
|||
public:
|
||||
Viewer(QWidget * parent, bool antialiasing = false);
|
||||
~Viewer();
|
||||
bool testDisplayId(double, double, double);
|
||||
void updateIds(CGAL::Three::Scene_item *);
|
||||
// overload several QGLViewer virtual functions
|
||||
bool testDisplayId(double, double, double)Q_DECL_OVERRIDE;
|
||||
void updateIds(CGAL::Three::Scene_item *)Q_DECL_OVERRIDE;
|
||||
//! overload several QGLViewer virtual functions
|
||||
//! Draws the scene.
|
||||
void draw();
|
||||
void draw()Q_DECL_OVERRIDE;
|
||||
//!This step happens after draw(). It is here that all the useful information is displayed, like the axis system or the informative text.
|
||||
void drawVisualHints();
|
||||
void drawVisualHints()Q_DECL_OVERRIDE;
|
||||
//! Deprecated. Does the same as draw().
|
||||
void fastDraw();
|
||||
void fastDraw()Q_DECL_OVERRIDE;
|
||||
bool isExtensionFound()Q_DECL_OVERRIDE;
|
||||
//! Initializes the OpenGL functions and sets the backGround color.
|
||||
void initializeGL();
|
||||
void initializeGL()Q_DECL_OVERRIDE;
|
||||
//! Draws the scene "with names" to allow picking.
|
||||
void drawWithNames();
|
||||
void drawWithNames()Q_DECL_OVERRIDE;
|
||||
/*! Uses the parameter pixel's coordinates to get the corresponding point
|
||||
* in the World frame. If this point is found, emits selectedPoint, selected,
|
||||
* and selectionRay signals.
|
||||
*/
|
||||
void postSelection(const QPoint&);
|
||||
void postSelection(const QPoint&)Q_DECL_OVERRIDE;
|
||||
//! Sets the picking matrix to allow the picking.
|
||||
void beginSelection(const QPoint &point);
|
||||
void beginSelection(const QPoint &point)Q_DECL_OVERRIDE;
|
||||
//! Sets the pick matrix to Identity once the picking is done.
|
||||
void endSelection(const QPoint &point);
|
||||
void endSelection(const QPoint &point)Q_DECL_OVERRIDE;
|
||||
//! Sets the scene for the viewer.
|
||||
void setScene(CGAL::Three::Scene_draw_interface* scene);
|
||||
void setScene(CGAL::Three::Scene_draw_interface* scene)Q_DECL_OVERRIDE;
|
||||
//! @returns the antialiasing state.
|
||||
bool antiAliasing() const;
|
||||
bool antiAliasing() const Q_DECL_OVERRIDE;
|
||||
//! @returns the fastDrawing state.
|
||||
bool inFastDrawing() const;
|
||||
bool inFastDrawing() const Q_DECL_OVERRIDE;
|
||||
//! Implementation of `Viewer_interface::inDrawWithNames()`
|
||||
bool inDrawWithNames() const;
|
||||
bool inDrawWithNames() const Q_DECL_OVERRIDE;
|
||||
//! Implementation of `Viewer_interface::attribBuffers()`
|
||||
void attribBuffers(int program_name) const;
|
||||
void attribBuffers(int program_name) const Q_DECL_OVERRIDE;
|
||||
//! Implementation of `Viewer_interface::getShaderProgram()`
|
||||
QOpenGLShaderProgram* getShaderProgram(int name) const;
|
||||
QOpenGLShaderProgram* getShaderProgram(int name) const Q_DECL_OVERRIDE;
|
||||
//!Declares a program names `name`, using `v_shader` as vertex shader and `f_shader` as fragment shader.
|
||||
QOpenGLShaderProgram* declare_program(int name,
|
||||
const char* v_shader,
|
||||
const char* f_shader)const;
|
||||
QPainter* getPainter();
|
||||
QPainter* getPainter()Q_DECL_OVERRIDE;
|
||||
void saveSnapshot(bool , bool overwrite = false);
|
||||
void setOffset(qglviewer::Vec offset);
|
||||
qglviewer::Vec offset()const;
|
||||
qglviewer::Vec offset()const Q_DECL_OVERRIDE;
|
||||
void setSceneBoundingBox(const qglviewer::Vec &min, const qglviewer::Vec &max);
|
||||
|
||||
TextRenderer* textRenderer() Q_DECL_OVERRIDE;
|
||||
|
||||
Q_SIGNALS:
|
||||
void sendMessage(QString);
|
||||
public Q_SLOTS:
|
||||
//! Sets the antialiasing to true or false.
|
||||
void setAntiAliasing(bool b);
|
||||
void setAntiAliasing(bool b) Q_DECL_OVERRIDE;
|
||||
//! If b is true, facets will be ligted from both internal and external sides.
|
||||
//! If b is false, only the side that is exposed to the light source will be lighted.
|
||||
void setTwoSides(bool b);
|
||||
void setTwoSides(bool b) Q_DECL_OVERRIDE;
|
||||
void SetOrthoProjection( bool b);
|
||||
//! If b is true, some items are displayed in a simplified version when moving the camera.
|
||||
//! If b is false, items display is never altered, even when moving.
|
||||
void setFastDrawing(bool b);
|
||||
void setFastDrawing(bool b) Q_DECL_OVERRIDE;
|
||||
//! Makes the camera turn around.
|
||||
void turnCameraBy180Degres();
|
||||
void turnCameraBy180Degres() Q_DECL_OVERRIDE;
|
||||
//! @returns a QString containing the position and orientation of the camera.
|
||||
QString dumpCameraCoordinates();
|
||||
QString dumpCameraCoordinates() Q_DECL_OVERRIDE;
|
||||
//!Moves the camera to the new coordinates (position and orientation) through an animation.
|
||||
bool moveCameraToCoordinates(QString,
|
||||
float animation_duration = 0.5f);
|
||||
float animation_duration = 0.5f) Q_DECL_OVERRIDE;
|
||||
//!Makes the Viewer display a message
|
||||
void printMessage(QString message, int ms_delay );
|
||||
void displayMessage(const QString &_message, int delay);
|
||||
void displayMessage(const QString &_message){displayMessage(_message, 2000);}
|
||||
void hideMessage();
|
||||
void setBindingSelect() Q_DECL_OVERRIDE
|
||||
{
|
||||
#if QGLVIEWER_VERSION >= 0x020501
|
||||
setMouseBinding(::Qt::ShiftModifier, ::Qt::LeftButton, SELECT);
|
||||
#else
|
||||
setMouseBinding(::Qt::SHIFT + ::Qt::LeftButton, SELECT);
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void setNoBinding() Q_DECL_OVERRIDE
|
||||
{
|
||||
#if QGLVIEWER_VERSION >= 0x020501
|
||||
setMouseBinding(::Qt::ShiftModifier, ::Qt::LeftButton, NO_CLICK_ACTION);
|
||||
#else
|
||||
setMouseBinding(::Qt::SHIFT + ::Qt::LeftButton, NO_CLICK_ACTION);
|
||||
#endif
|
||||
}
|
||||
|
||||
protected:
|
||||
void postDraw();
|
||||
void paintEvent(QPaintEvent *);
|
||||
void paintGL();
|
||||
void postDraw()Q_DECL_OVERRIDE;
|
||||
void paintEvent(QPaintEvent *)Q_DECL_OVERRIDE;
|
||||
void paintGL()Q_DECL_OVERRIDE;
|
||||
|
||||
//!Defines the behaviour for the mouse press events
|
||||
void mousePressEvent(QMouseEvent*);
|
||||
void wheelEvent(QWheelEvent *);
|
||||
void mousePressEvent(QMouseEvent*)Q_DECL_OVERRIDE;
|
||||
void wheelEvent(QWheelEvent *)Q_DECL_OVERRIDE;
|
||||
//!Defines the behaviour for the key press events
|
||||
void keyPressEvent(QKeyEvent*);
|
||||
void keyPressEvent(QKeyEvent*)Q_DECL_OVERRIDE;
|
||||
//!Deal with context menu events
|
||||
void contextMenuEvent(QContextMenuEvent*);
|
||||
void contextMenuEvent(QContextMenuEvent*)Q_DECL_OVERRIDE;
|
||||
//!Defines the behaviour for the key release events
|
||||
void keyReleaseEvent(QKeyEvent *);
|
||||
void keyReleaseEvent(QKeyEvent *)Q_DECL_OVERRIDE;
|
||||
|
||||
|
||||
void resizeGL(int w, int h);
|
||||
void resizeGL(int w, int h)Q_DECL_OVERRIDE;
|
||||
|
||||
protected:
|
||||
friend class Viewer_impl;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ uniform bool is_selected;
|
|||
void main(void) {
|
||||
if(color.w<0)
|
||||
{
|
||||
vec4 my_color = vec4(color.xzy, 1.);
|
||||
vec4 my_color = vec4(color.xyz, 1.);
|
||||
highp vec3 L = light_pos.xyz - fP.xyz;
|
||||
highp vec3 V = -fP.xyz;
|
||||
highp vec3 N;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ struct Time_stamper
|
|||
static std::size_t time_stamp(const T* pt)
|
||||
{
|
||||
if(pt == NULL){
|
||||
return 0;
|
||||
return std::size_t(-1);
|
||||
}
|
||||
return pt->time_stamp();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@
|
|||
#include <string>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
#include <boost/array.hpp>
|
||||
|
|
|
|||
|
|
@ -200,11 +200,17 @@ The main advantage is to decrease from log to constant the complexity for access
|
|||
|
||||
\cgalExample{Surface_mesh_segmentation/segmentation_with_facet_ids_example.cpp}
|
||||
|
||||
|
||||
\subsection Surface_mesh_segmentationUsingapolyhedron Using a Surface_mesh
|
||||
When using a `Surface_mesh`, you can use the built-in property mechanism.
|
||||
|
||||
\cgalExample{Surface_mesh_segmentation/segmentation_from_sdf_values_SM_example.cpp}
|
||||
|
||||
\subsection Surface_mesh_segmentationIndependantmeshpersegment Independant TriangleMesh per Segment
|
||||
It is possible to consider each segment as an independant triangle mesh, like in the following example, where the area of each segment is computed.
|
||||
|
||||
\cgalExample{Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp}
|
||||
|
||||
<BR>
|
||||
\section Performances Performances
|
||||
<!-- \subsection SMSRuntime Runtime of the functions sdf_values() and segmentation_from_sdf_values() -->
|
||||
|
|
|
|||
|
|
@ -3,3 +3,4 @@
|
|||
/// \example Surface_mesh_segmentation/segmentation_from_sdf_values_SM_example.cpp
|
||||
/// \example Surface_mesh_segmentation/segmentation_via_sdf_values_example.cpp
|
||||
/// \example Surface_mesh_segmentation/segmentation_with_facet_ids_example.cpp
|
||||
/// \example Surface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp
|
||||
|
|
|
|||
|
|
@ -64,9 +64,12 @@ create_single_source_cgal_program( "segmentation_from_sdf_values_example.cpp" )
|
|||
create_single_source_cgal_program( "segmentation_via_sdf_values_example.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "segmentation_with_facet_ids_example.cpp" )
|
||||
|
||||
create_single_source_cgal_program( "segmentation_from_sdf_values_SM_example.cpp")
|
||||
create_single_source_cgal_program( "segmentation_from_sdf_values_LCC_example.cpp")
|
||||
|
||||
create_single_source_cgal_program( "extract_segmentation_into_mesh_example.cpp")
|
||||
|
||||
if(OpenMesh_FOUND)
|
||||
create_single_source_cgal_program( "segmentation_from_sdf_values_OpenMesh_example.cpp" )
|
||||
target_link_libraries( segmentation_from_sdf_values_OpenMesh_example ${OPENMESH_LIBRARIES} )
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Surface_mesh.h>
|
||||
#include <CGAL/boost/graph/Face_filtered_graph.h>
|
||||
#include <CGAL/Polygon_mesh_processing/measure.h>
|
||||
#include <CGAL/boost/graph/copy_face_graph.h>
|
||||
#include <CGAL/mesh_segmentation.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
|
||||
typedef CGAL::Surface_mesh<Kernel::Point_3> SM;
|
||||
typedef boost::graph_traits<SM>::face_descriptor face_descriptor;
|
||||
|
||||
int main(int argc, char** argv )
|
||||
{
|
||||
SM mesh;
|
||||
if (argc==2){
|
||||
std::ifstream input(argv[1]);
|
||||
input >> mesh;
|
||||
} else {
|
||||
std::ifstream cactus("data/cactus.off");
|
||||
cactus >> mesh;
|
||||
}
|
||||
typedef SM::Property_map<face_descriptor,double> Facet_double_map;
|
||||
Facet_double_map sdf_property_map;
|
||||
|
||||
sdf_property_map = mesh.add_property_map<face_descriptor,double>("f:sdf").first;
|
||||
|
||||
CGAL::sdf_values(mesh, sdf_property_map);
|
||||
|
||||
// create a property-map for segment-ids
|
||||
typedef SM::Property_map<face_descriptor, std::size_t> Facet_int_map;
|
||||
Facet_int_map segment_property_map = mesh.add_property_map<face_descriptor,std::size_t>("f:sid").first;;
|
||||
|
||||
// segment the mesh using default parameters for number of levels, and smoothing lambda
|
||||
// Any other scalar values can be used instead of using SDF values computed using the CGAL function
|
||||
std::size_t number_of_segments = CGAL::segmentation_from_sdf_values(mesh, sdf_property_map, segment_property_map);
|
||||
|
||||
typedef CGAL::Face_filtered_graph<SM> Filtered_graph;
|
||||
//print area of each segment and then put it in a Mesh and print it in an OFF file
|
||||
Filtered_graph segment_mesh(mesh, 0, segment_property_map);
|
||||
for(std::size_t id = 0; id < number_of_segments; ++id)
|
||||
{
|
||||
if(id > 0)
|
||||
segment_mesh.set_selected_faces(id, segment_property_map);
|
||||
std::cout << "Segment "<<id<<"'s area is : "<<CGAL::Polygon_mesh_processing::area(segment_mesh)<<std::endl;
|
||||
SM out;
|
||||
CGAL::copy_face_graph(segment_mesh, out);
|
||||
std::ostringstream oss;
|
||||
oss << "Segment_" << id<<".off";
|
||||
std::ofstream os(oss.str().data());
|
||||
os<<out;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ The concept `StopPredicate` describes the requirements for the predicate which i
|
|||
|
||||
\cgalHasModel `CGAL::Surface_mesh_simplification::Count_stop_predicate<ECM>`
|
||||
\cgalHasModel `CGAL::Surface_mesh_simplification::Count_ratio_stop_predicate<ECM>`
|
||||
\cgalHasModel `CGAL::Surface_mesh_simplification::Edge_length_stop_predicate<FT>`
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,11 @@ test_directory()
|
|||
START=`date +%s`
|
||||
run_local_cgal_test &
|
||||
|
||||
if wait_for_process "$!" "1200" "5"
|
||||
TIME_PERIOD=1200
|
||||
if [ "$1" = "Polyhedron_Demo" ]; then
|
||||
TIME_PERIOD=2400
|
||||
fi
|
||||
if wait_for_process "$!" "$TIME_PERIOD" "5"
|
||||
then
|
||||
if [ -f test_failure ] ; then
|
||||
exit_failure=`cat test_failure`
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
#include "CGAL/Three/Scene_group_item.h"
|
||||
#include "Scene_plane_item.h"
|
||||
|
||||
//This plugin crates an action in Operations that displays "Hello World" in the 'console' dockwidet.
|
||||
//This plugin crates an action in Operations that displays the name of the selected item,
|
||||
//adds a scene_plane_item to the scene, and adds the selected item and the plane to a new group.
|
||||
class BasicItemPlugin :
|
||||
public QObject,
|
||||
public CGAL::Three::Polyhedron_demo_plugin_interface
|
||||
|
|
@ -19,27 +20,27 @@ class BasicItemPlugin :
|
|||
public:
|
||||
//! [applicable]
|
||||
//This plugin is only applicable if there is exactly one selected item.
|
||||
bool applicable(QAction*) const
|
||||
bool applicable(QAction*) const Q_DECL_OVERRIDE
|
||||
{
|
||||
return scene->selectionIndices().size() ==1;
|
||||
}
|
||||
//! [applicable]
|
||||
//the list of the actions of the plugin.
|
||||
QList<QAction*> actions() const
|
||||
QList<QAction*> actions() const Q_DECL_OVERRIDE
|
||||
{
|
||||
return _actions;
|
||||
}
|
||||
//this acts like a constructor for the plugin. It gets the references to the mainwindow and the scene, and connects the action.
|
||||
void init(QMainWindow* mw, CGAL::Three::Scene_interface* sc, Messages_interface* mi)
|
||||
void init(QMainWindow* mw, CGAL::Three::Scene_interface* sc, Messages_interface* mi) Q_DECL_OVERRIDE
|
||||
{
|
||||
//gets the reference to the message interface, to display text in the console widget
|
||||
this->messageInterface = mi;
|
||||
//get the references
|
||||
this->scene = sc;
|
||||
this->mw = mainWindow;
|
||||
this->mw = mw;
|
||||
|
||||
//creates the action
|
||||
QAction *actionHelloWorld= new QAction(QString("Hello World"), mw);
|
||||
QAction *actionHelloWorld= new QAction(QString("Create a group"), mw);
|
||||
//specifies the subMenu
|
||||
actionHelloWorld->setProperty("submenuName", "Basic");
|
||||
//links the action
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ Change the value of EXAMPLE_COMPLEXITY in the first line to change the behavior
|
|||
- 1 : pops-up a simple dialog asking to enter an integer , then prints it in the Info and console widgets
|
||||
- 2 : pops-up a little more elaborated dialog asking to enter an integer , then prints it in the Info and console widgets if it was indeed an integer, else pops-up an error message box.
|
||||
*/
|
||||
#define EXAMPLE_COMPLEXITY 2
|
||||
#include "ui_Basic_dialog_plugin.h"
|
||||
#define EXAMPLE_COMPLEXITY 0
|
||||
#include "ui_Basic_dialog.h"
|
||||
//! [headers_plugin]
|
||||
#include <CGAL/Three/Polyhedron_demo_plugin_interface.h>
|
||||
#include <QApplication>
|
||||
|
|
@ -33,7 +33,7 @@ public:
|
|||
//! [dialog_plugin]
|
||||
//! [opening_plugin]
|
||||
|
||||
//This plugin crates an action in Operations that displays "Hello World" in the 'console' dockwidet.
|
||||
//This plugin creates an action in Operations depending on EXAMPLE_COMPLEXITY.
|
||||
class BasicPlugin :
|
||||
public QObject,
|
||||
public CGAL::Three::Polyhedron_demo_plugin_interface
|
||||
|
|
@ -43,17 +43,17 @@ class BasicPlugin :
|
|||
Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0")
|
||||
public:
|
||||
//decides if the plugin's actions will be displayed or not.
|
||||
bool applicable(QAction*) const
|
||||
bool applicable(QAction*) const Q_DECL_OVERRIDE
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//the list of the actions of the plugin.
|
||||
QList<QAction*> actions() const
|
||||
QList<QAction*> actions() const Q_DECL_OVERRIDE
|
||||
{
|
||||
return _actions;
|
||||
}
|
||||
//this acts like a constructor for the plugin. It gets the references to the main window and the scene, and connects the action.
|
||||
void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* sc, Messages_interface* mi)
|
||||
void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* sc, Messages_interface* mi) Q_DECL_OVERRIDE
|
||||
{
|
||||
//gets the reference to the message interface, to display text in the console widget
|
||||
this->messageInterface = mi;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
|
|||
|
||||
polyhedron_demo_plugin(example_plugin Example_plugin)
|
||||
|
||||
qt5_wrap_ui( basicUI_FILES Basic_dialog_plugin.ui )
|
||||
qt5_wrap_ui( basicUI_FILES Basic_dialog.ui )
|
||||
polyhedron_demo_plugin(basic_plugin Basic_plugin ${basicUI_FILES})
|
||||
|
||||
qt5_wrap_ui( dockUI_FILES Basic_dock_widget.ui )
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public:
|
|||
}
|
||||
};
|
||||
//! [dock]
|
||||
//This plugin crates an action in Operations that displays "Hello World" in the 'console' dockwidet.
|
||||
//This plugin crates an action in Operations that creates a DOckWidget to display a number in the 'console' dockwidet.
|
||||
class BasicPlugin :
|
||||
public QObject,
|
||||
public CGAL::Three::Polyhedron_demo_plugin_helper
|
||||
|
|
@ -29,27 +29,27 @@ class BasicPlugin :
|
|||
Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0")
|
||||
public:
|
||||
//decides if the plugin's actions will be displayed or not.
|
||||
bool applicable(QAction*) const
|
||||
bool applicable(QAction*) const Q_DECL_OVERRIDE
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//the list of the actions of the plugin.
|
||||
QList<QAction*> actions() const
|
||||
QList<QAction*> actions() const Q_DECL_OVERRIDE
|
||||
{
|
||||
return _actions;
|
||||
}
|
||||
//! [init]
|
||||
//this acts like a constructor for the plugin. It gets the references to the mainwindow and the scene, and connects the action.
|
||||
void init(QMainWindow* mw, CGAL::Three::Scene_interface* sc, Messages_interface* mi)
|
||||
void init(QMainWindow* mw, CGAL::Three::Scene_interface* sc, Messages_interface* mi) Q_DECL_OVERRIDE
|
||||
{
|
||||
//gets the reference to the message interface, to display text in the console widget
|
||||
this->messageInterface = mi;
|
||||
//get the references
|
||||
this->scene = sc;
|
||||
this->mw = mainWindow;
|
||||
this->mw = mw;
|
||||
|
||||
//creates the action
|
||||
QAction *actionHelloWorld= new QAction(QString("Hello World"), mw);
|
||||
QAction *actionHelloWorld= new QAction(QString("Open Dock Widget"), mw);
|
||||
//specifies the subMenu
|
||||
actionHelloWorld->setProperty("submenuName", "Basic");
|
||||
//links the action
|
||||
|
|
|
|||
|
|
@ -28,24 +28,24 @@ public :
|
|||
double cx,double cy, double cz);
|
||||
|
||||
// Indicates if rendering mode is supported
|
||||
bool supportsRenderingMode(RenderingMode m) const {
|
||||
bool supportsRenderingMode(RenderingMode m) const Q_DECL_OVERRIDE {
|
||||
return (m == Flat);
|
||||
}
|
||||
|
||||
//Displays the item
|
||||
void draw(CGAL::Three::Viewer_interface* viewer) const;
|
||||
void draw(CGAL::Three::Viewer_interface* viewer) const Q_DECL_OVERRIDE;
|
||||
|
||||
//Specifies that the buffers need to be initialized again.
|
||||
//Is mostly called after a change of geometry in the data.
|
||||
void invalidateOpenGLBuffers();
|
||||
void invalidateOpenGLBuffers() Q_DECL_OVERRIDE;
|
||||
|
||||
//fills the std::vector
|
||||
void computeElements(double ax,double ay, double az,
|
||||
double bx,double by, double bz,
|
||||
double cx,double cy, double cz) const;
|
||||
double cx,double cy, double cz) const Q_DECL_OVERRIDE;
|
||||
|
||||
Scene_item* clone() const {return 0;}
|
||||
QString toolTip() const {return QString();}
|
||||
Scene_item* clone() const Q_DECL_OVERRIDE {return 0;}
|
||||
QString toolTip() const Q_DECL_OVERRIDE {return QString();}
|
||||
|
||||
|
||||
private:
|
||||
|
|
@ -55,7 +55,7 @@ private:
|
|||
mutable QOpenGLShaderProgram *program;
|
||||
using CGAL::Three::Scene_item::initializeBuffers;
|
||||
//Fills the buffers with data. The buffers allow us to give data to the shaders.
|
||||
void initializeBuffers(CGAL::Three::Viewer_interface *viewer)const;
|
||||
void initializeBuffers(CGAL::Three::Viewer_interface *viewer)const Q_DECL_OVERRIDE;
|
||||
}; //end of class Scene_triangle_item
|
||||
//! [itemdeclaration]
|
||||
Scene_triangle_item::Scene_triangle_item(double ax,double ay, double az,
|
||||
|
|
@ -63,9 +63,6 @@ Scene_triangle_item::Scene_triangle_item(double ax,double ay, double az,
|
|||
double cx,double cy, double cz)
|
||||
: CGAL::Three::Scene_item(1,1)
|
||||
{
|
||||
|
||||
//Color is uniform, no need for a buffer. Changing the color will not re-compute the data
|
||||
is_monochrome = true;
|
||||
nb_pos = 0;
|
||||
are_buffers_filled = false;
|
||||
computeElements(ax, ay, az,
|
||||
|
|
@ -171,7 +168,7 @@ class Q_DECL_EXPORT Polyhedron_demo_example_plugin :
|
|||
|
||||
public :
|
||||
// Adds an action to the menu and configures the widget
|
||||
void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface*) {
|
||||
void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* scene_interface, Messages_interface*) Q_DECL_OVERRIDE{
|
||||
//get the references
|
||||
this->scene = scene_interface;
|
||||
this->mw = mainWindow;
|
||||
|
|
@ -184,11 +181,11 @@ public :
|
|||
_actions << actionDrawTriangle;
|
||||
}
|
||||
}
|
||||
bool applicable(QAction*) const
|
||||
bool applicable(QAction*) const Q_DECL_OVERRIDE
|
||||
{
|
||||
return true;
|
||||
}
|
||||
QList<QAction*> actions() const {
|
||||
QList<QAction*> actions() const Q_DECL_OVERRIDE{
|
||||
return _actions;
|
||||
}
|
||||
|
||||
|
|
@ -200,6 +197,7 @@ public Q_SLOTS:
|
|||
triangle = new Scene_triangle_item(0, 0, 0,
|
||||
1, 0, 0,
|
||||
0.5, 0.5, 0);
|
||||
triangle->setName(QString("Basic triangle"));
|
||||
scene->addItem(triangle);
|
||||
}
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -1,156 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Polyhedron_demo_example_plugin_dialog</class>
|
||||
<widget class="QDialog" name="Polyhedron_demo_example_plugin_dialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>199</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Triangle coordinates</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>150</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="gridLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>9</y>
|
||||
<width>381</width>
|
||||
<height>121</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="3">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Point C</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_Az"/>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_By"/>
|
||||
</item>
|
||||
<item row="2" column="3">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_Cy"/>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_Bz"/>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_Cz"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_Ax"/>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_Cx"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_Ay"/>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QDoubleSpinBox" name="doubleSpinBox_Bx"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Point A</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Point B</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>X</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Z</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="triangle_name_label">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>Polyhedron_demo_example_plugin_dialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>Polyhedron_demo_example_plugin_dialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
|
|
@ -1,8 +1,6 @@
|
|||
@INCLUDE = ${CGAL_DOC_PACKAGE_DEFAULTS}
|
||||
PROJECT_NAME = "CGAL ${CGAL_DOC_VERSION} - Three"
|
||||
INPUT += ${CGAL_Polyhedron_DEMO_DIR}/Polyhedron/Scene.h \
|
||||
${CGAL_Polyhedron_DEMO_DIR}/Polyhedron/Viewer.h \
|
||||
${CGAL_Polyhedron_DEMO_DIR}/Polyhedron/MainWindow.h \
|
||||
${CGAL_Polyhedron_DEMO_DIR}/Polyhedron/Polyhedron_demo.h \
|
||||
|
||||
EXAMPLE_PATH = ${CGAL_PACKAGE_DIR}/demo
|
||||
|
|
|
|||
|
|
@ -25,7 +25,9 @@
|
|||
- `CGAL::Three::Polyhedron_demo_io_plugin_interface`
|
||||
|
||||
## Classes ##
|
||||
- `MainWindow`
|
||||
- `TextRenderer`
|
||||
- `TextItem`
|
||||
- `TextListItem`
|
||||
- `CGAL::Three::Scene_item`
|
||||
- `CGAL::Three::Scene_group_item`
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ A basic plugin will inherit from `CGAL::Three::Polyhedron_demo_plugin_interface`
|
|||
It must be created in the corresponding folder named after its package, and containing all the files created for the plugin, and a CMakeLists.txt file.
|
||||
Its name must be of the form Xxxx_yyyy_plugin. \n
|
||||
|
||||
[init()]: @ref CGAL::Three::Polyhedron_demo_plugin_interface#init(QMainWindow *, Scene_interface *)
|
||||
[init()]: @ref CGAL::Three::Polyhedron_demo_plugin_interface#init(QMainWindow *, Scene_interface *, Messages_interface*)
|
||||
[applicable()]: @ref CGAL::Three::Polyhedron_demo_plugin_interface#applicable()
|
||||
[actions()]: @ref CGAL::Three::Polyhedron_demo_plugin_interface#actions()
|
||||
The class must contain the following lines :\n
|
||||
|
|
@ -82,9 +82,9 @@ For a more elaborate interface, you will have to use the designer tool of QtCrea
|
|||
* \image html menu_2.png
|
||||
Then select among the template/form choices.
|
||||
* \image html menu_3.png
|
||||
Name it Xxxx_yyyy_plugin_dialog.ui (you may have to rename it once it is created as QtCreator tends to forget the capital letters), and add it to the project in the CMakeLists :
|
||||
Name it Xxxx_yyyy_dialog.ui (you may have to rename it once it is created as QtCreator tends to forget the capital letters), and add it to the project in the CMakeLists :
|
||||
|
||||
qt5_wrap_ui( basicUI_FILES Basic_dialog_plugin.ui )
|
||||
qt5_wrap_ui( basicUI_FILES Basic_dialog.ui )
|
||||
polyhedron_demo_plugin(basic_plugin Basic_plugin ${basicUI_FILES})
|
||||
|
||||
Add a layout to the dialog with a drag and drop and lay it out.
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ class Polyhedron_demo_io_plugin_interface
|
|||
{
|
||||
public:
|
||||
//!Returns the name of the plugin
|
||||
//!It is used by the loading system.
|
||||
virtual QString name() const = 0;
|
||||
virtual ~Polyhedron_demo_io_plugin_interface() {}
|
||||
/*! The filters for the names of the files that can be used
|
||||
|
|
@ -44,17 +45,27 @@ public:
|
|||
* Example : to filter OFF files : return "OFF files (*.off)"
|
||||
*/
|
||||
virtual QString nameFilters() const = 0;
|
||||
//!Returns only the filters used for saving. The default is `nameFilters()`.
|
||||
//! You must override this function to change its behavior.
|
||||
virtual QString saveNameFilters() const {return nameFilters();}
|
||||
//!Returns only the filters used for loading. The default is `nameFilters()`.
|
||||
//! You must override this function to change its behavior.
|
||||
//! If multiple plugins have the same load filters, only once will be kept,
|
||||
//! so be careful not to use one that already exists.
|
||||
virtual QString loadNameFilters() const {return nameFilters();}
|
||||
|
||||
//! Specifies if the io_plugin is able to load an item or not.
|
||||
//! This must be overriden.
|
||||
virtual bool canLoad() const = 0;
|
||||
//! Loads an item from a file.
|
||||
//! This must be overriden.
|
||||
virtual Scene_item* load(QFileInfo fileinfo) = 0;
|
||||
//!Specifies if the io_plugin can save the item or not.
|
||||
//!This must be overriden.
|
||||
virtual bool canSave(const Scene_item*) = 0;
|
||||
//!Saves the item in the file corresponding to the path
|
||||
//!contained in fileinfo. Returns false if error.
|
||||
//! This must be overriden.
|
||||
virtual bool save(const Scene_item*, QFileInfo fileinfo) = 0;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,11 +50,9 @@ class SCENE_ITEM_EXPORT Polyhedron_demo_plugin_helper
|
|||
public:
|
||||
|
||||
/*! \brief Gets an item of the templated type.
|
||||
*
|
||||
* The function first checks if the selected item is of the wanted type. If not, it will look in the scene entries if there is at least one item of the
|
||||
* right type, make it the selection and return it.
|
||||
* \return the first item found with the templated type
|
||||
* \return NULL if none is found
|
||||
* \returns The currently selected `SceneType` item
|
||||
* \returns the first `SceneType` item found in the scene's list of items if the selected item is not a `SceneType`
|
||||
* \returns NULL if there is no `SceneType` in the list.
|
||||
*/
|
||||
template<class SceneType>
|
||||
SceneType* getSelectedItem() const{
|
||||
|
|
@ -84,7 +82,8 @@ public:
|
|||
void addDockWidget(QDockWidget* dock);
|
||||
/*! \brief Automatically connects each action of the plugin to the corresponding slot.
|
||||
*
|
||||
* All actions in actions() must have their slot name on_ActionsName_triggered().
|
||||
* \attention Each action named `ActionName` in the plugin's `actions()` list must have a corresponding slot named `on_ActionsName_triggered()`
|
||||
* in the plugin.
|
||||
*/
|
||||
void autoConnectActions();
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -37,23 +37,28 @@ namespace CGAL {
|
|||
namespace Three {
|
||||
class Scene_interface;
|
||||
/*!
|
||||
* This class gives some virtual functions to help making a plugin
|
||||
* This virtual class provides the basic functions used for making a plugin.
|
||||
*/
|
||||
class Polyhedron_demo_plugin_interface
|
||||
{
|
||||
public:
|
||||
//! Initializes the plugin and gives access to a Message interface, that
|
||||
//! can be used to display messages in the console dock widget.
|
||||
//! @see init(QMainWindow*, CGAL::Three::Scene_interface*)
|
||||
//! \brief Initializes the plugin
|
||||
//! This function acts like a constructor. This is where the attributes must be initialized.
|
||||
//! The Message_interface allows to print warnings or errors on the screen and the `Console` widget.
|
||||
virtual void init(QMainWindow* , CGAL::Three::Scene_interface* , Messages_interface*) = 0;
|
||||
|
||||
//! Decides if the plugin's actions will be displayed or not.
|
||||
//! @returns \c true, if the plugin is applicable, \c false
|
||||
//! \brief Indicates if an action is usable or not.
|
||||
//! This function usually tests the type of the selected item to determine if `action` can be applied to it,
|
||||
//! but not necessarly.
|
||||
//! @returns \c true if `action` can be called in the current state, \c false
|
||||
//! otherwise
|
||||
virtual bool applicable(QAction*) const = 0;
|
||||
//!The list of the actions of the plugin.
|
||||
virtual bool applicable(QAction* action) const = 0;
|
||||
//!Contains all the plugin's actions.
|
||||
virtual QList<QAction*> actions() const = 0;
|
||||
//!If you need to do something when the plugin is closed, do it here
|
||||
//!\brief Is called when the application is closed.
|
||||
//! Override this function if you need to perform a specific action
|
||||
//! when the application is closed, like hide the widgets if you don't want
|
||||
//! their visibility to be saved.
|
||||
virtual void closure() {
|
||||
}
|
||||
protected :
|
||||
|
|
|
|||
|
|
@ -33,30 +33,44 @@ namespace Three {
|
|||
class Scene_item;
|
||||
|
||||
|
||||
// Base class to interact with the scene from the viewer.
|
||||
//! Base class to interact with the scene from the viewer.
|
||||
class Scene_draw_interface {
|
||||
public:
|
||||
virtual ~Scene_draw_interface(){}
|
||||
|
||||
/*! Is called by Viewer::initializeGL(). Allows all the initialization
|
||||
* of OpenGL code that needs a context.
|
||||
*/
|
||||
virtual void initializeGL() = 0;
|
||||
|
||||
//! \brief Draws the items.
|
||||
//! It is called by Viewer::draw().
|
||||
virtual void draw(CGAL::Three::Viewer_interface*) = 0;
|
||||
//!\brief draws the scene in a hidden frame to perform picking.
|
||||
//! Is called by Viewer::drawWithNames().
|
||||
virtual void drawWithNames(CGAL::Three::Viewer_interface*) = 0;
|
||||
/*! Sets the screen coordinates of the currently picked point.*/
|
||||
//!Pick the point `e` on the screen.
|
||||
virtual void setPickedPixel(const QPoint &e) = 0;
|
||||
//! \brief Manages the key events.
|
||||
//! Override this function to perform actions when keys are pressed.
|
||||
//! @returns true if the keyEvent executed well.
|
||||
//!
|
||||
virtual bool keyPressEvent(QKeyEvent* e) = 0;
|
||||
virtual float get_bbox_length() const = 0;
|
||||
//!\brief print theTextItems.
|
||||
virtual void printPrimitiveId(QPoint point, CGAL::Three::Viewer_interface*) = 0;
|
||||
//!\brief update theTextItems.
|
||||
virtual void updatePrimitiveIds(CGAL::Three::Viewer_interface* , CGAL::Three::Scene_item*) = 0;
|
||||
|
||||
/*!
|
||||
* \brief testDisplayId checks if the id at position (x,y,z) is visible or not.
|
||||
* \param x the X coordinate of the id's position.
|
||||
* \param y the Y coordinate of the id's position.
|
||||
* \param z the Z coordinate of the id's position.
|
||||
* \brief checks if the text at position (x,y,z) is visible or not.
|
||||
* \param x the X coordinate of theTextItem's position.
|
||||
* \param y the Y coordinate of theTextItem's position.
|
||||
* \param z the Z coordinate of theTextItem's position.
|
||||
* \param viewer the viewer used to display the Scene.
|
||||
* \return true if the ID is visible. */
|
||||
* \return true if the TextItem is visible. */
|
||||
virtual bool testDisplayId(double x, double y, double z, CGAL::Three::Viewer_interface* viewer) = 0;
|
||||
/*!
|
||||
* \brief printPrimitiveIds displays all the Ids if there are less than max_textItems.
|
||||
* \brief printPrimitiveIds displays all the TextItems if there are less than Viewer::max_textItems.
|
||||
*/
|
||||
virtual void printPrimitiveIds(CGAL::Three::Viewer_interface*) = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,9 +37,11 @@ using namespace CGAL::Three;
|
|||
#endif
|
||||
namespace CGAL {
|
||||
namespace Three {
|
||||
//!A Scene_group_item is a virtual Scene_item that does not draw anything,
|
||||
//!A Scene_group_item is a special Scene_item that does not draw anything,
|
||||
//! but regroups other items as its children. It allows the
|
||||
//! user to apply several actions to multiple items at the same time.
|
||||
//! A custom Scene_item can derive from it to have children. They appear
|
||||
//! hierarchically in the Geometric Objects list.
|
||||
class DEMO_FRAMEWORK_EXPORT Scene_group_item : public Scene_item
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -54,11 +56,14 @@ public :
|
|||
bool isEmpty() const ;
|
||||
/*!
|
||||
* \brief Locks a child
|
||||
*
|
||||
* A locked child cannot be moved out of the group nor can it be deleted.
|
||||
* Use it to prevent a child to be destroyed without its parent.
|
||||
*/
|
||||
void lockChild(CGAL::Three::Scene_item*);
|
||||
/*!
|
||||
* \brief Unlocks a child
|
||||
*
|
||||
* @see lockChild()
|
||||
*/
|
||||
void unlockChild(CGAL::Three::Scene_item*);
|
||||
|
|
@ -68,33 +73,59 @@ public :
|
|||
* @see lockChild()
|
||||
*/
|
||||
bool isChildLocked(CGAL::Three::Scene_item*);
|
||||
//!Returns if the group_item is currently expanded or collapsed in the view.
|
||||
//!Returns if the group_item is currently expanded or collapsed in the Geometric Objects list.
|
||||
//! True means expanded, false means collapsed.
|
||||
//! @see setExpanded.
|
||||
//! @see isExpanded().
|
||||
bool isExpanded() const;
|
||||
//!Makes the group_item expanded or collapsed in the view.
|
||||
//! True means expanded, false means collapsed.
|
||||
//! @see isExpanded().
|
||||
void setExpanded(bool);
|
||||
//! @see isExpanded.
|
||||
//!Returns an empty BBox to avoid disturbing the BBox of the scene.
|
||||
//!Returns an empty Bbox to avoid disturbing the Bbox of the scene.
|
||||
Bbox bbox() const;
|
||||
//!Not supported.
|
||||
Scene_item* clone() const {return 0;}
|
||||
//! Indicates if the rendering mode is supported.
|
||||
//! \returns true for all rendering modes that are shared by
|
||||
//! all of the children.
|
||||
bool supportsRenderingMode(RenderingMode m) const;
|
||||
//!Prints the number of children.
|
||||
//!\returns a string containing the number of children.
|
||||
QString toolTip() const;
|
||||
|
||||
/// Draw functions
|
||||
/// Scene_group_item's children are not drawn by the scene, they are drawn by the group.
|
||||
///@{
|
||||
//!\brief draws all the children
|
||||
//!
|
||||
//! Calls `Scene_item::draw()`, then calls `Scene_item::drawEdges()`
|
||||
//! and `Scene_item::drawPoints` for each child if its current
|
||||
//! rendering mode is adequat.
|
||||
//! @see #RenderingMode
|
||||
virtual void draw(CGAL::Three::Viewer_interface*) const;
|
||||
//!\brief draws all the children
|
||||
//!
|
||||
//! Calls `Scene_item::drawEdges()`, then calls `Scene_item::draw()`
|
||||
//! and `Scene_item::drawPoints` for each child if its current
|
||||
//! rendering mode is adequat.
|
||||
//! @see #RenderingMode
|
||||
virtual void drawEdges(CGAL::Three::Viewer_interface*) const;
|
||||
//!\brief draws all the children
|
||||
//!
|
||||
//! Calls `Scene_item::drawPoints()`, then calls `Scene_item::draw()`
|
||||
//! and `Scene_item::drawEdges()` for each child if its current
|
||||
//! rendering mode is adequat.
|
||||
//! @see #RenderingMode
|
||||
virtual void drawPoints(CGAL::Three::Viewer_interface*) const;
|
||||
//!\brief draws all the children
|
||||
//!
|
||||
//! Calls `Scene_item::drawSplats()` for each child if its current
|
||||
//! rendering mode is `Splatting`.
|
||||
//! @see #RenderingMode
|
||||
virtual void drawSplats(CGAL::Three::Viewer_interface*) const;
|
||||
///@}
|
||||
|
||||
//!Adds a Scene_item* to the list of children.
|
||||
//!@see getChildren. @see removeChild.
|
||||
//!Adds a CGAL::Three::Scene_item* to the list of children.
|
||||
//!@see getChildren() @see removeChild()
|
||||
void addChild(Scene_item* new_item);
|
||||
//!Sets all the children to the specified color.
|
||||
void setColor(QColor c);
|
||||
|
|
@ -138,10 +169,13 @@ public :
|
|||
void setSplattingMode(){
|
||||
setRenderingMode(Splatting);
|
||||
}
|
||||
//!Returns a list of all the direct children.
|
||||
//! \brief Returns a list of all the direct children.
|
||||
//!
|
||||
//! Only returns children that have this item as a parent.
|
||||
//! Children of these children are not returned.
|
||||
QList<Scene_item*> getChildren() const {return children;}
|
||||
//!Removes a Scene_item from the list of children.
|
||||
//!@see getChildren @see addChild
|
||||
//!@see getChildren() @see addChild()
|
||||
void removeChild( Scene_item* item)
|
||||
{
|
||||
if(isChildLocked(item))
|
||||
|
|
@ -155,12 +189,16 @@ public :
|
|||
void moveDown(int);
|
||||
|
||||
public Q_SLOTS:
|
||||
//!Let the scene know that the item has not been drawn yet.
|
||||
//!\brief Redraws children.
|
||||
//!
|
||||
//! As each drawing function of a group draws all parts of its children,
|
||||
//! once any of these functions is called, we skip all drawing calls
|
||||
//! until `resetDraw()` is called. This keeps children from being
|
||||
//! drawn several times. It is automatically called at the end of the scene's
|
||||
//! `draw()` function.
|
||||
void resetDraw() { already_drawn = false;}
|
||||
private:
|
||||
//!Updates the property has_group for each group and sub-groups containing new_item.
|
||||
void update_group_number(Scene_item*new_item, int n);
|
||||
|
||||
bool expanded;
|
||||
mutable bool already_drawn;
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -19,10 +19,31 @@
|
|||
// Author(s) : Laurent RINEAU
|
||||
|
||||
//! \file Scene_interface.h
|
||||
|
||||
|
||||
#ifndef SCENE_INTERFACE_H
|
||||
#define SCENE_INTERFACE_H
|
||||
|
||||
#include <CGAL/license/Three.h>
|
||||
/*!
|
||||
* \ingroup PkgThree
|
||||
* The RenderingMode determines which of an item's primitives must be drawn.
|
||||
* It can be Points, PointsPlusNormals, Wireframe, Flat, FlatPlusEdges, or Gouraud.
|
||||
* - Points, PointsPlusNormals, and Wireframe have no light model.
|
||||
* - Flat and FlatPlusEdges use a basic light model with one normal per facet.
|
||||
* - Gouraud uses the same light model but with one normal per vertex.
|
||||
*/
|
||||
enum RenderingMode
|
||||
{
|
||||
Points = 0, //! Renders only points without lighting.
|
||||
PointsPlusNormals, //!Renders points and normals.
|
||||
Splatting, //!Renders splats. Splats are oriented points that look like discs.
|
||||
Wireframe, //!Renders only edges.
|
||||
Flat, //!Renders only faces, with a lighting per face.
|
||||
FlatPlusEdges, //!Renders flat faces and edges.
|
||||
Gouraud, //!Renders only faces, with a lighting per vertex.
|
||||
ShadedPoints, //!Renders only points with lighting.
|
||||
NumberOfRenderingMode //!Number of values in this enum.
|
||||
};
|
||||
|
||||
|
||||
#include <QString>
|
||||
|
|
@ -31,31 +52,12 @@
|
|||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <CGAL/Bbox_3.h>
|
||||
namespace CGAL{namespace Three{
|
||||
namespace CGAL{
|
||||
namespace Three{
|
||||
class Scene_item;
|
||||
class Scene_group_item;
|
||||
}}
|
||||
// OpenGL rendering mode
|
||||
/*!
|
||||
* Contains the class Scene_interface and the enum RenderingMode.
|
||||
*/
|
||||
/*!
|
||||
* \brief The RenderingMode enum
|
||||
* Can be Points, PointsPlusNormals, Wireframe, Flat, FlatPlusEdges, or Gouraud.
|
||||
* - Points, PointsPlusNormals, and Wireframe have no light model.
|
||||
* - Flat and FlatPlusEdges use a basic light model with one normal per facet.
|
||||
* - Gouraud use the same light model but with one normal per vertex.
|
||||
*/
|
||||
enum RenderingMode { Points = 0,
|
||||
PointsPlusNormals,
|
||||
Splatting,
|
||||
Wireframe,
|
||||
Flat,
|
||||
FlatPlusEdges,
|
||||
Gouraud,
|
||||
ShadedPoints,
|
||||
NumberOfRenderingMode};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
namespace CGAL {
|
||||
namespace Three{
|
||||
|
|
@ -64,19 +66,25 @@ namespace Three{
|
|||
* */
|
||||
class Scene_interface {
|
||||
public:
|
||||
|
||||
//!A bounding box is a box with each face corresponding to an extremum of its contents.
|
||||
|
||||
typedef CGAL::Bbox_3 Bbox;
|
||||
//!Integer used as the index of a Scene_item.
|
||||
|
||||
//!\brief Integer used as the index of a Scene_item.
|
||||
//! An item's index is its position in the Geometric Objects list.
|
||||
typedef int Item_id;
|
||||
//!Virtual destructor
|
||||
virtual ~Scene_interface() {};
|
||||
//!Adds an item to the list of items.
|
||||
//!Adds an item to the Geometric Objects list.
|
||||
//!@returns the index of the new item.
|
||||
virtual Item_id addItem(CGAL::Three::Scene_item* item) = 0;
|
||||
//!Replace an item by a new one in the scene. The first is deleted and gives its index to the latter.
|
||||
//!If emit_item_about_to_be_destroyed is true, emits
|
||||
//!an itemAboutToBeDestroyed signal.
|
||||
//! \brief Replaces an item by a new one in the scene.
|
||||
//! The item which id is `id` is replaced by `item`.
|
||||
//! The first one is deleted and gives its index to the second one.
|
||||
//! If emit_item_about_to_be_destroyed is true, emits
|
||||
//! an itemAboutToBeDestroyed signal.
|
||||
//!@returns a pointer to the old item.
|
||||
virtual Scene_item* replaceItem(Item_id, CGAL::Three::Scene_item*, bool emit_item_about_to_be_destroyed = false) = 0;
|
||||
virtual Scene_item* replaceItem(Item_id id, CGAL::Three::Scene_item* item, bool emit_item_about_to_be_destroyed = false) = 0;
|
||||
//!Moves item to the targeted group.
|
||||
virtual void changeGroup(CGAL::Three::Scene_item* item, CGAL::Three::Scene_group_item* target_group) = 0;
|
||||
|
||||
|
|
@ -85,57 +93,64 @@ public:
|
|||
* or just after.
|
||||
* @returns -1 if the list is empty.*/
|
||||
virtual Item_id erase(Item_id) = 0;
|
||||
/*! Deletes the items with the target indices.
|
||||
* @returns the index of the polyhedron just before the
|
||||
* one that is erased, or just after. Returns -1 if
|
||||
* the list is empty.
|
||||
*/
|
||||
virtual int erase(QList<int>) = 0;
|
||||
|
||||
/*! Duplicates a scene item.
|
||||
/*! Creates a copy of the item whith the id `id`.
|
||||
* @returns the index of the new item (-1 on error).
|
||||
*/
|
||||
virtual Item_id duplicate(Item_id) = 0;
|
||||
virtual Item_id duplicate(Item_id id) = 0;
|
||||
|
||||
// Accessors (getters)
|
||||
//!
|
||||
//! \brief The number of items
|
||||
//!@returns the number of items in the scene.
|
||||
virtual int numberOfEntries() const = 0;
|
||||
//!
|
||||
//!\brief The `id`th item.
|
||||
//! @returns the item with the specified index.
|
||||
virtual CGAL::Three::Scene_item* item(Item_id) const = 0;
|
||||
//!
|
||||
virtual CGAL::Three::Scene_item* item(Item_id id) const = 0;
|
||||
//!\brief The id of `item`
|
||||
//! @returns the id of the specified item.
|
||||
virtual Item_id item_id(CGAL::Three::Scene_item*) const = 0;
|
||||
//!
|
||||
//!@returns the currently selected item's index. If several items are selected, returns the last one's index.
|
||||
virtual Item_id item_id(CGAL::Three::Scene_item* item) const = 0;
|
||||
//!\brief The currently selected item's index.
|
||||
//!@returns the currently selected item's index.
|
||||
//!@returns -1 if none or several items are selected
|
||||
virtual Item_id mainSelectionIndex() const = 0;
|
||||
//!
|
||||
//!The id of the currently selected item.
|
||||
//!@returns the list of currently selected items indices.
|
||||
virtual QList<Item_id> selectionIndices() const = 0;
|
||||
//!
|
||||
//!Item_A is designated with the column A/B in the Geometric Objetcts widget.
|
||||
//!@returns the index of the Item_A
|
||||
virtual Item_id selectionAindex() const = 0;
|
||||
//!
|
||||
//!Item_B is designated with the column A/B in the Geometric Objetcts widget.
|
||||
//!@returns the index of the Item_B
|
||||
virtual Item_id selectionBindex() const = 0;
|
||||
//!
|
||||
//!@returns the scene bounding box
|
||||
|
||||
//!\brief The scene's Bbox
|
||||
//!@returns the scene's bounding box
|
||||
//! @see Scene_interface::Bbox
|
||||
virtual Bbox bbox() const = 0;
|
||||
//!
|
||||
//!The length of the diagonal of the scene's Bbox
|
||||
//!@returns the length of the bounding box's diagonal.
|
||||
virtual double len_diagonal() const = 0;
|
||||
|
||||
public:
|
||||
/*! Emits a dataChanged signal. */
|
||||
virtual void itemChanged(Item_id i) = 0;
|
||||
/*! Emits a dataChanged signal.*/
|
||||
virtual void itemChanged(CGAL::Three::Scene_item*) = 0;
|
||||
//! Updates the information about the item `i`th in the
|
||||
//! Geometric Objects list and redraws the scene.
|
||||
virtual void itemChanged(Item_id i) = 0;
|
||||
//! Updates the information about `item` in the
|
||||
//! Geometric Objects list and redraws the scene.
|
||||
virtual void itemChanged(CGAL::Three::Scene_item* itme) = 0;
|
||||
|
||||
/*! Selects the item with the specified index. */
|
||||
virtual void setSelectedItem(Item_id) = 0;
|
||||
/*! Adds group to the Scene. If items were selected at the
|
||||
* moment this function is called, they are added to the group.
|
||||
* If all the selected items were in the same group, the new group
|
||||
* is added as a sub-group of this group.*/
|
||||
virtual void addGroup(Scene_group_item* group) = 0;
|
||||
|
||||
//! Clears the current selection then sets the selected item to the target index.
|
||||
//! Used to update the selection in the Geometric Objects view.
|
||||
virtual void setSelectedItem(Item_id) = 0;
|
||||
}; // end interface Scene_interface
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // SCENE_INTERFACE_H
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
#include <QOpenGLVertexArrayObject>
|
||||
#include <vector>
|
||||
#include <CGAL/Bbox_3.h>
|
||||
#include <CGAL/Three/Scene_print_interface_item.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Three {
|
||||
|
|
@ -51,8 +50,10 @@ namespace Three {
|
|||
|
||||
class Scene_group_item;
|
||||
class Viewer_interface;
|
||||
//! This class represents an object in the OpenGL scene
|
||||
class SCENE_ITEM_EXPORT Scene_item : public QObject, public CGAL::Three::Scene_print_interface_item {
|
||||
//! This class represents an object in the OpenGL scene.
|
||||
//! It contains all the functions called by the Scene. It
|
||||
//! acts like a mix between an interface and a helper.
|
||||
class SCENE_ITEM_EXPORT Scene_item : public QObject{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QColor color READ color WRITE setColor)
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
|
|
@ -62,54 +63,64 @@ class SCENE_ITEM_EXPORT Scene_item : public QObject, public CGAL::Three::Scene_p
|
|||
public:
|
||||
/*!
|
||||
* \brief The OpenGL_program_IDs enum
|
||||
*
|
||||
* This enum holds the OpenGL programs IDs that are given to getShaderProgram() and attribBuffers().
|
||||
*@see getShaderProgram
|
||||
* @see getShaderProgram
|
||||
* @see attribBuffers
|
||||
*/
|
||||
enum OpenGL_program_IDs
|
||||
{
|
||||
PROGRAM_WITH_LIGHT = 0, /** Used to render a surface or edge affected by the light. It uses a per fragment lighting model, and renders brighter the selected item.*/
|
||||
PROGRAM_WITHOUT_LIGHT, /** Used to render a polygon edge or points. It renders in a uniform color and is not affected by light. It renders the selected item in black.*/
|
||||
PROGRAM_NO_SELECTION, /** Used to render a polyline or a surface that is not affected by light, like a cutting plane. It renders in a uniform color that does not change with selection.*/
|
||||
PROGRAM_WITH_TEXTURE, /** Used to render a textured polyhedron. Affected by light.*/
|
||||
PROGRAM_PLANE_TWO_FACES, /** Used to render a two-faced plane. The two faces have a different color. Not affected by light.*/
|
||||
PROGRAM_WITH_TEXTURED_EDGES, /** Used to render the edges of a textured polyhedorn. Not affected by light.*/
|
||||
PROGRAM_INSTANCED, /** Used to display instanced rendered spheres.Affected by light.*/
|
||||
PROGRAM_INSTANCED_WIRE, /** Used to display instanced rendered wired spheres. Not affected by light.*/
|
||||
PROGRAM_C3T3, /** Used to render a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Affected by light.*/
|
||||
PROGRAM_C3T3_EDGES, /** Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.*/
|
||||
PROGRAM_CUTPLANE_SPHERES, /** Used to render the spheres of an item with a cut plane.*/
|
||||
PROGRAM_SPHERES, /** Used to render one or several spheres.*/
|
||||
PROGRAM_C3T3_TETS, /** Used to render the tetrahedra of the intersection of a c3t3_item.*/
|
||||
PROGRAM_FLAT, /** Used to render flat shading without pre computing normals*/
|
||||
NB_OF_PROGRAMS /** Holds the number of different programs in this enum.*/
|
||||
PROGRAM_WITH_LIGHT = 0, //! Used to render a surface or an edge affected by the light. It uses a per fragment lighting model, and renders the selected item brighter.
|
||||
PROGRAM_WITHOUT_LIGHT, //! Used to render a polyhedron edge or points. It renders in a uniform color and is not affected by light. \attention It renders the selected item in black.
|
||||
PROGRAM_NO_SELECTION, //! Used to render a polyline or a surface that is not affected by light, like a cutting plane. It renders in a uniform color that does not change with selection.
|
||||
PROGRAM_WITH_TEXTURE, //! Used to render a textured polyhedron. Affected by light.
|
||||
PROGRAM_PLANE_TWO_FACES, //! Used to render a two-faced plane. The two faces have a different color. Not affected by light.
|
||||
PROGRAM_WITH_TEXTURED_EDGES, //! Used to render the edges of a textured polyhedron. Not affected by light.
|
||||
PROGRAM_INSTANCED, //! Used to display instanced rendered spheres.Affected by light.
|
||||
PROGRAM_INSTANCED_WIRE, //! Used to display instanced rendered wired spheres. Not affected by light.
|
||||
PROGRAM_C3T3, //! Used to render a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Affected by light.
|
||||
PROGRAM_C3T3_EDGES, //! Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.
|
||||
PROGRAM_CUTPLANE_SPHERES, //! Used to render the spheres of an item with a cut plane.
|
||||
PROGRAM_SPHERES, //! Used to render one or several spheres.
|
||||
PROGRAM_C3T3_TETS, //! Used to render the tetrahedra of the intersection of a c3t3_item.
|
||||
PROGRAM_FLAT, //! Used to render flat shading without pre computing normals
|
||||
NB_OF_PROGRAMS //! Holds the number of different programs in this enum.
|
||||
};
|
||||
typedef CGAL::Bbox_3 Bbox;
|
||||
typedef qglviewer::ManipulatedFrame ManipulatedFrame;
|
||||
//! The default color of a scene_item.
|
||||
//! \brief The default color of a scene_item.
|
||||
//!
|
||||
//! This color is the one that will be displayed if none is specified after its creation.
|
||||
static const QColor defaultColor; // defined in Scene_item.cpp
|
||||
|
||||
//!The Constructor.
|
||||
/*!
|
||||
* Initializes the number of VBOs and VAOs and creates them.
|
||||
*/
|
||||
//!\brief The Constructor.
|
||||
//!
|
||||
//! This is where the vectors of VBOs and VAOs are initialized.
|
||||
Scene_item(int buffers_size = 20, int vaos_size = 10);
|
||||
|
||||
//! Sets the number of isolated vertices.
|
||||
//! \brief Sets the number of isolated vertices.
|
||||
//!
|
||||
//! This number will be displayed in a warning box at loading.
|
||||
//! @see getNbIsolatedvertices
|
||||
void setNbIsolatedvertices(std::size_t nb) { nb_isolated_vertices = nb;}
|
||||
//! Getter for the number of isolated vertices.
|
||||
//! @see setNbIsolatedvertices
|
||||
std::size_t getNbIsolatedvertices() const {return nb_isolated_vertices;}
|
||||
//!The destructor. It is virtual as the item is virtual.
|
||||
virtual ~Scene_item();
|
||||
//! Creates a new item as a copy of the sender.
|
||||
//! \brief Duplicates the item.
|
||||
//!
|
||||
//! Creates a new item as a copy of this one.
|
||||
virtual Scene_item* clone() const = 0;
|
||||
|
||||
//! Indicates if rendering mode is supported
|
||||
//! \brief Indicates if `m` is supported
|
||||
//!
|
||||
//! If it is, it will be displayed in the context menu of the item.
|
||||
virtual bool supportsRenderingMode(RenderingMode m) const = 0;
|
||||
//! Deprecated. Does nothing.
|
||||
virtual void draw() const {}
|
||||
/*! \brief The drawing function.
|
||||
* Draws the facets of the item in the viewer using OpenGL functions. The data
|
||||
/*! \brief The drawing function for faces.
|
||||
*
|
||||
* Draws the faces of the item in the viewer. The data
|
||||
* for the drawing is gathered in computeElements(), and is sent
|
||||
* to buffers in initializeBuffers().
|
||||
* @see computeElements()
|
||||
|
|
@ -118,8 +129,9 @@ public:
|
|||
virtual void draw(CGAL::Three::Viewer_interface*) const { draw(); }
|
||||
//! Deprecated. Does nothing.
|
||||
virtual void drawEdges() const { draw(); }
|
||||
/*! \brief The drawing function.
|
||||
* Draws the edges and lines of the item in the viewer using OpenGL functions. The data
|
||||
/*! \brief The drawing function for the edges.
|
||||
*
|
||||
* Draws the edges and lines of the item in the viewer. The data
|
||||
* for the drawing is gathered in computeElements(), and is sent
|
||||
* to buffers in initializeBuffers().
|
||||
* @see computeElements()
|
||||
|
|
@ -128,8 +140,9 @@ public:
|
|||
virtual void drawEdges(CGAL::Three::Viewer_interface* viewer) const { draw(viewer); }
|
||||
//! Deprecated. Does nothing.
|
||||
virtual void drawPoints() const { draw(); }
|
||||
/*! \brief The drawing function.
|
||||
* Draws the points of the item in the viewer using OpenGL functions. The data
|
||||
/*! \brief The drawing function for the points.
|
||||
*
|
||||
* Draws the points of the item in the viewer. The data
|
||||
* for the drawing is gathered in computeElements(), and is sent
|
||||
* to buffers in initializeBuffers().
|
||||
* @see computeElements()
|
||||
|
|
@ -139,7 +152,7 @@ public:
|
|||
|
||||
//! Draws the splats of the item in the viewer using GLSplat functions.
|
||||
virtual void drawSplats() const {}
|
||||
//! Draws the splats of the item in the viewer using GLSplat functions.
|
||||
//! Draws the splats of the item in the viewer using the GLSplat library.
|
||||
virtual void drawSplats(CGAL::Three::Viewer_interface*) const {drawSplats();}
|
||||
|
||||
//! Called by the scene. If b is true, then this item is currently selected.
|
||||
|
|
@ -147,30 +160,40 @@ public:
|
|||
|
||||
// Functions for displaying meta-data of the item
|
||||
//!\brief Contains meta-data about the item.
|
||||
//! Data is :Number of vertices, Number of edges, Number of facets,
|
||||
//! Volume, Area, Bounding box limits and Number of isolated points.
|
||||
//! @returns a QString containing meta-data about the item.
|
||||
virtual QString toolTip() const = 0;
|
||||
//! \brief contains graphical meta-data about the item.
|
||||
//! \brief Contains graphical meta-data about the item.
|
||||
//! @returns a QPixmap containing graphical meta-data about the item.
|
||||
virtual QPixmap graphicalToolTip() const { return QPixmap(); }
|
||||
//! \brief contains the font used for the data of the item.
|
||||
//! \brief Contains the font used for the data of the item.
|
||||
//! @returns a QFont containing the font used for the data of the item.
|
||||
virtual QFont font() const { return QFont(); }
|
||||
|
||||
// Functions that help the Scene to compute its bbox
|
||||
//! If isFinite() returns false, the BBox is not computed.
|
||||
//! \brief Determines if the item is finite or not.
|
||||
//!
|
||||
//! For example, a plane is not finite.
|
||||
//! If false, the BBox is not computed.
|
||||
virtual bool isFinite() const { return true; }
|
||||
//! Specifies if the item is empty or null.
|
||||
//! If true, the BBox is not computed.
|
||||
virtual bool isEmpty() const { return true; }
|
||||
//! \brief the item's bounding box.
|
||||
//!@returns the item's bounding box.
|
||||
//! \brief The item's bounding box.
|
||||
//!
|
||||
//! If the Bbox has never been computed, computes it and
|
||||
//! saves the result for further calls.
|
||||
//! @returns the item's bounding box.
|
||||
virtual Bbox bbox() const {
|
||||
if(!is_bbox_computed)
|
||||
compute_bbox();
|
||||
is_bbox_computed = true;
|
||||
return _bbox;
|
||||
}
|
||||
//! \brief the item's bounding box's diagonal length.
|
||||
//!
|
||||
//! If the diagonal's length has never been computed, computes it and
|
||||
//! saves the result for further calls.
|
||||
//! @returns the item's bounding box's diagonal length.
|
||||
virtual double diagonalBbox() const {
|
||||
if(!is_diag_bbox_computed)
|
||||
compute_diag_bbox();
|
||||
|
|
@ -178,37 +201,49 @@ public:
|
|||
return _diag_bbox;
|
||||
}
|
||||
|
||||
//!Finds the spot the closest to point and prints the id of the corresponding Primitive (vertex, edg or Facet).
|
||||
virtual void printPrimitiveId(QPoint, CGAL::Three::Viewer_interface*);
|
||||
virtual void printPrimitiveIds(CGAL::Three::Viewer_interface*)const;
|
||||
|
||||
virtual bool testDisplayId(double, double, double, CGAL::Three::Viewer_interface*);
|
||||
// Function about manipulation
|
||||
//! returns true if the item can have a ManipulatedFrame.
|
||||
//! Returns true if the item has a ManipulatedFrame.
|
||||
//! @see manipulatedFrame()
|
||||
virtual bool manipulatable() const { return false; }
|
||||
//!\brief The manipulatedFrame of the item.
|
||||
//!
|
||||
//! A manipulated frame is an independant system that can be
|
||||
//! translated or rotated using the Ctrl key and the mouse.
|
||||
//!@returns the manipulatedFrame of the item.
|
||||
virtual ManipulatedFrame* manipulatedFrame() { return 0; }
|
||||
|
||||
// Getters for the four basic properties
|
||||
//!Getter for the item's color.
|
||||
//! @returns the current color of the item.
|
||||
virtual QColor color() const { return color_; }
|
||||
//!Getter for the item's name.
|
||||
//! @returns the current name of the item.
|
||||
virtual QString name() const { return name_; }
|
||||
//! If the item is not visible, it is not drawn and its Bbox
|
||||
//! is ignored in the computation of the scene's.
|
||||
//! @returns the current visibility of the item.
|
||||
virtual bool visible() const { return visible_; }
|
||||
//!Getter for the item's rendering mode.
|
||||
//! @returns the current rendering mode of the item.
|
||||
//!@see RenderingMode
|
||||
virtual RenderingMode renderingMode() const { return rendering_mode; }
|
||||
//!The renderingMode's name.
|
||||
//! @returns the current rendering mode of the item as a human readable string.
|
||||
virtual QString renderingModeName() const;
|
||||
|
||||
//! Context menu
|
||||
//! \brief Context menu
|
||||
//!
|
||||
//! Contains the list of the supported rendering modes,
|
||||
//! the Operations menu, actions to save or clone the item if it is supported
|
||||
//! and any contextual action for the item.
|
||||
virtual QMenu* contextMenu();
|
||||
|
||||
//!Handles key press events.
|
||||
virtual bool keyPressEvent(QKeyEvent*){return false;}
|
||||
|
||||
//!The parent group, or 0 if the item is not in a group.
|
||||
//!The group containing the item.
|
||||
//! \returns the parent group if the item is in a group
|
||||
//! \returns 0 if the item is not in a group.
|
||||
Scene_group_item* parentGroup() const;
|
||||
|
||||
//!Contains the header for the table in the statistics dialog
|
||||
|
|
@ -385,8 +420,8 @@ protected:
|
|||
* @see invalidateOpenGLBuffers()*/
|
||||
RenderingMode prev_shading;
|
||||
/*! \todo replace it by RenderingMode().
|
||||
* \brief
|
||||
* Contains the current RenderingMode.
|
||||
* \brief Contains the current RenderingMode.
|
||||
*
|
||||
* This is used to determine if invalidateOpenGLBuffers should be called or not
|
||||
* in certain cases.
|
||||
* @see invalidateOpenGLBuffers()*/
|
||||
|
|
@ -407,7 +442,7 @@ protected:
|
|||
vaos[i] = n_vao;
|
||||
}
|
||||
|
||||
/*! Fills the VBOs with data. Must be called after each call to #compute_elements().
|
||||
/*! Fills the VBOs with data. Must be called after each call to #computeElements().
|
||||
* @see compute_elements()
|
||||
*/
|
||||
void initializeBuffers(){}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,14 @@ namespace Three {
|
|||
class Scene_item;
|
||||
|
||||
//! Base class to allow an item to copy properties from another.
|
||||
//! Properties reprensent the current state of an item : its color,
|
||||
//! the position of its manipulated frame, ...
|
||||
class Scene_item_with_properties {
|
||||
public:
|
||||
virtual ~Scene_item_with_properties(){}
|
||||
//!Copies properties from another Scene_item
|
||||
//!\brief Copies properties from another Scene_item.
|
||||
//!
|
||||
//! Override this function to specify what must be copied.
|
||||
virtual void copyProperties(Scene_item*)=0; //pure virtual method
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@
|
|||
//
|
||||
// Author(s) : Maxime GIMENO
|
||||
|
||||
#ifndef SCENE_PRINT_INTERFACE_ITEM_H
|
||||
#define SCENE_PRINT_INTERFACE_ITEM_H
|
||||
#ifndef SCENE_PRINT_ITEM_INTERFACE_H
|
||||
#define SCENE_PRINT_ITEM_INTERFACE_H
|
||||
|
||||
#include <CGAL/license/Three.h>
|
||||
|
||||
#include <QtPlugin>
|
||||
#include <QPoint>
|
||||
namespace CGAL
|
||||
{
|
||||
|
|
@ -29,16 +29,24 @@ namespace Three {
|
|||
class Viewer_interface;
|
||||
|
||||
|
||||
//! Base class to allow an item to print its primitive IDs.
|
||||
class Scene_print_interface_item {
|
||||
//! An item that wants to print its primitive IDs must derive from this interface.
|
||||
class Scene_print_item_interface {
|
||||
public:
|
||||
virtual ~Scene_print_interface_item(){}
|
||||
//!Print the ID of the selected primitive.
|
||||
virtual ~Scene_print_item_interface(){}
|
||||
//! Finds the spot the closest to `point` and prints the id of the corresponding Primitive (vertex, edge or face).
|
||||
virtual void printPrimitiveId(QPoint, CGAL::Three::Viewer_interface*) = 0;
|
||||
//!Prints the ID of all the primitives.
|
||||
//! Prints all the primitive ids if their number is not too high. The limit is
|
||||
//! editable in the View menu of the application.
|
||||
virtual void printPrimitiveIds(CGAL::Three::Viewer_interface*)const = 0;
|
||||
//! \brief Tests if an id should be displayed or not.
|
||||
//!
|
||||
//! \returns true if the Id should be displayed
|
||||
//! \returns false if the Id should not be displayed (if it is hidden for example)
|
||||
virtual bool testDisplayId(double, double, double, CGAL::Three::Viewer_interface*)const = 0;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // SCENE_PRINT_INTERFACE_ITEM_H
|
||||
|
||||
Q_DECLARE_INTERFACE(CGAL::Three::Scene_print_item_interface, "com.geometryfactory.PolyhedronDemo.PrintInterface/1.0")
|
||||
#endif // SCENE_PRINT_ITEM_INTERFACE_H
|
||||
|
||||
|
|
@ -30,31 +30,30 @@
|
|||
#include <CGAL/Three/Viewer_interface.h>
|
||||
#include <CGAL/Three/Scene_interface.h>
|
||||
|
||||
//!This class holds the properties of each line of text to be rendered.
|
||||
class QVector3D;
|
||||
namespace CGAL{
|
||||
namespace Three{
|
||||
class Scene_item;
|
||||
}
|
||||
}
|
||||
//!A TextItem is a string with properties, like coordinates, font and color, that is
|
||||
//! to be rendered in the viewer.
|
||||
class VIEWER_EXPORT TextItem{
|
||||
public :
|
||||
/*!
|
||||
* \brief The default constructor.
|
||||
* This is an overloaded functtion.
|
||||
*/
|
||||
TextItem() {}
|
||||
/*!
|
||||
* \brief The construtor for the TextItem
|
||||
* \param p_x the X coordinate of the displayed text.
|
||||
* \param p_y the Y coordinate of the displayed text.
|
||||
* \param p_z the Z coordinate of the displayed text.
|
||||
* \param p_x, p_y, p_z the coordinates of the TextItem.
|
||||
* \param p_text the text to render.
|
||||
* \param p_3D
|
||||
* If true : the renderer will convert the coordinates into world coordinates.
|
||||
* If false : the renderer will display the text in screen coordinates, and ignore p_z
|
||||
* If true : the TextRenderer will convert the coordinates into world coordinates.
|
||||
* If false : the TextRenderer will display the text in screen coordinates, and ignore p_z
|
||||
* \param font the font used for the rendering.
|
||||
* \param p_color the color of the text.
|
||||
* \param always_visible overrides Viewer_interface::testDisplayId() if true;
|
||||
*/
|
||||
TextItem(float p_x, float p_y, float p_z, QString p_text, bool p_3D = true, QFont font = QFont(), QColor p_color = Qt::black, bool always_visible = false)
|
||||
:x(p_x), y(p_y), z(p_z),_3D(p_3D), _is_always_visible(always_visible), m_text(p_text), m_font(font), m_color(p_color)
|
||||
|
|
@ -63,14 +62,29 @@ public :
|
|||
_width = float(fm.width(m_text));
|
||||
_height = float(fm.height());
|
||||
}
|
||||
//!\brief Accessor for the string
|
||||
//!
|
||||
//! @returns the item's string
|
||||
QString text()const {return m_text;}
|
||||
//!Returns the position of the center of the text, in world coordinates.
|
||||
//!\brief The center of the item
|
||||
//!
|
||||
//!@returns the position of the center of the text, in world coordinates.
|
||||
QVector3D position(){return QVector3D(x,y,z);}
|
||||
//!The text's width in pixels
|
||||
float width(){return _width;}
|
||||
//!The text's height in pixels
|
||||
float height(){return _height;}
|
||||
//!Accessor for the text's font
|
||||
QFont font(){return m_font;}
|
||||
//!Accessor for the text's color
|
||||
QColor color() {return m_color;}
|
||||
//!Specifies if the item's coordinates are World or Screen coordinates
|
||||
//! @returns true if they are World coordinates
|
||||
//! @returns false if they are Screen coordinates
|
||||
bool is_3D()const{return _3D;}
|
||||
//!Specifies if the item may be hidden
|
||||
//! @returns true if it may not
|
||||
//! @returns false if it may
|
||||
bool is_always_visible(){return _is_always_visible;}
|
||||
private:
|
||||
float x;
|
||||
|
|
@ -86,28 +100,38 @@ private:
|
|||
|
||||
};//end class TextItem
|
||||
|
||||
//! This is a list of TextItems associated with a CGAL::Three::Scene_item.
|
||||
class VIEWER_EXPORT TextListItem{
|
||||
public:
|
||||
//!\brief The Constructor
|
||||
//! \param pItem the CGAL::Three::Scene_item associated to the list.
|
||||
TextListItem(CGAL::Three::Scene_item* pItem)
|
||||
{
|
||||
_list = QList<TextItem*>();
|
||||
_item = pItem;
|
||||
}
|
||||
|
||||
CGAL::Three::Scene_item* item()const {return _item;}
|
||||
//!The associated CGAL::Three::Scene_item.
|
||||
CGAL::Three::Scene_item* item()const {return _item;}
|
||||
//!The list of TextItems
|
||||
QList<TextItem*> textList()const {return _list;}
|
||||
//!Adds a `ti` to the list.
|
||||
void append(TextItem* ti) {_list.append(ti);}
|
||||
//!Clears the list of all the TextItems.
|
||||
void clear(){_list.clear();}
|
||||
//!Tells if the list there is any TextItem in the list.
|
||||
//! \returns true if there is no TextItem in the list
|
||||
//! \returns false if there is any TextItem in the list
|
||||
bool isEmpty()const {return _list.empty();}
|
||||
//!The size of the list
|
||||
std::size_t size()const{return _list.size();}
|
||||
private:
|
||||
CGAL::Three::Scene_item* _item;
|
||||
QList<TextItem*> _list;
|
||||
|
||||
};
|
||||
//!This class draws all the textItems.
|
||||
/*!
|
||||
* Projects each textItem from the world coordinates to the Screen coordinates
|
||||
* The TextRender projects each TextItem from the world coordinates to the Screen coordinates
|
||||
* and draws it.
|
||||
*/
|
||||
class VIEWER_EXPORT TextRenderer : public QObject{
|
||||
|
|
@ -116,33 +140,55 @@ public:
|
|||
TextRenderer() : max_textItems(30000)
|
||||
{
|
||||
}
|
||||
//!Draws all the TextItems
|
||||
//!Draws all the `TextItem`s
|
||||
void draw(CGAL::Three::Viewer_interface* viewer);
|
||||
//!Adds a TextItem to the local list.
|
||||
//!\brief Adds a single TextItem to TextRenderer::local_textItems
|
||||
//!
|
||||
//! @see addText(float p_x, float p_y, float p_z, QString p_text, bool p_3D = true, QFont font = QFont(), QColor p_color = Qt::black)
|
||||
void addText(TextItem*);
|
||||
//!Adds a TextListItem to the global list.
|
||||
void addTextList(TextListItem*);
|
||||
//!Creates a new TextItem and adds it to the local list.
|
||||
//!\brief Creates a new TextItem in TextRenderer::local_textItems
|
||||
//!
|
||||
//!This is a version of addText(TextItem*) that creates the TextItem on the fly.
|
||||
//! @see addText(TextItem*)
|
||||
void addText(float p_x, float p_y, float p_z, QString p_text, bool p_3D = true, QFont font = QFont(), QColor p_color = Qt::black);
|
||||
//!Removes a TextItem from the local list.
|
||||
void removeText(TextItem*);
|
||||
//!Removes a TextItemList from the global list.
|
||||
//!\brief Adds a TextListItem to TextRenderer::textItems
|
||||
//!
|
||||
void addTextList(TextListItem*);
|
||||
//!Removes a `textItem` from TextRenderer::local_textItems
|
||||
//! @see addText(TextItem*)
|
||||
void removeText(TextItem* textItem);
|
||||
//!Removes a TextItemList from TextRenderer::textItems
|
||||
void removeTextList(TextListItem*);
|
||||
//!Returns the local list of TextItems. This is the renderer's default list.
|
||||
//!The local TextListItem.
|
||||
QList<TextItem*> getLocalTextItems(){return local_textItems;}
|
||||
//!Returns the global list of TextItems. This is the list that is fed by pre-filled lists of TextItems (such as global Polyhedron IDs).
|
||||
//!The global list of `TextListItem`s.
|
||||
QList<TextListItem*> items() const{return textItems;}
|
||||
//!Gives the renderer a Scene, needed to determine which Ids must be drawn.
|
||||
//!Gives the renderer a Scene.
|
||||
void setScene(CGAL::Three::Scene_interface* p_scene){scene = p_scene;}
|
||||
//! The maximum `TextItem`s that can be displayed at once.
|
||||
//! @see setMax()
|
||||
int getMax_textItems()const{return max_textItems;}
|
||||
//!Sets the maximum `TextItem`s that can be displayed at once.
|
||||
//! @see getMax_textItems()
|
||||
void setMax(int max){max_textItems = max;}
|
||||
|
||||
Q_SIGNALS:
|
||||
//!Emit this to print `message` on the viewer for `ms_delay` ms.
|
||||
void sendMessage(QString message, int ms_delay =2000);
|
||||
private:
|
||||
protected:
|
||||
//!\brief list of `TextListItem`s
|
||||
//!
|
||||
//! It holds lists of correlated `TextItem`s that are associated to a
|
||||
//! CGAL::Three::Scene_item, like primitiveIds.
|
||||
QList<TextListItem*> textItems;
|
||||
CGAL::Three::Scene_interface *scene;
|
||||
//!\brief List of `TextItem`s
|
||||
//!
|
||||
//! Usually fed by the viewer, it holds the text informations from the
|
||||
//! viewer that are displayed directly on the screen, like the fps,
|
||||
//! the distances, etc.
|
||||
QList<TextItem*> local_textItems;
|
||||
private:
|
||||
CGAL::Three::Scene_interface *scene;
|
||||
int max_textItems;
|
||||
|
||||
};//end class TextRenderer
|
||||
|
|
|
|||
|
|
@ -49,145 +49,177 @@ class VIEWER_EXPORT Viewer_interface : public QGLViewer, public QOpenGLFunctions
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief The OpenGL_program_IDs enum
|
||||
* This enum holds the OpenGL programs IDs that are given to getShaderProgram() and attribBuffers().
|
||||
*@see getShaderProgram
|
||||
* @see attribBuffers
|
||||
*/
|
||||
/*!
|
||||
* \brief The OpenGL_program_IDs enum
|
||||
*
|
||||
* This enum holds the OpenGL programs IDs that are given to getShaderProgram() and attribBuffers().
|
||||
* @see getShaderProgram
|
||||
* @see attribBuffers
|
||||
*/
|
||||
enum OpenGL_program_IDs
|
||||
{
|
||||
PROGRAM_WITH_LIGHT = 0, /** Used to render a surface or edge affected by the light. It uses a per fragment lighting model, and renders brighter the selected item.*/
|
||||
PROGRAM_WITHOUT_LIGHT, /** Used to render a polygon edge or points. It renders in a uniform color and is not affected by light. It renders the selected item in black.*/
|
||||
PROGRAM_NO_SELECTION, /** Used to render a polyline or a surface that is not affected by light, like a cutting plane. It renders in a uniform color that does not change with selection.*/
|
||||
PROGRAM_WITH_TEXTURE, /** Used to render a textured polyhedron. Affected by light.*/
|
||||
PROGRAM_PLANE_TWO_FACES, /** Used to render a two-faced plane. The two faces have a different color. Not affected by light.*/
|
||||
PROGRAM_WITH_TEXTURED_EDGES, /** Used to render the edges of a textured polyhedorn. Not affected by light.*/
|
||||
PROGRAM_INSTANCED, /** Used to display instanced rendered spheres.Affected by light.*/
|
||||
PROGRAM_INSTANCED_WIRE, /** Used to display instanced rendered wired spheres. Not affected by light.*/
|
||||
PROGRAM_C3T3, /** Used to render a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Affected by light.*/
|
||||
PROGRAM_C3T3_EDGES, /** Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.*/
|
||||
PROGRAM_CUTPLANE_SPHERES, /** Used to render the spheres of an item with a cut plane.*/
|
||||
PROGRAM_SPHERES, /** Used to render one or several spheres.*/
|
||||
PROGRAM_C3T3_TETS, /** Used to render the tetrahedra of the intersection of a c3t3_item.*/
|
||||
PROGRAM_FLAT, /** Used to render flat shading without pre computing normals*/
|
||||
NB_OF_PROGRAMS /** Holds the number of different programs in this enum.*/
|
||||
PROGRAM_WITH_LIGHT = 0, //! Used to render a surface or an edge affected by the light. It uses a per fragment lighting model, and renders the selected item brighter.
|
||||
PROGRAM_WITHOUT_LIGHT, //! Used to render a polyhedron edge or points. It renders in a uniform color and is not affected by light. \attention It renders the selected item in black.
|
||||
PROGRAM_NO_SELECTION, //! Used to render a polyline or a surface that is not affected by light, like a cutting plane. It renders in a uniform color that does not change with selection.
|
||||
PROGRAM_WITH_TEXTURE, //! Used to render a textured polyhedron. Affected by light.
|
||||
PROGRAM_PLANE_TWO_FACES, //! Used to render a two-faced plane. The two faces have a different color. Not affected by light.
|
||||
PROGRAM_WITH_TEXTURED_EDGES, //! Used to render the edges of a textured polyhedron. Not affected by light.
|
||||
PROGRAM_INSTANCED, //! Used to display instanced rendered spheres.Affected by light.
|
||||
PROGRAM_INSTANCED_WIRE, //! Used to display instanced rendered wired spheres. Not affected by light.
|
||||
PROGRAM_C3T3, //! Used to render a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Affected by light.
|
||||
PROGRAM_C3T3_EDGES, //! Used to render the edges of a c3t3_item. It discards any fragment on a side of a plane, meaning that nothing is displayed on this side of the plane. Not affected by light.
|
||||
PROGRAM_CUTPLANE_SPHERES, //! Used to render the spheres of an item with a cut plane.
|
||||
PROGRAM_SPHERES, //! Used to render one or several spheres.
|
||||
PROGRAM_C3T3_TETS, //! Used to render the tetrahedra of the intersection of a c3t3_item.
|
||||
PROGRAM_FLAT, //! Used to render flat shading without pre computing normals
|
||||
NB_OF_PROGRAMS //! Holds the number of different programs in this enum.
|
||||
};
|
||||
|
||||
//!Returns the viewer's QPainter
|
||||
//! \brief The viewer's QPainter
|
||||
//!
|
||||
//! The painter is the element that draws everything on screen,
|
||||
//! but you should only need this if you want to draw 2D things
|
||||
//! on top of the scene, like a selection rectangle.
|
||||
//! See <a href="http://doc.qt.io/qt-5/qpainter.html">QPainter's documentation </a> for details.
|
||||
virtual QPainter *getPainter() =0;
|
||||
|
||||
/*!
|
||||
* \brief textRenderer is used to display text on the screen.
|
||||
* The textRenderer uses the painter tu display 2D text over the 3D Scene. It has a list containing the TextItems to display.
|
||||
*/
|
||||
TextRenderer *textRenderer;
|
||||
/*!
|
||||
* \brief testDisplayId checks if the id at position (x,y,z) is visible or not.
|
||||
* \param x the X coordinate of the id's position.
|
||||
* \param y the Y coordinate of the id's position.
|
||||
* \param z the Z coordinate of the id's position.
|
||||
* \return true if the ID is visible. */
|
||||
virtual bool testDisplayId(double x, double y, double z) = 0;
|
||||
//!Recomputes the ids of the selected item.
|
||||
virtual void updateIds(CGAL::Three::Scene_item *) = 0;
|
||||
//!Returns true if the primitive ids are displayed
|
||||
virtual bool hasText() const { return false; }
|
||||
|
||||
|
||||
//! \brief Tests if an id should be displayed or not.
|
||||
//! \param x, y, z the coordinates of the id's position.
|
||||
//! \return true if the ID should be displayed.
|
||||
virtual bool testDisplayId(double x, double y, double z) = 0;
|
||||
//! \brief Updates the item's displayed ids.
|
||||
//!
|
||||
//! Call this after the mesh or its ids have changed.
|
||||
virtual void updateIds(CGAL::Three::Scene_item *) = 0;
|
||||
//! \brief Specifies if the items ids are being displayed.
|
||||
//!
|
||||
//! \returns true if the primitive ids are currently displayed
|
||||
virtual bool hasText() const { return false; }
|
||||
//! \brief Constructor
|
||||
//!
|
||||
//! Creates a valid context for OpenGL 2.1.
|
||||
//! \param parent the parent widget. It usually is the MainWindow.
|
||||
Viewer_interface(QWidget* parent) : QGLViewer(CGAL::Qt::createOpenGLContext(), parent) {}
|
||||
virtual ~Viewer_interface() {}
|
||||
|
||||
//! Sets the scene for the viewer.
|
||||
//! \brief Sets the scene for the viewer.
|
||||
virtual void setScene(CGAL::Three::Scene_draw_interface* scene) = 0;
|
||||
//! @returns the antialiasing state.
|
||||
//! \brief The antialiasing state.
|
||||
//!
|
||||
//! @returns true if the antialiasing is activated.
|
||||
virtual bool antiAliasing() const = 0;
|
||||
|
||||
// Those two functions are defined in Viewer.cpp
|
||||
//!Sets the position and orientation of a frame using a QString.
|
||||
//!@returns true if it worked.
|
||||
static bool readFrame(QString, qglviewer::Frame&);
|
||||
//!@returns a QString contining the position and orientation of a frame.
|
||||
//! \brief Sets the position and orientation of a frame using a QString.
|
||||
//! \param s is usually gotten by dumpFrame() and is of the form "Px Py Pz O1 O2 O3 O4 ", with
|
||||
//! - Px to Py : the new position coordinates,
|
||||
//! - O1 to O3 : axis coordinate *sin(angle/2)
|
||||
//! - O4 cos(angle/2).
|
||||
//! \param frame is the frame that will be moved
|
||||
//! @returns true if it worked.
|
||||
//! @see moveCameraToCoordinates()
|
||||
static bool readFrame(QString s, qglviewer::Frame& frame);
|
||||
//! \brief Gives information about a frame.
|
||||
//! @see readFrame
|
||||
//! @see dumpCameraCoordinates()
|
||||
//!@returns a QString containing the position and orientation of a frame.
|
||||
static QString dumpFrame(const qglviewer::Frame&);
|
||||
//! \brief The fastDrawing state.
|
||||
//!
|
||||
//! In fast drawing mode, some items will be simplified while the camera is moving
|
||||
//! to gain in performance.
|
||||
//! @returns the fastDrawing state.
|
||||
virtual bool inFastDrawing() const = 0;
|
||||
//! @returns if the viewer is in `drawWithNames()`
|
||||
//! \brief The drawWithNames state.
|
||||
//!
|
||||
//! In draw with name mode, the scene is not displayed, but a
|
||||
//! \a name is given to each Scene_item. It is used for picking.
|
||||
//! @returns true if the viewer is drawing with names.
|
||||
virtual bool inDrawWithNames() const = 0;
|
||||
|
||||
/*! Passes all the uniform data to the shaders.
|
||||
* According to program_name, this data may change.
|
||||
* @see OpenGL_program_IDs
|
||||
*/
|
||||
//! \brief Passes all the uniform data to the shaders.
|
||||
//!
|
||||
//! According to program_name, this data may change.
|
||||
//! This should be called in every Scene_item::draw() call.
|
||||
//! @see OpenGL_program_IDs
|
||||
//!
|
||||
virtual void attribBuffers(int program_name) const = 0;
|
||||
|
||||
/*! Returns a program according to name.
|
||||
* If the program does not exist yet, it is created and stored in shader_programs.
|
||||
* @see OpenGL_program_IDs
|
||||
* @returns a pointer to the corresponding program.*/
|
||||
//! \brief Returns a program according to name.
|
||||
//!
|
||||
//! If the program does not exist yet, it is created and stored in shader_programs.
|
||||
//! @see OpenGL_program_IDs
|
||||
//! @returns a pointer to the corresponding program.
|
||||
virtual QOpenGLShaderProgram* getShaderProgram(int name) const = 0;
|
||||
|
||||
//!\brief TextRenderer is used to display text on the screen.
|
||||
//!
|
||||
//! The textRenderer uses the painter to display 2D text over the 3D Scene.
|
||||
//! \returns the viewer's TextRender
|
||||
virtual TextRenderer* textRenderer() = 0;
|
||||
//!Allows OpenGL 2.1 context to get access to glDrawArraysInstanced.
|
||||
typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
|
||||
//!Allows OpenGL 2.1 context to get access to glVertexAttribDivisor.
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORARBPROC) (GLuint index, GLuint divisor);
|
||||
//!Allows OpenGL 2.1 context to get access to glVertexAttribDivisor.
|
||||
typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint target, GLuint attachment, GLuint textarget, GLuint texture, GLint level);
|
||||
//!Allows OpenGL 2.1 context to get access to gkFrameBufferTexture2D.
|
||||
|
||||
PFNGLDRAWARRAYSINSTANCEDARBPROC glDrawArraysInstanced;
|
||||
//!Allows OpenGL 2.1 context to get access to glVertexAttribDivisor.
|
||||
PFNGLVERTEXATTRIBDIVISORARBPROC glVertexAttribDivisor;
|
||||
//!Allows OpenGL 2.1 context to get access to gkFrameBufferTexture2D.
|
||||
PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2D;
|
||||
|
||||
//! \brief Used by the items to avoid SEGFAULT.
|
||||
//!@returns true if glVertexAttribDivisor, and glDrawArraysInstanced are found.
|
||||
//! Used by the items to avoid SEGFAULT.
|
||||
bool extension_is_found;
|
||||
//!The matrix used for the picking.
|
||||
mutable GLfloat pickMatrix_[16];
|
||||
virtual bool isExtensionFound() = 0;
|
||||
//!Returns the scene's offset
|
||||
virtual qglviewer::Vec offset()const = 0;
|
||||
//!Sets the binding for SHIFT+LEFT CLICK to SELECT (initially used in Scene_polyhedron_selection_item.h)
|
||||
void setBindingSelect()
|
||||
{
|
||||
#if QGLVIEWER_VERSION >= 0x020501
|
||||
setMouseBinding(::Qt::ShiftModifier, ::Qt::LeftButton, SELECT);
|
||||
#else
|
||||
setMouseBinding(::Qt::SHIFT + ::Qt::LeftButton, SELECT);
|
||||
#endif
|
||||
}
|
||||
//!Sets the binding for SHIFT+LEFT CLICK to NO_CLICK_ACTION (initially used in Scene_polyhedron_selection_item.h)
|
||||
void setNoBinding()
|
||||
{
|
||||
#if QGLVIEWER_VERSION >= 0x020501
|
||||
setMouseBinding(::Qt::ShiftModifier, ::Qt::LeftButton, NO_CLICK_ACTION);
|
||||
#else
|
||||
setMouseBinding(::Qt::SHIFT + ::Qt::LeftButton, NO_CLICK_ACTION);
|
||||
#endif
|
||||
}
|
||||
//!\brief Allows to perform picking from the keyboard and mouse
|
||||
//!
|
||||
//! Sets the combination SHIFT+LEFT CLICK to perform a selection on the screen.
|
||||
//! This is used to perform picking.
|
||||
virtual void setBindingSelect() = 0;
|
||||
//!\brief Disable the picking from the keyboard and mouse
|
||||
//!
|
||||
//! Unbinds the combination SHIFT+LEFT CLICK. It allows to
|
||||
//! avoid conflicts in the selection_tool, for example.
|
||||
virtual void setNoBinding() = 0 ;
|
||||
|
||||
Q_SIGNALS:
|
||||
//!Is emitted after an item is picked.
|
||||
void selected(int);
|
||||
//!Is emitted to require a contextual menu to appear at global_pos.
|
||||
//!Emit this to signal that the `id`th item has been picked.
|
||||
void selected(int id);
|
||||
//!Emit this to require a contextual menu to appear at `global_pos`.
|
||||
void requestContextMenu(QPoint global_pos);
|
||||
//!Is emitted after a point is selected.
|
||||
void selectedPoint(double, double, double);
|
||||
//!Is emitted to request the currently selected item to perform a selection based on an AABB_Tree and a raycasting.
|
||||
void selectionRay(double, double, double, double, double, double);
|
||||
//!Emit this to signal that the point at (`x`, `y`, `z`) has been picked.
|
||||
void selectedPoint(double x, double y, double z);
|
||||
//!Emit this to request the currently selected item to perform a selection based on an AABB_Tree and a raycasting.
|
||||
void selectionRay(double sx, double sy, double sz, double tx, double ty, double tz);
|
||||
|
||||
public Q_SLOTS:
|
||||
//! Sets the antialiasing to true or false.
|
||||
//! @see antiAliasing()
|
||||
virtual void setAntiAliasing(bool b) = 0;
|
||||
//! If b is true, facets will be ligted from both internal and external sides.
|
||||
//! If b is true, faces will be ligted from both internal and external side.
|
||||
//! If b is false, only the side that is exposed to the light source will be lighted.
|
||||
virtual void setTwoSides(bool b) = 0;
|
||||
//! If b is true, some items are displayed in a simplified version when moving the camera.
|
||||
//! If b is false, items display is never altered, even when moving.
|
||||
//! \brief Sets the fast drawing mode
|
||||
//! @see inFastDrawing()
|
||||
virtual void setFastDrawing(bool b) = 0;
|
||||
//! Make the camera turn around.
|
||||
//! Makes the camera turn around.
|
||||
virtual void turnCameraBy180Degres() = 0;
|
||||
//! @returns a QString containing the position and orientation of the camera.
|
||||
//! @see dumpFrame()
|
||||
virtual QString dumpCameraCoordinates() = 0;
|
||||
//!Moves the camera to the new coordinates (position and orientation) through an animation.
|
||||
virtual bool moveCameraToCoordinates(QString,
|
||||
//! \brief Moves the camera to the new coordinates.
|
||||
//!
|
||||
//! The movement is performed through an animation.
|
||||
//! \param target is usually gotten by dumpCameraCoordinates() and is of the form "Px Py Pz O1 O2 O3 O4 ", with
|
||||
//! - Px to Py : the new position coordinates,
|
||||
//! - O1 to O3 : axis coordinate *sin(angle/2)
|
||||
//! - O4 cos(angle/2).
|
||||
//! \param animation_duration is the duration of the animation of the movement.
|
||||
virtual bool moveCameraToCoordinates(QString target,
|
||||
float animation_duration = 0.5f) = 0;
|
||||
|
||||
}; // end class Viewer_interface
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ MainWindow::MainWindow(QWidget* parent)
|
|||
// addAboutDemo(QString htmlResourceName) is also a function in DemoMainWindow
|
||||
// it will add a menu action "About Demo..." to Help menu
|
||||
// when the action is invoked, it will popup a messageBox showing the given html
|
||||
this->addAboutDemo( "documentation/about.html" );
|
||||
this->addAboutDemo( ":/documentation/documentation/about.html" );
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -214,14 +214,9 @@ void MainWindow::on_actionClear_Scene_triggered()
|
|||
void MainWindow::popupAboutCGAL()
|
||||
{
|
||||
// read contents from .html file
|
||||
QFile about_CGAL( "documentation/about_CGAL.html" );
|
||||
about_CGAL.open(QIODevice::ReadOnly);
|
||||
QFile about_CGAL(":/documentation/documentation/about.html");
|
||||
about_CGAL.open(QIODevice::ReadOnly|QIODevice::Text);
|
||||
QString about_CGAL_txt = QTextStream(&about_CGAL).readAll();
|
||||
#ifdef CGAL_VERSION_STR
|
||||
about_CGAL_txt.replace("<!--CGAL_VERSION-->",
|
||||
QString(" (version %1, svn r%2)")
|
||||
.arg(CGAL_VERSION_STR).arg(CGAL_SVN_REVISION));
|
||||
#endif
|
||||
|
||||
// popup a message box
|
||||
QMessageBox mb(QMessageBox::NoIcon,
|
||||
|
|
@ -233,8 +228,8 @@ void MainWindow::popupAboutCGAL()
|
|||
// set links to be accessible by mouse or keyboard
|
||||
QLabel* mb_label = mb.findChild<QLabel*>("qt_msgbox_label");
|
||||
if(mb_label) {
|
||||
mb_label->setTextInteractionFlags(mb_label->textInteractionFlags() |
|
||||
::Qt::LinksAccessibleByMouse |
|
||||
mb_label->setTextInteractionFlags(mb_label->textInteractionFlags() |
|
||||
::Qt::LinksAccessibleByMouse |
|
||||
::Qt::LinksAccessibleByKeyboard);
|
||||
} else {
|
||||
std::cerr << "Cannot find child \"qt_msgbox_label\" in QMessageBox\n"
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1010</width>
|
||||
<height>22</height>
|
||||
<width>1100</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
|
|||
|
|
@ -1,31 +1,35 @@
|
|||
<RCC>
|
||||
<qresource prefix="/T3_demo/icons">
|
||||
<file>icons/flat.png</file>
|
||||
<file>icons/stereo.png</file>
|
||||
<file>icons/pause.jpeg</file>
|
||||
<file>icons/show_delaunay.jpeg</file>
|
||||
<file>icons/show_facet.jpeg</file>
|
||||
<file>icons/show_point.jpeg</file>
|
||||
<file>icons/show_voronoi.jpeg</file>
|
||||
<file>icons/play.jpeg</file>
|
||||
<file>icons/stop.jpeg</file>
|
||||
<file>icons/empty_sphere.jpeg</file>
|
||||
<file>icons/normal_view.jpeg</file>
|
||||
<file>icons/nearest_nb.png</file>
|
||||
<file>icons/quit.jpeg</file>
|
||||
<file>icons/insert_point.jpg</file>
|
||||
<file>icons/clear.jpeg</file>
|
||||
<file>icons/coordinates.jpeg</file>
|
||||
<file>icons/fileOpen.png</file>
|
||||
<file>icons/pointRandom.png</file>
|
||||
<file>icons/fileSave.png</file>
|
||||
<file>icons/cgal_logo.xpm</file>
|
||||
<file>icons/insert.jpeg</file>
|
||||
<file>icons/move_1.jpeg</file>
|
||||
<file>icons/select_hand.jpeg</file>
|
||||
<file>icons/preferences.jpeg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/T3_demo/html">
|
||||
<file>icons/about_CGAL.html</file>
|
||||
</qresource>
|
||||
<qresource prefix="/T3_demo/icons">
|
||||
<file>icons/flat.png</file>
|
||||
<file>icons/stereo.png</file>
|
||||
<file>icons/pause.jpeg</file>
|
||||
<file>icons/show_delaunay.jpeg</file>
|
||||
<file>icons/show_facet.jpeg</file>
|
||||
<file>icons/show_point.jpeg</file>
|
||||
<file>icons/show_voronoi.jpeg</file>
|
||||
<file>icons/play.jpeg</file>
|
||||
<file>icons/stop.jpeg</file>
|
||||
<file>icons/empty_sphere.jpeg</file>
|
||||
<file>icons/normal_view.jpeg</file>
|
||||
<file>icons/nearest_nb.png</file>
|
||||
<file>icons/quit.jpeg</file>
|
||||
<file>icons/insert_point.jpg</file>
|
||||
<file>icons/clear.jpeg</file>
|
||||
<file>icons/coordinates.jpeg</file>
|
||||
<file>icons/fileOpen.png</file>
|
||||
<file>icons/pointRandom.png</file>
|
||||
<file>icons/fileSave.png</file>
|
||||
<file>icons/cgal_logo.xpm</file>
|
||||
<file>icons/insert.jpeg</file>
|
||||
<file>icons/move_1.jpeg</file>
|
||||
<file>icons/select_hand.jpeg</file>
|
||||
<file>icons/preferences.jpeg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/T3_demo/html">
|
||||
<file>icons/about_CGAL.html</file>
|
||||
</qresource>
|
||||
<qresource prefix="/documentation">
|
||||
<file>documentation/about.html</file>
|
||||
<file>documentation/about_CGAL.html</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
Loading…
Reference in New Issue