diff --git a/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark.cpp b/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark.cpp index b31ff45ad51..03abfbe43c3 100644 --- a/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark.cpp +++ b/Isosurfacing_3/benchmark/Isosurfacing_3/benchmark.cpp @@ -4,11 +4,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomain.h b/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomain.h deleted file mode 100644 index 6d337669492..00000000000 --- a/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomain.h +++ /dev/null @@ -1,176 +0,0 @@ -/*! -\ingroup PkgIsosurfacing3Concepts - -\cgalConcept - -The concept `IsosurfacingDomain` describes the set of requirements to be -fulfilled by any class used as input data for any isosurfacing algorithms. - -\cgalHasModel `CGAL::Isosurfacing::Explicit_cartesian_grid_domain` -\cgalHasModel `CGAL::Isosurfacing::Implicit_cartesian_grid_domain` -*/ -class IsosurfacingDomain -{ -public: - /// \name Types - /// @{ - - /*! - Traits type model of \cgal %Kernel - */ - typedef unspecified_type Geom_traits; - - /*! - The scalar type. - */ - typedef unspecified_type FT; - - /*! - The point type. - */ - typedef unspecified_type Point; - - /*! - A descriptor to uniquely identify a vertex. - */ - typedef unspecified_type Vertex_descriptor; - - /*! - A descriptor to uniquely identify an edge. - */ - typedef unspecified_type Edge_descriptor; - - /*! - A descriptor to uniquely identify a cell. - */ - typedef unspecified_type Cell_descriptor; - - /*! - A container for the two vertices of an edge. - Must be a model of the concept `RandomAccessContainer` with size 2 whose value type is `Vertex_descriptor`. - */ - typedef unspecified_type Vertices_incident_to_edge; - - /*! - A container for the cells incident to an edge. - Must be a model of the concept `Container` whose value type is `Cell_descriptor`. - */ - typedef unspecified_type Cells_incident_to_edge; - - /*! - A container for the vertices of a cell. - Must be a model of the concept `Container` whose value type is `Vertex_descriptor`. - */ - typedef unspecified_type Cell_vertices; - - /*! - A container for the edges of a cell. - Must be a model of the concept `Container` whose value type is `Edge_descriptor`. - */ - typedef unspecified_type Cell_edges; - - - /// @} - - /// \name Operations - /// The following member functions must exist. - /// @{ - - /*! - Get the position of a vertex in 3D space - - \param v the descriptor of the vertex - - \return the position of the vertex as a point - */ - Point position(const Vertex_descriptor& v) const; - - /*! - Get the value of the function at a vertex - - \param v the descriptor of the vertex - - \return the value of the function - */ - FT value(const Vertex_descriptor& v) const; - - /*! - Get the two vertices incident to an edge - - \param e the descriptor of the edge - - \return a collection of the two vertex descriptors - */ - Vertices_incident_to_edge edge_vertices(const Edge_descriptor& e) const; - - /*! - Get all cells incident to an edge - - \param e the descriptor of the edge - - \return a collection of cell descriptors - */ - Cells_incident_to_edge cells_incident_to_edge(const Edge_descriptor& e) const; - - /*! - Get all vertices of the a cell - - \param c the descriptor of the cell - - \return a collection of vertex descriptors - */ - Cell_vertices cell_vertices(const Cell_descriptor& c) const; - - /*! - Get all edges of the cell c - - \param c the descriptor of the cell - - \return a collection of edge descriptors - */ - Cell_edges cell_edges(const Cell_descriptor& c) const; - - /*! - Iterate over all vertices and call a functor on each one - - /tparam Concurrency_tag decides if the vertices are iterated sequentially or in parallel. - Can be either `CGAL::Sequential_tag` or `CGAL::Parallel_tag`. - Only the sequential version has to be implemented. The parallel version is optional. - - /tparam Functor must implement `void operator()(const Vertex_descriptor& vertex)` - - \param f the functor called with every vertex - */ - template - void iterate_vertices(Functor& f) const; - - /*! - Iterate over all edges and call the functor f on each one - - /tparam Concurrency_tag decides if the edges are iterated sequentially or in parallel. - Can be either `CGAL::Sequential_tag` or `CGAL::Parallel_tag`. - Only the sequential version has to be implemented. The parallel version is optional. - - /tparam Functor must implement `void operator()(const Edge_descriptor& edge)`. - - \param f the functor called with every edge - */ - template - void iterate_edges(Functor& f) const; - - /*! - Iterate sequentially over all cells and call the functor f on each one - - /tparam Concurrency_tag decides if the cells are iterated sequentially or in parallel. - Can be either `CGAL::Sequential_tag` or `CGAL::Parallel_tag`. - Only the sequential version has to be implemented. The parallel version is optional. - - /tparam Functor must implement `void operator()(const Cell_descriptor& cell)`. - - \param f the functor called with every cell - */ - template - void iterate_cells(Functor& f) const; - - /// @} -}; diff --git a/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomainWithGradient.h b/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomainWithGradient.h deleted file mode 100644 index ac6b98d99b6..00000000000 --- a/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomainWithGradient.h +++ /dev/null @@ -1,40 +0,0 @@ -/*! -\ingroup PkgIsosurfacing3Concepts - -\cgalConcept - -The concept `IsosurfacingDomainWithGradient` describes the set of requirements to be -fulfilled by any class used as input data for some isosurfacing algorithms. - -\cgalHasModel `CGAL::Isosurfacing::Explicit_cartesian_grid_domain` -\cgalHasModel `CGAL::Isosurfacing::Implicit_cartesian_grid_domain` -*/ -class IsosurfacingDomainWithGradient - : public IsosurfacingDomain -{ -public: - /// \name Types - /// @{ - - /*! - The vector type. - */ - typedef unspecified_type Vector; - - /// @} - - /// \name Operations - /// The following member function must exist. - /// @{ - - /*! - Get the gradient at a position - - \param p the point at which the gradient is evaluated - - \return the gradient vector - */ - Vector gradient(const Point& p) const; - - /// @} -}; diff --git a/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomainWithGradient_3.h b/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomainWithGradient_3.h new file mode 100644 index 00000000000..5e790b5735c --- /dev/null +++ b/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomainWithGradient_3.h @@ -0,0 +1,42 @@ +/*! +\ingroup PkgIsosurfacing3Concepts + +\cgalConcept + +\cgalRefines `IsosurfacingDomain_3` + +\brief The concept `IsosurfacingDomainWithGradient_3` describes the set of requirements to be +fulfilled by any class used as input data for some isosurfacing algorithms. + +\cgalHasModel `CGAL::Isosurfacing::Explicit_Cartesian_grid_domain_3` +\cgalHasModel `CGAL::Isosurfacing::Implicit_Cartesian_grid_domain_3` +*/ +class IsosurfacingDomainWithGradient_3 +{ +public: + /// \name Types + /// @{ + + /*! + The geometric traits type. + Must be a model of `IsosurfacingTraits_3`. + */ + typedef unspecified_type Geom_traits; + + /*! + The vector type. + */ + typedef Geom_traits::Vector_3 Vector_3; + + /// @} + + /// \name Operations + /// @{ + + /*! + gets the gradient at a position + */ + Vector_3 gradient(const Geom_traits::Point_3& p) const; + + /// @} +}; diff --git a/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomain_3.h b/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomain_3.h new file mode 100644 index 00000000000..6f18b47350c --- /dev/null +++ b/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingDomain_3.h @@ -0,0 +1,149 @@ +/*! +\ingroup PkgIsosurfacing3Concepts + +\cgalConcept + +The concept `IsosurfacingDomain_3` describes the set of requirements to be +fulfilled by any class used as input data for any isosurfacing algorithms. + +\cgalHasModel `CGAL::Isosurfacing::Explicit_Cartesian_grid_domain_3` +\cgalHasModel `CGAL::Isosurfacing::Implicit_Cartesian_grid_domain_3` +*/ +class IsosurfacingDomain_3 +{ +public: + /// \name Types + /// @{ + + /*! + The geometric traits type. + Must be a model of `IsosurfacingTraits_3`. + */ + typedef unspecified_type Geom_traits; + + /*! + The scalar type. + */ + typedef Geom_traits::FT FT; + + /*! + The 3D point type. + */ + typedef Geom_traits::Point_3 Point_3; + + /*! + A descriptor to uniquely identify a vertex. + Must be a model of the concepts `DefaultConstructible`, `CopyConstructible`, and `Assignable`. + */ + typedef unspecified_type Vertex_descriptor; + + /*! + A descriptor to uniquely identify an edge. + Must be a model of the concepts `DefaultConstructible`, `CopyConstructible`, and `Assignable`. + */ + typedef unspecified_type Edge_descriptor; + + /*! + A descriptor to uniquely identify a cell. + Must be a model of the concepts `DefaultConstructible`, `CopyConstructible`, and `Assignable`. + */ + typedef unspecified_type Cell_descriptor; + + /*! + A container for the two vertices of an edge. + Must be a model of the concept `RandomAccessContainer` of size `2` whose value type is `Vertex_descriptor`. + */ + typedef unspecified_type Vertices_incident_to_edge; + + /*! + A container for the cells incident to an edge. + Must be a model of the concept `Container` whose value type is `Cell_descriptor`. + */ + typedef unspecified_type Cells_incident_to_edge; + + /*! + A container for the vertices of a cell. + Must be a model of the concept `Container` whose value type is `Vertex_descriptor`. + */ + typedef unspecified_type Cell_vertices; + + /*! + A container for the edges of a cell. + Must be a model of the concept `Container` whose value type is `Edge_descriptor`. + */ + typedef unspecified_type Cell_edges; + + + /// @} + + /// \name Operations + /// The following member functions must exist. + /// @{ + + /*! + gets the position of a vertex in 3D space + */ + Point_3 point(const Vertex_descriptor& v) const; + + /*! + gets the value of the function at a vertex + */ + FT value(const Vertex_descriptor& v) const; + + /*! + gets the two vertices incident to an edge + */ + Vertices_incident_to_edge incident_vertices(const Edge_descriptor& e) const; + + /*! + gets all cells incident to an edge + */ + Cells_incident_to_edge incident_cells(const Edge_descriptor& e) const; + + /*! + gets all vertices of the a cell + */ + Cell_vertices cell_vertices(const Cell_descriptor& c) const; + + /*! + gets all edges of the cell c + */ + Cell_edges cell_edges(const Cell_descriptor& c) const; + + /*! + iterates over all vertices and call a functor on each one + + \tparam ConcurrencyTag decides if the vertices are iterated sequentially or in parallel. + Can be either `CGAL::Sequential_tag`, `CGAL::Parallel_if_available_tag`, or `CGAL::Parallel_tag`. + + \tparam Functor must implement `void operator()(const Vertex_descriptor& vertex)` + + \param f the functor called with every vertex + */ + template + void iterate_vertices(Functor& f) const; + + /*! + iterates over all edges and call a functor f on each one + + \tparam ConcurrencyTag decides if the edges are iterated sequentially or in parallel. + Can be either `CGAL::Sequential_tag`, `CGAL::Parallel_if_available_tag`, or `CGAL::Parallel_tag`. + + \tparam Functor must implement `void operator()(const Edge_descriptor& edge)`. + */ + template + void iterate_edges(Functor& f) const; + + /*! + iterates over all cells and call a functor f on each one + + \tparam ConcurrencyTag decides if the cells are iterated sequentially or in parallel. + Can be either `CGAL::Sequential_tag`, `CGAL::Parallel_if_available_tag`, or `CGAL::Parallel_tag`. + + \tparam Functor must implement `void operator()(const Cell_descriptor& cell)`. + */ + template + void iterate_cells(Functor& f) const; + + /// @} +}; diff --git a/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingTraits_3.h b/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingTraits_3.h new file mode 100644 index 00000000000..37e493c378d --- /dev/null +++ b/Isosurfacing_3/doc/Isosurfacing_3/Concepts/IsosurfacingTraits_3.h @@ -0,0 +1,153 @@ +/*! +\ingroup PkgIsosurfacing3Concepts + +\cgalConcept + +The concept `IsosurfacingTraits_3` describes the set of requirements to be +fulfilled by any traits class of a model of `IsosurfacingDomain_3`. + +\cgalHasModel All models of `Kernel`. +*/ +class IsosurfacingTraits_3 +{ +public: + /// \name Types + /// @{ + + /*! + The scalar type. + Must be a model of `FieldNumberType` + */ + typedef unspecified_type FT; + + /*! + The 3D point type. + Must be a model of `DefaultConstructible` and `CopyConstructible` + */ + typedef unspecified_type Point_3; + + /*! + The 3D vector type. + Must be a model of `DefaultConstructible` and `CopyConstructible` + */ + typedef unspecified_type Vector_3; + + /*! + A construction object that must provide the function operators: + + `FT operator()(Point_3 p)` + + and + + `FT operator()(Vector_3 p)` + + which return the \f$ x\f$-coordinate of the point and the vector, respectively. + */ + typedef unspecified_type Compute_x_3; + + /*! + A construction object that must provide the function operators: + + `FT operator()(Point_3 p)` + + and + + `FT operator()(Vector_3 p)` + + which return the \f$ y\f$-coordinate of the point and the vector, respectively. + */ + typedef unspecified_type Compute_y_3; + + /*! + A construction object that must provide the function operators: + + `FT operator()(Point_3 p)` + + and + + `FT operator()(Vector_3 p)` + + which return the \f$ z\f$-coordinate of the point and the vector, respectively. + */ + typedef unspecified_type Compute_z_3; + + /*! + A construction object that must provide the function operator: + + `Point_3 operator()(FT x, FT y, FT z)` + + which constructs a 3D point from a set of coordinates. + */ + typedef unspecified_type Construct_point_3; + + /*! + A construction object that must provide the function operator: + + `Vector_3 operator()(FT x, FT y, FT z)` + + which constructs a 3D vector from a set of coordinates. + */ + typedef unspecified_type Construct_vector_3; + + /*! + A construction object that must provide the function operator: + + `Vector_3 operator()(Vector_3 v, FT s)` + + which returns the vector `v` scaled by a factor `s`. + */ + typedef unspecified_type Construct_scaled_vector_3; + + /*! + A construction object that must provide the function operator: + + `Vector_3 operator()(Vector_3 v1, Vector_3 v2)` + + which returns the vector `v1 + v2`. + */ + typedef unspecified_type Construct_sum_of_vectors_3; + + /// @} + + /// \name Operations + /// The following functions give access to the predicate and construction objects: + /// @{ + + /*! + + */ + Compute_x_3 compute_x_3_object(); + + /*! + + */ + Compute_y_3 compute_y_3_object(); + + /*! + + */ + Compute_z_3 compute_z_3_object(); + + /*! + + */ + Construct_point_3 construct_point_3_object(); + + /*! + + */ + Construct_vector_3 construct_vector_3_object(); + + /*! + + */ + Construct_scaled_vector_3 construct_scaled_vector_3_object(); + + /*! + + */ + Construct_sum_of_vectors_3 construct_sum_of_vectors_3_object(); + + /// @} + +}; diff --git a/Isosurfacing_3/doc/Isosurfacing_3/PackageDescription.txt b/Isosurfacing_3/doc/Isosurfacing_3/PackageDescription.txt index bf9770851ec..3fb2154035c 100644 --- a/Isosurfacing_3/doc/Isosurfacing_3/PackageDescription.txt +++ b/Isosurfacing_3/doc/Isosurfacing_3/PackageDescription.txt @@ -2,6 +2,15 @@ /// \defgroup PkgIsosurfacing3Concepts Concepts /// \ingroup PkgIsosurfacing3Ref +/// \defgroup IS_Domains_grp Isosurfacing Domains +/// \ingroup PkgIsosurfacing3Ref + +/// \defgroup IS_Domain_helpers_grp Isosurfacing Domain Helpers +/// \ingroup IS_Domains_grp + +/// \defgroup IS_Methods_grp Isosurfacing Methods +/// \ingroup PkgIsosurfacing3Ref + /*! \addtogroup PkgIsosurfacing3Ref \cgalPkgDescriptionBegin{3D Isosurfacing,PkgIsosurfacing3} @@ -27,22 +36,23 @@ The provided algorithms include Marching Cubes, topologically correct Marching C \cgalClassifedRefPages \cgalCRPSection{Concepts} -- `IsosurfacingDomain` -- `IsosurfacingDomainWithGradient` +- `IsosurfacingTraits_3` +- `IsosurfacingDomain_3` +- `IsosurfacingDomainWithGradient_3` -\cgalCRPSection{Classes} -- `CGAL::Cartesian_grid_3` -- `CGAL::Isosurfacing::Explicit_cartesian_grid_domain` -- `CGAL::Isosurfacing::Implicit_cartesian_grid_domain` +\cgalCRPSection{Isosurfacing Domains} +- `CGAL::Isosurfacing::create_explicit_Cartesian_grid_domain()` +- `CGAL::Isosurfacing::create_implicit_Cartesian_grid_domain()` +- `CGAL::Isosurfacing::Explicit_Cartesian_grid_domain_3` +- `CGAL::Isosurfacing::Implicit_Cartesian_grid_domain_3` +- `CGAL::Isosurfacing::Cartesian_grid_3` - `CGAL::Isosurfacing::Zero_gradient` -- `CGAL::Isosurfacing::Finite_difference_gradient` -- `CGAL::Isosurfacing::Explicit_cartesian_grid_gradient` +- `CGAL::Isosurfacing::Finite_difference_gradient_3` +- `CGAL::Isosurfacing::Explicit_Cartesian_grid_gradient_3` -\cgalCRPSection{Free Functions} +\cgalCRPSection{Isosurfacing Methods} - `CGAL::Isosurfacing::marching_cubes()` - `CGAL::Isosurfacing::dual_contouring()` -- `CGAL::Isosurfacing::create_explicit_cartesian_grid_domain()` -- `CGAL::Isosurfacing::create_implicit_cartesian_grid_domain()` */ diff --git a/Isosurfacing_3/doc/Isosurfacing_3/dependencies b/Isosurfacing_3/doc/Isosurfacing_3/dependencies index 1d8213a8e3a..b9fad59cc13 100644 --- a/Isosurfacing_3/doc/Isosurfacing_3/dependencies +++ b/Isosurfacing_3/doc/Isosurfacing_3/dependencies @@ -1,5 +1,6 @@ Manual Kernel_23 +BGL STL_Extension Algebraic_foundations Circulator diff --git a/Isosurfacing_3/doc/Isosurfacing_3/examples.txt b/Isosurfacing_3/doc/Isosurfacing_3/examples.txt index 28df4609397..4850687e77e 100644 --- a/Isosurfacing_3/doc/Isosurfacing_3/examples.txt +++ b/Isosurfacing_3/doc/Isosurfacing_3/examples.txt @@ -1,10 +1,10 @@ /*! \example Isosurfacing_3/marching_cubes_implicit_sphere.cpp -\example Isosurfacing_3/marching_cubes_cartesian_grid_sphere.cpp +\example Isosurfacing_3/marching_cubes_Cartesian_grid_sphere.cpp \example Isosurfacing_3/marching_cubes_inrimage.cpp \example Isosurfacing_3/marching_cubes_signed_mesh_offset.cpp -\example Isosurfacing_3/dual_contouring_cartesian_grid.cpp +\example Isosurfacing_3/dual_contouring_Cartesian_grid.cpp \example Isosurfacing_3/dual_contouring_mesh_offset.cpp \example Isosurfacing_3/dual_contouring_octree.cpp -\example Isosurfacing_3/all_cartesian_cube.cpp +\example Isosurfacing_3/all_Cartesian_cube.cpp */ diff --git a/Isosurfacing_3/examples/Isosurfacing_3/CMakeLists.txt b/Isosurfacing_3/examples/Isosurfacing_3/CMakeLists.txt index 248588c7d8f..0d885a0b05c 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/CMakeLists.txt +++ b/Isosurfacing_3/examples/Isosurfacing_3/CMakeLists.txt @@ -7,15 +7,15 @@ project( Isosurfacing_3_Examples ) find_package(CGAL REQUIRED) create_single_source_cgal_program( "marching_cubes_implicit_sphere.cpp" ) -create_single_source_cgal_program( "marching_cubes_cartesian_grid_sphere.cpp" ) +create_single_source_cgal_program( "marching_cubes_Cartesian_grid_sphere.cpp" ) create_single_source_cgal_program( "marching_cubes_signed_mesh_offset.cpp" ) create_single_source_cgal_program( "marching_cubes_inrimage.cpp" ) find_package(Eigen3 3.1.0 QUIET) #(3.1.0 or greater) include(CGAL_Eigen3_support) if(TARGET CGAL::Eigen3_support) - create_single_source_cgal_program( "dual_contouring_cartesian_grid.cpp" ) - target_link_libraries(dual_contouring_cartesian_grid PRIVATE CGAL::Eigen3_support) + create_single_source_cgal_program( "dual_contouring_Cartesian_grid.cpp" ) + target_link_libraries(dual_contouring_Cartesian_grid PRIVATE CGAL::Eigen3_support) create_single_source_cgal_program( "dual_contouring_mesh_offset.cpp" ) target_link_libraries(dual_contouring_mesh_offset PRIVATE CGAL::Eigen3_support) @@ -23,8 +23,8 @@ if(TARGET CGAL::Eigen3_support) create_single_source_cgal_program( "dual_contouring_octree.cpp" ) target_link_libraries(dual_contouring_octree PRIVATE CGAL::Eigen3_support) - create_single_source_cgal_program( "all_cartesian_cube.cpp" ) - target_link_libraries(all_cartesian_cube PRIVATE CGAL::Eigen3_support) + create_single_source_cgal_program( "all_Cartesian_cube.cpp" ) + target_link_libraries(all_Cartesian_cube PRIVATE CGAL::Eigen3_support) create_single_source_cgal_program( "dual_contouring_implicit_iwp.cpp" ) target_link_libraries(dual_contouring_implicit_iwp PRIVATE CGAL::Eigen3_support) @@ -36,15 +36,15 @@ find_package(TBB QUIET) include(CGAL_TBB_support) if(TARGET CGAL::TBB_support) target_link_libraries(marching_cubes_implicit_sphere PRIVATE CGAL::TBB_support) - target_link_libraries(marching_cubes_cartesian_grid_sphere PRIVATE CGAL::TBB_support) + target_link_libraries(marching_cubes_Cartesian_grid_sphere PRIVATE CGAL::TBB_support) target_link_libraries(marching_cubes_signed_mesh_offset PRIVATE CGAL::TBB_support) target_link_libraries(marching_cubes_inrimage PRIVATE CGAL::TBB_support) if(TARGET CGAL::Eigen3_support) - target_link_libraries(dual_contouring_cartesian_grid PRIVATE CGAL::TBB_support) + target_link_libraries(dual_contouring_Cartesian_grid PRIVATE CGAL::TBB_support) target_link_libraries(dual_contouring_mesh_offset PRIVATE CGAL::TBB_support) target_link_libraries(dual_contouring_octree PRIVATE CGAL::TBB_support) - target_link_libraries(all_cartesian_cube PRIVATE CGAL::TBB_support) + target_link_libraries(all_Cartesian_cube PRIVATE CGAL::TBB_support) target_link_libraries(dual_contouring_implicit_iwp PRIVATE CGAL::TBB_support) endif() endif() diff --git a/Isosurfacing_3/examples/Isosurfacing_3/all_cartesian_cube.cpp b/Isosurfacing_3/examples/Isosurfacing_3/all_Cartesian_cube.cpp similarity index 81% rename from Isosurfacing_3/examples/Isosurfacing_3/all_cartesian_cube.cpp rename to Isosurfacing_3/examples/Isosurfacing_3/all_Cartesian_cube.cpp index c81aaeddb87..2db3d21de2e 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/all_cartesian_cube.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/all_Cartesian_cube.cpp @@ -1,9 +1,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include @@ -12,7 +12,7 @@ using FT = typename Kernel::FT; using Point = typename Kernel::Point_3; using Vector = typename Kernel::Vector_3; -using Grid = CGAL::Cartesian_grid_3; +using Grid = CGAL::Isosurfacing::Cartesian_grid_3; using Point_range = std::vector; using Polygon_range = std::vector >; @@ -34,9 +34,9 @@ int main(int, char**) for(std::size_t y=0; y(grid, cube_gradient); + auto domain = CGAL::Isosurfacing::create_explicit_Cartesian_grid_domain(grid, cube_gradient); // containers for output indexed surface meshes Point_range points_mc, points_dc; @@ -76,7 +76,7 @@ int main(int, char**) // run topologically correct Marching Cubes and Dual Contouring with given isovalue const FT isovalue = 0.88; - CGAL::Isosurfacing::marching_cubes(domain, isovalue, points_mc, polygons_mc, true); + CGAL::Isosurfacing::marching_cubes(domain, isovalue, points_mc, polygons_mc); CGAL::Isosurfacing::dual_contouring(domain, isovalue, points_dc, polygons_dc); // save output indexed meshes to files, in the OFF format diff --git a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_cartesian_grid.cpp b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_Cartesian_grid.cpp similarity index 71% rename from Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_cartesian_grid.cpp rename to Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_Cartesian_grid.cpp index 94264709b13..75bd7b1b4a0 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_cartesian_grid.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_Cartesian_grid.cpp @@ -1,9 +1,9 @@ #include #include -#include -#include -#include +#include +#include +#include #include @@ -12,7 +12,7 @@ using FT = typename Kernel::FT; using Point = typename Kernel::Point_3; using Vector = typename Kernel::Vector_3; -using Grid = CGAL::Cartesian_grid_3; +using Grid = CGAL::Isosurfacing::Cartesian_grid_3; using Point_range = std::vector; using Polygon_range = std::vector >; @@ -28,9 +28,9 @@ int main(int, char**) for(std::size_t y=0; y gradient(grid); + CGAL::Isosurfacing::Explicit_Cartesian_grid_gradient_3 gradient(grid); // create domain from scalar and gradient fields - auto domain = CGAL::Isosurfacing::create_explicit_cartesian_grid_domain(grid, gradient); + auto domain = CGAL::Isosurfacing::create_explicit_Cartesian_grid_domain(grid, gradient); Point_range points; Polygon_range polygons; diff --git a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_implicit_iwp.cpp b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_implicit_iwp.cpp index d07277dee1b..7de06de04b3 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_implicit_iwp.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_implicit_iwp.cpp @@ -1,7 +1,7 @@ #include -#include -#include +#include +#include #include #include @@ -43,7 +43,7 @@ int main(int, char**) const Vector vec_spacing(spacing, spacing, spacing); // create a domain with given bounding box and grid spacing - auto domain = CGAL::Isosurfacing::create_implicit_cartesian_grid_domain(bbox, vec_spacing, iwp_value, iwp_gradient); + auto domain = CGAL::Isosurfacing::create_implicit_Cartesian_grid_domain(bbox, vec_spacing, iwp_value, iwp_gradient); // prepare collections for the result Point_range points; diff --git a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_mesh_offset.cpp b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_mesh_offset.cpp index 28e6c01b709..70304f7036b 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_mesh_offset.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_mesh_offset.cpp @@ -1,8 +1,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -69,7 +69,7 @@ int main(int, char**) }; // create a domain with given bounding box and grid spacing - auto domain = CGAL::Isosurfacing::create_implicit_cartesian_grid_domain(bbox, grid_spacing, + auto domain = CGAL::Isosurfacing::create_implicit_Cartesian_grid_domain(bbox, grid_spacing, mesh_distance, mesh_normal); // containers for output indexed surface mesh Point_range points; diff --git a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_octree.cpp b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_octree.cpp index e8e9f5f81f8..9bc2add1ed1 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_octree.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/dual_contouring_octree.cpp @@ -1,6 +1,6 @@ #include -#include +#include #include #include diff --git a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_cartesian_grid_sphere.cpp b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_Cartesian_grid_sphere.cpp similarity index 76% rename from Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_cartesian_grid_sphere.cpp rename to Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_Cartesian_grid_sphere.cpp index d929374579e..2af8d33ae6c 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_cartesian_grid_sphere.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_Cartesian_grid_sphere.cpp @@ -2,8 +2,8 @@ #include #include -#include -#include +#include +#include #include @@ -14,7 +14,7 @@ using Kernel = CGAL::Simple_cartesian; using FT = typename Kernel::FT; using Point = typename Kernel::Point_3; -using Grid = CGAL::Cartesian_grid_3; +using Grid = CGAL::Isosurfacing::Cartesian_grid_3; using Point_range = std::vector; using Polygon_range = std::vector >; @@ -30,9 +30,9 @@ int main(int, char**) for(std::size_t y=0; y -#include -#include +#include +#include #include @@ -30,7 +30,7 @@ int main(int, char**) }; // create a domain with given bounding box and grid spacing - auto domain = CGAL::Isosurfacing::create_implicit_cartesian_grid_domain(bbox, vec_spacing, sphere_function); + auto domain = CGAL::Isosurfacing::create_implicit_Cartesian_grid_domain(bbox, vec_spacing, sphere_function); // prepare collections for the output indexed mesh Point_range points; diff --git a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_inrimage.cpp b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_inrimage.cpp index 952f9bdda45..77b523d88cf 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_inrimage.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_inrimage.cpp @@ -1,8 +1,8 @@ #include #include -#include -#include +#include +#include #include @@ -11,7 +11,7 @@ using Kernel = CGAL::Simple_cartesian; using Point = typename Kernel::Point_3; -using Grid = CGAL::Cartesian_grid_3; +using Grid = CGAL::Isosurfacing::Cartesian_grid_3; using Point_range = std::vector; using Polygon_range = std::vector >; @@ -32,7 +32,7 @@ int main(int, char**) Grid grid { image }; // create a domain from the grid - auto domain = CGAL::Isosurfacing::create_explicit_cartesian_grid_domain(grid); + auto domain = CGAL::Isosurfacing::create_explicit_Cartesian_grid_domain(grid); // prepare collections for the output indexed mesh Point_range points; diff --git a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_signed_mesh_offset.cpp b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_signed_mesh_offset.cpp index e067c7310e6..846dca6b214 100644 --- a/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_signed_mesh_offset.cpp +++ b/Isosurfacing_3/examples/Isosurfacing_3/marching_cubes_signed_mesh_offset.cpp @@ -2,8 +2,8 @@ #include #include -#include -#include +#include +#include #include #include @@ -21,7 +21,7 @@ using FT = typename Kernel::FT; using Point = typename Kernel::Point_3; using Vector = typename Kernel::Vector_3; -using Grid = CGAL::Cartesian_grid_3; +using Grid = CGAL::Isosurfacing::Cartesian_grid_3; using Mesh = CGAL::Surface_mesh; @@ -73,9 +73,9 @@ int main(int, char**) for(std::size_t y=0; y +#include + +#include #include #include -#include #include #include #include namespace CGAL { +namespace Isosurfacing { /** - * \ingroup PkgIsosurfacing3Ref + * \ingroup IS_Domains_grp * - * \brief stores scalar values and gradients at the vertices of a Cartesian grid. + * \brief stores scalar values and gradients at the vertices of a %Cartesian grid. * - * \tparam GeomTraits must be a model of ``. + * \tparam GeomTraits must be a model of `IsosurfacingTraits_3`. */ template class Cartesian_grid_3 @@ -37,14 +40,23 @@ class Cartesian_grid_3 public: using Geom_traits = GeomTraits; using FT = typename Geom_traits::FT; - using Vector = typename Geom_traits::Vector_3; + using Point_3 = typename Geom_traits::Point_3; + using Vector_3 = typename Geom_traits::Vector_3; - using VertexDescriptor = Isosurfacing::internal::Grid_topology::Vertex_descriptor; + using Vertex_descriptor = Isosurfacing::internal::Grid_topology_3::Vertex_descriptor; + +private: + Bbox_3 m_bbox; + Vector_3 m_spacing; + std::array m_sizes; + + std::vector m_values; + std::vector m_gradients; + + Geom_traits m_gt; public: /** - * \ingroup PkgIsosurfacing3Ref - * * \brief creates a grid with `xdim * ydim * zdim` grid vertices. * * The grid covers the space described by a bounding box. @@ -53,30 +65,38 @@ public: * \param ydim the number of grid vertices in the `y` direction * \param zdim the number of grid vertices in the `z` direction * \param bbox the bounding box + * \param gt the geometric traits * * \pre `xdim`, `ydim`, and `zdim` are (strictly) positive. */ Cartesian_grid_3(const std::size_t xdim, const std::size_t ydim, const std::size_t zdim, - const Bbox_3& bbox) - : sizes{xdim, ydim, zdim}, - bbox(bbox) + const Bbox_3& bbox, + const Geom_traits& gt = Geom_traits()) + : m_sizes{xdim, ydim, zdim}, + m_bbox{bbox}, + m_gt{gt} { + CGAL_precondition(xdim > 0); + CGAL_precondition(ydim > 0); + CGAL_precondition(zdim > 0); + + auto vector = m_gt.construct_vector_3_object(); + // pre-allocate memory - values.resize(xdim * ydim * zdim); - gradients.resize(xdim * ydim * zdim); + const std::size_t nv = xdim * ydim * zdim; + m_values.resize(nv); + m_gradients.resize(nv); // calculate grid spacing - const FT d_x = bbox.x_span() / (xdim - 1); - const FT d_y = bbox.y_span() / (ydim - 1); - const FT d_z = bbox.z_span() / (zdim - 1); - spacing = Vector(d_x, d_y, d_z); + const FT d_x = FT{bbox.x_span()} / (xdim - 1); + const FT d_y = FT{bbox.y_span()} / (ydim - 1); + const FT d_z = FT{bbox.z_span()} / (zdim - 1); + m_spacing = vector(d_x, d_y, d_z); } /** - * \ingroup PkgIsosurfacing3Ref - * * \brief creates a grid from an `Image_3`. * * The dimensions and bounding box are read from the image. The values stored @@ -89,70 +109,90 @@ public: from_image(image); } + void from_image(const Image_3& image); + Image_3 to_image() const; + +public: + /** + * \return the geometric traits class + */ + const Geom_traits& geom_traits() const + { + return m_gt; + } + /** - * \ingroup PkgIsosurfacing3Ref - * * \return the number of grid vertices in the `x` direction */ std::size_t xdim() const { - return sizes[0]; + return m_sizes[0]; } /** - * \ingroup PkgIsosurfacing3Ref - * * \return the number of grid vertices in the `y` direction */ std::size_t ydim() const { - return sizes[1]; + return m_sizes[1]; } /** - * \ingroup PkgIsosurfacing3Ref - * * \return the number of grid vertices in the `z` direction */ std::size_t zdim() const { - return sizes[2]; + return m_sizes[2]; } /** - * \ingroup PkgIsosurfacing3Ref - * - * \return the bounding box of the Cartesian grid. + * \return the bounding box of the %Cartesian grid. */ - const Bbox_3& get_bbox() const + const Bbox_3& bbox() const { - return bbox; + return m_bbox; } /** - * \ingroup PkgIsosurfacing3Ref - * - * \return the spacing of the Cartesian grid, that is a vector whose coordinates are + * \return the spacing of the %Cartesian grid, that is a vector whose coordinates are * the grid steps in the `x`, `y`, and `z` directions, respectively */ - const Vector& get_spacing() const + const Vector_3& spacing() const { - return spacing; - } - - /** - * \ingroup PkgIsosurfacing3Ref - * - * \brief gets the scalar value stored at a grid vertex. - */ - FT operator()(const VertexDescriptor& v) const - { - return values[linear_index(v[0], v[1], v[2])]; + return m_spacing; } /** - * \ingroup PkgIsosurfacing3Ref + * \brief gets the geometric position of the grid vertex described by a set of indices. * + * Positions are not stored but calculated from an offset and grid spacing. + * + * \param x the index in the `x` direction + * \param y the index in the `y` direction + * \param z the index in the `z` direction + * + * \return the stored value + */ + const Point_3& point(const std::size_t x, + const std::size_t y, + const std::size_t z) const + { + typename Geom_traits::Compute_x_3 x_coord = m_gt.compute_x_3_object(); + typename Geom_traits::Compute_y_3 y_coord = m_gt.compute_y_3_object(); + typename Geom_traits::Compute_z_3 z_coord = m_gt.compute_z_3_object(); + typename Geom_traits::Construct_point_3 cp = m_gt.construct_point_3_object(); + + return cp(m_bbox.xmin() + x * x_coord(m_spacing), + m_bbox.ymin() + y * x_coord(m_spacing), + m_bbox.zmin() + z * x_coord(m_spacing)); + } + + const Point_3& point(const Vertex_descriptor& v) const + { + return point(v[0], v[1], v[2]); + } + + /** * \brief gets the scalar value stored at the grid vertex described by a set of indices. * * \param x the index in the `x` direction @@ -165,12 +205,15 @@ public: const std::size_t y, const std::size_t z) const { - return values[linear_index(x, y, z)]; + return m_values[linear_index(x, y, z)]; + } + + FT value(const Vertex_descriptor& v) const + { + return value(v[0], v[1], v[2]); } /** - * \ingroup PkgIsosurfacing3Ref - * * \brief gets the scalar value stored at the grid vertex described by a set of indices. * * \note This function can be used to set the value at a grid vertex. @@ -185,28 +228,34 @@ public: const std::size_t y, const std::size_t z) { - return values[linear_index(x, y, z)]; + return m_values[linear_index(x, y, z)]; + } + + FT& value(const Vertex_descriptor& v) + { + return value(v[0], v[1], v[2]); } /** - * \ingroup PkgIsosurfacing3Ref - * * \brief gets the gradient stored at the grid vertex described by a set of indices. * * \param x the index in the `x` direction * \param y the index in the `y` direction * \param z the index in the `z` direction */ - Vector gradient(const std::size_t x, - const std::size_t y, - const std::size_t z) const + const Vector_3& gradient(const std::size_t x, + const std::size_t y, + const std::size_t z) const { - return gradients[linear_index(x, y, z)]; + return m_gradients[linear_index(x, y, z)]; + } + + const Vector_3& gradient(const Vertex_descriptor& v) const + { + return gradient(v[0], v[1], v[2]); } /** - * \ingroup PkgIsosurfacing3Ref - * * \brief gets the gradient stored at the grid vertex described by a set of indices. * * \note This function can be used to set the gradient at a grid vertex. @@ -217,11 +266,16 @@ public: * * \return a reference to the stored gradient */ - Vector& gradient(const std::size_t x, - const std::size_t y, - const std::size_t z) + Vector_3& gradient(const std::size_t x, + const std::size_t y, + const std::size_t z) { - return gradients[linear_index(x, y, z)]; + return m_gradients[linear_index(x, y, z)]; + } + + Vector_3& gradient(const Vertex_descriptor& v) + { + return gradient(v[0], v[1], v[2]); } private: @@ -229,21 +283,11 @@ private: const std::size_t y, const std::size_t z) const { + CGAL_precondition(x < xdim() && y < ydim() && z < zdim()); + // convert (x, y, z) into a linear index to access the scalar value / gradient vectors return (z * ydim() + y) * xdim() + x; } - - void from_image(const Image_3& image); - Image_3 to_image() const; - -private: - std::vector values; - std::vector gradients; - - std::array sizes; - - Bbox_3 bbox; - Vector spacing; }; template @@ -251,28 +295,31 @@ void Cartesian_grid_3:: from_image(const Image_3& image) { + auto vector = m_gt.construct_vector_3_object(); + // compute bounding box const FT max_x = image.tx() + (image.xdim() - 1) * image.vx(); const FT max_y = image.ty() + (image.ydim() - 1) * image.vy(); const FT max_z = image.tz() + (image.zdim() - 1) * image.vz(); - bbox = Bbox_3(image.tx(), image.ty(), image.tz(), max_x, max_y, max_z); + m_bbox = Bbox_3{image.tx(), image.ty(), image.tz(), max_x, max_y, max_z}; // get spacing - spacing = Vector(image.vx(), image.vy(), image.vz()); + m_spacing = vector(image.vx(), image.vy(), image.vz()); // get sizes - sizes[0] = image.xdim(); - sizes[1] = image.ydim(); - sizes[2] = image.zdim(); + m_sizes[0] = image.xdim(); + m_sizes[1] = image.ydim(); + m_sizes[2] = image.zdim(); // pre-allocate - values.resize(xdim() * ydim() * zdim()); - gradients.resize(xdim() * ydim() * zdim()); + const std::size_t nv = m_sizes[0] * m_sizes[1] * m_sizes[2]; + m_values.resize(nv); + m_gradients.resize(nv); // copy values - for(std::size_t x=0; xtx = bbox.xmin(); - im->ty = bbox.ymin(); - im->tz = bbox.zmin(); + im->tx = m_bbox.xmin(); + im->ty = m_bbox.ymin(); + im->tz = m_bbox.zmin(); // copy data - FT* data = (FT*)im->data; - for(std::size_t x=0; x(im->data); + for(std::size_t x=0; x + +#include +#include +#include +#include +#include + +namespace CGAL { +namespace Isosurfacing { + +/** + * \ingroup IS_Domains_grp + * + * \cgalModels `IsosurfacingDomainWithGradient_3` + * + * \brief A domain that represents an explicitly stored %Cartesian grid. + * + * \tparam GeomTraits must be a model of `IsosurfacingTraits_3`. + * \tparam Gradient the type of the gradient functor. It must be a model of `CopyConstructible` and implement + * `GeomTraits::Vector_3 operator()(const GeomTraits::Point_3& point) const`. + */ +#ifdef DOXYGEN_RUNNING // Allow more than a CGAL::Cartesian_grid_3 +template