diff --git a/.github/test.sh b/.github/test.sh index cf69ebee955..59d4820ecdd 100755 --- a/.github/test.sh +++ b/.github/test.sh @@ -9,4 +9,5 @@ PLUGINS_ARRAY=(${LIST_OF_PLUGINS}); NB_OF_PLUGINS=${#PLUGINS_ARRAY[@]} DEL=$(($NB_OF_PLUGINS / 4)) cd build -make -j2 ${PLUGINS_ARRAY[@]:$(($FACTOR * $DEL)):$((($FACTOR + 1) * $DEL))} +NUM_PROCS=$(nproc) +make -j${NUM_PROCS} ${PLUGINS_ARRAY[@]:$(($FACTOR * $DEL)):$((($FACTOR + 1) * $DEL))} diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml index d523cc2079d..9735cd3d3c8 100644 --- a/.github/workflows/build_doc.yml +++ b/.github/workflows/build_doc.yml @@ -104,8 +104,8 @@ jobs: echo "DoxygenError=No package affected." >> $GITHUB_OUTPUT exit 1 fi - cd build_doc && make -j2 doc - make -j2 doc_with_postprocessing 2>tmp.log + cd build_doc && make -j$(nproc) doc + make -j$(nproc) doc_with_postprocessing 2>tmp.log if [ -s tmp.log ]; then content=`cat ./tmp.log` delimiter="$(openssl rand -hex 8)" diff --git a/.github/workflows/reuse.yml b/.github/workflows/reuse.yml index c55ba6df40d..f76a99b18dd 100644 --- a/.github/workflows/reuse.yml +++ b/.github/workflows/reuse.yml @@ -12,24 +12,24 @@ jobs: steps: - uses: actions/checkout@v4 - name: REUSE version - uses: fsfe/reuse-action@v2 + uses: fsfe/reuse-action@v3 with: args: --version - name: REUSE lint - uses: fsfe/reuse-action@v2 + uses: fsfe/reuse-action@v3 with: args: --include-submodules lint - name: REUSE SPDX SBOM - uses: fsfe/reuse-action@v2 + uses: fsfe/reuse-action@v3 with: args: spdx - name: install dependencies - run: sudo apt-get install -y cmake + run: sudo apt-get update && sudo apt-get install -y cmake - name: Create CGAL internal release run: | mkdir -p ./release cmake -DDESTINATION=./release -DCGAL_VERSION=9.9 -P ./Scripts/developer_scripts/cgal_create_release_with_cmake.cmake - name: REUSE lint release tarball - uses: fsfe/reuse-action@v2 + uses: fsfe/reuse-action@v3 with: args: --root ./release/CGAL-9.9 --include-submodules lint diff --git a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h index 645ce1347cb..ce9a56e15b9 100644 --- a/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h +++ b/AABB_tree/include/CGAL/AABB_tree/internal/AABB_traversal_traits.h @@ -73,7 +73,7 @@ public: Result; public: First_intersection_traits(const AABBTraits& traits) - : m_result(), m_traits(traits) + : m_result(std::nullopt), m_traits(traits) {} bool go_further() const { @@ -202,7 +202,7 @@ class First_primitive_traits public: First_primitive_traits(const AABBTraits& traits) : m_is_found(false) - , m_result() + , m_result(std::nullopt) , m_traits(traits) {} bool go_further() const { return !m_is_found; } diff --git a/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h b/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h index 7c03ff5d5e5..20883169ba7 100644 --- a/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h +++ b/Apollonius_graph_2/include/CGAL/Parabola_segment_2.h @@ -27,7 +27,7 @@ namespace Qt { } template < class Gt > -class Parabola_segment_2 : public Parabola_2< Gt > +struct Parabola_segment_2 : public Parabola_2< Gt > { typedef CGAL::Parabola_2 Base; typedef typename Base::Site_2 Site_2; @@ -39,10 +39,10 @@ class Parabola_segment_2 : public Parabola_2< Gt > using Base::t; using Base::f; -protected: + Point_2 p1, p2; -public: + Parabola_segment_2() : Parabola_2< Gt >() {} template diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementTypes.h b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementTypes.h index 417ffbd3fd0..ec9e20b6c98 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementTypes.h +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/ArrangementTypes.h @@ -15,7 +15,6 @@ #include #include -#include #include #include #include diff --git a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/IntersectCurves.cpp b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/IntersectCurves.cpp index 5e98113dabc..2a97cf19193 100644 --- a/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/IntersectCurves.cpp +++ b/Arrangement_on_surface_2/demo/Arrangement_on_surface_2/Utils/IntersectCurves.cpp @@ -11,7 +11,7 @@ #include "IntersectCurves.h" #include "ArrangementTypes.h" -#include +#include template diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt index 7c143578c89..5b4b9ed9051 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Arrangement_on_surface_2.txt @@ -69,10 +69,10 @@ class Arrangement_2 { ... }; An instance of this template represents an arrangement embedded in the plane. When the template is instantiated, the `GeometryTraits` -parameter must be substituted with a type that defines a set of +parameter must be substituted by a type that defines a set of geometric-object types, such as point and curve, and a set of operations on objects of these types (see Section \ref -aos_sec-geom_traits); the `Dcel` parameter must be substituted with a +aos_sec-geom_traits); the `Dcel` parameter must be substituted by a type that represents a doubly-connected edge list (\dcel) data structure. It defines types of topological objects, such as vertices, edges, and faces, and the operations required to maintain the @@ -91,7 +91,7 @@ An instance of this template represents a two-dimensional arrangement embedded in a surface in three dimensional space. When the template is instantiated, the `GeometryTraits` parameter must be substituted as described above; the `TopologyTraits` parameter must be substituted -with a type that deals with the topology of the surface (see Section +by a type that deals with the topology of the surface (see Section \ref aos_sec-topol_traits). In particular, it maintains a representation of the arrangement graph embedded in the surface using a doubly-connected edge list (\dcel) data-structure suitable for @@ -390,7 +390,7 @@ the `Arrangement_2` class template; their description follows.
    -
  • The `Traits` template-parameter should be instantiated with a +
  • The `Traits` template-parameter should be substituted by a model of the `ArrangementBasicTraits_2` concept and optionally additional geometry traits concepts. A model of the `ArrangementBasicTraits_2` concept defines the types of @@ -415,14 +415,15 @@ the `Arrangement_2` class template; their description follows. rational functions. We exemplify the usage of these traits classes in Section \ref aos_sec-geom_traits. -
  • The `Dcel` template-parameter should be instantiated with a class +
  • The `Dcel` template-parameter should be substituted by a class that models the `ArrangementDcel` concept, which is used to represent the topological layout of the arrangement. This parameter is - substituted with `Arr_default_dcel` by default, and + substituted by `Arr_default_dcel` by default, and we use this default value in this and in the following three - sections. However, in many applications it is necessary to - extend the \dcel features. This is done by substituting the - `Dcel` parameter with a different type; see Section \ref arr_ssecex_dcel + sections. However, in many applications it is necessary to extend the + \dcel features. This is done by substituting the `Dcel` parameter with + a different type (typically, a different instance of the + `Arr_dcel<>` class template); see Section \ref arr_ssecex_dcel for further explanations and examples.
@@ -1001,7 +1002,7 @@ segments common to all examples that do not construct new geometric objects. They are kept in the header file `arr_inexact_construction_segments.h`. In these examples the `Traits` parameter of the `Arrangement_2` class template is -substituted with an instance of the +substituted by an instance of the `Arr_non_caching_segment_traits_2` class template. The `Arr_non_caching_segment_traits_2` class template is instantiated with the predefined kernel that evaluates predicates in an exact manner, @@ -1438,7 +1439,7 @@ vary according to the user choice.} for answering queries: The landmark strategy requires that the type of the attached arrangement be an instance of the `Arrangement_2` class - template, where the `Traits` parameter is substituted with a + template, where the `Traits` parameter is substituted by a geometry-traits class that models the `ArrangementLandmarkTraits_2` concept, which refines the basic `ArrangementBasicTraits_2` concept; see Section \ref aos_sssec-tr_landmarks_concept for details. Most @@ -1742,7 +1743,7 @@ query results, and insert \f$c\f$ at its proper location.\cgalFootnote{The \cgalFootnoteCode{CGAL::insert_non_intersecting_curve<>()} function template, as all other functions reviewed in this section, is parameterized by an arrangement type and a point-location type (The -latter must be substituted with a model of the +latter must be substituted by a model of the `ArrangementPointLocation_2` concept).} The insertion operation thus hardly requires any geometric operations on top of the ones needed to answer the point-location queries. Moreover, it is sufficient that the @@ -1846,7 +1847,7 @@ condition. Consider the call \link CGAL::insert<>() `insert(arr, c, pl)`\endlink, where \f$c\f$ is not necessarily \f$x\f$-monotone. In this case the type of `arr` must be an instance of the `Arrangement_2` class template, where the `Traits` -template parameter is substituted with a traits class that models the +template parameter is substituted by a traits class that models the concept `ArrangementTraits_2`, which refines the `ArrangementXMonotoneTraits_2` concept. It has to define an additional \link ArrangementTraits_2::Curve_2 `Curve_2`\endlink type, which may @@ -2267,7 +2268,7 @@ accepts the name of an input file that contains the plain-text description of the geometric objects and an output iterator for storing the newly constructed objects. When the function is instantiated, the first template parameter, namely `Type`, must be -substituted with the type of objects to read. It is assumed that an +substituted by the type of objects to read. It is assumed that an extractor operator (`>>`) that extracts objects of the given type from the input stream is available. The listing of the function template, which is defined in the file `read_objects.h`, is omitted here @@ -2704,7 +2705,7 @@ All the free functions that operate on arrangements of bounded curves of unbounded curves. For example, consider a container of linear curves that has to be inserted into an arrangement object, the type of which is an instance of the `Arrangement_2` class -template, where the `Traits` parameter is substituted with the traits +template, where the `Traits` parameter is substituted by the traits class that handles linear curves; see Section \ref arr_sssectr_linear. You can do it incrementally; namely, insert the curves one by one as follows: @@ -3485,7 +3486,7 @@ point-location strategy. The type of an arrangement associated with the landmark point-location strategy (see Section \ref arr_ssecpl) must be an instance of the `Arrangement_on_surface_2` class template, -where the `GeomTraits` parameter is substituted with a model of the +where the `GeomTraits` parameter is substituted by a model of the concept `ArrangementLandmarkTraits_2`. (Naturally, it can also model either the `ArrangementXMonotoneTraits_2` concept or the `ArrangementTraits_2` concept.) The `ArrangementLandmarkTraits_2` @@ -4541,7 +4542,7 @@ PkgBooleanSetOperations2Ref. Note that it is not a model of the computations with square root numbers, which makes it attractive for arrangements induced by line segments, circular arcs, and whole circles. When the traits class-template is instantiated, the `Kernel` -template parameter must be substituted with a geometric kernel that +template parameter must be substituted by a geometric kernel that models the `Kernel` concept. Always plug in a kernel that uses a rational number type, such as `Exact_predicates_exact_constructions_kernel`. Observe that the nested @@ -4722,20 +4723,20 @@ follows:
    -
  • The `RatKernel` template parameter must be substituted with a +
  • The `RatKernel` template parameter must be substituted by a geometric kernel whose field type is an exact rational type. It is used to define basic geometric entities (e.g., a line segment or a circle) with rational coefficients. Typically we use one of the standard \cgal kernels, instantiated with the number type `NtTraits::Rational` (see below). -
  • The `AlgKernel` template parameter must be substituted with a +
  • The `AlgKernel` template parameter must be substituted by a geometric kernel whose field type is an exact algebraic type. It is used to define points with algebraic coordinates. Typically, we use one of the standard \cgal kernels, instantiated with the number type `NtTraits::Algebraic` (see below). -
  • The `NtTraits` template parameter must be substituted with a type +
  • The `NtTraits` template parameter must be substituted by a type that encapsulates all the numeric operations needed for performing geometric computation carried out by the geometric traits class. It defines the `Integer`, `Rational`, and `Algebraic` number-types, and @@ -4916,7 +4917,7 @@ provided by the traits in form of functors. When the `Arr_rational_function_traits_2` class template is instantiated, the template parameter must be substituted -with a model of the `AlgebraicKernel_d_1` concept. Models of this +by a model of the `AlgebraicKernel_d_1` concept. Models of this concept, such as the `Algebraic_kernel_d_1` class template provided by the package \ref PkgAlgebraicFoundations are meant to support algebraic functionalities on univariate polynomials @@ -5176,11 +5177,11 @@ polynomial. Currently supported integral number types are `Gmpz`, statements included in the header file `integer_type.h`, the listings of which are omitted here. This header file is used by the two example programs listed in this section. The template parameter `Coefficient` -can be substituted in addition with an instance of the +can be substituted in addition by an instance of the `Sqrt_extension` class template, where the template parameters -`NT` and `Root` are substituted in turn with one of the integral +`NT` and `Root` are substituted in turn by one of the integral number types above. Finally, the template parameter `Coefficient` can -be substituted also with a rational number type, where the type of the +be substituted also by a rational number type, where the type of the numerator and denominator is one of the types above. The type \link Arr_algebraic_segment_traits_2::Curve_2 @@ -5487,7 +5488,7 @@ decorator used to attach a data field to curves and to \f$x\f$-monotone curves. It is a class template named `Arr_curve_data_traits_2` parameterized by a base-traits class, which must -be substituted with one of the geometric traits models described in +be substituted by one of the geometric traits models described in the previous subsections or with a user-defined traits model, when the decorator is instantiated. The curve-data decorator derives from the base-traits class, and in particular inherits its \link @@ -5703,20 +5704,25 @@ objects, so that when one object changes state, all its dependents are notified and updated automatically. The observed object does not know anything about the observers. It merely "publishes" information about changes when they occur. In our case observers can be attached to an -arrangement object. An attached observer receives notifications about -the changes this arrangement undergoes. +arrangement object. -An observer object, the type of which is an instance of the -`Arr_observer` class template, stores a pointer to an -arrangement object. When the `Arr_observer` class -template is instantiated, the `Arrangement` parameter must be -substituted with the type of the arrangement object. The observer -receives notifications just before a structural change occurs -in the arrangement and immediately after such a change takes -place. `Arr_observer` serves as a base class for other -observer classes and defines a set of virtual notification -functions, with default empty implementations. The set of functions -can be divided into three categories, as follows: +An observer object that observes changes in an arrangement object +stores a pointer to the attached arrangement object. It receives +notifications about the changes this arrangement undergoes. The +observer receives notifications just before a structural +change occurs in the arrangement and immediately after such a +change takes place. An observer object that observes changes in an +arrangement object of type `Arrangement` must be of a type derived +from `Arrangement::Observer`, which is an alias to +`Aos_observer`, where +`Arrangement_on_surface_2` is the type of the arrangement object or +its base type. An instance of `Aos_observer<>` serves as a base type +for other observer classes and defines a set of virtual notification +functions, with default empty implementations. You can also use the +template alias `Arr_observer`, where `Arrangement_2` is +the type of the arrangement object in case it is derived from an +instance of the template `Arrangement_on_surface_2`. The set of +functions can be divided into three categories, as follows:
      @@ -5782,10 +5788,10 @@ the call to `after_global_change()`.
    See the Reference Manual for a detailed specification of the -`Arr_observer` class template and the prototypes of all notification +`Aos_observer` class template and the prototypes of all notification functions. -Each arrangement object stores a list of pointers to `Arr_observer` +Each arrangement object stores a list of pointers to `Aos_observer` objects. This list may be empty, in which case the arrangement does not have to notify any external class on the structural changes it undergoes. If, however, there are observers associated with the @@ -5799,7 +5805,7 @@ invoked for each observer. Concrete arrangement-observer classes should inherit from -`Arr_observer`. When an observer is constructed, it is attached to a +`Aos_observer`. When an observer is constructed, it is attached to a valid arrangement supplied to the observed constructor, or alternatively the observer can be attached to the arrangement at a later time. When this happens, the observer object inserts itself @@ -5809,8 +5815,8 @@ thereafter. Subsequently, the observer object unregisters itself by removing itself from this list just before it is destroyed. Most concrete observer-classes do not need to use the full set of notifications. Thus, the bodies of all notification methods defined in -the base class `Arr_observer` are empty. A concrete observer that -inherits from `Arr_observer` needs to override only the relevant +the base class `Aos_observer` are empty. A concrete observer that +inherits from `Aos_observer` needs to override only the relevant notification methods. The remaining methods are invoked when corresponding changes occur, but they do nothing. @@ -5877,12 +5883,12 @@ applications. All examples presented so far use the default \dcel; namely, they employ the `Arr_default_dcel` instance. This is done -implicitly, as an instance of this class template serves as the -default parameter for the `Arrangement_2` class template; see Section -\ref aos_ssec-basic-arr_class. The default \dcel class associates -points with vertices and \f$x\f$-monotone curves with halfedges, but -nothing more. In this section we show how to use alternative -\dcel types to extend the desired \dcel records. +implicitly, as this instance of the `Arr_default_dcel` class template +serves as the default parameter for the `Arrangement_2` class +template; see Section \ref aos_ssec-basic-arr_class. The default \dcel +class associates points with vertices and \f$x\f$-monotone curves with +halfedges, but nothing more. In this section we show how to use +alternative \dcel types to extend the desired \dcel records. \subsubsection arr_sssecex_dcel_face Extending the DCEL Faces @@ -6102,7 +6108,7 @@ ovl_traits)`\endlink constructs the arrangement `arr_o`, which is the overlay of two input arrangement `arr_r` and `arr_b`. All three arrangements must use the same geometric primitives. In other words, their types are instances of the `Arrangement_2` class -template, where the `Traits` parameter is substituted with three +template, where the `Traits` parameter is substituted by three geometry-traits classes, respectively. The geometry-traits classes of the input arrangements must be convertible to the geometry-traits class of the resulting arrangement.\cgalFootnote{It is sufficient that @@ -6111,17 +6117,17 @@ of arrangements derive from a common ancestor that models the geometry-traits concept.} Typically, all three arrangements use the same geometry-traits class. -The `overlay()` function template is suitable for -arrangements that do not store any additional data with their -\dcel records; namely, arrangements defined using an instance of -the default \dcel class-template `Arr_default_dcel`. Typically, -the overlay arrangement in this case does not store extra data with -its \dcel records as well (or if it does, the additional -data-fields cannot be computed by the overlay operation). The overlay -arrangement is equivalent to the arrangement induced by all curves of -`arr_r` and `arr_b`. Indeed, it is possible to obtain the same result -using the standard insertion-operations instead, but, as mentioned -above, this is less efficient. +The `overlay()` function template is suitable for arrangements that do +not store any additional data with their \dcel records; namely, +arrangements defined using the default \dcel, which is the instance +`Arr_default_dcel`. Typically, the overlay arrangement in this +case does not store extra data with its \dcel records as well. (If it +does, the additional data-fields cannot be computed by the overlay +operation in this case.) The overlay arrangement is equivalent to the +arrangement induced by all curves of `arr_r` and `arr_b`. Indeed, it +is possible to obtain the same result using the standard +insertion-operations instead, but, as mentioned above, this is less +efficient. \cgalFigureBegin{aos_figex_overlay,overlay.png} @@ -6163,7 +6169,7 @@ arrangement that results from overlaying two face-extended arrangements typically also stores additional data-fields with its faces. The types of such arrangements, for example, could be instances of the `Arrangement_2` class template, where the `Dcel` -parameters are substituted with instances of the +parameters are substituted by instances of the `Arr_face_extended_dcel` class template (see Section \ref arr_sssecex_dcel_face). The data field that is attached to an overlay face can be computed from the data fields of the two faces (in `arr_r` @@ -6173,7 +6179,7 @@ data fields with all their \dcel records typically also stores additional data-fields with all its \dcel records. The types of such arrangements, for example, could be instances of the `Arrangement_2` class template, where the `Dcel` -parameters are substituted with instances of the `Arr_extended_dcel` +parameters are substituted by instances of the `Arr_extended_dcel` class template (see Section \ref arr_sssecex_dcel_all). The data field attached to an overlay feature can be computed from the data fields of the two features (in `arr_r` and `arr_b`) that induce the overlay @@ -6188,7 +6194,7 @@ of the overlay traits can be an instance of the class template `Arr_face_overlay_traits`, which models the concept `OverlayTraits`. An object of this type operates on face-extended arrangements. When instantiated, the -`OverlayFaceData` parameter must be substituted with a functor that is +`OverlayFaceData` parameter must be substituted by a functor that is capable of combining two face-data fields of types `ArrangementR::Dcel::Face_data` and `ArrangementB::Dcel::Face_data` and computing the output `ArrangementO::Dcel::Face_data` object. The @@ -6203,7 +6209,7 @@ flag. A polygon is represented as a marked arrangement face (whose flag is set). The example uses an instance of the `Arr_face_overlay_traits` class template as the face-overlay traits class where the `OverlayFaceData` -template parameter is substituted with a functor that simply performs +template parameter is substituted by a functor that simply performs a logical and operation on Boolean flags. As a result, a face in the overlay arrangement is marked only when it corresponds to an overlapping region of two marked faces in the input @@ -6401,12 +6407,12 @@ between these curves and the arrangement edges they induce. Similarly, the `Arrangement_with_history_2` class-template extends the `Arrangement_2` class template. The `GeometryTraits` template parameter, of either class templates, must -be substituted with a model of the `ArrangementTraits_2` concept; see +be substituted by a model of the `ArrangementTraits_2` concept; see Section \ref aos_ssec-insert_gen. It should define the \link ArrangementTraits_2::Curve_2 `Curve_2`\endlink type and support its subdivision into \link ArrangementBasicTraits_2::X_monotone_curve_2 `X_monotone_curve_2`\endlink objects, among the others. The `Dcel` -parameter must be substituted with a model of the `ArrangementDcel` +parameter must be substituted by a model of the `ArrangementDcel` concept. You can use either the default \dcel class or an extended \dcel class (see Section \ref arr_ssecex_dcel) based on your needs. An arrangement that support the cross-mapping mentioned above is referred @@ -6483,7 +6489,7 @@ iterators is \link Arrangement_with_history_2::Curve_2 Overlaying two arrangement-with-history objects is possible only if their types are instances of the `Arrangement_with_history_2` class template, where the -respective `Traits` parameters are substituted with two traits classes +respective `Traits` parameters are substituted by two traits classes that are convertible to one another. In this case, the resulting arrangement stores a consolidated container of input curves, and automatically preserves the cross-mapping between the arrangement @@ -6663,15 +6669,15 @@ a file. \subsection arr_ssecarr_io_aux_data Arrangements with Auxiliary Data -\cgalAdvancedBegin -The inserter and extractor both ignore any auxiliary data stored with -the arrangement features. Thus, they are ideal for arrangements -instantiated using the `Arr_default_dcel` class. -However, as explained in Section \ref arr_ssecex_dcel, one can easily -extend the arrangement faces by using the `Arr_face_extended_dcel` -template, or extend all \dcel records by using the `Arr_extended_dcel` -template. In such cases, it might be crucial that the auxiliary data fields -are written to the file and read from there. +\cgalAdvancedBegin The inserter and extractor both ignore any +auxiliary data stored with the arrangement features. Thus, they are +ideal for arrangements instantiated using the default \dcel, which is +the instance `Arr_default_dcel`. However, as explained in +Section \ref arr_ssecex_dcel, one can easily extend the arrangement +faces by using the `Arr_face_extended_dcel` template, extend all \dcel +records by using the `Arr_extended_dcel` template, or use the +`Arr_dcel` template. In such cases, it might be crucial that the +auxiliary data fields are written to the file and read from there. The arrangement package includes the free functions `write(arr, os, formatter)`, which writes the arrangement `arr` @@ -6968,7 +6974,7 @@ algorithm on a dual arrangement. It uses the functor template information stored inside the faces. The functor implements a property map that utilizes the `data()` and `set_data()` member functions of the extended face to update or obtain the property. When the property map -is instantiated, the `Type` parameter must be substituted with the +is instantiated, the `Type` parameter must be substituted by the same type that is used to extend the arrangement face; see Section \ref arr_sssecex_dcel_face. The functor template is defined in the header file `Extended_face_property_map.h` listed below. diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Aos_observer.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Aos_observer.h new file mode 100644 index 00000000000..2f21f4a886c --- /dev/null +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Aos_observer.h @@ -0,0 +1,424 @@ +namespace CGAL { + +/*! \ingroup PkgArrangementOnSurface2Ref + * + * \anchor arr_refaos_obs + * + * `Aos_observer` serves as an abstract base class for all observer classes that + * are attached to an arrangement instance of type `Arrangement` and receive + * notifications from the arrangement. This base class handles the attachment + * of the observer to a given arrangement instance or to the detachment of the + * observer from this arrangement instance. It also gives a default empty + * implementation to all notification functions that are invoked by the + * arrangement to notify the observer on local or global changes it undergoes. + * The notification functions are all virtual functions, so they can be + * overridden by the concrete observer classes that inherit from `Aos_observer`. + * + * In order to implement a concrete arrangement observer-class, one simply needs + * to derive from `Aos_observer` and override the relevant notification + * functions. For example, if only face-split events are of interest, it is + * sufficient to override just `before_split_face()` (or just + * `after_split_face()`). + */ +template +class Aos_observer { +public: + + /// \name Types + /// @{ + + //! the type of the associated arrangement. + typedef unspecified_type Arrangement_2; + + //! the point type. + typedef typename Arrangement_2::Point_2 Point_2; + + //! the \f$x\f$-monotone curve type. + typedef typename Arrangement_2::X_monotone_curve_2 X_monotone_curve_2; + + //! the type of a handle to an arrangement vertex. + typedef typename Arrangement_2::Vertex_handle Vertex_handle; + + //! the type of a handle to an arrangement halfedge. + typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; + + //! the type of a handle to an arrangement face. + typedef typename Arrangement_2::Face_handle Face_handle; + + /*! represents a connected component of the boundary (CCB), either an outer + * boundary or an inner boundary (the latter is also referred to as a hole). + */ + typedef typename Arrangement_2::Ccb_halfedge_circulator Ccb_halfedge_circulator; + + /// @} + + /// \name Creation + /// @{ + + /*! constructs an observer that is unattached to any arrangement instance. */ + Aos_observer(); + + /*! constructs an observer and attaches it to the given arrangement `arr`. */ + Aos_observer(Arrangement_2& arr); + + /// @} + + /// \name Modifiers + /// @{ + + /*! attaches the observer to the given arrangement `arr`. */ + void attach(Arrangement_2& arr); + + /*! detaches the observer from its arrangement. */ + void detach(); + + /// @} + + /// \name Notifications on Global Arrangement Operations + /// @{ + + /*! issued just before the attached arrangement is assigned with the contents of another + * arrangement. + * \param arr The other arrangement. Notice that the arrangement type is the type used to + * instantiate the observer, which is conveniently defined as + * `Arrangement_2::Base_aos`. + */ + virtual void before_assign(const typename Arrangement_2::Base_aos& arr); + + /*! issued immediately after the attached arrangement has been assigned with + * the contents of another arrangement. + */ + virtual void after_assign(); + + /*! issued just before the attached arrangement is cleared. */ + virtual void before_clear(); + + /*! issued immediately after the attached arrangement has been cleared, so it + * now consists only of a the unbounded face `uf`. + */ + virtual void after_clear(Face_handle uf); + + /*! issued just before a global function starts to modify the attached + * arrangement. It is guaranteed that no queries (especially no point-location + * queries) are issued until the termination of the global function is + * indicated by `after_global_change()`. + */ + virtual void before_global_change(); + + /*! + issued immediately after a global function has stopped modifying the + attached arrangement. + */ + virtual void after_global_change(); + + /// @} + + /// \name Notifications on Attachment or Detachment + /// @{ + + /*! issued just before the observer is attached to the arrangement instance + * `arr`. + * \param arr The arrangement that is about to attach the observer. Notice + * that the arrangement type is the type used to instantiate the + * observer, which is conveniently defined as + * `Arrangement_2::Base_aos`. + */ + virtual void before_attach(const typename Arrangement_2::Base_aos& arr); + + /*! issued immediately after the observer has been attached to an arrangement + * instance. + */ + virtual void after_attach(); + + /*! issued just before the observer is detached from its arrangement instance. + */ + virtual void before_detach(); + + /*! issued immediately after the observer has been detached from its + * arrangement instance. + */ + virtual void after_detach(); + + /// @} + + /// \name Notifications on Local Changes in the Arrangement + /// @{ + + /*! issued just before a new vertex that corresponds to the point `p` is + * created. + */ + virtual void before_create_vertex(const Point_2& p); + + /*! issued immediately after a new vertex `v` has been created. Note that the + * vertex still has no incident edges and is not connected to any other vertex. + */ + virtual void after_create_vertex(Vertex_handle v); + + /*! issued just before a new vertex at infinity is created, `cv` is the curve + * incident to the surface boundary, `ind` is the relevant curve-end, `ps_x` + * is the boundary condition of the vertex in \f$x\f$ and `ps_y` is the + * boundary condition of the vertex in \f$y\f$. + */ + virtual void before_create_boundary_vertex(const X_monotone_curve_2& cv, + Arr_curve_end ind, + Arr_parameter_space ps_x, + Arr_parameter_space ps_y); + + /*! issued immediately after a new vertex `v` has been created. Note that the + * vertex still has no incident edges and is not connected to any other vertex. + */ + virtual void after_create_boundary_vertex(Vertex_handle v); + + /*! issued just before a new edge that corresponds to the \f$x\f$-monotone + * curve `c` and connects the vertices `v1` and `v2` is created. + */ + virtual void before_create_edge(const X_monotone_curve_2& c, + Vertex_handle v1, Vertex_handle v2); + + /*! issued immediately after a new edge `e` has been created. The halfedge + * that is sent to this function is always directed from `v1` to `v2` (see + * `before_create_edge()`). + */ + virtual void after_create_edge(Halfedge_handle e); + + /*! issued just before a vertex `v` is modified to be associated with the point + * `p`. + */ + virtual void before_modify_vertex(Vertex_handle v, const Point_2& p); + + /*! issued immediately after an existing vertex `v` has been modified. */ + virtual void after_modify_vertex(Vertex_handle v); + + /*! issued just before an edge `e` is modified to be associated with the + * \f$x\f$-monotone curve `c`. + */ + virtual void before_modify_edge(Halfedge_handle e, + const X_monotone_curve_2& c); + + /*! issued immediately after an existing edge `e` has been modified. */ + virtual void after_modify_edge(Halfedge_handle e); + + /*! issued just before an edge `e` is split into two edges that should be + * associated with the \f$x\f$-monotone curves `c1` and `c2`. The vertex `v` + * corresponds to the split point, and will be used to separate the two + * resulting edges. + */ + virtual void before_split_edge(Halfedge_handle e, Vertex_handle v, + const X_monotone_curve_2& c1, + const X_monotone_curve_2& c2); + + /*! issued immediately after an existing edge has been split into the two + * given edges `e1` and `e2`. + */ + virtual void after_split_edge(Halfedge_handle e1, Halfedge_handle e2); + + /*! issued just before a fictitious edge `e` is split into two. The vertex at + * infinity `v` corresponds to the split point, and will be used to separate + * the two resulting edges. + */ + virtual void before_split_fictitious_edge(Halfedge_handle e, Vertex_handle v); + + /*! issued immediately after an existing fictitious edge has been split into + * the two given fictitious edges `e1` and `e2`. + */ + virtual void after_split_fictitious_edge(Halfedge_handle e1, + Halfedge_handle e2); + + /*! issued just before a face `f` is split into two, as a result of the + * insertion of the edge `e` into the arrangement. + */ + virtual void before_split_face(Face_handle f, Halfedge_handle e); + + /*! issued immediately after the existing face `f1` has been split, such that + * a portion of it now forms a new face `f2`. The flag `is_hole` designates + * whether `f2` forms a hole (an inner CCB) inside `f1`. + */ + virtual void after_split_face(Face_handle f1, Face_handle f2, bool is_hole); + + /*! issued just before outer CCB `h` inside a face `f` is split into two, as a + * result of the removal of the edge `e` from the arrangement. + */ + virtual void before_split_outer_ccb(Face_handle f, Ccb_halfedge_circulator h, + Halfedge_handle e); + + /*! issued immediately after an outer CCB of the face `f` has been split, + * resulting in the two holes `h1` and `h2`. + */ + virtual void after_split_outer_ccb(Face_handle f, + Ccb_halfedge_circulator h1, + Ccb_halfedge_circulator h2); + + /*! issued just before an inner CCB `h` inside a face `f` is split into two, + * as a result of the removal of the edge `e` from the arrangement. + */ + virtual void before_split_inner_ccb(Face_handle f, Ccb_halfedge_circulator h, + Halfedge_handle e); + + /*! issued immediately after an inner CCB of the face `f` has been split, + * resulting in the two inner CCBs (holes) `h1` and `h2`. + */ + virtual void after_split_inner_ccb(Face_handle f, + Ccb_halfedge_circulator h1, + Ccb_halfedge_circulator h2); + + /*! issued just before the edge `e` is inserted as a new outer CCB inside the + * face `f`. + */ + virtual void before_add_outer_ccb(Face_handle f, Halfedge_handle e); + + /*! issued immediately after a new outer ccb `h` has been created. The outer + * ccb always consists of a single pair of twin halfedges. + */ + virtual void after_add_outer_ccb(Ccb_halfedge_circulator h); + + /*! issued just before the edge `e` is inserted as a new inner CCB inside the + * face `f`. + */ + virtual void before_add_inner_ccb(Face_handle f, Halfedge_handle e); + + /*! issued immediately after a new inner CCB `h` has been created. The inner + * CCB always consists of a single pair of twin halfedges. + */ + virtual void after_add_inner_ccb(Ccb_halfedge_circulator h); + + /*! issued just before the vertex `v` is inserted as an isolated vertex inside + * the face `f`. + */ + virtual void before_add_isolated_vertex(Face_handle f, Vertex_handle v); + + /*! issued immediately after the vertex `v` has been set as an isolated vertex. + */ + virtual void after_add_isolated_vertex(Vertex_handle v); + + /*! issued just before the two edges `e1` and `e2` are merged to form a single + * edge that will be associated with the \f$x\f$-monotone curve `c`. + */ + virtual void before_merge_edge(Halfedge_handle e1, Halfedge_handle e2, + const X_monotone_curve_2& c); + + /*! issued immediately after two edges have been merged to form the edge `e`. + */ + virtual void after_merge_edge(Halfedge_handle e); + + /*! issued just before the two fictitious edges `e1` and `e2` are merged to + * form a single fictitious edge. + */ + virtual void before_merge_fictitious_edge(Halfedge_handle e1, + Halfedge_handle e2); + + /*! issued immediately after two fictitious edges have been merged to form the + * fictitious edge `e`. + */ + virtual void after_merge_fictitious_edge(Halfedge_handle e); + + /*! issued just before the two edges `f1` and `f2` are merged to form a single + * face, following the removal of the edge `e` from the arrangement. + */ + virtual void before_merge_face(Face_handle f1, Face_handle f2, + Halfedge_handle e); + + /*! issued immediately after two faces have been merged to form the face `f`. + */ + virtual void after_merge_face(Face_handle f); + + /*! issued just before two outer ccbs `h1` and `h2` inside the face `f` are + * merged to form a single connected component, following the insertion of the + * edge `e` into the arrangement. + */ + virtual void before_merge_outer_ccb(Face_handle f, + Ccb_halfedge_circulator h1, + Ccb_halfedge_circulator h2, + Halfedge_handle e); + + /*! issued immediately after two outer cCBs have been merged to form a single + * outer CCB `h` inside the face `f`. + */ + virtual void after_merge_outer_ccb(Face_handle f, Ccb_halfedge_circulator h); + + /*! issued just before two inner CCBs `h1` and `h2` inside the face `f` are + * merged to form a single connected component, following the insertion of the + * edge `e` into the arrangement. + */ + virtual void before_merge_inner_ccb(Face_handle f, + Ccb_halfedge_circulator h1, + Ccb_halfedge_circulator h2, + Halfedge_handle e); + + /*! issued immediately after two inner CCBs have been merged to form a single + * inner CCB `h` inside the face `f`. + */ + virtual void after_merge_inner_ccb(Face_handle f, Ccb_halfedge_circulator h); + + /*! issued just before the outer CCB `h` is moved from one face to another. + * This can happen if the face `to_f` containing the outer CCB has just been + * split from `from_f`. + */ + virtual void before_move_outer_ccb(Face_handle from_f, Face_handle to_f, + Ccb_halfedge_circulator h); + + /*! issued immediately after the outer CCB `h` has been moved to a new face. + */ + virtual void after_move_outer_ccb(Ccb_halfedge_circulator h); + + /*! issued just before the inner CCB `h` is moved from one face to another. + * This can happen if the face `to_f` containing the inner CCB has just been + * split from `from_f`. + */ + virtual void before_move_inner_ccb(Face_handle from_f, Face_handle to_f, + Ccb_halfedge_circulator h); + + /*! issued immediately after the inner CCB `h` has been moved to a new face. + */ + virtual void after_move_inner_ccb(Ccb_halfedge_circulator h); + + /*! issued just before the isolated vertex `v` is moved from one face to + * another. This can happen if the face `to_f` containing the isolated vertex + * has just been split from `from_f`. + */ + virtual void before_move_isolated_vertex(Face_handle from_f, + Face_handle to_f, Vertex_handle v); + + /*! issued immediately after the isolated vertex `v` has been moved to a new + * face. + */ + virtual void after_move_isolated_vertex(Vertex_handle v); + + /*! issued just before the vertex `v` is removed from the arrangement. */ + virtual void before_remove_vertex(Vertex_handle v); + + /*! issued immediately after a vertex has been removed (and deleted) from the + * arrangement. + */ + virtual void after_remove_vertex(); + + /*! issued just before the edge `e` is removed from the arrangement. */ + virtual void before_remove_edge(Halfedge_handle e); + + /*! issued immediately after an edge has been removed (and deleted) from the + * arrangement. + */ + virtual void after_remove_edge(); + + /*! issued just before the outer ccb `f` is removed from inside the face `f`. + */ + virtual void before_remove_outer_ccb(Face_handle f, Ccb_halfedge_circulator h); + + /*! issued immediately after a outer CCB has been removed (and deleted) from + * inside the face `f`. + */ + virtual void after_remove_outer_ccb(Face_handle f); + + /*! issued just before the inner CCB `f` is removed from inside the face `f`. + */ + virtual void before_remove_inner_ccb(Face_handle f, + Ccb_halfedge_circulator h); + + /*! issued immediately after a inner CCB has been removed (and deleted) from + * inside the face `f`. + */ + virtual void after_remove_inner_ccb(Face_handle f); + + /// @} + +}; /* end Aos_observer */ +} /* end namespace CGAL */ diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_bounded_planar_topology_traits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_bounded_planar_topology_traits_2.h index f839b4967ef..9bda6a296b9 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_bounded_planar_topology_traits_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_bounded_planar_topology_traits_2.h @@ -9,13 +9,13 @@ namespace CGAL { * * The `Arr_bounded_planar_topology_traits_2` template has two parameters: *
      - *
    • The `GeometryTraits_2` template-parameter should be instantiated with + *
    • The `GeometryTraits_2` template-parameter should be substituted by * a model of the `ArrangementBasicTraits_2` concept. The traits * class defines the types of \f$x\f$-monotone curves and two-dimensional * points, namely `ArrangementBasicTraits_2::X_monotone_curve_2` and * `ArrangementBasicTraits_2::Point_2`, * respectively, and supports basic geometric predicates on them. - *
    • The `Dcel` template-parameter should be instantiated with + *
    • The `Dcel` template-parameter should be substituted by * a class that is a model of the `ArrangementDcel` concept. The * value of this parameter is by default * `Arr_default_dcel`. diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_conic_traits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_conic_traits_2.h index afe365a3da4..2db8001f4b1 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_conic_traits_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_conic_traits_2.h @@ -57,17 +57,17 @@ namespace CGAL { * algebraic number of degree \f$d\f$ if there exist a polynomial \f$ p\f$ with * integer coefficient of degree \f$d\f$ such that \f$p(\alpha) = 0\f$). * We therefore require separate representations of the curve - * coefficients and the point coordinates. The `NtTraits` should be instantiated - * with a class that defines nested `Integer`, `Rational`, and `Algebraic` number + * coefficients and the point coordinates. The `NtTraits` should be substituted + * by a class that defines nested `Integer`, `Rational`, and `Algebraic` number * types and supports various operations on them, yielding certified computation * results (for example, it can convert rational numbers to algebraic numbers * and can compute roots of polynomials with integer coefficients). The other * template parameters, `RatKernel` and `AlgKernel` should be geometric kernels * instantiated with the `NtTraits::Rational` and `NtTraits::Algebraic` number - * types, respectively. It is recommended instantiating the - * `CORE_algebraic_number_traits` class as the `NtTraits` parameter, with - * `Cartesian` and `Cartesian` - * instantiating the two kernel types, respectively. The number types in this + * types, respectively. It is recommended substituting the + * `CORE_algebraic_number_traits` class for the `NtTraits` parameter, and + * the `Cartesian` and `Cartesian` + * instances for two kernel types, respectively. The number types in this * case are provided by the \core library, with its ability to exactly represent * simple algebraic numbers. * diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_dcel.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_dcel.h new file mode 100644 index 00000000000..a86e1611695 --- /dev/null +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_dcel.h @@ -0,0 +1,39 @@ +namespace CGAL { + +/*! \ingroup PkgArrangementOnSurface2DCEL + * + * The \dcel class used by the `Arrangement_2`, + * `Arr_bounded_planar_topology_traits_2`, `Arr_unb_planar_topology_traits_2` + * class templates and other templates. It is parameterized by a geometry + * traits type and optionaly by a vertex, halfedge, or face types. By default, + * the `Arr_dcel` class template uses the \link + * ArrangementBasicTraits_2::Point_2 `Point_2`\endlink and \link + * ArrangementBasicTraits_2::X_monotone_curve_2 `X_monotone_curve_2`\endlink + * types nested in the traits type to instantiate the vertex and base halfedge + * types, respectively. Thus, by default the \dcel only stores the topological + * incidence relations and the geometric data attached to vertices and + * edges. Any one of the vertex, halfedge, or face types can be + * overriden. Notice that if the vertex and halfedge types are overriden, the + * traits type is ignored. + * + * \cgalModels{ArrangementDcelWithRebind} + * + * \tparam Traits a geometry traits type, which is a model of the + * `ArrangementBasicTraits_2` concept. + * \tparam V the vertex type, which is a model of the `ArrangementDcelVertex` + * concept. + * \tparam H the halfedge type, which is a model of the + * `ArrangementDcelHalfedge` concept. + * \tparam F the face type, which is a model of the `ArrangementDcelFace` + * concept. + * + * \sa `Arr_dcel_base` + */ +template , + typename H = Arr_halfedge_base, + typename F = Arr_face_base> +class Arr_dcel : public Arr_dcel_base { +}; + +} /* end namespace CGAL */ diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_default_dcel.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_default_dcel.h index 453a7f05092..b2dba1ca39e 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_default_dcel.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_default_dcel.h @@ -1,26 +1,25 @@ - namespace CGAL { -/*! -\ingroup PkgArrangementOnSurface2DCEL +/*! \ingroup PkgArrangementOnSurface2DCEL + * + * The default \dcel class used by the `Arrangement_2`, + * `Arr_bounded_planar_topology_traits_2`, `Arr_unb_planar_topology_traits_2` + * class templates and other templates. It is parameterized by a geometry + * traits type. It uses the \link ArrangementBasicTraits_2::Point_2 + * `Point_2`\endlink and \link ArrangementBasicTraits_2::X_monotone_curve_2 + * `X_monotone_curve_2`\endlink types nested in the traits type to instantiate + * the vertex and base halfedge types, respectively. Thus, by default the \dcel + * only stores the topological incidence relations and the geometric data + * attached to vertices and edges. + * + * \cgalModels{ArrangementDcelWithRebind} + * + * \tparam Traits a geometry traits type, which is a model of the + * `ArrangementBasicTraits_2` concept. + * + * \sa `Arr_dcel` + * \sa `Arr_dcel_base` + */ +template using Arr_default_dcel = Arr_dcel; -The default \dcel class used by the `Arrangement_2` class-template -is parameterized by a traits class, which is a model of the -`ArrangementBasicTraits_2` concept. It simply uses the nested -`Traits::Point_2` and `Traits::X_monotone_curve_2` to instantiate -the base vertex and halfedge types, respectively. Thus, the default -\dcel records store no other information, except for the topological -incidence relations and the geometric data attached to vertices and edges. - -\cgalModels{ArrangementDcelWithRebind} - -\sa `Arr_dcel_base` -*/ -template< typename Traits > -class Arr_default_dcel : - public Arr_dcel_base< Arr_vertex_base, - Arr_halfedge_base, - Arr_face_base> -{ -}; /* end Arr_default_dcel */ } /* end namespace CGAL */ diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_face_index_map.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_face_index_map.h index bcb0d5c378f..21f071f4596 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_face_index_map.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_face_index_map.h @@ -1,77 +1,69 @@ namespace CGAL { -/*! -\ingroup PkgArrangementOnSurface2Ref + /*! \ingroup PkgArrangementOnSurface2Ref + * + * `Arr_face_index_map` maintains a mapping of face handles of an attached + * arrangement object to indices (of type `unsigned int`). This class template + * is a model of the concept `ReadablePropertyMap`. A mapping between face + * handles and indices enables convenient usage of property-map classes supplied + * by `boost`. For example, the property-map class templates + * `boost::vector_property_map`, which is based on `std::vector`, and + * `boost::iterator_property_map`, which can be used to implement a property map + * based on a native \CC array, require the user to supply a mapping such as + * `Arr_face_index_map`. + * + * As new faces might be inserted into the attached arrangement, and + * existing faces might be removed, the notification mechanism is used + * to dynamically maintain the mapping of face handles to indices. + * + * \cgalModels{DefaultConstructible,CopyConstructible,Assignable,ReadablePropertyMap} + * + * \sa `Arr_vertex_index_map` + */ -`Arr_face_index_map` maintains a mapping of face handles of an -attached arrangement object to indices (of type `unsigned int`). -This class template is a model of the concept -`ReadablePropertyMap`. A mapping between face handles and indices -enables convenient usage of property-map classes supplied by `boost`. -For example, the property-map class templates -`boost::vector_property_map`, which is based on `std::vector`, -and `boost::iterator_property_map`, which can be used to implement -a property map based on a native \CC array, require the -user to supply a mapping such as `Arr_face_index_map`. + template + class Arr_face_index_map: public Arrangement_::Observer { + public: -As new faces might be inserted into the attached arrangement, and -existing faces might be removed, the notification mechanism is used -to dynamically maintain the mapping of face handles to indices. + /// \name Types + /// @{ + /*! the type of the attached arrangement. + */ + typedef Arrangement_ Arrangement_2; + typedef typename Arrangement_2::Base_aos Base_aos; -\cgalModels{DefaultConstructible,CopyConstructible,Assignable,ReadablePropertyMap} + typedef boost::readable_property_map_tag category; -\sa `Arr_observer` -\sa `Arr_vertex_index_map` -*/ + typedef unsigned int value_type; -template< typename Arrangement > -class Arr_face_index_map: public Arr_observer { -public: + typedef unsigned int reference; -/// \name Types -/// @{ + typedef Face_handle key_type; -/*! -the type of the attached arrangement. -*/ -typedef Arrangement Arrangement_2; + /*! The face handle type. + */ + typedef typename Base_aos::Face_handle Face_handle; -typedef boost::readable_property_map_tag category; + /*! The type of mapping of faces to indices. + */ + typedef Unique_hash_map Index_map; -typedef unsigned int value_type; + /// @} -typedef unsigned int reference; + /// \name Creation + /// @{ -typedef Face_handle key_type; + /*! constructs a map that is unattached to any arrangement instance. + */ + Arr_face_index_map(); -/*! -The face handle type. -*/ -typedef typename Arrangement_2::Face_handle Face_handle; + /*! constructs a map and attaches it to the given arrangement `arr`. + */ + Arr_face_index_map(Base_aos& arr); -/*! -The type of mapping of faces to indices. -*/ -typedef Unique_hash_map Index_map; + /// @} -/// @} + }; /* end Arr_accessor */ -/// \name Creation -/// @{ - -/*! -constructs a map that is unattached to any arrangement instance. -*/ -Arr_face_index_map(); - -/*! -constructs a map and attaches it to the given arrangement `arr`. -*/ -Arr_face_index_map(Arrangement_2& arr); - -/// @} - -}; /* end Arr_accessor */ } /* end namespace CGAL */ - diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_non_caching_segment_basic_traits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_non_caching_segment_basic_traits_2.h index e85664bdb76..ab5cf747b7a 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_non_caching_segment_basic_traits_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_non_caching_segment_basic_traits_2.h @@ -16,7 +16,7 @@ that are not provided by the kernel. The kernel is parameterized with a number type, which should support the arithmetic operations \f$ +\f$, \f$ -\f$ and \f$ \times\f$ in an exact manner in order to avoid robustness problems. Using `Cartesian` or `Cartesian` are possible -instantiations for the kernel. Using other (inexact) number types +substitutions for the kernel. Using other (inexact) number types (for example, instantiating the template with `Simple_cartesian`) is also possible, at the user's own risk. diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_observer.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_observer.h index fe04d140aeb..99abf22396f 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_observer.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_observer.h @@ -2,408 +2,14 @@ namespace CGAL { /*! \ingroup PkgArrangementOnSurface2Ref * - * \anchor arr_refarr_obs - * - * `Arr_observer` serves as an abstract base class for all observer classes that - * are attached to an arrangement instance of type `Arrangement` and receive - * notifications from the arrangement. This base class handles the attachment - * of the observer to a given arrangement instance or to the detachment of the - * observer from this arrangement instance. It also gives a default empty - * implementation to all notification functions that are invoked by the - * arrangement to notify the observer on local or global changes it undergoes. - * The notification functions are all virtual functions, so they can be - * overridden by the concrete observer classes that inherit from `Arr_observer`. - * - * In order to implement a concrete arrangement observer-class, one simply needs - * to derive from `Arr_observer` and override the relevant notification - * functions. For example, if only face-split events are of interest, it is - * sufficient to override just `before_split_face()` (or just - * `after_split_face()`). + * `Arr_observer` is an alias for + * Aos_observer`, + * where `Arrangement_2` derives from `Arrangement_on_surface_2` and the latter + * is an instance of the template + * `CGAL::Arrangement_on_surface_2`. */ -template< typename Arrangement > -class Arr_observer { -public: -/// \name Types -/// @{ +template +using Arr_observer = typename Arrangement_::Observer; -/*! the type of the associated arrangement. */ -typedef unspecified_type Arrangement_2; - -/*! the point type. */ -typedef typename Arrangement_2::Point_2 Point_2; - -/*! the \f$ x\f$-monotone curve type. */ -typedef typename Arrangement_2::X_monotone_curve_2 X_monotone_curve_2; - -/*! */ -typedef typename Arrangement_2::Vertex_handle Vertex_handle; - -/*! */ -typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - -/*! */ -typedef typename Arrangement_2::Face_handle Face_handle; - -/*! represents a connected component of the boundary (CCB), either an outer - * boundary or an inner boundary (the latter is also referred to as a hole). - */ -typedef typename Arrangement_2::Ccb_halfedge_circulator Ccb_halfedge_circulator; - -/// @} - -/// \name Creation -/// @{ - -/*! constructs an observer that is unattached to any arrangement instance. */ -Arr_observer(); - -/*! constructs an observer and attaches it to the given arrangement `arr`. */ -Arr_observer(Arrangement_2& arr); - -/// @} - -/// \name Modifiers -/// @{ - -/*! attaches the observer to the given arrangement `arr`. */ -void attach(Arrangement_2& arr); - -/*! detaches the observer from its arrangement. */ -void detach(); - -/// @} - -/// \name Notifications on Global Arrangement Operations -/// @{ - -/*! issued just before the attached arrangement is assigned with the contents of - * another arrangement `arr`. - */ -virtual void before_assign(const Arrangement_2& arr); - -/*! issued immediately after the attached arrangement has been assigned with the - * contents of another arrangement. - */ -virtual void after_assign(); - -/*! issued just before the attached arrangement is cleared. */ -virtual void before_clear(); - -/*! issued immediately after the attached arrangement has been cleared, so it - * now consists only of a the unbounded face `uf`. - */ -virtual void after_clear(Face_handle uf); - -/*! issued just before a global function starts to modify the attached - * arrangement. It is guaranteed that no queries (especially no point-location - * queries) are issued until the termination of the global function is indicated - * by `after_global_change()`. - */ -virtual void before_global_change(); - -/*! -issued immediately after a global function has stopped modifying the -attached arrangement. -*/ -virtual void after_global_change(); - -/// @} - -/// \name Notifications on Attachment or Detachment -/// @{ - -/*! issued just before the observer is attached to the arrangement instance - * `arr`. - */ -virtual void before_attach(const Arrangement_2& arr); - -/*! issued immediately after the observer has been attached to an arrangement - * instance. - */ -virtual void after_attach(); - -/*! issued just before the observer is detached from its arrangement instance. - */ -virtual void before_detach(); - -/*! issued immediately after the observer has been detached from its arrangement - * instance. - */ -virtual void after_detach(); - -/// @} - -/// \name Notifications on Local Changes in the Arrangement -/// @{ - -/*! issued just before a new vertex that corresponds to the point `p` is - * created. - */ -virtual void before_create_vertex(const Point_2& p); - -/*! issued immediately after a new vertex `v` has been created. Note that the - * vertex still has no incident edges and is not connected to any other vertex. - */ -virtual void after_create_vertex(Vertex_handle v); - -/*! issued just before a new vertex at infinity is created, `cv` is the curve - * incident to the surface boundary, `ind` is the relevant curve-end, `ps_x` is - * the boundary condition of the vertex in \f$ x\f$ and `ps_y` is the boundary - * condition of the vertex in \f$ y\f$. - */ -virtual void before_create_boundary_vertex(const X_monotone_curve_2& cv, - Arr_curve_end ind, - Arr_parameter_space ps_x, - Arr_parameter_space ps_y); - -/*! issued immediately after a new vertex `v` has been created. Note that the - * vertex still has no incident edges and is not connected to any other vertex. - */ -virtual void after_create_boundary_vertex(Vertex_handle v); - -/*! issued just before a new edge that corresponds to the \f$ x\f$-monotone - * curve `c` and connects the vertices `v1` and `v2` is created. - */ -virtual void before_create_edge(const X_monotone_curve_2& c, - Vertex_handle v1, Vertex_handle v2); - -/*! issued immediately after a new edge `e` has been created. The halfedge that - * is sent to this function is always directed from `v1` to `v2` (see above). - */ -virtual void after_create_edge(Halfedge_handle e); - -/*! issued just before a vertex `v` is modified to be associated with the point - * `p`. - */ -virtual void before_modify_vertex(Vertex_handle v, const Point_2& p); - -/*! issued immediately after an existing vertex `v` has been modified. */ -virtual void after_modify_vertex(Vertex_handle v); - -/*! issued just before an edge `e` is modified to be associated with the \f$ - * x\f$-monotone curve `c`. - */ -virtual void before_modify_edge(Halfedge_handle e, const X_monotone_curve_2& c); - -/*! issued immediately after an existing edge `e` has been modified. */ -virtual void after_modify_edge(Halfedge_handle e); - -/*! issued just before an edge `e` is split into two edges that should be - * associated with the \f$ x\f$-monotone curves `c1` and `c2`. The vertex `v` - * corresponds to the split point, and will be used to separate the two - * resulting edges. - */ -virtual void before_split_edge(Halfedge_handle e, Vertex_handle v, - const X_monotone_curve_2& c1, - const X_monotone_curve_2& c2); - -/*! issued immediately after an existing edge has been split into the two given - * edges `e1` and `e2`. - */ -virtual void after_split_edge(Halfedge_handle e1, Halfedge_handle e2); - -/*! issued just before a fictitious edge `e` is split into two. The vertex at - * infinity `v` corresponds to the split point, and will be used to separate the - * two resulting edges. - */ -virtual void before_split_fictitious_edge(Halfedge_handle e, Vertex_handle v); - -/*! issued immediately after an existing fictitious edge has been split into the - * two given fictitious edges `e1` and `e2`. - */ -virtual void after_split_fictitious_edge(Halfedge_handle e1, Halfedge_handle e2); - -/*! issued just before a face `f` is split into two, as a result of the - * insertion of the edge `e` into the arrangement. - */ -virtual void before_split_face(Face_handle f, Halfedge_handle e); - -/*! issued immediately after the existing face `f1` has been split, such that a - * portion of it now forms a new face `f2`. The flag `is_hole` designates - * whether `f2` forms a hole (an inner CCB) inside `f1`. - */ -virtual void after_split_face(Face_handle f1, Face_handle f2, bool is_hole); - -/*! issued just before outer ccb `h` inside a face `f` is split into two, as a - * result of the removal of the edge `e` from the arrangement. - */ -virtual void before_split_outer_ccb(Face_handle f, Ccb_halfedge_circulator h, - Halfedge_handle e); - -/*! issued immediately after an outer ccb of the face `f` has been split, - * resulting in the two holes `h1` and `h2`. - */ -virtual void after_split_outer_ccb(Face_handle f, - Ccb_halfedge_circulator h1, - Ccb_halfedge_circulator h2); - -/*! issued just before an inner ccb `h` inside a face `f` is split into two, as - * a result of the removal of the edge `e` from the arrangement. - */ -virtual void before_split_inner_ccb(Face_handle f, Ccb_halfedge_circulator h, - Halfedge_handle e); - -/*! issued immediately after an inner ccb of the face `f` has been split, - * resulting in the two inner CCBs (holes) `h1` and `h2`. - */ -virtual void after_split_inner_ccb(Face_handle f, - Ccb_halfedge_circulator h1, - Ccb_halfedge_circulator h2); - -/*! issued just before the edge `e` is inserted as a new outer ccb inside the - * face `f`. - */ -virtual void before_add_outer_ccb(Face_handle f, Halfedge_handle e); - -/*! issued immediately after a new outer ccb `h` has been created. The outer ccb - * always consists of a single pair of twin halfedges. - */ -virtual void after_add_outer_ccb(Ccb_halfedge_circulator h); - -/*! issued just before the edge `e` is inserted as a new inner ccb inside the - * face `f`. - */ -virtual void before_add_inner_ccb(Face_handle f, Halfedge_handle e); - -/*! issued immediately after a new inner ccb `h` has been created. The inner ccb - * always consists of a single pair of twin halfedges. - */ -virtual void after_add_inner_ccb(Ccb_halfedge_circulator h); - -/*! issued just before the vertex `v` is inserted as an isolated vertex inside - * the face `f`. - */ -virtual void before_add_isolated_vertex(Face_handle f, Vertex_handle v); - -/*! issued immediately after the vertex `v` has been set as an isolated vertex. - */ -virtual void after_add_isolated_vertex(Vertex_handle v); - -/*! issued just before the two edges `e1` and `e2` are merged to form a single - * edge that will be associated with the \f$ x\f$-monotone curve `c`. -*/ -virtual void before_merge_edge(Halfedge_handle e1, Halfedge_handle e2, - const X_monotone_curve_2& c); - -/*! issued immediately after two edges have been merged to form the edge `e`. */ -virtual void after_merge_edge(Halfedge_handle e); - -/*! issued just before the two fictitious edges `e1` and `e2` are merged to form - * a single fictitious edge. - */ -virtual void before_merge_fictitious_edge(Halfedge_handle e1, - Halfedge_handle e2); - -/*! issued immediately after two fictitious edges have been merged to form the - * fictitious edge `e`. - */ -virtual void after_merge_fictitious_edge(Halfedge_handle e); - -/*! issued just before the two edges `f1` and `f2` are merged to form a single - * face, following the removal of the edge `e` from the arrangement. - */ -virtual void before_merge_face(Face_handle f1, Face_handle f2, - Halfedge_handle e); - -/*! issued immediately after two faces have been merged to form the face `f`. */ -virtual void after_merge_face(Face_handle f); - -/*! issued just before two outer ccbs `h1` and `h2` inside the face `f` are - * merged to form a single connected component, following the insertion of the - * edge `e` into the arrangement. - */ -virtual void before_merge_outer_ccb(Face_handle f, - Ccb_halfedge_circulator h1, - Ccb_halfedge_circulator h2, - Halfedge_handle e); - -/*! issued immediately after two outer ccbs have been merged to form a single - * outer ccb `h` inside the face `f`. - */ -virtual void after_merge_outer_ccb(Face_handle f, Ccb_halfedge_circulator h); - -/*! issued just before two inner ccbs `h1` and `h2` inside the face `f` are - * merged to form a single connected component, following the insertion of the - * edge `e` into the arrangement. - */ -virtual void before_merge_inner_ccb(Face_handle f, - Ccb_halfedge_circulator h1, - Ccb_halfedge_circulator h2, - Halfedge_handle e); - -/*! issued immediately after two inner ccbs have been merged to form a single - * inner ccb `h` inside the face `f`. - */ -virtual void after_merge_inner_ccb(Face_handle f, Ccb_halfedge_circulator h); - -/*! issued just before the outer ccb `h` is moved from one face to another. - * This can happen if the face `to_f` containing the outer ccb has just been - * split from `from_f`. - */ -virtual void before_move_outer_ccb(Face_handle from_f, Face_handle to_f, - Ccb_halfedge_circulator h); - -/*! issued immediately after the outer ccb `h` has been moved to a new face. */ -virtual void after_move_outer_ccb(Ccb_halfedge_circulator h); - -/*! issued just before the inner ccb `h` is moved from one face to another. - * This can happen if the face `to_f` containing the inner ccb has just been - * split from `from_f`. - */ -virtual void before_move_inner_ccb(Face_handle from_f, Face_handle to_f, - Ccb_halfedge_circulator h); - -/*! issued immediately after the inner ccb `h` has been moved to a new face. */ -virtual void after_move_inner_ccb(Ccb_halfedge_circulator h); - -/*! issued just before the isolated vertex `v` is moved from one face to - * another. This can happen if the face `to_f` containing the isolated vertex - * has just been split from `from_f`. - */ -virtual void before_move_isolated_vertex(Face_handle from_f, - Face_handle to_f, Vertex_handle v); - -/*! issued immediately after the isolated vertex `v` has been moved to a new - * face. - */ -virtual void after_move_isolated_vertex(Vertex_handle v); - -/*! issued just before the vertex `v` is removed from the arrangement. */ -virtual void before_remove_vertex(Vertex_handle v); - -/*! issued immediately after a vertex has been removed (and deleted) from the - * arrangement. - */ -virtual void after_remove_vertex(); - -/*! issued just before the edge `e` is removed from the arrangement. */ -virtual void before_remove_edge(Halfedge_handle e); - -/*! issued immediately after an edge has been removed (and deleted) from the - * arrangement. - */ -virtual void after_remove_edge(); - -/*! issued just before the outer ccb `f` is removed from inside the face `f`. */ -virtual void before_remove_outer_ccb(Face_handle f, Ccb_halfedge_circulator h); - -/*! issued immediately after a outer ccb has been removed (and deleted) from - * inside the face `f`. - */ -virtual void after_remove_outer_ccb(Face_handle f); - -/*! issued just before the inner ccb `f` is removed from inside the face `f`. - */ -virtual void before_remove_inner_ccb(Face_handle f, -Ccb_halfedge_circulator h); - -/*! issued immediately after a inner ccb has been removed (and deleted) from - * inside the face `f`. - */ -virtual void after_remove_inner_ccb(Face_handle f); - -/// @} - -}; /* end Arr_observer */ -} /* end namespace CGAL */ +} // namespace CGAL diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_segment_traits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_segment_traits_2.h index 9036308edaa..37a7a6c29bd 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_segment_traits_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_segment_traits_2.h @@ -4,10 +4,10 @@ namespace CGAL { * * The traits class `Arr_segment_traits_2` is a model of the * `ArrangementTraits_2` concept, which allows the construction and maintenance - * of arrangements of line segments. It should be parameterized with a + * of arrangements of line segments. It is parameterized with a * \cgal-kernel model that is templated in turn with a number type. To avoid * numerical errors and robustness problems, the number type should support - * exact rational arithmetic - that is, the number type should support the + * exact rational arithmetic; that is, the number type should support the * arithmetic operations \f$ +\f$, \f$ -\f$, \f$ \times\f$ and \f$ \div\f$ * carried out without loss of precision. * diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_spherical_topology_traits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_spherical_topology_traits_2.h index 5c1775e331f..aa95832414a 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_spherical_topology_traits_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_spherical_topology_traits_2.h @@ -9,13 +9,13 @@ namespace CGAL { * * The `Arr_spherical_topology_traits_2` template has two parameters: *
        - *
      • The `GeometryTraits_2` template-parameter should be instantiated with + *
      • The `GeometryTraits_2` template-parameter should be substituted by * a model of the `ArrangementBasicTraits_2` concept. The traits * class defines the types of \f$x\f$-monotone curves and two-dimensional * points, namely `ArrangementBasicTraits_2::X_monotone_curve_2` and * `ArrangementBasicTraits_2::Point_2`, * respectively, and supports basic geometric predicates on them. - *
      • The `Dcel` template-parameter should be instantiated with + *
      • The `Dcel` template-parameter should be substituted by * a class that is a model of the `ArrangementDcel` concept. The * value of this parameter is by default * `Arr_default_dcel`. diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_triangulation_point_location.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_triangulation_point_location.h index 5106f32ec36..f0799d553be 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_triangulation_point_location.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_triangulation_point_location.h @@ -1,7 +1,6 @@ namespace CGAL { -/*! - * \ingroup PkgArrangementOnSurface2PointLocation +/*! \ingroup PkgArrangementOnSurface2PointLocation * * \anchor arr_reftri_pl * @@ -23,7 +22,6 @@ namespace CGAL { */ template -class Arr_triangulation_point_location : public Arr_observer -{} +class Arr_triangulation_point_location : public Arrangement_::Observer {} } diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_unb_planar_topology_traits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_unb_planar_topology_traits_2.h index 06efe81c731..9a3aaf14789 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_unb_planar_topology_traits_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_unb_planar_topology_traits_2.h @@ -9,13 +9,13 @@ namespace CGAL { * * The `Arr_unb_planar_topology_traits_2` template has two parameters: *
          - *
        • The `GeometryTraits_2` template-parameter should be instantiated with + *
        • The `GeometryTraits_2` template-parameter should be substituted by * a model of the `ArrangementBasicTraits_2` concept. The traits * class defines the types of \f$x\f$-monotone curves and two-dimensional * points, namely `ArrangementBasicTraits_2::X_monotone_curve_2` and * `ArrangementBasicTraits_2::Point_2`, * respectively, and supports basic geometric predicates on them. - *
        • The `Dcel` template-parameter should be instantiated with + *
        • The `Dcel` template-parameter should be substituted by * a class that is a model of the `ArrangementDcel` concept. The * value of this parameter is by default * `Arr_default_dcel`. diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_vertex_index_map.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_vertex_index_map.h index 1c915a6b23c..e5bb1449dbf 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_vertex_index_map.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arr_vertex_index_map.h @@ -1,82 +1,69 @@ namespace CGAL { -/*! -\ingroup PkgArrangementOnSurface2Ref + /*! \ingroup PkgArrangementOnSurface2Ref + * + * `Arr_vertex_index_map` maintains a mapping of vertex handles of an attached + * arrangement object to indices (of type `unsigned int`). This class template + * is a model of the concept `ReadablePropertyMap`. A mapping between vertex + * handles and indices enables convenient usage of property-map classes supplied + * by `boost`. For example, the property-map class templates + * `boost::vector_property_map`, which is based on `std::vector`, and + * `boost::iterator_property_map`, which can be used to implement a property map + * based on a native \CC array, require the user to supply a mapping such as + * `Arr_vertex_index_map`. + * + * As new vertices might be inserted into the attached arrangement, and + * existing vertices might be removed, the notification mechanism is used + * to dynamically maintain the mapping of vertex handles to indices. + * + * \cgalModels{DefaultConstructible,CopyConstructible,Assignable,ReadablePropertyMap} + * + * \sa `Arr_face_index_map` + */ -`Arr_vertex_index_map` maintains a mapping of vertex handles of an -attached arrangement object to indices (of type `unsigned int`). -This class template is a model of the concept -`ReadablePropertyMap`. A mapping between vertex handles and indices -enables convenient usage of property-map classes supplied by `boost`. -For example, the property-map class templates -`boost::vector_property_map`, which is based on `std::vector`, -and `boost::iterator_property_map`, which can be used to implement -a property map based on a native \CC array, require the -user to supply a mapping such as `Arr_vertex_index_map`. + template< typename Arrangement_> + class Arr_vertex_index_map: public Arrangement_::Observer { + public: -As new vertices might be inserted into the attached arrangement, and -existing vertices might be removed, the notification mechanism is used -to dynamically maintain the mapping of vertex handles to indices. + /// \name Types + /// @{ + /*! the type of the attached arrangement. + */ + typedef Arrangement_ Arrangement_2; + typedef typename Arrangement_2::Base_aos Base_aos; -\cgalModels{DefaultConstructible,CopyConstructible,Assignable,ReadablePropertyMap} + typedef boost::readable_property_map_tag category; -\sa `Arr_observer` -\sa `Arr_face_index_map` -*/ + typedef unsigned int value_type; -template< typename Arrangement > -class Arr_vertex_index_map: public Arr_observer { -public: + typedef unsigned int reference; -/// \name Types -/// @{ + typedef Vertex_handle key_type; -/*! -the type of the attached arrangement. -*/ -typedef Arrangement Arrangement_2; + /*! The vertex handle type. + */ + typedef typename Base_aos::Vertex_handle Vertex_handle; -typedef boost::readable_property_map_tag category; + /*! The type of mapping of vertices to indices. + */ + typedef Unique_hash_map Index_map; -typedef unsigned int value_type; + /// @} -typedef unsigned int reference; + /// \name Creation + /// @{ -typedef Vertex_handle key_type; + /*! constructs a map that is unattached to any arrangement instance. + */ + Arr_vertex_index_map(); -/*! -The vertex handle type. -*/ -typedef typename Arrangement_2::Vertex_handle Vertex_handle; + /*! constructs a map and attaches it to the given arrangement `arr`. + */ + Arr_vertex_index_map(Base_aos& arr); -/*! -The type of mapping of vertices to indices. -*/ -typedef Unique_hash_map Index_map; + /// @} -/// @} + }; /* end Arr_accessor */ -/// \name Creation -/// @{ - -/*! -constructs a map that is unattached to any arrangement instance. -*/ -Arr_vertex_index_map(); - -/*! -constructs a map and attaches it to the given arrangement `arr`. -*/ -Arr_vertex_index_map(Arrangement_2& arr); - -/// @} - -}; /* end Arr_accessor */ } /* end namespace CGAL */ - - - - - - diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_on_surface_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_on_surface_2.h index 5886ce3f19d..4de00662fa5 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_on_surface_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_on_surface_2.h @@ -16,14 +16,14 @@ namespace CGAL { * The `Arrangement_on_surface_2` template has two parameters: *
            - *
          • The `GeometryTraits` template-parameter should be instantiated with + *
          • The `GeometryTraits` template-parameter should be substituted by * a model of a geometry traits. The minimal requirements are defined by the * `ArrangementBasicTraits_2` concept. A model of this concept defines * the types of \f$ x\f$-monotone curves and two-dimensional points, namely * `ArrangementBasicTraits_2::X_monotone_curve_2` and * `ArrangementBasicTraits_2::Point_2`, respectively, and supports basic * geometric predicates on them. - *
          • The `TopologyTraits` template-parameter should be instantiated with a + *
          • The `TopologyTraits` template-parameter should be substituted by a * class that is a model of the `ArrangementTopologyTraits` concept. *
          * diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_on_surface_with_history_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_on_surface_with_history_2.h index a01bb1b19cf..ac6fac59496 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_on_surface_with_history_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_on_surface_with_history_2.h @@ -25,16 +25,15 @@ namespace CGAL { * The `Arrangement_on_surface_with_history_2` template has two parameters: * *
            - *
          • The `GeometryTraits` template-parameter should be instantiated with a + *
          • The `GeometryTraits` template-parameter should be substituted by a * model of the `ArrangementTraits_2` concept. The traits class defines the * `Curve_2` type, which represents an input curve. It also defines the types * of \f$ x\f$-monotone curves and two-dimensional points, namely * `ArrangementTraits_2::X_monotone_curve_2` and * `ArrangementTraits_2::Point_2`, respectively, and supports basic * geometric predicates on them. - *
          • The `Dcel` template-parameter should be instantiated with a class that is - * a model of the `ArrangementDcelWithRebind` concept. The value of this - * parameter is by default `Arr_default_dcel`. + *
          • The `TopologyTraits` template-parameter should be substituted by a + * class that is a model of the `ArrangementTopologyTraits` concept. *
          * * \sa `Arrangement_with_history_2` diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_with_history_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_with_history_2.h index 4c6e380b750..a4f001847c3 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_with_history_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/CGAL/Arrangement_with_history_2.h @@ -23,13 +23,13 @@ namespace CGAL { * * The `Arrangement_with_history_2` template has two parameters: *
            - *
          • The `Traits` template-parameter should be instantiated with a model of + *
          • The `Traits` template-parameter should be substituted by a model of * the `ArrangementTraits_2` concept. The traits class defines the `Curve_2` * type, which represents an input curve. It also defines the types of \f$ * x\f$-monotone curves and two-dimensional points, namely * `ArrangementTraits_2::X_monotone_curve_2` and `ArrangementTraits_2::Point_2`, * respectively, and supports basic geometric predicates on them. - *
          • The `Dcel` template-parameter should be instantiated with a class that is + *
          • The `Dcel` template-parameter should be substituted by a class that is * a model of the `ArrangementDcelWithRebind` concept. The value of this * parameter is by default `Arr_default_dcel`. *
          diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementDcelWithRebind.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementDcelWithRebind.h index f263a1aae0d..5d1c38474a6 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementDcelWithRebind.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementDcelWithRebind.h @@ -12,6 +12,7 @@ Instantiate a dcel class with many different possible types without ad-hoc limit \cgalHasModelsBegin \cgalHasModels{CGAL::Arr_default_dcel} +\cgalHasModels{CGAL::Arr_dcel} \cgalHasModels{CGAL::Arr_face_extended_dcel} \cgalHasModels{CGAL::Arr_extended_dcel} \cgalHasModelsEnd @@ -48,4 +49,3 @@ Arr_dcel(); /// @} }; /* end ArrangementDcelWithRebind */ - diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementLandmarkTraits_2.h b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementLandmarkTraits_2.h index 75c1a6bd241..673d553e69d 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementLandmarkTraits_2.h +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/Concepts/ArrangementLandmarkTraits_2.h @@ -7,7 +7,7 @@ * associated with the landmark point-location strategy (see * `CGAL::Arr_landmarks_point_location`) must be an instance of the * `CGAL::Arrangement_2` class template, where the Traits parameter - * is substituted with a model of this concept. + * is substituted by a model of this concept. * * \cgalRefines{ArrangementApproximateTraits_2,ArrangementConstructXMonotoneCurveTraits_2} * diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt index 20dc50a5795..1a82a431b56 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/PackageDescription.txt @@ -199,11 +199,13 @@ implemented as peripheral classes or as free (global) functions. - `CGAL::Arrangement_2` - `CGAL::Arrangement_with_history_2` - `CGAL::Arr_accessor` -- `CGAL::Arr_observer` +- `CGAL::Aos_observer` +- `CGAL::Arr_observer` - `CGAL::Arrangement_2::Vertex` - `CGAL::Arrangement_2::Halfedge` - `CGAL::Arrangement_2::Face` - `CGAL::Arr_dcel_base` +- `CGAL::Arr_dcel` - `CGAL::Arr_default_dcel` - `CGAL::Arr_face_extended_dcel` - `CGAL::Arr_extended_dcel` diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/curve_history.tex b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/curve_history.tex index dc37efec3c9..8b8d55590a0 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/curve_history.tex +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/curve_history.tex @@ -2,56 +2,62 @@ \input{header} \pagestyle{empty} \begin{document} -\psscalebox{1.8}{\arrset{1}% - \pspicture[](-1,-1)(8,7) - \arraxes(0,0)(-1,-1)(8,7) - \arrMainVertex(0,0){1} - \arrMainVertex(0,3){2} - \arrEmptyVertex(1,3){3} - \arrMainVertex(2,3){4} - \arrMainVertex(2,6){5} - \arrMainVertex(3,1){6} - \arrEmptyVertex(3,3){7} - \arrMainVertex(3,4){8} - \arrMainVertex(3,5){9} - \arrMainVertex(4,3){10} - \arrEmptyVertex(4,4){11} - \arrMainVertex(5,3){12} - \arrMainVertex(6,4){13} - \arrMainVertex(7,1){14} - \arrCrossVertex(4,6){x1}\uput[-45]{0}(4,6){$q_1$} - \arrCrossVertex(6,2){x2}\uput[45]{0}(6,2){$q_2$} - \arrCrossVertex(2,4){x3}\uput[45]{0}(2,4){$q_3$} - % - \ncline[linewidth=1pt,linecolor=blue]{1}{3} - \ncline[linewidth=1pt,linecolor=blue]{3}{5} - \ncline[linewidth=1pt,linecolor=blue]{5}{9} - \ncline[linewidth=1pt,linecolor=blue]{9}{11} - \ncline[linewidth=1pt,linecolor=blue]{11}{12} - \ncline[linewidth=1pt,linecolor=blue]{12}{14} - % - \ncline[linewidth=1pt,linecolor=blue]{6}{7} - \ncline[linewidth=1pt,linecolor=blue]{7}{8}\Bput[1pt]{\textcolor{blue}{$s_2$}} - \ncline[linewidth=1pt,linecolor=blue]{8}{9} - % - \ncline[linewidth=1pt,linecolor=blue]{8}{11} - \ncline[linewidth=1pt,linecolor=blue]{11}{13} - % - \ncline[linewidth=1pt,linecolor=blue]{4}{7} - \ncline[linewidth=1pt,linecolor=blue]{7}{10} - \ncline[linewidth=1pt,linecolor=blue]{10}{12} - % - \ncline[linestyle=dashed,dash=2pt 2pt,linewidth=1pt,linecolor=red]{2}{3} - \ncline[linestyle=dashed,dash=2pt 2pt,linewidth=1pt,linecolor=red]{3}{4} - \ncline[linestyle=dashed,dash=2pt 2pt,linewidth=1pt,linecolor=red]{4}{7} - \ncline[linestyle=dashed,dash=2pt 2pt,linewidth=1pt,linecolor=red]{7}{10} - % - \pnode(2,2){a}\uput{2pt}[-90]{0}(2,2){\textcolor{red}{$s_1$}} - \nccurve[linewidth=0.25pt,angleA=-90,angleB=90]{2}{a} - \nccurve[linewidth=0.25pt,angleA=-90,angleB=90]{10}{a} - \pnode(3.5,2){b}\uput{2pt}[-90]{0}(3.5,2){\textcolor{blue}{$s_3$}} - \nccurve[linewidth=0.25pt,angleA=-90,angleB=90]{4}{b} - \nccurve[linewidth=0.25pt,angleA=-90,angleB=90]{12}{b} - \endpspicture -} + \begin{tikzpicture}[scale=1] + \myAxes{-1}{-1}{8}{7} + \coordinate (a) at (0,0); + \coordinate (b) at (0,3); + \coordinate (d) at (2,3); + \coordinate (j) at (4,3); + \coordinate (l) at (5,3); + % + \arrMainVertexZ(a){1} + \arrMainVertexZ(b){2} + \arrIntersectionVertexZ(1,3){3} + \arrMainVertexZ(d){4} + \arrMainVertexZ(2,6){5} + \arrMainVertexZ(3,1){6} + \arrIntersectionVertexZ(3,3){7} + \arrMainVertexZ(3,4){8} + \arrMainVertexZ(3,5){9} + \arrMainVertexZ(j){10} + \arrIntersectionVertexZ(4,4){11} + \arrMainVertexZ(l){12} + \arrMainVertexZ(6,4){13} + \arrMainVertexZ(7,1){14} + % + \draw[edge](1)--(3); + \draw[edge](3)--(5); + \draw[edge](5)--(9); + \draw[edge](9)--(11); + \draw[edge](11)--(12); + \draw[edge](12)--(14); + % + \draw[edge](6)--node[sloped,below,pos=0.4] {\textcolor{blue}{$s_2$}} (7); + \draw[edge](7)--(8); + \draw[edge](8)--(9); + % + \draw[edge](8)--(11); + \draw[edge](11)--(13); + % + \draw[edge](4)--(7); + \draw[edge](7)--(10); + \draw[edge](10)--(12); + % + \draw[edge=red,dashed](2)--(3); + \draw[edge=red,dashed](3)--(4); + \draw[edge=red,dashed](4)--(7); + \draw[edge=red,dashed](7)--(10); + % + \arrQueryLabeledVertexZ[-45](4,6){x1}{$q_1$} + \arrQueryLabeledVertexZ[45](6,2){x2}{$q_2$} + \arrQueryLabeledVertexZ[45](2,4){x3}{$q_3$} + % + \draw [decoration={calligraphic brace, + raise=2pt, + amplitude=10pt,aspect=0.5},decorate,line width=0.2pt] (j)--(b) + node[midway,below=10pt,red]{$s_1$}; + \draw [decoration={calligraphic brace,raise=2pt, + amplitude=10pt,aspect=0.5},decorate,line width=0.2pt] (d)--(l) + node[midway,above=10pt,blue]{$s_3$}; + \end{tikzpicture} \end{document} diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/header.tex b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/header.tex index 26980faab6f..35b48e0c31b 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/header.tex +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/header.tex @@ -11,7 +11,7 @@ % ======== Math =============================================================== \usepackage{amsmath,amscd,amsthm} \usepackage{empheq} - +\usepackage{bm} % ======== pdf, url and hyperlink ============================================= % \usepackage{url} \usepackage{hyperref} @@ -42,24 +42,33 @@ % graphicx. \usepackage{tikz} \usepackage{pgfplots} +% \pgfplotsset{compat=1.16} +\pgfplotsset{compat=newest} +\usepgfplotslibrary{fillbetween} +\usepackage{tikz-3dplot} \usepackage{mathptmx} -\usetikzlibrary{calc} +\usetikzlibrary{arrows,arrows.meta} +\usetikzlibrary{automata} \usetikzlibrary{backgrounds} +\usetikzlibrary{calligraphy} +\usetikzlibrary{calc} +\usetikzlibrary{chains} +\usetikzlibrary{cd} \usetikzlibrary{decorations.pathmorphing} \usetikzlibrary{decorations.markings} \usetikzlibrary{decorations.pathreplacing} -\usetikzlibrary{patterns} -\usetikzlibrary{matrix} \usetikzlibrary{fit} -\usetikzlibrary{arrows,arrows.meta} -\usetikzlibrary{automata} +\usetikzlibrary{intersections} +\usetikzlibrary{math} +\usetikzlibrary{matrix} +\usetikzlibrary{patterns} \usetikzlibrary{positioning} \usetikzlibrary{shapes} -\usetikzlibrary{chains} +\usetikzlibrary{shapes.geometric} +\usetikzlibrary{shapes.misc} +\usetikzlibrary{shadows.blur} \usetikzlibrary{spy} -\usetikzlibrary{intersections} \usetikzlibrary{through} -\usetikzlibrary{cd} \usepackage{tikz-3dplot} %\usetikzlibrary{quotes,angles,graph} \tikzset{% @@ -72,6 +81,23 @@ point/.default=red, halfedge/.style={-{Stealth[left,scale=1.5]},commutative diagrams/shift left=#1}, halfedge/.default=3pt + edge/.style={line width=0.8pt,draw=#1}, + edge/.default=blue, + halfedge/.style={-{Stealth[left,scale=1.5]}, + commutative diagrams/shift left=#1}, + halfedge/.default=3pt, + cross/.style={#1,cross out,draw,very thick,rotate=0, + minimum size=2*(4pt-\pgflinewidth),inner sep=0pt,outer sep=0pt}, + cross/.default=red +} +\pgfplotsset{% + axisLimits/.style={enlarge x limits={abs value=\axisLimitsAbsValue,auto}, + enlarge y limits={abs value=\axisLimitsAbsValue,auto}}} +\newlength{\axisLimitsAbsValue}\setlength{\axisLimitsAbsValue}{0.08cm} +% ------------------------------------------------------------------------------ +\newcommand{\mySimpleAxes}[4]{% + \draw[-{Stealth[scale=1.5]}] (#1,0)--(#3,0) node[right]{$x$}; + \draw[-{Stealth[scale=1.5]}] (0,#2)--(0,#4) node[above]{$y$}; } % ------------------------------------------------------------------------------ % #1 half length of tick diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/simple_arr.tex b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/simple_arr.tex index 979dc5f5885..7fc10670ba3 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/simple_arr.tex +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/simple_arr.tex @@ -2,33 +2,38 @@ \input{header} \pagestyle{empty} \begin{document} -\psscalebox{1.8}{\arrset{1}% - \pspicture[](-3.1,-0.725)(3.1,1.709) - % - \pscustom[linecolor=blue,linewidth=0pt,fillstyle=hlines,hatchcolor=orange,hatchsep=2pt,hatchwidth=1pt]{% - \psplot{-2}{0}{0 x x mul x mul add x x mul add x 4 mul sub 1 add 8 div} - \psplot{0}{-2}{0 x x mul x mul sub x x mul add x 4 mul add 1 add 8 div} - } - % - \pscustom[linecolor=blue,linewidth=0pt,fillstyle=vlines,hatchcolor=orange,hatchsep=2pt,hatchwidth=1pt]{ - \psplot{0}{2}{0 x x mul x mul add x x mul add x 4 mul sub 1 add 8 div} - \psplot{2}{0}{0 x x mul x mul sub x x mul add x 4 mul add 1 add 8 div} - } - % - \psplot[linecolor=blue]{-2.5}{3}{0 x x mul x mul sub x x mul add x 4 mul add 1 add 8 div} - \psplot[linecolor=blue]{-3}{2.5}{0 x x mul x mul add x x mul add x 4 mul sub 1 add 8 div} - % - \arrMainVertex(-3,-0.625){1} - \arrMainVertex( 3,-0.625){2} - \arrMainVertex(-2.5,1.609){3} - \arrMainVertex( 2.5,1.609){4} - \arrEmptyVertex(-2,0.625){x1} - \arrEmptyVertex( 2,0.625){x2} - \arrEmptyVertex(0,0.125){x3} - \rput(-2.5,1){\textcolor{blue}{$c_1$}} - \rput(-2.9,0.15){\textcolor{blue}{$c_2$}} - \rput(-1,0.3){\boldmath{$f_1$}} - \rput(1,0.3){\boldmath{$f_2$}} - \endpspicture -} +\begin{tikzpicture}[scale=1.0,smooth] + \begin{axis}[ticks=none,axis line style={draw=none},unit vector ratio*=1 1 1, + enlarge x limits={abs value=0.08,auto}, + enlarge y limits={abs value=0.08,auto}, + % The following miraculously solves the wierd shift in the intersection + % computation + anchor=left of west + ] + % x^3+x^2-4x-8y=-1 + % -x^3+x^2+4x-8y=-1 + \addplot [draw=none,name path=f11,domain=-2:0]{(1-x^3+x^2+4*x)*0.125}; + \addplot [draw=none,name path=f12,domain=0:-2]{(1+x^3+x^2-4*x)*0.125}; + \addplot [draw=none,name path=f21,domain=0:2]{(1-x^3+x^2+4*x)/8.0}; + \addplot [draw=none,name path=f22,domain=2:0]{(1+x^3+x^2-4*x)/8.0}; + % + \addplot [name path global=A,color=blue,thick,domain=-2.5:3] + {(1-x^3+x^2+4*x)*0.125} coordinate[point,pos=0] coordinate[point]; + \addplot [name path global=B,color=blue,thick,domain=-3:2.5] + {(1+x^3+x^2-4*x)*0.125} coordinate[point,pos=0] coordinate[point]; + \coordinate [name intersections={of=A and B,name=x}]; + % + \node[point=white] at (x-1) {}; + \node[point=white] at (x-2) {}; + \node[point=white] at (x-3) {}; + % + \addplot[pattern={north east lines},pattern color=orange] fill between[of=f11 and f12]; + \addplot[pattern={north west lines},pattern color=orange] fill between[of=f21 and f22]; + % + \node at (-2.5,1){\textcolor{blue}{$c_1$}}; + \node at (-2.9,0.15){\textcolor{blue}{$c_2$}}; + \node at (-1,0.3){$\bm{f_1}$}; + \node at (1,0.3){$\bm{f_2}$}; + \end{axis} +\end{tikzpicture} \end{document} diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/unb_asymptote.tex b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/unb_asymptote.tex index c95d7de8d7c..6ff476a4a48 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/unb_asymptote.tex +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/unb_asymptote.tex @@ -2,7 +2,7 @@ \input{header} \pagestyle{empty} \begin{document} -\psscalebox{1.8}{\arrset{0.9}% +\psscalebox{1.0}{\arrset{0.75}% \begin{pspicture}(-3.5,-3.5)(2.1,2.1) \newpsstyle{SimpleHandle}{fillstyle=solid,fillcolor=white,framearc=0.5} \psframe[linewidth=0.25pt](-2,-2)(2,2) diff --git a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/unb_dcel.tex b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/unb_dcel.tex index e9cbee96d5a..81b9e033e49 100644 --- a/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/unb_dcel.tex +++ b/Arrangement_on_surface_2/doc/Arrangement_on_surface_2/fig_src/unb_dcel.tex @@ -2,143 +2,134 @@ \input{header} \pagestyle{empty} \begin{document} -\psscalebox{1.8}{\arrset{1}% - \begin{pspicture}(0,0)(10,7) - \psframe*[linecolor=lightyellow](0,0)(1,7) - \psframe*[linecolor=lightyellow](9,0)(10,7) - \psframe*[linecolor=lightyellow](1,0)(9,1) - \psframe*[linecolor=lightyellow](1,6)(9,7) - \psframe[linewidth=0.25pt](0,0)(10,7) + \begin{tikzpicture}[scale=0.93] + \fill[lightyellow](0,0)rectangle(1,7); + \fill[lightyellow](9,0)rectangle(10,7); + \fill[lightyellow](1,0)rectangle(9,1); + \fill[lightyellow](1,6)rectangle(9,7); + \draw[line width=0.25pt](0,0)rectangle(10,7); % - \arrlvertex[225](1,1){bl}{$v_{\mathrm{bl}}$} - \arrlvertex[135](1,6){tl}{$v_{\mathrm{tl}}$} - \arrlvertex[315](9,1){br}{$v_{\mathrm{br}}$} - \arrlvertex[45](9,6){tr}{$v_{\mathrm{tr}}$} - \arrv[180](1,2.5){1} - \arrv[180](1,4){2} - \arrv[180](1,5){3} - \arrv[270](5,1){4} - \arrv[90](5,6){5} - \arrv[0](9,1.5){6} - \arrv[0](9,4){7} - \arrv[0](9,5.5){8} + \arrMainLabeledVertexZ[225](1,1){bl}{$v_{\mathrm{bl}}$} + \arrMainLabeledVertexZ[135](1,6){tl}{$v_{\mathrm{tl}}$} + \arrMainLabeledVertexZ[315](9,1){br}{$v_{\mathrm{br}}$} + \arrMainLabeledVertexZ[45](9,6){tr}{$v_{\mathrm{tr}}$} + \arrvZ[180](1,2.5){1} + \arrvZ[180](1,4){2} + \arrvZ[180](1,5){3} + \arrvZ[270](5,1){4} + \arrvZ[90](5,6){5} + \arrvZ[0](9,1.5){6} + \arrvZ[0](9,4){7} + \arrvZ[0](9,5.5){8} % - \arrEmptyIntersectionVertex(1,4)(9,4)(5,1)(5,6){9} - \arrEmptyIntersectionVertex(1,4)(9,4)(1,5)(9,1.5){10} - \arrEmptyIntersectionVertex(1,5)(9,1.5)(5,1)(5,6){11} - \arrEmptyIntersectionVertex(1,5)(9,1.5)(1,2.5)(9,5.5){12} + \node[point=white] (9) at (intersection of 2--7 and 4--5) {}; + \node[point=white] (10) at (intersection of 2--7 and 3--6) {}; + \node[point=white] (11) at (intersection of 3--6 and 4--5) {}; + \node[point=white] (12) at (intersection of 3--6 and 1--8) {}; % - \ncline[linestyle=dashed,linewidth=0.5pt]{bl}{1} - \ncline[linewidth=0.5pt,offset=3pt]{->}{bl}{1} - \ncline[linewidth=0.5pt,offset=3pt,nodesepB=1pt]{->}{1}{bl} + \draw[dashed,line width=0.5pt](bl)--(1); + \draw[halfedge](bl)to(1); + \draw[halfedge](1)to(bl); % - \ncline[linestyle=dashed,linewidth=0.5pt]{1}{2} - \ncline[linewidth=0.5pt,offset=3pt]{->}{1}{2} - \ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=2pt]{->}{2}{1} + \draw[dashed,line width=0.5pt](1)--(2); + \draw[halfedge](1)to(2); + \draw[halfedge,shorten >=1pt](2)to(1); % - \ncline[linestyle=dashed,linewidth=0.5pt]{2}{3} - \ncline[linewidth=0.5pt,offset=3pt]{->}{2}{3} - \ncline[linewidth=0.5pt,offset=3pt,nodesepA=3pt,nodesepB=1pt]{->}{3}{2} + \draw[dashed,line width=0.5pt](2)--(3); + \draw[halfedge](2)to(3); + \draw[halfedge,shorten <=2pt](3)to(2); % - \ncline[linestyle=dashed,linewidth=0.5pt]{3}{tl} - \ncline[linewidth=0.5pt,offset=3pt]{->}{3}{tl} - \ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt]{->}{tl}{3} + \draw[dashed,line width=0.5pt](3)--(tl); + \draw[halfedge](3)to(tl); + \draw[halfedge](tl)to(3); % - \ncline[linestyle=dashed,linewidth=0.5pt]{tl}{5} - \ncline[linewidth=0.5pt,offset=3pt]{->}{tl}{5} - \ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{5}{tl} + \draw[dashed,line width=0.5pt](tl)--(5); + \draw[halfedge](tl)to(5); + \draw[halfedge](5)to(tl); % - \ncline[linestyle=dashed,linewidth=0.5pt]{5}{tr} - \ncline[linewidth=0.5pt,offset=3pt]{->}{5}{tr} - \ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{tr}{5} + \draw[dashed,line width=0.5pt](5)--(tr); + \draw[halfedge](5)to(tr); + \draw[halfedge](tr)to(5); % - \ncline[linestyle=dashed,linewidth=0.5pt]{tr}{8} - \ncline[linewidth=0.5pt,offset=3pt]{->}{tr}{8} - \ncline[linewidth=0.5pt,offset=3pt,nodesepB=1pt]{->}{8}{tr} + \draw[dashed,line width=0.5pt](tr)--(8); + \draw[halfedge](tr)to(8); + \draw[halfedge](8)to(tr); % - \ncline[linestyle=dashed,linewidth=0.5pt]{8}{7} - \ncline[linewidth=0.5pt,offset=3pt]{->}{8}{7} - \ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=2pt]{->}{7}{8} + \draw[dashed,line width=0.5pt](8)--(7); + \draw[halfedge](8)to(7); + \draw[halfedge,shorten >=1pt](7)to(8); % - \ncline[linestyle=dashed,linewidth=0.5pt]{7}{6} - \ncline[linewidth=0.5pt,offset=3pt]{->}{7}{6} - \ncline[linewidth=0.5pt,offset=3pt,nodesepA=3pt,nodesepB=1pt]{->}{6}{7} + \draw[dashed,line width=0.5pt](7)--(6); + \draw[halfedge](7)to(6); + \draw[halfedge,shorten <=1.8pt](6)to(7); % - \ncline[linestyle=dashed,linewidth=0.5pt]{6}{br} - \ncline[linewidth=0.5pt,offset=3pt]{->}{6}{br} - \ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt]{->}{br}{6} + \draw[dashed,line width=0.5pt](6)--(br); + \draw[halfedge](6)to(br); + \draw[halfedge](br)to(6); % - \ncline[linestyle=dashed,linewidth=0.5pt]{br}{4} - \ncline[linewidth=0.5pt,offset=3pt]{->}{br}{4} - \ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{4}{br} + \draw[dashed,line width=0.5pt](br)--(4); + \draw[halfedge](br)to(4); + \draw[halfedge](4)to(br); % - \ncline[linestyle=dashed,linewidth=0.5pt]{4}{bl} - \ncline[linewidth=0.5pt,offset=3pt]{->}{4}{bl} - \ncline[linewidth=0.5pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{bl}{4} + \draw[dashed,line width=0.5pt](4)--(bl); + \draw[halfedge](4)to(bl); + \draw[halfedge](bl)to(4); % - %\arredge{3}{10} - \ncline[linewidth=0.5pt,linecolor=blue]{3}{10} - \ncline[linewidth=0.25pt,offset=3pt]{->}{3}{10} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=12pt,nodesepB=2pt]{->}{10}{3} - %\arredge{10}{12} - \ncline[linewidth=0.5pt,linecolor=blue]{10}{12} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=6pt]{->}{12}{10} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=16pt,nodesepB=-2pt]{->}{10}{12} - %\arredge{12}{11} - \ncline[linewidth=0.5pt,linecolor=blue]{12}{11} - \ncline[linewidth=0.25pt,offset=3pt]{->}{11}{12} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=6pt,nodesepB=2pt]{->}{12}{11} - %\arredge{11}{6} - \ncline[linewidth=0.5pt,linecolor=blue]{11}{6} - \ncline[linewidth=0.25pt,offset=3pt,nodesepB=2pt]{->}{11}{6} - \ncline[linewidth=0.25pt,offset=3pt,nodesepB=2pt]{->}{6}{11} + \draw[edge](3)--(10); + \draw[halfedge](3)to(10); + \draw[halfedge,shorten <=11pt,shorten >=1.6pt](10)to(3); + \draw[edge](10)--(12); + \draw[halfedge,shorten <=4pt](12)to(10); + \draw[halfedge,shorten <=10pt,shorten >=-1.8pt](10)to(12); + \draw[edge](12)--(11); + \draw[halfedge](11)to(12); + \draw[halfedge,shorten <=4.2pt,shorten >=1.2pt](12)to(11); + \draw[edge](11)--(6); + \draw[halfedge,shorten >=1.6pt](11)to(6); + \draw[halfedge,shorten >=1.6pt](6)to(11); - %\arredge{1}{12} - \ncline[linewidth=0.5pt,linecolor=blue]{1}{12} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=2pt,nodesepB=5pt]{->}{1}{12} - \ncline[linewidth=0.25pt,offset=3pt]{->}{12}{1} - %\arredge{12}{9} - \ncline[linewidth=0.5pt,linecolor=blue]{12}{9} - \ncline[linewidth=0.25pt,,offset=3pt,nodesepB=12pt]{->}{12}{9} - \ncline[linewidth=0.25pt,,offset=3pt,nodesepA=2pt,nodesepB=5pt]{->}{9}{12} - %\arredge{9}{8} - \ncline[linewidth=0.5pt,linecolor=blue]{9}{8} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=2pt]{->}{9}{8} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=2pt,nodesepB=12pt]{->}{8}{9} + \draw[edge](1)--(12); + \draw[halfedge,shorten <=1.4pt,shorten >=4pt](1)to(12); + \draw[halfedge](12)to(1); + \draw[edge](12)--(9); + \draw[halfedge,shorten >=11.6pt](12)to(9); + \draw[halfedge,shorten <=2pt,shorten >=3.6pt](9)to(12); + \draw[edge](9)--(8); + \draw[halfedge,shorten <=1.4pt](9)to(8); + \draw[halfedge,shorten <=1.8pt,shorten >=11.8pt](8)to(9); - \ncline[linewidth=0.5pt,linecolor=blue]{2}{10} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=1pt,nodesepB=10pt]{->}{2}{10} - \ncline[linewidth=0.25pt,offset=3pt,nodesepB=1pt]{->}{10}{2} + \draw[edge](2)--(10); + \draw[halfedge,shorten >=10pt](2)to(10); + \draw[halfedge](10)to(2); - \ncline[linewidth=0.5pt,linecolor=blue]{10}{9} - \ncline[linewidth=0.25pt,offset=3pt,nodesepB=1pt]{->}{10}{9} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=16pt,nodesepB=10pt]{->}{9}{10} + \draw[edge](10)--(9); + \draw[halfedge](10)to(9); + \draw[halfedge,shorten <=13pt,shorten >=9.4pt](9)to(10); - \ncline[linewidth=0.5pt,linecolor=blue]{9}{7} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=16pt,nodesepB=1pt]{->}{9}{7} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{7}{9} + \draw[edge](9)--(7); + \draw[halfedge,shorten <=13pt](9)to(7); + \draw[halfedge](7)to(9); - \ncline[linewidth=0.5pt,linecolor=blue]{4}{11} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=1pt]{->}{4}{11} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=2pt,nodesepB=1pt]{->}{11}{4} + \draw[edge](4)--(11); + \draw[halfedge](4)to(11); + \draw[halfedge,shorten <=2pt](11)to(4); - \ncline[linewidth=0.5pt,linecolor=blue]{11}{9} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=1pt]{->}{9}{11} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=2pt,nodesepB=2pt]{->}{11}{9} + \draw[edge](11)--(9); + \draw[halfedge](9)to(11); + \draw[halfedge,shorten <=2pt,shorten >=1pt](11)to(9); - \ncline[linewidth=0.5pt,linecolor=blue]{9}{5} - \ncline[linewidth=0.25pt,offset=3pt,nodesepA=1pt,nodesepB=1pt]{->}{9}{5} - \ncline[linewidth=0.25pt,offset=3pt,,nodesepA=1pt,nodesepB=2pt]{->}{5}{9} + \draw[edge](9)--(5); + \draw[halfedge](9)to(5); + \draw[halfedge,shorten >=1.2pt](5)to(9); % - \rput(2,6.5){$\tilde{f}$} - \rput(6.2,5.2){$f_1$} - \rput(8.5,4.4){$f_2$} - \rput(8.3,3.4){$f_3$} - \rput(6.2,2){$f_4$} - \rput(3.8,2){$f_5$} - \rput(1.7,3.4){$f_6$} - \rput(1.5,4.4){$f_7$} - \rput(3.8,5.2){$f_8$} - \end{pspicture} -} + \node at(2,6.5){$\tilde{f}$}; + \node at(6.2,5.2){$f_1$}; + \node at(8.5,4.4){$f_2$}; + \node at(8.3,3.4){$f_3$}; + \node at(6.2,2){$f_4$}; + \node at(3.8,2){$f_5$}; + \node at(1.7,3.4){$f_6$}; + \node at(1.5,4.4){$f_7$}; + \node at (3.8,5.2){$f_8$}; + \end{tikzpicture} \end{document} diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/face_extension.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/face_extension.cpp index 8befee7dafc..d1bdaa8bb38 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/face_extension.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/face_extension.cpp @@ -18,9 +18,10 @@ private: public: Face_index_observer(Ex_arrangement& arr) : - CGAL::Arr_observer(arr), n_faces(0) + CGAL::Arr_observer(arr), + n_faces(0) { - CGAL_precondition (arr.is_empty()); + CGAL_precondition(arr.is_empty()); arr.unbounded_face()->set_data (0); } diff --git a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/sgm_point_location.cpp b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/sgm_point_location.cpp index 1b27e3bdda0..2fb6649b535 100644 --- a/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/sgm_point_location.cpp +++ b/Arrangement_on_surface_2/examples/Arrangement_on_surface_2/sgm_point_location.cpp @@ -55,22 +55,6 @@ int main() { // Landmarks_pl landmarks_pl(gm); Walk_pl walk_pl(gm); // Trap_pl trap_pl(gm); - /* Need to add the code below to both Arr_spherical_gaussian_map_3 and - * Arr_polyhedral_sgm, and then work on the trap point location code... - -private: - friend class Arr_observer; - friend class Arr_accessor; - -protected: - typedef Arr_observer Observer; - - void _register_observer(Observer *p_obs) - { Base::_register_observer((typename Base::Observer*)p_obs); } - - bool _unregister_observer(Observer *p_obs) - { return (Base::_unregister_observer ((typename Base::Observer*)p_obs)); } - */ Gm_traits traits; Gm_initializer gm_initializer(gm); diff --git a/Arrangement_on_surface_2/include/CGAL/Aos_observer.h b/Arrangement_on_surface_2/include/CGAL/Aos_observer.h new file mode 100644 index 00000000000..6f918138c66 --- /dev/null +++ b/Arrangement_on_surface_2/include/CGAL/Aos_observer.h @@ -0,0 +1,571 @@ +// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s): Ron Wein +// Efi Fogel + +#ifndef CGAL_AOS_OBSERVER_H +#define CGAL_AOS_OBSERVER_H + +#include + +#include + +#include + +/*! \file + * Definition of the `Aos_observer` base class. + */ + +namespace CGAL { + +/*! \class + * A base class for arrangement observers. + * The Arrangement parameter corresponds to an arrangement instantiation. + */ +template +class Aos_observer { +public: + typedef Arrangement_ Arrangement_2; + typedef Aos_observer Self; + + typedef typename Arrangement_2::Point_2 Point_2; + typedef typename Arrangement_2::X_monotone_curve_2 X_monotone_curve_2; + + typedef typename Arrangement_2::Vertex_handle Vertex_handle; + typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; + typedef typename Arrangement_2::Face_handle Face_handle; + typedef typename Arrangement_2::Ccb_halfedge_circulator + Ccb_halfedge_circulator; + +private: + Arrangement_2* p_arr; // The associated arrangement. + + /*! Copy constructor - not supported. */ + Aos_observer(const Self&); + + /*! Assignment operator - not supported. */ + Self& operator=(const Self&); + +public: + /// \name Construction and destruction functions. + //@{ + + /*! Default constructor. */ + Aos_observer() : p_arr(nullptr) {} + + /*! Constructor with an associated arrangement. */ + Aos_observer(Arrangement_2& arr) : p_arr(&arr) + { + // Register the observer object in the arrangement. + p_arr->_register_observer(this); + } + + /*! Destructor. */ + virtual ~Aos_observer() + { + // Unregister the observer object from the arrangement. + if (p_arr != nullptr) + p_arr->_unregister_observer(this); + } + //@} + + /// \name Modifying the associated arrangement. + //@{ + + /*! Get the associated arrangement (const version). */ + const Arrangement_2* arrangement() const { return (p_arr); } + + /*! Get the associated arrangement (non-const version). */ + Arrangement_2* arrangement() { return (p_arr); } + + /*! Attach the observer to an arrangement. + * \pre The observer is not already attached to an arrangement. + */ + void attach(Arrangement_2& arr) + { + // Do nothing if the associated arrangement is not changed. + if (p_arr == &arr) return; + + // The observer is not already attached to an arrangement. + CGAL_precondition (p_arr == nullptr); + + if (p_arr != nullptr) return; + + // Notify the concrete observer (the sub-class) about the attachment. + before_attach(arr); + + // Register the observer object in the new arrangement. + p_arr = &arr; + p_arr->_register_observer(this); + + // Notify the concrete observer that the attachment took place. + after_attach(); + } + + /*! Detach the observer from the arrangement. */ + void detach() + { + if (p_arr == nullptr) return; + + // Notify the concrete observer (the sub-class) about the detachment. + before_detach (); + + // Unregister the observer object from the current arrangement, and mark + // that the observer is not attached to an arrangement. + p_arr->_unregister_observer(this); + p_arr = nullptr; + + // Notify the concrete observer that the detachment took place. + after_detach(); + } + //@} + + /// \name Notification functions on global arrangement operations. + //@{ + + /*! Notification before the arrangement is assigned with another + * arrangement. + * \param arr The arrangement to be copied. + */ + virtual void before_assign(const Arrangement_2& /* arr */) {} + + /*! Notification after the arrangement has been assigned with another + * arrangement. + */ + virtual void after_assign() {} + + /*! Notification before the arrangement is cleared. */ + virtual void before_clear() {} + + /*! Notification after the arrangement is cleared. */ + virtual void after_clear() {} + + /*! Notification before a global operation modifies the arrangement. */ + virtual void before_global_change() {} + + /*! Notification after a global operation is completed. */ + virtual void after_global_change() {} + //@} + + /// \name Notification functions on observer attachment or detachment. + //@{ + + /*! Notification before the observer is attached to an arrangement. + * \param arr The arrangement that is about to attach the observer. + */ + virtual void before_attach(const Arrangement_2& /* arr */) {} + + /*! Notification after the observer has been attached to an arrangement. */ + virtual void after_attach() {} + + /*! Notification before the observer is detached from the arrangement. */ + virtual void before_detach() {} + + /*! Notification after the observer has been detached from the arrangement. */ + virtual void after_detach() {} + //@} + + /// \name Notification functions on local changes in the arrangement. + //@{ + + /*! Notification before the creation of a new vertex. + * \param p The point to be associated with the vertex. + * This point cannot lie on the surface boundaries. + */ + virtual void before_create_vertex(const Point_2& /* p */) {} + + /*! Notification after the creation of a new vertex. + * \param v A handle to the created vertex. + */ + virtual void after_create_vertex(Vertex_handle /* v */) + {} + + /*! Notification before the creation of a new boundary vertex. + * \param p The point on the surface boundary. + * \param ps_x The boundary condition of the vertex in x. + * \param ps_y The boundary condition of the vertex in y. + */ + virtual void before_create_boundary_vertex(const Point_2& /* p */, + Arr_parameter_space /* ps_x */, + Arr_parameter_space /* ps_y */) + {} + + /*! Notification before the creation of a new boundary vertex. + * \param cv The curve incident to the surface boundary. + * \param ind The relevant curve-end. + * \param ps_x The boundary condition of the vertex in x. + * \param ps_y The boundary condition of the vertex in y. + */ + virtual void before_create_boundary_vertex(const X_monotone_curve_2& /* cv */, + Arr_curve_end /* ind */, + Arr_parameter_space /* ps_x */, + Arr_parameter_space /* ps_y */) + {} + + /*! Notification after the creation of a new vertex at infinity. + * \param v A handle to the created vertex. + */ + virtual void after_create_boundary_vertex(Vertex_handle /* v */) {} + + /*! Notification before the creation of a new edge. + * \param c The \f$x\f$-monotone curve to be associated with the edge. + * \param v1 A handle to the first end-vertex of the edge. + * \param v2 A handle to the second end-vertex of the edge. + */ + virtual void before_create_edge(const X_monotone_curve_2& /* c */, + Vertex_handle /* v1 */, + Vertex_handle /* v2 */) + {} + + /*! Notification after the creation of a new edge. + * \param e A handle to one of the twin halfedges that were created. + */ + virtual void after_create_edge(Halfedge_handle /* e */) {} + + /*! Notification before the modification of an existing vertex. + * \param v A handle to the vertex to be updated. + * \param p The point to be associated with the vertex. + */ + virtual void before_modify_vertex(Vertex_handle /* v */, + const Point_2& /* p */) + {} + + /*! Notification after a vertex was modified. + * \param v A handle to the updated vertex. + */ + virtual void after_modify_vertex(Vertex_handle /* v */) {} + + /*! Notification before the modification of an existing edge. + * \param e A handle to one of the twin halfedges to be updated. + * \param c The \f$x\f$-monotone curve to be associated with the edge. + */ + virtual void before_modify_edge(Halfedge_handle /* e */, + const X_monotone_curve_2& /* c */) + {} + + /*! Notification after an edge was modified. + * \param e A handle to one of the twin halfedges that were updated. + */ + virtual void after_modify_edge(Halfedge_handle /* e */) {} + + /*! Notification before the splitting of an edge into two. + * \param e A handle to one of the existing halfedges. + * \param v A vertex representing the split point. + * \param c1 The \f$x\f$-monotone curve to be associated with the first edge. + * \param c2 The \f$x\f$-monotone curve to be associated with the second edge. + */ + virtual void before_split_edge(Halfedge_handle /* e */, + Vertex_handle /* v */, + const X_monotone_curve_2& /* c1 */, + const X_monotone_curve_2& /* c2 */) + {} + + /*! Notification after an edge was split. + * \param e1 A handle to one of the twin halfedges forming the first edge. + * \param e2 A handle to one of the twin halfedges forming the second edge. + */ + virtual void after_split_edge(Halfedge_handle /* e1 */, + Halfedge_handle /* e2 */) + {} + + /*! Notification before the splitting of a fictitious edge into two. + * \param e A handle to one of the existing halfedges. + * \param v A vertex representing the unbounded split point. + */ + virtual void before_split_fictitious_edge(Halfedge_handle /* e */, + Vertex_handle /* v */) + {} + + /*! Notification after a fictitious edge was split. + * \param e1 A handle to one of the twin halfedges forming the first edge. + * \param e2 A handle to one of the twin halfedges forming the second edge. + */ + virtual void after_split_fictitious_edge(Halfedge_handle /* e1 */, + Halfedge_handle /* e2 */) + {} + + /*! Notification before the splitting of a face into two. + * \param f A handle to the existing face. + * \param e The new edge whose insertion causes the face to split. + */ + virtual void before_split_face(Face_handle /* f */, + Halfedge_handle /* e */) + {} + + /*! Notification after a face was split. + * \param f A handle to the face we have just split. + * \param new_f A handle to the new face that has been created. + * \param is_hole Whether the new face forms a hole inside f. + */ + virtual void after_split_face(Face_handle /* f */, + Face_handle /* new_f */, + bool /* is_hole */) + {} + + /*! Notification before the splitting of an outer CCB into two. + * \param f A handle to the face that owns the outer CCB. + * \param h A circulator representing the component boundary. + * \param e The new edge whose removal causes the outer CCB to split. + */ + virtual void before_split_outer_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */, + Halfedge_handle /* e */) + {} + + /*! Notification after an outer CCB was split. + * \param f A handle to the face that owns the outer CCBs. + * \param h1 A circulator representing the boundary of the first component. + * \param h2 A circulator representing the boundary of the second component. + */ + virtual void after_split_outer_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h1 */, + Ccb_halfedge_circulator /* h2 */) + {} + + /*! Notification before the splitting of an inner CCB into two. + * \param f A handle to the face containing the inner CCB. + * \param h A circulator representing the component boundary. + * \param e The new edge whose removal causes the inner CCB to split. + */ + virtual void before_split_inner_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */, + Halfedge_handle /* e */) + {} + + /*! Notification after an inner CCB was split. + * \param f A handle to the face containing the inner CCBs. + * \param h1 A circulator representing the boundary of the first component. + * \param h2 A circulator representing the boundary of the second component. + */ + virtual void after_split_inner_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h1 */, + Ccb_halfedge_circulator /* h2 */) + {} + + /*! Notification before the creation of a new outer CCB of a face. + * \param f A handle to the face that owns the outer CCB. + * \param e A halfedge along the new outer CCB. + */ + virtual void before_add_outer_ccb(Face_handle /* f */, + Halfedge_handle /* e */) + {} + + /*! Notification after an outer CCB was added to a face. + * \param h A circulator representing the boundary of the new outer CCB. + */ + virtual void after_add_outer_ccb(Ccb_halfedge_circulator /* h */) {} + + /*! Notification before the creation of a new inner CCB inside a face. + * \param f A handle to the face containing the inner CCB. + * \param e The new halfedge that forms the new inner CCB. + */ + virtual void before_add_inner_ccb(Face_handle /* f */, + Halfedge_handle /* e */) + {} + + /*! Notification after an inner CCB was created inside a face. + * \param h A circulator representing the boundary of the new inner CCB. + */ + virtual void after_add_inner_ccb(Ccb_halfedge_circulator /* h */) {} + + /*! Notification before the creation of a new isolated vertex inside a face. + * \param f A handle to the face containing the isolated vertex. + * \param v The isolated vertex. + */ + virtual void before_add_isolated_vertex(Face_handle /* f */, + Vertex_handle /* v */) + {} + + /*! Notification after an isolated vertex was created inside a face. + * \param v The isolated vertex. + */ + virtual void after_add_isolated_vertex(Vertex_handle /* v */) {} + + /*! Notification before the merging of two edges. + * \param e1 A handle to one of the halfedges forming the first edge. + * \param e2 A handle to one of the halfedges forming the second edge. + * \param c The \f$x\f$-monotone curve to be associated with the merged edge. + */ + virtual void before_merge_edge(Halfedge_handle /* e1 */, + Halfedge_handle /* e2 */, + const X_monotone_curve_2& /* c */) + {} + + /*! Notification after an edge was merged. + * \param e A handle to one of the twin halfedges forming the merged edge. + */ + virtual void after_merge_edge(Halfedge_handle /* e */) {} + + /*! Notification before the merging of two fictitious edges. + * \param e1 A handle to one of the halfedges forming the first edge. + * \param e2 A handle to one of the halfedges forming the second edge. + */ + virtual void before_merge_fictitious_edge(Halfedge_handle /* e1 */, + Halfedge_handle /* e2 */) + {} + + /*! Notification after a fictitious edge was merged. + * \param e A handle to one of the twin halfedges forming the merged edge. + */ + virtual void after_merge_fictitious_edge(Halfedge_handle /* e */) {} + + /*! Notification before the merging of two faces. + * \param f1 A handle to the first face. + * \param f2 A handle to the second face. + * \param e The edge whose removal causes the faces to merge. + */ + virtual void before_merge_face(Face_handle /* f1 */, + Face_handle /* f2 */, + Halfedge_handle /* e */) + {} + + /*! Notification after a face was merged. + * \param f A handle to the merged face. + */ + virtual void after_merge_face(Face_handle /* f */) {} + + /*! Notification before the merging of two outer CCBs. + * \param f A handle to the face that owns the outer CCBs. + * \param h1 A circulator representing the boundary of the first component. + * \param h2 A circulator representing the boundary of the second component. + * \param e The edge whose insertion or removal causes the CCBs to merge. + */ + virtual void before_merge_outer_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h1 */, + Ccb_halfedge_circulator /* h2 */, + Halfedge_handle /* e */) + {} + + /*! Notification after an outer CCB was merged. + * \param f A handle to the face that owns the outer CCBs. + * \param h A circulator representing the boundary of the merged component. + */ + virtual void after_merge_outer_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */) + {} + + /*! Notification before the merging of two inner CCBs (holes). + * \param f A handle to the face that contains the inner CCBs. + * \param h1 A circulator representing the boundary of the first component. + * \param h2 A circulator representing the boundary of the second component. + * \param e The edge whose insertion causes the inner CCBs to merge. + */ + virtual void before_merge_inner_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h1 */, + Ccb_halfedge_circulator /* h2 */, + Halfedge_handle /* e */) + {} + + /*! Notification after an inner CCB was merged. + * \param f A handle to the face that contains the inner CCBs. + * \param h A circulator representing the boundary of the merged component. + */ + virtual void after_merge_inner_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */) + {} + + /*! Notification before an outer CCB is moved from one face to another. + * \param from_f A handle to the face that currently owns the outer CCB. + * \param to_f A handle to the face that should own the outer CCB. + * \param h A circulator representing the boundary of the component. + */ + virtual void before_move_outer_ccb(Face_handle /* from_f */, + Face_handle /* to_f */, + Ccb_halfedge_circulator /* h */) + {} + + /*! Notification after an outer CCB is moved from one face to another. + * \param h A circulator representing the boundary of the component. + */ + virtual void after_move_outer_ccb(Ccb_halfedge_circulator /* h */) {} + + + /*! Notification before an inner CCB is moved from one face to another. + * \param from_f A handle to the face currently containing the inner CCB. + * \param to_f A handle to the face that should contain the inner CCB. + * \param h A circulator representing the boundary of the component. + */ + virtual void before_move_inner_ccb(Face_handle /* from_f */, + Face_handle /* to_f */, + Ccb_halfedge_circulator /* h */) + {} + + /*! + * Notification after an inner CCB is moved from one face to another. + * \param h A circulator representing the boundary of the component. + */ + virtual void after_move_inner_ccb(Ccb_halfedge_circulator /* h */) {} + + /*! Notification before an isolated vertex is moved from one face to another. + * \param from_f A handle to the face currently containing the vertex. + * \param to_f A handle to the face that should contain the vertex. + * \param v The isolated vertex. + */ + virtual void before_move_isolated_vertex(Face_handle /* from_f */, + Face_handle /* to_f */, + Vertex_handle /* v */) + {} + + /*! Notification after an isolated vertex is moved from one face to another. + * \param v The isolated vertex. + */ + virtual void after_move_isolated_vertex(Vertex_handle /* v */) {} + + /*! Notificaion before the removal of a vertex. + * \param v A handle to the vertex to be deleted. + */ + virtual void before_remove_vertex(Vertex_handle /* v */) {} + + /*! Notificaion after the removal of a vertex. */ + virtual void after_remove_vertex() {} + + /*! Notification before the removal of an edge. + * \param e A handle to one of the twin halfedges to be deleted. + */ + virtual void before_remove_edge(Halfedge_handle /* e */) {} + + /*! Notificaion after the removal of an edge. */ + virtual void after_remove_edge() {} + + /*! Notification before the removal of an outer CCB. + * \param f The face that owns the outer CCB. + * \param h A circulator representing the boundary of the component. + */ + virtual void before_remove_outer_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */) + {} + + /*! Notificaion after the removal of an outer CCB. + * \param f The face that used to own the outer CCB. + */ + virtual void after_remove_outer_ccb(Face_handle /* f */) {} + + /*! Notification before the removal of an inner CCB. + * \param f The face containing the inner CCB. + * \param h A circulator representing the boundary of the component. + */ + virtual void before_remove_inner_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */) + {} + + /*! Notificaion after the removal of an inner CCB. + * \param f The face that used to contain the inner CCB. + */ + virtual void after_remove_inner_ccb(Face_handle /* f */) {} + + //@} +}; + +} //namespace CGAL + +#include + +#endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_algebraic_segment_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_algebraic_segment_traits_2.h index af9b28db6f2..03566eaa919 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_algebraic_segment_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_algebraic_segment_traits_2.h @@ -5,15 +5,18 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s): Michael Kerber // // ============================================================================ -#ifndef CGAL_ARR_ALGEBRAIC_SEGMENT_TRAITS -#define CGAL_ARR_ALGEBRAIC_SEGMENT_TRAITS +#ifndef CGAL_ARR_ALGEBRAIC_SEGMENT_TRAITS_H +#define CGAL_ARR_ALGEBRAIC_SEGMENT_TRAITS_H + +#include + #include @@ -655,4 +658,4 @@ public: #include -#endif // CGAL_ARR_ALGEBRAIC_SEGMENT_TRAITS +#endif // CGAL_ARR_ALGEBRAIC_SEGMENT_TRAITS_H diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_bounded_planar_topology_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_bounded_planar_topology_traits_2.h index 4d0d46c8de1..105d379297d 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_bounded_planar_topology_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_bounded_planar_topology_traits_2.h @@ -26,6 +26,7 @@ */ #include +#include #include #include #include diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_dcel.h b/Arrangement_on_surface_2/include/CGAL/Arr_dcel.h new file mode 100644 index 00000000000..531bb32b245 --- /dev/null +++ b/Arrangement_on_surface_2/include/CGAL/Arr_dcel.h @@ -0,0 +1,69 @@ +// Copyright (c) 2005,2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// +// Author(s): Ron Wein +// Baruch Zukerman +// Efi Fogel + +#ifndef CGAL_ARR_DCEL_H +#define CGAL_ARR_DCEL_H + +#include + +#include + +/*! \file + * The definition of the Arr_dcel class. + */ + +#include + +namespace CGAL { + +/*! \class + * The arrangement DCEL class. + * The Traits parameters corresponds to a geometric traits class, which + * defines the Point_2 and X_monotone_curve_2 types. + */ +template , + typename H = Arr_halfedge_base, + typename F = Arr_face_base> +class Arr_dcel : public Arr_dcel_base { +public: + /*! \struct + * An auxiliary structure for rebinding the DCEL with a new traits class. + */ + template + struct rebind { + private: + using Pnt = typename T::Point_2; + using Xcv = typename T::X_monotone_curve_2; + using Rebind_v = typename V::template rebind; + using V_other = typename Rebind_v::other; + using Rebind_h = typename H::template rebind; + using H_other = typename Rebind_h::other; + + public: + using other = Arr_dcel; + }; + + /*! Default constructor. */ + Arr_dcel() {} + + /*! Destructor. */ + virtual ~Arr_dcel() {} +}; + +} //namespace CGAL + +#include + +#endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h b/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h index af2ea182fa7..b0627f38eae 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_dcel_base.h @@ -8,8 +8,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Ron Wein -// (based on old version by: Iddo Hanniel and Oren Nechushtan) +// Author(s): Ron Wein +// Efi Fogel +// (based on old version by: Iddo Hanniel and Oren Nechushtan) #ifndef CGAL_ARR_DCEL_BASE_H #define CGAL_ARR_DCEL_BASE_H @@ -23,11 +24,12 @@ * peripheral records. */ -#include -#include #include #include -#include + +#include +#include +#include #include #include #include diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_default_dcel.h b/Arrangement_on_surface_2/include/CGAL/Arr_default_dcel.h index ca98dc7ec5f..feb23717d41 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_default_dcel.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_default_dcel.h @@ -1,4 +1,4 @@ -// Copyright (c) 2005,2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// Copyright (c) 2023 Tel-Aviv University (Israel). // All rights reserved. // // This file is part of CGAL (www.cgal.org). @@ -8,8 +8,7 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Ron Wein -// Baruch Zukerman +// Author(s): Efi Fogel #ifndef CGAL_ARR_DEFAULT_DCEL_H #define CGAL_ARR_DEFAULT_DCEL_H @@ -19,46 +18,19 @@ #include /*! \file - * The definition of the Arr_default_dcel class. + * The definition of the Arr_default_dcel type. */ -#include +#include namespace CGAL { -/*! \class - * The default arrangement DCEL class. +/*! The default arrangement DCEL type. * The Traits parameters corresponds to a geometric traits class, which * defines the Point_2 and X_monotone_curve_2 types. */ -template -class Arr_default_dcel : - public Arr_dcel_base, - Arr_halfedge_base, - Arr_face_base> -{ -public: - - /*! \struct - * An auxiliary structure for rebinding the DCEL with a new traits class. - */ - template - struct rebind - { - typedef Arr_default_dcel other; - }; - - /*! Default constructor. */ - Arr_default_dcel() - {} - - /*! Destructor. */ - virtual ~Arr_default_dcel() - {} -}; +template using Arr_default_dcel = Arr_dcel; } //namespace CGAL -#include - #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_default_overlay_traits.h b/Arrangement_on_surface_2/include/CGAL/Arr_default_overlay_traits.h index f70b4dcb1fb..56efabb2a44 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_default_overlay_traits.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_default_overlay_traits.h @@ -8,8 +8,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Ron Wein -// Baruch Zukerman +// Author(s): Ron Wein +// Baruch Zukerman +// Efi Fogel #ifndef CGAL_ARR_DEFAULT_OVERLAY_TRAITS_H #define CGAL_ARR_DEFAULT_OVERLAY_TRAITS_H @@ -23,7 +24,6 @@ * Definition of default overlay-traits classes. */ -#include #include #include diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_extended_dcel.h b/Arrangement_on_surface_2/include/CGAL/Arr_extended_dcel.h index dc863fe57e8..fd958718c69 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_extended_dcel.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_extended_dcel.h @@ -8,8 +8,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Ron Wein -// Efi Fogel +// Author(s): Ron Wein +// Efi Fogel #ifndef CGAL_ARR_EXTENDED_DCEL_H #define CGAL_ARR_EXTENDED_DCEL_H @@ -26,142 +26,115 @@ namespace CGAL { -/*! - * \class +/*! \class * An extended DCEL vertex with auxiliary data field. */ -template -class Arr_extended_vertex : public VertexBase_ -{ - typedef Arr_extended_vertex Self; - typedef VertexBase_ Base; +template +class Arr_extended_vertex : public VertexBase { + using Vertex_base = VertexBase; + using Vertex_data = VertexData; + + using Self = Arr_extended_vertex; public: - typedef VertexData_ Data; + typedef Vertex_data Data; private: - - Data m_data; // The auxiliary data field. + Data m_data; // The auxiliary data field. public: - /*! Get the auxiliary data (const version). */ - const Data& data () const - { - return (m_data); - } + const Data& data() const { return m_data; } /*! Get the auxiliary data (non-const version). */ - Data& data () - { - return (m_data); - } + Data& data() { return m_data; } /*! Set the auxiliary data. */ - void set_data (const Data& data) - { - m_data = data; - } + void set_data(const Data& data) { m_data = data; } /*! Assign from another vertex. */ - virtual void assign (const Base& v) - { - Base::assign (v); - - const Self& ex_v = static_cast(v); + virtual void assign(const Vertex_base& v) { + Vertex_base::assign(v); + const Self& ex_v = static_cast(v); m_data = ex_v.m_data; } + + template + struct rebind { + using Point_2 = Point_; + using other = typename Vertex_base::template rebind; + }; }; -/*! - * \class +/*! \class * An extended DCEL halfedge with auxiliary data field. */ -template -class Arr_extended_halfedge : public HalfedgeBase_ -{ - typedef Arr_extended_halfedge Self; - typedef HalfedgeBase_ Base; +template +class Arr_extended_halfedge : public HalfedgeBase { + using Halfedge_base = HalfedgeBase; + using Halfedge_data = HalfedgeData; + + using Self = Arr_extended_halfedge; public: - typedef HalfedgeData_ Data; + typedef Halfedge_data Data; private: - - Data m_data; // The auxiliary data field. + Data m_data; // The auxiliary data field. public: - /*! Get the auxiliary data (const version). */ - const Data& data () const - { - return (m_data); - } + const Data& data() const { return m_data; } /*! Get the auxiliary data (non-const version). */ - Data& data () - { - return (m_data); - } + Data& data() { return m_data; } /*! Set the auxiliary data. */ - void set_data (const Data& data) - { - m_data = data; - } + void set_data(const Data& data) { m_data = data; } - /*! Assign from another vertex. */ - virtual void assign (const Base& he) - { - Base::assign (he); - - const Self& ex_he = static_cast(he); + /*! Assign from another halfedge. */ + virtual void assign(const Halfedge_base& he) { + Halfedge_base::assign(he); + const Self& ex_he = static_cast(he); m_data = ex_he.m_data; } + + template + struct rebind { + using X_monotonote_curve_2 = XMonotoneCurve; + using other = typename Halfedge_base::template rebind; + }; }; -/*! - * \class +/*! \class * An extended DCEL face with auxiliary data field. */ -template -class Arr_extended_face : public FaceBase_ -{ - typedef Arr_extended_face Self; - typedef FaceBase_ Base; +template +class Arr_extended_face : public FaceBase { + using Face_base = FaceBase; + using Face_data = FaceData; + + using Self = Arr_extended_face; public: - typedef FaceData_ Data; + typedef Face_data Data; private: - - Data m_data; // The auxiliary data field. + Data m_data; // The auxiliary data field. public: - /*! Get the auxiliary data (const version). */ - const Data& data () const - { - return (m_data); - } + const Data& data() const { return m_data; } /*! Get the auxiliary data (non-const version). */ - Data& data () - { - return (m_data); - } + Data& data() { return m_data; } /*! Set the auxiliary data. */ - void set_data (const Data& data) - { - m_data = data; - } - - /*! Assign from another vertex. */ - virtual void assign (const Base& f) - { - Base::assign (f); + void set_data(const Data& data) { m_data = data; } + /*! Assign from another face. */ + virtual void assign(const Face_base& f) { + Face_base::assign(f); const Self& ex_f = static_cast(f); m_data = ex_f.m_data; } @@ -173,49 +146,41 @@ public: * defines the Point_2 and X_monotone_curve_2 types. * The FaceData parameter specifies the object type stored with each face. */ -template , - class HalfedgeBase_ = - Arr_halfedge_base, - class FaceBase_ = Arr_face_base> +template , + typename HalfedgeBase = + Arr_halfedge_base, + typename FaceBase = Arr_face_base> class Arr_face_extended_dcel : - public Arr_dcel_base > -{ + public Arr_dcel_base> { public: - - typedef FaceData_ Face_data; + using Face_base = FaceBase; + using Face_data = FaceData; /*! \struct * An auxiliary structure for rebinding the DCEL with a new traits class. */ - template - class rebind - { - typedef typename VertexBase_::template rebind - Rebind_vertex; - typedef typename Rebind_vertex::other Vertex_base; - typedef typename HalfedgeBase_::template rebind - Rebind_halfedge; - typedef typename Rebind_halfedge::other Halfedge_base; + template + class rebind { + private: + using Pnt = typename T::Point_2; + using Xcv = typename T::X_monotone_curve_2; + using Rebind_vertex = typename VertexBase::template rebind; + using Vertex_other = typename Rebind_vertex::other; + using Rebind_halfedge = typename HalfedgeBase::template rebind; + using Halfedge_other = typename Rebind_halfedge::other; public: - - typedef Arr_face_extended_dcel other; + using other = Arr_face_extended_dcel; }; /*! Default constructor. */ - Arr_face_extended_dcel () - {} + Arr_face_extended_dcel() {} /*! Destructor. */ - virtual ~Arr_face_extended_dcel () - {} + virtual ~Arr_face_extended_dcel() {} }; /*! \class @@ -225,54 +190,48 @@ public: * The VertexData, HalfedgeData and FaceData parameter specify the object types * stored with each vertex, halfedge and face, respectively. */ -template , - class HalfedgeBase_ = - Arr_halfedge_base, - class FaceBase_ = Arr_face_base> +template , + typename HalfedgeBase = + Arr_halfedge_base, + typename FaceBase = Arr_face_base> class Arr_extended_dcel : - public Arr_dcel_base, - Arr_extended_halfedge, - Arr_extended_face > -{ + public Arr_dcel_base, + Arr_extended_halfedge, + Arr_extended_face> { public: - - typedef VertexData_ Vertex_data; - typedef HalfedgeData_ Halfedge_data; - typedef FaceData_ Face_data; + using Vertex_data = VertexData; + using Halfedge_data = HalfedgeData; + using Face_data = FaceData; + using Vertex_base = VertexBase; + using Halfedge_base = HalfedgeBase; + using Face_base = FaceBase; /*! \struct * An auxiliary structure for rebinding the DCEL with a new traits class. */ - template - class rebind - { - typedef typename VertexBase_::template rebind - Rebind_vertex; - typedef typename Rebind_vertex::other Vertex_base; - typedef typename HalfedgeBase_::template rebind - Rebind_halfedge; - typedef typename Rebind_halfedge::other Halfedge_base; + template + struct rebind { + private: + using Pnt = typename T::Point_2; + using Xcv = typename T::X_monotone_curve_2; + using Rebind_vertex = typename VertexBase::template rebind; + using Vertex_other = typename Rebind_vertex::other; + using Rebind_halfedge = typename HalfedgeBase::template rebind; + using Halfedge_other = typename Rebind_halfedge::other; public: - - typedef Arr_extended_dcel other; + using other = Arr_extended_dcel; }; /*! Default constructor. */ - Arr_extended_dcel () - {} + Arr_extended_dcel() {} /*! Destructor. */ - virtual ~Arr_extended_dcel () - {} + virtual ~Arr_extended_dcel() {} }; } //namespace CGAL diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_face_index_map.h b/Arrangement_on_surface_2/include/CGAL/Arr_face_index_map.h index 1e03af5e1c6..ee804c574c5 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_face_index_map.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_face_index_map.h @@ -21,7 +21,6 @@ * Definition of the Arr_face_index_map class. */ -#include #include #include @@ -34,140 +33,110 @@ namespace CGAL { * arrangement faces to the indices 0, ..., (n -1), where n is the number * of faces in the arrangement. */ -template -class Arr_face_index_map : public Arr_observer -{ +template +class Arr_face_index_map : public Arrangement_::Observer { public: + using Arrangement_2 = Arrangement_; + using Base_aos = typename Arrangement_2::Base_aos; - typedef Arrangement_ Arrangement_2; - typedef typename Arrangement_2::Face_handle Face_handle; + using Halfedge_handle = typename Base_aos::Halfedge_handle; + using Face_handle = typename Base_aos::Face_handle; // Boost property type definitions: - typedef boost::readable_property_map_tag category; - typedef unsigned int value_type; - typedef value_type reference; - typedef Face_handle key_type; + using category = boost::readable_property_map_tag; + using value_type = unsigned int; + using reference = value_type; + using key_type = Face_handle; private: + using Self = Arr_face_index_map; + using Base = typename Arrangement_2::Observer; - typedef Arr_face_index_map Self; - typedef Arr_observer Base; - - typedef Unique_hash_map Index_map; + using Index_map = Unique_hash_map; // Data members: - unsigned int n_faces; // The current number of faces. - Index_map index_map; // Mapping faces to indices. - std::vector rev_map; // Mapping indices to faces. + unsigned int n_faces; // The current number of faces. + Index_map index_map; // Mapping faces to indices. + std::vector rev_map; // Mapping indices to faces. enum {MIN_REV_MAP_SIZE = 32}; public: - /*! Default constructor. */ - Arr_face_index_map () : - Base (), - n_faces (0), - rev_map (MIN_REV_MAP_SIZE) + Arr_face_index_map() : + Base(), + n_faces(0), + rev_map(MIN_REV_MAP_SIZE) {} /*! Constructor with an associated arrangement. */ - Arr_face_index_map (const Arrangement_2& arr) : - Base (const_cast (arr)) - { - _init(); - } + Arr_face_index_map(const Base_aos& arr) : + Base(const_cast(arr)) + { _init(); } /*! Copy constructor. */ - Arr_face_index_map (const Self& other) : - Base (const_cast (*(other.arrangement()))) - { - _init(); - } + Arr_face_index_map(const Self& other) : + Base(const_cast(*(other.arrangement()))) + { _init(); } /*! Assignment operator. */ - Self& operator= (const Self& other) - { - if (this == &other) - return (*this); + Self& operator= (const Self& other) { + if (this == &other) return (*this); this->detach(); - this->attach (const_cast (*(other.arrangement()))); + this->attach(const_cast(*(other.arrangement()))); return (*this); } - /*! - * Get the index of a given face. + /*! Get the index of a given face. * \param f A handle to the face. * \pre f is a valid face in the arrangement. */ - unsigned int operator[] (Face_handle f) const - { - return (index_map[f]); - } + unsigned int operator[](Face_handle f) const { return (index_map[f]); } - /*! - * Get the face given its index. + /*! Get the face given its index. * \param i The index of the face. * \pre i is less than the number of faces in the arrangement. */ - Face_handle face (const int i) const - { + Face_handle face(const int i) const { CGAL_precondition((unsigned int) i < n_faces); - return (rev_map[i]); } /// \name Notification functions, to keep the mapping up-to-date. //@{ - /*! - * Update the mapping after the arrangement has been assigned with another + /*! Update the mapping after the arrangement has been assigned with another * arrangement. */ - virtual void after_assign () - { - _init(); - } + virtual void after_assign() override { _init(); } - /*! - * Update the mapping after the arrangement is cleared. + /*! Update the mapping after the arrangement is cleared. */ - virtual void after_clear () - { - _init(); - } + virtual void after_clear() override { _init(); } - /*! - * Update the mapping after attaching to a new arrangement. + /*! Update the mapping after attaching to a new arrangement. */ - virtual void after_attach () - { - _init(); - } + virtual void after_attach() override { _init(); } - /*! - * Update the mapping after detaching the arrangement. + /*! Update the mapping after detaching the arrangement. */ - virtual void after_detach () - { + virtual void after_detach() override { n_faces = 0; index_map.clear(); } - /*! - * Update the mapping after the creation of a new face is split from another + /*! Update the mapping after the creation of a new face is split from another * face. * \param f A handle to the existing face. * \param new_f A handle to the newly created face. */ - virtual void after_split_face (Face_handle /* f */, - Face_handle new_f, - bool /* is_hole */) - { + virtual void after_split_face(Face_handle /* f */, + Face_handle new_f, + bool /* is_hole */) override { // Update the number of vertices. - n_faces++; + ++n_faces; // If necessary, allocate memory for the reverse mapping. if (rev_map.size() < n_faces) @@ -176,97 +145,77 @@ public: // Update the mapping of the newly created face. index_map[new_f] = n_faces - 1; rev_map[n_faces - 1] = new_f; - - return; } - /*! - * Update the mapping before the merge of two faces. + /*! Update the mapping before the merge of two faces. * \param f1 A handle to the face that is going to remain. * \param f2 A handle to the face that is about to be removed. */ - virtual void before_merge_face (Face_handle /* f1 */, - Face_handle f2, - typename - Arrangement_2::Halfedge_handle /* e */) - { + virtual void before_merge_face(Face_handle /* f1 */, + Face_handle f2, + Halfedge_handle /* e */) override { // Update the number of faces. - n_faces--; + --n_faces; // Reduce memory consumption in case the number of faces has // drastically decreased. if (2*n_faces+1 < rev_map.size() && rev_map.size() / 2 >= MIN_REV_MAP_SIZE) { - rev_map.resize (rev_map.size() / 2); + rev_map.resize(rev_map.size() / 2); } // Get the current face index, and assign this index to the face // currently indexed (n - 1). - unsigned int index = index_map[f2]; + unsigned int index = index_map[f2]; - if (index == n_faces) - return; + if (index == n_faces) return; - Face_handle last_f = rev_map[n_faces]; + Face_handle last_f = rev_map[n_faces]; index_map[last_f] = index; rev_map[index] = last_f; // Clear the reverse mapping for the last face. rev_map[n_faces] = Face_handle(); - - return; } //@} private: - /*! Initialize the map for the given arrangement. */ - void _init () - { + void _init() { // Get the number of faces and allocate the reverse map accordingly. n_faces = static_cast(this->arrangement()->number_of_faces()); - if (n_faces < MIN_REV_MAP_SIZE) - rev_map.resize (MIN_REV_MAP_SIZE); - else - rev_map.resize (n_faces); + if (n_faces < MIN_REV_MAP_SIZE) rev_map.resize (MIN_REV_MAP_SIZE); + else rev_map.resize (n_faces); // Clear the current mapping. index_map.clear(); // Create the initial mapping. - typename Arrangement_2::Face_iterator fit; - Face_handle fh; - unsigned int index = 0; + Face_handle fh; + unsigned int index = 0; - for (fit = this->arrangement()->faces_begin(); - fit != this->arrangement()->faces_end(); ++fit, ++index) - { + for (auto fit = this->arrangement()->faces_begin(); + fit != this->arrangement()->faces_end(); ++fit, ++index) { // Map the current face to the current index. fh = fit; index_map[fh] = index; rev_map[index] = fh; } - - return; } - }; -/*! - * Get the index property-map function. Provided so that boost is able to +/*! Get the index property-map function. Provided so that boost is able to * access the Arr_face_index_map above. * \param index_map The index map. * \param f A face handle. * \return The face index. */ -template -unsigned int get (const CGAL::Arr_face_index_map& index_map, - typename Arrangement::Face_handle f) -{ - return (index_map[f]); -} +template +unsigned int get(const CGAL::Arr_face_index_map& index_map, + typename Arrangement::Face_handle f) +{ return (index_map[f]); } } //namespace CGAL diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_observer.h b/Arrangement_on_surface_2/include/CGAL/Arr_observer.h index c622bbe1a32..1e0791ed05a 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_observer.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_observer.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006,2007,2009,2010,2011 Tel-Aviv University (Israel). +// Copyright (c) 2023 Tel-Aviv University (Israel). // All rights reserved. // // This file is part of CGAL (www.cgal.org). @@ -8,565 +8,26 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Ron Wein -// Efi Fogel +// Author(s): Efi Fogel #ifndef CGAL_ARR_OBSERVER_H #define CGAL_ARR_OBSERVER_H +/*! \file + * Definition of the `Arr_observer` base class mainly for backward + * compatibility. + */ + #include #include -#include - -/*! \file - * Definition of the Arr_observer base class. - */ - namespace CGAL { -/*! \class - * A base class for arrangement observers. - * The Arrangement parameter corresponds to an arrangement instantiation. - */ template -class Arr_observer -{ -public: - typedef Arrangement_ Arrangement_2; - typedef Arr_observer Self; +using Arr_observer = typename Arrangement_::Observer; - typedef typename Arrangement_2::Point_2 Point_2; - typedef typename Arrangement_2::X_monotone_curve_2 X_monotone_curve_2; - - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Face_handle Face_handle; - typedef typename Arrangement_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; - -private: - Arrangement_2* p_arr; // The associated arrangement. - - /*! Copy constructor - not supported. */ - Arr_observer(const Self&); - - /*! Assignment operator - not supported. */ - Self& operator=(const Self&); - -public: - /// \name Construction and destruction functions. - //@{ - - /*! Default constructor. */ - Arr_observer() : p_arr(nullptr) {} - - /*! Constructor with an associated arrangement. */ - Arr_observer(Arrangement_2& arr) : p_arr(&arr) - { - // Register the observer object in the arrangement. - p_arr->_register_observer(this); - } - - /*! Destructor. */ - virtual ~Arr_observer() - { - // Unregister the observer object from the arrangement. - if (p_arr != nullptr) - p_arr->_unregister_observer(this); - } - //@} - - /// \name Modifying the associated arrangement. - //@{ - - /*! Get the associated arrangement (non-const version). */ - const Arrangement_2* arrangement() const { return (p_arr); } - - /*! Get the associated arrangement (non-const version). */ - Arrangement_2* arrangement() { return (p_arr); } - - /*! Attach the observer to an arrangement. - * \pre The observer is not already attached to an arrangement. - */ - void attach(Arrangement_2& arr) - { - // Do nothing if the associated arrangement is not changed. - if (p_arr == &arr) return; - - // The observer is not already attached to an arrangement. - CGAL_precondition (p_arr == nullptr); - - if (p_arr != nullptr) return; - - // Notify the concrete observer (the sub-class) about the attachment. - before_attach(arr); - - // Register the observer object in the new arrangement. - p_arr = &arr; - p_arr->_register_observer(this); - - // Notify the concrete observer that the attachment took place. - after_attach(); - } - - /*! Detach the observer from the arrangement. */ - void detach() - { - if (p_arr == nullptr) return; - - // Notify the concrete observer (the sub-class) about the detachment. - before_detach (); - - // Unregister the observer object from the current arrangement, and mark - // that the observer is not attached to an arrangement. - p_arr->_unregister_observer(this); - p_arr = nullptr; - - // Notify the concrete observer that the detachment took place. - after_detach(); - } - //@} - - /// \name Notification functions on global arrangement operations. - //@{ - - /*! Notification before the arrangement is assigned with another - * arrangement. - * \param arr The arrangement to be copied. - */ - virtual void before_assign(const Arrangement_2& /* arr */) {} - - /*! Notification after the arrangement has been assigned with another - * arrangement. - */ - virtual void after_assign() {} - - /*! Notification before the arrangement is cleared. */ - virtual void before_clear() {} - - /*! Notification after the arrangement is cleared. */ - virtual void after_clear() {} - - /*! Notification before a global operation modifies the arrangement. */ - virtual void before_global_change() {} - - /*! Notification after a global operation is completed. */ - virtual void after_global_change() {} - //@} - - /// \name Notification functions on observer attachment or detachment. - //@{ - - /*! Notification before the observer is attached to an arrangement. - * \param arr The arrangement we are about to attach the observer to. - */ - virtual void before_attach(const Arrangement_2& /* arr */) {} - - /*! Notification after the observer has been attached to an arrangement. */ - virtual void after_attach() {} - - /*! Notification before the observer is detached from the arrangement. */ - virtual void before_detach() {} - - /*! Notification after the observer has been detached to the arrangement. */ - virtual void after_detach() {} - //@} - - /// \name Notification functions on local changes in the arrangement. - //@{ - - /*! - * Notification before the creation of a new vertex. - * \param p The point to be associated with the vertex. - * This point cannot lies on the surface boundaries. - */ - virtual void before_create_vertex(const Point_2& /* p */) {} - - /*! Notification after the creation of a new vertex. - * \param v A handle to the created vertex. - */ - virtual void after_create_vertex(Vertex_handle /* v */) - {} - - /*! Notification before the creation of a new boundary vertex. - * \param p The on the surface boundary. - * \param ps_x The boundary condition of the vertex in x. - * \param ps_y The boundary condition of the vertex in y. - */ - virtual void before_create_boundary_vertex(const Point_2& /* p */, - Arr_parameter_space /* ps_x */, - Arr_parameter_space /* ps_y */) - {} - - /*! Notification before the creation of a new boundary vertex. - * \param cv The curve incident to the surface boundary. - * \param ind The relevant curve-end. - * \param ps_x The boundary condition of the vertex in x. - * \param ps_y The boundary condition of the vertex in y. - */ - virtual void before_create_boundary_vertex(const X_monotone_curve_2& /* cv */, - Arr_curve_end /* ind */, - Arr_parameter_space /* ps_x */, - Arr_parameter_space /* ps_y */) - {} - - /*! Notification after the creation of a new vertex at infinity. - * \param v A handle to the created vertex. - */ - virtual void after_create_boundary_vertex(Vertex_handle /* v */) {} - - /*! Notification before the creation of a new edge. - * \param c The x-monotone curve to be associated with the edge. - * \param v1 A handle to the first end-vertex of the edge. - * \param v2 A handle to the second end-vertex of the edge. - */ - virtual void before_create_edge(const X_monotone_curve_2& /* c */, - Vertex_handle /* v1 */, - Vertex_handle /* v2 */) - {} - - /*! Notification after the creation of a new edge. - * \param e A handle to one of the twin halfedges that were created. - */ - virtual void after_create_edge(Halfedge_handle /* e */) {} - - /*! Notification before the modification of an existing vertex. - * \param v A handle to the vertex to be updated. - * \param p The point to be associated with the vertex. - */ - virtual void before_modify_vertex(Vertex_handle /* v */, - const Point_2& /* p */) - {} - - /*! Notification after a vertex was modified. - * \param v A handle to the updated vertex. - */ - virtual void after_modify_vertex(Vertex_handle /* v */) {} - - /*! Notification before the modification of an existing edge. - * \param e A handle to one of the twin halfedges to be updated. - * \param c The x-monotone curve to be associated with the edge. - */ - virtual void before_modify_edge(Halfedge_handle /* e */, - const X_monotone_curve_2& /* c */) - {} - - /*! Notification after an edge was modified. - * \param e A handle to one of the twin halfedges that were updated. - */ - virtual void after_modify_edge(Halfedge_handle /* e */) {} - - /*! Notification before the splitting of an edge into two. - * \param e A handle to one of the existing halfedges. - * \param v A vertex representing the split point. - * \param c1 The x-monotone curve to be associated with the first edge. - * \param c2 The x-monotone curve to be associated with the second edge. - */ - virtual void before_split_edge(Halfedge_handle /* e */, - Vertex_handle /* v */, - const X_monotone_curve_2& /* c1 */, - const X_monotone_curve_2& /* c2 */) - {} - - /*! Notification after an edge was split. - * \param e1 A handle to one of the twin halfedges forming the first edge. - * \param e2 A handle to one of the twin halfedges forming the second edge. - */ - virtual void after_split_edge(Halfedge_handle /* e1 */, - Halfedge_handle /* e2 */) - {} - - /*! Notification before the splitting of a fictitious edge into two. - * \param e A handle to one of the existing halfedges. - * \param v A vertex representing the unbounded split point. - */ - virtual void before_split_fictitious_edge(Halfedge_handle /* e */, - Vertex_handle /* v */) - {} - - /*! Notification after a fictitious edge was split. - * \param e1 A handle to one of the twin halfedges forming the first edge. - * \param e2 A handle to one of the twin halfedges forming the second edge. - */ - virtual void after_split_fictitious_edge(Halfedge_handle /* e1 */, - Halfedge_handle /* e2 */) - {} - - /*! Notification before the splitting of a face into two. - * \param f A handle to the existing face. - * \param e The new edge whose insertion causes the face to split. - */ - virtual void before_split_face(Face_handle /* f */, - Halfedge_handle /* e */) - {} - - /*! Notification after a face was split. - * \param f A handle to the face we have just split. - * \param new_f A handle to the new face that has been created. - * \param is_hole Whether the new face forms a hole inside f. - */ - virtual void after_split_face(Face_handle /* f */, - Face_handle /* new_f */, - bool /* is_hole */) - {} - - /*! Notification before the splitting of an outer CCB into two. - * \param f A handle to the face that owns the outer CCB. - * \param h A circulator representing the component boundary. - * \param e The new edge whose removal causes the outer CCB to split. - */ - virtual void before_split_outer_ccb(Face_handle /* f */, - Ccb_halfedge_circulator /* h */, - Halfedge_handle /* e */) - {} - - /*! Notification after an outer CCB was split. - * \param f A handle to the face that owns the outer CCBs. - * \param h1 A circulator representing the boundary of the first component. - * \param h2 A circulator representing the boundary of the second component. - */ - virtual void after_split_outer_ccb(Face_handle /* f */, - Ccb_halfedge_circulator /* h1 */, - Ccb_halfedge_circulator /* h2 */) - {} - - /*! Notification before the splitting of an inner CCB into two. - * \param f A handle to the face containing the inner CCB. - * \param h A circulator representing the component boundary. - * \param e The new edge whose removal causes the inner CCB to split. - */ - virtual void before_split_inner_ccb(Face_handle /* f */, - Ccb_halfedge_circulator /* h */, - Halfedge_handle /* e */) - {} - - /*! Notification after an inner CCB was split. - * \param f A handle to the face containing the inner CCBs. - * \param h1 A circulator representing the boundary of the first component. - * \param h2 A circulator representing the boundary of the second component. - */ - virtual void after_split_inner_ccb(Face_handle /* f */, - Ccb_halfedge_circulator /* h1 */, - Ccb_halfedge_circulator /* h2 */) - {} - - /*! Notification before the creation of a new outer CCB of a face. - * \param f A handle to the face that owns the outer CCB. - * \param e A halfedge along the new outer CCB. - */ - virtual void before_add_outer_ccb(Face_handle /* f */, - Halfedge_handle /* e */) - {} - - /*! Notification after an outer CCB was added to a face. - * \param h A circulator representing the boundary of the new outer CCB. - */ - virtual void after_add_outer_ccb(Ccb_halfedge_circulator /* h */) {} - - /*! Notification before the creation of a new inner CCB inside a face. - * \param f A handle to the face containing the inner CCB. - * \param e The new halfedge that forms the new inner CCB. - */ - virtual void before_add_inner_ccb(Face_handle /* f */, - Halfedge_handle /* e */) - {} - - /*! Notification after an inner CCB was created inside a face. - * \param h A circulator representing the boundary of the new inner CCB. - */ - virtual void after_add_inner_ccb(Ccb_halfedge_circulator /* h */) {} - - /*! Notification before the creation of a new isolated vertex inside a face. - * \param f A handle to the face containing the isolated vertex. - * \param v The isolated vertex. - */ - virtual void before_add_isolated_vertex(Face_handle /* f */, - Vertex_handle /* v */) - {} - - /*! Notification after an isolated vertex was created inside a face. - * \param v The isolated vertex. - */ - virtual void after_add_isolated_vertex(Vertex_handle /* v */) {} - - /*! Notification before the merging of two edges. - * \param e1 A handle to one of the halfedges forming the first edge. - * \param e2 A handle to one of the halfedges forming the second edge. - * \param c The x-monotone curve to be associated with the merged edge. - */ - virtual void before_merge_edge(Halfedge_handle /* e1 */, - Halfedge_handle /* e2 */, - const X_monotone_curve_2& /* c */) - {} - - /*! Notification after an edge was merged. - * \param e A handle to one of the twin halfedges forming the merged edge. - */ - virtual void after_merge_edge(Halfedge_handle /* e */) {} - - /*! Notification before the merging of two fictitious edges. - * \param e1 A handle to one of the halfedges forming the first edge. - * \param e2 A handle to one of the halfedges forming the second edge. - */ - virtual void before_merge_fictitious_edge(Halfedge_handle /* e1 */, - Halfedge_handle /* e2 */) - {} - - /*! Notification after a fictitious edge was merged. - * \param e A handle to one of the twin halfedges forming the merged edge. - */ - virtual void after_merge_fictitious_edge(Halfedge_handle /* e */) {} - - /*! Notification before the merging of two faces. - * \param f1 A handle to the first face. - * \param f2 A handle to the second face. - * \param e The edge whose removal causes the faces to merge. - */ - virtual void before_merge_face(Face_handle /* f1 */, - Face_handle /* f2 */, - Halfedge_handle /* e */) - {} - - /*! Notification after a face was merged. - * \param f A handle to the merged face. - */ - virtual void after_merge_face(Face_handle /* f */) {} - - /*! Notification before the merging of two outer CCBs. - * \param f A handle to the face that owns the outer CCBs. - * \param h1 A circulator representing the boundary of the first component. - * \param h2 A circulator representing the boundary of the second component. - * \param e The edge whose insertion or removal causes the CCBs to merge. - */ - virtual void before_merge_outer_ccb(Face_handle /* f */, - Ccb_halfedge_circulator /* h1 */, - Ccb_halfedge_circulator /* h2 */, - Halfedge_handle /* e */) - {} - - /*! Notification after an outer CCB was merged. - * \param f A handle to the face that owns the outer CCBs. - * \param h A circulator representing the boundary of the merged component. - */ - virtual void after_merge_outer_ccb(Face_handle /* f */, - Ccb_halfedge_circulator /* h */) - {} - - /*! Notification before the merging of two inner CCBs (holes). - * \param f A handle to the face that contains the inner CCBs. - * \param h1 A circulator representing the boundary of the first component. - * \param h2 A circulator representing the boundary of the second component. - * \param e The edge whose insertion causes the inner CCBs to merge. - */ - virtual void before_merge_inner_ccb(Face_handle /* f */, - Ccb_halfedge_circulator /* h1 */, - Ccb_halfedge_circulator /* h2 */, - Halfedge_handle /* e */) - {} - - /*! Notification after an inner CCB was merged. - * \param f A handle to the face that contains the inner CCBs. - * \param h A circulator representing the boundary of the merged component. - */ - virtual void after_merge_inner_ccb(Face_handle /* f */, - Ccb_halfedge_circulator /* h */) - {} - - /*! Notification before an outer CCB is moved from one face to another. - * \param from_f A handle to the face that currently owns the outer CCB. - * \param to_f A handle to the face that should own the outer CCB. - * \param h A circulator representing the boundary of the component. - */ - virtual void before_move_outer_ccb(Face_handle /* from_f */, - Face_handle /* to_f */, - Ccb_halfedge_circulator /* h */) - {} - - /*! Notification after an outer CCB is moved from one face to another. - * \param h A circulator representing the boundary of the component. - */ - virtual void after_move_outer_ccb(Ccb_halfedge_circulator /* h */) {} - - - /*! Notification before an inner CCB is moved from one face to another. - * \param from_f A handle to the face currently containing the inner CCB. - * \param to_f A handle to the face that should contain the inner CCB. - * \param h A circulator representing the boundary of the component. - */ - virtual void before_move_inner_ccb(Face_handle /* from_f */, - Face_handle /* to_f */, - Ccb_halfedge_circulator /* h */) - {} - - /*! - * Notification after an inner CCB is moved from one face to another. - * \param h A circulator representing the boundary of the component. - */ - virtual void after_move_inner_ccb(Ccb_halfedge_circulator /* h */) {} - - /*! Notification before an isolated vertex is moved from one face to another. - * \param from_f A handle to the face currently containing the vertex. - * \param to_f A handle to the face that should contain the vertex. - * \param v The isolated vertex. - */ - virtual void before_move_isolated_vertex(Face_handle /* from_f */, - Face_handle /* to_f */, - Vertex_handle /* v */) - {} - - /*! Notification after an isolated vertex is moved from one face to another. - * \param v The isolated vertex. - */ - virtual void after_move_isolated_vertex(Vertex_handle /* v */) {} - - /*! Notificaion before the removal of a vertex. - * \param v A handle to the vertex to be deleted. - */ - virtual void before_remove_vertex(Vertex_handle /* v */) {} - - /*! Notificaion after the removal of a vertex. */ - virtual void after_remove_vertex() {} - - /*! Notification before the removal of an edge. - * \param e A handle to one of the twin halfedges to be deleted. - */ - virtual void before_remove_edge(Halfedge_handle /* e */) {} - - /*! Notificaion after the removal of an edge. */ - virtual void after_remove_edge() {} - - /*! Notification before the removal of an outer CCB. - * \param f The face that owns the outer CCB. - * \param h A circulator representing the boundary of the component. - */ - virtual void before_remove_outer_ccb(Face_handle /* f */, - Ccb_halfedge_circulator /* h */) - {} - - /*! Notificaion after the removal of an outer CCB. - * \param f The face that used to own the outer CCB. - */ - virtual void after_remove_outer_ccb(Face_handle /* f */) {} - - /*! Notification before the removal of an inner CCB. - * \param f The face containing the inner CCB. - * \param h A circulator representing the boundary of the component. - */ - virtual void before_remove_inner_ccb(Face_handle /* f */, - Ccb_halfedge_circulator /* h */) - {} - - /*! Notificaion after the removal of an inner CCB. - * \param f The face that used to contain the inner CCB. - */ - virtual void after_remove_inner_ccb(Face_handle /* f */) {} - - //@} -}; - -} //namespace CGAL +} // namespace CGAL #include diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Arr_lm_generator_base.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Arr_lm_generator_base.h index daf08604ed2..42dc494377f 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Arr_lm_generator_base.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Arr_lm_generator_base.h @@ -20,7 +20,6 @@ * Definition of the Arr_landmarks_generator_base template. */ #include -#include #include #include #include @@ -43,44 +42,44 @@ namespace CGAL { */ template > -class Arr_landmarks_generator_base : public Arr_observer { + Arr_landmarks_nearest_neighbor > +class Arr_landmarks_generator_base : public Arrangement_::Observer { public: - typedef Arrangement_ Arrangement_2; - typedef Nearest_neighbor_ Nearest_neighbor; + using Arrangement_2 = Arrangement_; + using Base_aos = typename Arrangement_2::Base_aos; - typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; - typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; - typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Face_handle Face_handle; - typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator; - typedef typename Arrangement_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; + using Nearest_neighbor = Nearest_neighbor_; - typedef typename Arrangement_2::Point_2 Point_2; - typedef typename Arrangement_2::X_monotone_curve_2 X_monotone_curve_2; + using Geometry_traits_2 = typename Base_aos::Geometry_traits_2; + using Vertex_const_handle = typename Base_aos::Vertex_const_handle; + using Halfedge_const_handle = typename Base_aos::Halfedge_const_handle; + using Face_const_handle = typename Base_aos::Face_const_handle; + using Vertex_handle = typename Base_aos::Vertex_handle; + using Halfedge_handle = typename Base_aos::Halfedge_handle; + using Face_handle = typename Base_aos::Face_handle; + using Vertex_const_iterator = typename Base_aos::Vertex_const_iterator; + using Ccb_halfedge_circulator = typename Base_aos::Ccb_halfedge_circulator; - typedef typename Nearest_neighbor::NN_Point_2 NN_Point_2; - typedef std::list NN_Points_set; + using Point_2 = typename Base_aos::Point_2; + using X_monotone_curve_2 = typename Base_aos::X_monotone_curve_2; - typedef std::vector Points_set; + using NN_Point_2 = typename Nearest_neighbor::NN_Point_2; + using NN_Points_set = std::list; - typedef Arr_point_location_result PL_result; - typedef typename PL_result::Type PL_result_type; + using Points_set = std::vector; - typedef std::pair PL_pair; - typedef std::vector Pairs_set; - typedef typename std::vector::iterator Pairs_iterator; + using PL_result = Arr_point_location_result; + using PL_result_type = typename PL_result::Type; + + using PL_pair = std::pair; + using Pairs_set = std::vector; + using Pairs_iterator = typename std::vector::iterator; private: - typedef Arr_landmarks_generator_base - Self; + using Self = Arr_landmarks_generator_base; protected: - typedef Arr_traits_basic_adaptor_2 Traits_adaptor_2; + using Traits_adaptor_2 = Arr_traits_basic_adaptor_2; // Data members: const Traits_adaptor_2* m_traits; // The associated traits object. @@ -109,8 +108,8 @@ public: /*! Constructor from an arrangement. * \param arr (in) The arrangement. */ - Arr_landmarks_generator_base(const Arrangement_2& arr) : - Arr_observer (const_cast(arr)), + Arr_landmarks_generator_base(const Base_aos& arr) : + Base_aos::Observer(const_cast(arr)), m_traits(static_cast(arr.geometry_traits())), m_ignore_notifications(false), m_ignore_remove_edge(false), @@ -124,8 +123,7 @@ public: /*! Create the landmarks set (choosing the landmarks) , * and saving them in the nearest-neighbor search structure. */ - virtual void build_landmark_set() - { + virtual void build_landmark_set() { // Create the landmark points. NN_Points_set nn_points; _create_nn_points_set(nn_points); @@ -140,8 +138,7 @@ public: /*! clear the set of landmarks. */ - virtual void clear_landmark_set() - { + virtual void clear_landmark_set() { nn.clear(); num_small_not_updated_changes = 0; updated = false; @@ -153,8 +150,7 @@ public: * arrangement (a vertex, halfedge, or face handle). * \return The nearest landmark point. */ - virtual Point_2 closest_landmark(const Point_2& p, PL_result_type& obj) - { + virtual Point_2 closest_landmark(const Point_2& p, PL_result_type& obj) { CGAL_assertion(updated); return (nn.find_nearest_neighbor(p, obj)); } @@ -162,13 +158,13 @@ public: /// \name Overloaded observer functions on global changes. //@{ - /*! - * Notification before the arrangement is assigned with another - * arrangement. - * \param arr The arrangement to be copied. + /*! Notification before the arrangement is assigned with the content of + * another arrangement. + * \param arr The other arrangement. Notice that the arrangement type is the + * type used to instantiate the observer, which is conveniently + * defined as `Arrangement_2::Base_aos`. */ - virtual void before_assign(const Arrangement_2& arr) - { + virtual void before_assign(const Base_aos& arr) override { this->clear_landmark_set(); m_traits = static_cast(arr.geometry_traits()); m_ignore_notifications = true; @@ -177,8 +173,7 @@ public: /*! Notification after the arrangement has been assigned with another * arrangement. */ - virtual void after_assign() - { + virtual void after_assign() override { this->build_landmark_set(); m_ignore_notifications = false; } @@ -186,8 +181,7 @@ public: /*! Notification before the observer is attached to an arrangement. * \param arr The arrangement we are about to attach the observer to. */ - virtual void before_attach(const Arrangement_2& arr) - { + virtual void before_attach(const Base_aos& arr) override { this->clear_landmark_set(); m_traits = static_cast(arr.geometry_traits()); m_ignore_notifications = true; @@ -195,38 +189,33 @@ public: /*! Notification after the observer has been attached to an arrangement. */ - virtual void after_attach() - { + virtual void after_attach() override { this->build_landmark_set(); m_ignore_notifications = false; } /*! Notification before the observer is detached from the arrangement. */ - virtual void before_detach() - { this->clear_landmark_set(); } + virtual void before_detach() override { this->clear_landmark_set(); } /*! Notification after the arrangement is cleared. * \param u A handle to the unbounded face. */ - virtual void after_clear() - { + virtual void after_clear() override { this->clear_landmark_set(); this->build_landmark_set(); } /*! Notification before a global operation modifies the arrangement. */ - virtual void before_global_change() - { + virtual void before_global_change() override { this->clear_landmark_set(); m_ignore_notifications = true; } /*! Notification after a global operation is completed. */ - virtual void after_global_change() - { + virtual void after_global_change() override { this->build_landmark_set(); m_ignore_notifications = false; } @@ -238,12 +227,11 @@ public: /*! Notification before the removal of an edge. * \param e (in) A handle to one of the twin halfedges to be removed. */ - virtual void before_remove_edge(Halfedge_handle /* e */) + virtual void before_remove_edge(Halfedge_handle /* e */) override { m_ignore_remove_edge = true; } /*! Notification after the creation of a new vertex. */ - virtual void after_create_vertex(Vertex_handle) - { + virtual void after_create_vertex(Vertex_handle) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -251,8 +239,7 @@ public: } /*! Notification after the creation of a new edge. */ - virtual void after_create_edge(Halfedge_handle) - { + virtual void after_create_edge(Halfedge_handle) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -260,8 +247,7 @@ public: } /*! Notification after an edge was split. */ - virtual void after_split_edge(Halfedge_handle, Halfedge_handle) - { + virtual void after_split_edge(Halfedge_handle, Halfedge_handle) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -269,8 +255,7 @@ public: } /*! Notification after a face was split. */ - virtual void after_split_face(Face_handle, Face_handle, bool) - { + virtual void after_split_face(Face_handle, Face_handle, bool) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -280,8 +265,7 @@ public: /*! Notification after an outer CCB was split.*/ virtual void after_split_outer_ccb(Face_handle, Ccb_halfedge_circulator, - Ccb_halfedge_circulator) - { + Ccb_halfedge_circulator) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -291,8 +275,7 @@ public: /*! Notification after an inner CCB was split. */ virtual void after_split_inner_ccb(Face_handle, Ccb_halfedge_circulator, - Ccb_halfedge_circulator) - { + Ccb_halfedge_circulator) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -300,8 +283,7 @@ public: } /*! Notification after an outer CCB was added to a face. */ - virtual void after_add_outer_ccb(Ccb_halfedge_circulator) - { + virtual void after_add_outer_ccb(Ccb_halfedge_circulator) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -309,8 +291,7 @@ public: } /*! Notification after an inner CCB was created inside a face. */ - virtual void after_add_inner_ccb(Ccb_halfedge_circulator) - { + virtual void after_add_inner_ccb(Ccb_halfedge_circulator) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -318,8 +299,7 @@ public: } /*! Notification after an isolated vertex was created inside a face. */ - virtual void after_add_isolated_vertex(Vertex_handle) - { + virtual void after_add_isolated_vertex(Vertex_handle) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -327,8 +307,7 @@ public: } /*! Notification after an edge was merged. */ - virtual void after_merge_edge(Halfedge_handle) - { + virtual void after_merge_edge(Halfedge_handle) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -336,8 +315,7 @@ public: } /*! Notification after a face was merged. */ - virtual void after_merge_face(Face_handle) - { + virtual void after_merge_face(Face_handle) override { if (! m_ignore_notifications && ! m_ignore_remove_edge) { clear_landmark_set(); build_landmark_set(); @@ -346,7 +324,7 @@ public: /*! Notification after an outer CCB was merged. */ virtual void after_merge_outer_ccb(Face_handle, Ccb_halfedge_circulator) - { + override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -355,7 +333,7 @@ public: /*! Notification after an inner CCB was merged. */ virtual void after_merge_inner_ccb(Face_handle, Ccb_halfedge_circulator) - { + override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -363,8 +341,7 @@ public: } /*! Notification after an outer CCB is moved from one face to another. */ - virtual void after_move_outer_ccb(Ccb_halfedge_circulator ) - { + virtual void after_move_outer_ccb(Ccb_halfedge_circulator) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -372,8 +349,7 @@ public: } /*! Notification after an inner CCB is moved from one face to another. */ - virtual void after_move_inner_ccb(Ccb_halfedge_circulator ) - { + virtual void after_move_inner_ccb(Ccb_halfedge_circulator) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -381,8 +357,7 @@ public: } /*! Notification after an isolated vertex is moved. */ - virtual void after_move_isolated_vertex(Vertex_handle ) - { + virtual void after_move_isolated_vertex(Vertex_handle) override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -390,8 +365,7 @@ public: } /*! Notificaion after the removal of a vertex. */ - virtual void after_remove_vertex() - { + virtual void after_remove_vertex() override { if (! m_ignore_notifications && ! m_ignore_remove_edge) { clear_landmark_set(); build_landmark_set(); @@ -399,8 +373,7 @@ public: } /*! Notification after the removal of an edge. */ - virtual void after_remove_edge() - { + virtual void after_remove_edge() override { if (! m_ignore_notifications) { clear_landmark_set(); build_landmark_set(); @@ -409,8 +382,7 @@ public: } /*! Notificaion after the removal of an outer CCB. */ - virtual void after_remove_outer_ccb(Face_handle) - { + virtual void after_remove_outer_ccb(Face_handle) override { if (! m_ignore_notifications && ! m_ignore_remove_edge) { clear_landmark_set(); build_landmark_set(); @@ -418,8 +390,7 @@ public: } /*! Notificaion after the removal of an inner CCB. */ - virtual void after_remove_inner_ccb(Face_handle) - { + virtual void after_remove_inner_ccb(Face_handle) override { if (! m_ignore_notifications && ! m_ignore_remove_edge) { clear_landmark_set(); build_landmark_set(); @@ -434,8 +405,7 @@ protected: */ virtual void _create_points_set(Points_set&) = 0; - virtual void _create_nn_points_set(NN_Points_set& nn_points) - { + virtual void _create_nn_points_set(NN_Points_set& nn_points) { Points_set points; Pairs_set pairs; @@ -453,8 +423,7 @@ protected: // Insert all landmarks (paired with their current location in the // arrangement) into the nearest-neighbor search structure. - Pairs_iterator itr; - for (itr = pairs.begin(); itr != pairs.end(); ++itr) { + for (auto itr = pairs.begin(); itr != pairs.end(); ++itr) { NN_Point_2 np(itr->first, itr->second); nn_points.push_back(np); } diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Arr_lm_vertices_generator.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Arr_lm_vertices_generator.h index 57478ec7936..01fd5aba052 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Arr_lm_vertices_generator.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Arr_lm_vertices_generator.h @@ -98,14 +98,13 @@ public: virtual void build_landmark_set() { // Go over the arrangement, and insert all its vertices as landmarks. - NN_Point_list nnp_list; - const Arrangement_2* arr = this->arrangement(); - Vertex_const_iterator vit; + NN_Point_list nnp_list; + const auto* arr = this->arrangement(); num_landmarks = 0; - for (vit = arr->vertices_begin(); vit != arr->vertices_end(); ++vit) { + for (auto vit = arr->vertices_begin(); vit != arr->vertices_end(); ++vit) { Vertex_const_handle vh = vit; nnp_list.push_back(NN_Point_2(vh->point(), this->pl_make_result(vh))); - num_landmarks++; + ++num_landmarks; } // Update the search structure. diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Trapezoidal_decomposition_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Trapezoidal_decomposition_2.h index 1a3549c0008..82b554cb6a0 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Trapezoidal_decomposition_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_point_location/Trapezoidal_decomposition_2.h @@ -177,6 +177,7 @@ public: //typedef of arrangement on surface typedef typename Traits::Arrangement_on_surface_2 Arrangement_on_surface_2; + using Base_aos = typename Arrangement_on_surface_2::Base_aos; //type of traits adaptor typedef typename Traits::Arrangement_on_surface_2::Traits_adaptor_2 @@ -1804,7 +1805,7 @@ public: return m_number_of_curves; } - void init_arrangement_and_traits(const Arrangement_on_surface_2* arr, + void init_arrangement_and_traits(const Base_aos* arr, bool allocate_traits = true) { m_arr = arr; @@ -2125,7 +2126,7 @@ protected: unsigned long m_number_of_curves; const Traits* traits; //Before_split_data m_before_split; - const Arrangement_on_surface_2* m_arr; + const Base_aos* m_arr; const Traits_adaptor_2* m_trts_adaptor; Halfedge_const_handle m_empty_he_handle; diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_trapezoid_ric_point_location.h b/Arrangement_on_surface_2/include/CGAL/Arr_trapezoid_ric_point_location.h index 7a4042e9601..5776d9cf3ab 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_trapezoid_ric_point_location.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_trapezoid_ric_point_location.h @@ -8,8 +8,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Idit Haran -// (based on old version by Oren Nechushtan and Iddo Hanniel) +// Author(s): Idit Haran +// (based on old version by Oren Nechushtan and Iddo Hanniel) #ifndef CGAL_ARR_TRAPEZOID_RIC_POINT_LOCATION_H #define CGAL_ARR_TRAPEZOID_RIC_POINT_LOCATION_H @@ -26,7 +26,6 @@ #include #include #include -#include namespace CGAL { @@ -36,96 +35,95 @@ namespace CGAL { * The Arrangement parameter corresponds to an arrangement instantiation. */ template -class Arr_trapezoid_ric_point_location : public Arr_observer { +class Arr_trapezoid_ric_point_location : public Arrangement_::Observer { public: //type of arrangement on surface - typedef Arrangement_ Arrangement_on_surface_2; + using Arrangement_on_surface_2 = Arrangement_; + using Base_aos = typename Arrangement_on_surface_2::Base_aos; //type of geometry traits - typedef typename Arrangement_on_surface_2::Geometry_traits_2 - Geometry_traits_2; + using Geometry_traits_2 = typename Base_aos::Geometry_traits_2; + //type of traits adaptor - typedef typename Arrangement_on_surface_2::Traits_adaptor_2 - Traits_adaptor_2; + using Traits_adaptor_2 = typename Base_aos::Traits_adaptor_2; + //type of vertex handle - typedef typename Arrangement_on_surface_2::Vertex_handle - Vertex_handle; + using Vertex_handle = typename Base_aos::Vertex_handle; + //type of vertex const handle - typedef typename Arrangement_on_surface_2::Vertex_const_handle - Vertex_const_handle; + using Vertex_const_handle = typename Base_aos::Vertex_const_handle; + //type of halfedge handle - typedef typename Arrangement_on_surface_2::Halfedge_handle - Halfedge_handle; + using Halfedge_handle = typename Base_aos::Halfedge_handle; + //type of halfedge const handle - typedef typename Arrangement_on_surface_2::Halfedge_const_handle - Halfedge_const_handle; + using Halfedge_const_handle = typename Base_aos::Halfedge_const_handle; + //type of face const handle - typedef typename Arrangement_on_surface_2::Face_const_handle - Face_const_handle; + using Face_const_handle = typename Base_aos::Face_const_handle; + //type of edge const iterator - typedef typename Arrangement_on_surface_2::Edge_const_iterator - Edge_const_iterator; + using Edge_const_iterator = typename Base_aos::Edge_const_iterator; + //type of isolated vertex const iterator - typedef typename Arrangement_on_surface_2::Isolated_vertex_const_iterator - Isolated_vertex_const_iterator; + using Isolated_vertex_const_iterator = + typename Base_aos::Isolated_vertex_const_iterator; + //type of point - typedef typename Geometry_traits_2::Point_2 Point_2; + using Point_2 = typename Geometry_traits_2::Point_2; //type of x-monotone curve - typedef typename Geometry_traits_2::X_monotone_curve_2 - X_monotone_curve_2; + using X_monotone_curve_2 = typename Geometry_traits_2::X_monotone_curve_2; + //type of trapezoidal decomposition traits class - typedef CGAL::Td_traits - Td_traits; + using Td_traits = CGAL::Td_traits; + //type of trapezoidal decomposition class - typedef Trapezoidal_decomposition_2 - Trapezoidal_decomposition; + using Trapezoidal_decomposition = Trapezoidal_decomposition_2; //!types of Td_map_item-s - typedef typename Trapezoidal_decomposition::Td_map_item - Td_map_item; - typedef typename Trapezoidal_decomposition::Td_active_vertex - Td_active_vertex; - typedef typename Trapezoidal_decomposition::Td_active_fictitious_vertex - Td_active_fictitious_vertex; - typedef typename Trapezoidal_decomposition::Td_active_edge - Td_active_edge; - typedef typename Trapezoidal_decomposition::Td_active_trapezoid - Td_active_trapezoid; + using Td_map_item = typename Trapezoidal_decomposition::Td_map_item; + using Td_active_vertex = typename Trapezoidal_decomposition::Td_active_vertex; + using Td_active_fictitious_vertex = + typename Trapezoidal_decomposition::Td_active_fictitious_vertex; + using Td_active_edge = typename Trapezoidal_decomposition::Td_active_edge; + using Td_active_trapezoid = + typename Trapezoidal_decomposition::Td_active_trapezoid; + //!type of side tags - typedef typename Traits_adaptor_2::Left_side_category Left_side_category; - typedef typename Traits_adaptor_2::Bottom_side_category Bottom_side_category; - typedef typename Traits_adaptor_2::Top_side_category Top_side_category; - typedef typename Traits_adaptor_2::Right_side_category Right_side_category; + using Left_side_category = typename Traits_adaptor_2::Left_side_category; + using Bottom_side_category = typename Traits_adaptor_2::Bottom_side_category; + using Top_side_category = typename Traits_adaptor_2::Top_side_category; + using Right_side_category = typename Traits_adaptor_2::Right_side_category; protected: - typedef Arr_point_location_result Result; - typedef typename Result::Type Result_type; + using Result = Arr_point_location_result; + using Result_type = typename Result::Type; public: // Support cpp11::result_of - typedef Result_type result_type; + using result_type = Result_type; protected: //type of trapezoidal decomposition class - typedef Trapezoidal_decomposition TD; + using TD = Trapezoidal_decomposition; - typedef typename Arr_all_sides_oblivious_category::result - All_sides_oblivious_category; + using All_sides_oblivious_category= + typename Arr_all_sides_oblivious_category::result; // Data members: const Traits_adaptor_2* m_traits; // Its associated traits object. - TD td; // instance of trapezoidal decomposition + TD td; // instance of trapezoidal decomposition bool m_with_guarantees; //for the notification functions - X_monotone_curve_2 m_cv_before_split; - Halfedge_handle m_he_after_merge; - //X_monotone_curve_2 m_cv_before_merge1; - //X_monotone_curve_2 m_cv_before_merge2; + X_monotone_curve_2 m_cv_before_split; + Halfedge_handle m_he_after_merge; + //X_monotone_curve_2 m_cv_before_merge1; + //X_monotone_curve_2 m_cv_before_merge2; template Result_type make_result(T t) const { return Result::make_result(t); } @@ -133,26 +131,25 @@ protected: public: /*! Default constructor. */ - Arr_trapezoid_ric_point_location(bool with_guarantees = true, - double depth_thrs = CGAL_TD_DEFAULT_DEPTH_THRESHOLD, - double size_thrs = CGAL_TD_DEFAULT_SIZE_THRESHOLD) : - m_traits(nullptr), m_with_guarantees(with_guarantees) - { + Arr_trapezoid_ric_point_location + (bool with_guarantees = true, + double depth_thrs = CGAL_TD_DEFAULT_DEPTH_THRESHOLD, + double size_thrs = CGAL_TD_DEFAULT_SIZE_THRESHOLD) : + m_traits(nullptr), m_with_guarantees(with_guarantees) { td.set_with_guarantees(with_guarantees); td.depth_threshold(depth_thrs); td.size_threshold(size_thrs); } /*! Constructor given an arrangement. */ - Arr_trapezoid_ric_point_location (const Arrangement_on_surface_2& arr, - bool with_guarantees = true, - double depth_thrs = CGAL_TD_DEFAULT_DEPTH_THRESHOLD, - double size_thrs = CGAL_TD_DEFAULT_SIZE_THRESHOLD) : - Arr_observer - (const_cast(arr)), - m_with_guarantees(with_guarantees) - { - m_traits = static_cast (arr.geometry_traits()); + Arr_trapezoid_ric_point_location + (const Base_aos& arr, + bool with_guarantees = true, + double depth_thrs = CGAL_TD_DEFAULT_DEPTH_THRESHOLD, + double size_thrs = CGAL_TD_DEFAULT_SIZE_THRESHOLD) : + Base_aos::Observer(const_cast(arr)), + m_with_guarantees(with_guarantees) { + m_traits = static_cast(arr.geometry_traits()); td.set_with_guarantees(with_guarantees); td.init_arrangement_and_traits(&arr); td.depth_threshold(depth_thrs); @@ -161,17 +158,15 @@ public: } /*! Destructor. */ - ~Arr_trapezoid_ric_point_location () { } + ~Arr_trapezoid_ric_point_location() { } /*! defines whether the underlying search structure guarantees logarithmic * query time and linear size */ - void with_guarantees (bool with_guarantees) - { + void with_guarantees(bool with_guarantees) { //if with_guarantees was changed from false to true - reconstruct // the search structure with guarantees td.set_with_guarantees(with_guarantees); - if (with_guarantees && !m_with_guarantees) - { + if (with_guarantees && !m_with_guarantees) { td.clear(); _construct_td(); } @@ -182,30 +177,20 @@ public: * (the longest path in the DAG) */ unsigned long depth() //longest_dag_path() - { - return td.largest_leaf_depth() + 1; - } + { return td.largest_leaf_depth() + 1; } /*! returns the longest query path in the underlying search structure */ unsigned long longest_query_path_length() - { - return td.longest_query_path_length(); - } + { return td.longest_query_path_length(); } #ifdef CGAL_TD_DEBUG //void locate_and_print (std::ostream& out, const Point_2& p) const - //{ - // td.locate_and_print(out, p); - //} + //{ td.locate_and_print(out, p); } - void print_dag(std::ostream& out) const - { - td.print_dag(out); - } + void print_dag(std::ostream& out) const { td.print_dag(out); } #endif - /*! - * Locate the arrangement feature containing the given point. + /*! Locate the arrangement feature containing the given point. * \param p The query point. * \return An object representing the arrangement feature containing the * query point. This object is either a Face_const_handle or a @@ -213,8 +198,7 @@ public: */ result_type locate(const Point_2& p) const; - /*! - * Locate the arrangement feature which a upward vertical ray emanating from + /*! Locate the arrangement feature which a upward vertical ray emanating from * the given point hits. * \param p The query point. * \return An object representing the arrangement feature the ray hits. @@ -224,8 +208,7 @@ public: result_type ray_shoot_up(const Point_2& p) const { return (_vertical_ray_shoot(p, true)); } - /*! - * Locate the arrangement feature which a downward vertical ray emanating + /*! Locate the arrangement feature which a downward vertical ray emanating * from the given point hits. * \param p The query point. * \return An object representing the arrangement feature the ray hits. @@ -239,72 +222,62 @@ public: // base observer. //@{ - virtual void before_assign (const Arrangement_on_surface_2& arr) - { + /*! Notification before the arrangement is assigned with the content of + * another arrangement. + * \param arr The other arrangement. Notice that the arrangement type is the + * type used to instantiate the observer, which is conveniently + * defined as `Arrangement_2::Base_aos`. + */ + virtual void before_assign(const Base_aos& arr) override { td.clear(); m_traits = static_cast (arr.geometry_traits()); td.init_arrangement_and_traits(&arr, false); } - virtual void after_assign () - { - _construct_td(); - } + virtual void after_assign() override { _construct_td(); } - virtual void before_clear () - { - td.clear(); - } + virtual void before_clear() override { td.clear(); } - virtual void after_clear () - { - _construct_td(); - } + virtual void after_clear() override { _construct_td(); } - virtual void before_attach (const Arrangement_on_surface_2& arr) - { + /*! Notification before the observer is attached to an arrangement. + * \param arr The arrangement that is about to attach the observer. Notice + * that the arrangement type is the type used to instantiate the + * observer, which is conveniently defined as + * `Arrangement_2::Base_aos`. + */ + virtual void before_attach(const Base_aos& arr) override { td.clear(); m_traits = static_cast (arr.geometry_traits()); td.init_arrangement_and_traits(&arr); } - virtual void after_attach () - { - _construct_td(); - } + virtual void after_attach() override { _construct_td(); } - virtual void before_detach () - { - td.clear(); - } + virtual void before_detach() override { td.clear(); } - virtual void after_create_edge (Halfedge_handle e) - { - td.insert(e); - } + virtual void after_create_edge(Halfedge_handle e) override { td.insert(e); } //TODO IDIT OREN: what can be done in order to avoid the need //to save the original curve is to find the common endpoint of the //two new halfedges, locate it in the trapezoid in order to find the //curve it lies on, which is the curve that was split, and then remove //this curve. - virtual void before_split_edge (Halfedge_handle e, - Vertex_handle /* v */, - const X_monotone_curve_2& /* cv1 */ , - const X_monotone_curve_2& /* cv2 */ ) - { + virtual void before_split_edge(Halfedge_handle e, + Vertex_handle /* v */, + const X_monotone_curve_2& /* cv1 */, + const X_monotone_curve_2& /* cv2 */) override { - ////MICHAL: commented due to inefficient depth update, remove and insert instead - ////save the curve for the "after" function. + ////MICHAL: commented due to inefficient depth update, remove and insert + ////instead save the curve for the "after" function. //m_cv_before_split = e->curve(); //td.before_split_edge(m_cv_before_split, cv1, cv2); td.remove(e); } - virtual void after_split_edge (Halfedge_handle e1, - Halfedge_handle e2) - { + virtual void after_split_edge(Halfedge_handle e1, Halfedge_handle e2) + override { //MICHAL: commented due to inefficient depth update, remove and insert instead //td.split_edge(m_cv_before_split,e1,e2); @@ -312,29 +285,20 @@ public: td.insert(e2); } - virtual void before_merge_edge (Halfedge_handle e1, - Halfedge_handle e2, - const X_monotone_curve_2& cv) - { + virtual void before_merge_edge(Halfedge_handle e1, Halfedge_handle e2, + const X_monotone_curve_2& cv) override { //save the halfedge handle for the "after" function. m_he_after_merge = e1; td.merge_edge (e1, e2, cv); } - virtual void after_merge_edge (Halfedge_handle e) - { - td.after_merge_edge(e, m_he_after_merge); - } + virtual void after_merge_edge(Halfedge_handle e) override + { td.after_merge_edge(e, m_he_after_merge); } - virtual void before_remove_edge (Halfedge_handle e) - { - //called before combinatoric deletion - td.remove(e); - } + virtual void before_remove_edge(Halfedge_handle e) override { td.remove(e); } //@} public: - //#ifdef CGAL_TD_DEBUG // void debug() // { @@ -343,27 +307,22 @@ public: //#endif protected: - /*! Construct the trapezoidal decomposition. */ - void _construct_td () - { + void _construct_td() { td.clear(); std::vector he_container; - Edge_const_iterator eit; - Halfedge_const_handle he_cst; - Arrangement_on_surface_2 *arr = this->arrangement(); + auto* arr = this->arrangement(); //collect the arrangement halfedges - for (eit = arr->edges_begin(); eit != arr->edges_end(); ++eit) - { - he_cst = eit; + for (auto eit = arr->edges_begin(); eit != arr->edges_end(); ++eit) { + Halfedge_const_handle he_cst = eit; he_container.push_back(he_cst); } //container insertion td.insert(he_container.begin(), he_container.end()); } - /*! gets the unbounded face that contains the point when the trapezoid is + /*! Obtain the unbounded face that contains the point when the trapezoid is * unbounded * \param tr The unbounded trapezoid whose face we should get * \param p The query point. @@ -371,24 +330,23 @@ protected: * \return A Face_const_handle representing the arrangement unbounded face in * which the point p lies */ - Face_const_handle _get_unbounded_face (const Td_map_item& tr, - const Point_2& p, - Arr_all_sides_oblivious_tag) const; + Face_const_handle _get_unbounded_face(const Td_map_item& tr, + const Point_2& p, + Arr_all_sides_oblivious_tag) const; - /*! gets the unbounded face that contains the point when the trapezoid is + /*! Obtain the unbounded face that contains the point when the trapezoid is * unbounded * \param tr The unbounded trapezoid whose face we should get * \param p The query point. * \param Arr_not_all_sides_oblivious_tag - * \return A Face_const_handle representing the arrangement unbounded face in which - * the point p lies + * \return A Face_const_handle representing the arrangement unbounded face in + * which the point p lies */ - Face_const_handle _get_unbounded_face (const Td_map_item& tr, - const Point_2& p, - Arr_not_all_sides_oblivious_tag) const; + Face_const_handle _get_unbounded_face(const Td_map_item& tr, + const Point_2& p, + Arr_not_all_sides_oblivious_tag) const; - /*! - * Locate the arrangement feature which a vertical ray emanating from the + /*! Locate the arrangement feature which a vertical ray emanating from the * given point hits, considering isolated vertices. * \param p The query point. * \param shoot_up Indicates whether the ray is directed upward or downward. @@ -403,11 +361,10 @@ protected: * we check the isolated vertices inside the face to check whether there * is an isolated vertex right above/below the query point. */ - result_type - _check_isolated_for_vertical_ray_shoot - (Halfedge_const_handle halfedge_found, - const Point_2& p, bool shoot_up, - const Td_map_item& tr) const; + result_type _check_isolated_for_vertical_ray_shoot + (Halfedge_const_handle halfedge_found, + const Point_2& p, bool shoot_up, + const Td_map_item& tr) const; }; } //namespace CGAL diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_triangulation_point_location.h b/Arrangement_on_surface_2/include/CGAL/Arr_triangulation_point_location.h index e3f5c3565ff..37aef38630c 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_triangulation_point_location.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_triangulation_point_location.h @@ -21,7 +21,6 @@ * Definition of the Arr_triangulation_point_location template. */ -#include #include #include @@ -39,73 +38,70 @@ namespace CGAL { * triangulation algorithm. */ template -class Arr_triangulation_point_location : public Arr_observer -{ +class Arr_triangulation_point_location : public Arrangement_::Observer { public: - typedef Arrangement_ Arrangement_2; + using Arrangement_2 = Arrangement_; + using Base_aos = typename Arrangement_2::Base_aos; - typedef typename Arrangement_2::Geometry_traits_2 Geometry_traits_2; - typedef typename Geometry_traits_2::Kernel Kernel; + using Geometry_traits_2 = typename Base_aos::Geometry_traits_2; + using Kernel = typename Geometry_traits_2::Kernel; - typedef typename Arrangement_2::Vertex_const_handle Vertex_const_handle; - typedef typename Arrangement_2::Halfedge_const_handle Halfedge_const_handle; - typedef typename Arrangement_2::Face_const_handle Face_const_handle; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; - typedef typename Arrangement_2::Halfedge_handle Halfedge_handle; - typedef typename Arrangement_2::Face_handle Face_handle; + using Vertex_const_handle = typename Base_aos::Vertex_const_handle; + using Halfedge_const_handle = typename Base_aos::Halfedge_const_handle; + using Face_const_handle = typename Base_aos::Face_const_handle; + using Vertex_handle = typename Base_aos::Vertex_handle; + using Halfedge_handle = typename Base_aos::Halfedge_handle; + using Face_handle = typename Base_aos::Face_handle; - typedef typename Arrangement_2::Vertex_const_iterator Vertex_const_iterator; - typedef typename Arrangement_2::Edge_const_iterator Edge_const_iterator; - typedef typename Arrangement_2::Face_const_iterator Face_const_iterator; - typedef typename Arrangement_2::Halfedge_const_iterator - Halfedge_const_iterator; - typedef typename Arrangement_2::Halfedge_around_vertex_const_circulator - Halfedge_around_vertex_const_circulator; - typedef typename Arrangement_2::Ccb_halfedge_const_circulator - Ccb_halfedge_const_circulator; - typedef typename Arrangement_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; - typedef typename Arrangement_2::Isolated_vertex_const_iterator - Isolated_vertex_const_iterator; + using Vertex_const_iterator = typename Base_aos::Vertex_const_iterator; + using Edge_const_iterator = typename Base_aos::Edge_const_iterator; + using Face_const_iterator = typename Base_aos::Face_const_iterator; + using Halfedge_const_iterator = typename Base_aos::Halfedge_const_iterator; + using Halfedge_around_vertex_const_circulator = + typename Base_aos::Halfedge_around_vertex_const_circulator; + using Ccb_halfedge_const_circulator = + typename Base_aos::Ccb_halfedge_const_circulator; + using Ccb_halfedge_circulator = typename Base_aos::Ccb_halfedge_circulator; + using Isolated_vertex_const_iterator = + typename Base_aos::Isolated_vertex_const_iterator; - typedef typename Geometry_traits_2::Point_2 Point_2; - typedef typename Geometry_traits_2::X_monotone_curve_2 X_monotone_curve_2; + using Point_2 = typename Geometry_traits_2::Point_2; + using X_monotone_curve_2 = typename Geometry_traits_2::X_monotone_curve_2; - typedef std::list Edge_list; - typedef typename Edge_list::iterator Std_edge_iterator; + using Edge_list = std::list; + using Std_edge_iterator = typename Edge_list::iterator; //---------------------------------------------------------- // Triangulation Types //---------------------------------------------------------- - typedef Triangulation_vertex_base_with_info_2 - Vbb; - typedef Triangulation_hierarchy_vertex_base_2 Vb; + using Vbb = Triangulation_vertex_base_with_info_2; + using Vb = Triangulation_hierarchy_vertex_base_2; //typedef Triangulation_face_base_with_info_2 Fbt; - typedef Constrained_triangulation_face_base_2 Fb; - typedef Triangulation_data_structure_2 TDS; - typedef Exact_predicates_tag Itag; + using Fb = Constrained_triangulation_face_base_2; + using TDS = Triangulation_data_structure_2; + using Itag = Exact_predicates_tag; //typedef Constrained_Delaunay_triangulation_2 CDT; - typedef Constrained_Delaunay_triangulation_2 CDT_t; - typedef Triangulation_hierarchy_2 CDTH; - typedef Constrained_triangulation_plus_2 CDT; + using CDT_t = Constrained_Delaunay_triangulation_2; + using CDTH = Triangulation_hierarchy_2; + using CDT = Constrained_triangulation_plus_2; - typedef typename CDT::Point CDT_Point; - typedef typename CDT::Edge CDT_Edge; - typedef typename CDT::Face_handle CDT_Face_handle; - typedef typename CDT::Vertex_handle CDT_Vertex_handle; - typedef typename CDT::Finite_faces_iterator CDT_Finite_faces_iterator; - typedef typename CDT::Finite_vertices_iterator CDT_Finite_vertices_iterator; - typedef typename CDT::Finite_edges_iterator CDT_Finite_edges_iterator; - typedef typename CDT::Locate_type CDT_Locate_type; + using CDT_Point = typename CDT::Point; + using CDT_Edge = typename CDT::Edge; + using CDT_Face_handle = typename CDT::Face_handle; + using CDT_Vertex_handle = typename CDT::Vertex_handle; + using CDT_Finite_faces_iterator = typename CDT::Finite_faces_iterator; + using CDT_Finite_vertices_iterator = typename CDT::Finite_vertices_iterator; + using CDT_Finite_edges_iterator = typename CDT::Finite_edges_iterator; + using CDT_Locate_type = typename CDT::Locate_type; - typedef Arr_point_location_result Result; - typedef typename Result::Type Result_type; + using Result = Arr_point_location_result; + using Result_type = typename Result::Type; // Support cpp11::result_of - typedef Result_type result_type; + using result_type = Result_type; protected: - typedef Arr_traits_basic_adaptor_2 Traits_adaptor_2; + using Traits_adaptor_2 = Arr_traits_basic_adaptor_2; // Data members: const Traits_adaptor_2* m_traits; // Its associated traits object. @@ -128,8 +124,8 @@ public: /*! Constructor from an arrangement. * \param arr (in) The arrangement. */ - Arr_triangulation_point_location(const Arrangement_2& arr) : - Arr_observer(const_cast(arr)), + Arr_triangulation_point_location(const Base_aos& arr) : + Base_aos::Observer(const_cast(arr)), m_traits(static_cast(arr.geometry_traits())), m_ignore_notifications(false), m_ignore_remove_edge(false) @@ -149,12 +145,12 @@ public: /*! Attach an arrangement. * \param arr (in) The arrangement. */ - virtual void before_attach(const Arrangement_2& arr) + virtual void before_attach(const Base_aos& arr) override { m_traits = static_cast(arr.geometry_traits()); } - virtual void after_attach() { build_triangulation(); } + virtual void after_attach() override { build_triangulation(); } - virtual void before_detach() { clear_triangulation(); } + virtual void before_detach() override { clear_triangulation(); } /// \name Overloaded observer functions on global changes. //@{ @@ -162,32 +158,28 @@ public: /*! Notification after the arrangement has been assigned with another * arrangement. */ - virtual void after_assign() - { + virtual void after_assign() override { clear_triangulation(); build_triangulation(); } /*! Notification after the arrangement is cleared. */ - virtual void after_clear() - { + virtual void after_clear() override { clear_triangulation(); build_triangulation(); } /*! Notification before a global operation modifies the arrangement. */ - virtual void before_global_change() - { + virtual void before_global_change() override { clear_triangulation(); m_ignore_notifications = true; } /*! Notification after a global operation is completed. */ - virtual void after_global_change() - { + virtual void after_global_change() override { build_triangulation(); m_ignore_notifications = false; } @@ -199,14 +191,13 @@ public: /*! Notification before the removal of an edge. * \param e (in) A handle to one of the twin halfedges to be removed. */ - virtual void before_remove_edge(Halfedge_handle /* e */) + virtual void before_remove_edge(Halfedge_handle /* e */) override { m_ignore_remove_edge = true; } /*! Notification after the creation of a new vertex. * \param v (in) A handle to the created vertex. */ - virtual void after_create_vertex(Vertex_handle /* v */) - { + virtual void after_create_vertex(Vertex_handle /* v */) override { if (! m_ignore_notifications) { clear_triangulation(); build_triangulation(); @@ -216,8 +207,7 @@ public: /*! Notification after the creation of a new edge. * \param e (in) A handle to one of the twin halfedges that were created. */ - virtual void after_create_edge(Halfedge_handle /* e */) - { + virtual void after_create_edge(Halfedge_handle /* e */) override { if (! m_ignore_notifications) { clear_triangulation(); build_triangulation(); @@ -229,8 +219,7 @@ public: * \param e2 (in) A handle to one of the twin halfedges forming the second edge. */ virtual void after_split_edge(Halfedge_handle /* e1 */, - Halfedge_handle /* e2 */) - { + Halfedge_handle /* e2 */) override { if (! m_ignore_notifications) { clear_triangulation(); build_triangulation(); @@ -244,8 +233,7 @@ public: */ virtual void after_split_face(Face_handle /* f */, Face_handle /* new_f */, - bool /* is_hole */) - { + bool /* is_hole */) override { if (! m_ignore_notifications) { clear_triangulation(); build_triangulation(); @@ -255,8 +243,7 @@ public: /*! Notification after an outer CCB was created inside a face. * \param h (in) A circulator representing the boundary of the new outer CCB. */ - virtual void after_add_outer_ccb(Ccb_halfedge_circulator /* h */) - { + virtual void after_add_outer_ccb(Ccb_halfedge_circulator /* h */) override { if (! m_ignore_notifications) { clear_triangulation(); build_triangulation(); @@ -266,8 +253,7 @@ public: /*! Notification after an edge was merged. * \param e (in) A handle to one of the twin halfedges forming the merged edge. */ - virtual void after_merge_edge(Halfedge_handle /* e */) - { + virtual void after_merge_edge(Halfedge_handle /* e */) override { if (! m_ignore_notifications) { clear_triangulation(); build_triangulation(); @@ -277,8 +263,7 @@ public: /*! Notification after a face was merged. * \param f (in) A handle to the merged face. */ - virtual void after_merge_face(Face_handle /* f */) - { + virtual void after_merge_face(Face_handle /* f */) override { if (! m_ignore_notifications && ! m_ignore_remove_edge) { clear_triangulation(); build_triangulation(); @@ -288,8 +273,7 @@ public: /*! Notification after an outer CCB is moved from one face to another. * \param h (in) A circulator representing the boundary of the component. */ - virtual void after_move_outer_ccb(Ccb_halfedge_circulator /* h */) - { + virtual void after_move_outer_ccb(Ccb_halfedge_circulator /* h */) override { if (! m_ignore_notifications) { clear_triangulation(); build_triangulation(); @@ -299,8 +283,7 @@ public: /*! Notificaion before the removal of a vertex. * \param v (in) A handle to the vertex to be deleted. */ - virtual void after_remove_vertex() - { + virtual void after_remove_vertex() override { if (! m_ignore_notifications && ! m_ignore_remove_edge) { clear_triangulation(); build_triangulation(); @@ -310,8 +293,7 @@ public: /*! Notification before the removal of an edge. * \param e (in) A handle to one of the twin halfedges to be deleted. */ - virtual void after_remove_edge() - { + virtual void after_remove_edge() override { if (! m_ignore_notifications) { clear_triangulation(); build_triangulation(); @@ -322,8 +304,7 @@ public: /*! Notification before the removal of an outer CCB. * \param f (in) The face that used to own the outer CCB. */ - virtual void after_remove_outer_ccb(Face_handle /* f */) - { + virtual void after_remove_outer_ccb(Face_handle /* f */) override { if (! m_ignore_notifications && ! m_ignore_remove_edge) { clear_triangulation(); build_triangulation(); @@ -333,8 +314,7 @@ public: /*! Notification after an inner CCB was created inside a face. * \param h (in) A circulator representing the boundary of the new inner CCB. */ - virtual void after_add_inner_ccb(Ccb_halfedge_circulator /* h */) - { + virtual void after_add_inner_ccb(Ccb_halfedge_circulator /* h */) override { if (! m_ignore_notifications) { clear_triangulation(); build_triangulation(); @@ -344,8 +324,7 @@ public: /*! Notification after an inner CCB is moved from one face to another. * \param h (in) A circulator representing the boundary of the component. */ - virtual void after_move_inner_ccb(Ccb_halfedge_circulator /* h */) - { + virtual void after_move_inner_ccb(Ccb_halfedge_circulator /* h */) override { if (! m_ignore_notifications) { clear_triangulation(); build_triangulation(); @@ -355,8 +334,7 @@ public: /*! Notificaion after the removal of an inner CCB. * \param f (in) The face that used to contain the inner CCB. */ - virtual void after_remove_inner_ccb(Face_handle /* f */) - { + virtual void after_remove_inner_ccb(Face_handle /* f */) override { if (! m_ignore_notifications && ! m_ignore_remove_edge) { clear_triangulation(); build_triangulation(); diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_unb_planar_topology_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_unb_planar_topology_traits_2.h index 58558968882..664aa1a4864 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_unb_planar_topology_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_unb_planar_topology_traits_2.h @@ -23,6 +23,7 @@ */ #include +#include #include #include #include diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_vertex_index_map.h b/Arrangement_on_surface_2/include/CGAL/Arr_vertex_index_map.h index ac6902cc9e2..a9682dc5bad 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_vertex_index_map.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_vertex_index_map.h @@ -22,7 +22,6 @@ /*! \file * Definition of the Arr_vertex_index_map class. */ -#include #include #include @@ -35,136 +34,120 @@ namespace CGAL { * arrangement vertices to the indices 0, ..., (n -1), where n is the number * of vertices in the arrangement. */ -template -class Arr_vertex_index_map : public Arr_observer -{ +template +class Arr_vertex_index_map : public Arrangement_::Observer { public: + using Arrangement_2 = Arrangement_; + using Base_aos = typename Arrangement_2::Base_aos; - typedef Arrangement_ Arrangement_2; - typedef typename Arrangement_2::Vertex_handle Vertex_handle; + using Vertex_handle = typename Base_aos::Vertex_handle; // Boost property type definitions: - typedef boost::readable_property_map_tag category; - typedef unsigned int value_type; - typedef value_type reference; - typedef Vertex_handle key_type; + using category = boost::readable_property_map_tag; + using value_type = unsigned int; + using reference = value_type; + using key_type = Vertex_handle; private: + using Self = Arr_vertex_index_map; + using Base = typename Arrangement_2::Observer; - typedef Arr_vertex_index_map Self; - typedef Arr_observer Base; - - typedef Unique_hash_map Index_map; + using Index_map = Unique_hash_map; // Data members: - unsigned int n_vertices; // The current number of vertices. - Index_map index_map; // Mapping vertices to indices. - std::vector rev_map; // Mapping indices to vertices. + unsigned int n_vertices; // The current number of vertices. + Index_map index_map; // Mapping vertices to indices. + std::vector rev_map; // Mapping indices to vertices. enum {MIN_REV_MAP_SIZE = 32}; public: - /*! Default constructor. */ - Arr_vertex_index_map () : - Base (), - n_vertices (0), - rev_map (MIN_REV_MAP_SIZE) + Arr_vertex_index_map() : + Base(), + n_vertices(0), + rev_map(MIN_REV_MAP_SIZE) {} /*! Constructor with an associated arrangement. */ - Arr_vertex_index_map (const Arrangement_2& arr) : - Base (const_cast (arr)) - { - _init(); - } + Arr_vertex_index_map(const Base_aos& arr) : + Base(const_cast(arr)) + { _init(); } /*! Copy constructor. */ - Arr_vertex_index_map (const Self& other) : - Base (const_cast (*(other.arrangement()))) - { - _init(); - } + Arr_vertex_index_map(const Self& other) : + Base(const_cast(*(other.arrangement()))) + { _init(); } /*! Assignment operator. */ - Self& operator= (const Self& other) - { - if (this == &other) - return (*this); + Self& operator= (const Self& other) { + if (this == &other) return (*this); this->detach(); - this->attach (const_cast (*(other.arrangement()))); + this->attach(const_cast(*(other.arrangement()))); return (*this); } - /*! - * Get the index of a given vertex. + /*! Get the index of a given vertex. * \param v A handle to the vertex. * \pre v is a valid vertex in the arrangement. */ - unsigned int operator[] (Vertex_handle v) const - { - return index_map[v]; - } + unsigned int operator[](Vertex_handle v) const { return index_map[v]; } - /*! - * Get the vertex given its index. + /*! Get the vertex given its index. * \param i The index of the vertex. * \pre i is less than the number of vertices in the graph. */ - Vertex_handle vertex (const int i) const - { - CGAL_precondition (i < n_vertices); - + Vertex_handle vertex(const int i) const { + CGAL_precondition(i < n_vertices); return rev_map[i]; } /// \name Notification functions, to keep the mapping up-to-date. //@{ - /*! - * Update the mapping after the arrangement has been assigned with another + /*! Update the mapping after the arrangement has been assigned with another * arrangement. */ - virtual void after_assign () - { - _init(); - } + virtual void after_assign() override { _init(); } - /*! - * Update the mapping after the arrangement is cleared. + /*! Update the mapping after the arrangement is cleared. */ - virtual void after_clear () - { - _init(); - } + virtual void after_clear() override { _init(); } - /*! - * Update the mapping after attaching to a new arrangement. + /*! Update the mapping after attaching to a new arrangement. */ - virtual void after_attach () - { - _init(); - } + virtual void after_attach() override { _init(); } - /*! - * Update the mapping after detaching the arrangement. + /*! Update the mapping after detaching the arrangement. */ - virtual void after_detach () - { + virtual void after_detach() override { n_vertices = 0; index_map.clear(); } - /*! - * Update the mapping after the creation of a new vertex. + /*! Update the mapping after the creation of a new vertex. * \param v A handle to the created vertex. */ - virtual void after_create_vertex (Vertex_handle v) - { + virtual void after_create_vertex(Vertex_handle v) override { // Update the number of vertices. - n_vertices++; + ++n_vertices; + + // If necessary, allocate memory for the reverse mapping. + if (rev_map.size() < n_vertices) rev_map.resize(2 * n_vertices); + + // Update the mapping of the newly created vertex. + index_map[v] = n_vertices - 1; + rev_map[n_vertices - 1] = v; + } + + /*! Update the mapping after the creation of a new boundary vertex. + * \param v A handle to the created vertex. + */ + virtual void after_create_boundary_vertex(Vertex_handle v) override { + // Update the number of vertices. + ++n_vertices; // If necessary, allocate memory for the reverse mapping. if (rev_map.size() < n_vertices) @@ -175,49 +158,28 @@ public: rev_map[n_vertices - 1] = v; } - /*! - * Update the mapping after the creation of a new boundary vertex. - * \param v A handle to the created vertex. - */ - virtual void after_create_boundary_vertex (Vertex_handle v) - { - // Update the number of vertices. - n_vertices++; - - // If necessary, allocate memory for the reverse mapping. - if (rev_map.size() < n_vertices) - rev_map.resize (2 * n_vertices); - - // Update the mapping of the newly created vertex. - index_map[v] = n_vertices - 1; - rev_map[n_vertices - 1] = v; - } - - /*! - * Update the mapping before the removal of a vertex. + /*! Update the mapping before the removal of a vertex. * \param v A handle to the vertex to be removed. */ - virtual void before_remove_vertex (Vertex_handle v) - { + virtual void before_remove_vertex(Vertex_handle v) override { // Update the number of vertices. - n_vertices--; + --n_vertices; // Reduce memory consumption in case the number of vertices has // drastically decreased. if (2*n_vertices+1 < rev_map.size() && rev_map.size() / 2 >= MIN_REV_MAP_SIZE) { - rev_map.resize (rev_map.size() / 2); + rev_map.resize(rev_map.size() / 2); } // Get the current vertex index, and assign this index to the vertex // currently indexed (n - 1). - unsigned int index = index_map[v]; + unsigned int index = index_map[v]; - if (index == n_vertices) - return; + if (index == n_vertices) return; - Vertex_handle last_v = rev_map[n_vertices]; + Vertex_handle last_v = rev_map[n_vertices]; index_map[last_v] = index; rev_map[index] = last_v; @@ -227,51 +189,42 @@ public: //@} private: - /*! Initialize the map for the given arrangement. */ - void _init () - { + void _init() { // Get the number of vertices and allocate the reverse map accordingly. - n_vertices = static_cast(this->arrangement()->number_of_vertices()); + n_vertices = + static_cast(this->arrangement()->number_of_vertices()); - if (n_vertices < MIN_REV_MAP_SIZE) - rev_map.resize (MIN_REV_MAP_SIZE); - else - rev_map.resize (n_vertices); + if (n_vertices < MIN_REV_MAP_SIZE) rev_map.resize (MIN_REV_MAP_SIZE); + else rev_map.resize (n_vertices); // Clear the current mapping. index_map.clear(); // Create the initial mapping. - typename Arrangement_2::Vertex_iterator vit; - Vertex_handle vh; - unsigned int index = 0; + Vertex_handle vh; + unsigned int index = 0; - for (vit = this->arrangement()->vertices_begin(); - vit != this->arrangement()->vertices_end(); ++vit, ++index) - { + for (auto vit = this->arrangement()->vertices_begin(); + vit != this->arrangement()->vertices_end(); ++vit, ++index) { // Map the current vertex to the current index. vh = vit; index_map[vh] = index; rev_map[index] = vh; } } - }; -/*! - * Get the index property-map function. Provided so that boost is able to +/*! Get the index property-map function. Provided so that boost is able to * access the Arr_vertex_index_map above. * \param index_map The index map. * \param v A vertex handle. * \return The vertex index. */ -template -unsigned int get (const CGAL::Arr_vertex_index_map& index_map, - typename Arrangement::Vertex_handle v) -{ - return index_map[v]; -} +template +unsigned int get(const CGAL::Arr_vertex_index_map& index_map, + typename Arrangement::Vertex_handle v) +{ return index_map[v]; } } //namespace CGAL diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_2.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_2.h index 5ff66d78b30..dbeab324b12 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_2.h @@ -25,6 +25,7 @@ #include #include #include +#include namespace CGAL { @@ -115,12 +116,9 @@ public: typedef typename Base::Inner_ccb_const_iterator Hole_const_iterator; private: - - friend class Arr_observer; friend class Arr_accessor; public: - /// \name Constructors. //@{ @@ -215,34 +213,6 @@ public: } //@} - -protected: - - /// \name Managing and notifying the arrangement observers. - //@{ - typedef Arr_observer Observer; - - /*! - * Register a new observer (so it starts receiving notifications). - * \param p_obs A pointer to the observer object. - */ - void _register_observer (Observer *p_obs) - { - Base::_register_observer ((typename Base::Observer*)p_obs); - return; - } - - /*! - * Unregister a new observer (so it stops receiving notifications). - * \param p_obs A pointer to the observer object. - * \return Whether the observer was successfully unregistered. - */ - bool _unregister_observer (Observer *p_obs) - { - return (Base::_unregister_observer ((typename Base::Observer*)p_obs)); - } - //@} - }; } //namespace CGAL diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_on_surface_with_history_2_impl.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_on_surface_with_history_2_impl.h index b60f198906f..8c63a3344c1 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_on_surface_with_history_2_impl.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_on_surface_with_history_2_impl.h @@ -273,29 +273,6 @@ bool Arrangement_on_surface_with_history_2::are_mergeable e2->curve())); } -//----------------------------------------------------------------------------- -// Register a new observer (so it starts receiving notifications). -// -template -void Arrangement_on_surface_with_history_2:: -_register_observer(Arr_observer *p_obs) -{ - Base_arr_2::_register_observer - (reinterpret_cast*>(p_obs)); - return; -} - -//----------------------------------------------------------------------------- -// Unregister an observer (so it stops receiving notifications). -// -template -bool Arrangement_on_surface_with_history_2:: -_unregister_observer(Arr_observer *p_obs) -{ - return (Base_arr_2::_unregister_observer - (reinterpret_cast*>(p_obs))); -} - } //namespace CGAL #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_traits_adaptor_2.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_traits_adaptor_2.h index 8f88642aed8..0bcc3f633a5 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_traits_adaptor_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arr_traits_adaptor_2.h @@ -577,7 +577,7 @@ public: return (m_self->compare_y_at_x_right_2_object()(xcv1, xcv2, left1)); } - // We now that the curves do not share a common endpoint, and we can + // We know that the curves do not share a common endpoint, and we can // compare their relative y-position (which does not change to the left // of the given point p). return (m_self->compare_y_position_2_object()(xcv1, xcv2)); diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h index ae87c8ddb28..35c1c0ebcb8 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h @@ -39,11 +39,11 @@ #include #include #include -#include -#include +#include #include #include #include +#include #include #include #include @@ -109,8 +109,11 @@ public: typedef typename Topology_traits::Dcel Dcel; typedef typename Dcel::Size Size; + using Observer = Aos_observer; + using Base_aos = Self; + protected: - friend class Arr_observer; + friend class Aos_observer; friend class Arr_accessor; // Internal DCEL types: @@ -892,7 +895,6 @@ protected: typedef CGAL_ALLOCATOR(Point_2) Points_alloc; typedef CGAL_ALLOCATOR(X_monotone_curve_2) Curves_alloc; - typedef Arr_observer Observer; typedef std::list Observers_container; typedef typename Observers_container::iterator Observers_iterator; diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_with_history_2.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_with_history_2.h index af560449961..34855a735c8 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_with_history_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_with_history_2.h @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -75,10 +74,7 @@ public: typedef typename Geometry_traits_2::Curve_2 Curve_2; typedef typename Geometry_traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef Arr_observer Observer; - protected: - friend class Arr_observer; friend class Arr_accessor; friend class Arr_with_history_accessor; @@ -170,104 +166,75 @@ protected: // Forward declaration: class Curve_halfedges_observer; +public: /*! \class * Extension of a curve with the set of edges that it induces. * Each edge is represented by one of the halfedges. */ class Curve_halfedges : public Curve_2, - public In_place_list_base - { + public In_place_list_base { + using Gt = Geometry_traits_2; + using Btt = Base_topology_traits; + using Aos_wh = Arrangement_on_surface_with_history_2; + friend class Curve_halfedges_observer; - friend class Arrangement_on_surface_with_history_2; - friend class Arr_with_history_accessor< - Arrangement_on_surface_with_history_2 >; + friend class Arrangement_on_surface_with_history_2; + friend class Arr_with_history_accessor; private: - typedef std::set Halfedges_set; + using Halfedges_set = std::set; // Data members: Halfedges_set m_halfedges; public: /*! Default constructor. */ - Curve_halfedges () - {} + Curve_halfedges() {} /*! Constructor from a given curve. */ - Curve_halfedges (const Curve_2& curve) : - Curve_2(curve) - {} + Curve_halfedges(const Curve_2& curve) : Curve_2(curve) {} - typedef typename Halfedges_set::iterator iterator; - typedef typename Halfedges_set::const_iterator const_iterator; + using iterator = typename Halfedges_set::iterator; + using const_iterator = typename Halfedges_set::const_iterator; private: - /*! Get the number of edges induced by the curve. */ - Size _size () const - { - return (m_halfedges.size()); - } + Size size() const { return m_halfedges.size(); } /*! Get an iterator for the first edge in the set (const version). */ - const_iterator _begin () const - { - return m_halfedges.begin(); - } + const_iterator begin() const { return m_halfedges.begin(); } /*! Get an iterator for the first edge in the set (non-const version). */ - iterator _begin () - { - return m_halfedges.begin(); - } + iterator begin() { return m_halfedges.begin(); } /*! Get a past-the-end iterator for the set edges (const version). */ - const_iterator _end () const - { - return m_halfedges.end(); - } + const_iterator end() const { return m_halfedges.end(); } /*! Get a past-the-end iterator for the set edges (non-const version). */ - iterator _end () - { - return m_halfedges.end(); - } + iterator end() { return m_halfedges.end(); } /*! Insert an edge to the set. */ - iterator _insert (Halfedge_handle he) - { + iterator _insert(Halfedge_handle he) { std::pair res = m_halfedges.insert(he); CGAL_assertion(res.second); - return (res.first); + return res.first; } /*! Erase an edge, given by its position, from the set. */ - void _erase(iterator pos) - { - m_halfedges.erase(pos); - return; - } + void erase(iterator pos) { m_halfedges.erase(pos); } /*! Erase an edge from the set. */ - void _erase (Halfedge_handle he) - { + void _erase(Halfedge_handle he) { size_t res = m_halfedges.erase(he); - if (res == 0) - res = m_halfedges.erase(he->twin()); + if (res == 0) res = m_halfedges.erase(he->twin()); CGAL_assertion(res != 0); - return; } /*! Cleat the edges set. */ - void _clear () - { - m_halfedges.clear(); - return; - } + void clear() { m_halfedges.clear(); } }; +protected: typedef CGAL_ALLOCATOR(Curve_halfedges) Curves_alloc; typedef In_place_list Curve_halfedges_list; @@ -276,111 +243,87 @@ protected: * involving edges and updates the list of halfedges associated with the * input curves accordingly. */ - class Curve_halfedges_observer : public Arr_observer { + class Curve_halfedges_observer : public Base_arr_2::Observer { public: + using Base_aos = typename Base_arr_2::Base_aos; - typedef typename Base_arr_2::Halfedge_handle Halfedge_handle; - typedef typename Base_arr_2::Vertex_handle Vertex_handle; - typedef typename Base_arr_2::X_monotone_curve_2 X_monotone_curve_2; + using Vertex_handle = typename Base_aos::Vertex_handle; + using Halfedge_handle = typename Base_aos::Halfedge_handle; + using X_monotone_curve_2 = typename Base_aos::X_monotone_curve_2; - /*! - * Notification after the creation of a new edge. + /*! Notification after the creation of a new edge. * \param e A handle to one of the twin halfedges that were created. */ - virtual void after_create_edge (Halfedge_handle e) - { - _register_edge(e); - } + virtual void after_create_edge(Halfedge_handle e) override + { _register_edge(e); } /*! * Notification before the modification of an existing edge. * \param e A handle to one of the twin halfedges to be updated. * \param c The x-monotone curve to be associated with the edge. */ - virtual void before_modify_edge (Halfedge_handle e, - const X_monotone_curve_2& /* c */) - { - _unregister_edge(e); - } + virtual void before_modify_edge(Halfedge_handle e, + const X_monotone_curve_2& /* c */) override + { _unregister_edge(e); } - /*! - * Notification after an edge was modified. + /*! Notification after an edge was modified. * \param e A handle to one of the twin halfedges that were updated. */ - virtual void after_modify_edge (Halfedge_handle e) - { - _register_edge(e); - } + virtual void after_modify_edge(Halfedge_handle e) override + { _register_edge(e); } - /*! - * Notification before the splitting of an edge into two. + /*! Notification before the splitting of an edge into two. * \param e A handle to one of the existing halfedges. * \param c1 The x-monotone curve to be associated with the first edge. * \param c2 The x-monotone curve to be associated with the second edge. */ - virtual void before_split_edge (Halfedge_handle e, - Vertex_handle /* v */, - const X_monotone_curve_2& /* c1 */, - const X_monotone_curve_2& /* c2 */) - { - _unregister_edge(e); - } + virtual void before_split_edge(Halfedge_handle e, + Vertex_handle /* v */, + const X_monotone_curve_2& /* c1 */, + const X_monotone_curve_2& /* c2 */) override + { _unregister_edge(e); } - /*! - * Notification after an edge was split. + /*! Notification after an edge was split. * \param e1 A handle to one of the twin halfedges forming the first edge. * \param e2 A handle to one of the twin halfedges forming the second edge. */ - virtual void after_split_edge (Halfedge_handle e1, Halfedge_handle e2) - { + virtual void after_split_edge(Halfedge_handle e1, Halfedge_handle e2) + override { _register_edge(e1); _register_edge(e2); } - /*! - * Notification before the merging of two edges. + /*! Notification before the merging of two edges. * \param e1 A handle to one of the halfedges forming the first edge. * \param e2 A handle to one of the halfedges forming the second edge. * \param c The x-monotone curve to be associated with the merged edge. */ - virtual void before_merge_edge (Halfedge_handle e1, Halfedge_handle e2, - const X_monotone_curve_2& /* c */) - { + virtual void before_merge_edge(Halfedge_handle e1, Halfedge_handle e2, + const X_monotone_curve_2& /* c */) override { _unregister_edge(e1); _unregister_edge(e2); } - /*! - * Notification after an edge was merged. + /*! Notification after an edge was merged. * \param e A handle to one of the twin halfedges forming the merged edge. */ - virtual void after_merge_edge (Halfedge_handle e) - { - _register_edge(e); - } + virtual void after_merge_edge(Halfedge_handle e) override + { _register_edge(e); } - /*! - * Notification before the removal of an edge. + /*! Notification before the removal of an edge. * \param e A handle to one of the twin halfedges to be deleted. */ - virtual void before_remove_edge (Halfedge_handle e) - { - _unregister_edge(e); - } + virtual void before_remove_edge(Halfedge_handle e) override + { _unregister_edge(e); } private: - /*! - * Register the given halfedge in the set(s) associated with its curve. + /*! Register the given halfedge in the set(s) associated with its curve. */ - void _register_edge (Halfedge_handle e) - { - Curve_halfedges *curve_halfedges; - Data_iterator di; - - for (di = e->curve().data().begin(); di != e->curve().data().end(); ++di) - { - curve_halfedges = static_cast(*di); + void _register_edge(Halfedge_handle e) { + for (auto di = e->curve().data().begin(); di != e->curve().data().end(); + ++di) { + Curve_halfedges* curve_halfedges = static_cast(*di); curve_halfedges->_insert(e); } } @@ -388,14 +331,10 @@ protected: /*! * Unregister the given halfedge from the set(s) associated with its curve. */ - void _unregister_edge (Halfedge_handle e) - { - Curve_halfedges *curve_halfedges; - Data_iterator di; - - for (di = e->curve().data().begin(); di != e->curve().data().end(); ++di) - { - curve_halfedges = static_cast(*di); + void _unregister_edge(Halfedge_handle e) { + for (auto di = e->curve().data().begin(); di != e->curve().data().end(); + ++di) { + Curve_halfedges* curve_halfedges = static_cast(*di); curve_halfedges->_erase(e); } } @@ -537,16 +476,13 @@ public: /// \name Traversal of the edges induced by a curve. //@{ - Size number_of_induced_edges (Curve_const_handle c) const - { - return (c->_size()); - } + Size number_of_induced_edges (Curve_const_handle c) const { return c->size(); } Induced_edge_iterator - induced_edges_begin (Curve_const_handle c) const { return (c->_begin()); } + induced_edges_begin (Curve_const_handle c) const { return (c->begin()); } Induced_edge_iterator - induced_edges_end (Curve_const_handle c) const { return (c->_end()); } + induced_edges_end (Curve_const_handle c) const { return (c->end()); } //@} /// \name Manipulating edges. @@ -582,24 +518,6 @@ public: //@} protected: - - /// \name Managing and notifying the arrangement observers. - //@{ - - /*! - * Register a new observer (so it starts receiving notifications). - * \param p_obs A pointer to the observer object. - */ - void _register_observer (Observer *p_obs); - - /*! - * Unregister an observer (so it stops receiving notifications). - * \param p_obs A pointer to the observer object. - * \return Whether the observer was successfully unregistered. - */ - bool _unregister_observer (Observer *p_obs); - //@} - /// \name Curve insertion and deletion. //@{ @@ -696,12 +614,12 @@ protected: Size _remove_curve (Curve_handle ch) { // Go over all edges the given curve induces. - Curve_halfedges *p_cv = &(*ch); - typename Curve_halfedges::const_iterator it = ch->_begin(); - Halfedge_handle he; - Size n_removed = 0; + Curve_halfedges* p_cv = &(*ch); + Halfedge_handle he; + Size n_removed = 0; - while (it != ch->_end()) { + typename Curve_halfedges::const_iterator it = ch->begin(); + while (it != ch->end()) { // Check how many curves have originated the current edge. // Note we increment the iterator now, as the edge may be removed. he = *it; diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_with_history_2.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_with_history_2.h index 134c2f0c20e..010fa182c00 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_with_history_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_with_history_2.h @@ -9,6 +9,7 @@ // // // Author(s): Ron Wein +// Efi Fogel #ifndef CGAL_ARRANGEMENT_WITH_HISTORY_2_H #define CGAL_ARRANGEMENT_WITH_HISTORY_2_H @@ -23,6 +24,7 @@ #include #include +#include namespace CGAL { @@ -119,7 +121,6 @@ public: private: typedef Arrangement_with_history_2 Self; - friend class Arr_observer; friend class Arr_accessor; public: @@ -233,35 +234,8 @@ public: return (Face_const_handle (p_oc->face())); } + //@} - -protected: - - /// \name Managing and notifying the arrangement observers. - //@{ - typedef Arr_observer Observer; - - /*! - * Register a new observer (so it starts receiving notifications). - * \param p_obs A pointer to the observer object. - */ - void _register_observer (Observer *p_obs) - { - Base::_register_observer ((typename Base::Observer*)p_obs); - return; - } - - /*! - * Unregister a new observer (so it stops receiving notifications). - * \param p_obs A pointer to the observer object. - * \return Whether the observer was successfully unregistered. - */ - bool _unregister_observer (Observer *p_obs) - { - return (Base::_unregister_observer ((typename Base::Observer*)p_obs)); - } - //@} - }; } //namespace CGAL diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Arc_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Arc_2.h index 8766eac294d..c7a47a2c1b2 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Arc_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Arc_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Eric Berberich // Pavel Emeliyanenko @@ -13,6 +13,9 @@ #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_ARC_2_H #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_ARC_2_H +#include + + /*!\file include/CGAL/Curved_kernel_via_analysis_2/Arc_2.h *\brief defines class \c Arc_2 that represents an arc on a curve that * can be analyzed. diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curve_interval_arcno_cache.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curve_interval_arcno_cache.h index 7a8cf2840bf..36152129a94 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curve_interval_arcno_cache.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curve_interval_arcno_cache.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Pavel Emeliyanenko @@ -13,6 +13,9 @@ #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_CURVE_INTERVAL_ARCNO_CACHE_H #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_CURVE_INTERVAL_ARCNO_CACHE_H +#include + + /*!\file include/CGAL/Curved_kernel_via_analysis_2/Curve_interval_arcno_cache.h * \brief defines \c Curve_interval_arcno_cache functor */ diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curve_renderer_facade.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curve_renderer_facade.h index 3bb749b395c..dc31345cf8c 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curve_renderer_facade.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curve_renderer_facade.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Pavel Emeliyanenko // @@ -21,6 +21,9 @@ #ifndef CGAL_CKVA_CURVE_RENDERER_FACADE_H #define CGAL_CKVA_CURVE_RENDERER_FACADE_H +#include + + // do not compile curve renderer code (for fast debugging) //#define CGAL_CKVA_DUMMY_RENDERER diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_functors.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_functors.h index 8fe1efa48c7..7087285e754 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_functors.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_functors.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Eric Berberich @@ -14,6 +14,9 @@ #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_FUNCTORS_H #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_FUNCTORS_H +#include + + /*!\file include/CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_functors.h * \brief defines Curved_kernel_via_analysis_2 function objects + class */ diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_impl.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_impl.h index 66f20cccf09..cbc2a9ad81a 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_impl.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Curved_kernel_via_analysis_2_impl.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Eric Berberich @@ -14,6 +14,9 @@ #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_IMPL_H #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_IMPL_H +#include + + /*!\file include/CGAL/Curved_kernel_via_analysis_2.h * \brief defines class \c Curved_kernel_via_analysis_2 * diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Filtered_curved_kernel_via_analysis_2_impl.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Filtered_curved_kernel_via_analysis_2_impl.h index 45bb19fa558..34eb19ae4b2 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Filtered_curved_kernel_via_analysis_2_impl.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Filtered_curved_kernel_via_analysis_2_impl.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Eric Berberich @@ -15,6 +15,9 @@ #ifndef CGAL_FILTERED_CURVED_KERNEL_VIA_ANALYSIS_2_IMPL_H #define CGAL_FILTERED_CURVED_KERNEL_VIA_ANALYSIS_2_IMPL_H +#include + + /*!\file include/CGAL/Filtered_curved_kernel_via_analysis_2.h * \brief defines class \c Filtered_curved_kernel_via_analysis_2 * diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Generic_arc_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Generic_arc_2.h index 06ec76eb58f..d0f318f0fa6 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Generic_arc_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Generic_arc_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Pavel Emeliyanenko @@ -14,6 +14,9 @@ #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_GENERIC_ARC_2_H #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_GENERIC_ARC_2_H +#include + + /*!\file include/CGAL/Curved_kernel_via_analysis_2/Generic_arc_2.h * \brief defines class \c Generic_arc_2 * diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Generic_point_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Generic_point_2.h index c465cae0300..b13e3cd0da4 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Generic_point_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Generic_point_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Pavel Emeliyanenko @@ -13,6 +13,9 @@ #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_GENERIC_POINT_2_H #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_GENERIC_POINT_2_H +#include + + /*!\file include/CGAL/Curved_kernel_via_analysis_2/Generic_point_2.h * \brief defines class \c Generic_point_2 * diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Make_x_monotone_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Make_x_monotone_2.h index aae3aea01e9..0b495e31bc2 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Make_x_monotone_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Make_x_monotone_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Eric Berberich @@ -17,6 +17,9 @@ #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_MAKE_X_MONOTONE_2_H #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_MAKE_X_MONOTONE_2_H +#include + + /*!\file include/CGAL/Curved_kernel_via_analysis_2/Make_x_monotone_2.h * \brief defines \c Make_x_monotone_2 functor */ diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Non_x_monotone_arc_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Non_x_monotone_arc_2.h index d2cae5964bf..9e95d7de5fb 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Non_x_monotone_arc_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Non_x_monotone_arc_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Pavel Emeliyanenko @@ -13,6 +13,9 @@ #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_NON_X_MONOTONE_ARC_2_H #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_NON_X_MONOTONE_ARC_2_H +#include + + /*!\file include/CGAL/Curved_kernel_via_analysis_2/Non_x_monotone_arc_2.h * \brief defines class \c Non_x_monotone_arc_2 * diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Point_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Point_2.h index f64c67b70ea..f2c5c1bec8a 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Point_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Point_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Eric Berberich @@ -14,6 +14,9 @@ #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_POINT_2_H #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_POINT_2_H +#include + + /*!\file include/CGAL/Curved_kernel_via_analysis_2/Point_2.h * \brief defines class \c Point_2 that represents a point on a curve that can * be analyzed. diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Sweep_curves_adapter_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Sweep_curves_adapter_2.h index 018992c467b..9576806a1b3 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Sweep_curves_adapter_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/Sweep_curves_adapter_2.h @@ -5,13 +5,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Pavel Emeliyanenko #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_SWEEP_CURVES_ADAPTER_2_H -#define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_SWEEP_CURVES_ADAPTER_2_H 1 +#define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_SWEEP_CURVES_ADAPTER_2_H + +#include + /*!\file include/CGAL/Curved_kernel_via_analysis_2/Sweep_curves_adapter_2.h * \brief defines class \c Sweep_curves_adapter_2 diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_2.h index 32d3d4cc849..fcf022620d9 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Pavel Emeliyanenko // @@ -19,6 +19,9 @@ #ifndef CGAL_CKVA_CURVE_RENDERER_2_H #define CGAL_CKVA_CURVE_RENDERER_2_H +#include + + #ifndef CGAL_AK_ENABLE_DEPRECATED_INTERFACE #define CGAL_AK_ENABLE_DEPRECATED_INTERFACE 1 #endif diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_internals.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_internals.h index c0c62a2ad88..636b7919b33 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_internals.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_internals.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Pavel Emeliyanenko // @@ -22,7 +22,10 @@ */ #ifndef CGAL_CKVA_CURVE_RENDERER_INTERNALS_H -#define CGAL_CKVA_CURVE_RENDERER_INTERNALS_H 1 +#define CGAL_CKVA_CURVE_RENDERER_INTERNALS_H + +#include + #include #include @@ -88,8 +91,6 @@ struct Pixel_2_ Integer sub_x, sub_y; // subpixel coordinates relative to pixel's boundary // (always 0 for pixels) - Pixel_2_& operator =(const Pixel_2_& pix) = default; - bool operator ==(const Pixel_2_& pix) const { return ( x == pix.x && y == pix.y && level == pix.level && diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h index 32e108b71c0..5300354df86 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Curve_renderer_traits.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Pavel Emeliyanenko // @@ -14,6 +14,9 @@ #ifndef CGAL_CKVA_CURVE_RENDERER_TRAITS_H #define CGAL_CKVA_CURVE_RENDERER_TRAITS_H +#include + + #include #include diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Subdivision_1.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Subdivision_1.h index 395b44a9f11..078b7df5b8e 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Subdivision_1.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Subdivision_1.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Pavel Emeliyanenko // @@ -17,7 +17,10 @@ */ #ifndef CGAL_CKVA_SUBDIVISION_1_H -#define CGAL_CKVA_SUBDIVISION_1_H 1 +#define CGAL_CKVA_SUBDIVISION_1_H + +#include + #include #include diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Subdivision_2.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Subdivision_2.h index 9358316c0b8..5a70721c609 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Subdivision_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/gfx/Subdivision_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Pavel Emeliyanenko // @@ -17,7 +17,10 @@ */ #ifndef CGAL_CKVA_SUBDIVISION_2_H -#define CGAL_CKVA_SUBDIVISION_2_H 1 +#define CGAL_CKVA_SUBDIVISION_2_H + +#include + #warning this file is considered obsolete diff --git a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/test/simple_models.h b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/test/simple_models.h index 201bfc19b4b..c81fd5b93bd 100644 --- a/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/test/simple_models.h +++ b/Arrangement_on_surface_2/include/CGAL/Curved_kernel_via_analysis_2/test/simple_models.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Pavel Emeliyanenko @@ -13,6 +13,9 @@ #ifndef CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_TEST_SIMPLE_MODELS_H #define CGAL_CURVED_KERNEL_VIA_ANALYSIS_2_TEST_SIMPLE_MODELS_H +#include + + /*!\file include/CGAL/Curved_kernel_via_analysis_2/test/simple_models.h * \brief defines dummy implementations satisfying Curve_kernel_2 * concept requirenments diff --git a/Arrangement_on_surface_2/include/CGAL/boost/graph/graph_traits_Arrangement_2.h b/Arrangement_on_surface_2/include/CGAL/boost/graph/graph_traits_Arrangement_2.h index ad371b4667d..aabdea5bb49 100644 --- a/Arrangement_on_surface_2/include/CGAL/boost/graph/graph_traits_Arrangement_2.h +++ b/Arrangement_on_surface_2/include/CGAL/boost/graph/graph_traits_Arrangement_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Ron Wein @@ -14,6 +14,9 @@ #ifndef CGAL_BOOST_GRAPH_GRAPH_TRAITS_ARRANGEMENT_2_H #define CGAL_BOOST_GRAPH_GRAPH_TRAITS_ARRANGEMENT_2_H +#include + + #include #endif //CGAL_BOOST_GRAPH_GRAPH_TRAITS_ARRANGEMENT_2_H diff --git a/Arrangement_on_surface_2/include/CGAL/boost/graph/graph_traits_Dual_Arrangement_2.h b/Arrangement_on_surface_2/include/CGAL/boost/graph/graph_traits_Dual_Arrangement_2.h index 5126f010686..f46345c3fcc 100644 --- a/Arrangement_on_surface_2/include/CGAL/boost/graph/graph_traits_Dual_Arrangement_2.h +++ b/Arrangement_on_surface_2/include/CGAL/boost/graph/graph_traits_Dual_Arrangement_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Ron Wein @@ -14,6 +14,9 @@ #ifndef CGAL_BOOST_GRAPH_GRAPH_TRAITS_DUAL_ARRANGEMENT_2_H #define CGAL_BOOST_GRAPH_GRAPH_TRAITS_ARRANGEMENT_2_H +#include + + #include #endif //CGAL_BOOST_GRAPH_GRAPH_TRAITS_DUAL_ARRANGEMENT_2_H diff --git a/Arrangement_on_surface_2/include/CGAL/draw_arrangement_2.h b/Arrangement_on_surface_2/include/CGAL/draw_arrangement_2.h index 76e2eaf3283..7810ca4e62f 100644 --- a/Arrangement_on_surface_2/include/CGAL/draw_arrangement_2.h +++ b/Arrangement_on_surface_2/include/CGAL/draw_arrangement_2.h @@ -9,7 +9,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s): Efi Fogel @@ -17,6 +17,9 @@ #ifndef CGAL_DRAW_ARRANGEMENT_2_H #define CGAL_DRAW_ARRANGEMENT_2_H +#include + + #include #include diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake index 6ce6ad5b5d3..59f174e0ba6 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake @@ -72,13 +72,23 @@ if(CGAL_DISABLE_GMP) endif() if(CGAL_DISABLE_GMP) - message(STATUS "GMP is disable. Try to use LEDA instead.") - set(GMPZ_NT ${LEDA_INT_NT}) - set(QUOTIENT_CGAL_GMPZ_NT ${LEDA_RAT_NT}) - set(CGAL_GMPQ_NT ${LEDA_RAT_NT}) - set(LAZY_CGAL_GMPQ_NT ${LAZY_LEDA_RAT_NT}) - set(LAZY_GMPZ_NT ${LAZY_LEDA_RAT_NT}) - set(CGAL_GMPZ_NT ${LEDA_INT_NT}) + if (CGAL_USE_LEDA) + message(STATUS "GMP is disabled, try to use LEDA instead.") + set(GMPZ_NT ${LEDA_INT_NT}) + set(QUOTIENT_CGAL_GMPZ_NT ${LEDA_RAT_NT}) + set(CGAL_GMPQ_NT ${LEDA_RAT_NT}) + set(LAZY_CGAL_GMPQ_NT ${LAZY_LEDA_RAT_NT}) + set(LAZY_GMPZ_NT ${LAZY_LEDA_RAT_NT}) + set(CGAL_GMPZ_NT ${LEDA_INT_NT}) + else() + message(STATUS "GMP is disabled, try to use MP float instead.") + set(GMPZ_NT ${MP_FLOAT_NT}) + set(QUOTIENT_CGAL_GMPZ_NT ${QUOTIENT_MP_FLOAT_NT}) + set(CGAL_GMPQ_NT ${QUOTIENT_MP_FLOAT_NT}) + set(LAZY_CGAL_GMPQ_NT ${LAZY_QUOTIENT_MP_FLOAT_NT}) + set(LAZY_GMPZ_NT ${LAZY_QUOTIENT_MP_FLOAT_NT}) + set(CGAL_GMPZ_NT ${MP_FLOAT_NT}) + endif() endif() set(COMPARE 1) diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_with_cmake b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_with_cmake index 4d62ce61777..d8c26c68390 100755 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_with_cmake +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test_with_cmake @@ -78,13 +78,23 @@ CORE_INT_NT=15 CORE_RAT_NT=16 if [ -n "${CGAL_DISABLE_GMP}" ]; then - echo GMP is disable. Try to use LEDA instead. - GMPZ_NT=$LEDA_INT_NT - QUOTIENT_CGAL_GMPZ_NT=$LEDA_RAT_NT - CGAL_GMPQ_NT=$LEDA_RAT_NT - LAZY_CGAL_GMPQ_NT=$LAZY_LEDA_RAT_NT - LAZY_GMPZ_NT=$LAZY_LEDA_RAT_NT - CGAL_GMPZ_NT=$LEDA_INT_NT + if [ -n "CGAL_USE_LEDA" ]; then + echo GMP is disabled, try to use LEDA instead. + GMPZ_NT=$LEDA_INT_NT + QUOTIENT_CGAL_GMPZ_NT=$LEDA_RAT_NT + CGAL_GMPQ_NT=$LEDA_RAT_NT + LAZY_CGAL_GMPQ_NT=$LAZY_LEDA_RAT_NT + LAZY_GMPZ_NT=$LAZY_LEDA_RAT_NT + CGAL_GMPZ_NT=$LEDA_INT_NT + else + echo GMP is disabled, try to use MP float instead. + GMPZ_NT=$MP_FLOAT_NT + QUOTIENT_CGAL_GMPZ_NT=$QUOTIENT_MP_FLOAT_NT + CGAL_GMPQ_NT=$QUOTIENT_MP_FLOAT_NT + LAZY_CGAL_GMPQ_NT=$LAZY_QUOTIENT_MP_FLOAT_NT + LAZY_GMPZ_NT=$LAZY_QUOTIENT_MP_FLOAT_NT + CGAL_GMPZ_NT=$MP_FLOAT_NT + fi fi COMPARE=1 diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_observer.cpp b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_observer.cpp index 6f12f6e8c73..6c5d646c62e 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_observer.cpp +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_observer.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include @@ -34,687 +33,509 @@ typedef Traits_2::Point_2 Point_2; typedef Traits_2::X_monotone_curve_2 Segment_2; typedef CGAL::Arrangement_2 Arrangement_2; -void skip_comments(std::ifstream & is, char * line) -{ +void skip_comments(std::ifstream & is, char* line) { while (!is.eof()) { is.getline(line, 128); if (line[0] != '#') break; } } -void compare_results(std::string str) -{ - skip_comments(global_input_file, one_line); - std::istringstream str_stream(one_line); - str_stream.getline(buff, 128, ' '); - if (std::string(buff)!=str) - { - std::cout << "Expected " << std::string(buff) << " obtained " - << str << std::endl; - ok=-1; - } +void compare_results(std::string str) { + skip_comments(global_input_file, one_line); + std::istringstream str_stream(one_line); + str_stream.getline(buff, 128, ' '); + if (std::string(buff) != str) { + std::cout << "Expected " << std::string(buff) << " obtained " + << str << std::endl; + ok = -1; + } } // An arrangement observer, used to receive notifications of face splits and // face mergers. -class Test_observer : public CGAL::Arr_observer -{ - +class Test_observer : public Arrangement_2::Observer { public: + using Observer = Arrangement_2::Observer; + using Base_aos = Arrangement_2::Base_aos; - Test_observer (Arrangement_2& arr) : - CGAL::Arr_observer (arr) - {} + using Vertex_handle = Base_aos::Vertex_handle; + using Halfedge_handle = Base_aos::Halfedge_handle; + using Face_handle = Base_aos::Face_handle; + using Ccb_halfedge_circulator = Base_aos::Ccb_halfedge_circulator; + using Point_2 = Base_aos::Point_2; + using X_monotone_curve_2 = Base_aos::X_monotone_curve_2; + + Test_observer(Base_aos& arr) : Observer(arr) {} /// \name Notification functions on global arrangement operations. //@{ - /*! - * Notification before the arrangement is assigned with another - * arrangement. - * \param arr The arrangement to be copied. + /*! Notification before the arrangement is assigned with the content of + * another arrangement. + * \param arr The other arrangement. Notice that the arrangement type is the + * type used to instantiate the observer, which is conveniently + * defined as `Arrangement_2::Base_aos`. */ - virtual void before_assign (const Arrangement_2& /* arr */) - { - compare_results("before_assign"); - } + virtual void before_assign(const Base_aos& /* arr */) override + { compare_results("before_assign"); } /*! * Notification after the arrangement has been assigned with another * arrangement. */ - virtual void after_assign () - { - compare_results("after_assign"); - } + virtual void after_assign() override { compare_results("after_assign"); } /*! Notification before the arrangement is cleared. */ - virtual void before_clear () - { - compare_results("before_clear"); - } + virtual void before_clear() override { compare_results("before_clear"); } /*! * Notification after the arrangement is cleared. */ - virtual void after_clear () - { - compare_results("after_clear"); - } + virtual void after_clear() override { compare_results("after_clear"); } /*! Notification before a global operation modifies the arrangement. */ - virtual void before_global_change () - { - compare_results("before_global_change"); - } + virtual void before_global_change() override + { compare_results("before_global_change"); } /*! Notification after a global operation is completed. */ - virtual void after_global_change () - { - compare_results("after_global_change"); - } + virtual void after_global_change() override + { compare_results("after_global_change"); } //@} /// \name Notification functions on observer attachment or detachment. //@{ - /*! - * Notification before the observer is attached to an arrangement. + /*! Notification before the observer is attached to an arrangement. * \param arr The arrangement we are about to attach the observer to. */ - virtual void before_attach (const Arrangement_2& /* arr */) - { - compare_results("before_attach"); - } + virtual void before_attach(const Base_aos& /* arr */) override + { compare_results("before_attach"); } - /*! - * Notification after the observer has been attached to an arrangement. + /*! Notification after the observer has been attached to an arrangement. */ - virtual void after_attach () - { - compare_results("after_attach"); - } + virtual void after_attach() override { compare_results("after_attach"); } - /*! - * Notification before the observer is detached from the arrangement. + /*! Notification before the observer is detached from the arrangement. */ - virtual void before_detach () - { - compare_results("before_detach"); - } + virtual void before_detach() override { compare_results("before_detach"); } - /*! - * Notification after the observer has been detached to the arrangement. + /*! Notification after the observer has been detached to the arrangement. */ - virtual void after_detach () - - { - compare_results("after_detach"); - } + virtual void after_detach() override { compare_results("after_detach"); } //@} /// \name Notification functions on local changes in the arrangement. //@{ - /*! - * Notification before the creation of a new vertex. + /*! Notification before the creation of a new vertex. * \param p The point to be associated with the vertex. * This point cannot lies on the surface boundaries. */ - virtual void before_create_vertex (const Point_2& /* p */) - { - compare_results("before_create_vertex"); - } + virtual void before_create_vertex(const Point_2& /* p */) override + { compare_results("before_create_vertex"); } - /*! - * Notification after the creation of a new vertex. + /*! Notification after the creation of a new vertex. * \param v A handle to the created vertex. */ - virtual void after_create_vertex (Vertex_handle /* v */) - { - compare_results("after_create_vertex"); - } + virtual void after_create_vertex(Vertex_handle /* v */) override + { compare_results("after_create_vertex"); } - /*! - * Notification before the creation of a new boundary vertex. + /*! Notification before the creation of a new boundary vertex. * \param cv The curve incident to the surface boundary. * \param ind The relevant curve-end. * \param bound_x The boundary condition of the vertex in x. * \param bound_y The boundary condition of the vertex in y. */ - virtual void before_create_boundary_vertex (const X_monotone_curve_2& /*cv*/, - CGAL::Arr_curve_end /* ind */, - CGAL::Arr_parameter_space /* bound_x */, - CGAL::Arr_parameter_space /* bound_y */) - { - compare_results("before_create_boundary_vertex"); - } + virtual void + before_create_boundary_vertex(const X_monotone_curve_2& /*cv*/, + CGAL::Arr_curve_end /* ind */, + CGAL::Arr_parameter_space /* bound_x */, + CGAL::Arr_parameter_space /* bound_y */) + override + { compare_results("before_create_boundary_vertex"); } - /*! - * Notification after the creation of a new vertex at infinity. + /*! Notification after the creation of a new vertex at infinity. * \param v A handle to the created vertex. */ - virtual void after_create_boundary_vertex (Vertex_handle /* v */) - { - compare_results("after_create_boundary_vertex"); - } + virtual void after_create_boundary_vertex(Vertex_handle /* v */) override + { compare_results("after_create_boundary_vertex"); } - /*! - * Notification before the creation of a new edge. + /*! Notification before the creation of a new edge. * \param c The x-monotone curve to be associated with the edge. * \param v1 A handle to the first end-vertex of the edge. * \param v2 A handle to the second end-vertex of the edge. */ - virtual void before_create_edge (const X_monotone_curve_2& /* c */, - Vertex_handle /* v1 */, - Vertex_handle /* v2 */) - { - compare_results("before_create_edge"); - } + virtual void before_create_edge(const X_monotone_curve_2& /* c */, + Vertex_handle /* v1 */, + Vertex_handle /* v2 */) override + { compare_results("before_create_edge"); } - /*! - * Notification after the creation of a new edge. + /*! Notification after the creation of a new edge. * \param e A handle to one of the twin halfedges that were created. */ - virtual void after_create_edge (Halfedge_handle /* e */) - { - compare_results("after_create_edge"); - } + virtual void after_create_edge(Halfedge_handle /* e */) override + { compare_results("after_create_edge"); } - /*! - * Notification before the modification of an existing vertex. + /*! Notification before the modification of an existing vertex. * \param v A handle to the vertex to be updated. * \param p The point to be associated with the vertex. */ - virtual void before_modify_vertex (Vertex_handle /* v */, - const Point_2& /* p */) - { - compare_results("before_modify_vertex"); - } + virtual void before_modify_vertex(Vertex_handle /* v */, + const Point_2& /* p */) override + { compare_results("before_modify_vertex"); } - /*! - * Notification after a vertex was modified. + /*! Notification after a vertex was modified. * \param v A handle to the updated vertex. */ - virtual void after_modify_vertex (Vertex_handle /* v */) - { - compare_results("after_modify_vertex"); - } + virtual void after_modify_vertex(Vertex_handle /* v */) override + { compare_results("after_modify_vertex"); } - /*! - * Notification before the modification of an existing edge. + /*! Notification before the modification of an existing edge. * \param e A handle to one of the twin halfedges to be updated. * \param c The x-monotone curve to be associated with the edge. */ - virtual void before_modify_edge (Halfedge_handle /* e */, - const X_monotone_curve_2& /* c */) - { - compare_results("before_modify_edge"); - } + virtual void before_modify_edge(Halfedge_handle /* e */, + const X_monotone_curve_2& /* c */) override + { compare_results("before_modify_edge"); } - /*! - * Notification after an edge was modified. + /*! Notification after an edge was modified. * \param e A handle to one of the twin halfedges that were updated. */ - virtual void after_modify_edge (Halfedge_handle /* e */) - { - compare_results("after_modify_edge"); - } + virtual void after_modify_edge(Halfedge_handle /* e */) override + { compare_results("after_modify_edge"); } - /*! - * Notification before the splitting of an edge into two. + /*! Notification before the splitting of an edge into two. * \param e A handle to one of the existing halfedges. * \param v A vertex representing the split point. * \param c1 The x-monotone curve to be associated with the first edge. * \param c2 The x-monotone curve to be associated with the second edge. */ - virtual void before_split_edge (Halfedge_handle /* e */, - Vertex_handle /* v */, - const X_monotone_curve_2& /* c1 */, - const X_monotone_curve_2& /* c2 */) - { - compare_results("before_split_edge"); - } + virtual void before_split_edge(Halfedge_handle /* e */, + Vertex_handle /* v */, + const X_monotone_curve_2& /* c1 */, + const X_monotone_curve_2& /* c2 */) override + { compare_results("before_split_edge"); } - /*! - * Notification after an edge was split. + /*! Notification after an edge was split. * \param e1 A handle to one of the twin halfedges forming the first edge. * \param e2 A handle to one of the twin halfedges forming the second edge. */ - virtual void after_split_edge (Halfedge_handle /* e1 */, - Halfedge_handle /* e2 */) - { - compare_results("after_split_edge"); - } + virtual void after_split_edge(Halfedge_handle /* e1 */, + Halfedge_handle /* e2 */) override + { compare_results("after_split_edge"); } - /*! - * Notification before the splitting of a fictitious edge into two. + /*! Notification before the splitting of a fictitious edge into two. * \param e A handle to one of the existing halfedges. * \param v A vertex representing the unbounded split point. */ - virtual void before_split_fictitious_edge (Halfedge_handle /* e */, - Vertex_handle /* v */) - { - compare_results("before_split_fictitious_edge"); - } + virtual void before_split_fictitious_edge(Halfedge_handle /* e */, + Vertex_handle /* v */) override + { compare_results("before_split_fictitious_edge"); } - /*! - * Notification after a fictitious edge was split. + /*! Notification after a fictitious edge was split. * \param e1 A handle to one of the twin halfedges forming the first edge. * \param e2 A handle to one of the twin halfedges forming the second edge. */ - virtual void after_split_fictitious_edge (Halfedge_handle /* e1 */, - Halfedge_handle /* e2 */) - { - compare_results("after_split_fictitious_edge"); - } + virtual void after_split_fictitious_edge(Halfedge_handle /* e1 */, + Halfedge_handle /* e2 */) override + { compare_results("after_split_fictitious_edge"); } - /*! - * Notification before the splitting of a face into two. + /*! Notification before the splitting of a face into two. * \param f A handle to the existing face. * \param e The new edge whose insertion causes the face to split. */ - virtual void before_split_face (Face_handle /* f */, - Halfedge_handle /* e */) - { - compare_results("before_split_face"); - } + virtual void before_split_face(Face_handle /* f */, + Halfedge_handle /* e */) override + { compare_results("before_split_face"); } - /*! - * Notification after a face was split. + /*! Notification after a face was split. * \param f A handle to the face we have just split. * \param new_f A handle to the new face that has been created. * \param is_hole Whether the new face forms a hole inside f. */ virtual void after_split_face (Face_handle /* f */, Face_handle /* new_f */, - bool /* is_hole */) - { - compare_results("after_split_face"); - } + bool /* is_hole */) override + { compare_results("after_split_face"); } - /*! - * Notification before the splitting of an outer CCB into two. + /*! Notification before the splitting of an outer CCB into two. * \param f A handle to the face that owns the outer CCB. * \param h A circulator representing the component boundary. * \param e The new edge whose removal causes the outer CCB to split. */ - virtual void before_split_outer_ccb (Face_handle /* f */, - Ccb_halfedge_circulator /* h */, - Halfedge_handle /* e */) - { - compare_results("before_split_outer_ccb"); - } + virtual void before_split_outer_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */, + Halfedge_handle /* e */) override + { compare_results("before_split_outer_ccb"); } - /*! - * Notification after an outer CCB was split. + /*! Notification after an outer CCB was split. * \param f A handle to the face that owns the outer CCBs. * \param h1 A circulator representing the boundary of the first component. * \param h2 A circulator representing the boundary of the second component. */ - virtual void after_split_outer_ccb (Face_handle /* f */, - Ccb_halfedge_circulator /* h1 */, - Ccb_halfedge_circulator /* h2 */) - { - compare_results("after_split_outer_ccb"); - } + virtual void after_split_outer_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h1 */, + Ccb_halfedge_circulator /* h2 */) override + { compare_results("after_split_outer_ccb"); } - /*! - * Notification before the splitting of an inner CCB into two. + /*! Notification before the splitting of an inner CCB into two. * \param f A handle to the face containing the inner CCB. * \param h A circulator representing the component boundary. * \param e The new edge whose removal causes the inner CCB to split. */ - virtual void before_split_inner_ccb (Face_handle /* f */, - Ccb_halfedge_circulator /* h */, - Halfedge_handle /* e */) - { - compare_results("before_split_inner_ccb"); - } + virtual void before_split_inner_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */, + Halfedge_handle /* e */) override + { compare_results("before_split_inner_ccb"); } - /*! - * Notification after an inner CCB was split. + /*! Notification after an inner CCB was split. * \param f A handle to the face containing the inner CCBs. * \param h1 A circulator representing the boundary of the first component. * \param h2 A circulator representing the boundary of the second component. */ - virtual void after_split_inner_ccb (Face_handle /* f */, - Ccb_halfedge_circulator /* h1 */, - Ccb_halfedge_circulator /* h2 */) - { - compare_results("after_split_inner_ccb"); - } + virtual void after_split_inner_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h1 */, + Ccb_halfedge_circulator /* h2 */) override + { compare_results("after_split_inner_ccb"); } - /*! - * Notification before the creation of a new outer CCB of a face. + /*! Notification before the creation of a new outer CCB of a face. * \param f A handle to the face that owns the outer CCB. * \param e A halfedge along the new outer CCB. */ - virtual void before_add_outer_ccb (Face_handle /* f */, - Halfedge_handle /* e */) - { - compare_results("before_add_outer_ccb"); - } + virtual void before_add_outer_ccb(Face_handle /* f */, + Halfedge_handle /* e */) override + { compare_results("before_add_outer_ccb"); } - /*! - * Notification after an outer CCB was added to a face. + /*! Notification after an outer CCB was added to a face. * \param h A circulator representing the boundary of the new outer CCB. */ - virtual void after_add_outer_ccb (Ccb_halfedge_circulator /* h */) - { - compare_results("after_add_outer_ccb"); - } + virtual void after_add_outer_ccb(Ccb_halfedge_circulator /* h */) override + { compare_results("after_add_outer_ccb"); } - /*! - * Notification before the creation of a new inner CCB inside a face. + /*! Notification before the creation of a new inner CCB inside a face. * \param f A handle to the face containing the inner CCB. * \param e The new halfedge that forms the new inner CCB. */ - virtual void before_add_inner_ccb (Face_handle /* f */, - Halfedge_handle /* e */) - { - compare_results("before_add_inner_ccb"); - } + virtual void before_add_inner_ccb(Face_handle /* f */, + Halfedge_handle /* e */) override + { compare_results("before_add_inner_ccb"); } - /*! - * Notification after an inner CCB was created inside a face. + /*! Notification after an inner CCB was created inside a face. * \param h A circulator representing the boundary of the new inner CCB. */ - virtual void after_add_inner_ccb (Ccb_halfedge_circulator /* h */) - { - compare_results("after_add_inner_ccb"); - } + virtual void after_add_inner_ccb(Ccb_halfedge_circulator /* h */) override + { compare_results("after_add_inner_ccb"); } - /*! - * Notification before the creation of a new isolated vertex inside a face. + /*! Notification before the creation of a new isolated vertex inside a face. * \param f A handle to the face containing the isolated vertex. * \param v The isolated vertex. */ - virtual void before_add_isolated_vertex (Face_handle /* f */, - Vertex_handle /* v */) - { - compare_results("before_add_isolated_vertex"); - } + virtual void before_add_isolated_vertex(Face_handle /* f */, + Vertex_handle /* v */) override + { compare_results("before_add_isolated_vertex"); } - /*! - * Notification after an isolated vertex was created inside a face. + /*! Notification after an isolated vertex was created inside a face. * \param v The isolated vertex. */ - virtual void after_add_isolated_vertex (Vertex_handle /* v */) - { - compare_results("after_add_isolated_vertex"); - } + virtual void after_add_isolated_vertex(Vertex_handle /* v */) override + { compare_results("after_add_isolated_vertex"); } - /*! - * Notification before the merging of two edges. + /*! Notification before the merging of two edges. * \param e1 A handle to one of the halfedges forming the first edge. * \param e2 A handle to one of the halfedges forming the second edge. * \param c The x-monotone curve to be associated with the merged edge. */ - virtual void before_merge_edge (Halfedge_handle /* e1 */, - Halfedge_handle /* e2 */, - const X_monotone_curve_2& /* c */) - { - compare_results("before_merge_edge"); - } + virtual void before_merge_edge(Halfedge_handle /* e1 */, + Halfedge_handle /* e2 */, + const X_monotone_curve_2& /* c */) override + { compare_results("before_merge_edge"); } - /*! - * Notification after an edge was merged. + /*! Notification after an edge was merged. * \param e A handle to one of the twin halfedges forming the merged edge. */ - virtual void after_merge_edge (Halfedge_handle /* e */) - { - compare_results("after_merge_edge"); - } + virtual void after_merge_edge(Halfedge_handle /* e */) override + { compare_results("after_merge_edge"); } /*! * Notification before the merging of two fictitious edges. * \param e1 A handle to one of the halfedges forming the first edge. * \param e2 A handle to one of the halfedges forming the second edge. */ - virtual void before_merge_fictitious_edge (Halfedge_handle /* e1 */, - Halfedge_handle /* e2 */) - { - compare_results("before_merge_fictitious_edge"); - } + virtual void before_merge_fictitious_edge(Halfedge_handle /* e1 */, + Halfedge_handle /* e2 */) override + { compare_results("before_merge_fictitious_edge"); } - /*! - * Notification after a fictitious edge was merged. + /*! Notification after a fictitious edge was merged. * \param e A handle to one of the twin halfedges forming the merged edge. */ - virtual void after_merge_fictitious_edge (Halfedge_handle /* e */) - { - compare_results("after_merge_fictitious_edge"); - } + virtual void after_merge_fictitious_edge (Halfedge_handle /* e */) override + { compare_results("after_merge_fictitious_edge"); } - /*! - * Notification before the merging of two faces. + /*! Notification before the merging of two faces. * \param f1 A handle to the first face. * \param f2 A handle to the second face. * \param e The edge whose removal causes the faces to merge. */ - virtual void before_merge_face (Face_handle /* f1 */, - Face_handle /* f2 */, - Halfedge_handle /* e */) - { - compare_results("before_merge_face"); - } + virtual void before_merge_face(Face_handle /* f1 */, + Face_handle /* f2 */, + Halfedge_handle /* e */) override + { compare_results("before_merge_face"); } - /*! - * Notification after a face was merged. + /*! Notification after a face was merged. * \param f A handle to the merged face. */ - virtual void after_merge_face (Face_handle /* f */) - { - compare_results("after_merge_face"); - } + virtual void after_merge_face(Face_handle /* f */) override + { compare_results("after_merge_face"); } - /*! - * Notification before the merging of two outer CCBs. + /*! Notification before the merging of two outer CCBs. * \param f A handle to the face that owns the outer CCBs. * \param h1 A circulator representing the boundary of the first component. * \param h2 A circulator representing the boundary of the second component. * \param e The edge whose insertion or removal causes the CCBs to merge. */ - virtual void before_merge_outer_ccb (Face_handle /* f */, - Ccb_halfedge_circulator /* h1 */, - Ccb_halfedge_circulator /* h2 */, - Halfedge_handle /* e */) - { - compare_results("before_merge_outer_ccb"); - } + virtual void before_merge_outer_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h1 */, + Ccb_halfedge_circulator /* h2 */, + Halfedge_handle /* e */) override + { compare_results("before_merge_outer_ccb"); } - /*! - * Notification after an outer CCB was merged. + /*! Notification after an outer CCB was merged. * \param f A handle to the face that owns the outer CCBs. * \param h A circulator representing the boundary of the merged component. */ - virtual void after_merge_outer_ccb (Face_handle /* f */, - Ccb_halfedge_circulator /* h */) - { - compare_results("after_merge_outer_ccb"); - } + virtual void after_merge_outer_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */) override + { compare_results("after_merge_outer_ccb"); } - /*! - * Notification before the merging of two inner CCBs (holes). + /*! Notification before the merging of two inner CCBs (holes). * \param f A handle to the face that contains the inner CCBs. * \param h1 A circulator representing the boundary of the first component. * \param h2 A circulator representing the boundary of the second component. * \param e The edge whose insertion causes the inner CCBs to merge. */ - virtual void before_merge_inner_ccb (Face_handle /* f */, - Ccb_halfedge_circulator /* h1 */, - Ccb_halfedge_circulator /* h2 */, - Halfedge_handle /* e */) - { - compare_results("before_merge_inner_ccb"); - } + virtual void before_merge_inner_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h1 */, + Ccb_halfedge_circulator /* h2 */, + Halfedge_handle /* e */) override + { compare_results("before_merge_inner_ccb"); } - /*! - * Notification after an inner CCB was merged. + /*! Notification after an inner CCB was merged. * \param f A handle to the face that contains the inner CCBs. * \param h A circulator representing the boundary of the merged component. */ - virtual void after_merge_inner_ccb (Face_handle /* f */, - Ccb_halfedge_circulator /* h */) - { - compare_results("after_merge_inner_ccb"); - } + virtual void after_merge_inner_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */) override + { compare_results("after_merge_inner_ccb"); } - /*! - * Notification before an outer CCB is moved from one face to another. + /*! Notification before an outer CCB is moved from one face to another. * \param from_f A handle to the face that currently owns the outer CCB. * \param to_f A handle to the face that should own the outer CCB. * \param h A circulator representing the boundary of the component. */ - virtual void before_move_outer_ccb (Face_handle /* from_f */, - Face_handle /* to_f */, - Ccb_halfedge_circulator /* h */) - { - compare_results("before_move_outer_ccb"); - } + virtual void before_move_outer_ccb(Face_handle /* from_f */, + Face_handle /* to_f */, + Ccb_halfedge_circulator /* h */) override + { compare_results("before_move_outer_ccb"); } - /*! - * Notification after an outer CCB is moved from one face to another. + /*! Notification after an outer CCB is moved from one face to another. * \param h A circulator representing the boundary of the component. */ - virtual void after_move_outer_ccb (Ccb_halfedge_circulator /* h */) - { - compare_results("after_move_outer_ccb"); - } + virtual void after_move_outer_ccb(Ccb_halfedge_circulator /* h */) override + { compare_results("after_move_outer_ccb"); } - /*! - * Notification before an inner CCB is moved from one face to another. + /*! Notification before an inner CCB is moved from one face to another. * \param from_f A handle to the face currently containing the inner CCB. * \param to_f A handle to the face that should contain the inner CCB. * \param h A circulator representing the boundary of the component. */ - virtual void before_move_inner_ccb (Face_handle /* from_f */, - Face_handle /* to_f */, - Ccb_halfedge_circulator /* h */) - { - compare_results("before_move_inner_ccb"); - } + virtual void before_move_inner_ccb(Face_handle /* from_f */, + Face_handle /* to_f */, + Ccb_halfedge_circulator /* h */) override + { compare_results("before_move_inner_ccb"); } - /*! - * Notification after an inner CCB is moved from one face to another. + /*! Notification after an inner CCB is moved from one face to another. * \param h A circulator representing the boundary of the component. */ - virtual void after_move_inner_ccb (Ccb_halfedge_circulator /* h */) - { - compare_results("after_move_inner_ccb"); - } + virtual void after_move_inner_ccb(Ccb_halfedge_circulator /* h */) override + { compare_results("after_move_inner_ccb"); } - /*! - * Notification before an isolated vertex is moved from one face to another. + /*! Notification before an isolated vertex is moved from one face to another. * \param from_f A handle to the face currently containing the vertex. * \param to_f A handle to the face that should contain the vertex. * \param v The isolated vertex. */ - virtual void before_move_isolated_vertex (Face_handle /* from_f */, - Face_handle /* to_f */, - Vertex_handle /* v */) - { - compare_results("before_move_isolated_vertex"); - } + virtual void before_move_isolated_vertex(Face_handle /* from_f */, + Face_handle /* to_f */, + Vertex_handle /* v */) override + { compare_results("before_move_isolated_vertex"); } - /*! - * Notification after an isolated vertex is moved from one face to another. + /*! Notification after an isolated vertex is moved from one face to another. * \param v The isolated vertex. */ - virtual void after_move_isolated_vertex (Vertex_handle /* v */) - { - compare_results("after_move_isolated_vertex"); - } + virtual void after_move_isolated_vertex(Vertex_handle /* v */) override + { compare_results("after_move_isolated_vertex"); } - /*! - * Notificaion before the removal of a vertex. + /*! Notificaion before the removal of a vertex. * \param v A handle to the vertex to be deleted. */ - virtual void before_remove_vertex (Vertex_handle /* v */) - { - compare_results("before_remove_vertex"); - } + virtual void before_remove_vertex(Vertex_handle /* v */) override + { compare_results("before_remove_vertex"); } - /*! - * Notificaion after the removal of a vertex. + /*! Notificaion after the removal of a vertex. */ - virtual void after_remove_vertex () - { - compare_results("after_remove_vertex"); - } + virtual void after_remove_vertex() override + { compare_results("after_remove_vertex"); } - /*! - * Notification before the removal of an edge. + /*! Notification before the removal of an edge. * \param e A handle to one of the twin halfedges to be deleted. */ - virtual void before_remove_edge (Halfedge_handle /* e */) - { - compare_results("before_remove_edge"); - } + virtual void before_remove_edge(Halfedge_handle /* e */) override + { compare_results("before_remove_edge"); } - /*! - * Notificaion after the removal of an edge. + /*! Notificaion after the removal of an edge. */ - virtual void after_remove_edge () - { - compare_results("after_remove_edge"); - } + virtual void after_remove_edge() override + { compare_results("after_remove_edge"); } - /*! - * Notification before the removal of an outer CCB. + /*! Notification before the removal of an outer CCB. * \param f The face that owns the outer CCB. * \param h A circulator representing the boundary of the component. */ - virtual void before_remove_outer_ccb (Face_handle /* f */, - Ccb_halfedge_circulator /* h */) - { - compare_results("before_remove_outer_ccb"); - } + virtual void before_remove_outer_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */) override + { compare_results("before_remove_outer_ccb"); } - /*! - * Notificaion after the removal of an outer CCB. + /*! Notificaion after the removal of an outer CCB. * \param f The face that used to own the outer CCB. */ - virtual void after_remove_outer_ccb (Face_handle /* f */) - { - compare_results("after_remove_outer_ccb"); - } + virtual void after_remove_outer_ccb(Face_handle /* f */) override + { compare_results("after_remove_outer_ccb"); } - /*! - * Notification before the removal of an inner CCB. + /*! Notification before the removal of an inner CCB. * \param f The face containing the inner CCB. * \param h A circulator representing the boundary of the component. */ - virtual void before_remove_inner_ccb (Face_handle /* f */, - Ccb_halfedge_circulator /* h */) - { - compare_results("before_remove_inner_ccb"); - } + virtual void before_remove_inner_ccb(Face_handle /* f */, + Ccb_halfedge_circulator /* h */) override + { compare_results("before_remove_inner_ccb"); } - /*! - * Notificaion after the removal of an inner CCB. + /*! Notificaion after the removal of an inner CCB. * \param f The face that used to contain the inner CCB. */ - virtual void after_remove_inner_ccb (Face_handle /* f */) - { - compare_results("after_remove_inner_ccb"); - } + virtual void after_remove_inner_ccb(Face_handle /* f */) override + { compare_results("after_remove_inner_ccb"); } //@} }; -int main (int argc, char * argv[]) -{ - if (argc != 2) - { +int main (int argc, char* argv[]) { + if (argc != 2) { std::cout << "Usage: " << argv[0] << " inputfile" << std::endl; CGAL_error(); } - else - { + else { // Construct the arrangement containing one diamond-shaped face. Arrangement_2 arr; global_input_file.open(argv[1]); @@ -725,55 +546,48 @@ int main (int argc, char * argv[]) int i_vh = 0, i_heh = 0; std::vector heh_vec; std::vector vh_vec; - while (!global_input_file.eof()) - { + while (! global_input_file.eof()) { skip_comments(global_input_file, one_line); std::istringstream str_stream(one_line); char c; str_stream >> c; if (!global_input_file.gcount()) break; - if (c=='s') - { + if (c=='s') { str_stream >> c; //read segment str_stream >> s; - if (c=='i') - { + if (c=='i') { // si means insert intersecting segment insert(arr,s); std::cout << "intersecting segment insert " << s << std::endl; } - else if (c=='n') - { + else if (c=='n') { // sn means insert non intersecting segment heh_vec.push_back(insert_non_intersecting_curve (arr, s)); std::cout << "non intersecting segment insert " << s << std::endl; } } - else if (c=='p') - { + else if (c=='p') { // p means read point str_stream >> p ; - std::cout << "point insert " << p << " index " << vh_vec.size() << std::endl; + std::cout << "point insert " << p << " index " << vh_vec.size() + << std::endl; vh_vec.push_back(insert_point(arr,p)); } - else if (c=='e') - { + else if (c=='e') { // e means read edge index to be removed str_stream >> i_heh ; std::cout << "remove edge " << heh_vec[i_heh]->curve() << std::endl; remove_edge(arr,heh_vec[i_heh]); } - else if (c=='v') - { + else if (c=='v') { // v means read point index to be removed str_stream >> i_vh ; std::cout << "remove point " << vh_vec[i_vh]->point() << std::endl; remove_vertex(arr,vh_vec[i_vh]); } - else - { + else { //error std::cout << "error, unknowen command" << std::endl; return -1; diff --git a/Boolean_set_operations_2/include/CGAL/draw_polygon_set_2.h b/Boolean_set_operations_2/include/CGAL/draw_polygon_set_2.h index 6eaa81b02f7..bd9cfec7f7c 100644 --- a/Boolean_set_operations_2/include/CGAL/draw_polygon_set_2.h +++ b/Boolean_set_operations_2/include/CGAL/draw_polygon_set_2.h @@ -9,7 +9,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Guillaume Damiand @@ -17,6 +17,9 @@ #ifndef CGAL_DRAW_POLYGON_SET_2_H #define CGAL_DRAW_POLYGON_SET_2_H +#include + + #include #ifdef DOXYGEN_RUNNING diff --git a/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Approximate_min_ellipsoid_d_impl.h b/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Approximate_min_ellipsoid_d_impl.h index b38b7794967..e6c85c192a6 100644 --- a/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Approximate_min_ellipsoid_d_impl.h +++ b/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Approximate_min_ellipsoid_d_impl.h @@ -10,6 +10,10 @@ // // Author(s) : Kaspar Fischer +#ifndef CGAL_APPROXIMATE_MIN_ELLIPSOID_D_APPROXIMATE_MIN_ELLIPSOID_D_IMPL_H +#define CGAL_APPROXIMATE_MIN_ELLIPSOID_D_APPROXIMATE_MIN_ELLIPSOID_D_IMPL_H + +#include #include @@ -272,3 +276,5 @@ namespace CGAL { } } + +#endif //CGAL_APPROXIMATE_MIN_ELLIPSOID_D_APPROXIMATE_MIN_ELLIPSOID_D_IMPL_H diff --git a/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Khachiyan_approximation_impl.h b/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Khachiyan_approximation_impl.h index 90944fd8b7f..c3c5844f273 100644 --- a/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Khachiyan_approximation_impl.h +++ b/Bounding_volumes/include/CGAL/Approximate_min_ellipsoid_d/Khachiyan_approximation_impl.h @@ -10,6 +10,11 @@ // // Author(s) : Kaspar Fischer +#ifndef CGAL_APPROX_MIN_ELLIPSOID_KHACHIYAN_APPROX_IMPL_H +#define CGAL_APPROX_MIN_ELLIPSOID_KHACHIYAN_APPROX_IMPL_H + +#include + // Note: whenever a comment refers to "Khachiyan's paper" then the // paper "Rounding of polytopes in the real number model of // computation" is meant (Mathematics of Operations Research, Vol. 21, @@ -663,3 +668,5 @@ namespace CGAL { } } + +#endif // CGAL_APPROX_MIN_ELLIPSOID_KHACHIYAN_APPROX_IMPL_H diff --git a/Bounding_volumes/include/CGAL/Min_circle_2/Min_circle_2_impl.h b/Bounding_volumes/include/CGAL/Min_circle_2/Min_circle_2_impl.h index 114a59a297a..c7f9893103d 100644 --- a/Bounding_volumes/include/CGAL/Min_circle_2/Min_circle_2_impl.h +++ b/Bounding_volumes/include/CGAL/Min_circle_2/Min_circle_2_impl.h @@ -10,6 +10,11 @@ // // Author(s) : Sven Schoenherr , Bernd Gaertner +#ifndef CGAL_MIN_CIRCLE_2_MIN_CIRCLE_2_IMPL_H +#define CGAL_MIN_CIRCLE_2_MIN_CIRCLE_2_IMPL_H + +#include + #include namespace CGAL { @@ -98,3 +103,5 @@ operator >> ( std::istream& is, CGAL::Min_circle_2& min_circle) } //namespace CGAL // ===== EOF ================================================================== + +#endif // CGAL_MIN_CIRCLE_2_MIN_CIRCLE_2_IMPL_H diff --git a/Bounding_volumes/include/CGAL/Min_circle_2/Optimisation_circle_2_impl.h b/Bounding_volumes/include/CGAL/Min_circle_2/Optimisation_circle_2_impl.h index f2e94333b61..04a47b6d2b0 100644 --- a/Bounding_volumes/include/CGAL/Min_circle_2/Optimisation_circle_2_impl.h +++ b/Bounding_volumes/include/CGAL/Min_circle_2/Optimisation_circle_2_impl.h @@ -10,6 +10,11 @@ // // Author(s) : Sven Schoenherr , Bernd Gaertner +#ifndef CGAL_MIN_SPHERE_D_OPTIMISATION_CIRCLE_2_IMPL_H +#define CGAL_MIN_SPHERE_D_OPTIMISATION_CIRCLE_2_IMPL_H + +#include + // includes # include @@ -89,3 +94,5 @@ operator >> ( std::istream& is, CGAL::Optimisation_circle_2& c) } //namespace CGAL // ===== EOF ================================================================== + +#endif //CGAL_MIN_SPHERE_D_OPTIMISATION_CIRCLE_2_IMPL_H diff --git a/Bounding_volumes/include/CGAL/Min_ellipse_2/Min_ellipse_2_impl.h b/Bounding_volumes/include/CGAL/Min_ellipse_2/Min_ellipse_2_impl.h index d7bd821350e..01cc0d2dcf7 100644 --- a/Bounding_volumes/include/CGAL/Min_ellipse_2/Min_ellipse_2_impl.h +++ b/Bounding_volumes/include/CGAL/Min_ellipse_2/Min_ellipse_2_impl.h @@ -10,6 +10,11 @@ // // Author(s) : Sven Schoenherr , Bernd Gaertner +#ifndef CGAL_MIN_ELLIPSE_2_MIN_ELLIPSE_2_IMP_H +#define CGAL_MIN_ELLIPSE_2_MIN_ELLIPSE_2_IMP_H + +#include + #include namespace CGAL { @@ -98,3 +103,5 @@ operator >> ( std::istream& is, CGAL::Min_ellipse_2& min_ellipse) } //namespace CGAL // ===== EOF ================================================================== + +#endif // CGAL_MIN_ELLIPSE_2_MIN_ELLIPSE_2_IMP_H diff --git a/Bounding_volumes/include/CGAL/Min_ellipse_2/Optimisation_ellipse_2_impl.h b/Bounding_volumes/include/CGAL/Min_ellipse_2/Optimisation_ellipse_2_impl.h index 4f94bbe4047..4100d9d3de6 100644 --- a/Bounding_volumes/include/CGAL/Min_ellipse_2/Optimisation_ellipse_2_impl.h +++ b/Bounding_volumes/include/CGAL/Min_ellipse_2/Optimisation_ellipse_2_impl.h @@ -10,6 +10,11 @@ // // Author(s) : Sven Schoenherr , Bernd Gaertner +#ifndef CGAL_MIN_ELLIPSE_2_OPTIMISATION_ELLIPSE_2_IMPL_H +#define CGAL_MIN_ELLIPSE_2_OPTIMISATION_ELLIPSE_2_IMPL_H + +#include + namespace CGAL { // Class implementation (continued) @@ -116,3 +121,5 @@ operator >> ( std::istream& is, CGAL::Optimisation_ellipse_2& e) } //namespace CGAL // ===== EOF ================================================================== + +#endif // CGAL_MIN_ELLIPSE_2_OPTIMISATION_ELLIPSE_2_IMPL_H diff --git a/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_2.h b/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_2.h index 05dd8668050..933212c0c6b 100644 --- a/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_2.h +++ b/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_2.h @@ -9,7 +9,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Sven Schoenherr @@ -17,6 +17,9 @@ #ifndef CGAL_MIN_SPHERE_ANNULUS_D_TRAITS_2_H #define CGAL_MIN_SPHERE_ANNULUS_D_TRAITS_2_H +#include + + // includes # include # include diff --git a/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_3.h b/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_3.h index 75c7f038d70..a941f4e0b46 100644 --- a/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_3.h +++ b/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_3.h @@ -9,7 +9,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Sven Schoenherr @@ -17,6 +17,9 @@ #ifndef CGAL_MIN_SPHERE_ANNULUS_D_TRAITS_3_H #define CGAL_MIN_SPHERE_ANNULUS_D_TRAITS_3_H +#include + + // includes # include # include diff --git a/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_d.h b/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_d.h index 8d2f13a56c6..ff1feca70bd 100644 --- a/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_d.h +++ b/Bounding_volumes/include/CGAL/Min_sphere_annulus_d_traits_d.h @@ -9,7 +9,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Sven Schoenherr @@ -17,6 +17,9 @@ #ifndef CGAL_MIN_SPHERE_ANULUS_D_TRAITS_D_H #define CGAL_MIN_SPHERE_ANULUS_D_TRAITS_D_H +#include + + // includes # include # include diff --git a/Bounding_volumes/include/CGAL/Min_sphere_d/Min_sphere_d_impl.h b/Bounding_volumes/include/CGAL/Min_sphere_d/Min_sphere_d_impl.h index 17231e575e4..95ebcd1fb31 100644 --- a/Bounding_volumes/include/CGAL/Min_sphere_d/Min_sphere_d_impl.h +++ b/Bounding_volumes/include/CGAL/Min_sphere_d/Min_sphere_d_impl.h @@ -11,6 +11,11 @@ // Author(s) : Sven Schoenherr // Bernd Gaertner +#ifndef CGAL_MIN_SPHERE_D_MIN_SPHERE_D_IMPL_H +#define CGAL_MIN_SPHERE_D_MIN_SPHERE_D_IMPL_H + +#include + #include namespace CGAL { @@ -105,3 +110,5 @@ operator >> ( std::istream& is, Min_sphere_d& min_sphere) } //namespace CGAL // ===== EOF ================================================================== + +#endif //CGAL_MIN_SPHERE_D_MIN_SPHERE_D_IMPL_H diff --git a/CGAL_ImageIO/include/CGAL/ImageIO/analyze_impl.h b/CGAL_ImageIO/include/CGAL/ImageIO/analyze_impl.h index 1c326b6fa1f..86bb69221a0 100644 --- a/CGAL_ImageIO/include/CGAL/ImageIO/analyze_impl.h +++ b/CGAL_ImageIO/include/CGAL/ImageIO/analyze_impl.h @@ -463,60 +463,79 @@ int _readAnalyzeHeader( _image* im, const char* name, for ( i=0; inuser; i++ ) im->user[i] = nullptr; i = 0 ; - im->user[i] = (char *) ImageIO_alloc((strlen("Data lost in the Analyze -> ImageIO conversion:") + 1)); - sprintf( im->user[i++], "Data lost in the Analyze -> ImageIO conversion:" ); + size_t buffer_size; + buffer_size = strlen("Data lost in the Analyze -> ImageIO conversion:") + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, "Data lost in the Analyze -> ImageIO conversion:" ); - im->user[i] = (char *) ImageIO_alloc((strlen(" descrip: ") + 1 + strlen(analyzeHeader->hist.descrip) )); - sprintf( im->user[i++], " descrip: %s", analyzeHeader->hist.descrip ); + buffer_size = snprintf(nullptr, 0, " descrip: %s", analyzeHeader->hist.descrip) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " descrip: %s", analyzeHeader->hist.descrip ); - im->user[i] = (char *) ImageIO_alloc((strlen(" aux_file: ") + 1 + strlen(analyzeHeader->hist.descrip) )); - sprintf( im->user[i++], " aux_file: %s", analyzeHeader->hist.descrip ); + buffer_size = snprintf(nullptr, 0, " aux_file: %s", analyzeHeader->hist.descrip ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " aux_file: %s", analyzeHeader->hist.descrip ); - im->user[i] = (char *) ImageIO_alloc((strlen(" orient: ") + 1+ 2)); - sprintf( im->user[i++], " orient: %d", analyzeHeader->hist.orient ); + buffer_size = snprintf(nullptr, 0, " orient: %d", analyzeHeader->hist.orient ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " orient: %d", analyzeHeader->hist.orient ); - im->user[i] = (char *) ImageIO_alloc((strlen(" originator: ") + 1 + strlen(analyzeHeader->hist.originator) )); - sprintf( im->user[i++], " originator: %s", analyzeHeader->hist.originator ); + buffer_size = snprintf(nullptr, 0, " originator: %s", analyzeHeader->hist.originator ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " originator: %s", analyzeHeader->hist.originator ); - im->user[i] = (char *) ImageIO_alloc((strlen(" generated: ") + 1 + strlen(analyzeHeader->hist.generated) )); - sprintf( im->user[i++], " generated: %s", analyzeHeader->hist.generated ); + buffer_size = snprintf(nullptr, 0, " generated: %s", analyzeHeader->hist.generated ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " generated: %s", analyzeHeader->hist.generated ); - im->user[i] = (char *) ImageIO_alloc((strlen(" scannum: ") + 1 + strlen(analyzeHeader->hist.scannum) )); - sprintf( im->user[i++], " scannum: %s", analyzeHeader->hist.scannum ); + buffer_size = snprintf(nullptr, 0, " scannum: %s", analyzeHeader->hist.scannum ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " scannum: %s", analyzeHeader->hist.scannum ); - im->user[i] = (char *) ImageIO_alloc((strlen(" patient_id: ") + 1 + strlen(analyzeHeader->hist.patient_id) )); - sprintf( im->user[i++], " patient_id: %s", analyzeHeader->hist.patient_id ); + buffer_size = snprintf(nullptr, 0, " patient_id: %s", analyzeHeader->hist.patient_id ) +1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " patient_id: %s", analyzeHeader->hist.patient_id ); - im->user[i] = (char *) ImageIO_alloc((strlen(" exp_date: ") + 1 + strlen(analyzeHeader->hist.exp_date) )); - sprintf( im->user[i++], " exp_date: %s", analyzeHeader->hist.exp_date ); + buffer_size = snprintf(nullptr, 0, " exp_date: %s", analyzeHeader->hist.exp_date ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " exp_date: %s", analyzeHeader->hist.exp_date ); - im->user[i] = (char *) ImageIO_alloc((strlen(" exp_time: ") + 1 + strlen(analyzeHeader->hist.exp_time) )); - sprintf( im->user[i++], " exp_time: %s", analyzeHeader->hist.exp_time ); + buffer_size = snprintf(nullptr, 0, " exp_time: %s", analyzeHeader->hist.exp_time ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " exp_time: %s", analyzeHeader->hist.exp_time ); + buffer_size = snprintf(nullptr, 0, " views: %d", analyzeHeader->hist.views ) + 1; /* A 32 bit int doesn't print on more than 11 chars */ - im->user[i] = (char *) ImageIO_alloc((strlen(" views: ") + 11 + 1)); - sprintf( im->user[i++], " views: %d", analyzeHeader->hist.views ); + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " views: %d", analyzeHeader->hist.views ); - im->user[i] = (char *) ImageIO_alloc((strlen(" vols_added: ") + 11 + 1)); - sprintf( im->user[i++], " vols_added: %d", analyzeHeader->hist.vols_added ); + buffer_size = snprintf(nullptr, 0, " vols_added: %d", analyzeHeader->hist.vols_added ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " vols_added: %d", analyzeHeader->hist.vols_added ); - im->user[i] = (char *) ImageIO_alloc((strlen(" start_field: ") + 11 + 1)); - sprintf( im->user[i++], " start_field: %d", analyzeHeader->hist.start_field ); + buffer_size = snprintf(nullptr, 0, " start_field: %d", analyzeHeader->hist.start_field ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " start_field: %d", analyzeHeader->hist.start_field ); - im->user[i] = (char *) ImageIO_alloc((strlen(" field_skip: ") + 11 + 1)); - sprintf( im->user[i++], " field_skip: %d", analyzeHeader->hist.field_skip ); + buffer_size = snprintf(nullptr, 0, " field_skip: %d", analyzeHeader->hist.field_skip ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " field_skip: %d", analyzeHeader->hist.field_skip ); - im->user[i] = (char *) ImageIO_alloc((strlen(" omax: ") + 11 + 1)); - sprintf( im->user[i++], " omax: %d", analyzeHeader->hist.omax ); + buffer_size = snprintf(nullptr, 0, " omax: %d", analyzeHeader->hist.omax ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " omax: %d", analyzeHeader->hist.omax ); - im->user[i] = (char *) ImageIO_alloc((strlen(" omin: ") + 11 + 1)); - sprintf( im->user[i++], " omin: %d", analyzeHeader->hist.omin ); + buffer_size = snprintf(nullptr, 0, " omin: %d", analyzeHeader->hist.omin ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " omin: %d", analyzeHeader->hist.omin ); - im->user[i] = (char *) ImageIO_alloc((strlen(" smax: ") + 11 + 1)); - sprintf( im->user[i++], " smax: %d", analyzeHeader->hist.smax ); + buffer_size = snprintf(nullptr, 0, " smax: %d", analyzeHeader->hist.smax ) + 1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " smax: %d", analyzeHeader->hist.smax ); - im->user[i] = (char *) ImageIO_alloc((strlen(" smin: ") + 11 + 1)); - sprintf( im->user[i++], " smin: %d", analyzeHeader->hist.smin ); + buffer_size = snprintf(nullptr, 0, " smin: %d", analyzeHeader->hist.smin ) +1; + im->user[i] = (char *) ImageIO_alloc(buffer_size); + snprintf( im->user[i++], buffer_size, " smin: %d", analyzeHeader->hist.smin ); /* header is read. close header file and open data file. */ diff --git a/CGAL_ImageIO/include/CGAL/ImageIO/gis_impl.h b/CGAL_ImageIO/include/CGAL/ImageIO/gis_impl.h index e2d9b5b2818..f9c590dd5a7 100644 --- a/CGAL_ImageIO/include/CGAL/ImageIO/gis_impl.h +++ b/CGAL_ImageIO/include/CGAL/ImageIO/gis_impl.h @@ -130,10 +130,10 @@ int writeGis( char *name, _image* im) { do { memset( str, 0, _LGTH_STRING_ ); for ( j=0; jwordKind) { case WK_FLOAT: - sprintf(type, "float"); + snprintf(type, 30, "float"); scale[0] = '\0'; break; case WK_FIXED: switch(im->sign) { case SGN_SIGNED: - sprintf(type, "signed fixed"); + snprintf(type, 30, "signed fixed"); break; case SGN_UNSIGNED: - sprintf(type, "unsigned fixed"); + snprintf(type, 30, "unsigned fixed"); break; default: return -1; } - sprintf(scale, "SCALE=2**0\n"); + snprintf(scale, 20, "SCALE=2**0\n"); break; default: @@ -101,17 +101,17 @@ int _writeInrimageHeader(const _image *im, ENDIANNESS end) { switch(end) { case END_LITTLE: - sprintf(endianness, "decm"); + snprintf(endianness, 5, "decm"); break; case END_BIG: - sprintf(endianness, "sun"); + snprintf(endianness, 5, "sun"); break; default: /* fix architecture endianness */ if( _getEndianness() == END_LITTLE) - sprintf(endianness, "decm"); + snprintf(endianness, 5, "decm"); else - sprintf(endianness, "sun"); + snprintf(endianness, 5, "sun"); break; } diff --git a/CGAL_ImageIO/include/CGAL/ImageIO/mincio_impl.h b/CGAL_ImageIO/include/CGAL/ImageIO/mincio_impl.h index cd701bb2e89..5addca29f1e 100644 --- a/CGAL_ImageIO/include/CGAL/ImageIO/mincio_impl.h +++ b/CGAL_ImageIO/include/CGAL/ImageIO/mincio_impl.h @@ -357,7 +357,7 @@ int writeMincFile( const _image* im, const char *filename, strcat(newname, filename + i + 1); } else - sprintf(newname, "#TMP#%s", filename); + snprintf(newname,strlen(filename) + 10, "#TMP#%s", filename); } } diff --git a/CGAL_ImageIO/include/CGAL/ImageIO/pnm_impl.h b/CGAL_ImageIO/include/CGAL/ImageIO/pnm_impl.h index 1298dd4e84a..ceb9d7ff68a 100644 --- a/CGAL_ImageIO/include/CGAL/ImageIO/pnm_impl.h +++ b/CGAL_ImageIO/include/CGAL/ImageIO/pnm_impl.h @@ -524,14 +524,14 @@ int writePgmImage(char *name,_image *im ) } if ( im->dataMode == DM_ASCII ) - sprintf( string, "%s\n", PGM_ASCII_MAGIC ); + snprintf( string, 256, "%s\n", PGM_ASCII_MAGIC ); else - sprintf( string, "%s\n", PGM_MAGIC ); + snprintf( string, 256, "%s\n", PGM_MAGIC ); ImageIO_write( im, string, strlen( string ) ); - sprintf( string, "# CREATOR: pnm.c $Revision$ $Date$\n" ); + snprintf( string, 256, "# CREATOR: pnm.c $Revision$ $Date$\n" ); ImageIO_write( im, string, strlen( string ) ); - sprintf( string, "%zu %zu\n", im->xdim, im->ydim ); + snprintf( string, 256, "%zu %zu\n", im->xdim, im->ydim ); ImageIO_write( im, string, strlen( string ) ); max = 0; switch ( im->wdim ) { @@ -552,7 +552,7 @@ int writePgmImage(char *name,_image *im ) } /* max == 0 causes problems for xv */ if ( max == 0 ) max = 1; - sprintf( string, "%d\n", max ); + snprintf( string, 256, "%d\n", max ); ImageIO_write( im, string, strlen( string ) ); if ( im->dataMode == DM_ASCII ) { @@ -574,10 +574,10 @@ int writePgmImage(char *name,_image *im ) do { memset( str, 0, _LGTH_STRING_ ); for ( j=0; jopenMode = OM_CLOSE; return 1; } - - - diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/Intersection_traits.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/Intersection_traits.h index 34ba0ccc386..bab7cfadfc1 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/Intersection_traits.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/Intersection_traits.h @@ -5,11 +5,11 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Philipp Möller and Sebastien Loriot @@ -17,6 +17,9 @@ #ifndef CGAL_CIRCULAR_KERNEL_2_INTERSECTION_TRAITS_H #define CGAL_CIRCULAR_KERNEL_2_INTERSECTION_TRAITS_H +#include + + #include #include diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h index ca10ee63135..544f437b936 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/interface_macros.h @@ -9,6 +9,8 @@ // // Author(s) : Monique Teillaud, Sylvain Pion, Pedro Machado +#include + // Partially supported by the IST Programme of the EU as a Shared-cost // RTD (FET Open) Project under Contract No IST-2000-26473 // (ECG - Effective Computational Geometry for Curves and Surfaces) diff --git a/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/interface_macros.h b/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/interface_macros.h index 32afcea5df7..73dd6f14b37 100644 --- a/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/interface_macros.h +++ b/Circular_kernel_2/include/CGAL/Filtered_bbox_circular_kernel_2/interface_macros.h @@ -9,6 +9,8 @@ // // Author(s) : Monique Teillaud, Sylvain Pion, Pedro Machado +#include + // Partially supported by the IST Programme of the EU as a Shared-cost // RTD (FET Open) Project under Contract No IST-2000-26473 // (ECG - Effective Computational Geometry for Curves and Surfaces) diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Intersection_traits.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Intersection_traits.h index 9612d2ca578..ed6ac62628f 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/Intersection_traits.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/Intersection_traits.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Philipp Möller and Sebastien Loriot @@ -13,6 +13,9 @@ #ifndef CGAL_CIRCULAR_KERNEL_3_INTERSECTION_TRAITS_H #define CGAL_CIRCULAR_KERNEL_3_INTERSECTION_TRAITS_H +#include + + #include #include diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/interface_macros.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/interface_macros.h index dfb43c31298..17d538869ed 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/interface_macros.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/interface_macros.h @@ -10,6 +10,8 @@ // Author(s) : Monique Teillaud, Sylvain Pion, Pedro Machado, // Sebastien Loriot, Julien Hazebrouck, Damien Leroy +#include + // Partially supported by the IST Programme of the EU as a // STREP (FET Open) Project under Contract No IST-006413 // (ACS -- Algorithms for Complex Shapes) diff --git a/Circular_kernel_3/include/CGAL/Spherical_kernel_type_equality_wrapper.h b/Circular_kernel_3/include/CGAL/Spherical_kernel_type_equality_wrapper.h index 5553e556698..7e3e82c822d 100644 --- a/Circular_kernel_3/include/CGAL/Spherical_kernel_type_equality_wrapper.h +++ b/Circular_kernel_3/include/CGAL/Spherical_kernel_type_equality_wrapper.h @@ -11,7 +11,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Monique Teillaud // Sylvain Pion @@ -22,6 +22,9 @@ #ifndef CGAL_SPHERICAL_KERNEL_TYPE_EQUALITY_WRAPPER_H #define CGAL_SPHERICAL_KERNEL_TYPE_EQUALITY_WRAPPER_H +#include + + #include #include #include diff --git a/Cone_spanners_2/examples/Cone_spanners_2/CMakeLists.txt b/Cone_spanners_2/examples/Cone_spanners_2/CMakeLists.txt index ded37dfad08..99442720fc1 100644 --- a/Cone_spanners_2/examples/Cone_spanners_2/CMakeLists.txt +++ b/Cone_spanners_2/examples/Cone_spanners_2/CMakeLists.txt @@ -5,21 +5,10 @@ find_package(CGAL REQUIRED OPTIONAL_COMPONENTS Core) find_package(LEDA QUIET) if(CGAL_Core_FOUND OR LEDA_FOUND) - if(MSVC) - # Turn off a boost related warning that appears with VC2015 - # boost_1_65_1\boost\graph\named_function_params.hpp(240) : - # warning C4172: returning address of local variable or temporary - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4172") - endif() - - # create a target per cppfile - file( - GLOB cppfiles - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) - foreach(cppfile ${cppfiles}) - create_single_source_cgal_program("${cppfile}") - endforeach() + create_single_source_cgal_program("compute_cones.cpp") + create_single_source_cgal_program("theta_io.cpp") else() message("NOTICE: This program requires the CGAL_Core library (or LEDA), and will not be compiled.") endif() + +create_single_source_cgal_program("dijkstra_theta.cpp") diff --git a/Cone_spanners_2/include/CGAL/Compute_cone_boundaries_2.h b/Cone_spanners_2/include/CGAL/Compute_cone_boundaries_2.h index 74e12a8f4db..4256fd0dc17 100644 --- a/Cone_spanners_2/include/CGAL/Compute_cone_boundaries_2.h +++ b/Cone_spanners_2/include/CGAL/Compute_cone_boundaries_2.h @@ -30,7 +30,9 @@ #include #include // CGAL_PI is defined there #include +#if defined(CGAL_USE_LEDA) || defined(CGAL_USE_CORE) #include +#endif #include namespace CGAL { @@ -111,7 +113,7 @@ public: }; - +#if defined(CGAL_USE_LEDA) || defined(CGAL_USE_CORE) /* The specialised functor for computing the directions of cone boundaries exactly with a given cone number and a given initial direction. @@ -209,6 +211,7 @@ public: } // end of operator() }; // end of functor specialization: Compute_cone_..._2 +#endif } // namespace CGAL diff --git a/Cone_spanners_2/include/CGAL/Cone_spanners_2/Less_by_direction_2.h b/Cone_spanners_2/include/CGAL/Cone_spanners_2/Less_by_direction_2.h index 6ba9f53652e..e36137df8fb 100644 --- a/Cone_spanners_2/include/CGAL/Cone_spanners_2/Less_by_direction_2.h +++ b/Cone_spanners_2/include/CGAL/Cone_spanners_2/Less_by_direction_2.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include diff --git a/Cone_spanners_2/test/Cone_spanners_2/CMakeLists.txt b/Cone_spanners_2/test/Cone_spanners_2/CMakeLists.txt index 462edfc7819..17c47060a82 100644 --- a/Cone_spanners_2/test/Cone_spanners_2/CMakeLists.txt +++ b/Cone_spanners_2/test/Cone_spanners_2/CMakeLists.txt @@ -5,12 +5,16 @@ cmake_minimum_required(VERSION 3.1...3.23) project(Cone_spanners_2_Tests) find_package(CGAL REQUIRED COMPONENTS Core) +find_package(LEDA QUIET) -# create a target per cppfile -file( - GLOB cppfiles - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) -foreach(cppfile ${cppfiles}) - create_single_source_cgal_program("${cppfile}") -endforeach() +create_single_source_cgal_program("cones_inexact.cpp") +create_single_source_cgal_program("theta_inexact.cpp") +create_single_source_cgal_program("yao_inexact.cpp") + +if(CGAL_Core_FOUND OR LEDA_FOUND) + create_single_source_cgal_program("cones_exact.cpp") + create_single_source_cgal_program("theta_exact.cpp") + create_single_source_cgal_program("yao_exact.cpp") +else() + message("NOTICE: Some tests require the CGAL_Core library (or LEDA), and will not be compiled.") +endif() diff --git a/Convex_hull_2/include/CGAL/Convex_hull_traits_adapter_2.h b/Convex_hull_2/include/CGAL/Convex_hull_traits_adapter_2.h index f5aa3fe06d7..eb7f87c96ea 100644 --- a/Convex_hull_2/include/CGAL/Convex_hull_traits_adapter_2.h +++ b/Convex_hull_2/include/CGAL/Convex_hull_traits_adapter_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Sebastien Loriot @@ -13,6 +13,9 @@ #ifndef CGAL_CONVEX_HULL_TRAITS_ADAPTER_2_H #define CGAL_CONVEX_HULL_TRAITS_ADAPTER_2_H +#include + + #include #include diff --git a/Documentation/doc/Documentation/Doxyfile.in b/Documentation/doc/Documentation/Doxyfile.in index e33963e5c87..d3e21f24daa 100644 --- a/Documentation/doc/Documentation/Doxyfile.in +++ b/Documentation/doc/Documentation/Doxyfile.in @@ -34,4 +34,4 @@ SEARCHENGINE = true ALIASES += "cgalPkgDescriptionBegin{2}=\subsection \2 \1" ALIASES += "cgalPkgManuals{2}=
          \ref \1 \"User Manual\" \ref \2 \"Reference Manual\"
          " -ALIASES += "cgalReleaseNumber =${CGAL_DOC_VERSION}" +ALIASES += "cgalReleaseNumber=${CGAL_DOC_VERSION}" diff --git a/Documentation/doc/resources/1.10.0/header_package.html b/Documentation/doc/resources/1.10.0/header_package.html index 827e05a9663..f2309e17bcd 100644 --- a/Documentation/doc/resources/1.10.0/header_package.html +++ b/Documentation/doc/resources/1.10.0/header_package.html @@ -26,6 +26,7 @@ + diff --git a/Documentation/doc/resources/1.10.0/menu_version.js b/Documentation/doc/resources/1.10.0/menu_version.js index f3b20c2fe00..5b8d97efba0 100644 --- a/Documentation/doc/resources/1.10.0/menu_version.js +++ b/Documentation/doc/resources/1.10.0/menu_version.js @@ -7,9 +7,9 @@ var all_versions = [ 'master', '6.0-beta1', - '5.6', + '5.6.1', 'latest', - '5.5.2', + '5.5.4', '5.4.4', '5.3.2', '5.2.4', diff --git a/Documentation/doc/resources/1.8.13/menu_version.js b/Documentation/doc/resources/1.8.13/menu_version.js index f3b20c2fe00..5b8d97efba0 100644 --- a/Documentation/doc/resources/1.8.13/menu_version.js +++ b/Documentation/doc/resources/1.8.13/menu_version.js @@ -7,9 +7,9 @@ var all_versions = [ 'master', '6.0-beta1', - '5.6', + '5.6.1', 'latest', - '5.5.2', + '5.5.4', '5.4.4', '5.3.2', '5.2.4', diff --git a/Documentation/doc/resources/1.9.6/menu_version.js b/Documentation/doc/resources/1.9.6/menu_version.js index f3b20c2fe00..5b8d97efba0 100644 --- a/Documentation/doc/resources/1.9.6/menu_version.js +++ b/Documentation/doc/resources/1.9.6/menu_version.js @@ -7,9 +7,9 @@ var all_versions = [ 'master', '6.0-beta1', - '5.6', + '5.6.1', 'latest', - '5.5.2', + '5.5.4', '5.4.4', '5.3.2', '5.2.4', diff --git a/Envelope_2/include/CGAL/Envelope_2/Env_divide_and_conquer_2.h b/Envelope_2/include/CGAL/Envelope_2/Env_divide_and_conquer_2.h index 4e17e189b11..adda5dca064 100644 --- a/Envelope_2/include/CGAL/Envelope_2/Env_divide_and_conquer_2.h +++ b/Envelope_2/include/CGAL/Envelope_2/Env_divide_and_conquer_2.h @@ -15,13 +15,11 @@ #include -#include -#include - #include - #include +#include +#include namespace CGAL { @@ -29,11 +27,9 @@ namespace CGAL { * A class implementing the divide-and-conquer algorithm for computing the * lower (or upper) envelope of a set of curves. */ -template -class Envelope_divide_and_conquer_2 -{ +template +class Envelope_divide_and_conquer_2 { public: - typedef Traits_ Traits_2; typedef typename Traits_2::Point_2 Point_2; typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; @@ -42,11 +38,9 @@ public: typedef Diagram_ Envelope_diagram_1; protected: - typedef Envelope_divide_and_conquer_2 Self; - enum Envelope_type - { + enum Envelope_type { LOWER, UPPER }; @@ -62,159 +56,118 @@ protected: typedef Arr_traits_adaptor_2 Traits_adaptor_2; // Data members: - const Traits_adaptor_2 *traits; // The traits object. - bool own_traits; // Whether we own the traits object. - Envelope_type env_type; // Either LOWER or UPPER. + const Traits_adaptor_2* traits; // The traits object. + bool own_traits; // Whether we own the traits object. + Envelope_type env_type; // Either LOWER or UPPER. // Copy constructor and assignment operator - not supported. - Envelope_divide_and_conquer_2 (const Self& ); - Self& operator= (const Self& ); + Envelope_divide_and_conquer_2(const Self&); + Self& operator=(const Self& ); public: - - /*! - * Constructor. + /*! Constructor. */ - Envelope_divide_and_conquer_2 () : + Envelope_divide_and_conquer_2() : own_traits(true), env_type(LOWER) - { - traits = new Traits_adaptor_2; - } + { traits = new Traits_adaptor_2; } - /*! - * Constructor with a traits object. + /*! Constructor with a traits object. * \param _traits The traits object. */ - Envelope_divide_and_conquer_2 (const Traits_2* _traits) : + Envelope_divide_and_conquer_2(const Traits_2* _traits) : own_traits(false), env_type(LOWER) - { - traits = static_cast (_traits); - } + { traits = static_cast (_traits); } - /*! - * Destructor. + /*! Destructor. */ - ~Envelope_divide_and_conquer_2 () - { - if (own_traits) - delete traits; - } + ~Envelope_divide_and_conquer_2() + { if (own_traits) delete traits; } - /*! - * Construct the lower (or upper) envelope to the given range of curves. + /*! Construct the lower (or upper) envelope to the given range of curves. * \param begin An iterator pointing at the beginning of the curves range. * \param end A past-the-end iterator for the curves range. * \param type The envelope type (true for lower, false of upper). * \param diagram Output: The minimization (or maximization) diagram. */ - template - void insert_curves (CurvesIterator begin, CurvesIterator end, - bool type, - Envelope_diagram_1& diagram) - { + template + void insert_curves(CurvesIterator begin, CurvesIterator end, bool type, + Envelope_diagram_1& diagram) { // Subdivide the curves into x-monotone subcurves. - CurvesIterator it; std::list> objects; - std::list x_curves; + std::list x_curves; - for (it = begin; it != end; it++) - { + for (auto it = begin; it != end; ++it) { // Split the current curve to x-monotone subcurves. objects.clear(); traits->make_x_monotone_2_object()(*it, std::back_inserter(objects)); - for (auto obj_it = objects.begin(); obj_it != objects.end(); ++obj_it) - { - if(const X_monotone_curve_2* xcv_ptr = std::get_if(&(*obj_it))) + for (auto obj_it = objects.begin(); obj_it != objects.end(); ++obj_it) { + if (const auto* xcv_ptr = std::get_if(&(*obj_it))) x_curves.push_back (*xcv_ptr); } } // Construct the envelope of the x-monotone curves. - insert_x_monotone_curves (x_curves.begin(), x_curves.end(), - type, - diagram); - return; + insert_x_monotone_curves(x_curves.begin(), x_curves.end(), type, diagram); } - /*! - * Construct the lower (or upper) envelope to the given range of + /*! Construct the lower (or upper) envelope to the given range of * x-monotone curves. * \param begin An iterator pointing at the beginning of the curves range. * \param end A past-the-end iterator for the curves range. * \param type The envelope type (true for lower, false for upper). * \param diagram Output: The minimization (or maximization) diagram. */ - template - void insert_x_monotone_curves (XCurvesIterator begin, XCurvesIterator end, - bool type, - Envelope_diagram_1& diagram) - { + template + void insert_x_monotone_curves(XCurvesIterator begin, XCurvesIterator end, + bool type, Envelope_diagram_1& diagram) { // Set the envelope type. env_type = (type ? LOWER : UPPER); // Separate the regular curves from the vertical ones. - typename Traits_2::Is_vertical_2 is_vertical = - traits->is_vertical_2_object(); + auto is_vertical = traits->is_vertical_2_object(); - Curve_pointer_vector reg_vec; - Curve_pointer_vector vert_vec; - XCurvesIterator iter; + Curve_pointer_vector reg_vec; + Curve_pointer_vector vert_vec; - for (iter = begin; iter != end; ++iter) - { - if (is_vertical (*iter)) - vert_vec.push_back (&(*iter)); - else - reg_vec.push_back (&(*iter)); + for (auto iter = begin; iter != end; ++iter) { + if (is_vertical (*iter)) vert_vec.push_back (&(*iter)); + else reg_vec.push_back (&(*iter)); } // Construct the envelope for the non-vertical curves. - _construct_envelope_non_vertical (reg_vec.begin(), reg_vec.end(), - diagram); + _construct_envelope_non_vertical(reg_vec.begin(), reg_vec.end(), diagram); // Merge the vertical segments. - if (vert_vec.size() > 0) - _merge_vertical_segments (vert_vec, - diagram); - - return; + if (vert_vec.size() > 0) _merge_vertical_segments(vert_vec, diagram); } - /*! - * Get the traits object. + /*! Get the traits object. * \return A pointer to the traits object. */ - Traits_2* get_traits () const - { - return (traits); - } + Traits_2* get_traits() const { return (traits); } protected: - - /*! - * Construct the lower/upper envelope of the given list of non-vertical + /*! Construct the lower/upper envelope of the given list of non-vertical * curves. * \param begin The first x-monotone curve. * \param end A past-the-end iterator for the curves. * \param out_d Output: The minimization (or maximization) diagram. */ - void _construct_envelope_non_vertical (Curve_pointer_iterator begin, - Curve_pointer_iterator end, - Envelope_diagram_1& out_d); + void _construct_envelope_non_vertical(Curve_pointer_iterator begin, + Curve_pointer_iterator end, + Envelope_diagram_1& out_d); - /*! - * Construct a singleton diagram, which matches a single curve. + /*! Construct a singleton diagram, which matches a single curve. * \param cv The x-monotone curve. * \param out_d Output: The minimization (or maximization) diagram. */ void _construct_singleton_diagram (const X_monotone_curve_2& cv, Envelope_diagram_1& out_d); - /* - * Merge two minimization (or maximization) diagrams. + /* Merge two minimization (or maximization) diagrams. * \param d1 The first diagram, * representing the envelope of the curve set C1. * \param d1 The first diagram, @@ -222,12 +175,11 @@ protected: * \param out_d Output: The merged diagram, representing the envelope of * the union of C1 and C2. */ - void _merge_envelopes (const Envelope_diagram_1& d1, - const Envelope_diagram_1& d2, - Envelope_diagram_1& out_d); + void _merge_envelopes(const Envelope_diagram_1& d1, + const Envelope_diagram_1& d2, + Envelope_diagram_1& out_d); - /*! - * Compare two vertices. + /*! Compare two vertices. * \param v1 The first vertex. * \param v2 The second vertex. * \param same_x Output parameter: TRUE iff x(v1) = x(v2). @@ -239,13 +191,12 @@ protected: * - we compute the upper envelope, and y(v1) < y(v2). * EQUAL if v1 = v2. */ - Comparison_result _compare_vertices (Vertex_const_handle v1, - Vertex_const_handle v2, - bool& same_x) const; + Comparison_result _compare_vertices(Vertex_const_handle v1, + Vertex_const_handle v2, + bool& same_x) const; - /*! - * Deal with an interval which is non-empty in one of the merged diagrams and - * empty in the other. + /*! Deal with an interval which is non-empty in one of the merged diagrams + * and empty in the other. * \param e The non-empty edge. * \param other_edge The empty edge. * \param v The next vertex to the right. @@ -256,33 +207,32 @@ protected: * the same place. * \param out_d The merged diagram. */ - void _merge_single_interval (Edge_const_handle e, - Edge_const_handle other_edge, - Vertex_const_handle v, bool v_exists, - Comparison_result origin_of_v, - Envelope_diagram_1& out_d); + void _merge_single_interval(Edge_const_handle e, + Edge_const_handle other_edge, + Vertex_const_handle v, bool v_exists, + Comparison_result origin_of_v, + Envelope_diagram_1& out_d); - //! Compare the $y$-coordinates of two curves at their endpoints - /*! The function compares the $y$ values of two curves with a joint - range of $x$ values, at the end of the joint range. - \param xcv1 The first curve - \param xcv2 The second curve - \param curve_end ARR_MIN_END - compare the $y$ value of the smaller - endpoint, ARR_MAX_END - compare the $y$ value of the larger endpoint. - \pre The two $x$-monotone curves need to have a partially overlapping - $x$-ranges. - \return - \todo Move it to Arr_traits_adaptor ? - */ + /*! Compare the $y$-coordinates of two curves at their endpoints + * The function compares the $y$ values of two curves with a joint + * range of $x$ values, at the end of the joint range. + * \param xcv1 The first curve + * \param xcv2 The second curve + * \param curve_end ARR_MIN_END - compare the $y$ value of the smaller + * endpoint, ARR_MAX_END - compare the $y$ value of the larger endpoint. + * \pre The two $x$-monotone curves need to have a partially overlapping + * $x$-ranges. + * \return + * \todo Move it to Arr_traits_adaptor ? + */ Comparison_result compare_y_at_end(const X_monotone_curve_2& xcv1, const X_monotone_curve_2& xcv2, Arr_curve_end curve_end) const; - /*! - * Merge two non-empty intervals into the merged diagram. + /*! Merge two non-empty intervals into the merged diagram. * \param e1 The first non-empty edge. * \param is_leftmost1 Is it the leftmost edge in its diagram. * \param e2 The second non-empty edge. @@ -295,14 +245,13 @@ protected: * is still taken from e2. * \param out_d The merged diagram. */ - void _merge_two_intervals (Edge_const_handle e1, bool is_leftmost1, - Edge_const_handle e2, bool is_leftmost2, - Vertex_const_handle v, bool v_exists, - Comparison_result origin_of_v, - Envelope_diagram_1& out_d); + void _merge_two_intervals(Edge_const_handle e1, bool is_leftmost1, + Edge_const_handle e2, bool is_leftmost2, + Vertex_const_handle v, bool v_exists, + Comparison_result origin_of_v, + Envelope_diagram_1& out_d); - /*! - * Append a vertex to the given diagram: The new vertex that represents the + /*! Append a vertex to the given diagram: The new vertex that represents the * given point as the new rightmost vertex of the diagram. The edge * between the current rightmost vertex and the new one contains the same * curves as the input edge. @@ -311,53 +260,45 @@ protected: * \param e The input edge. * \return A handle for the vertex. */ - Vertex_handle _append_vertex (Envelope_diagram_1& diag, - const Point_2& p, Edge_const_handle e); + Vertex_handle _append_vertex(Envelope_diagram_1& diag, + const Point_2& p, Edge_const_handle e); /*! \struct * A functor used to sort vertical segments by their x-coordinate. */ - class Less_vertical_segment - { + class Less_vertical_segment { private: - typename Traits_2::Compare_x_2 comp_x; typename Traits_2::Construct_min_vertex_2 min_vertex; public: - - Less_vertical_segment (const Traits_2 *traits) : + Less_vertical_segment(const Traits_2 *traits) : comp_x(traits->compare_x_2_object()), min_vertex(traits->construct_min_vertex_2_object()) {} - bool operator() (const X_monotone_curve_2 *cv1, - const X_monotone_curve_2 *cv2) const - { - return (comp_x (min_vertex (*cv1), - min_vertex (*cv2)) == SMALLER); - } + bool operator()(const X_monotone_curve_2* cv1, + const X_monotone_curve_2* cv2) const + { return(comp_x(min_vertex(*cv1), min_vertex(*cv2)) == SMALLER); } }; - /*! - * Merge the vertical segments into the lower/upper envelope given as a + /*! Merge the vertical segments into the lower/upper envelope given as a * minimization (or maximization) diagram. * \param vert_vec The list of vertical segments. * \param out_d The input minimization (or maximization) diagram. * The function merges the vertical segments into this diagram. */ - void _merge_vertical_segments (Curve_pointer_vector& vert_vec, - Envelope_diagram_1& out_d); + void _merge_vertical_segments(Curve_pointer_vector& vert_vec, + Envelope_diagram_1& out_d); - /*! - * Split a given diagram edge by inserting a vertex in its interior. + /*! Split a given diagram edge by inserting a vertex in its interior. * \param diag The diagram. * \param p The point that the new vertex is associated with. * \param e The edge to split. * \return A handle for the vertex. */ - Vertex_handle _split_edge (Envelope_diagram_1& diag, - const Point_2& p, Edge_handle e); + Vertex_handle _split_edge(Envelope_diagram_1& diag, + const Point_2& p, Edge_handle e); }; diff --git a/Envelope_2/include/CGAL/Envelope_diagram_1.h b/Envelope_2/include/CGAL/Envelope_diagram_1.h index 2d7b8e9f819..6a3f533a111 100644 --- a/Envelope_2/include/CGAL/Envelope_diagram_1.h +++ b/Envelope_2/include/CGAL/Envelope_diagram_1.h @@ -7,7 +7,8 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Ron Wein +// Author(s): Ron Wein +// Efi Fogel #ifndef CGAL_ENVELOPE_DIAGRAM_1_H #define CGAL_ENVELOPE_DIAGRAM_1_H @@ -26,7 +27,7 @@ namespace CGAL { * A minimization (or a maximization) diagram that represents the lower (or the * upper) envelope of a set of curves in the plane. */ -template +template class Envelope_diagram_1 { public: typedef Traits_ Traits_2; @@ -37,228 +38,138 @@ public: typedef typename Curve_container::const_iterator Curve_const_iterator; typedef std::size_t Size; - /*! - * Representation of a diagram vertex, which stores the point it represents + /*! Representation of a diagram vertex, which stores the point it represents * and a list of all curves that pass at that point. */ class Edge; class Vertex { private: - Point_2 _p; - Curve_container _cvs; + Point_2 _p; + Curve_container _cvs; Edge* _leftP; Edge* _rightP; public: /*! Constructor. */ - Vertex () : + Vertex() : _leftP(nullptr), _rightP(nullptr) {} /*! Constructor with a point. */ - Vertex (const Point_2& p) : + Vertex(const Point_2& p) : _p(p), _leftP(nullptr), _rightP(nullptr) {} /*! Get the point. */ - const Point_2& point () const - { - return (_p); - } + const Point_2& point() const { return _p; } /*! Get the number of curves associated with the vertex. */ - Size number_of_curves () const - { - return (_cvs.size()); - } + Size number_of_curves() const { return _cvs.size(); } /*! Get the range of curves associated with the vertex. */ - Curve_const_iterator curves_begin () const - { - return (_cvs.begin()); - } + Curve_const_iterator curves_begin() const { return _cvs.begin(); } - Curve_const_iterator curves_end () const - { - return (_cvs.end()); - } + Curve_const_iterator curves_end() const { return _cvs.end(); } /*! Get the left edge (const version). */ - const Edge* left () const - { - return (_leftP); - } + const Edge* left() const { return _leftP; } /*! Get the left edge (non-const version). */ - Edge* left () - { - return (_leftP); - } + Edge* left() { return _leftP; } /*! Get the right edge (const version). */ - const Edge* right () const - { - return (_rightP); - } + const Edge* right() const { return _rightP; } /*! Get the right edge (non-const version). */ - Edge* right () - { - return (_rightP); - } + Edge* right() { return _rightP; } /*! Set the point. */ - void set_point (const Point_2& p) - { - _p = p; - } + void set_point (const Point_2& p) { _p = p; } /*! Clear the list of curves. */ - void clear_curves () - { - _cvs.clear(); - } + void clear_curves() { _cvs.clear(); } /*! Associate a new curve with the vertex. */ - void add_curve (const X_monotone_curve_2& cv) - { - _cvs.push_back (cv); - } + void add_curve(const X_monotone_curve_2& cv) { _cvs.push_back(cv); } /*! Associate a range of new curves with the vertex. */ - void add_curves (Curve_const_iterator begin, Curve_const_iterator end) - { - Curve_const_iterator iter; - - for (iter = begin; iter != end; ++iter) - _cvs.push_back (*iter); - } + void add_curves(Curve_const_iterator begin, Curve_const_iterator end) + { for (auto iter = begin; iter != end; ++iter) _cvs.push_back(*iter); } /*! Set the left edge. */ - void set_left (Edge* e) - { - _leftP = e; - } + void set_left(Edge* e) { _leftP = e; } /*! Get the right edge. */ - void set_right (Edge* e) - { - _rightP = e; - } + void set_right(Edge* e) { _rightP = e; } }; - /*! - * Representation of a diagram edge, which represents an interval and + /*! Representation of a diagram edge, which represents an interval and * stores all curves that form the envelope on it (usually there's just one * curve or zero curves, unless the input contains overlapping curves). */ - class Edge - { + class Edge { private: - Curve_container _cvs; + Curve_container _cvs; Vertex* _leftP; Vertex* _rightP; public: /*! Constructor. */ - Edge () : + Edge() : _leftP(nullptr), _rightP(nullptr) {} /*! Check if the edge represents an empty interval. */ - bool is_empty () const - { - return (_cvs.empty()); - } + bool is_empty() const { return _cvs.empty(); } /*! Get the number of curves associated with the edge. */ - Size number_of_curves () const - { - return (_cvs.size()); - } + Size number_of_curves() const { return _cvs.size(); } - /*! - * Get a representative x-monotone curve. + /*! Get a representative x-monotone curve. * \pre The edge does not represent an empty interval. */ - const X_monotone_curve_2& curve () const - { - CGAL_precondition (! _cvs.empty()); + const X_monotone_curve_2& curve() const { + CGAL_precondition(! _cvs.empty()); return (*(_cvs.begin())); } /*! Get the range of curves associated with the edge. */ - Curve_const_iterator curves_begin () const - { - return (_cvs.begin()); - } + Curve_const_iterator curves_begin() const { return _cvs.begin(); } - Curve_const_iterator curves_end () const - { - return (_cvs.end()); - } + Curve_const_iterator curves_end() const { return _cvs.end(); } /*! Get the left vertex (const version). */ - const Vertex* left () const - { - return (_leftP); - } + const Vertex* left() const { return _leftP; } /*! Get the left vertex (const version). */ - Vertex* left () - { - return (_leftP); - } + Vertex* left() { return _leftP; } /*! Get the right vertex (const version). */ - const Vertex* right () const - { - return (_rightP); - } + const Vertex* right() const { return _rightP; } /*! Get the right vertex (non-const version). */ - Vertex* right () - { - return (_rightP); - } + Vertex* right() { return _rightP; } /*! Clear the list of curves. */ - void clear_curves () - { - _cvs.clear(); - } + void clear_curves() { _cvs.clear(); } /*! Associate a new curve with the edge. */ - void add_curve (const X_monotone_curve_2& cv) - { - _cvs.push_back (cv); - } + void add_curve(const X_monotone_curve_2& cv) { _cvs.push_back (cv); } /*! Associate a range of new curves with the edge. */ - void add_curves (Curve_const_iterator begin, Curve_const_iterator end) - { - Curve_const_iterator iter; - - for (iter = begin; iter != end; ++iter) - _cvs.push_back (*iter); - } + void add_curves(Curve_const_iterator begin, Curve_const_iterator end) + { for (auto iter = begin; iter != end; ++iter) _cvs.push_back (*iter); } /*! Set the left vertex. */ - void set_left (Vertex* v) - { - _leftP = v; - } + void set_left(Vertex* v) { _leftP = v; } /*! Get the right vertex. */ - void set_right (Vertex* v) - { - _rightP = v; - } + void set_right(Vertex* v) { _rightP = v; } }; typedef Vertex* Vertex_handle; @@ -267,7 +178,6 @@ public: typedef const Edge* Edge_const_handle; private: - // Vertex allocator. typedef std::allocator_traits Allocator_traits; typedef typename Allocator_traits::template rebind_alloc Vertex_allocator; @@ -280,143 +190,111 @@ private: Edge* _rightmostP; // The rightmost edge of the diagram // (representing the range to +oo). - Vertex_allocator vertex_alloc; // An allocator for vertices. - Edge_allocator edge_alloc; // An allocator for edges. + Vertex_allocator vertex_alloc; // An allocator for vertices. + Edge_allocator edge_alloc; // An allocator for edges. public: - - /*! - * Constructor. + /*! Constructor. + * An empty diagram contains one (empty) edge, representing (-oo, +oo): */ - Envelope_diagram_1 () - { - // An empty diagram contains one (empty) edge, representing (-oo, +oo): - _leftmostP = _rightmostP = new_edge(); + Envelope_diagram_1() { _leftmostP = _rightmostP = new_edge(); } + + /*! Move constructor. + */ + Envelope_diagram_1(Envelope_diagram_1&& other) { + _leftmostP = other._leftmostP; + _rightmostP = other._rightmostP; + other._leftmostP = other._rightmostP = new_edge(); } - /*! - * Destructor. + /*! Move assignment operator. */ - ~Envelope_diagram_1 () - { - _free(); + Envelope_diagram_1& operator=(Envelope_diagram_1&& other) { + _leftmostP = other._leftmostP; + _rightmostP = other._rightmostP; + other._leftmostP = other._rightmostP = new_edge(); + return *this; } - /*! - * Get the leftmost edge of the diagram (const version). + /*! Destructor. */ - Edge_const_handle leftmost () const - { - return (_leftmostP); - } + ~Envelope_diagram_1() { _free(); } - /*! - * Get the leftmost edge of the diagram (non-const version). + /*! Get the leftmost edge of the diagram (const version). */ - Edge_handle leftmost () - { - return (_leftmostP); - } + Edge_const_handle leftmost() const { return _leftmostP; } - /*! - * Get the rightmost edge of the diagram (const version). + /*! Get the leftmost edge of the diagram (non-const version). */ - Edge_const_handle rightmost () const - { - return (_rightmostP); - } + Edge_handle leftmost() { return _leftmostP; } - /*! - * Get the rightmost edge of the diagram (non-const version). + /*! Get the rightmost edge of the diagram (const version). */ - Edge_handle rightmost () - { - return (_rightmostP); - } + Edge_const_handle rightmost() const { return _rightmostP; } - /*! - * Clear the diagram. + /*! Get the rightmost edge of the diagram (non-const version). */ - void clear () - { + Edge_handle rightmost() { return _rightmostP; } + + /*! Clear the diagram. + */ + void clear() { _free(); // An empty diagram contains one (empty) edge, representing (-oo, +oo): _leftmostP = _rightmostP = new_edge(); } - /*! - * Set the leftmost edge. + /*! Set the leftmost edge. */ - void set_leftmost (Edge_handle e) - { - _leftmostP = e; - } + void set_leftmost(Edge_handle e) { _leftmostP = e; } - /*! - * Set the rightmost edge. + /*! Set the rightmost edge. */ - void set_rightmost (Edge_handle e) - { - _rightmostP = e; - } + void set_rightmost(Edge_handle e) { _rightmostP = e; } - /*! Create a new vertex. */ - Vertex_handle new_vertex (const Point_2& p) - { + /*! Create a new vertex. + */ + Vertex_handle new_vertex(const Point_2& p) { Vertex* v = vertex_alloc.allocate (1); std::allocator_traits::construct(vertex_alloc, v, p); return (v); } - /*! Create a new edge. */ - Edge_handle new_edge () - { + /*! Create a new edge. + */ + Edge_handle new_edge() { Edge* e = edge_alloc.allocate (1); std::allocator_traits::construct(edge_alloc, e); return (e); } - /*! Delete an existing vertex. */ - void delete_vertex (Vertex_handle v) - { + /*! Delete an existing vertex. + */ + void delete_vertex(Vertex_handle v) { std::allocator_traits::destroy(vertex_alloc, v); vertex_alloc.deallocate (v, 1); } - /*! Delete an existing edge. */ - void delete_edge (Edge_handle e) - { + /*! Delete an existing edge. + */ + void delete_edge(Edge_handle e) { std::allocator_traits::destroy(edge_alloc, e); edge_alloc.deallocate (e, 1); } private: - /*! - * Free all diagram elements. + /*! Free all diagram elements. */ - void _free () - { - Vertex* v; + void _free() { Edge* e = _leftmostP; - while (e != nullptr) { - // Get a pointer to the next vertex. - v = e->right(); + Vertex* v = e->right(); + delete_edge(e); + if (v == nullptr) break; - // Free the edge and update it to be the next one after v. - delete_edge (e); - - if (v != nullptr) { - e = v->right(); - - // Free the current vertex. - delete_vertex (v); - } - else - { - e = nullptr; - } + e = v->right(); + delete_vertex(v); } _leftmostP = nullptr; diff --git a/Envelope_3/doc/Envelope_3/CGAL/Env_plane_traits_3.h b/Envelope_3/doc/Envelope_3/CGAL/Env_plane_traits_3.h index 81d5861e3c8..21872b31f57 100644 --- a/Envelope_3/doc/Envelope_3/CGAL/Env_plane_traits_3.h +++ b/Envelope_3/doc/Envelope_3/CGAL/Env_plane_traits_3.h @@ -1,39 +1,43 @@ namespace CGAL { -/*! -\ingroup PkgEnvelope3Ref - -The traits class `Env_plane_traits_3` models the `EnvelopeTraits_3` concept, -and is used for the construction of lower and upper envelopes of planes -and half planes in the space. It is parameterized by a \cgal-kernel model, -which is parameterized in turn by a number type. The number type should -support exact rational arithmetic, to avoid numerical errors and -robustness problems. In particular, the number type should support the -arithmetic operations \f$ +\f$, \f$ -\f$, \f$ \times\f$, and \f$ \div\f$ without loss of -precision. For optimal performance, we recommend instantiating the traits -class with the predefined -`Exact_predicates_exact_constructions_kernel` provided by \cgal. -Using this kernel guarantees exactness and robustness, while it incurs -only a minor overhead (in comparison to working with a fast, inexact number -type) for most inputs. - -Note that an entire plane has no boundaries, and the projection of a -half-plane is an (unbounded) line. Naturally, rays and segments may occur as -a result of overlaying projections of several half planes. Indeed, -`Env_plane_traits_3` inherits from the `Arr_linear_traits_2` traits -class, and extends it by adding operations on planes and half planes. -The nested `Xy_monotone_surface_3` and `Surface_3` types refer -to the same type. They are constructible from a `Kernel::Plane_3` -in case of an entire plane, or from `Kernel::Plane_3` and -`Kernel::Line_2` in case of a half-plane. The line orientation -determines which half is considered. - -\cgalModels{EnvelopeTraits_3} - -*/ -template< typename Kernel > -class Env_plane_traits_3 : public Arr_linear_traits_2 { +/*! \ingroup PkgEnvelope3Ref + * + * The traits class template `Env_plane_traits_3` models the `EnvelopeTraits_3` + * concept, and is used for the construction of lower and upper envelopes of + * planes and half planes in the space. When the template is instantiated, the + * template parameter `Kernel` must be substituted by a \cgal-kernel model, the + * number type of which should support exact rational arithmetic, to avoid + * numerical errors and robustness problems. In particular, the number type + * should support the arithmetic operations \f$ +\f$, \f$ -\f$, \f$ \times\f$, + * and \f$ \div\f$ without loss of precision. For optimal performance, we + * recommend instantiating the traits class with the predefined + * `Exact_predicates_exact_constructions_kernel` provided by \cgal. Using this + * kernel guarantees exactness and robustness, while it incurs only a minor + * overhead (in comparison to working with a fast, inexact number type) for most + * inputs. + * + * The second template parameter, namely `ArrLinearTraits`, should be + * substituted by a 2D arrangement geometry traits class that supports unbounded + * linear objects, i.e, lines, rays, and segments. By default it is substituted + * by `Arr_linear_traits_2`. + * + * Note that an entire plane has no boundaries, and the projection of a + * half-plane is an (unbounded) line. Naturally, rays and segments may occur as + * a result of overlaying projections of several half planes. Indeed, + * `Env_plane_traits_3` inherits from the traits class that substitutes + * `ArrLinearTraits`, and extends it by adding operations on planes and half + * planes. The nested `Xy_monotone_surface_3` and `Surface_3` types refer to + * the same type. They are constructible from a `Kernel::Plane_3` in case of an + * entire plane, or from `Kernel::Plane_3` and `Kernel::Line_2` in case of a + * half-plane. The line orientation determines which half is considered. + * + * \cgalModels{EnvelopeTraits_3} + */ +template > +class Env_plane_traits_3 : public ArrLinearTraits { public: }; /* end Env_plane_traits_3 */ + } /* end namespace CGAL */ diff --git a/Envelope_3/doc/Envelope_3/CGAL/Env_surface_data_traits_3.h b/Envelope_3/doc/Envelope_3/CGAL/Env_surface_data_traits_3.h index bcd4f97ab41..cdfb26c219f 100644 --- a/Envelope_3/doc/Envelope_3/CGAL/Env_surface_data_traits_3.h +++ b/Envelope_3/doc/Envelope_3/CGAL/Env_surface_data_traits_3.h @@ -1,84 +1,64 @@ namespace CGAL { -/*! -\ingroup PkgEnvelope3Ref - -The class `Env_surface_data_traits_3` is a model of the `EnvelopeTraits_3` concept -and serves as a decorator class that allows the extension of the surfaces -defined by the base traits-class (the `Traits` parameter), which serves -as a geometric traits-class (a model of the `EnvelopeTraits_3` concept), -with extraneous (non-geometric) data fields. - -The traits-class decorator extends the `Surface_3` and the -`Xy_monotone_surface_3` types as detailed below. -Each `Surface_3` object is associated with a single data field of type -`SData`, and each `Xy_monotone_surface_3` object is associated with -a single data field of type `XyData`. When a surface is -subdivided into \f$ xy\f$-monotone surfaces, its data field is converted using -the conversion functor, which is specified by the `Cnv` template-parameter, -and the resulting objects is copied to all `Xy_monotone_surface_3` objects -induced by this surface. The conversion functor should provide an operator with -the following prototype: - -`XyData operator() (const SData& d) const;` - -By default, the two data types are the same, so the conversion operator -is trivial and just copies the data object: - - - - - -
          -`SData` = - -`XyData` -
          -`Cnv` = - -`_Default_convert_functor` -
          - -\cgalModels{EnvelopeTraits_3} - -*/ -template< typename Traits, typename XyData, typename SData, typename Cnv > +/*! \ingroup PkgEnvelope3Ref + * + * The class `Env_surface_data_traits_3` is a model of the `EnvelopeTraits_3` + * concept and serves as a decorator class that allows the extension of the + * surfaces defined by the base traits-class (the `Traits` parameter), which + * serves as a geometric traits-class (a model of the `EnvelopeTraits_3` + * concept), with extraneous (non-geometric) data fields. + * + * The traits-class decorator extends the `Surface_3` and the + * `Xy_monotone_surface_3` types as detailed below. Each `Surface_3` object is + * associated with a single data field of type `SData`, and each + * `Xy_monotone_surface_3` object is associated with a single data field of type + * `XyData`. When a surface is subdivided into \f$ xy\f$-monotone surfaces, its + * data field is converted using the conversion functor, which is specified by + * the `Cnv` template-parameter, and the resulting objects is copied to all + * `Xy_monotone_surface_3` objects induced by this surface. The conversion + * functor should provide an operator with the following prototype: + * + * `XyData operator() (const SData& d) const;` + * + * By default, the two data types are the same, so the conversion operator + * is trivial and just copies the data object: + * + * + * + * + * + * + * + * + *
          `SData` =`XyData`
          `Cnv` =`_Default_convert_functor`
          + * + * \cgalModels{EnvelopeTraits_3} + * + */ +template class Env_surface_data_traits_3 : public Traits { public: -/// \name Types -/// @{ + /// \name Types + /// @{ -/*! -the base traits-class. -*/ -typedef Traits Base_traits_3; + //! the base traits-class. + typedef Traits Base_traits_3; -/*! -the base surface. -*/ -typedef typename Base_traits_3::Surface_3 Base_surface_3; + //! the base surface. + typedef typename Base_traits_3::Surface_3 Base_surface_3; -/*! -the base \f$ xy\f$-monotone surface surface. -*/ -typedef typename Base_traits_3::Xy_monotone_surface_3 Base_xy_monotone_surface_3; + //! the base \f$ xy\f$-monotone surface surface. + typedef typename Base_traits_3::Xy_monotone_surface_3 Base_xy_monotone_surface_3; -/*! -the conversion functor. -*/ -typedef Cnv Convert; + //! the conversion functor. + typedef Cnv Convert; -/*! -the type of data associated with surfaces. -*/ -typedef SData Surface_data; - -/*! -the type of data associated with \f$ xy\f$-monotone surfaces. -*/ -typedef XyData Xy_monotone_surface_data; + //! the type of data associated with surfaces. + typedef SData Surface_data; + //! the type of data associated with \f$ xy\f$-monotone surfaces. + typedef XyData Xy_monotone_surface_data; /// The `Surface_3` class nested within the surface-data traits /// extends the `Base_traits_3::Surface_3` type with an extra data field. @@ -87,38 +67,33 @@ typedef XyData Xy_monotone_surface_data; /// \name Creation /// @{ - /*! - default constructor. - */ - Surface_3 (); + /*! default constructor. + */ + Surface_3(); - /*! - constructs surface from the given `base` surface with uninitialized - data field. - */ - Surface_3 (const Base_surface_3& base); + /*! constructs surface from the given `base` surface with uninitialized + * data field. + */ + Surface_3(const Base_surface_3& base); - /*! - constructs surface from the given `base` surface with an attached - `data` field. - */ - Surface_3 (const Base_surface_3& base, const Surface_data& data); + /*! constructs surface from the given `base` surface with an attached + * `data` field. + */ + Surface_3(const Base_surface_3& base, const Surface_data& data); /// @} /// \name Access Functions /// @{ - /*! - returns the data field (a non-const version, which returns a reference - to the data object, is also available). - */ + /*! returns the data field (a non-const version, which returns a reference + * to the data object, is also available). + */ const Surface_data& data () const; - /*! - sets the data field. - */ - void set_data (const Surface_data& data); + /*! sets the data field. + */ + void set_env_data (const Surface_data& data); /// @} }; @@ -131,22 +106,19 @@ typedef XyData Xy_monotone_surface_data; /// \name Creation /// @{ - /*! - default constructor. - */ + /*! default constructor. + */ Xy_monotone_surface_3 (); - /*! - constructs an \f$ xy\f$-monotone surface from the given `base` surface with - uninitialized data field. - */ - Xy_monotone_surface_3 (const Base_xy_monotone_surface_3& base); + /*! constructs an \f$ xy\f$-monotone surface from the given `base` surface + * with uninitialized data field. + */ + Xy_monotone_surface_3(const Base_xy_monotone_surface_3& base); - /*! - constructs an \f$ x\f$-monotone surface from the given `base` \f$ x\f$-monotone - surface with an attached `data` field. - */ - Xy_monotone_surface_3 (const Base_xy_monotone_surface_3& base, + /*! constructs an \f$ x\f$-monotone surface from the given `base` + * \f$ x\f$-monotone surface with an attached `data` field. + */ + Xy_monotone_surface_3(const Base_xy_monotone_surface_3& base, const Xy_monotone_surface_data& data); /// @} @@ -154,21 +126,20 @@ typedef XyData Xy_monotone_surface_data; /// \name Access Functions /// @{ - /*! - returns the field (a non-const version, which returns a reference - to the data object, is also available). - */ - const Xy_monotone_surface_data& data () const; + /*! returns the field (a non-const version, which returns a reference + * to the data object, is also available). + */ + const Xy_monotone_surface_data& data() const; - /*! - sets the data field. - */ - void set_data (const Xy_monotone_surface_data& data); + /*! sets the data field. + */ + void set_env_data(const Xy_monotone_surface_data& data); /// @} }; -/// @} + /// @} }; /* end */ + } /* end namespace CGAL */ diff --git a/Envelope_3/doc/Envelope_3/CGAL/Env_triangle_traits_3.h b/Envelope_3/doc/Envelope_3/CGAL/Env_triangle_traits_3.h index 74646352052..30cbba6d642 100644 --- a/Envelope_3/doc/Envelope_3/CGAL/Env_triangle_traits_3.h +++ b/Envelope_3/doc/Envelope_3/CGAL/Env_triangle_traits_3.h @@ -1,42 +1,46 @@ namespace CGAL { -/*! -\ingroup PkgEnvelope3Ref - -The traits class `Env_triangle_traits_3` models the `EnvelopeTraits_3` -concept, and is used for the construction of lower and upper envelopes -of triangles in the space. It is parameterized by a \cgal-kernel, -which is parameterized in turn by a number type. The number type should -support exact rational arithmetic, to avoid numerical errors and -robustness problems. In particular, the number type should support -the arithmetic operations \f$ +\f$, \f$ -\f$, \f$ \times\f$, and \f$ \div\f$ without loss -of precision. For optimal performance, we recommend instantiating the -traits class with the predefined -`Exact_predicates_exact_constructions_kernel` provided by \cgal. -Using this kernel guarantees exactness and robustness, while it incurs -only a minor overhead (in comparison to working with a fast, inexact number -type) for most inputs. - -Note that when we project the boundary of a triangle, or the intersection -of two triangles, onto the \f$ xy\f$-plane, we obtain line segments. Indeed, -`Env_triangle_traits_3` inherits from the `Arr_segment_traits_2` traits -class, and extends it by adding operations on 3D objects, namely spacial -triangles. Note that the traits class does not define -`Kernel::Triangle_3` as its surface (and \f$ xy\f$-monotone surface) type, -as one may expect. This is because the traits class needs to store extra -data with the triangles in order to efficiently operate on them. -Nevertheless, the nested `Xy_monotone_surface_3` and `Surface_3` -types are however constructible from a `Kernel::Triangle_3` -instance and are also convertible to a `Kernel::Triangle_3` object. -Both types, `Xy_monotone_surface_3` and `Surface_3`, refer to the -same class, as every triangle is (weakly) \f$ xy\f$-monotone). - -\cgalModels{EnvelopeTraits_3} - -*/ -template< typename Kernel > -class Env_triangle_traits_3 : public Arr_segment_traits_2 { +/*! \ingroup PkgEnvelope3Ref + * + * The traits class template `Env_triangle_traits_3` models the + * `EnvelopeTraits_3` concept, and is used for the construction of lower and + * upper envelopes of triangles in the space. When the template is instantiated, + * the template parameter `Kernel` must be substituted by a \cgal-kernel model, + * the number type of which should support exact rational arithmetic, to avoid + * numerical errors and robustness problems. In particular, the number type + * should support the arithmetic operations \f$ +\f$, \f$ -\f$, \f$ \times\f$, + * and \f$ \div\f$ without loss of precision. For optimal performance, we + * recommend instantiating the traits class with the predefined + * `Exact_predicates_exact_constructions_kernel` provided by \cgal. Using this + * kernel guarantees exactness and robustness, while it incurs only a minor + * overhead (in comparison to working with a fast, inexact number type) for most + * inputs. + * + * The second template parameter, namely `ArrSegmentTraits`, should be + * substituted by a 2D arrangement geometry traits class that supports + * segments. By default it is substituted by `Arr_segment_traits_2`. + * + * Note that when we project the boundary of a triangle, or the intersection of + * two triangles, onto the \f$ xy\f$-plane, we obtain line segments. Indeed, + * `Env_triangle_traits_3` inherits from the traits class that substitutes + * `ArrSegmentTraits`, and extends it by adding operations on 3D objects, namely + * spacial triangles. Note that the traits class does not define + * `Kernel::Triangle_3` as its surface (and \f$ xy\f$-monotone surface) type, as + * one may expect. This is because the traits class needs to store extra data + * with the triangles in order to efficiently operate on them. Nevertheless, + * the nested `Xy_monotone_surface_3` and `Surface_3` types are however + * constructible from a `Kernel::Triangle_3` instance and are also convertible + * to a `Kernel::Triangle_3` object. Both types, `Xy_monotone_surface_3` and + * `Surface_3`, refer to the same class, as every triangle is (weakly) + * \f$ xy\f$-monotone). + * + * \cgalModels{EnvelopeTraits_3} + */ +template > +class Env_triangle_traits_3 : public ArrSegmentTraits { public: }; /* end Env_triangle_traits_3 */ + } /* end namespace CGAL */ diff --git a/Envelope_3/doc/Envelope_3/Concepts/EnvelopeTraits_3.h b/Envelope_3/doc/Envelope_3/Concepts/EnvelopeTraits_3.h index 3665e2ae25a..fc72154073a 100644 --- a/Envelope_3/doc/Envelope_3/Concepts/EnvelopeTraits_3.h +++ b/Envelope_3/doc/Envelope_3/Concepts/EnvelopeTraits_3.h @@ -1,231 +1,213 @@ -/*! -\ingroup PkgEnvelope3Concepts -\cgalConcept - -This concept defines the minimal set of geometric predicates and -operations needed to compute the envelope of a set of arbitrary -surfaces in \f$ \mathbb{R}^3\f$. It refines the -`ArrangementXMonotoneTraits_2` concept. In addition to the -`Point_2` and `X_monotone_curve_2` types and the -`Has_boundary_category` category tag listed in the base concept, -it also lists the `Surface_3` and `Xy_monotone_surface_3` -types, which represent arbitrary surfaces and \f$ xy\f$-monotone surfaces, -respectively, and some constructions and predicates on these types. -Note however, that these operations usually involve the projection of -3D objects onto the \f$ xy\f$-plane. - -\cgalRefines{ArrangementXMonotoneTraits_2} - -\cgalHasModelsBegin -\cgalHasModels{CGAL::Env_triangle_traits_3} -\cgalHasModels{CGAL::Env_sphere_traits_3} -\cgalHasModels{CGAL::Env_plane_traits_3} -\cgalHasModels{CGAL::Env_surface_data_traits_3} -\cgalHasModelsEnd - -*/ +/*! \ingroup PkgEnvelope3Concepts + * \cgalConcept + * + * This concept defines the minimal set of geometric predicates and operations + * needed to compute the envelope of a set of arbitrary surfaces in \f$ + * \mathbb{R}^3\f$. It refines the `ArrangementXMonotoneTraits_2` concept. In + * addition to the `Point_2` and `X_monotone_curve_2` types and the + * `Has_boundary_category` category tag listed in the base concept, it also + * lists the `Surface_3` and `Xy_monotone_surface_3` types, which represent + * arbitrary surfaces and \f$ xy\f$-monotone surfaces, respectively, and some + * constructions and predicates on these types. Note however, that these + * operations usually involve the projection of 3D objects onto the \f$ + * xy\f$-plane. + * + * \cgalRefines{ArrangementXMonotoneTraits_2} + * + * \cgalHasModelsBegin + * \cgalHasModels{CGAL::Env_triangle_traits_3} + * \cgalHasModels{CGAL::Env_sphere_traits_3} + * \cgalHasModels{CGAL::Env_plane_traits_3} + * \cgalHasModels{CGAL::Env_surface_data_traits_3} + * \cgalHasModelsEnd + */ class EnvelopeTraits_3 { public: -/// \name Types -/// @{ + /// \name Types + /// @{ -/*! -represents an arbitrary surface in \f$ \mathbb{R}^3\f$. -*/ -typedef unspecified_type Surface_3; + /*! represents an arbitrary surface in \f$ \mathbb{R}^3\f$. + */ + typedef unspecified_type Surface_3; -/*! -represents a weakly \f$ xy\f$-monotone surface in \f$ \mathbb{R}^3\f$. -*/ -typedef unspecified_type Xy_monotone_surface_3; + /*! represents a weakly \f$ xy\f$-monotone surface in \f$ \mathbb{R}^3\f$. + */ + typedef unspecified_type Xy_monotone_surface_3; -/// @} + /// @} -/// \name Functor Types -/// @{ + /// \name Functor Types + /// @{ -/*! -provides the operator (templated by the `OutputIterator` type) : -
            -
          • `OutputIterator operator() (Surface_3 S, bool is_lower, OutputIterator oi)` -
            -which subdivides the given surface `S` into \f$ xy\f$-monotone parts -and inserts them into the output iterator. The value of -`is_lower` indicates whether we compute the lower or the upper -envelope, so that \f$ xy\f$-monotone surfaces that are irrelevant to the -lower-envelope (resp. upper-envelope) computation may be discarded. -The value-type of `OutputIterator` is `Xy_monotone_surface_3`. -The operator returns a past-the-end iterator for the output sequence. -
          -*/ -typedef unspecified_type Make_xy_monotone_3; + /*! provides the operator (templated by the `OutputIterator` type) : + *
            + *
          • `OutputIterator operator() (Surface_3 S, bool is_lower, OutputIterator oi)` + *
            + * which subdivides the given surface `S` into \f$ xy\f$-monotone parts + * and inserts them into the output iterator. The value of + * `is_lower` indicates whether we compute the lower or the upper + * envelope, so that \f$ xy\f$-monotone surfaces that are irrelevant to the + * lower-envelope (resp. upper-envelope) computation may be discarded. + * The value-type of `OutputIterator` is `Xy_monotone_surface_3`. + * The operator returns a past-the-end iterator for the output sequence. + *
          + */ + typedef unspecified_type Make_xy_monotone_3; -/*! -provides the operator (templated by the `OutputIterator` type) : -
            -
          • `OutputIterator operator() (Xy_monotone_surface_3 s, OutputIterator oi)` -
            -which computes all planar \f$ x\f$-monotone curves and possibly isolated planar -points that form the projection of the boundary of the given \f$ xy\f$-monotone -surface \f$ s\f$ onto the \f$ xy\f$-plane, and inserts them into the output iterator. -The value-type of `OutputIterator` is `Object`, where `Object` -wraps either a `Point_2`, or a -`pair`. In the former case, the -object represents an isolated point of the projected boundary. In the latter, -more general, case the object represents an \f$ x\f$-monotone boundary curve -along with an enumeration value which is either `ON_NEGATIVE_SIDE` -or `ON_POSITIVE_SIDE`, indicating whether whether the projection of the -surface onto the \f$ xy\f$-plane lies below or above this \f$ x\f$-monotone curve, -respectively. In degenerate case, namely when the surface itself is vertical, -and its projection onto the plane is \f$ 1\f$-dimensional, the `Oriented_side` -value is `ON_ORIENTED_BOUNDARY`. The operator returns a past-the-end -iterator for the output sequence. -
          -*/ -typedef unspecified_type Construct_projected_boundary_2; + /*! provides the operator (templated by the `OutputIterator` type) : + *
            + *
          • `OutputIterator operator() (Xy_monotone_surface_3 s, OutputIterator oi)` + *
            + * which computes all planar \f$ x\f$-monotone curves and possibly isolated + * planar points that form the projection of the boundary of the given + * \f$ xy\f$-monotone surface \f$ s\f$ onto the \f$ xy\f$-plane, and inserts + * them into the output iterator. + * The value-type of `OutputIterator` is `Object`, where `Object` wraps either + * a `Point_2`, or a `pair`. In the former + * case, the object represents an isolated point of the projected boundary. In + * the latter, more general, case the object represents an \f$ x\f$-monotone + * boundary curve along with an enumeration value which is either + * `ON_NEGATIVE_SIDE` or `ON_POSITIVE_SIDE`, indicating whether whether the + * projection of the surface onto the \f$ xy\f$-plane lies below or above this + * \f$ x\f$-monotone curve, respectively. In degenerate case, namely when the + * surface itself is vertical, and its projection onto the plane is + * \f$ 1\f$-dimensional, the `Oriented_side` value is `ON_ORIENTED_BOUNDARY`. + * The operator returns a past-the-end iterator for the output sequence. + *
          + */ + typedef unspecified_type Construct_projected_boundary_2; -/*! -provides the operator (templated by the `OutputIterator` type) : -
            -
          • `OutputIterator operator() (Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2, OutputIterator oi)` -
            -which computes the projection of the intersections of the -\f$ xy\f$-monotone surfaces `s1` and `s2` onto the \f$ xy\f$-plane, -and inserts them into the output iterator. -The value-type of `OutputIterator` is `Object`, where -each `Object` either wraps a `pair` -instance, which represents a projected intersection curve with its -multiplicity (in case the multiplicity is undefined or not known, it -should be set to \f$ 0\f$) or an `Point_2` instance, representing the -projected image of a degenerate intersection (the projection of an -isolated intersection point, or of a vertical intersection curve). -The operator returns a past-the-end iterator for the output sequence. -
          -*/ -typedef unspecified_type Construct_projected_intersections_2; + /*! provides the operator (templated by the `OutputIterator` type) : + *
            + *
          • `OutputIterator operator() (Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2, OutputIterator oi)` + *
            + * which computes the projection of the intersections of the + * \f$ xy\f$-monotone surfaces `s1` and `s2` onto the \f$ xy\f$-plane, + * and inserts them into the output iterator. + * The value-type of `OutputIterator` is `Object`, where + * each `Object` either wraps a `pair` + * instance, which represents a projected intersection curve with its + * multiplicity (in case the multiplicity is undefined or not known, it + * should be set to \f$ 0\f$) or an `Point_2` instance, representing the + * projected image of a degenerate intersection (the projection of an + * isolated intersection point, or of a vertical intersection curve). + * The operator returns a past-the-end iterator for the output sequence. + *
          + */ + typedef unspecified_type Construct_projected_intersections_2; -/*! -provides the operators : -
            -
          • `Comparison_result operator() (Point_2 p, Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2)` -
            -which determines the relative \f$ z\f$-order of the two given \f$ xy\f$-monotone -surfaces at the \f$ xy\f$-coordinates of the point `p`, with the -precondition that both surfaces are defined over `p`. Namely, it -returns the comparison result of \f$ s_1(p)\f$ and \f$ s_2(p)\f$. -
          • `Comparison_result operator() (X_monotone_curve_2 c, Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2)` -
            -which determines the relative \f$ z\f$-order of the two given \f$ xy\f$-monotone -surfaces over the interior of a given \f$ x\f$-monotone curve \f$ c\f$, with the -precondition that \f$ c\f$ is fully contained in the \f$ xy\f$-definition range -of both \f$ s_1\f$ and \f$ s_2\f$, and that the surfaces do not intersect over -\f$ c\f$. The functor should therefore return the comparison result of -\f$ s_1(p')\f$ and \f$ s_2(p')\f$ for some point \f$ p'\f$ in the interior of \f$ c\f$. -
          • `Comparison_result operator() (Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2)` -
            -which determines the relative \f$ z\f$-order of the two given unbounded -\f$ xy\f$-monotone surfaces, which are defined over the entire \f$ xy\f$-plane and -have no boundary, with the precondition that the surfaces do not intersect -at all. -The functor should therefore return the comparison result of -\f$ s_1(p)\f$ and \f$ s_2(p)\f$ for some planar point \f$ p \in\mathbb{R}^2\f$. -This operator is required iff the category tag `Has_boundary_category` -is defined as `Tag_true`. -
          -*/ -typedef unspecified_type Compare_z_at_xy_3; + /*! provides the operators : + *
            + *
          • `Comparison_result operator() (Point_2 p, Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2)` + *
            + * which determines the relative \f$ z\f$-order of the two given + * \f$ xy\f$-monotone surfaces at the \f$ xy\f$-coordinates of the point `p`, + * with the precondition that both surfaces are defined over `p`. Namely, it + * returns the comparison result of \f$ s_1(p)\f$ and \f$ s_2(p)\f$. + *
          • `Comparison_result operator() (X_monotone_curve_2 c, Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2)` + *
            + * which determines the relative \f$ z\f$-order of the two given + * \f$ xy\f$-monotone surfaces over the interior of a given \f$ x\f$-monotone + * curve \f$ c\f$, with the precondition that \f$ c\f$ is fully contained in + * the \f$ xy\f$-definition range of both \f$ s_1\f$ and \f$ s_2\f$, and that + * the surfaces do not intersect over \f$ c\f$. The functor should therefore + * return the comparison result of \f$ s_1(p')\f$ and \f$ s_2(p')\f$ for some + * point \f$ p'\f$ in the interior of \f$ c\f$. + *
          • `Comparison_result operator() (Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2)` + *
            + * which determines the relative \f$ z\f$-order of the two given unbounded + * \f$ xy\f$-monotone surfaces, which are defined over the entire + * \f$ xy\f$-plane and have no boundary, with the precondition that the + * surfaces do not intersect at all. The functor should therefore return the + * comparison result of \f$ s_1(p)\f$ and \f$ s_2(p)\f$ for some planar point + * \f$ p \in\mathbb{R}^2\f$. This operator is required iff the category tag + * `Has_boundary_category` is defined as `Tag_true`. + *
          + */ + typedef unspecified_type Compare_z_at_xy_3; -/*! -provides the operator : -
            -
          • `Comparison_result operator() (X_monotone_curve_2 c, Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2)` -
            -which determines the relative \f$ z\f$-order of the two given \f$ xy\f$-monotone -surfaces immediately above their projected intersection curve -\f$ c\f$ (a planar point \f$ p\f$ is above an \f$ x\f$-monotone curve \f$ c\f$ if it -is in the \f$ x\f$-range of \f$ c\f$, and lies to its left when the curve is -traversed from its \f$ xy\f$-lexicographically smaller endpoint to its -larger endpoint). We have the precondition that both surfaces are -defined "above" \f$ c\f$, and their relative \f$ z\f$-order is the same for -some small enough neighborhood of points above \f$ c\f$. -
          -*/ -typedef unspecified_type Compare_z_at_xy_above_3; + /*! provides the operator : + *
            + *
          • `Comparison_result operator() (X_monotone_curve_2 c, Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2)` + *
            + * which determines the relative \f$ z\f$-order of the two given + * \f$ xy\f$-monotone surfaces immediately above their projected intersection + * curve \f$ c\f$ (a planar point \f$ p\f$ is above an + * \f$ x\f$-monotone curve \f$ c\f$ if it is in the \f$ x\f$-range of + * \f$ c\f$, and lies to its left when the curve is traversed from its + * \f$ xy\f$-lexicographically smaller endpoint to its larger endpoint). We + * have the precondition that both surfaces are defined "above" \f$ c\f$, and + * their relative \f$ z\f$-order is the same for some small enough + * neighborhood of points above \f$ c\f$. + *
          + */ + typedef unspecified_type Compare_z_at_xy_above_3; -/*! -provides the operator : -
            -
          • `Comparison_result operator() (X_monotone_curve_2 c, Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2)` -
            -which determines the relative \f$ z\f$-order of the two given \f$ xy\f$-monotone -surfaces immediately below their projected intersection curve -\f$ c\f$ (a planar point \f$ p\f$ is below an \f$ x\f$-monotone curve \f$ c\f$ if it -is in the \f$ x\f$-range of \f$ c\f$, and lies to its right when the curve is -traversed from its \f$ xy\f$-lexicographically smaller endpoint to its -larger endpoint). We have the precondition that both surfaces are -defined "below" \f$ c\f$, and their relative \f$ z\f$-order is the same for -some small enough neighborhood of points below \f$ c\f$. -
          -*/ -typedef unspecified_type Compare_z_at_xy_below_3; + /*! provides the operator : + *
            + *
          • `Comparison_result operator() (X_monotone_curve_2 c, Xy_monotone_surface_3 s1, Xy_monotone_surface_3 s2)` + *
            + * which determines the relative \f$ z\f$-order of the two given + * \f$ xy\f$-monotone surfaces immediately below their projected intersection + * curve \f$ c\f$ (a planar point \f$ p\f$ is below an + * \f$ x\f$-monotone curve \f$ c\f$ if it is in the \f$ x\f$-range of + * \f$ c\f$, and lies to its right when the curve is traversed from its + * \f$ xy\f$-lexicographically smaller endpoint to its larger endpoint). We + * have the precondition that both surfaces are defined "below" \f$ c\f$, and + * their relative \f$ z\f$-order is the same for some small enough + * neighborhood of points below \f$ c\f$. + *
          + */ + typedef unspecified_type Compare_z_at_xy_below_3; -/// @} + /// @} -/// \name Creation -/// @{ + /// \name Creation + /// @{ -/*! -default constructor. -*/ -EnvelopeTraits_3(); + /*! default constructor. + */ + EnvelopeTraits_3(); -/*! -copy constructor. -*/ -EnvelopeTraits_3(EnvelopeTraits_3 other); + /*! copy constructor. + */ + EnvelopeTraits_3(EnvelopeTraits_3 other); -/*! -assignment operator. -*/ -EnvelopeTraits_3 operator=(other); + /*! assignment operator. + */ + EnvelopeTraits_3 operator=(other); -/// @} + /// @} -/// \name Accessing Functor Objects -/// @{ + /// \name Accessing Functor Objects + /// @{ -/*! + /*! + */ + Make_xy_monotone_3 make_xy_monotone_3_object(); -*/ -Make_xy_monotone_3 make_xy_monotone_3_object(); + /*! + */ + Construct_projected_boundary_2 construct_projected_boundary_2_object(); -/*! + /*! + */ + Construct_projected_intersections_2 construct_projected_intersections_2_object(); -*/ -Construct_projected_boundary_2 construct_projected_boundary_2_object(); + /*! + */ + Compare_z_at_xy_3 compare_z_at_xy_3_object(); -/*! + /*! + */ + Compare_z_at_xy_above_3 compare_z_at_xy_above_3_object(); -*/ -Construct_projected_intersections_2 construct_projected_intersections_2_object(); + /*! + */ + Compare_z_at_xy_below_3 compare_z_at_xy_below_3_object(); -/*! - -*/ -Compare_z_at_xy_3 compare_z_at_xy_3_object(); - -/*! - -*/ -Compare_z_at_xy_above_3 compare_z_at_xy_above_3_object(); - -/*! - -*/ -Compare_z_at_xy_below_3 compare_z_at_xy_below_3_object(); - -/// @} + /// @} }; /* end EnvelopeTraits_3 */ diff --git a/Envelope_3/doc/Envelope_3/PackageDescription.txt b/Envelope_3/doc/Envelope_3/PackageDescription.txt index df0fb936667..7579fff2c1e 100644 --- a/Envelope_3/doc/Envelope_3/PackageDescription.txt +++ b/Envelope_3/doc/Envelope_3/PackageDescription.txt @@ -39,10 +39,9 @@ diagram cell is unique. \cgalCRPSection{Classes} - `CGAL::Envelope_diagram_2` -- `CGAL::Env_triangle_traits_3` +- `CGAL::Env_triangle_traits_3` - `CGAL::Env_sphere_traits_3` -- `CGAL::Env_plane_traits_3` +- `CGAL::Env_plane_traits_3` - `CGAL::Env_surface_data_traits_3` */ - diff --git a/Envelope_3/examples/Envelope_3/envelope_planes.cpp b/Envelope_3/examples/Envelope_3/envelope_planes.cpp index 6595f5e9585..ce8e77b6fe4 100644 --- a/Envelope_3/examples/Envelope_3/envelope_planes.cpp +++ b/Envelope_3/examples/Envelope_3/envelope_planes.cpp @@ -1,81 +1,63 @@ //! \file examples/Envelope_3/ex_envelope_planes.cpp // Constructing the lower and the upper envelope of a set of planes. +#include +#include + #include #include #include #include -#include -#include - -typedef CGAL::Exact_rational Number_type; -typedef CGAL::Cartesian Kernel; -typedef Kernel::Plane_3 Plane_3; -typedef CGAL::Env_plane_traits_3 Traits_3; -typedef Traits_3::Surface_3 Surface_3; -typedef CGAL::Envelope_diagram_2 Envelope_diagram_2; +using Number_type = CGAL::Exact_rational; +using Kernel = CGAL::Cartesian; +using Plane_3 = Kernel::Plane_3; +using Traits_3 = CGAL::Env_plane_traits_3; +using Surface_3 = Traits_3::Surface_3; +using Envelope_diagram_2 = CGAL::Envelope_diagram_2; /* Auxiliary function - print the features of the given envelope diagram. */ -void print_diagram (const Envelope_diagram_2& diag) -{ +void print_diagram(const Envelope_diagram_2& diag) { // Go over all arrangement faces. - Envelope_diagram_2::Face_const_iterator fit; - Envelope_diagram_2::Ccb_halfedge_const_circulator ccb; - Envelope_diagram_2::Surface_const_iterator sit; - - for (fit = diag.faces_begin(); fit != diag.faces_end(); ++fit) - { + for (auto fit = diag.faces_begin(); fit != diag.faces_end(); ++fit) { // Print the face boundary. // Print the vertices along the outer boundary of the face. - ccb = fit->outer_ccb(); - std::cout << "[Face] "; - do - { - if(!ccb->is_fictitious()) - std::cout << '(' << ccb->curve() << ") "; - ++ccb; - } while (ccb != fit->outer_ccb()); + auto ccb = fit->outer_ccb(); + std::cout << "[Face] "; + do if (!ccb->is_fictitious()) std::cout << '(' << ccb->curve() << ") "; + while (++ccb != fit->outer_ccb()); // Print the planes that induce the envelope on this face. - std::cout << "--> " << fit->number_of_surfaces() - << " planes:"; + std::cout << "--> " << fit->number_of_surfaces() << " planes:"; - for (sit = fit->surfaces_begin(); sit != fit->surfaces_end(); ++sit) + for (auto sit = fit->surfaces_begin(); sit != fit->surfaces_end(); ++sit) std::cout << ' ' << sit->plane(); std::cout << std::endl; } - - return; } /* The main program: */ -int main () -{ +int main() { // Construct the input planes. - std::list planes; + std::list planes; - planes.push_back (Surface_3(Plane_3(0, -1, 1, 0))); - planes.push_back (Surface_3(Plane_3(-1, 0, 1, 0))); - planes.push_back (Surface_3(Plane_3(0, 1 , 1, 0))); - planes.push_back (Surface_3(Plane_3(1, 0, 1, 0))); + planes.push_back(Surface_3(Plane_3(0, -1, 1, 0))); + planes.push_back(Surface_3(Plane_3(-1, 0, 1, 0))); + planes.push_back(Surface_3(Plane_3(0, 1 , 1, 0))); + planes.push_back(Surface_3(Plane_3(1, 0, 1, 0))); // Compute and print the minimization diagram. - Envelope_diagram_2 min_diag; - - CGAL::lower_envelope_3 (planes.begin(), planes.end(), min_diag); - + Envelope_diagram_2 min_diag; + CGAL::lower_envelope_3(planes.begin(), planes.end(), min_diag); std::cout << std::endl << "The minimization diagram:" << std::endl; - print_diagram (min_diag); + print_diagram(min_diag); // Compute and print the maximization diagram. - Envelope_diagram_2 max_diag; - - CGAL::upper_envelope_3 (planes.begin(), planes.end(), max_diag); - + Envelope_diagram_2 max_diag; + CGAL::upper_envelope_3(planes.begin(), planes.end(), max_diag); std::cout << std::endl << "The maximization diagram:" << std::endl; print_diagram (max_diag); - return (0); + return 0; } diff --git a/Envelope_3/examples/Envelope_3/envelope_spheres.cpp b/Envelope_3/examples/Envelope_3/envelope_spheres.cpp index 41c9bb4568f..e71fb5bba14 100644 --- a/Envelope_3/examples/Envelope_3/envelope_spheres.cpp +++ b/Envelope_3/examples/Envelope_3/envelope_spheres.cpp @@ -5,47 +5,44 @@ #ifndef CGAL_USE_CORE #include -int main() -{ +int main() { std::cout << "Sorry, this example needs CORE ..." << std::endl; return 0; } #else +#include +#include +#include + #include #include #include #include #include -#include -#include -#include -typedef CGAL::CORE_algebraic_number_traits Nt_traits; -typedef Nt_traits::Rational Rational; -typedef Nt_traits::Algebraic Algebraic; -typedef CGAL::Cartesian Rat_kernel; -typedef Rat_kernel::Point_3 Rat_point_3; -typedef CGAL::Cartesian Alg_kernel; +using Nt_traits = CGAL::CORE_algebraic_number_traits; +using Rational = Nt_traits::Rational; +using Algebraic = Nt_traits::Algebraic; +using Rat_kernel = CGAL::Cartesian; +using Rat_point_3 = Rat_kernel::Point_3; +using Alg_kernel = CGAL::Cartesian; -typedef CGAL::Arr_conic_traits_2 - Conic_traits_2; +using Conic_traits_2 = + CGAL::Arr_conic_traits_2; -typedef CGAL::Env_sphere_traits_3 Traits_3; -typedef Traits_3::Surface_3 Sphere_3; -typedef CGAL::Envelope_diagram_2 Envelope_diagram_2; +using Traits_3 = CGAL::Env_sphere_traits_3; +using Sphere_3 = Traits_3::Surface_3; +using Envelope_diagram_2 = CGAL::Envelope_diagram_2; -int main(int argc, char **argv) -{ +int main(int argc, char* argv[]) { // Get the name of the input file from the command line, or use the default // fan_grids.dat file if no command-line parameters are given. - const char * filename = (argc > 1) ? argv[1] : "spheres.dat"; + const char* filename = (argc > 1) ? argv[1] : "spheres.dat"; // Open the input file. - std::ifstream in_file(filename); - - if (! in_file.is_open()) - { + std::ifstream in_file(filename); + if (! in_file.is_open()) { std::cerr << "Failed to open " << filename << " ..." << std::endl; return 1; } @@ -57,37 +54,28 @@ int main(int argc, char **argv) // // center and squared radious of sphere #2. // : : : : // // center and squared radious of sphere #n. - int n = 0; - std::list spheres; - int x = 0, y = 0, z = 0, sqr_r = 0; - int i; - + int n = 0; + std::list spheres; + int x = 0, y = 0, z = 0, sqr_r = 0; in_file >> n; - for (i = 0; i < n; ++i) - { + for (int i = 0; i < n; ++i) { in_file >> x >> y >> z >> sqr_r; spheres.push_back(Sphere_3(Rat_point_3(x, y, z), Rational(sqr_r))); } in_file.close(); + std::cout << "Constructing the lower envelope of " << n << " spheres.\n"; // Compute the lower envelope. - Envelope_diagram_2 min_diag; - CGAL::Timer timer; - - std::cout << "Constructing the lower envelope of " - << n << " spheres." << std::endl; - - timer.start(); + Envelope_diagram_2 min_diag; + auto start = std::chrono::system_clock::now(); CGAL::lower_envelope_3(spheres.begin(), spheres.end(), min_diag); - timer.stop(); + std::chrono::duration secs = std::chrono::system_clock::now() - start; // Print the dimensions of the minimization diagram. std::cout << "V = " << min_diag.number_of_vertices() - << ", E = " << min_diag.number_of_edges() - << ", F = " << min_diag.number_of_faces() << std::endl; - - std::cout << "Construction took " << timer.time() - << " seconds." << std::endl; + << ", E = " << min_diag.number_of_edges() + << ", F = " << min_diag.number_of_faces() << std::endl; + std::cout << "Construction took " << secs.count() << " seconds.\n"; return 0; } diff --git a/Envelope_3/examples/Envelope_3/envelope_triangles.cpp b/Envelope_3/examples/Envelope_3/envelope_triangles.cpp index b8715c10b42..b16a229f290 100644 --- a/Envelope_3/examples/Envelope_3/envelope_triangles.cpp +++ b/Envelope_3/examples/Envelope_3/envelope_triangles.cpp @@ -1,110 +1,82 @@ //! \file examples/Envelope_3/ex_envelope_triangles.cpp // Constructing the lower and the upper envelope of a set of triangles. +#include +#include + #include #include #include #include #include -#include -#include -typedef CGAL::Exact_rational Number_type; -typedef CGAL::Cartesian Kernel; -typedef CGAL::Env_triangle_traits_3 Traits_3; -typedef Kernel::Point_3 Point_3; -typedef Traits_3::Surface_3 Triangle_3; -typedef CGAL::Env_surface_data_traits_3 Data_traits_3; -typedef Data_traits_3::Surface_3 Data_triangle_3; -typedef CGAL::Envelope_diagram_2 Envelope_diagram_2; +using Number_type = CGAL::Exact_rational; +using Kernel = CGAL::Cartesian; +using Traits_3 = CGAL::Env_triangle_traits_3; +using Point_3 = Kernel::Point_3; +using Triangle_3 = Traits_3::Surface_3; +using Data_traits_3 = CGAL::Env_surface_data_traits_3; +using Data_triangle_3 = Data_traits_3::Surface_3; +using Envelope_diagram_2 = CGAL::Envelope_diagram_2; /* Auxiliary function - print the features of the given envelope diagram. */ -void print_diagram (const Envelope_diagram_2& diag) -{ +void print_diagram(const Envelope_diagram_2& diag) { // Go over all arrangement faces. - Envelope_diagram_2::Face_const_iterator fit; - Envelope_diagram_2::Ccb_halfedge_const_circulator ccb; - Envelope_diagram_2::Surface_const_iterator sit; - - for (fit = diag.faces_begin(); fit != diag.faces_end(); ++fit) - { + for (auto fit = diag.faces_begin(); fit != diag.faces_end(); ++fit) { // Print the face boundary. - if (fit->is_unbounded()) - { - std::cout << "[Unbounded face]"; - } - else - { + if (fit->is_unbounded()) std::cout << "[Unbounded face]"; + else { // Print the vertices along the outer boundary of the face. - ccb = fit->outer_ccb(); + auto ccb = fit->outer_ccb(); std::cout << "[Face] "; - do - { - std::cout << '(' << ccb->target()->point() << ") "; - ++ccb; - } while (ccb != fit->outer_ccb()); + do std::cout << '(' << ccb->target()->point() << ") "; + while (++ccb != fit->outer_ccb()); } // Print the labels of the triangles that induce the envelope on this face. - std::cout << "--> " << fit->number_of_surfaces() - << " triangles:"; + std::cout << "--> " << fit->number_of_surfaces() << " triangles:"; - for (sit = fit->surfaces_begin(); sit != fit->surfaces_end(); ++sit) + for (auto sit = fit->surfaces_begin(); sit != fit->surfaces_end(); ++sit) std::cout << ' ' << sit->data(); std::cout << std::endl; } // Go over all arrangement edges. - Envelope_diagram_2::Edge_const_iterator eit; + Envelope_diagram_2::Edge_const_iterator eit; - for (eit = diag.edges_begin(); eit != diag.edges_end(); ++eit) - { + for (auto eit = diag.edges_begin(); eit != diag.edges_end(); ++eit) { // Print the labels of the triangles that induce the envelope on this edge. std::cout << "[Edge] (" << eit->source()->point() - << ") (" << eit->target()->point() - << ") --> " << eit->number_of_surfaces() + << ") (" << eit->target()->point() + << ") --> " << eit->number_of_surfaces() << " triangles:"; - for (sit = eit->surfaces_begin(); sit != eit->surfaces_end(); ++sit) + for (auto sit = eit->surfaces_begin(); sit != eit->surfaces_end(); ++sit) std::cout << ' ' << sit->data(); std::cout << std::endl; } - - return; } /* The main program: */ -int main () -{ +int main() { // Construct the input triangles, makred A and B. - std::list triangles; - - triangles.push_back (Data_triangle_3 (Triangle_3 (Point_3 (0, 0, 0), - Point_3 (0, 6, 0), - Point_3 (5, 3, 4)), - 'A')); - triangles.push_back (Data_triangle_3 (Triangle_3 (Point_3 (6, 0, 0), - Point_3 (6, 6, 0), - Point_3 (1, 3, 4)), - 'B')); + std::list triangles; + auto t1 = Triangle_3(Point_3 (0, 0, 0), Point_3 (0, 6, 0), Point_3 (5, 3, 4)); + triangles.push_back(Data_triangle_3(t1, 'A')); + auto t2 = Triangle_3(Point_3 (6, 0, 0), Point_3 (6, 6, 0), Point_3 (1, 3, 4)); + triangles.push_back(Data_triangle_3(t2, 'B')); // Compute and print the minimization diagram. - Envelope_diagram_2 min_diag; - - CGAL::lower_envelope_3 (triangles.begin(), triangles.end(), - min_diag); - + Envelope_diagram_2 min_diag; + CGAL::lower_envelope_3(triangles.begin(), triangles.end(), min_diag); std::cout << std::endl << "The minimization diagram:" << std::endl; - print_diagram (min_diag); + print_diagram(min_diag); // Compute and print the maximization diagram. - Envelope_diagram_2 max_diag; - - CGAL::upper_envelope_3 (triangles.begin(), triangles.end(), - max_diag); - + Envelope_diagram_2 max_diag; + CGAL::upper_envelope_3 (triangles.begin(), triangles.end(), max_diag); std::cout << std::endl << "The maximization diagram:" << std::endl; print_diagram (max_diag); - return (0); + return 0; } diff --git a/Envelope_3/include/CGAL/Env_plane_traits_3.h b/Envelope_3/include/CGAL/Env_plane_traits_3.h index 85fbbf161be..d0eb6049462 100644 --- a/Envelope_3/include/CGAL/Env_plane_traits_3.h +++ b/Envelope_3/include/CGAL/Env_plane_traits_3.h @@ -7,7 +7,8 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Baruch Zukerman +// Author(s) : Baruch Zukerman +// Efi Fogel #ifndef CGAL_ENV_PLANE_TRAITS_3_H #define CGAL_ENV_PLANE_TRAITS_3_H @@ -27,169 +28,150 @@ namespace CGAL { -template -class Env_plane_traits_3 : public Arr_linear_traits_2 -{ +template > +class Env_plane_traits_3 : public ArrLinearTraits { public: - typedef Kernel_ Kernel; - typedef typename Kernel::FT FT; - typedef Arr_linear_traits_2 Base; - typedef Env_plane_traits_3 Self; + using Kernel = Kernel_; + using FT = typename Kernel::FT; + using Base = Arr_linear_traits_2; + using Self = Env_plane_traits_3; - typedef typename Base::Multiplicity Multiplicity; - typedef typename Base::Point_2 Point_2; - typedef typename Base::Curve_2 Curve_2; - typedef typename Base::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Kernel::Plane_3 Plane_3; - typedef typename Kernel::Vector_2 Vector_2; - typedef typename Kernel::Vector_3 Vector_3; - typedef typename Kernel::Segment_2 Segment_2; - typedef typename Kernel::Ray_2 Ray_2; - typedef typename Kernel::Line_2 Line_2; - typedef typename Kernel::Line_3 Line_3; - typedef std::pair Intersection_curve; + using Multiplicity = typename Base::Multiplicity; + using Point_2 = typename Base::Point_2; + using Curve_2 = typename Base::Curve_2; + using X_monotone_curve_2 = typename Base::X_monotone_curve_2; + using Plane_3 = typename Kernel::Plane_3; + using Vector_2 = typename Kernel::Vector_2; + using Vector_3 = typename Kernel::Vector_3; + using Segment_2 = typename Kernel::Segment_2; + using Ray_2 = typename Kernel::Ray_2; + using Line_2 = typename Kernel::Line_2; + using Line_3 = typename Kernel::Line_3; + using Intersection_curve = std::pair; - typedef typename Base::Left_side_category Left_side_category; - typedef typename Base::Bottom_side_category Bottom_side_category; - typedef typename Base::Top_side_category Top_side_category; - typedef typename Base::Right_side_category Right_side_category; + using Left_side_category = typename Base::Left_side_category; + using Bottom_side_category = typename Base::Bottom_side_category; + using Top_side_category = typename Base::Top_side_category; + using Right_side_category = typename Base::Right_side_category; - class Is_vertical_3 - { + //! + class Is_vertical_3 { public: - bool operator()(const Plane_3& h) const - { - return CGAL::is_zero(h.c()); - } + bool operator()(const Plane_3& h) const { return CGAL::is_zero(h.c()); } }; - Is_vertical_3 is_vertical_3_object() const - { - return Is_vertical_3(); - } + //! Obtain an Is_vertical_3 functor object. + Is_vertical_3 is_vertical_3_object() const { return Is_vertical_3(); } - class _Env_plane - { + // + class _Env_plane { protected: - Plane_3 m_plane; - Line_2 m_line; - bool m_is_all_plane; // true -> all plane, false -> halfplane - bool m_is_vert; + Plane_3 m_plane; + Line_2 m_line; + bool m_is_all_plane; // true -> all plane, false -> halfplane + bool m_is_vert; public: - _Env_plane() - {} + _Env_plane() {} - _Env_plane(const Plane_3& h) : m_plane(h), - m_is_all_plane(true) - { + _Env_plane(const Plane_3& h) : m_plane(h), m_is_all_plane(true) { Self s; m_is_vert = s.is_vertical_3_object()(h); } - _Env_plane(const Plane_3& h, const Line_2& l) : m_plane(h), - m_line(l), - m_is_all_plane(false), - m_is_vert(false) - { + _Env_plane(const Plane_3& h, const Line_2& l) : + m_plane(h), m_line(l), m_is_all_plane(false), m_is_vert(false) { CGAL_precondition_code(Self s); - CGAL_precondition(!s.is_vertical_3_object()(h)); + CGAL_precondition(! s.is_vertical_3_object()(h)); } - bool is_vertical() const - { - return m_is_vert; - } + bool is_vertical() const { return m_is_vert; } - const Plane_3& plane() const - { - return m_plane; - } + const Plane_3& plane() const { return m_plane; } + operator Plane_3() const { return m_plane; } - operator Plane_3 () const - { - return (m_plane); - } - - const Line_2& line() const - { - CGAL_assertion(!m_is_all_plane); + const Line_2& line() const { + CGAL_assertion(! m_is_all_plane); return m_line; } - bool is_all_plane() const - { - return m_is_all_plane; - } + bool is_all_plane() const { return m_is_all_plane; } }; - typedef _Env_plane Xy_monotone_surface_3; - typedef _Env_plane Surface_3; + using Xy_monotone_surface_3 = _Env_plane; + using Surface_3 = _Env_plane; - class Make_xy_monotone_3 - { + /*! Subdivide a given surface into \f$xy\f$-monotone parts. + */ + class Make_xy_monotone_3 { public: - - template - OutputIterator operator()(const Surface_3& s, - bool /* is_lower */, - OutputIterator o) const - { + template + OutputIterator operator()(const Surface_3& s, bool /* is_lower */, + OutputIterator o) const { *o++ = s; return o; } }; + //! Obtain a Make_xy_monotone_3 functor object. Make_xy_monotone_3 make_xy_monotone_3_object() const - { - return Make_xy_monotone_3(); - } + { return Make_xy_monotone_3(); } + + /*! Determine the relative \f$z\f$-order of two given \f$xy\f$-monotone + * surfaces at the \f$xy\f$-coordinates of a given point or \f$x\f$-monotone + * curve. + */ + class Compare_z_at_xy_3 { + protected: + using Traits_3 = Env_plane_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Compare_z_at_xy_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_plane_traits_3; - class Compare_z_at_xy_3 - { public: - + // Comparison_result operator()(const Point_2& p, const Xy_monotone_surface_3& h1, - const Xy_monotone_surface_3& h2) const - { + const Xy_monotone_surface_3& h2) const { const Plane_3& plane1 = h1.plane(); const Plane_3& plane2 = h2.plane(); Sign sign_of_c1c2 = CGAL::sign(plane1.c() * plane2.c()); Sign sign_of_expr = - CGAL::sign ((p.x()*plane1.a() + p.y()*plane1.b() + - plane1.d())*plane2.c() - - (p.x()*plane2.a() + p.y()*plane2.b() + - plane2.d())*plane1.c()); + CGAL::sign((p.x()*plane1.a() + p.y()*plane1.b() + + plane1.d())*plane2.c() - + (p.x()*plane2.a() + p.y()*plane2.b() + + plane2.d())*plane1.c()); int i = -1 * static_cast(sign_of_c1c2) * static_cast(sign_of_expr); return static_cast(i); } + // Comparison_result operator()(const X_monotone_curve_2& cv, const Xy_monotone_surface_3& h1, - const Xy_monotone_surface_3& h2) const - { - Kernel k; - Point_2 p; - if(cv.is_segment()) - p = k.construct_midpoint_2_object()(cv.left(), cv.right()); - else - if(cv.is_ray()) - p = k.construct_point_on_2_object()(cv.ray(), 1); - else - { - CGAL_assertion(cv.is_line()); - p = k.construct_point_on_2_object()(cv.line(), 1); - } + const Xy_monotone_surface_3& h2) const { + const Kernel& kernel = m_traits; + Point_2 p = (cv.is_segment()) ? + kernel.construct_midpoint_2_object()(cv.left(), cv.right()) : + ((cv.is_ray()) ? + kernel.construct_point_on_2_object()(cv.ray(), 1) : + kernel.construct_point_on_2_object()(cv.line(), 1)); return this->operator()(p, h1, h2); } + // Comparison_result operator()(const Xy_monotone_surface_3& h1, - const Xy_monotone_surface_3& h2) const - { + const Xy_monotone_surface_3& h2) const { CGAL_assertion(h1.is_all_plane() && h2.is_all_plane()); const Plane_3& p1 = h1.plane(); @@ -201,35 +183,63 @@ public: } }; + //! Obtain a Compare_z_at_xy_3 functor object. Compare_z_at_xy_3 compare_z_at_xy_3_object() const - { - return Compare_z_at_xy_3(); - } + { return Compare_z_at_xy_3(*this); } + + /*! Determine the relative \f$z\f$-order of the two given \f$xy\f$-monotone + * surfaces immediately above their projected intersection curve (a planar + * point \f$p\f$ is above an \f$x\f$-monotone curve \f$c\f$ if it is in the + * \f$x\f$-range of \f$c\f$, and lies to its left when the curve is traversed + * from its \f$xy\f$-lexicographically smaller endpoint to its larger + * endpoint). + */ + class Compare_z_at_xy_above_3 { + protected: + using Traits_3 = Env_plane_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Compare_z_at_xy_above_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_plane_traits_3; - class Compare_z_at_xy_above_3 - { public: + /*! Determine the relative \f$z\f$-order of the two given \f$xy\f$-monotone + * surfaces immediately above their projected intersection curve, which is + * also given. + * + * \param cv the intersection curve. + * \param h1 the first surface. + * \param h2 the second surface. + * \pre `h1` and `h2` are defined "above" `cv`, and their relative + * \f$z\f$-order is the same for some small enough neighborhood of points + * above `cv`. + */ Comparison_result operator()(const X_monotone_curve_2& cv, const Xy_monotone_surface_3& h1, - const Xy_monotone_surface_3& h2) const - { + const Xy_monotone_surface_3& h2) const { const Plane_3& plane1 = h1.plane(); const Plane_3& plane2 = h2.plane(); - const FT& a1 = plane1.a(), - b1 = plane1.b(), - c1 = plane1.c(); + const FT& a1 = plane1.a(); + const FT& b1 = plane1.b(); + const FT& c1 = plane1.c(); - const FT& a2 = plane2.a(), - b2 = plane2.b(), - c2 = plane2.c(); + const FT& a2 = plane2.a(); + const FT& b2 = plane2.b(); + const FT& c2 = plane2.c(); // our line is a3*x + b3*y + c3 = 0 // it is assumed that the planes intersect over this line const Line_2& line = cv.supp_line(); - const FT& a3 = line.a(), - b3 = line.b(), - c3 = line.c(); + const FT& a3 = line.a(); + const FT& b3 = line.b(); + // const FT& c3 = line.c(); // unused // if the line was parallel to the y-axis (i.e x = const), // then it was enough to compare dz/dx of both planes @@ -266,62 +276,97 @@ public: // are transformed to (v1,w1) and (v2,w2), so we need that w2 > w1 // (otherwise the result should be multiplied by -1) - Kernel k; - Point_2 p1 (k.construct_point_on_2_object()(line, 0)); - Point_2 p2 (k.construct_point_on_2_object()(line, 1)); + const Kernel& kernel = m_traits; + Point_2 p1 = kernel.construct_point_on_2_object()(line, 0); + Point_2 p2 = kernel.construct_point_on_2_object()(line, 1); - if(k.compare_xy_2_object()(p1, p2) == LARGER) - std::swap(p1, p2); + if (kernel.compare_xy_2_object()(p1, p2) == LARGER) std::swap(p1, p2); - CGAL_assertion(k.compare_xy_2_object()(p1, p2) == SMALLER); + CGAL_assertion(kernel.compare_xy_2_object()(p1, p2) == SMALLER); - const FT& x1 = p1.x(), - y1 = p1.y(), - x2 = p2.x(), - y2 = p2.y(); + const FT& x1 = p1.x(); + const FT& y1 = p1.y(); + const FT& x2 = p2.x(); + const FT& y2 = p2.y(); Sign s2 = CGAL_NTS sign(-b3*x1+a3*y1-(-b3*x2+a3*y2)); return s1 * s2; } - }; + //! Obtain a Compare_z_at_xy_above_3 functor object. Compare_z_at_xy_above_3 compare_z_at_xy_above_3_object() const - { - return Compare_z_at_xy_above_3(); - } + { return Compare_z_at_xy_above_3(*this); } + + /*! Determine the relative \f$z\f$-order of the two given \f$xy\f$-monotone + * surfaces immediately below their projected intersection curve (a planar + * point \f$p\f$ is below an \f$x\f$-monotone curve \f$c\f$ if it is in the + * \f$x\f$-range of \f$c\f$, and lies to its left when the curve is traversed + * from its \f$xy\f$-lexicographically smaller endpoint to its larger + * endpoint). + */ + class Compare_z_at_xy_below_3 { + protected: + using Traits_3 = Env_plane_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Compare_z_at_xy_below_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_plane_traits_3; - class Compare_z_at_xy_below_3 - { public: + /*! Determine the relative \f$z\f$-order of the two given \f$xy\f$-monotone + * surfaces immediately below their projected intersection curve, which is + * also given. + * + * \param cv the intersection curve. + * \param h1 the first surface. + * \param h2 the second surface. + * \pre `h1` and `h2` are defined "above" `cv`, and their relative + * \f$z\f$-order is the same for some small enough neighborhood of points + * below `cv`. + */ Comparison_result operator()(const X_monotone_curve_2& cv, const Xy_monotone_surface_3& h1, - const Xy_monotone_surface_3& h2) const - { - Compare_z_at_xy_above_3 cmp_above; + const Xy_monotone_surface_3& h2) const { + auto cmp_above = m_traits.compare_z_at_xy_above_3_object(); return CGAL::opposite(cmp_above(cv, h1, h2)); } - }; + //! Obtain a Compare_z_at_xy_below_3 functor object. Compare_z_at_xy_below_3 compare_z_at_xy_below_3_object() const - { - return Compare_z_at_xy_below_3(); - } + { return Compare_z_at_xy_below_3(*this); } + /*! Compute all planar \f$x\f$-monotone curves and possibly isolated planar + * points that form the projection of the boundary of the given + * \f$xy\f$-monotone surface s onto the \f$xy\f$-plane. + */ + class Construct_projected_boundary_2 { + protected: + using Traits_3 = Env_plane_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Construct_projected_boundary_2(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_plane_traits_3; - class Construct_projected_boundary_2 - { public: - - template + template OutputIterator operator()(const Xy_monotone_surface_3& s, - OutputIterator o) const - { - if(s.is_all_plane()) - { - if(!s.is_vertical()) - return o; + OutputIterator o) const { + if (s.is_all_plane()) { + if (! s.is_vertical()) return o; const Plane_3& h = s.plane(); Line_2 proj_line(h.a(), h.b(), h.d()); @@ -331,10 +376,10 @@ public: } // s is half-plane - Kernel k; - const Point_2& p1 = k.construct_point_on_2_object()(s.line(), 0); - const Point_2& p2 = k.construct_point_on_2_object()(s.line(), 1); - Comparison_result res = k.compare_xy_2_object()(p1, p2); + const Kernel& kernel = m_traits; + const Point_2& p1 = kernel.construct_point_on_2_object()(s.line(), 0); + const Point_2& p2 = kernel.construct_point_on_2_object()(s.line(), 1); + Comparison_result res = kernel.compare_xy_2_object()(p1, p2); Oriented_side side = (res == SMALLER) ? ON_POSITIVE_SIDE : ON_NEGATIVE_SIDE; @@ -343,118 +388,106 @@ public: } }; + // Construct_projected_boundary_2 construct_projected_boundary_2_object() const - { - return Construct_projected_boundary_2(); - } + { return Construct_projected_boundary_2(*this); } + /*! compute the projection of the intersections of the \f$xy\f$-monotone + * surfaces onto the \f$xy\f$-plane, + */ + class Construct_projected_intersections_2 { + protected: + using Traits_3 = Env_plane_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Construct_projected_intersections_2(const Traits_3& traits) : + m_traits(traits) + {} + + friend class Env_plane_traits_3; - class Construct_projected_intersections_2 - { public: - - template + template OutputIterator operator()(const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2, - OutputIterator o) const - { - Kernel k; + OutputIterator o) const { + const Kernel& kernel = m_traits; const Plane_3& h1 = s1.plane(); const Plane_3& h2 = s2.plane(); - if(s1.is_vertical() && s2.is_vertical()) - { + if (s1.is_vertical() && s2.is_vertical()) { Line_2 l1(h1.a(), h1.b(), h1.d()); Line_2 l2(h2.a(), h2.b(), h2.d()); - auto obj = k.intersect_2_object()(l1, l2); + auto obj = kernel.intersect_2_object()(l1, l2); - if(const Point_2* p = std::get_if(&(*obj))) - *o++ = *p; + if (const auto* p = std::get_if(&(*obj))) *o++ = *p; // otherwise, the vertical planes are parallel or overlap, so we return // nothing. return o; } - if(s1.is_all_plane() && s2.is_all_plane()) - { - auto obj = k.intersect_3_object()(h1, h2); + if (s1.is_all_plane() && s2.is_all_plane()) { + auto obj = kernel.intersect_3_object()(h1, h2); CGAL_assertion(obj != std::nullopt); - if(const Line_3* l = std::get_if(&(*obj))) - *o++ = Intersection_curve(project_xy(*l, k), 1); - + if (const auto* l = std::get_if(&(*obj))) + *o++ = Intersection_curve(project_xy(*l, kernel), 1); return o; } - if(s1.is_all_plane() && !s2.is_all_plane()) - { - auto obj = plane_half_plane_proj_intersection(h1, - h2, - s2.line(), - k); - if(obj ==std::nullopt) - return o; - if(const Line_2* line = std::get_if(&(*obj))) - { + if (s1.is_all_plane() && ! s2.is_all_plane()) { + auto obj = plane_half_plane_proj_intersection(h1, h2, s2.line(), kernel); + if (obj == std::nullopt) return o; + if (const auto* line = std::get_if(&(*obj))) { *o++ = Intersection_curve(*line, 1); return o; } - if(const Ray_2* ray = std::get_if(&(*obj))) - { + if (const auto* ray = std::get_if(&(*obj))) { *o++ = Intersection_curve(*ray, 1); return o; } return o; } - if(!s2.is_all_plane() && s2.is_all_plane()) - { - auto obj = plane_half_plane_proj_intersection(h2, - h1, - s1.line(), - k); - if(obj == std::nullopt) - return o; - if(const Line_2* line = std::get_if(&(*obj))) - { + if (! s2.is_all_plane() && s2.is_all_plane()) { + auto obj = plane_half_plane_proj_intersection(h2, h1, s1.line(), kernel); + if (obj == std::nullopt) return o; + if (const auto* line = std::get_if(&(*obj))) { *o++ = Intersection_curve(*line, 1); return o; } - if(const Ray_2* ray = std::get_if(&(*obj))) - { + if (const auto* ray = std::get_if(&(*obj))) { *o++ = Intersection_curve(*ray, 1); return o; } return o; } - CGAL_assertion(!s2.is_all_plane() && !s2.is_all_plane()); - auto obj = - half_plane_half_plane_proj_intersection(h1, s1.line(), h2, s2.line(), k); + CGAL_assertion(! s2.is_all_plane() && ! s2.is_all_plane()); + auto obj = half_plane_half_plane_proj_intersection(h1, s1.line(), + h2, s2.line(), kernel); - if(obj ==std::nullopt ) - return o; + if (obj == std::nullopt) return o; - if(const Line_2* line = std::get_if(&(*obj))) - { + if (const auto* line = std::get_if(&(*obj))) { *o++ = Intersection_curve(*line, 1); return o; } - if(const Ray_2* ray = std::get_if(&(*obj))) - { + if (const auto* ray = std::get_if(&(*obj))) { *o++ = Intersection_curve(*ray, 1); return o; } - - if(const Segment_2* seg = std::get_if(&(*obj))) - { + if (const auto* seg = std::get_if(&(*obj))) { *o++ = Intersection_curve(*seg, 1); return o; } - - if(const Point_2* p = std::get_if(&(*obj))) - { + if (const auto* p = std::get_if(&(*obj))) { *o++ = *p; return o; } @@ -462,12 +495,10 @@ public: } }; + //! Obtain a Construct_projected_intersections_2 functor object. Construct_projected_intersections_2 construct_projected_intersections_2_object() const - { - return Construct_projected_intersections_2(); - } - + { return Construct_projected_intersections_2(*this); } }; } //namespace CGAL diff --git a/Envelope_3/include/CGAL/Env_sphere_traits_3.h b/Envelope_3/include/CGAL/Env_sphere_traits_3.h index 2a42d07f0a0..3d272f81b29 100644 --- a/Envelope_3/include/CGAL/Env_sphere_traits_3.h +++ b/Envelope_3/include/CGAL/Env_sphere_traits_3.h @@ -7,10 +7,10 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman -// Ron Wein -// Efi Fogel +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Ron Wein +// Efi Fogel #ifndef CGAL_ENV_SPHERE_TRAITS_3_H #define CGAL_ENV_SPHERE_TRAITS_3_H @@ -32,96 +32,115 @@ namespace CGAL { template class Env_sphere_traits_3 : public ConicTraits_2 { public: - typedef ConicTraits_2 Traits_2; - typedef Env_sphere_traits_3 Self; + using Traits_2 = ConicTraits_2; - typedef typename Traits_2::Point_2 Point_2; - typedef typename Traits_2::Curve_2 Curve_2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Multiplicity Multiplicity; + using Point_2 = typename Traits_2::Point_2; + using Curve_2 = typename Traits_2::Curve_2; + using X_monotone_curve_2 = typename Traits_2::X_monotone_curve_2; + using Multiplicity = typename Traits_2::Multiplicity; - typedef typename Traits_2::Rat_kernel Rat_kernel; - typedef typename Traits_2::Alg_kernel Alg_kernel; - typedef typename Traits_2::Nt_traits Nt_traits; + using Rat_kernel = typename Traits_2::Rat_kernel; + using Alg_kernel = typename Traits_2::Alg_kernel; + using Nt_traits = typename Traits_2::Nt_traits; - typedef typename Rat_kernel::FT Rational; - typedef typename Rat_kernel::Point_2 Rat_point_2; - typedef typename Rat_kernel::Segment_2 Rat_segment_2; - typedef typename Rat_kernel::Line_2 Rat_line_2; - typedef typename Rat_kernel::Circle_2 Rat_circle_2; - typedef typename Rat_kernel::Point_3 Rat_point_3; + using Rational = typename Rat_kernel::FT; + using Rat_point_2 = typename Rat_kernel::Point_2; + using Rat_segment_2 = typename Rat_kernel::Segment_2; + using Rat_line_2 = typename Rat_kernel::Line_2; + using Rat_circle_2 = typename Rat_kernel::Circle_2; + using Rat_point_3 = typename Rat_kernel::Point_3; - typedef typename Alg_kernel::FT Algebraic; - typedef typename Alg_kernel::Point_2 Alg_point_2; - typedef typename Alg_kernel::Circle_2 Alg_circle_2; + using Algebraic = typename Alg_kernel::FT; + using Alg_point_2 = typename Alg_kernel::Point_2; + using Alg_circle_2 = typename Alg_kernel::Circle_2; - typedef typename Rat_kernel::Sphere_3 Surface_3; + using Surface_3 = typename Rat_kernel::Sphere_3; // here we refer to the lower part of the sphere only - typedef Surface_3 Xy_monotone_surface_3; + using Xy_monotone_surface_3 = Surface_3; protected: - typedef std::pair Intersection_curve; + using Intersection_curve = std::pair; public: + /*! Subdivide a given surface into \f$xy\f$-monotone parts. + */ class Make_xy_monotone_3 { protected: - const Self& parent; + using Traits_3 = Env_sphere_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Make_xy_monotone_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_sphere_traits_3; public: - Make_xy_monotone_3(const Self * p) : parent(*p) {} - // create xy-monotone surfaces from a general surface // return a past-the-end iterator - template - OutputIterator operator()(const Surface_3& s, - bool is_lower, - OutputIterator o) const - { + template + OutputIterator operator()(const Surface_3& s, bool is_lower, + OutputIterator o) const { // our half sphere is of same type as our full sphere since we always // need only the lower/upper part of each sphere - parent.m_is_lower = is_lower; + m_traits.m_is_lower = is_lower; *o++ = s; return o; } }; - /*! Get a Make_xy_monotone_3 functor object. */ - Make_xy_monotone_3 - make_xy_monotone_3_object() const { return Make_xy_monotone_3(this); } + /*! Obtain a Make_xy_monotone_3 functor object. */ + Make_xy_monotone_3 make_xy_monotone_3_object() const + { return Make_xy_monotone_3(*this); } + /*! Compute all planar \f$x\f$-monotone curves and possibly isolated planar + * points that form the projection of the boundary of the given + * \f$xy\f$-monotone surface s onto the \f$xy\f$-plane. + */ class Construct_projected_boundary_2 { protected: - const Self& parent; + using Traits_3 = Env_sphere_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Construct_projected_boundary_2(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_sphere_traits_3; public: - Construct_projected_boundary_2(const Self* p) : parent(*p) {} - // insert into the OutputIterator all the (2d) curves of the boundary of // the vertical projection of the surface on the xy-plane // the OutputIterator value type is X_monotone_curve_2 - template + template OutputIterator operator()(const Xy_monotone_surface_3& s, OutputIterator o) const { - const auto gt_2 = parent.geometry_traits_2(); + const Traits_2& gt2 = m_traits; // the projected boundary in a circle, with a projected center, // and same radius - Rat_point_2 proj_center = parent.project(s.center()); + Rat_point_2 proj_center = m_traits.project(s.center()); Rat_circle_2 circ(proj_center, s.squared_radius()); - Curve_2 curve = gt_2->construct_curve_2_object()(circ); - typedef std::variant Variant; + Curve_2 curve = gt2.construct_curve_2_object()(circ); + using Variant = std::variant; Variant objs[2]; CGAL_assertion_code(Variant* p = ) - parent.make_x_monotone_2_object()(curve, objs); + m_traits.make_x_monotone_2_object()(curve, objs); CGAL_assertion(p == objs + 2); - const X_monotone_curve_2* cv1 = std::get_if(&(objs[0])); - const X_monotone_curve_2* cv2 = std::get_if(&(objs[1])); + const auto* cv1 = std::get_if(&(objs[0])); + const auto* cv2 = std::get_if(&(objs[1])); - CGAL_assertion(cv1!=nullptr); - CGAL_assertion(cv2!=nullptr); + CGAL_assertion(cv1 != nullptr); + CGAL_assertion(cv2 != nullptr); if (cv1->is_lower()) { CGAL_assertion(cv2->is_upper()); @@ -138,39 +157,52 @@ public: } }; - /*! Get a Construct_projected_boundary_2 functor object. */ + /*! Obtain a Construct_projected_boundary_2 functor object. */ Construct_projected_boundary_2 construct_projected_boundary_2_object() const - { return Construct_projected_boundary_2(this); } + { return Construct_projected_boundary_2(*this); } + /*! compute the projection of the intersections of the \f$xy\f$-monotone + * surfaces onto the \f$xy\f$-plane, + */ class Construct_projected_intersections_2 { protected: - const Self& parent; + using Traits_3 = Env_sphere_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Construct_projected_intersections_2(const Traits_3& traits) : + m_traits(traits) + {} + + friend class Env_sphere_traits_3; public: - Construct_projected_intersections_2(const Self * p) : parent(*p) {} - // insert into OutputIterator all the (2d) projections on the xy plane of // the intersection objects between the 2 surfaces // the data type of OutputIterator is Object template - OutputIterator - operator()(const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2, - OutputIterator o) const { - const auto gt_2 = parent.geometry_traits_2(); - auto ctr_cv = gt_2->construct_curve_2_object(); - auto nt_traits = gt_2->nt_traits(); + OutputIterator operator()(const Xy_monotone_surface_3& s1, + const Xy_monotone_surface_3& s2, + OutputIterator o) const { + const Traits_2& gt2 = m_traits; + auto ctr_cv = gt2.construct_curve_2_object(); + auto nt_traits = gt2.nt_traits(); - Rat_point_3 p1 = s1.center(); - Rat_point_3 p2 = s2.center(); - const Rational a1 = p1.x(); - const Rational b1 = p1.y(); - const Rational c1 = p1.z(); - const Rational a2 = p2.x(); - const Rational b2 = p2.y(); - const Rational c2 = p2.z(); - const Rational sqr_r1 = s1.squared_radius(); - const Rational sqr_r2 = s2.squared_radius(); + const Rat_point_3& p1 = s1.center(); + const Rat_point_3& p2 = s2.center(); + const Rational& a1 = p1.x(); + const Rational& b1 = p1.y(); + const Rational& c1 = p1.z(); + const Rational& a2 = p2.x(); + const Rational& b2 = p2.y(); + const Rational& c2 = p2.z(); + const Rational& sqr_r1 = s1.squared_radius(); + const Rational& sqr_r2 = s2.squared_radius(); // // the spheres intersect iff d(p1, p2) <= (r1+r2) // // squaring this twice, we get the condition @@ -225,7 +257,7 @@ public: Rational B = -8*b1*sqr_a_diff; Rational C = 4*sqr_a_diff*(sqr_a1+sqr_b1-sqr_r1) + m*m - 4*m*a1*a_diff; - Algebraic ys[2]; + Algebraic ys[2]; Algebraic* ys_end = nt_traits->solve_quadratic_equation(A, B, C, ys); std::ptrdiff_t n_ys = ys_end - ys; @@ -254,7 +286,7 @@ public: // 2(a1-a2)x - m = 0 Curve_2 res = ctr_cv(0, 0, 0, 2*a_diff, 0, -m, COLLINEAR, end1, end2); - parent.add_curve_to_output(res, o); + m_traits.add_curve_to_output(res, o); //*o++ = Intersection_curve(res, TRANSVERSAL); } else { @@ -328,7 +360,7 @@ public: // 2(a1-a2)x + 2(b1-b2)y - m = 0 Curve_2 res = ctr_cv(0,0,0, 2*a_diff, 2*b_diff, -m, COLLINEAR, end1, end2); - parent.add_curve_to_output(res, o); + m_traits.add_curve_to_output(res, o); //*o++ = Intersection_curve(res, TRANSVERSAL); } } @@ -401,14 +433,14 @@ public: // if the full spheres do not intersect, the equation we get has no // real solution, so we should check it: bool ellipse_is_point = false; - if (! parent.is_valid_conic_equation(R, S, T, U, V, W, ellipse_is_point)) + if (! m_traits.is_valid_conic_equation(R, S, T, U, V, W, ellipse_is_point)) return o; // we need only a part of the ellipse (as stated in (**)) so we // construct the cutting line, which is: // equation (*) <= min(c1,c2) -- for lower envelope // equation (*) >= max(c1,c2) -- for upper envelope - Rational z_plane = (parent.m_is_lower) ? + Rational z_plane = (m_traits.m_is_lower) ? ((c1 < c2) ? c1 : c2) : ((c1 > c2) ? c1 : c2); @@ -423,7 +455,7 @@ public: // for upper envelope, we should multiply the line equation by -1 int envelope_coef = 1; - if (! parent.m_is_lower) envelope_coef = -1; + if (! m_traits.m_is_lower) envelope_coef = -1; Sign sign_c_diff = CGAL_NTS sign(c_diff); Rational la = envelope_coef*2*a_diff*sign_c_diff; @@ -454,13 +486,12 @@ public: // intersection - in which case lc >= 0 // or there is no intersection at all between the 2 half spheres - // in which case lc < 0 - if (CGAL_NTS compare(a_diff, zero) == EQUAL && - CGAL_NTS compare(b_diff, zero) == EQUAL) - { + if ((CGAL_NTS compare(a_diff, zero) == EQUAL) && + (CGAL_NTS compare(b_diff, zero) == EQUAL)) { Sign sign_lc = CGAL_NTS sign(lc); if (sign_lc != NEGATIVE) { Curve_2 res = ctr_cv(R, S, T, U, V, W); - parent.add_curve_to_output(res, o); + m_traits.add_curve_to_output(res, o); //*o++ = Intersection_curve(res, TRANSVERSAL); } return o; @@ -510,7 +541,7 @@ public: Curve_2 inter_cv = ctr_cv(R, S, T, U, V, W); CGAL_precondition_code(x_mid_n_y_points = ) - gt_2->points_at_x(inter_cv, x_mid_point, x_mid_y_points); + gt2.points_at_x(inter_cv, x_mid_point, x_mid_y_points); CGAL_precondition(x_mid_n_y_points > 0); @@ -566,7 +597,7 @@ public: Curve_2 inter_cv = ctr_cv(R, S, T, U, V, W); CGAL_precondition_code(int y_mid_n_x_points =) - gt_2->points_at_y(inter_cv, y_mid_point, y_mid_x_points); + gt2.points_at_y(inter_cv, y_mid_point, y_mid_x_points); CGAL_precondition(y_mid_n_x_points > 0); Algebraic x1 = y_mid_x_points[0].x(), x2 = y_mid_x_points[1].x(); @@ -600,7 +631,7 @@ public: Alg_point_2 vtan_ps[2]; CGAL_assertion_code(std::size_t n_vtan_ps =) - gt_2->vertical_tangency_points(inter_cv, vtan_ps); + gt2.vertical_tangency_points(inter_cv, vtan_ps); CGAL_assertion(n_vtan_ps == 2); @@ -609,7 +640,7 @@ public: Sign lval_sign = CGAL_NTS sign(lval); if (lval_sign == POSITIVE) { // the full ellipse is in the positive side - parent.add_curve_to_output(inter_cv, o); + m_traits.add_curve_to_output(inter_cv, o); //*o++ = Intersection_curve(inter_cv, TRANSVERSAL); return o; } @@ -630,7 +661,7 @@ public: lval_sign = CGAL_NTS sign(lval); CGAL_assertion(lval_sign != ZERO); - if (lval_sign == POSITIVE) parent.add_curve_to_output(inter_cv, o); + if (lval_sign == POSITIVE) m_traits.add_curve_to_output(inter_cv, o); //*o++ = Intersection_curve(inter_cv, TRANSVERSAL); else *o++ = Point_2(source); @@ -644,14 +675,14 @@ public: // If the mid-point forms a left-turn with the source and the target // points, the orientation is positive (going counterclockwise). // Otherwise, it is negative (going clockwise). - auto alg_kernel = gt_2->alg_kernel(); + auto alg_kernel = gt2.alg_kernel(); auto orient_f = alg_kernel->orientation_2_object(); Orientation orient = (orient_f(source, pmid, target) == LEFT_TURN) ? CGAL::COUNTERCLOCKWISE : CGAL::CLOCKWISE; Curve_2 res = ctr_cv(R, S, T, U, V, W, orient, source, target); CGAL_assertion(res.is_valid()); - parent.add_curve_to_output(res, o); + m_traits.add_curve_to_output(res, o); //*o++ = Intersection_curve(res, TRANSVERSAL); } @@ -659,18 +690,30 @@ public: } }; - /*! Get a Construct_projected_intersections_2 functor object. */ + /*! Obtain a Construct_projected_intersections_2 functor object. */ Construct_projected_intersections_2 construct_projected_intersections_2_object() const - { return Construct_projected_intersections_2(this); } + { return Construct_projected_intersections_2(*this); } + /*! Determine the relative \f$z\f$-order of two given \f$xy\f$-monotone + * surfaces at the \f$xy\f$-coordinates of a given point or \f$x\f$-monotone + * curve. + */ class Compare_z_at_xy_3 { protected: - const Self& parent; + using Traits_3 = Env_sphere_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Compare_z_at_xy_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_sphere_traits_3; public: - Compare_z_at_xy_3(const Self* p) : parent(*p) {} - // check which of the surfaces is closer to the envelope at the xy // coordinates of point (i.e. lower if computing the lower envelope, or // upper if computing the upper envelope) @@ -697,9 +740,8 @@ public: const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2) const { // we compute a middle point on cv and use the previous function - Point_2 mid = parent.construct_middle_point(cv); - Comparison_result res = parent.compare_z_at_xy_3_object()(mid, s1, s2); - return res; + Point_2 mid = m_traits.construct_middle_point(cv); + return m_traits.compare_z_at_xy_3_object()(mid, s1, s2); } protected: @@ -710,12 +752,12 @@ public: const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2) const { // find the z coordinates of surface 1 over p - Algebraic z1 = parent.compute_envelope_z_in_point(p, s1); + Algebraic z1 = m_traits.compute_envelope_z_in_point(p, s1); // find the z coordinates of surface 2 over p - Algebraic z2 = parent.compute_envelope_z_in_point(p, s2); + Algebraic z2 = m_traits.compute_envelope_z_in_point(p, s2); Sign res = CGAL_NTS sign(z1 - z2); - if (parent.m_is_lower) return res; + if (m_traits.m_is_lower) return res; else return -res; } @@ -735,19 +777,19 @@ public: Comparison_result compare_in_point_second_method(const Point_2& p, const Xy_monotone_surface_3& s1, - const Xy_monotone_surface_3& s2) const - { - Rat_point_3 p1 = s1.center(); - Rat_point_3 p2 = s2.center(); - const Rational a1 = p1.x(); - const Rational b1 = p1.y(); - const Rational c1 = p1.z(); - const Rational a2 = p2.x(); - const Rational b2 = p2.y(); - const Rational c2 = p2.z(); - const Rational sqr_r1 = s1.squared_radius(); - const Rational sqr_r2 = s2.squared_radius(); - const Algebraic x1 = p.x(), y1 = p.y(); + const Xy_monotone_surface_3& s2) const { + const Rat_point_3& p1 = s1.center(); + const Rat_point_3& p2 = s2.center(); + const Rational& a1 = p1.x(); + const Rational& b1 = p1.y(); + const Rational& c1 = p1.z(); + const Rational& a2 = p2.x(); + const Rational& b2 = p2.y(); + const Rational& c2 = p2.z(); + const Rational& sqr_r1 = s1.squared_radius(); + const Rational& sqr_r2 = s2.squared_radius(); + const Algebraic& x1 = p.x(); + const Algebraic& y1 = p.y(); Rational c_diff = c1 - c2; Algebraic x_diff1 = x1 - a1, y_diff1 = y1 - b1; @@ -773,17 +815,32 @@ public: } }; - /*! Get a Compare_z_at_xy_3 functor object. */ + /*! Obtain a Compare_z_at_xy_3 functor object. */ Compare_z_at_xy_3 - compare_z_at_xy_3_object() const { return Compare_z_at_xy_3(this); } + compare_z_at_xy_3_object() const { return Compare_z_at_xy_3(*this); } + /*! Determine the relative \f$z\f$-order of the two given \f$xy\f$-monotone + * surfaces immediately above their projected intersection curve (a planar + * point \f$p\f$ is above an \f$x\f$-monotone curve \f$c\f$ if it is in the + * \f$x\f$-range of \f$c\f$, and lies to its left when the curve is traversed + * from its \f$xy\f$-lexicographically smaller endpoint to its larger + * endpoint). + */ class Compare_z_at_xy_above_3 { protected: - const Self& parent; + using Traits_3 = Env_sphere_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Compare_z_at_xy_above_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_sphere_traits_3; public: - Compare_z_at_xy_above_3(const Self* p) : parent(*p) {} - // check which of the surfaces is closer to the envelope on the points above // the curve cv (i.e. lower if computing the lower envelope, or upper if // computing the upper envelope) @@ -795,35 +852,46 @@ public: operator()(const X_monotone_curve_2& cv, const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2) const - { return parent.compare_on_side(cv, s1, s2, false); } + { return m_traits.compare_on_side(cv, s1, s2, false); } }; - /*! Get a Compare_z_at_xy_above_3 functor object. */ + /*! Obtain a Compare_z_at_xy_above_3 functor object. */ Compare_z_at_xy_above_3 compare_z_at_xy_above_3_object() const - { return Compare_z_at_xy_above_3(this); } + { return Compare_z_at_xy_above_3(*this); } + /*! Determine the relative \f$z\f$-order of the two given \f$xy\f$-monotone + * surfaces immediately below their projected intersection curve (a planar + * point \f$p\f$ is below an \f$x\f$-monotone curve \f$c\f$ if it is in the + * \f$x\f$-range of \f$c\f$, and lies to its left when the curve is traversed + * from its \f$xy\f$-lexicographically smaller endpoint to its larger + * endpoint). + */ class Compare_z_at_xy_below_3 { protected: - const Self& parent; + using Traits_3 = Env_sphere_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Compare_z_at_xy_below_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_sphere_traits_3; public: - Compare_z_at_xy_below_3(const Self* p) : parent(*p) {} - - Comparison_result - operator()(const X_monotone_curve_2& cv, - const Xy_monotone_surface_3& s1, - const Xy_monotone_surface_3& s2) const - { - Comparison_result res = parent.compare_on_side(cv, s1, s2, true); - return res; - } + Comparison_result operator()(const X_monotone_curve_2& cv, + const Xy_monotone_surface_3& s1, + const Xy_monotone_surface_3& s2) const + { return m_traits.compare_on_side(cv, s1, s2, true); } }; - /*! Get a Compare_z_at_xy_below_3 functor object. */ + /*! Obtain a Compare_z_at_xy_below_3 functor object. */ Compare_z_at_xy_below_3 compare_z_at_xy_below_3_object() const - { return Compare_z_at_xy_below_3(this); } + { return Compare_z_at_xy_below_3(*this); } /***************************************************************************/ @@ -832,31 +900,39 @@ public: // checks if point is in the xy-range of surf class Is_defined_over { protected: - const Self& parent; + using Traits_3 = Env_sphere_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Is_defined_over(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_sphere_traits_3; public: - Is_defined_over(const Self* p) : parent(*p) {} - // checks if point is in the xy-range of surf bool operator()(const Point_2& p, const Xy_monotone_surface_3& s) const { // project the surface on the plane - Rat_point_2 proj_center = parent.project(s.center()); + Rat_point_2 proj_center = m_traits.project(s.center()); Rat_circle_2 boundary(proj_center, s.squared_radius()); - const auto gt_2 = parent.geometry_traits_2(); - auto nt_traits = gt_2->nt_traits(); + const Traits_2& gt2 = m_traits; + auto nt_traits = gt2.nt_traits(); Alg_point_2 aproj_center(proj_center.x(), proj_center.y()); Alg_circle_2 aboundary(aproj_center, nt_traits->convert(s.squared_radius())); // check if the projected point is inside the projected boundary - auto alg_kernel = gt_2->alg_kernel(); + auto alg_kernel = gt2.alg_kernel(); return (! alg_kernel->has_on_unbounded_side_2_object()(aboundary, p)); } }; - /*! Get a Is_defined_over functor object. */ + /*! Obtain a Is_defined_over functor object. */ Is_defined_over is_defined_over_object() const - { return Is_defined_over(this); } + { return Is_defined_over(*this); } /***************************************************************************/ @@ -867,8 +943,7 @@ public: Comparison_result compare_on_side(const X_monotone_curve_2& cv, const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2, - bool compare_on_right) const - { + bool compare_on_right) const { // cv(x,y) : r*x^2 + s*y^2 + t*xy + u*x + v*y + w = 0 // let p be the leftmost endpoint of cv, p=(x0, y0) // the tangence of cv at p is a line. on the infinitesimal region @@ -881,7 +956,8 @@ public: // since we assume that such point represents better what is going // on all internal curve points Point_2 cv_point = construct_middle_point(cv); - Algebraic x0 = cv_point.x(), y0 = cv_point.y(); + const Algebraic& x0 = cv_point.x(); + const Algebraic& y0 = cv_point.y(); // d(cv)/dx : 2r*x + 2s*y*dy/dx + t*y + t*x*dy/dx +u + v*dy/dx = 0 // in point p=(x0,y0) we get @@ -895,8 +971,12 @@ public: // n != 0: y - y0 = y'(x-x0) ==> -y'x + y + (y'x0 - y0) = 0 // and in general we have: // -m*x + n*y + (m*x0 -n*y0) = 0 (with integer coordinates) - const Rational r = cv.r(), s = cv.s(), t = cv.t(), - u = cv.u(), v = cv.v(), w = cv.w(); + const Rational& r = cv.r(); + const Rational& s = cv.s(); + const Rational& t = cv.t(); + const Rational& u = cv.u(); + const Rational& v = cv.v(); + // const Rational& w = cv.w(); // unused Algebraic m = -1 * (2*r*x0 + t*y0 + u); Algebraic n = 2*s*y0 + t*x0 + v; // line coefficients: A3, B3, C3 @@ -931,14 +1011,14 @@ public: // Di = -(x0-ai)x0 - (y0-bi)y0 - (z0-ci)z0 // // and we solve the problem as for triangles - Rat_point_3 p1 = s1.center(); - Rat_point_3 p2 = s2.center(); - const Rational a1 = p1.x(); - const Rational b1 = p1.y(); - const Rational c1 = p1.z(); - const Rational a2 = p2.x(); - const Rational b2 = p2.y(); - const Rational c2 = p2.z(); + const Rat_point_3& p1 = s1.center(); + const Rat_point_3& p2 = s2.center(); + const Rational& a1 = p1.x(); + const Rational& b1 = p1.y(); + const Rational& c1 = p1.z(); + const Rational& a2 = p2.x(); + const Rational& b2 = p2.y(); + const Rational& c2 = p2.z(); Algebraic A1 = x0 - a1, B1 = y0 - b1, C1 = z0 - c1; Algebraic A2 = x0 - a2, B2 = y0 - b2, C2 = z0 - c2; if (C1 != 0 && C2 != 0) { @@ -971,6 +1051,7 @@ public: return EQUAL; } + // Rat_point_2 project(const Rat_point_3& p) const { return Rat_point_2(p.x(), p.y()); } @@ -979,15 +1060,15 @@ public: // precondition: s is defined at p Algebraic compute_envelope_z_in_point(const Point_2& p, const Xy_monotone_surface_3& s) const { - Algebraic res; - // the point coordinates const Algebraic x1 = p.x(), y1 = p.y(); // the surface equations - Rat_point_3 center = s.center(); - const Rational a = center.x(), b = center.y(), c = center.z(); - const Rational sqr_r = s.squared_radius(); + const Rat_point_3& center = s.center(); + const Rational& a = center.x(); + const Rational& b = center.y(); + const Rational& c = center.z(); + const Rational& sqr_r = s.squared_radius(); // we substitute x1 and y1 in the equation of s // (x-a)^2 + (y-b)^2 + (z-c)^2 = r^2 @@ -999,11 +1080,12 @@ public: Algebraic B = -2*c; Algebraic C = x_diff*x_diff + y_diff*y_diff + c*c - sqr_r; - Algebraic zs[2]; + Algebraic zs[2]; Algebraic* zs_end; std::ptrdiff_t n_zs; - auto nt_traits = m_geometry_traits_2->nt_traits(); + const Traits_2& gt2 = *this; + auto nt_traits = gt2.nt_traits(); zs_end = nt_traits->solve_quadratic_equation(A, B, C, zs); n_zs = zs_end - zs; @@ -1013,6 +1095,7 @@ public: if (n_zs == 1) return zs[0]; CGAL_assertion(n_zs == 2); + Algebraic res; Comparison_result comp = CGAL_NTS compare(zs[0], zs[1]); if (m_is_lower) res = ((comp == SMALLER) ? zs[0] : zs[1]); else res = ((comp == LARGER) ? zs[0] : zs[1]); @@ -1021,8 +1104,10 @@ public: // construct the point in the middle of cv Point_2 construct_middle_point(const X_monotone_curve_2& cv) const { + const Traits_2& gt2 = *this; + // get the x-value of the middle point - auto alg_kernel = m_geometry_traits_2->alg_kernel(); + auto alg_kernel = gt2.alg_kernel(); Alg_point_2 mid_x = alg_kernel->construct_midpoint_2_object()(cv.source(), cv.target()); @@ -1030,13 +1115,14 @@ public: // maybe we want it there? // if (cv.is_segment()) return mid_x; if (cv.is_vertical()) return Point_2(mid_x); - return Point_2(m_geometry_traits_2->point_at_x(cv, mid_x)); + return Point_2(gt2.point_at_x(cv, mid_x)); } // for the test Point_2 construct_middle_point(const Point_2& p1, const Point_2& p2) const { - auto alg_kernel = m_geometry_traits_2->alg_kernel(); + const Traits_2& gt2 = *this; + auto alg_kernel = gt2.alg_kernel(); return Point_2(alg_kernel->construct_midpoint_2_object()(p1, p2)); } @@ -1044,7 +1130,7 @@ public: // r*x^2 + s*y^2 + t*xy + u*x + v*y + w = 0 // has real solutions // is_point is set to true if the equation represents just one point - template + template bool is_valid_conic_equation(const NT& r, const NT& s, const NT& t, const NT& u, const NT& v, const NT& w, bool& is_point) const { @@ -1103,30 +1189,31 @@ public: // for the test: Point_2 vertical_ray_shoot_2(const Point_2& pt, const X_monotone_curve_2& cv) - const - { + const { + const Traits_2& gt2 = *this; if (cv.is_vertical()) { - auto alg_kernel = m_geometry_traits_2->alg_kernel(); - if (! alg_kernel->less_y_2_object()(cv.left(), pt)) - return cv.left(); - else { - CGAL_assertion(alg_kernel->less_y_2_object()(cv.right(), pt)); - return cv.right(); - } + auto alg_kernel = gt2.alg_kernel(); + if (! alg_kernel->less_y_2_object()(cv.left(), pt)) return cv.left(); + + CGAL_assertion(alg_kernel->less_y_2_object()(cv.right(), pt)); + return cv.right(); } - else return m_geometry_traits_2->point_at_x(cv, pt); + + return gt2.point_at_x(cv, pt); } + // template OutputIterator add_curve_to_output(const Curve_2& c, OutputIterator oi) const { std::variant objs[2]; - std::variant* p_obj = this->make_x_monotone_2_object()(c, objs); - for(std::variant* o = objs; o != p_obj; ++o) { - if(const X_monotone_curve_2* cv = std::get_if(o)) + std::variant* p_obj = + this->make_x_monotone_2_object()(c, objs); + for (std::variant* o = objs; o != p_obj; ++o) { + if (const auto* cv = std::get_if(o)) *oi++ = Intersection_curve(*cv, 1); else { - const Point_2* pt = std::get_if(o); + const auto* pt = std::get_if(o); CGAL_assertion(pt!=nullptr); *oi++ = *pt; } @@ -1134,55 +1221,39 @@ public: return oi; } - typedef std::shared_ptr Shared_geometry_traits_2; - /*! Default constructor. */ - Env_sphere_traits_3() : - m_is_lower(true), - m_geometry_traits_2(new Traits_2) - {} - - /*! Constructor from a conic 2D geometry traits. */ - Env_sphere_traits_3(Shared_geometry_traits_2 geometry_traits_2) : - m_is_lower(true), - m_geometry_traits_2(geometry_traits_2) - {} - - /*! Obtain the undelying conic 2D geometry traits. - */ - const Shared_geometry_traits_2 geometry_traits_2() const - { return m_geometry_traits_2; } + Env_sphere_traits_3() : m_is_lower(true) {} protected: mutable bool m_is_lower; - -private: - //! The conic geometry-traits. - const Shared_geometry_traits_2 m_geometry_traits_2; }; -/*! - * Compare two spheres: first compare their center points in an - * xyz-lexicographic order, then by their radii. +/*! Compare two spheres: first compare their center points in an + * xyz-lexicographic order, then by their squared radii. + * + * \todo This should be deprecated and instead the traits should provide this + * functionality. */ template bool operator<(const CGAL::Sphere_3& a, const CGAL::Sphere_3& b) { Kernel k; Comparison_result res = k.compare_xyz_3_object()(a.center(), b.center()); - if (res == EQUAL) res = CGAL::compare (a.squared_radius(), b.squared_radius()); + if (res == EQUAL) res = CGAL::compare(a.squared_radius(), b.squared_radius()); return (res == SMALLER); } -/*! - * Compare two spheres for equality. +/*! Compare two spheres for equality. + * + * \todo This should be deprecated and instead the traits should provide this + * functionality. */ template -bool operator== (const typename Kernel::Sphere_3& a, - const typename Kernel::Sphere_3& b) { +bool operator==(const typename Kernel::Sphere_3& a, + const typename Kernel::Sphere_3& b) { Kernel k; - if (! k.equal_3_object() (a.center(), b.center())) return (false); - return (CGAL::compare (a.squared_radius(), b.squared_radius()) == EQUAL); + if (! k.equal_3_object()(a.center(), b.center())) return (false); + return (CGAL::compare(a.squared_radius(), b.squared_radius()) == EQUAL); } } //namespace CGAL diff --git a/Envelope_3/include/CGAL/Env_surface_data_traits_3.h b/Envelope_3/include/CGAL/Env_surface_data_traits_3.h index 9624b70a79d..835ec7b35e2 100644 --- a/Envelope_3/include/CGAL/Env_surface_data_traits_3.h +++ b/Envelope_3/include/CGAL/Env_surface_data_traits_3.h @@ -8,7 +8,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Ron Wein +// Author(s) : Ron Wein +// Efi Fogel + #ifndef CGAL_ENV_SURFACE_DATA_TRAITS_3_H #define CGAL_ENV_SURFACE_DATA_TRAITS_3_H @@ -19,9 +21,10 @@ * Definition of the env_surface_data_traits_3<> class template. */ -#include #include +#include + namespace CGAL { /*! \class @@ -31,95 +34,80 @@ namespace CGAL { * It can attach data objects to Surface_3 and to Xy_monotone_surface_3 objects * (possibly of two different types). */ -template > -class Env_surface_data_traits_3 : public Traits_ -{ +template > +class Env_surface_data_traits_3 : public Traits_ { public: + using Base_traits_3 = Traits_; + using Xy_monotone_surface_data = XyMonotoneSurfaceData; + using Surface_data = SurfaceData; + using Convert = Convert_; - typedef Traits_ Base_traits_3; - typedef XyMonotoneSurfaceData_ Xy_monotone_surface_data; - typedef SurfaceData_ Surface_data; - typedef Convert_ Convert; - - typedef typename Base_traits_3::Surface_3 Base_surface_3; - typedef typename Base_traits_3::Xy_monotone_surface_3 - Base_xy_monotone_surface_3; + using Base_surface_3 = typename Base_traits_3::Surface_3; + using Base_xy_monotone_surface_3 = + typename Base_traits_3::Xy_monotone_surface_3; // Representation of a surface with an additional data field: - typedef _Curve_data_ex Surface_3; + using Surface_3 = _Curve_data_ex; // Representation of an xy-monotone surface with an additional data field: - typedef _Curve_data_ex Xy_monotone_surface_3; + using Xy_monotone_surface_3 = + _Curve_data_ex; public: - /// \name Construction. //@{ /*! Default constructor. */ - Env_surface_data_traits_3 () - {} + Env_surface_data_traits_3() {} /*! Constructor from a base-traits class. */ - Env_surface_data_traits_3 (const Base_traits_3 & traits) : - Base_traits_3 (traits) + Env_surface_data_traits_3(const Base_traits_3& traits) : + Base_traits_3(traits) {} //@} /// \name Overridden functors. //@{ - class Make_xy_monotone_3 - { + class Make_xy_monotone_3 { private: - const Base_traits_3 * base; + const Base_traits_3* base; public: - /*! Constructor. */ - Make_xy_monotone_3 (const Base_traits_3 * _base) : base (_base) - {} + Make_xy_monotone_3(const Base_traits_3* _base) : base (_base) {} - /*! - * Subdivide the given surface into xy-monotone surfaces and insert them + /*! Subdivide the given surface into xy-monotone surfaces and insert them * to the given output iterator. * \param S The surface. * \param oi The output iterator, * whose value-type is Xy_monotone_surface_2. * \return The past-the-end iterator. */ - template - OutputIterator operator() (const Surface_3& S, bool is_lower, - OutputIterator oi) const - { + template + OutputIterator operator()(const Surface_3& S, bool is_lower, + OutputIterator oi) const { // Make the original surface xy-monotone. - std::list xy_surfaces; - typename std::list::iterator xys_it; + std::list xy_surfaces; + typename std::list::iterator xys_it; - base->make_xy_monotone_3_object() - (S, is_lower, std::back_inserter (xy_surfaces)); + base->make_xy_monotone_3_object()(S, is_lower, + std::back_inserter(xy_surfaces)); // Attach the data to each of the resulting xy-monotone surfaces. for (xys_it = xy_surfaces.begin(); xys_it != xy_surfaces.end(); ++xys_it) - { - *oi = Xy_monotone_surface_3 (*xys_it, - Convert() (S.data())); - ++oi; - } + *oi++ = Xy_monotone_surface_3(*xys_it, Convert() (S.data())); - return (oi); + return oi; } }; /*! Get a Make_xy_monotone_3 functor object. */ Make_xy_monotone_3 make_xy_monotone_3_object() const - { - return Make_xy_monotone_3 (this); - } + { return Make_xy_monotone_3(this); } //@} diff --git a/Envelope_3/include/CGAL/Env_triangle_traits_3.h b/Envelope_3/include/CGAL/Env_triangle_traits_3.h index 00ccc69e8fa..0bb6e384c45 100644 --- a/Envelope_3/include/CGAL/Env_triangle_traits_3.h +++ b/Envelope_3/include/CGAL/Env_triangle_traits_3.h @@ -7,8 +7,9 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Efi Fogel /*! \file CGAL/Envelope_triangles_traits_3.h * \brief Model for CGAL's EnvelopeTraits_3 concept. @@ -20,72 +21,62 @@ #include + +#include + #include #include #include #include -#include - namespace CGAL { -template class Env_triangle_3; +template class Env_triangle_3; // this traits class supports both triagles and segments in 3d -template -class Env_triangle_traits_3 : public Arr_segment_traits_2 -{ +template > +class Env_triangle_traits_3 : public ArrSegmentTraits { public: - typedef Arr_segment_traits_2 Traits_2; - typedef typename Traits_2::Point_2 Point_2; - typedef typename Traits_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits_2::Multiplicity Multiplicity; + using Traits_2 = Arr_segment_traits_2; + using Point_2 = typename Traits_2::Point_2; + using X_monotone_curve_2 = typename Traits_2::X_monotone_curve_2; + using Multiplicity = typename Traits_2::Multiplicity; - typedef Kernel_ Kernel; - typedef Env_triangle_traits_3 Self; + using Kernel = Kernel_; + using Self = Env_triangle_traits_3; - typedef typename Kernel::Point_3 Point_3; + using Point_3 = typename Kernel::Point_3; - /*! - * \class Representation of a 3d triangle with cached data. + /*! \class Representation of a 3d triangle with cached data. */ - class _Triangle_cached_3 - { + class _Triangle_cached_3 { public: - - typedef typename Kernel::Plane_3 Plane_3; - typedef typename Kernel::Triangle_3 Triangle_3; - typedef typename Kernel::Point_3 Point_3; - typedef typename Kernel::Segment_3 Segment_3; + using Plane_3 = typename Kernel::Plane_3; + using Triangle_3 = typename Kernel::Triangle_3; + using Point_3 = typename Kernel::Point_3; + using Segment_3 = typename Kernel::Segment_3; protected: - Plane_3 pl; // The plane that supports the triangle. Point_3 vertices[3]; // The vertices of the triangle. - bool is_vert; // Is this a vertical triangle (or a segment). - bool is_seg; // Is this a segment. + bool is_vert; // Is this a vertical triangle (or a segment). + bool is_seg; // Is this a segment. + public: - - /*! - * Default constructor. + /*! Default constructor. */ - _Triangle_cached_3() : - is_vert(false), - is_seg(false) - {} + _Triangle_cached_3() : is_vert(false), is_seg(false) {} - /*! - * Constructor from a non-degenerate triangle. + /*! Constructor from a non-degenerate triangle. * \param tri The triangle. * \pre The triangle is not degenerate. */ - _Triangle_cached_3(const Triangle_3 & tri) - { - Kernel kernel; - CGAL_assertion(!kernel.is_degenerate_3_object()(tri)); + _Triangle_cached_3(const Triangle_3& tri) { + Kernel kernel; + CGAL_assertion(! kernel.is_degenerate_3_object()(tri)); - typename Kernel::Construct_vertex_3 - construct_vertex = kernel.construct_vertex_3_object(); + auto construct_vertex = kernel.construct_vertex_3_object(); vertices[0] = construct_vertex(tri, 0); vertices[1] = construct_vertex(tri, 1); @@ -100,25 +91,22 @@ public: is_seg = false; } - /*! - * Construct a triangle from three non-collinear end-points. + /*! Construct a triangle from three non-collinear end-points. * \param p1 The first point. * \param p2 The second point. * \param p3 The third point. * \pre The 3 endpoints are not the collinear. */ - _Triangle_cached_3(const Point_3 &p1, const Point_3 &p2, - const Point_3 &p3) - { - Kernel kernel; - CGAL_assertion(!kernel.collinear_3_object()(p1, p2, p3)); + _Triangle_cached_3(const Point_3& p1, const Point_3& p2, + const Point_3& p3) { + Kernel kernel; + CGAL_assertion(! kernel.collinear_3_object()(p1, p2, p3)); vertices[0] = p1; vertices[1] = p2; vertices[2] = p3; - pl = kernel.construct_plane_3_object()(vertices[0], - vertices[1], + pl = kernel.construct_plane_3_object()(vertices[0], vertices[1], vertices[2]); Self self; is_vert = kernel.collinear_2_object()(self.project(vertices[0]), @@ -127,8 +115,7 @@ public: is_seg = false; } - /*! - * Construct a triangle from 3 end-points on a supporting plane. + /*! Construct a triangle from 3 end-points on a supporting plane. * \param supp_plane The supporting plane. * \param p1 The first point. * \param p2 The second point. @@ -136,13 +123,10 @@ public: * \pre The 3 endpoints are not the collinear and all lie on the given * plane. */ - _Triangle_cached_3(const Plane_3& supp_plane, - const Point_3 &p1, - const Point_3 &p2, - const Point_3 &p3) : - pl(supp_plane) - { - Kernel kernel; + _Triangle_cached_3(const Plane_3& supp_plane, const Point_3& p1, + const Point_3& p2, const Point_3& p3) : + pl(supp_plane) { + Kernel kernel; CGAL_precondition(kernel.has_on_3_object() (pl, p1) && kernel.has_on_3_object() (pl, p2) && @@ -160,15 +144,13 @@ public: is_seg = false; } - /*! - * Constructor from a segment. + /*! Constructor from a segment. * \param seg The segment. * \pre The segment is not degenerate. */ - _Triangle_cached_3(const Segment_3 & seg) - { - Kernel kernel; - CGAL_assertion(!kernel.is_degenerate_3_object()(seg)); + _Triangle_cached_3(const Segment_3& seg) { + Kernel kernel; + CGAL_assertion(! kernel.is_degenerate_3_object()(seg)); typename Kernel::Construct_vertex_3 construct_vertex = kernel.construct_vertex_3_object(); @@ -182,22 +164,18 @@ public: // construct a vertical plane through the segment Point_3 tmp(vertices[0].x(), vertices[0].y(), vertices[0].z()-1); - pl = kernel.construct_plane_3_object()(vertices[0], - vertices[1], tmp); - + pl = kernel.construct_plane_3_object()(vertices[0], vertices[1], tmp); } - /*! - * Constructor from two points. + /*! Constructor from two points. * \param p1 The first point. * \param p2 The second point. * \param seg The segment. * \pre The segment between the points is not degenerate. */ - _Triangle_cached_3(const Point_3 &p1, const Point_3 &p2) - { - Kernel kernel; - CGAL_assertion(!kernel.equal_3_object()(p1, p2)); + _Triangle_cached_3(const Point_3& p1, const Point_3& p2) { + Kernel kernel; + CGAL_assertion(! kernel.equal_3_object()(p1, p2)); vertices[0] = p1; vertices[1] = p2; @@ -208,22 +186,17 @@ public: // construct a vertical plane through the segment Point_3 tmp(vertices[0].x(), vertices[0].y(), vertices[0].z()-1); - pl = kernel.construct_plane_3_object()(vertices[0], - vertices[1], tmp); - + pl = kernel.construct_plane_3_object()(vertices[0], vertices[1], tmp); } - /*! - * Assignment operator. + /*! Assignment operator. * \param tri the source triangle to copy from */ - const _Triangle_cached_3& operator=(const Triangle_3 &tri) - { - Kernel kernel; - CGAL_assertion(!kernel.is_degenerate_3_object()(tri)); + const _Triangle_cached_3& operator=(const Triangle_3& tri) { + Kernel kernel; + CGAL_assertion(! kernel.is_degenerate_3_object()(tri)); - typename Kernel_::Construct_vertex_3 - construct_vertex = kernel.construct_vertex_3_object(); + auto construct_vertex = kernel.construct_vertex_3_object(); vertices[0] = construct_vertex(tri, 0); vertices[1] = construct_vertex(tri, 1); @@ -240,129 +213,105 @@ public: return (*this); } - /*! - * Get the ith endpoint. + /*! Get the ith endpoint. */ - const Point_3& vertex(unsigned int i) const - { - return vertices[i%3]; - } + const Point_3& vertex(unsigned int i) const { return vertices[i%3]; } - /*! - * Get the supporting plane. + /*! Get the supporting plane. */ - const Plane_3& plane() const - { - return (pl); - } + const Plane_3& plane() const { return (pl); } - /*! - * Check if the triangle is vertical. + /*! Check whether the triangle is vertical. */ - bool is_vertical() const - { - return (is_vert); - } + bool is_vertical() const { return (is_vert); } - /*! - * Check if the surface is a segment. + /*! Check whether the surface is a segment. */ - bool is_segment() const - { - return (is_seg); - } + bool is_segment() const { return (is_seg); } - /*! - * Check if the surface is xy-monotone (false, if it is a vertical + /*! Check whether the surface is xy-monotone (false, if it is a vertical * triangle) */ - bool is_xy_monotone() const - { - return (!is_vertical() || is_segment()); - } + bool is_xy_monotone() const { return (!is_vertical() || is_segment()); } }; public: - // types for EnvelopeTraits_3 concept //! type of xy-monotone surfaces - typedef Env_triangle_3 Xy_monotone_surface_3; + using Xy_monotone_surface_3 = Env_triangle_3; //! type of surfaces - typedef Xy_monotone_surface_3 Surface_3; + using Surface_3 = Xy_monotone_surface_3; // we have a collision between the Kernel's Intersect_2 and the one // from the segment traits - typedef typename Traits_2::Intersect_2 Intersect_2; + using Intersect_2 = typename Traits_2::Intersect_2; protected: - typedef typename Kernel::FT FT; - typedef typename Kernel::Triangle_2 Triangle_2; - typedef typename Kernel::Segment_2 Segment_2; + using FT = typename Kernel::FT; + using Triangle_2 = typename Kernel::Triangle_2; + using Segment_2 = typename Kernel::Segment_2; - typedef typename Kernel::Segment_3 Segment_3; - typedef typename Kernel::Triangle_3 Triangle_3; - typedef typename Kernel::Plane_3 Plane_3; + using Segment_3 = typename Kernel::Segment_3; + using Triangle_3 = typename Kernel::Triangle_3; + using Plane_3 = typename Kernel::Plane_3; - typedef typename Kernel::Assign_2 Assign_2; - typedef typename Kernel::Construct_vertex_2 Construct_vertex_2; + using Assign_2 = typename Kernel::Assign_2; + using Construct_vertex_2 = typename Kernel::Construct_vertex_2; - typedef typename Kernel::Assign_3 Assign_3; - typedef typename Kernel::Intersect_3 Intersect_3; - typedef typename Kernel::Construct_vertex_3 Construct_vertex_3; + using Assign_3 = typename Kernel::Assign_3; + using Intersect_3 = typename Kernel::Intersect_3; + using Construct_vertex_3 = typename Kernel::Construct_vertex_3; - typedef typename Kernel::Line_2 Line_2; - typedef typename Kernel::Direction_2 Direction_2; + using Line_2 = typename Kernel::Line_2; + using Direction_2 = typename Kernel::Direction_2; - typedef typename Kernel::Line_3 Line_3; - typedef typename Kernel::Direction_3 Direction_3; + using Line_3 = typename Kernel::Line_3; + using Direction_3 = typename Kernel::Direction_3; + + using Intersection_curve = std::pair; - typedef std::pair Intersection_curve; public: - /***************************************************************************/ // EnvelopeTraits_3 functors /***************************************************************************/ - /*!\brief - * Subdivide the given surface into envelope relevant xy-monotone - * parts, and insert them into the output iterator. - * - * The iterator value-type is Xy_monotone_surface_3 + /*! Subdivide a given surface into \f$xy\f$-monotone parts. */ - class Make_xy_monotone_3 - { + class Make_xy_monotone_3 { protected: - const Self * parent; + using Traits_3 = Env_triangle_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Make_xy_monotone_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_triangle_traits_3; public: - Make_xy_monotone_3(const Self * p) : parent(p) - {} // create xy-monotone surfaces from a general surface // return a past-the-end iterator - template - OutputIterator operator()(const Surface_3& s, - bool is_lower, - OutputIterator o) const - { + template + OutputIterator operator()(const Surface_3& s, bool is_lower, + OutputIterator o) const { m_is_lower = is_lower; // a non-vertical triangle is already xy-monotone - if (!s.is_vertical()) - *o++ = s; - else - { + if (! s.is_vertical()) *o++ = s; + else { // split a vertical triangle into one or two segments - const Point_3 &a1 = s.vertex(0), - a2 = s.vertex(1), - a3 = s.vertex(2); - Point_2 b1 = parent->project(a1), - b2 = parent->project(a2), - b3 = parent->project(a3); - Kernel k; - if (k.collinear_are_ordered_along_line_2_object()(b1, b2, b3)) - { + const Point_3& a1 = s.vertex(0); + const Point_3& a2 = s.vertex(1); + const Point_3& a3 = s.vertex(2); + Point_2 b1 = m_traits.project(a1); + Point_2 b2 = m_traits.project(a2); + Point_2 b3 = m_traits.project(a3); + const Kernel& k = m_traits; + if (k.collinear_are_ordered_along_line_2_object()(b1, b2, b3)) { if (k.equal_2_object()(b1, b2)) // only one segment in the output - the vertical does not count *o++ = Xy_monotone_surface_3(find_envelope_point(a1, a2), a3); @@ -372,8 +321,7 @@ public: // check whether two or one segments appear on the envelope return find_envelope_segments(a1, a2, a3, s.plane(), o); } - else if (k.collinear_are_ordered_along_line_2_object()(b1, b3, b2)) - { + else if (k.collinear_are_ordered_along_line_2_object()(b1, b3, b2)) { if (k.equal_2_object()(b1, b3)) // only one segment in the output *o++ = Xy_monotone_surface_3(find_envelope_point(a1, a3), a2); @@ -381,42 +329,35 @@ public: // check whether two or one segments appear on the envelope return find_envelope_segments(a1, a3, a2, s.plane(), o); } - else - { + else { // check whether two or one segments appear on the envelope return find_envelope_segments(a2, a1, a3, s.plane(), o); } - } return o; } protected: // find the envelope point among the two points with same xy coordinates - const Point_3& find_envelope_point (const Point_3& p1, - const Point_3& p2) const - { + const Point_3& find_envelope_point(const Point_3& p1, const Point_3& p2) + const { CGAL_precondition(p1.x() == p2.x() && p1.y() == p2.y()); - Kernel k; + const Kernel& k = m_traits; Comparison_result cr = k.compare_z_3_object()(p1, p2); CGAL_assertion(cr != EQUAL); - if ((m_is_lower && cr == SMALLER) || - (!m_is_lower && cr == LARGER)) + if ((m_is_lower && cr == SMALLER) || (! m_is_lower && cr == LARGER)) return p1; - else - return p2; + else return p2; } // get the three triangle coordinates (ordered along 2d-line) and find // which segment(s) is(are) the envelope of this triangle // "plane" is the vertical plane on which the triangle lies - template - OutputIterator find_envelope_segments(const Point_3& p1, - const Point_3& p2, + template + OutputIterator find_envelope_segments(const Point_3& p1, const Point_3& p2, const Point_3& p3, const Plane_3& plane, - OutputIterator o) const - { + OutputIterator o) const { // our vertical plane is a*x + b*y + d = 0 FT a = plane.a(), b = plane.b(); CGAL_precondition(plane.c() == 0); @@ -445,9 +386,9 @@ public: // (-b*x3 + a*y3 + b*x1 - a*y1)(z2 - z1) - // (z3 - z1)(-b*x2 + a*y2 + b*x1 - a*y1) // - FT w1 = a*p1.y() - b*p1.x(), - w2 = a*p2.y() - b*p2.x(), - w3 = a*p3.y() - b*p3.x(); + FT w1 = a*p1.y() - b*p1.x(); + FT w2 = a*p2.y() - b*p2.x(); + FT w3 = a*p3.y() - b*p3.x(); Sign s1 = CGAL::sign((w3 - w1)*(p2.z() - p1.z()) - (p3.z() - p1.z())*(w2 - w1)); @@ -461,16 +402,11 @@ public: Sign s = CGAL_NTS sign(int(s1 * s2)); bool use_one_segment = true; - if ((m_is_lower && s == NEGATIVE) || - (!m_is_lower && s == POSITIVE)) + if ((m_is_lower && (s == NEGATIVE)) || (! m_is_lower && (s == POSITIVE))) use_one_segment = false; - if (use_one_segment) - { - *o++ = Xy_monotone_surface_3(p1, p3); - } - else - { + if (use_one_segment) *o++ = Xy_monotone_surface_3(p1, p3); + else { *o++ = Xy_monotone_surface_3(p1, p2); *o++ = Xy_monotone_surface_3(p2, p3); } @@ -480,50 +416,49 @@ public: mutable bool m_is_lower; }; - /*! Get a Make_xy_monotone_3 functor object. */ + /*! Obtain a Make_xy_monotone_3 functor object. */ Make_xy_monotone_3 - make_xy_monotone_3_object() const - { - return Make_xy_monotone_3(this); - } + make_xy_monotone_3_object() const { return Make_xy_monotone_3(*this); } - /*!\brief - * Insert all 2D curves, which form the boundary of the vertical - * projection of the surface onto the xy-plane, into the output iterator. - * The iterator value-type is X_monotone_curve_2. + /*! Compute all planar \f$x\f$-monotone curves and possibly isolated planar + * points that form the projection of the boundary of the given + * \f$xy\f$-monotone surface s onto the \f$xy\f$-plane. */ - class Construct_projected_boundary_2 - { + class Construct_projected_boundary_2 { protected: - const Self *parent; + using Traits_3 = Env_triangle_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Construct_projected_boundary_2(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_triangle_traits_3; + public: - - Construct_projected_boundary_2(const Self* p) - : parent(p) - {} - // insert into the OutputIterator all the (2d) curves of the boundary of // the vertical projection of the surface on the xy-plane // the OutputIterator value type is X_monotone_curve_2 - template + template OutputIterator operator()(const Xy_monotone_surface_3& s, - OutputIterator o) const - { + OutputIterator o) const { // the input xy-monotone surface should be either non-vertical or // a segment CGAL_assertion(s.is_xy_monotone()); - if (!s.is_vertical()) - { + if (! s.is_vertical()) { // the projection is a triangle - const Point_3 &a1 = s.vertex(0), - a2 = s.vertex(1), - a3 = s.vertex(2); - Point_2 b1 = parent->project(a1), - b2 = parent->project(a2), - b3 = parent->project(a3); + const Point_3& a1 = s.vertex(0); + const Point_3& a2 = s.vertex(1); + const Point_3& a3 = s.vertex(2); + Point_2 b1 = m_traits.project(a1); + Point_2 b2 = m_traits.project(a2); + Point_2 b3 = m_traits.project(a3); - Kernel k; + const Kernel& k = m_traits; X_monotone_curve_2 A(b1, b2); X_monotone_curve_2 B(b2, b3); @@ -540,128 +475,116 @@ public: Oriented_side s2 = k.oriented_side_2_object()(l2, b1); Oriented_side s3 = k.oriented_side_2_object()(l3, b2); - CGAL_assertion(s1 != ON_ORIENTED_BOUNDARY && - s2 != ON_ORIENTED_BOUNDARY && - s3 != ON_ORIENTED_BOUNDARY); + CGAL_assertion((s1 != ON_ORIENTED_BOUNDARY) && + (s2 != ON_ORIENTED_BOUNDARY) && + (s3 != ON_ORIENTED_BOUNDARY)); *o++ = std::make_pair(A, s1); *o++ = std::make_pair(B, s2); *o++ = std::make_pair(C, s3); + return o; } - else - { - // s is a segment, and so is its projection - // s shouldn't be a z-vertical segment - const Point_3 &a1 = s.vertex(0), - a2 = s.vertex(1); - Point_2 b1 = parent->project(a1), - b2 = parent->project(a2); - CGAL_assertion(b1 != b2); + // s is a segment, and so is its projection + // s shouldn't be a z-vertical segment + const Point_3& a1 = s.vertex(0); + const Point_3& a2 = s.vertex(1); - *o++ = std::make_pair(X_monotone_curve_2(b1, b2), - ON_ORIENTED_BOUNDARY); - } + Point_2 b1 = m_traits.project(a1); + Point_2 b2 = m_traits.project(a2); + CGAL_assertion(b1 != b2); + + *o++ = std::make_pair(X_monotone_curve_2(b1, b2), ON_ORIENTED_BOUNDARY); return o; } }; - /*! Get a Construct_projected_boundary_curves_2 functor object. */ + /*! Obtain a Construct_projected_boundary_curves_2 functor object. */ Construct_projected_boundary_2 construct_projected_boundary_2_object() const - { - return Construct_projected_boundary_2(this); - } + { return Construct_projected_boundary_2(*this); } - /*!\brief - * Insert all the 2D projections (onto the xy-plane) of the - * intersection objects between s1 and s2 into the output iterator. - * - * The iterator value-type is Object. An Object may be: - * 1. A pair, where the intersection - * type is an enumeration that can take the values - * {Transversal, Tangency, Unknown}. - * 2. A Point_2 instance (in degenerate cases). + /*! compute the projection of the intersections of the \f$xy\f$-monotone + * surfaces onto the \f$xy\f$-plane, */ - class Construct_projected_intersections_2 - { + class Construct_projected_intersections_2 { protected: - const Self *parent; - public: + using Traits_3 = Env_triangle_traits_3; - Construct_projected_intersections_2(const Self* p) - : parent(p) + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Construct_projected_intersections_2(const Traits_3& traits) : + m_traits(traits) {} + friend class Env_triangle_traits_3; + + public: // insert into OutputIterator all the (2d) projections on the xy plane of // the intersection objects between the 2 surfaces // the data type of OutputIterator is Object - template + template OutputIterator operator()(const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2, - OutputIterator o) const - { + OutputIterator o) const { CGAL_assertion(s1.is_xy_monotone() && s2.is_xy_monotone()); - Kernel k; - if (!parent->do_intersect(s1, s2)) - { + if (! m_traits.do_intersect(s1, s2)) return o; + + const Kernel& k = m_traits; + std::optional> inter_obj = + m_traits.intersection(s1, s2); + if (inter_obj == std::nullopt) return o; + + if (const auto* point = std::get_if(&(*inter_obj))) { + *o++ = m_traits.project(*point); return o; } - std::optional> inter_obj - = parent->intersection(s1,s2); - if (inter_obj == std::nullopt) - { + const auto* curve = std::get_if(&(*inter_obj)); + CGAL_assertion(curve != nullptr); + + Segment_2 proj_seg = m_traits.project(*curve); + if (! k.is_degenerate_2_object() (proj_seg)) { + Intersection_curve inter_cv (proj_seg, 1); + *o++ = inter_cv; return o; } - if (const Point_3* point = std::get_if(&(*inter_obj))) - *o++ = parent->project(*point); - else - { - const Segment_3* curve = std::get_if(&(*inter_obj)); - CGAL_assertion(curve != nullptr); - - Segment_2 proj_seg = parent->project(*curve); - if (! k.is_degenerate_2_object() (proj_seg)) - { - Intersection_curve inter_cv (proj_seg, 1); - *o++ = inter_cv; - } - else - { - const Point_2& p = k.construct_point_on_2_object() (proj_seg, 0); - *o++ = p; - } - } - + const Point_2& p = k.construct_point_on_2_object() (proj_seg, 0); + *o++ = p; return o; } }; - /*! Get a Construct_projected_intersections_2 functor object. */ + /*! Obtain a Construct_projected_intersections_2 functor object. */ Construct_projected_intersections_2 construct_projected_intersections_2_object() const - { - return Construct_projected_intersections_2(this); - } + { return Construct_projected_intersections_2(*this); } - /*!\brief - * Check if the surface s1 is closer/equally distanced/farther - * from the envelope with respect to s2 at the xy-coordinates of p/c. + /*! Determine the relative \f$z\f$-order of two given \f$xy\f$-monotone + * surfaces at the \f$xy\f$-coordinates of a given point or \f$x\f$-monotone + * curve. */ - class Compare_z_at_xy_3 - { + class Compare_z_at_xy_3 { protected: - const Self *parent; + using Traits_3 = Env_triangle_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Compare_z_at_xy_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_triangle_traits_3; public: - - Compare_z_at_xy_3(const Self* p) - : parent(p) - {} - // check which of the surfaces is closer to the envelope at the xy // coordinates of point // (i.e. lower if computing the lower envelope, or upper if computing @@ -669,8 +592,7 @@ public: // precondition: the surfaces are defined in point Comparison_result operator()(const Point_2& p, const Xy_monotone_surface_3& surf1, - const Xy_monotone_surface_3& surf2) const - { + const Xy_monotone_surface_3& surf2) const { // we compute the points on the planes, and then compare their z // coordinates const Plane_3& plane1 = surf1.plane(); @@ -679,18 +601,14 @@ public: // if the 2 triangles have the same supporting plane, and they are not // vertical, then they have the same z coordinate over this point if ((plane1 == plane2 || plane1 == plane2.opposite()) && - !surf1.is_vertical()) - { + ! surf1.is_vertical()) return EQUAL; - } - - Kernel k; // Compute the intersetion between the vertical line and the given // surfaces - Point_3 ip1 = parent->envelope_point_of_surface(p, surf1); - Point_3 ip2 = parent->envelope_point_of_surface(p, surf2); - + const Kernel& k = m_traits; + Point_3 ip1 = m_traits.envelope_point_of_surface(p, surf1); + Point_3 ip2 = m_traits.envelope_point_of_surface(p, surf2); return k.compare_z_3_object()(ip1, ip2); } @@ -702,50 +620,49 @@ public: // and the answer is the same for each of these points Comparison_result operator()(const X_monotone_curve_2& cv, const Xy_monotone_surface_3& surf1, - const Xy_monotone_surface_3& surf2) const - { + const Xy_monotone_surface_3& surf2) const { // first try the endpoints, if cannot be sure, use the mid point - Comparison_result res; - res = parent->compare_z_at_xy_3_object()(cv.left(), surf1, surf2); + Comparison_result res = + m_traits.compare_z_at_xy_3_object()(cv.left(), surf1, surf2); - if (res == EQUAL) - { - res = parent->compare_z_at_xy_3_object()(cv.right(), surf1, surf2); - if (res == EQUAL) - { - Point_2 mid = parent->construct_middle_point(cv); - res = parent->compare_z_at_xy_3_object()(mid, surf1, surf2); + if (res == EQUAL) { + res = m_traits.compare_z_at_xy_3_object()(cv.right(), surf1, surf2); + if (res == EQUAL) { + Point_2 mid = m_traits.construct_middle_point(cv); + res = m_traits.compare_z_at_xy_3_object()(mid, surf1, surf2); } } return res; } - }; - /*! Get a Compare_z_at_xy_3 functor object. */ + /*! Obtain a Compare_z_at_xy_3 functor object. */ Compare_z_at_xy_3 - compare_z_at_xy_3_object() const - { - return Compare_z_at_xy_3(this); - } + compare_z_at_xy_3_object() const { return Compare_z_at_xy_3(*this); } - /*!\brief - * Check if the surface s1 is closer/equally distanced/farther - * from the envelope with - * respect to s2 immediately above the curve c. + /*! Determine the relative \f$z\f$-order of the two given \f$xy\f$-monotone + * surfaces immediately above their projected intersection curve (a planar + * point \f$p\f$ is above an \f$x\f$-monotone curve \f$c\f$ if it is in the + * \f$x\f$-range of \f$c\f$, and lies to its left when the curve is traversed + * from its \f$xy\f$-lexicographically smaller endpoint to its larger + * endpoint). */ - class Compare_z_at_xy_above_3 - { + class Compare_z_at_xy_above_3 { protected: - const Self *parent; + using Traits_3 = Env_triangle_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Compare_z_at_xy_above_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_triangle_traits_3; public: - - Compare_z_at_xy_above_3(const Self* p) - : parent(p) - {} - // check which of the surfaces is closer to the envelope on the points // above the curve cv // (i.e. lower if computing the lower envelope, or upper if computing the @@ -759,29 +676,24 @@ public: Comparison_result operator()(const X_monotone_curve_2& cv, const Xy_monotone_surface_3& surf1, - const Xy_monotone_surface_3& surf2) const - { + const Xy_monotone_surface_3& surf2) const { // a vertical surface cannot be defined in the infinitesimal region above // a curve - CGAL_precondition(!surf1.is_vertical()); - CGAL_precondition(!surf2.is_vertical()); + CGAL_precondition(! surf1.is_vertical()); + CGAL_precondition(! surf2.is_vertical()); - CGAL_precondition(parent->compare_z_at_xy_3_object() - (cv, surf1, surf2) == EQUAL); - CGAL_precondition(parent->compare_z_at_xy_3_object() - (cv.source(), surf1, surf2) == EQUAL); - CGAL_precondition(parent->compare_z_at_xy_3_object() - (cv.target(), surf1, surf2) == EQUAL); + CGAL_precondition(m_traits.compare_z_at_xy_3_object() + (cv, surf1, surf2) == EQUAL); + CGAL_precondition(m_traits.compare_z_at_xy_3_object() + (cv.source(), surf1, surf2) == EQUAL); + CGAL_precondition(m_traits.compare_z_at_xy_3_object() + (cv.target(), surf1, surf2) == EQUAL); - - if (parent->do_overlap(surf1, surf2)) - { - return EQUAL; - } + if (m_traits.do_overlap(surf1, surf2)) return EQUAL; // now we must have 2 different non-vertical planes: - // plane1: a1*x + b1*y + c1*z + d1 = 0 , c1 != 0 - // plane2: a2*x + b2*y + c2*z + d2 = 0 , c2 != 0 + // plane1: a1*x + b1*y + c1*z + d1 = 0 , c1 != 0 + // plane2: a2*x + b2*y + c2*z + d2 = 0 , c2 != 0 const Plane_3& plane1 = surf1.plane(); const Plane_3& plane2 = surf2.plane(); @@ -789,8 +701,8 @@ public: FT a1 = plane1.a(), b1 = plane1.b(), c1 = plane1.c(); FT a2 = plane2.a(), b2 = plane2.b(), c2 = plane2.c(); - // our line is a3*x + b3*y + c3 = 0 - // it is assumed that the planes intersect over this line + // our line is a3*x + b3*y + c3 = 0 + // it is assumed that the planes intersect over this line const Line_2& line = cv.line(); FT a3 = line.a(), b3 = line.b(), c3 = line.c(); @@ -838,37 +750,40 @@ public: } }; - - /*! Get a Compare_z_at_xy_above_3 functor object. */ + /*! Obtain a Compare_z_at_xy_above_3 functor object. */ Compare_z_at_xy_above_3 compare_z_at_xy_above_3_object() const - { - return Compare_z_at_xy_above_3(this); - } + { return Compare_z_at_xy_above_3(*this); } - /*!\brief - * Check if the surface s1 is closer/equally distanced/farther - * from the envelope with - * respect to s2 immediately below the curve c. + /*! Determine the relative \f$z\f$-order of the two given \f$xy\f$-monotone + * surfaces immediately below their projected intersection curve (a planar + * point \f$p\f$ is below an \f$x\f$-monotone curve \f$c\f$ if it is in the + * \f$x\f$-range of \f$c\f$, and lies to its left when the curve is traversed + * from its \f$xy\f$-lexicographically smaller endpoint to its larger + * endpoint). */ - class Compare_z_at_xy_below_3 - { + class Compare_z_at_xy_below_3 { protected: - const Self *parent; + using Traits_3 = Env_triangle_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Compare_z_at_xy_below_3(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_triangle_traits_3; public: - - Compare_z_at_xy_below_3(const Self* p) - : parent(p) - {} - + // Comparison_result operator()(const X_monotone_curve_2& cv, const Xy_monotone_surface_3& surf1, - const Xy_monotone_surface_3& surf2) const - { + const Xy_monotone_surface_3& surf2) const { Comparison_result left_res = - parent->compare_z_at_xy_above_3_object()(cv, surf1, surf2); + m_traits.compare_z_at_xy_above_3_object()(cv, surf1, surf2); return CGAL::opposite(left_res); /*if (left_res == LARGER) @@ -880,12 +795,10 @@ public: } }; - /*! Get a Compare_z_at_xy_below_3 functor object. */ + /*! Obtain a Compare_z_at_xy_below_3 functor object. */ Compare_z_at_xy_below_3 compare_z_at_xy_below_3_object() const - { - return Compare_z_at_xy_below_3(this); - } + { return Compare_z_at_xy_below_3(*this); } /***************************************************************************/ @@ -911,24 +824,33 @@ public: // public method needed for testing // checks if point is in the xy-range of surf - class Is_defined_over - { + class Is_defined_over { + protected: + using Traits_3 = Env_triangle_traits_3; + + //! The traits (in case it has state). + const Traits_3& m_traits; + + /*! Constructor + * \param traits the traits + */ + Is_defined_over(const Traits_3& traits) : m_traits(traits) {} + + friend class Env_triangle_traits_3; + public: // checks if point is in the xy-range of surf - bool operator()(const Point_2& point, - const Xy_monotone_surface_3& surf) const - - { - Kernel k; - Self parent; + bool operator()(const Point_2& point, const Xy_monotone_surface_3& surf) + const { + const Kernel& k = m_traits; // project the surface on the plane - Triangle_2 boundary = parent.project(surf); + Triangle_2 boundary = m_traits.project(surf); // if surface is not vertical (i.e. boundary is not degenerate) // check if the projected point is inside the projected boundary - if (!k.is_degenerate_2_object()(boundary)) - return (!k.has_on_unbounded_side_2_object()(boundary, point)); + if (! k.is_degenerate_2_object()(boundary)) + return (! k.has_on_unbounded_side_2_object()(boundary, point)); // if surface is vertical, we check if the point is collinear // with the projected vertices, and on one of the projected segments @@ -937,7 +859,7 @@ public: Point_2 v2 = k.construct_vertex_2_object()(boundary, 1); Point_2 v3 = k.construct_vertex_2_object()(boundary, 2); - if (!k.collinear_2_object()(v1, v2, point)) + if (! k.collinear_2_object()(v1, v2, point)) return false; // enough to check 2 edges, because the 3rd is part of their union @@ -949,67 +871,60 @@ public: /*! Get a Is_defined_over functor object. */ Is_defined_over is_defined_over_object() const - { - return Is_defined_over(); - } + { return Is_defined_over(*this); } - Segment_2 project (const Segment_3& seg) const - { - typedef typename Kernel::Construct_vertex_3 Construct_vertex_3; - - Kernel k; - Construct_vertex_3 vertex_on = k.construct_vertex_3_object(); - - const Point_3 q0 = (vertex_on (seg, 0)); - const Point_3 q1 = (vertex_on (seg, 1)); - const Point_2 p0 (q0.x(), q0.y()); - const Point_2 p1 (q1.x(), q1.y()); + // + Segment_2 project (const Segment_3& seg) const { + using Construct_vertex_3 = typename Kernel::Construct_vertex_3; + const Kernel& k = *this; + Construct_vertex_3 vertex_on = k.construct_vertex_3_object(); + const Point_3 q0 = vertex_on(seg, 0); + const Point_3 q1 = vertex_on(seg, 1); + const Point_2 p0(q0.x(), q0.y()); + const Point_2 p1(q1.x(), q1.y()); return (k.construct_segment_2_object() (p0, p1)); } + // Point_2 project(const Point_3& obj) const - { - return Point_2(obj.x(), obj.y()); - } + { return Point_2(obj.x(), obj.y()); } - Triangle_2 project(const Xy_monotone_surface_3& triangle_3) const - { - const Point_3& end1 = triangle_3.vertex(0), - end2 = triangle_3.vertex(1), - end3 = triangle_3.vertex(2); - Point_2 projected_end1(end1.x(), end1.y()), - projected_end2(end2.x(), end2.y()), - - projected_end3(end3.x(), end3.y()); + // + Triangle_2 project(const Xy_monotone_surface_3& triangle_3) const { + const Point_3& end1 = triangle_3.vertex(0); + const Point_3& end2 = triangle_3.vertex(1); + const Point_3& end3 = triangle_3.vertex(2); + Point_2 projected_end1(end1.x(), end1.y()); + Point_2 projected_end2(end2.x(), end2.y()); + Point_2 projected_end3(end3.x(), end3.y()); return Triangle_2(projected_end1, projected_end2, projected_end3); } // triangles overlap if they lie on the same plane and intersect on it. // this test is only needed for non-vertical triangles bool do_overlap(const Xy_monotone_surface_3& s1, - const Xy_monotone_surface_3& s2) const - { - CGAL_precondition(s1.is_xy_monotone() && !s1.is_vertical()); - CGAL_precondition(s2.is_xy_monotone() && !s2.is_vertical()); + const Xy_monotone_surface_3& s2) const { + CGAL_precondition(s1.is_xy_monotone() && ! s1.is_vertical()); + CGAL_precondition(s2.is_xy_monotone() && ! s2.is_vertical()); - Kernel k; - if (!k.do_intersect_3_object()(static_cast(s1), - static_cast(s2))) + const Kernel& k = *this; + auto do_x = k.do_intersect_3_object(); + if (! do_x(static_cast(s1), static_cast(s2))) return false; // check if they are coplanar - Point_3 a1 = s1.vertex(0), - b1 = s1.vertex(1), - c1 = s1.vertex(2); - Point_3 a2 = s2.vertex(0), - b2 = s2.vertex(1), - c2 = s2.vertex(2); + Point_3 a1 = s1.vertex(0); + Point_3 b1 = s1.vertex(1); + Point_3 c1 = s1.vertex(2); + Point_3 a2 = s2.vertex(0); + Point_3 b2 = s2.vertex(1); + Point_3 c2 = s2.vertex(2); bool b = k.coplanar_3_object()(a1, b1, c1, a2); - if (!b) return false; + if (! b) return false; b = k.coplanar_3_object()(a1, b1, c1, b2); - if (!b) return false; + if (! b) return false; b = k.coplanar_3_object()(a1, b1, c1, c2); return b; @@ -1018,75 +933,61 @@ public: // check whether two xy-monotone surfaces (3D-triangles or segments) // intersect bool do_intersect(const Xy_monotone_surface_3& s1, - const Xy_monotone_surface_3& s2) const - { + const Xy_monotone_surface_3& s2) const { CGAL_precondition(s1.is_xy_monotone()); CGAL_precondition(s2.is_xy_monotone()); - Kernel k; - if (!s1.is_segment() && !s2.is_segment()) - return k.do_intersect_3_object()(static_cast(s1), - static_cast(s2)); - else if (!s1.is_segment()) - return k.do_intersect_3_object()(static_cast(s1), - static_cast(s2)); - else if (!s2.is_segment()) - return k.do_intersect_3_object()(static_cast(s1), - static_cast(s2)); - else - // in case of two segments, we don't use easy do-intersect test - return true; + + const Kernel& k = *this; + auto do_x = k.do_intersect_3_object(); + if (! s1.is_segment() && ! s2.is_segment()) + return do_x(static_cast(s1), static_cast(s2)); + else if (! s1.is_segment()) + return do_x(static_cast(s1), static_cast(s2)); + else if (! s2.is_segment()) + return do_x(static_cast(s1), static_cast(s2)); + else return true; // if two segments, we don't use easy do-intersect test } // intersect two xy-monotone surfaces (3D-triangles or segments) // if the triangles overlap, the result is empty // the result can be a segment or a point - std::optional< std::variant> - intersection(const Xy_monotone_surface_3& s1, - const Xy_monotone_surface_3& s2) const - { + std::optional> + intersection(const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2) + const { CGAL_precondition(s1.is_xy_monotone()); CGAL_precondition(s2.is_xy_monotone()); Kernel k; // first, try to intersect the bounding boxes of the triangles, // efficiently return empty object when the triangles are faraway - if (!CGAL::do_overlap(s1.bbox(), s2.bbox())) - return std::nullopt; + if (! CGAL::do_overlap(s1.bbox(), s2.bbox())) return std::nullopt; // if intersecting two segment - alculate the intersection // as in the case of dimension 2 if (s1.is_segment() && s2.is_segment()) - { return intersection_of_segments(s1, s2); - } // if both triangles lie on the same (non-vertical) plane, they overlap // we don't care about overlaps, because they are not passed to the // algorithm anyway, so we save the costly computation Plane_3 p1 = s1.plane(); Plane_3 p2 = s2.plane(); - if (p1 == p2 || p1 == p2.opposite()) - return std::nullopt; + if ((p1 == p2) || (p1 == p2.opposite())) return std::nullopt; // calculate intersection between a triangle and the other triangle's // supporting plane // if there is no intersection - then the triangles have no intersection // between them. auto inter_obj = intersection(p1, s2); - - if (inter_obj == std::nullopt) - return std::nullopt; + if (inter_obj == std::nullopt) return std::nullopt; // otherwise, if the intersection in a point, we should check if it lies // inside the first triangle - if (const Point_3* inter_point = std::get_if(&(*inter_obj))) - { + if (const Point_3* inter_point = std::get_if(&(*inter_obj))) { std::optional res = intersection_on_plane_3(p1, s1, *inter_point); - if (res != std::nullopt) - return res.value(); + if (res != std::nullopt) return res.value(); } - else - { + else { // if the intersection is a segment, we check the intersection of the // other plane-triangle pair const Segment_3* inter_seg = std::get_if(&(*inter_obj)); @@ -1096,51 +997,40 @@ public: // if there is no intersection - then the triangles have no intersection // between them. - if (inter_obj2 == std::nullopt) - return std::nullopt; + if (inter_obj2 == std::nullopt) return std::nullopt; - if (const Point_3* inter_point = std::get_if(&(*inter_obj2))) - { + if (const Point_3* inter_point = std::get_if(&(*inter_obj2))) { // if the intersection is a point, which lies on the segment, // than it is the result, // otherwise, empty result - if (k.has_on_3_object()(*inter_seg, *inter_point)) - return *inter_point; - else - return std::nullopt; + if (k.has_on_3_object()(*inter_seg, *inter_point)) return *inter_point; + else return std::nullopt; } - else - { + else { // both plane-triangle intersections are segments, which are collinear, // and lie on the line which is the intersection of the two supporting // planes const Segment_3* inter_seg2 = std::get_if(&(*inter_obj)); CGAL_assertion(inter_seg2 != nullptr); - Point_3 min1 = k.construct_min_vertex_3_object()(*inter_seg), - max1 = k.construct_max_vertex_3_object()(*inter_seg); - Point_3 min2 = k.construct_min_vertex_3_object()(*inter_seg2), - max2 = k.construct_max_vertex_3_object()(*inter_seg2); + Point_3 min1 = k.construct_min_vertex_3_object()(*inter_seg); + Point_3 max1 = k.construct_max_vertex_3_object()(*inter_seg); + Point_3 min2 = k.construct_min_vertex_3_object()(*inter_seg2); + Point_3 max2 = k.construct_max_vertex_3_object()(*inter_seg2); CGAL_assertion((k.collinear_3_object()(min1, min2, max1) && k.collinear_3_object()(min1, max2, max1))); // we need to find the overlapping part, if exists Point_3 min, max; - if (k.less_xyz_3_object()(min1, min2)) - min = min2; - else - min = min1; - if (k.less_xyz_3_object()(max1, max2)) - max = max1; - else - max = max2; + if (k.less_xyz_3_object()(min1, min2)) min = min2; + else min = min1; + if (k.less_xyz_3_object()(max1, max2)) max = max1; + else max = max2; Comparison_result comp_res = k.compare_xyz_3_object()(min, max); - if (comp_res == EQUAL) - return min; - else if (comp_res == SMALLER) - return Segment_3(min, max); + if (comp_res == EQUAL) return min; + else if (comp_res == SMALLER) return Segment_3(min, max); // else - empty result } } @@ -1151,14 +1041,13 @@ public: std::optional intersection_on_plane_3(const Plane_3& plane, const Xy_monotone_surface_3& triangle, - const Point_3& point) const - { - Kernel k; - CGAL_precondition( triangle.is_xy_monotone() ); - CGAL_precondition( !k.is_degenerate_3_object()(plane) ); - CGAL_precondition( triangle.plane() == plane || - triangle.plane() == plane.opposite()); - CGAL_precondition( k.has_on_3_object()(plane, point) ); + const Point_3& point) const { + const Kernel& k = *this; + CGAL_precondition(triangle.is_xy_monotone() ); + CGAL_precondition(! k.is_degenerate_3_object()(plane) ); + CGAL_precondition((triangle.plane() == plane) || + (triangle.plane() == plane.opposite())); + CGAL_precondition(k.has_on_3_object()(plane, point) ); CGAL_USE(plane); // if the point is inside the triangle, then the point is the intersection @@ -1168,63 +1057,55 @@ public: has_on = k.has_on_3_object()(static_cast(triangle), point); else has_on = k.has_on_3_object()(static_cast(triangle), point); - if (has_on) - return point; - else - return std::nullopt; + if (has_on) return point; + else return std::nullopt; } // calculate intersection between 2 segments on the same vertical plane plane - std::optional< std::variant> + std::optional> intersection_of_segments(const Xy_monotone_surface_3& s1, - const Xy_monotone_surface_3& s2) const - { - Kernel k; - CGAL_precondition( s1.is_xy_monotone() && s1.is_segment()); - CGAL_precondition( s2.is_xy_monotone() && s2.is_segment()); + const Xy_monotone_surface_3& s2) const { + const Kernel& k = *this; + CGAL_precondition(s1.is_xy_monotone() && s1.is_segment()); + CGAL_precondition(s2.is_xy_monotone() && s2.is_segment()); // if the segments are not coplanar, they cannot intersect - if (!k.coplanar_3_object()(s1.vertex(0), s1.vertex(1), - s2.vertex(0), s2.vertex(1))) + if (! k.coplanar_3_object()(s1.vertex(0), s1.vertex(1), + s2.vertex(0), s2.vertex(1))) return std::nullopt; const Plane_3& plane = s1.plane(); - if (s2.plane() != plane && - s2.plane() != plane.opposite()) + if (s2.plane() != plane && s2.plane() != plane.opposite()) // todo: this case is not needed in the algorithm, // so we don't implement it return std::nullopt; - CGAL_precondition( !k.is_degenerate_3_object()(plane) ); - CGAL_precondition( s2.plane() == plane || - s2.plane() == plane.opposite()); + CGAL_precondition(! k.is_degenerate_3_object()(plane) ); + CGAL_precondition((s2.plane() == plane) || + (s2.plane() == plane.opposite())); // for simplicity, we transform the segments to the xy-plane, // compute the intersection there, and transform it back to the 3d plane. - Point_2 v1 = plane.to_2d(s1.vertex(0)), - v2 = plane.to_2d(s1.vertex(1)); + Point_2 v1 = plane.to_2d(s1.vertex(0)); + Point_2 v2 = plane.to_2d(s1.vertex(1)); Segment_2 seg1_t(v1, v2); - Point_2 u1 = plane.to_2d(s2.vertex(0)), - u2 = plane.to_2d(s2.vertex(1)); + Point_2 u1 = plane.to_2d(s2.vertex(0)); + Point_2 u2 = plane.to_2d(s2.vertex(1)); Segment_2 seg2_t(u1, u2); auto inter_obj = k.intersect_2_object()(seg1_t, seg2_t); - if (inter_obj == std::nullopt) - return std::nullopt; + if (inter_obj == std::nullopt) return std::nullopt; if (const Point_2* inter_point = std::get_if(&(*inter_obj))) return plane.to_3d(*inter_point); - else - { - const Segment_2* inter_segment = std::get_if(&(*inter_obj)); - CGAL_assertion(inter_segment!=nullptr); - return Segment_3 - (plane.to_3d(k.construct_vertex_2_object()(*inter_segment, 0)), - plane.to_3d(k.construct_vertex_2_object()(*inter_segment, 1))); - } + const Segment_2* inter_segment = std::get_if(&(*inter_obj)); + CGAL_assertion(inter_segment != nullptr); + auto ctr_vertex = k.construct_vertex_2_object(); + return Segment_3(plane.to_3d(ctr_vertex(*inter_segment, 0)), + plane.to_3d(ctr_vertex(*inter_segment, 1))); } // calculate the intersection between a triangle/segment @@ -1232,12 +1113,10 @@ public: // the result object can be empty, a point, a segment or the original // triangle std::optional> - intersection(const Plane_3& pl, - const Xy_monotone_surface_3& tri) const - { - Kernel k; - CGAL_precondition( tri.is_xy_monotone() ); - CGAL_precondition( !k.is_degenerate_3_object()(pl) ); + intersection(const Plane_3& pl, const Xy_monotone_surface_3& tri) const { + const Kernel& k = *this; + CGAL_precondition(tri.is_xy_monotone() ); + CGAL_precondition(! k.is_degenerate_3_object()(pl) ); if (tri.is_segment()) return k.intersect_3_object()(pl, static_cast(tri)); @@ -1255,8 +1134,7 @@ public: int n_points_on_negative = 0; Oriented_side side; - for (int i=0; i<3; ++i) - { + for (int i = 0; i < 3; ++i) { side = pl.oriented_side(tri.vertex(i)); if (side == ON_NEGATIVE_SIDE) points_on_negative[n_points_on_negative++] = i; @@ -1266,28 +1144,25 @@ public: points_on_plane[n_points_on_plane++] = i; } - CGAL_assertion(n_points_on_plane + n_points_on_positive + n_points_on_negative == 3); + CGAL_assertion(n_points_on_plane + n_points_on_positive + + n_points_on_negative == 3); // if all vertices of tri lie on the same size (positive/negative) of pl, // there is no intersection - if (n_points_on_positive == 3 || n_points_on_negative == 3) + if ((n_points_on_positive == 3) || (n_points_on_negative == 3)) return std::nullopt; // if all vertices of tri lie on pl then we return tri - if (n_points_on_plane == 3) - return tri; + if (n_points_on_plane == 3) return tri; // if 2 vertices lie on pl, then return the segment between them - if (n_points_on_plane == 2) - { + if (n_points_on_plane == 2) { int point_idx1 = points_on_plane[0], point_idx2 = points_on_plane[1]; - return Segment_3(tri.vertex(point_idx1), - tri.vertex(point_idx2)); + return Segment_3(tri.vertex(point_idx1), tri.vertex(point_idx2)); } // if only 1 lie on pl, should check the segment opposite to it on tri - if (n_points_on_plane == 1) - { + if (n_points_on_plane == 1) { int point_on_plane_idx = points_on_plane[0]; // if the other 2 vertices are on the same side of pl, @@ -1308,23 +1183,20 @@ public: // create the resulting segment // (between tri[point_on_plane_idx] and inter_point) - return Segment_3(tri.vertex(point_on_plane_idx), - *inter_point); - + return Segment_3(tri.vertex(point_on_plane_idx), *inter_point); } - CGAL_assertion( n_points_on_plane == 0 ); - CGAL_assertion( n_points_on_positive + n_points_on_negative == 3 ); - CGAL_assertion( n_points_on_positive != 0 ); - CGAL_assertion( n_points_on_negative != 0 ); + CGAL_assertion(n_points_on_plane == 0); + CGAL_assertion(n_points_on_positive + n_points_on_negative == 3); + CGAL_assertion(n_points_on_positive != 0); + CGAL_assertion(n_points_on_negative != 0); // now it known that there is an intersection between 2 segments of tri // and pl, it is also known which segments are those. Point_3 inter_points[2]; - int pos_it, neg_it, n_inter_points = 0; - for(pos_it = 0; pos_it < n_points_on_positive; ++pos_it) - for(neg_it = 0; neg_it < n_points_on_negative; ++neg_it) - { + int n_inter_points = 0; + for (int pos_it = 0; pos_it < n_points_on_positive; ++pos_it) + for (int neg_it = 0; neg_it < n_points_on_negative; ++neg_it) { Segment_3 seg(tri.vertex(points_on_positive[pos_it]), tri.vertex(points_on_negative[neg_it])); auto inter_result = k.intersect_3_object()(pl, seg); @@ -1339,11 +1211,8 @@ public: // compare the value of s1 in p1 to the value of s2 in p2 Comparison_result - compare_z(const Point_2& p1, - const Xy_monotone_surface_3& s1, - const Point_2& p2, - const Xy_monotone_surface_3& s2) - { + compare_z(const Point_2& p1, const Xy_monotone_surface_3& s1, + const Point_2& p2, const Xy_monotone_surface_3& s2) { CGAL_precondition(is_defined_over_object()(p1, s1)); CGAL_precondition(is_defined_over_object()(p2, s2)); @@ -1356,21 +1225,18 @@ public: // find the envelope point of the surface over the given point // precondition: the surface is defined in point Point_3 - envelope_point_of_surface(const Point_2& p, - const Xy_monotone_surface_3& s) const - { + envelope_point_of_surface(const Point_2& p, const Xy_monotone_surface_3& s) + const { CGAL_precondition(s.is_xy_monotone()); CGAL_precondition(is_defined_over_object()(p, s)); Point_3 point(p.x(), p.y(), 0); // Compute the intersetion between the vertical line and the given surfaces - if (s.is_segment()) - return envelope_point_of_segment(point, s); - else - { + if (s.is_segment()) return envelope_point_of_segment(point, s); + else { // s is a non-vertical triangle - CGAL_assertion(!s.is_vertical()); + CGAL_assertion(! s.is_vertical()); // Construct a vertical line passing through point Kernel k; @@ -1390,8 +1256,7 @@ public: // find the envelope point of the surface over the given point // precondition: the surface is defined in point and is a segment Point_3 envelope_point_of_segment(const Point_3& point, - const Xy_monotone_surface_3& s) const - { + const Xy_monotone_surface_3& s) const { Kernel k; CGAL_precondition(s.is_segment()); CGAL_precondition(is_defined_over_object()(project(point), s)); @@ -1401,11 +1266,11 @@ public: // Construct a vertical line passing through point Direction_3 dir (0, 0, 1); - Line_3 vl = k.construct_line_3_object() (point, dir); + Line_3 vl = k.construct_line_3_object() (point, dir); // we need 2 points on this line, to be transformed to 2d, // and preserve the direction of the envelope - Point_3 vl_point1 = k.construct_point_on_3_object()(vl, 0), - vl_point2 = k.construct_point_on_3_object()(vl, 1); + Point_3 vl_point1 = k.construct_point_on_3_object()(vl, 0); + Point_3 vl_point2 = k.construct_point_on_3_object()(vl, 1); // the surface and the line are on the same plane(plane), // so we transform them to the xy-plane, compute the intersecting point @@ -1427,14 +1292,12 @@ public: return plane.to_3d(*inter_point); } - Point_2 construct_middle_point(const Point_2& p1, const Point_2& p2) const - { + Point_2 construct_middle_point(const Point_2& p1, const Point_2& p2) const { Kernel k; return k.construct_midpoint_2_object()(p1, p2); } - Point_2 construct_middle_point(const X_monotone_curve_2& cv) const - { + Point_2 construct_middle_point(const X_monotone_curve_2& cv) const { Kernel k; return k.construct_midpoint_2_object()(cv.source(), cv.target()); } @@ -1443,196 +1306,147 @@ public: // for vertical decomposition /***************************************************************************/ - class Construct_vertical_2 - { + class Construct_vertical_2 { public: X_monotone_curve_2 operator()(const Point_2& p1, const Point_2& p2) const - { - return X_monotone_curve_2(p1, p2); - - } + { return X_monotone_curve_2(p1, p2); } }; /*! Get a Construct_vertical_2 functor object. */ Construct_vertical_2 construct_vertical_2_object() const - { - return Construct_vertical_2(); - } + { return Construct_vertical_2(); } - - Point_2 vertical_ray_shoot_2 (const Point_2& pt, - const X_monotone_curve_2& cv) const - { - CGAL_precondition(!cv.is_vertical()); + Point_2 vertical_ray_shoot_2(const Point_2& pt, const X_monotone_curve_2& cv) + const { + CGAL_precondition(! cv.is_vertical()); typename Kernel::Segment_2 seg = cv; - Kernel k; + const Kernel& k = *this; // If the curve contains pt, return it. - if (k.has_on_2_object() (seg, pt)) - return (pt); + if (k.has_on_2_object()(seg, pt)) return (pt); // Construct a vertical line passing through pt. - typename Kernel::Direction_2 dir (0, 1); - typename Kernel::Line_2 vl = k.construct_line_2_object() (pt, dir); + typename Kernel::Direction_2 dir(0, 1); + typename Kernel::Line_2 vl = k.construct_line_2_object()(pt, dir); // Compute the intersetion between the vertical line and the given curve. auto res = k.intersect_2_object()(seg, vl); const Point_2* ip = std::get_if(&(*res)); - CGAL_assertion (ip != nullptr); + CGAL_assertion(ip != nullptr); return *ip; } }; - -/*! - * \class A representation of a triangle, as used by the +/*! \class A representation of a triangle, as used by the * Env_triangle_traits_3 traits-class. */ -template -class Env_triangle_3 : - public Env_triangle_traits_3::_Triangle_cached_3 +template +class Env_triangle_3 : public Env_triangle_traits_3::_Triangle_cached_3 { - typedef Kernel_ Kernel; - typedef typename Kernel::Triangle_3 Triangle_3; - typedef typename Kernel::Point_3 Point_3; - typedef typename Kernel::Plane_3 Plane_3; - typedef typename Kernel::Segment_3 Segment_3; + using Kernel = Kernel_; + using Triangle_3 = typename Kernel::Triangle_3; + using Point_3 = typename Kernel::Point_3; + using Plane_3 = typename Kernel::Plane_3; + using Segment_3 = typename Kernel::Segment_3; - typedef typename Env_triangle_traits_3::_Triangle_cached_3 - Base; + using Base = typename Env_triangle_traits_3::_Triangle_cached_3; public: - - /*! - * Default constructor. + /*! Default constructor. */ - Env_triangle_3() : - Base() - {} + Env_triangle_3() : Base() {} - /*! - * Constructor from a "kernel" triangle. + /*! Constructor from a "kernel" triangle. * \param seg The segment. */ - Env_triangle_3(const Triangle_3& tri) : - Base(tri) - {} + Env_triangle_3(const Triangle_3& tri) : Base(tri) {} - /*! - * Construct a triangle from 3 end-points. + /*! Construct a triangle from 3 end-points. * \param p1 The first point. * \param p2 The second point. * \param p3 The third point. */ - Env_triangle_3(const Point_3 &p1, const Point_3 &p2, const Point_3 &p3) : - Base(p1, p2, p3) + Env_triangle_3(const Point_3& p1, const Point_3& p2, const Point_3& p3) : + Base(p1, p2, p3) {} - /*! - * Construct a triangle from a plane and 3 end-points. + /*! Construct a triangle from a plane and 3 end-points. * \param pl The supporting plane. * \param p1 The first point. * \param p2 The second point. * \param p3 The third point. * \pre All points must be on the supporting plane. */ - Env_triangle_3(const Plane_3& pl, - const Point_3 &p1, - const Point_3 &p2, - const Point_3 &p3) : + Env_triangle_3(const Plane_3& pl, const Point_3& p1, + const Point_3& p2, const Point_3& p3) : Base(pl, p1, p2, p3) - {} - /*! - * Construct a segment from 2 end-points. + /*! Construct a segment from 2 end-points. * \param p1 The first point. * \param p2 The second point. */ - Env_triangle_3(const Point_3 &p1, const Point_3 &p2) : - Base(p1, p2) - {} + Env_triangle_3(const Point_3& p1, const Point_3& p2) : Base(p1, p2) {} - /*! - * Cast to a triangle. + /*! Cast to a triangle. */ operator Triangle_3() const - { - return (Triangle_3(this->vertex(0), this->vertex(1), this->vertex(2))); - } + { return (Triangle_3(this->vertex(0), this->vertex(1), this->vertex(2))); } - /*! - * Cast to a segment (only when possible). + /*! Cast to a segment (only when possible). */ - operator Segment_3() const - { + operator Segment_3() const { CGAL_precondition(this->is_segment()); return (Segment_3(this->vertex(0), this->vertex(1))); } - /*! - * Create a bounding box for the triangle. + /*! Create a bounding box for the triangle. */ - Bbox_3 bbox() const - { + Bbox_3 bbox() const { Triangle_3 tri(this->vertex(0), this->vertex(1), this->vertex(2)); return (tri.bbox()); } }; -template -bool -operator<(const Env_triangle_3 &a, - const Env_triangle_3 &b) -{ - if (a.vertex(0) < b.vertex(0)) - return true; - if (a.vertex(0) > b.vertex(0)) - return false; - if (a.vertex(1) < b.vertex(1)) - return true; - if (a.vertex(1) > b.vertex(1)) - return false; - if (a.vertex(2) < b.vertex(2)) - return true; - if (a.vertex(2) > b.vertex(2)) - return false; +template +bool operator<(const Env_triangle_3& a, + const Env_triangle_3& b) { + if (a.vertex(0) < b.vertex(0)) return true; + if (a.vertex(0) > b.vertex(0)) return false; + if (a.vertex(1) < b.vertex(1)) return true; + if (a.vertex(1) > b.vertex(1)) return false; + if (a.vertex(2) < b.vertex(2)) return true; + if (a.vertex(2) > b.vertex(2)) return false; return false; } -template -bool -operator==(const Env_triangle_3 &a, - const Env_triangle_3 &b) -{ - return (a.vertex(0) == b.vertex(0) && - a.vertex(1) == b.vertex(1) && - a.vertex(2) == b.vertex(2)); + +template +bool operator==(const Env_triangle_3& a, + const Env_triangle_3& b) { + return ((a.vertex(0) == b.vertex(0)) && + (a.vertex(1) == b.vertex(1)) && + (a.vertex(2) == b.vertex(2))); } -/*! - * Exporter for the triangle class used by the traits-class. +/*! Exporter for the triangle class used by the traits-class. */ -template -OutputStream& operator<< (OutputStream& os, const Env_triangle_3& tri) -{ - os << static_cast(tri); - if (tri.is_segment()) - os << " (segment)"; - return (os); +template +OutputStream& operator<<(OutputStream& os, const Env_triangle_3& tri) { + os << static_cast(tri); + if (tri.is_segment()) os << " (segment)"; + return os; } -/*! - * Importer for the triangle class used by the traits-class. +/*! Importer for the triangle class used by the traits-class. */ -template -InputStream& operator>> (InputStream& is, Env_triangle_3& tri) -{ - typename Kernel::Triangle_3 kernel_tri; +template +InputStream& operator>>(InputStream& is, Env_triangle_3& tri) { + typename Kernel_::Triangle_3 kernel_tri; is >> kernel_tri; tri = kernel_tri; - return (is); + return is; } } //namespace CGAL diff --git a/Envelope_3/include/CGAL/Envelope_3/Envelope_diagram_on_surface_2.h b/Envelope_3/include/CGAL/Envelope_3/Envelope_diagram_on_surface_2.h index b9f922ef699..b21fa6b9a6b 100644 --- a/Envelope_3/include/CGAL/Envelope_3/Envelope_diagram_on_surface_2.h +++ b/Envelope_3/include/CGAL/Envelope_3/Envelope_diagram_on_surface_2.h @@ -7,10 +7,10 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman -// Ophir Setter -// Efi Fogel +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Ophir Setter +// Efi Fogel #ifndef CGAL_ENVELOPE_DIAGRAM_ON_SURFACE_2_H #define CGAL_ENVELOPE_DIAGRAM_ON_SURFACE_2_H @@ -21,9 +21,7 @@ #include #include #include - #include - #include namespace CGAL { @@ -32,114 +30,93 @@ namespace CGAL { * Representation of an envelope diagram (a minimization diagram or a * maximization diagram). */ -template >::Traits - > +template >::Traits> class Envelope_diagram_on_surface_2 : -public Arrangement_on_surface_2 -{ + public Arrangement_on_surface_2 { public: - typedef GeomTraits_ Traits_3; - typedef TopTraits_ TopTraits; - typedef typename Traits_3::Xy_monotone_surface_3 Xy_monotone_surface_3; + using Traits_3 = GeomTraits_; + using TopTraits = TopTraits_; + using Xy_monotone_surface_3 = typename Traits_3::Xy_monotone_surface_3; protected: - typedef Envelope_3::Envelope_pm_dcel Env_dcel; - typedef Envelope_diagram_on_surface_2 Self; + using Self = Envelope_diagram_on_surface_2; + friend class Arr_accessor; public: - typedef Arrangement_on_surface_2 Base; - // This is yacky, but we have not choice because of observer stuff. - typedef Base Arrangement; + using Base = Arrangement_on_surface_2; - typedef typename Env_dcel::Dcel_data_const_iterator Surface_const_iterator; + // The following is not needed anymore, but kept for backward compatibility + using Arrangement = Base; + + using Face = typename Base::Face; + using Surface_iterator = typename Face::Data_iterator; + using Surface_const_iterator = typename Face::Data_const_iterator; /*! Default constructor. */ - Envelope_diagram_on_surface_2() : - Base() - {} + Envelope_diagram_on_surface_2() : Base() {} /*! Constructor with a traits-class instance. */ - Envelope_diagram_on_surface_2 (Traits_3* tr) : - Base (tr) - {} - + Envelope_diagram_on_surface_2(const Traits_3* tr) : Base(tr) {} }; - /*! \class * Representation of an envelope diagram (a minimization diagram or a * maximization diagram). */ - -template - > +template > class Envelope_diagram_2 : - public Envelope_diagram_on_surface_2< GeomTraits_, - typename Default_planar_topology::Traits - > + public Envelope_diagram_on_surface_2::Traits> { public: - typedef GeomTraits_ Traits_3; - typedef typename Traits_3::Xy_monotone_surface_3 Xy_monotone_surface_3; + using Traits_3 = GeomTraits; + using Xy_monotone_surface_3 = typename Traits_3::Xy_monotone_surface_3; protected: - typedef Dcel_ Env_dcel; - typedef Envelope_diagram_2 Self; + using Env_dcel = Dcel_; + using Self = Envelope_diagram_2; + friend class Arr_accessor; public: - typedef typename Default_planar_topology< Traits_3, - Env_dcel >::Traits Topology_traits; - typedef Envelope_diagram_on_surface_2 - Base; - typedef typename Env_dcel::Dcel_data_const_iterator Surface_const_iterator; - - // This is yacky, but we have not choice because of observer stuff. - typedef typename Base::Base Arrangement; + using Topology_traits = + typename Default_planar_topology< Traits_3, Env_dcel>::Traits; + using Base = Envelope_diagram_on_surface_2; + using Surface_iterator = typename Base::Surface_iterator; + using Surface_const_iterator = typename Base::Surface_const_iterator; + // The following is not needed anymore, but kept for backward compatibility + using Arrangement = typename Base::Base; /*! Default constructor. */ - Envelope_diagram_2() : - Base() - {} + Envelope_diagram_2() : Base() {} /*! Constructor with a traits-class instance. */ - Envelope_diagram_2 (Traits_3* tr) : - Base (tr) - {} - + Envelope_diagram_2(const Traits_3* tr) : Base(tr) {} }; - //-------------------------------- Envelope_on_surface_3 // specialization -template -class is_arrangement_2< - Envelope_diagram_on_surface_2 -> : public std::true_type +template +class is_arrangement_2> : + public std::true_type {}; // specialization -template -class is_arrangement_2< - Envelope_diagram_2 -> : public std::true_type +template +class is_arrangement_2> : + public std::true_type {}; - // /*! \class // * Representation of an envelope diagram (a minimization diagram or a // * maximization diagram). @@ -185,7 +162,6 @@ class is_arrangement_2< // }; - } //namespace CGAL #endif diff --git a/Envelope_3/include/CGAL/Envelope_3/Envelope_divide_and_conquer_3.h b/Envelope_3/include/CGAL/Envelope_3/Envelope_divide_and_conquer_3.h index 9b3136be2b4..42aa64669a1 100644 --- a/Envelope_3/include/CGAL/Envelope_3/Envelope_divide_and_conquer_3.h +++ b/Envelope_3/include/CGAL/Envelope_3/Envelope_divide_and_conquer_3.h @@ -7,9 +7,9 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman -// Efi Fogel +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Efi Fogel #ifndef CGAL_ENVELOPE_DIVIDE_AND_CONQUER_3_H #define CGAL_ENVELOPE_DIVIDE_AND_CONQUER_3_H @@ -28,16 +28,16 @@ #include #include -#include #include #include #include #include #ifdef CGAL_ENVELOPE_USE_BFS_FACE_ORDER +#include + #include #include -#include #endif // this base divide & conquer algorithm splits the input into 2 groups, @@ -83,125 +83,95 @@ namespace CGAL { // of the arrangement // 4. Overlay_2 - overlay of 2 MinimizationDiagram_2 -template , - class Overlay_2 = Envelope_overlay_2 > -class Envelope_divide_and_conquer_3 -{ + typename Overlay_2 = Envelope_overlay_2 > +class Envelope_divide_and_conquer_3 { public: - typedef EnvelopeTraits_3 Traits; - typedef typename Traits::Surface_3 Surface_3; - typedef typename Traits::Xy_monotone_surface_3 Xy_monotone_surface_3; + using Traits = EnvelopeTraits_3; + using Surface_3 = typename Traits::Surface_3; + using Xy_monotone_surface_3 = typename Traits::Xy_monotone_surface_3; - typedef MinimizationDiagram_2 Minimization_diagram_2; + using Minimization_diagram_2 = MinimizationDiagram_2; - typedef typename Traits::Point_2 Point_2; - typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits::Curve_2 Curve_2; + using Point_2 = typename Traits::Point_2; + using X_monotone_curve_2 = typename Traits::X_monotone_curve_2; + using Curve_2 = typename Traits::Curve_2; - typedef EnvelopeResolver_3 Envelope_resolver; + using Envelope_resolver = EnvelopeResolver_3; - typedef Envelope_divide_and_conquer_3 Self; + using Self = Envelope_divide_and_conquer_3; protected: + using Vertex_handle = typename Minimization_diagram_2::Vertex_handle; + using Halfedge_handle = typename Minimization_diagram_2::Halfedge_handle; + using Face_handle = typename Minimization_diagram_2::Face_handle; + using Ccb_halfedge_circulator = + typename Minimization_diagram_2::Ccb_halfedge_circulator; + using Halfedge_around_vertex_circulator = + typename Minimization_diagram_2::Halfedge_around_vertex_circulator; - typedef typename Minimization_diagram_2::Halfedge_const_iterator - Halfedge_const_iterator; - typedef typename Minimization_diagram_2::Halfedge_handle - Halfedge_handle; - typedef typename Minimization_diagram_2::Halfedge_iterator - Halfedge_iterator; - typedef typename Minimization_diagram_2::Face_handle - Face_handle; - typedef typename Minimization_diagram_2::Edge_iterator - Edge_iterator; - typedef typename Minimization_diagram_2::Face_iterator - Face_iterator; - typedef typename Minimization_diagram_2::Vertex_handle - Vertex_handle; - typedef typename Minimization_diagram_2::Vertex_iterator - Vertex_iterator; - typedef typename Minimization_diagram_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; - typedef typename Minimization_diagram_2::Halfedge_around_vertex_circulator - Halfedge_around_vertex_circulator; - typedef typename Minimization_diagram_2::Outer_ccb_iterator - Outer_ccb_iterator; - typedef typename Minimization_diagram_2::Inner_ccb_iterator - Inner_ccb_iterator; - - typedef Arr_observer Md_observer; - typedef typename Minimization_diagram_2::Dcel::Dcel_data_iterator - Envelope_data_iterator; + using Md_observer = typename Minimization_diagram_2::Observer; + using Face = typename Minimization_diagram_2::Face; + using Envelope_data_iterator = typename Face::Data_iterator; #ifdef CGAL_ENVELOPE_USE_BFS_FACE_ORDER - typedef CGAL::Dual - Dual_Minimization_diagram_2; + using Dual_Minimization_diagram_2 = CGAL::Dual; #endif public: // c'tor - Envelope_divide_and_conquer_3(Envelope_type type = ENVELOPE_LOWER) - { + Envelope_divide_and_conquer_3(Envelope_type type = ENVELOPE_LOWER) { // Allocate the traits. m_geom_traits = new Traits; m_own_traits = true; // Allocate the Envelope resolver with our traits - resolver = new Envelope_resolver(m_geom_traits, type); + m_resolver = new Envelope_resolver(m_geom_traits, type); m_is_lower = ((type == ENVELOPE_LOWER) ? true : false); } Envelope_divide_and_conquer_3(const Traits* geom_traits, - Envelope_type type = ENVELOPE_LOWER) - { + Envelope_type type = ENVELOPE_LOWER) { // Set the traits. m_geom_traits = geom_traits; m_own_traits = false; // Allocate the Envelope resolver with our traits - resolver = new Envelope_resolver(m_geom_traits, type); + m_resolver = new Envelope_resolver(m_geom_traits, type); m_is_lower = ((type == ENVELOPE_LOWER) ? true : false); } // virtual destructor. - virtual ~Envelope_divide_and_conquer_3() - { + virtual ~Envelope_divide_and_conquer_3() { // Free the traits object, if necessary. - if (m_own_traits) - delete m_geom_traits; + if (m_own_traits) delete m_geom_traits; // Free the resolver - delete resolver; + delete m_resolver; } // compute the envelope of surfaces in 3D, using the default arbitrary // divider - template + template void construct_lu_envelope(SurfaceIterator begin, SurfaceIterator end, - Minimization_diagram_2& result) - { + Minimization_diagram_2& result) { Envelope_3::Arbitrary_dividor dividor; construct_lu_envelope(begin, end, result, dividor); } // compute the envelope of surfaces in 3D using the given set divider - template + template void construct_lu_envelope(SurfaceIterator begin, SurfaceIterator end, Minimization_diagram_2& result, - SetDividor& dividor) - { - if (begin == end) - { - return; // result is empty - } + SetDividor& dividor) { + if (begin == end) return; // result is empty // make the general surfaces xy-monotone std::list xy_monotones; @@ -219,25 +189,22 @@ public: // compute the envelope of xy-monotone surfaces in 3D, // using the default arbitrary divider - template + template void construct_envelope_xy_monotone(SurfaceIterator begin, SurfaceIterator end, - Minimization_diagram_2& result) - { + Minimization_diagram_2& result) { Envelope_3::Arbitrary_dividor dividor; construct_envelope_xy_monotone(begin, end, result, dividor); } // compute the envelope of xy-monotone surfaces in 3D using the given // set divider - template + template void construct_envelope_xy_monotone(SurfaceIterator begin, SurfaceIterator end, Minimization_diagram_2& result, - SetDividor& dividor) - { - if (begin == end) - return; // result is empty + SetDividor& dividor) { + if (begin == end) return; // result is empty // recursively construct the envelope of the xy-monotone parts construct_lu_envelope_xy_monotones(begin, end, result, dividor); @@ -245,36 +212,25 @@ public: } /*! Access the traits object. */ - const Traits* get_traits() const - { - return m_geom_traits; - } + const Traits* get_traits() const { return m_geom_traits; } - void reset() - { - resolver->reset(); - } + void reset() { m_resolver->reset(); } protected: // compute the envelope of xy-monotone surfaces in 3D - template + template void construct_lu_envelope_xy_monotones(SurfaceIterator begin, SurfaceIterator end, Minimization_diagram_2& result, - SetDividor& dividor) - { - if (begin == end) - { - return; // result is empty - } + SetDividor& dividor) { + if (begin == end) return; // result is empty SurfaceIterator first = begin++; - if (begin == end) - { + if (begin == end) { // only one surface is in the collection. insert it the result - Xy_monotone_surface_3& surf = *first; + const Xy_monotone_surface_3& surf = *first; deal_with_one_surface(surf, result); return; @@ -303,106 +259,91 @@ protected: CGAL_assertion(is_envelope_valid(result)); } - void deal_with_one_surface(Xy_monotone_surface_3& surf, - Minimization_diagram_2& result) - { - typedef std::pair Boundary_xcurve; - typedef std::list> Boundary_list; + void deal_with_one_surface(const Xy_monotone_surface_3& surf, + Minimization_diagram_2& result) { + using Boundary_xcurve = std::pair; + using Boundary_list = std::list>; - Boundary_list boundary; + Boundary_list boundary; m_geom_traits-> construct_projected_boundary_2_object()(surf, std::back_inserter(boundary)); - if (boundary.empty()) - { + if (boundary.empty()) { //one infinite surface CGAL_assertion_msg(result.number_of_faces() == 1, "In the beginning there should be only one face"); - result.faces_begin()->set_data(surf); + result.faces_begin()->set_env_data(surf); return; } - for (auto boundary_it = boundary.begin(); - boundary_it != boundary.end(); - ++boundary_it) - { - if (const Boundary_xcurve* boundary_cv = std::get_if(&(*boundary_it))) - { + for (auto boundary_it = boundary.begin(); boundary_it != boundary.end(); + ++boundary_it) { + if (const Boundary_xcurve* boundary_cv = + std::get_if(&(*boundary_it))) { Oriented_side side = boundary_cv->second; Halfedge_handle he = insert_non_intersecting_curve(result, boundary_cv->first); - if (side == ON_ORIENTED_BOUNDARY) - { + if (side == ON_ORIENTED_BOUNDARY) { // vertical xy-surface - he->face()->set_no_data(); - he->twin()->face()->set_no_data(); + he->face()->set_no_env_data(); + he->twin()->face()->set_no_env_data(); continue; } - if (he->face() != he->twin()->face()) - { + if (he->face() != he->twin()->face()) { // new face created. // 'he' is directed from left to right, so the face to the left // of 'he' is above 'cv. Face_handle f; - if (side == ON_NEGATIVE_SIDE) // the surface is below cv. - { + if (side == ON_NEGATIVE_SIDE) { // the surface is below cv. f = he->twin()->face(); - f->set_data(surf); - he->face()->set_no_data(); + f->set_env_data(surf); + he->face()->set_no_env_data(); } - else - { + else { CGAL_assertion(side == ON_POSITIVE_SIDE); f = he->face(); - f->set_data(surf); - he->twin()->face()->set_no_data(); + f->set_env_data(surf); + he->twin()->face()->set_no_env_data(); } // init auxiliary data for f and its boundaries. - for(Outer_ccb_iterator ocit = f->outer_ccbs_begin(); - ocit != f->outer_ccbs_end(); ocit++){ + for (auto ocit = f->outer_ccbs_begin(); ocit != f->outer_ccbs_end(); + ++ocit) { Ccb_halfedge_circulator face_hec = *ocit; Ccb_halfedge_circulator face_hec_begin = face_hec; - do - { - face_hec->set_is_equal_data_in_face(true); - face_hec->set_has_equal_data_in_face(true); - face_hec->set_has_equal_data_in_target_and_face(true); + do { + face_hec->set_is_equal_env_data_in_face(true); + face_hec->set_has_equal_env_data_in_face(true); + face_hec->set_has_equal_env_data_in_target_and_face(true); - face_hec->twin()->set_is_equal_data_in_face(false); - face_hec->twin()->set_has_equal_data_in_face(false); - face_hec->twin()->set_has_equal_data_in_target_and_face(false); - - ++face_hec; - } - while(face_hec != face_hec_begin); + face_hec->twin()->set_is_equal_env_data_in_face(false); + face_hec->twin()->set_has_equal_env_data_in_face(false); + face_hec->twin()->set_has_equal_env_data_in_target_and_face(false); + } + while (++face_hec != face_hec_begin); } - for(Outer_ccb_iterator icit = f->inner_ccbs_begin(); - icit != f->inner_ccbs_end(); icit++){ + for (auto icit = f->inner_ccbs_begin(); icit != f->inner_ccbs_end(); + ++icit) { Ccb_halfedge_circulator face_hec = *icit; Ccb_halfedge_circulator face_hec_begin = face_hec; - do - { - face_hec->set_is_equal_data_in_face(true); - face_hec->set_has_equal_data_in_face(true); - face_hec->set_has_equal_data_in_target_and_face(true); + do { + face_hec->set_is_equal_env_data_in_face(true); + face_hec->set_has_equal_env_data_in_face(true); + face_hec->set_has_equal_env_data_in_target_and_face(true); - face_hec->twin()->set_is_equal_data_in_face(false); - face_hec->twin()->set_has_equal_data_in_face(false); - face_hec->twin()->set_has_equal_data_in_target_and_face(false); - - ++face_hec; - } - while(face_hec != face_hec_begin); + face_hec->twin()->set_is_equal_env_data_in_face(false); + face_hec->twin()->set_has_equal_env_data_in_face(false); + face_hec->twin()->set_has_equal_env_data_in_target_and_face(false); + } + while (++face_hec != face_hec_begin); } } } - else - { + else { // the xy-surface is an isolated point const Point_2* p = std::get_if(&(*boundary_it)); CGAL_assertion(p!=nullptr); @@ -412,27 +353,23 @@ protected: // update information in all the edges & vertices to indicate that // this surface is the envelope - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi) + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); ++hi) { - hi->set_data(surf); + hi->set_env_data(surf); // since all the edges & vertices have their envelope data equal to the // current surface, we can set is/has equal_data_in_target of all // halfedges to true - hi->set_is_equal_data_in_target(true); - hi->set_has_equal_data_in_target(true); + hi->set_is_equal_env_data_in_target(true); + hi->set_has_equal_env_data_in_target(true); } - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - { - vi->set_data(surf); - if (vi->is_isolated()) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { + vi->set_env_data(surf); + if (vi->is_isolated()) { // update the is/has equal_data_in_face flags according to the face data - bool equal_data = !vi->face()->has_no_data(); - vi->set_is_equal_data_in_face(equal_data); - vi->set_has_equal_data_in_face(equal_data); + bool equal_data = !vi->face()->has_no_env_data(); + vi->set_is_equal_env_data_in_face(equal_data); + vi->set_has_equal_env_data_in_face(equal_data); } } } @@ -441,8 +378,7 @@ protected: public: void merge_envelopes(Minimization_diagram_2& result1, Minimization_diagram_2& result2, - Minimization_diagram_2& result) - { + Minimization_diagram_2& result) { // overlay the 2 arrangements Overlay_2 overlay; @@ -465,25 +401,20 @@ public: // compute the surface on the envelope for each edge // edge can be split as surfaces can intersect (or touch) over it std::list edges_to_resolve; - Edge_iterator ei = result.edges_begin(); - for (; ei != result.edges_end(); ++ei) - { + for (auto ei = result.edges_begin(); ei != result.edges_end(); ++ei) { Halfedge_handle hh = ei; // there must be data from at least one map, because all the surfaces // are continuous - if (!get_aux_is_set(hh, 0) || !get_aux_is_set(hh, 1)) - continue; - CGAL_assertion(get_aux_is_set(hh, 0)); - CGAL_assertion(get_aux_is_set(hh, 1)); + if (! aux_is_set(hh, 0) || !aux_is_set(hh, 1)) continue; + CGAL_assertion(aux_is_set(hh, 0)); + CGAL_assertion(aux_is_set(hh, 1)); CGAL_assertion(!aux_has_no_data(hh, 1) || !aux_has_no_data(hh, 0)); - if (aux_has_no_data(hh, 0) && !aux_has_no_data(hh, 1)) - { + if (aux_has_no_data(hh, 0) && !aux_has_no_data(hh, 1)) { hh->set_decision(DAC_DECISION_SECOND); hh->twin()->set_decision(DAC_DECISION_SECOND); continue; } - else if (!aux_has_no_data(hh, 0) && aux_has_no_data(hh, 1)) - { + else if (!aux_has_no_data(hh, 0) && aux_has_no_data(hh, 1)) { hh->set_decision(DAC_DECISION_FIRST); hh->twin()->set_decision(DAC_DECISION_FIRST); continue; @@ -491,12 +422,12 @@ public: bool should_resolve = true; #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS - if (hh->get_has_equal_aux_data_in_face(0) && - hh->get_has_equal_aux_data_in_face(1)) + if (hh->has_equal_aux_data_in_face(0) && + hh->has_equal_aux_data_in_face(1)) should_resolve = false; - if (hh->twin()->get_has_equal_aux_data_in_face(0) && - hh->twin()->get_has_equal_aux_data_in_face(1)) + if (hh->twin()->has_equal_aux_data_in_face(0) && + hh->twin()->has_equal_aux_data_in_face(1)) should_resolve = false; #endif @@ -506,12 +437,8 @@ public: edges_to_resolve.push_back(hh); } // now deal with the edges - typename std::list::iterator li; - for (li = edges_to_resolve.begin(); li != edges_to_resolve.end(); ++li) - { - resolver->resolve(*li, result); - - } + for (auto li = edges_to_resolve.begin(); li != edges_to_resolve.end(); ++li) + m_resolver->resolve(*li, result); edges_to_resolve.clear(); // decompose the result, to have faces without holes @@ -547,74 +474,60 @@ public: index_map.detach(); #else // traverse the faces in arbitrary order - Face_iterator fi = result.faces_begin(); - for (; fi != result.faces_end(); ++fi) - { + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) { Face_handle fh = fi; - // if a surface of one map doesn't exist, then we set the second surface - if (aux_has_no_data(fh, 0) && !aux_has_no_data(fh, 1)) - { - fh->set_decision(DAC_DECISION_SECOND); - continue; - } - else if (aux_has_no_data(fh, 0) && aux_has_no_data(fh, 1)) - { - fh->set_decision(EQUAL); - fh->set_no_data(); - - continue; - } - else if (!aux_has_no_data(fh, 0) && aux_has_no_data(fh, 1)) - { - fh->set_decision(DAC_DECISION_FIRST); - continue; - } - - // here, we have both surfaces. - // we save the face in a list for a later treatment, because the - // face can change and destroy the iterator - faces_to_split.push_back(fh); + // if a surface of one map doesn't exist, then we set the second surface + if (aux_has_no_data(fh, 0) && !aux_has_no_data(fh, 1)) { + fh->set_decision(DAC_DECISION_SECOND); + continue; } + else if (aux_has_no_data(fh, 0) && aux_has_no_data(fh, 1)) { + fh->set_decision(EQUAL); + fh->set_no_env_data(); + continue; + } + else if (!aux_has_no_data(fh, 0) && aux_has_no_data(fh, 1)) { + fh->set_decision(DAC_DECISION_FIRST); + continue; + } + + // here, we have both surfaces. + // we save the face in a list for a later treatment, because the + // face can change and destroy the iterator + faces_to_split.push_back(fh); + } #endif deal_with_faces_to_split(faces_to_split, result); -// #ifndef CGAL_ENVELOPE_SAVE_COMPARISONS -// hi = result.halfedges_begin(); -// for (; hi != result.halfedges_end(); ++hi, ++hi) -// { -// if (!hi->is_decision_set()) -// resolver->resolve(hi, result); -// } -// #endif + // #ifndef CGAL_ENVELOPE_SAVE_COMPARISONS + // hi = result.halfedges_begin(); + // for (; hi != result.halfedges_end(); ++hi, ++hi) { + // if (!hi->is_decision_set()) m_resolver->resolve(hi, result); + // } + // #endif // detach the edge_observer from result, since no need for it anymore edge_observer.detach(); // compute the surface on the envelope for each vertex - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; - if (vh->is_decision_set()) - continue; + if (vh->is_decision_set()) continue; // there must be data from at least one map, because all the surfaces // are continuous - CGAL_assertion(get_aux_is_set(vh, 0)); - CGAL_assertion(get_aux_is_set(vh, 1)); + CGAL_assertion(aux_is_set(vh, 0)); + CGAL_assertion(aux_is_set(vh, 1)); CGAL_assertion(!aux_has_no_data(vh, 1) || !aux_has_no_data(vh, 0)); - if (aux_has_no_data(vh, 0) && !aux_has_no_data(vh, 1)) - { + if (aux_has_no_data(vh, 0) && !aux_has_no_data(vh, 1)) { vh->set_decision(DAC_DECISION_SECOND); continue; } - else if (!aux_has_no_data(vh, 0) && aux_has_no_data(vh, 1)) - { + else if (!aux_has_no_data(vh, 0) && aux_has_no_data(vh, 1)) { vh->set_decision(DAC_DECISION_FIRST); continue; } - resolver->resolve(vh); - + m_resolver->resolve(vh); } CGAL_expensive_assertion_msg(result.is_valid(), @@ -640,7 +553,7 @@ public: CGAL_expensive_assertion_msg(result.is_valid(), "after remove vertices result is not valid"); - // update is_equal_data and has_equal_data of halfedge->face and + // update is_equal_env_data and has_equal_env_data of halfedge->face and // vertex->face relations, according to the decision, and the aux // similar flags update_flags(result); @@ -655,43 +568,36 @@ public: "after merge result is not valid"); } - protected: - void deal_with_faces_to_split(std::list& faces_to_split, - Minimization_diagram_2& result) - { + Minimization_diagram_2& result) { // for each face in faces_to_split, find the intersection over the face, // and split the face - typename std::list::iterator li; - for (li = faces_to_split.begin(); li != faces_to_split.end(); ++li) - resolver->resolve(*li, result); + for (auto li = faces_to_split.begin(); li != faces_to_split.end(); ++li) + m_resolver->resolve(*li, result); faces_to_split.clear(); } - template - bool is_equal_data(const InputIterator& begin1, - const InputIterator& end1, - const InputIterator& begin2, - const InputIterator& end2) - { + template + bool is_equal_env_data(const InputIterator& begin1, + const InputIterator& end1, + const InputIterator& begin2, + const InputIterator& end2) { // insert the input data objects into a set std::set first(begin1, end1); std::set second(begin2, end2); - if (first.size() != second.size()) - return false; + if (first.size() != second.size()) return false; return (first == second); } // todo: should remove the uses of this method from this class - template - bool has_equal_data(const InputIterator& begin1, - const InputIterator& end1, - const InputIterator& begin2, - const InputIterator& end2) - { + template + bool has_equal_env_data(const InputIterator& begin1, + const InputIterator& end1, + const InputIterator& begin2, + const InputIterator& end2) { // insert the input data objects into a set std::set first(begin1, end1); std::set second(begin2, end2); @@ -702,36 +608,31 @@ protected: return (intersection.size() > 0); return true; } + // todo: should remove the uses of this method from this class - template + template bool has_equal_aux_data(unsigned int id, FeatureHandle1 fh1, - FeatureHandle2 fh2) - { + FeatureHandle2 fh2) { Envelope_data_iterator begin1, end1, begin2, end2; - get_aux_data_iterators(id, fh1, begin1, end1); - get_aux_data_iterators(id, fh2, begin2, end2); - bool has_eq = has_equal_data(begin1, end1, begin2, end2); + aux_data_iterators(id, fh1, begin1, end1); + aux_data_iterators(id, fh2, begin2, end2); + bool has_eq = has_equal_env_data(begin1, end1, begin2, end2); return has_eq; } // Remove unnecessary edges, between faces with the same surface // (and which are not degenerate) - void remove_unnecessary_edges(Minimization_diagram_2& result) - { + void remove_unnecessary_edges(Minimization_diagram_2& result) { // collect all those edges in this list, and remove them all at the end // (thus, not destroying the iterator) std::list edges; - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi, ++hi) - { + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); + ++hi, ++hi) { Halfedge_handle hh = hi; - if (can_remove_edge(hh)) - edges.push_back(hh); + if (can_remove_edge(hh)) edges.push_back(hh); } - for (typename std::list::iterator ci = edges.begin(); - ci != edges.end(); ++ci) - { + for (auto ci = edges.begin(); ci != edges.end(); ++ci) { // if the endpoints become isolated after the removal we need to remove // them if they have the same data as the edge Halfedge_handle h = *ci; @@ -740,20 +641,20 @@ protected: CGAL_assertion_code(Face_handle h_face = h->face()); bool remove_src = can_remove_edge_target(h->twin()); bool remove_trg = can_remove_edge_target(h); - bool src_is_equal_0 = (h->twin()->get_is_equal_aux_data_in_face(0) && - h->twin()->get_is_equal_aux_data_in_target(0)); - bool src_is_equal_1 = (h->twin()->get_is_equal_aux_data_in_face(1) && - h->twin()->get_is_equal_aux_data_in_target(1)); - bool trg_is_equal_0 = (h->get_is_equal_aux_data_in_face(0) && - h->get_is_equal_aux_data_in_target(0)); - bool trg_is_equal_1 = (h->get_is_equal_aux_data_in_face(1) && - h->get_is_equal_aux_data_in_target(1)); + bool src_is_equal_0 = (h->twin()->is_equal_aux_data_in_face(0) && + h->twin()->is_equal_aux_data_in_target(0)); + bool src_is_equal_1 = (h->twin()->is_equal_aux_data_in_face(1) && + h->twin()->is_equal_aux_data_in_target(1)); + bool trg_is_equal_0 = (h->is_equal_aux_data_in_face(0) && + h->is_equal_aux_data_in_target(0)); + bool trg_is_equal_1 = (h->is_equal_aux_data_in_face(1) && + h->is_equal_aux_data_in_target(1)); bool src_has_equal_0 = - h->twin()->get_has_equal_aux_data_in_target_and_face(0); + h->twin()->has_equal_aux_data_in_target_and_face(0); bool src_has_equal_1 = - h->twin()->get_has_equal_aux_data_in_target_and_face(1); - bool trg_has_equal_0 = h->get_has_equal_aux_data_in_target_and_face(0); - bool trg_has_equal_1 = h->get_has_equal_aux_data_in_target_and_face(1); + h->twin()->has_equal_aux_data_in_target_and_face(1); + bool trg_has_equal_0 = h->has_equal_aux_data_in_target_and_face(0); + bool trg_has_equal_1 = h->has_equal_aux_data_in_target_and_face(1); /* A vertex at an open boundary is removed once it becomes redundant * regardless of the boolean values passed as the 2nd and 3rd argument @@ -780,8 +681,7 @@ protected: src->set_has_equal_aux_data_in_face(0, src_has_equal_0); src->set_has_equal_aux_data_in_face(1, src_has_equal_1); } - if (!remove_trg && trg->is_isolated()) - { + if (! remove_trg && trg->is_isolated()) { trg->set_is_equal_aux_data_in_face(0, trg_is_equal_0); trg->set_is_equal_aux_data_in_face(1, trg_is_equal_1); // make sure h_face is also trg face @@ -796,17 +696,16 @@ protected: } } - template - void get_aux_data_iterators(unsigned int id, FeatureHandle fh, - Envelope_data_iterator& begin, - Envelope_data_iterator& end) - { + template + void aux_data_iterators(unsigned int id, FeatureHandle fh, + Envelope_data_iterator& begin, + Envelope_data_iterator& end) { Halfedge_handle h; Vertex_handle v; Face_handle f; - const Object& o = fh->get_aux_source(id); - CGAL_assertion(!o.is_empty()); + const Object& o = fh->aux_source(id); + CGAL_assertion(! o.is_empty()); // aux source of a face must be a face! // aux source of a halfedge can be face or halfedge @@ -815,23 +714,20 @@ protected: // this is why we start with a check for a face, then halfedge // and last vertex - if (assign(f, o)) - { - begin = f->begin_data(); - end = f->end_data(); + if (assign(f, o)) { + begin = f->begin_env_data(); + end = f->end_env_data(); } - else if (assign(h, o)) - { - begin = h->begin_data(); - end = h->end_data(); + else if (assign(h, o)) { + begin = h->begin_env_data(); + end = h->end_env_data(); } - else - { + else { CGAL_assertion_code(bool b = ) assign(v, o); CGAL_assertion(b); - begin = v->begin_data(); - end = v->end_data(); + begin = v->begin_env_data(); + end = v->end_env_data(); } } @@ -839,41 +735,36 @@ protected: // this can be done if the envelope surfaces on the edge are the same as // the envelope surfaces on both sides of the edge // (or if the edge is fake, i.e. created in the vd process) - bool can_remove_edge(Halfedge_handle hh) - { + bool can_remove_edge(Halfedge_handle hh) { Face_handle f1 = hh->face(), f2 = hh->twin()->face(); // we check if the decision done on the edge is equal to the decision // done on the faces. if not, then the envelope surfaces must differ CGAL_assertion(hh->is_decision_set() && f1->is_decision_set() && f2->is_decision_set()); - if (hh->get_decision() != f1->get_decision() || - hh->get_decision() != f2->get_decision()) + if (hh->decision() != f1->decision() || + hh->decision() != f2->decision()) { return false; } // now, check the equality of the surfaces list according to the decision - CGAL::Dac_decision decision = hh->get_decision(); - bool equal_first = (hh->get_is_equal_aux_data_in_face(0) && - hh->twin()->get_is_equal_aux_data_in_face(0)); - bool equal_second = (hh->get_is_equal_aux_data_in_face(1) && - hh->twin()->get_is_equal_aux_data_in_face(1)); + CGAL::Dac_decision decision = hh->decision(); + bool equal_first = (hh->is_equal_aux_data_in_face(0) && + hh->twin()->is_equal_aux_data_in_face(0)); + bool equal_second = (hh->is_equal_aux_data_in_face(1) && + hh->twin()->is_equal_aux_data_in_face(1)); - if (decision == DAC_DECISION_FIRST) - return equal_first; + if (decision == DAC_DECISION_FIRST) return equal_first; - if (decision == DAC_DECISION_SECOND) - return equal_second; + if (decision == DAC_DECISION_SECOND) return equal_second; return (equal_first && equal_second); } - // check if can remove the edge's target if we remove the edge // this means that the target has the same envelope information as the edge - bool can_remove_edge_target(Halfedge_handle h) - { + bool can_remove_edge_target(Halfedge_handle h) { // \todo Use new design /* The code below uses the is_at_open_boundary. The comment from the calling function says: @@ -886,41 +777,33 @@ protected: if ((v->parameter_space_in_x() != ARR_INTERIOR) || (v->parameter_space_in_y() != ARR_INTERIOR)) return false; - */ + Vertex_handle v = h->target(); - if (v->is_at_open_boundary()) - return false; + if (v->is_at_open_boundary()) return false; - - /*if (v->get_is_fake() && !v->is_decision_set()) - return true; - - - if (h->get_is_fake() && !h->is_decision_set()) - { - h->set_decision(h->face()->get_decision()); - h->twin()->set_decision(h->get_decision()); - }*/ + /* if (v->is_fake() && !v->is_decision_set()) return true; + * if (h->is_fake() && !h->is_decision_set()) { + * h->set_decision(h->face()->decision()); + * h->twin()->set_decision(h->decision()); + * } + */ CGAL_assertion(v->is_decision_set()); CGAL_assertion(h->is_decision_set()); // if the decision done on the vertex and edge are different, // the envelope differs too. - if (h->get_decision() != v->get_decision()) - return false; + if (h->decision() != v->decision()) return false; // now, check the equality of the surfaces list according to the decision - CGAL::Dac_decision decision = h->get_decision(); - bool equal_first = (h->get_is_equal_aux_data_in_target(0)); - bool equal_second = (h->get_is_equal_aux_data_in_target(1)); + CGAL::Dac_decision decision = h->decision(); + bool equal_first = (h->is_equal_aux_data_in_target(0)); + bool equal_second = (h->is_equal_aux_data_in_target(1)); - if (decision == DAC_DECISION_FIRST) - return equal_first; + if (decision == DAC_DECISION_FIRST) return equal_first; - if (decision == DAC_DECISION_SECOND) - return equal_second; + if (decision == DAC_DECISION_SECOND) return equal_second; return (equal_first && equal_second); } @@ -928,26 +811,22 @@ protected: // check if we can remove an isolated vertex from the envelope // this can be done if the envelope surfaces on the vertex are the same as // the envelope surfaces on its incident face - bool can_remove_isolated_vertex(Vertex_handle vh) - { + bool can_remove_isolated_vertex(Vertex_handle vh) { Face_handle f = vh->face(); CGAL_assertion(vh->is_decision_set() && f->is_decision_set()); // if the decision done on the vertex and face are different, // the envelope differs too. - if (vh->get_decision() != f->get_decision()) - return false; + if (vh->decision() != f->decision()) return false; // now, check the equality of the surfaces list according to the decision - CGAL::Dac_decision decision = vh->get_decision(); + CGAL::Dac_decision decision = vh->decision(); - bool equal_first = (vh->get_is_equal_aux_data_in_face(0)); - bool equal_second = (vh->get_is_equal_aux_data_in_face(1)); + bool equal_first = (vh->is_equal_aux_data_in_face(0)); + bool equal_second = (vh->is_equal_aux_data_in_face(1)); - if (decision == DAC_DECISION_FIRST) - return equal_first; + if (decision == DAC_DECISION_FIRST) return equal_first; - if (decision == DAC_DECISION_SECOND) - return equal_second; + if (decision == DAC_DECISION_SECOND) return equal_second; return (equal_first && equal_second); } @@ -957,16 +836,15 @@ protected: // the geometric point of view (i.e. if the curves can merge) // this can be done if the envelope surfaces on the vertex are the same as // the envelope surfaces on its 2 incident halfedges - bool combinatorically_can_remove_vertex(Vertex_handle vh) - { + bool combinatorically_can_remove_vertex(Vertex_handle vh) { Halfedge_around_vertex_circulator hec1 = vh->incident_halfedges(); Halfedge_around_vertex_circulator hec2 = hec1++; Halfedge_handle he1 = hec1, he2 = hec2; CGAL_assertion(he1 != he2); CGAL_assertion(he1->is_decision_set() && he2->is_decision_set()); - /* if (vh->get_is_fake()) { - * CGAL_assertion(he1->get_decision() == he2->get_decision()); + /* if (vh->is_fake()) { + * CGAL_assertion(he1->decision() == he2->decision()); * return true; * } */ @@ -975,22 +853,20 @@ protected: // if the decision done on the vertex and its incident halfedges are // different, the envelope differs too. CGAL_assertion(vh == he1->target() && vh == he2->target()); - if (vh->get_decision() != he1->get_decision() || - vh->get_decision() != he2->get_decision()) + if (vh->decision() != he1->decision() || + vh->decision() != he2->decision()) return false; // now, check the equality of the surfaces list according to the decision - CGAL::Dac_decision decision = vh->get_decision(); - bool equal_first = (he1->get_is_equal_aux_data_in_target(0) && - he2->get_is_equal_aux_data_in_target(0)); - bool equal_second = (he1->get_is_equal_aux_data_in_target(1) && - he2->get_is_equal_aux_data_in_target(1)); + CGAL::Dac_decision decision = vh->decision(); + bool equal_first = (he1->is_equal_aux_data_in_target(0) && + he2->is_equal_aux_data_in_target(0)); + bool equal_second = (he1->is_equal_aux_data_in_target(1) && + he2->is_equal_aux_data_in_target(1)); - if (decision == DAC_DECISION_FIRST) - return equal_first; + if (decision == DAC_DECISION_FIRST) return equal_first; - if (decision == DAC_DECISION_SECOND) - return equal_second; + if (decision == DAC_DECISION_SECOND) return equal_second; return (equal_first && equal_second); } @@ -998,8 +874,7 @@ protected: // Remove unnecessary vertices, which have degree 2, and the 2 curves // can be merged // (and which are not degenerate) - void remove_unnecessary_vertices(Minimization_diagram_2& result) - { + void remove_unnecessary_vertices(Minimization_diagram_2& result) { // we have 2 types of unnecessary vertices: those with degree 2 (that // satisfy all the conditions below), and isolated vertices that have the // same envelope information as the face they're contained in. @@ -1017,9 +892,7 @@ protected: std::list candidates_to_remove; std::list isolated_to_remove; - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; if (!vh->is_decision_set() || vh->degree() == 2) candidates_to_remove.push_back(vh); @@ -1027,22 +900,19 @@ protected: isolated_to_remove.push_back(vh); } - typename Traits::Merge_2 curves_merge = m_geom_traits->merge_2_object(); - typename Traits::Are_mergeable_2 curves_can_merge = - m_geom_traits->are_mergeable_2_object(); + auto curves_merge = m_geom_traits->merge_2_object(); + auto curves_can_merge = m_geom_traits->are_mergeable_2_object(); // check the candidates and remove if necessary - typename std::list::iterator ci; - for (ci = candidates_to_remove.begin(); - ci != candidates_to_remove.end(); ++ci) + for (auto ci = candidates_to_remove.begin(); + ci != candidates_to_remove.end(); ++ci) { Vertex_handle vh = *ci; CGAL_assertion(vh->degree() == 2); // we can remove this vertex only if the data on its halfedges is the // same - if (!combinatorically_can_remove_vertex(vh)) - continue; + if (!combinatorically_can_remove_vertex(vh)) continue; // merge the edges, if geometrically possible (if data on vertex is not // set, then it must be geometrically possible) @@ -1053,8 +923,7 @@ protected: const X_monotone_curve_2& a = he1->curve(), b = he2->curve(); CGAL_assertion(vh->is_decision_set() || curves_can_merge(a,b)); - if (vh->is_decision_set() && !curves_can_merge(a,b)) - continue; + if (vh->is_decision_set() && !curves_can_merge(a,b)) continue; X_monotone_curve_2 c; curves_merge(a,b,c); @@ -1070,30 +939,30 @@ protected: // <----------- ------------> // he1->twin() he2->twin() he1->set_is_equal_aux_data_in_target - (0, he2->twin()->get_is_equal_aux_data_in_target(0)); + (0, he2->twin()->is_equal_aux_data_in_target(0)); he1->set_is_equal_aux_data_in_target - (1, he2->twin()->get_is_equal_aux_data_in_target(1)); + (1, he2->twin()->is_equal_aux_data_in_target(1)); he1->set_has_equal_aux_data_in_target - (0, he2->twin()->get_has_equal_aux_data_in_target(0)); + (0, he2->twin()->has_equal_aux_data_in_target(0)); he1->set_has_equal_aux_data_in_target - (1, he2->twin()->get_has_equal_aux_data_in_target(1)); + (1, he2->twin()->has_equal_aux_data_in_target(1)); he1->set_has_equal_aux_data_in_target_and_face - (0, he2->twin()->get_has_equal_aux_data_in_target_and_face(0)); + (0, he2->twin()->has_equal_aux_data_in_target_and_face(0)); he1->set_has_equal_aux_data_in_target_and_face - (1, he2->twin()->get_has_equal_aux_data_in_target_and_face(1)); + (1, he2->twin()->has_equal_aux_data_in_target_and_face(1)); he2->set_is_equal_aux_data_in_target - (0, he1->twin()->get_is_equal_aux_data_in_target(0)); + (0, he1->twin()->is_equal_aux_data_in_target(0)); he2->set_is_equal_aux_data_in_target - (1, he1->twin()->get_is_equal_aux_data_in_target(1)); + (1, he1->twin()->is_equal_aux_data_in_target(1)); he2->set_has_equal_aux_data_in_target - (0, he1->twin()->get_has_equal_aux_data_in_target(0)); + (0, he1->twin()->has_equal_aux_data_in_target(0)); he2->set_has_equal_aux_data_in_target - (1, he1->twin()->get_has_equal_aux_data_in_target(1)); + (1, he1->twin()->has_equal_aux_data_in_target(1)); he2->set_has_equal_aux_data_in_target_and_face - (0, he1->twin()->get_has_equal_aux_data_in_target_and_face(0)); + (0, he1->twin()->has_equal_aux_data_in_target_and_face(0)); he2->set_has_equal_aux_data_in_target_and_face - (1, he1->twin()->get_has_equal_aux_data_in_target_and_face(1)); + (1, he1->twin()->has_equal_aux_data_in_target_and_face(1)); // order of halfedges for merge doesn't matter #if !defined(CGAL_NO_ASSERTIONS) @@ -1108,8 +977,8 @@ protected: // remove isolated vertices - typename std::list::iterator li; - for (li = isolated_to_remove.begin(); li != isolated_to_remove.end(); ++li) + for (auto li = isolated_to_remove.begin(); li != isolated_to_remove.end(); + ++li) { Vertex_handle vh = *li; CGAL_assertion(vh->is_isolated()); @@ -1119,133 +988,113 @@ protected: } } - template - void update_envelope_surfaces_by_decision(FeatureHandle fh) - { - CGAL::Dac_decision decision = fh->get_decision(); + template + void update_envelope_surfaces_by_decision(FeatureHandle fh) { + CGAL::Dac_decision decision = fh->decision(); Halfedge_handle h; Vertex_handle v; Face_handle f; - if (decision == DAC_DECISION_FIRST || decision == DAC_DECISION_BOTH) - { + if (decision == DAC_DECISION_FIRST || decision == DAC_DECISION_BOTH) { Envelope_data_iterator begin, end; - get_aux_data_iterators(0, fh, begin, end); - fh->set_data(begin, end); + aux_data_iterators(0, fh, begin, end); + fh->set_env_data(begin, end); } - if (decision == DAC_DECISION_SECOND || decision == DAC_DECISION_BOTH) - { + if (decision == DAC_DECISION_SECOND || decision == DAC_DECISION_BOTH) { // copy data from second envelope Envelope_data_iterator begin, end; - get_aux_data_iterators(1, fh, begin, end); + aux_data_iterators(1, fh, begin, end); - if (decision == DAC_DECISION_SECOND) - fh->set_data(begin, end); - else - fh->add_data(begin, end); + if (decision == DAC_DECISION_SECOND) fh->set_env_data(begin, end); + else fh->add_env_data(begin, end); } } // foreach feature of result, update the envelope surfaces, according // to the decision done over this feature, and its aux sources - void update_envelope_surfaces_by_decision(Minimization_diagram_2& result) - { + void update_envelope_surfaces_by_decision(Minimization_diagram_2& result) { // vertices - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) update_envelope_surfaces_by_decision(vi); // edges - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi) + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); ++hi) update_envelope_surfaces_by_decision(hi); // faces - Face_iterator fi = result.faces_begin(); - for (; fi != result.faces_end(); ++fi) + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) update_envelope_surfaces_by_decision(fi); } // update the is_equal/has_equal flags of the result envelope - void update_edge_face_flags(Halfedge_handle h) - { + void update_edge_face_flags(Halfedge_handle h) { bool is_equal, has_equal; - is_equal = (h->get_decision() == h->face()->get_decision()); + is_equal = (h->decision() == h->face()->decision()); // has equal can be true even if the decision is not the same, // but has same surfaces, i.e. one of the features got DAC_DECISION_BOTH // decision, and the other didn't - has_equal = (h->get_decision() == h->face()->get_decision() || - h->get_decision() == DAC_DECISION_BOTH || - h->face()->get_decision() == DAC_DECISION_BOTH); + has_equal = (h->decision() == h->face()->decision() || + h->decision() == DAC_DECISION_BOTH || + h->face()->decision() == DAC_DECISION_BOTH); - CGAL::Dac_decision decision = h->face()->get_decision(); - bool is_equal_first = (h->get_is_equal_aux_data_in_face(0)); - bool has_equal_first = (h->get_has_equal_aux_data_in_face(0)); - bool is_equal_second = (h->get_is_equal_aux_data_in_face(1)); - bool has_equal_second = (h->get_has_equal_aux_data_in_face(1)); - if (decision == DAC_DECISION_FIRST) - { + CGAL::Dac_decision decision = h->face()->decision(); + bool is_equal_first = (h->is_equal_aux_data_in_face(0)); + bool has_equal_first = (h->has_equal_aux_data_in_face(0)); + bool is_equal_second = (h->is_equal_aux_data_in_face(1)); + bool has_equal_second = (h->has_equal_aux_data_in_face(1)); + if (decision == DAC_DECISION_FIRST) { is_equal &= is_equal_first; has_equal &= has_equal_first; } - else if (decision == DAC_DECISION_SECOND) - { + else if (decision == DAC_DECISION_SECOND) { is_equal &= is_equal_second; has_equal &= has_equal_second; } - else - { + else { is_equal &= (is_equal_first & is_equal_second); // we check if the halfedge has a different decision, and if so, // we update the flag according to the halfedge decision - decision = h->get_decision(); - if (decision == DAC_DECISION_FIRST) - has_equal &= has_equal_first; - else if (decision == DAC_DECISION_SECOND) - has_equal &= has_equal_second; - else - has_equal &= (has_equal_first & has_equal_second); + decision = h->decision(); + if (decision == DAC_DECISION_FIRST) has_equal &= has_equal_first; + else if (decision == DAC_DECISION_SECOND) has_equal &= has_equal_second; + else has_equal &= (has_equal_first & has_equal_second); } - h->set_is_equal_data_in_face(is_equal); - h->set_has_equal_data_in_face(has_equal); + h->set_is_equal_env_data_in_face(is_equal); + h->set_has_equal_env_data_in_face(has_equal); } - void update_edge_target_flags(Halfedge_handle h) - { + + void update_edge_target_flags(Halfedge_handle h) { bool is_equal, has_equal; - is_equal = (h->get_decision() == h->target()->get_decision()); + is_equal = (h->decision() == h->target()->decision()); // has equal can be true even if the decision is not the same, // but has same surfaces, i.e. one of the features got DAC_DECISION_BOTH // decision, and the other didn't - has_equal = (h->get_decision() == h->target()->get_decision() || - h->get_decision() == DAC_DECISION_BOTH || - h->target()->get_decision() == DAC_DECISION_BOTH); + has_equal = (h->decision() == h->target()->decision() || + h->decision() == DAC_DECISION_BOTH || + h->target()->decision() == DAC_DECISION_BOTH); - CGAL::Dac_decision decision = h->get_decision(); - bool is_equal_first = (h->get_is_equal_aux_data_in_target(0)); - bool has_equal_first = (h->get_has_equal_aux_data_in_target(0)); - bool is_equal_second = (h->get_is_equal_aux_data_in_target(1)); - bool has_equal_second = (h->get_has_equal_aux_data_in_target(1)); - if (decision == DAC_DECISION_FIRST) - { + CGAL::Dac_decision decision = h->decision(); + bool is_equal_first = (h->is_equal_aux_data_in_target(0)); + bool has_equal_first = (h->has_equal_aux_data_in_target(0)); + bool is_equal_second = (h->is_equal_aux_data_in_target(1)); + bool has_equal_second = (h->has_equal_aux_data_in_target(1)); + if (decision == DAC_DECISION_FIRST) { is_equal &= is_equal_first; has_equal &= has_equal_first; } - - else if (decision == DAC_DECISION_SECOND) - { + else if (decision == DAC_DECISION_SECOND) { is_equal &= is_equal_second; has_equal &= has_equal_second; } - else - { + else { is_equal &= (is_equal_first & is_equal_second); // we check if the vertex has a different decision, and if so, // we update the flag according to the vertex decision - decision = h->target()->get_decision(); + decision = h->target()->decision(); if (decision == DAC_DECISION_FIRST) has_equal &= has_equal_first; else if (decision == DAC_DECISION_SECOND) @@ -1254,75 +1103,64 @@ protected: else has_equal &= (has_equal_first & has_equal_second); } - h->set_is_equal_data_in_target(is_equal); - h->set_has_equal_data_in_target(has_equal); + h->set_is_equal_env_data_in_target(is_equal); + h->set_has_equal_env_data_in_target(has_equal); } - void update_target_face_flags(Halfedge_handle h) - { + + void update_target_face_flags(Halfedge_handle h) { bool has_equal; // has equal can be true even if the decision is not the same, // but has same surfaces, i.e. one of the features got DAC_DECISION_BOTH // decision, and the other didn't - has_equal = (h->face()->get_decision() == h->target()->get_decision() || - h->face()->get_decision() == DAC_DECISION_BOTH || - h->target()->get_decision() == DAC_DECISION_BOTH); + has_equal = (h->face()->decision() == h->target()->decision() || + h->face()->decision() == DAC_DECISION_BOTH || + h->target()->decision() == DAC_DECISION_BOTH); - CGAL::Dac_decision decision = h->face()->get_decision(); - bool has_equal_first = (h->get_has_equal_aux_data_in_target_and_face(0)); - bool has_equal_second = (h->get_has_equal_aux_data_in_target_and_face(1)); - if (decision == DAC_DECISION_FIRST) - has_equal &= has_equal_first; - else if (decision == DAC_DECISION_SECOND) - has_equal &= has_equal_second; - else - { + CGAL::Dac_decision decision = h->face()->decision(); + bool has_equal_first = (h->has_equal_aux_data_in_target_and_face(0)); + bool has_equal_second = (h->has_equal_aux_data_in_target_and_face(1)); + if (decision == DAC_DECISION_FIRST) has_equal &= has_equal_first; + else if (decision == DAC_DECISION_SECOND) has_equal &= has_equal_second; + else { // we check if the vertex has a different decision, and if so, // we update the flag according to the vertex decision - decision = h->target()->get_decision(); - if (decision == DAC_DECISION_FIRST) - has_equal &= has_equal_first; - else if (decision == DAC_DECISION_SECOND) - has_equal &= has_equal_second; - - else - has_equal &= (has_equal_first & has_equal_second); + decision = h->target()->decision(); + if (decision == DAC_DECISION_FIRST) has_equal &= has_equal_first; + else if (decision == DAC_DECISION_SECOND) has_equal &= has_equal_second; + else has_equal &= (has_equal_first & has_equal_second); } - h->set_has_equal_data_in_target_and_face(has_equal); + h->set_has_equal_env_data_in_target_and_face(has_equal); } - void update_vertex_face_flags(Vertex_handle v, Face_handle f) - { + void update_vertex_face_flags(Vertex_handle v, Face_handle f) { bool is_equal, has_equal; - is_equal = (v->get_decision() == f->get_decision()); + is_equal = (v->decision() == f->decision()); // has equal can be true even if the decision is not the same, // but has same surfaces, i.e. one of the features got DAC_DECISION_BOTH // decision, and the other didn't - has_equal = (v->get_decision() == f->get_decision() || - v->get_decision() == DAC_DECISION_BOTH || - f->get_decision() == DAC_DECISION_BOTH); + has_equal = (v->decision() == f->decision() || + v->decision() == DAC_DECISION_BOTH || + f->decision() == DAC_DECISION_BOTH); - CGAL::Dac_decision decision = v->get_decision(); - bool is_equal_first = (v->get_is_equal_aux_data_in_face(0)); - bool has_equal_first = (v->get_has_equal_aux_data_in_face(0)); - bool is_equal_second = (v->get_is_equal_aux_data_in_face(1)); - bool has_equal_second = (v->get_has_equal_aux_data_in_face(1)); - if (decision == DAC_DECISION_FIRST) - { + CGAL::Dac_decision decision = v->decision(); + bool is_equal_first = (v->is_equal_aux_data_in_face(0)); + bool has_equal_first = (v->has_equal_aux_data_in_face(0)); + bool is_equal_second = (v->is_equal_aux_data_in_face(1)); + bool has_equal_second = (v->has_equal_aux_data_in_face(1)); + if (decision == DAC_DECISION_FIRST) { is_equal &= is_equal_first; has_equal &= has_equal_first; } - else if (decision == DAC_DECISION_SECOND) - { + else if (decision == DAC_DECISION_SECOND) { is_equal &= is_equal_second; has_equal &= has_equal_second; } - else - { + else { is_equal &= (is_equal_first & is_equal_second); // we check if the face has a different decision, and if so, // we update the flag according to the face decision - decision = f->get_decision(); + decision = f->decision(); if (decision == DAC_DECISION_FIRST) has_equal &= has_equal_first; else if (decision == DAC_DECISION_SECOND) @@ -1330,15 +1168,13 @@ protected: else has_equal &= (has_equal_first & has_equal_second); } - v->set_is_equal_data_in_face(is_equal); - v->set_has_equal_data_in_face(has_equal); + v->set_is_equal_env_data_in_face(is_equal); + v->set_has_equal_env_data_in_face(has_equal); } - void update_flags(Minimization_diagram_2& result) - { + void update_flags(Minimization_diagram_2& result) { // edges - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi) + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); ++hi) { update_edge_face_flags(hi); update_edge_target_flags(hi); @@ -1346,23 +1182,17 @@ protected: } // vertices - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - if (vi->is_isolated()) - update_vertex_face_flags(vi, vi->face()); - + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) + if (vi->is_isolated()) update_vertex_face_flags(vi, vi->face()); } - template - bool get_aux_is_set(FeatureHandle fh, unsigned int id) - { - return fh->get_aux_is_set(id); - } + template + bool aux_is_set(FeatureHandle fh, unsigned int id) + { return fh->aux_is_set(id); } - template - bool aux_has_no_data(FeatureHandle fh, unsigned int id) - { - const Object& o = fh->get_aux_source(id); + template + bool aux_has_no_data(FeatureHandle fh, unsigned int id) { + const Object& o = fh->aux_source(id); Halfedge_handle h; Vertex_handle v; Face_handle f; @@ -1372,16 +1202,13 @@ protected: // aux source of a vertex can be face, halfedge or vertex // this is why we start with a check for a face, then halfedge // and last vertex - if (assign(f, o)) - return f->has_no_data(); - else if (assign(h, o)) - return h->has_no_data(); - else - { + if (assign(f, o)) return f->has_no_env_data(); + else if (assign(h, o)) return h->has_no_env_data(); + else { CGAL_assertion_code(bool b =) assign(v, o); CGAL_assertion(b); - return v->has_no_data(); + return v->has_no_env_data(); } } @@ -1391,96 +1218,77 @@ protected: // methods for assertion and checking //*************************************************************************** - void get_data_iterators(Object aux_src, + void env_data_iterators(Object aux_src, Envelope_data_iterator& begin, - Envelope_data_iterator& end) - { + Envelope_data_iterator& end) { CGAL_assertion(!aux_src.is_empty()); Vertex_handle v; Halfedge_handle h; Face_handle f; - if (assign(v, aux_src)) - { - begin = v->begin_data(); - end = v->end_data(); + if (assign(v, aux_src)) { + begin = v->begin_env_data(); + end = v->end_env_data(); } - else if (assign(h, aux_src)) - { - begin = h->begin_data(); - end = h->end_data(); + else if (assign(h, aux_src)) { + begin = h->begin_env_data(); + end = h->end_env_data(); } - else - { + else { CGAL_assertion(assign(f, aux_src)); assign(f, aux_src); - begin = f->begin_data(); - end = f->end_data(); + begin = f->begin_env_data(); + end = f->end_env_data(); } } - bool is_equal_data(Object o, - Envelope_data_iterator begin, - Envelope_data_iterator end) - { + + bool is_equal_env_data(Object o, + Envelope_data_iterator begin, + Envelope_data_iterator end) { + CGAL_assertion(! o.is_empty()); + Vertex_handle v; + Halfedge_handle h; + Face_handle f; + + if (assign(v, o)) return v->is_equal_env_data(begin, end); + else if (assign(h, o)) return h->is_equal_env_data(begin, end); + else { + CGAL_assertion(assign(f, o)); + assign(f, o); + return f->is_equal_env_data(begin, end); + } + } + bool has_equal_env_data(Object o, + Envelope_data_iterator begin, + Envelope_data_iterator end) { CGAL_assertion(!o.is_empty()); Vertex_handle v; Halfedge_handle h; Face_handle f; - if (assign(v, o)) - return v->is_equal_data(begin, end); - else if (assign(h, o)) - return h->is_equal_data(begin, end); - else - { + if (assign(v, o)) return v->has_equal_env_data(begin, end); + else if (assign(h, o)) return h->has_equal_env_data(begin, end); + else { CGAL_assertion(assign(f, o)); assign(f, o); - return f->is_equal_data(begin, end); - } - } - bool has_equal_data(Object o, - Envelope_data_iterator begin, - Envelope_data_iterator end) - { - CGAL_assertion(!o.is_empty()); - Vertex_handle v; - Halfedge_handle h; - Face_handle f; - - if (assign(v, o)) - return v->has_equal_data(begin, end); - else if (assign(h, o)) - return h->has_equal_data(begin, end); - else - { - CGAL_assertion(assign(f, o)); - assign(f, o); - return f->has_equal_data(begin, end); + return f->has_equal_env_data(begin, end); } } - void print_decisions(Minimization_diagram_2& result) - { - Face_iterator fi = result.faces_begin(); - for (; fi != result.faces_end(); ++fi) - { - if (fi->is_unbounded()) - continue; + void print_decisions(Minimization_diagram_2& result) { + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) { + if (fi->is_unbounded()) continue; Face_handle fh = fi; Ccb_halfedge_circulator face_hec = fh->outer_ccb(); Ccb_halfedge_circulator face_hec_begin = face_hec; - do { - ++face_hec; - } while(face_hec != face_hec_begin); + do ++face_hec; + while (face_hec != face_hec_begin); - Inner_ccb_iterator inner_iter = fh->holes_begin(); - for (; inner_iter != fh->holes_end(); ++inner_iter) - - { + for (auto inner_iter = fh->holes_begin(); inner_iter != fh->holes_end(); + ++inner_iter) { face_hec = face_hec_begin = (*inner_iter); - do { - ++face_hec; - } while(face_hec != face_hec_begin); + do ++face_hec; + while(face_hec != face_hec_begin); } } } @@ -1488,48 +1296,37 @@ protected: // confirm that aux source and decision are set over all minimization // diagram features - bool check_resolve_was_ok(Minimization_diagram_2& result) - { + bool check_resolve_was_ok(Minimization_diagram_2& result) { bool all_ok = true; - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; - /* if (vh->get_is_fake()) - * continue; - */ - - all_ok &= (vh->get_aux_is_set(0)); + // if (vh->is_fake()) continue; + all_ok &= (vh->aux_is_set(0)); CGAL_assertion_msg(all_ok, "aux source (0) not set over vertex"); - all_ok &= (vh->get_aux_is_set(1)); + all_ok &= (vh->aux_is_set(1)); CGAL_assertion_msg(all_ok, "aux source (1) not set over vertex"); all_ok &= (vh->is_decision_set()); CGAL_assertion_msg(all_ok, "decision was not set over vertex"); } - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi) + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); ++hi) { Halfedge_handle hh = hi; - /* if (hh->get_is_fake()) - * continue; - */ + // if (hh->is_fake()) continue; - all_ok &= (hh->get_aux_is_set(0)); + all_ok &= (hh->aux_is_set(0)); CGAL_assertion_msg(all_ok, "aux source (0) not set over edge"); - all_ok &= (hh->get_aux_is_set(1)); + all_ok &= (hh->aux_is_set(1)); CGAL_assertion_msg(all_ok, "aux source (1) not set over edge"); all_ok &= (hh->is_decision_set()); CGAL_assertion_msg(all_ok, "decision was not set over edge"); } - Face_iterator fi = result.faces_begin(); - for (; fi != result.faces_end(); ++fi) - { - Face_handle fh = fi; - all_ok &= (fh->get_aux_is_set(0)); + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) { + Face_handle fh = fi; + all_ok &= (fh->aux_is_set(0)); CGAL_assertion_msg(all_ok, "aux source (0) not set over face"); - all_ok &= (fh->get_aux_is_set(1)); + all_ok &= (fh->aux_is_set(1)); CGAL_assertion_msg(all_ok, "aux source (1) not set over face"); all_ok &= (fh->is_decision_set()); CGAL_assertion_msg(all_ok, "decision was not set over face"); @@ -1539,44 +1336,38 @@ protected: // confirm that envelope data is set over all minimization diagram features // and that no fake feature are left - bool is_envelope_valid(Minimization_diagram_2& result) - { + bool is_envelope_valid(Minimization_diagram_2& result) { bool all_ok = true; - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; - all_ok &= (vh->get_is_set()); + all_ok &= (vh->is_env_set()); CGAL_assertion_msg(all_ok, "data not set over vertex"); - all_ok &= (!vh->has_no_data()); + all_ok &= (!vh->has_no_env_data()); CGAL_assertion_msg(all_ok, "data empty over vertex"); - /* all_ok &= (!vh->get_is_fake());*/ + /* all_ok &= (!vh->is_fake());*/ CGAL_assertion_msg(all_ok, "fake vertex in envelope"); } - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi) + + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); ++hi) { Halfedge_handle hh = hi; - all_ok &= (hh->get_is_set()); - if (!all_ok) - std::cerr << "edge: " << hh->curve() << std::endl; + all_ok &= (hh->is_env_set()); + if (!all_ok) std::cerr << "edge: " << hh->curve() << std::endl; CGAL_assertion_msg(all_ok, "data not set over edge"); - all_ok &= (!hh->has_no_data()); - if (!all_ok) - std::cerr << "edge: " << hh->curve() << std::endl; + all_ok &= (!hh->has_no_env_data()); + if (!all_ok) std::cerr << "edge: " << hh->curve() << std::endl; CGAL_assertion_msg(all_ok, "data empty over edge"); - /*all_ok &= (!hh->get_is_fake());*/ + /*all_ok &= (!hh->is_fake());*/ CGAL_assertion_msg(all_ok, "fake edge in envelope"); } - Face_iterator fi = result.faces_begin(); - for (; fi != result.faces_end(); ++fi) - { + + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) { Face_handle fh = fi; - all_ok &= (fh->get_is_set()); + all_ok &= (fh->is_env_set()); CGAL_assertion_msg(all_ok, "data not set over face"); } return all_ok; @@ -1584,159 +1375,147 @@ protected: // observer for the minimization diagram // keeps the relevant data in the new faces - class Keep_face_data_observer : public Md_observer - { + class Keep_face_data_observer : public Md_observer { public: - typedef typename Minimization_diagram_2::Face_handle Face_handle; + using Base_aos = typename Minimization_diagram_2::Base_aos; + using Face_handle = typename Base_aos::Face_handle; - Keep_face_data_observer(Minimization_diagram_2& arr) : - Md_observer(arr) - {} + Keep_face_data_observer(Base_aos& arr) : Md_observer(arr) {} virtual void after_split_face(Face_handle org_f, Face_handle new_f, - bool /* is_hole*/) - { + bool /* is_hole*/) override { // update data in the new face from the original face - if (org_f->get_aux_is_set(0)) - new_f->set_aux_source(0, org_f->get_aux_source(0)); - if (org_f->get_aux_is_set(1)) - new_f->set_aux_source(1, org_f->get_aux_source(1)); + if (org_f->aux_is_set(0)) + new_f->set_aux_source(0, org_f->aux_source(0)); + if (org_f->aux_is_set(1)) + new_f->set_aux_source(1, org_f->aux_source(1)); if (org_f->is_decision_set()) - new_f->set_decision(org_f->get_decision()); + new_f->set_decision(org_f->decision()); } }; // observer for the minimization diagram // keeps the relevant data in the new edges & vertices - class Keep_edge_data_observer : public Md_observer - { + class Keep_edge_data_observer : public Md_observer { public: - typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle; - typedef typename Minimization_diagram_2::Vertex_handle Vertex_handle; - typedef typename Minimization_diagram_2::X_monotone_curve_2 - X_monotone_curve_2; + using Base_aos = typename Minimization_diagram_2::Base_aos; + using Vertex_handle = typename Base_aos::Vertex_handle; + using Halfedge_handle = typename Base_aos::Halfedge_handle; + using X_monotone_curve_2 = typename Base_aos::X_monotone_curve_2; - typedef typename Envelope_divide_and_conquer_3::Self Self; - Keep_edge_data_observer(Minimization_diagram_2& arr, - Self* b) : + using Self = typename Envelope_divide_and_conquer_3::Self; + Keep_edge_data_observer(Base_aos& arr, Self* b) : Md_observer(arr), base(b) - { - CGAL_assertion(base != nullptr); - } + { CGAL_assertion(base != nullptr); } - /* virtual void before_split_edge (Halfedge_handle e, - * Vertex_handle v, - * const X_monotone_curve_2& c1, - * const X_monotone_curve_2& c2) + /* virtual void before_split_edge(Halfedge_handle e, + * Vertex_handle v, + * const X_monotone_curve_2& c1, + * const X_monotone_curve_2& c2) * {} */ virtual void after_split_edge(Halfedge_handle he1, Halfedge_handle he2) - { + override { // update data of the new vertex, which is the common vertex of he1 and // he2, and of the new edge according to the data in the original edge CGAL_assertion(he2->source() == he1->target()); Vertex_handle new_vertex; -// if (he2->source() == he1->target() || -// he2->source() == he1->source()) + // if (he2->source() == he1->target() || he2->source() == he1->source()) new_vertex = he2->source(); -// else -// new_vertex = he2->target(); + // else new_vertex = he2->target(); CGAL_assertion(!new_vertex->is_decision_set()); - CGAL_assertion(!new_vertex->get_aux_is_set(0)); - CGAL_assertion(!new_vertex->get_aux_is_set(1)); + CGAL_assertion(!new_vertex->aux_is_set(0)); + CGAL_assertion(!new_vertex->aux_is_set(1)); // find the halfedge with the additional information, to be copied into // the second halfedge Halfedge_handle org_he = he1, new_he = he2; - if (org_he->is_decision_set()) - { - new_he->set_decision(org_he->get_decision()); - new_he->twin()->set_decision(org_he->get_decision()); - new_vertex->set_decision(org_he->get_decision()); + if (org_he->is_decision_set()) { + new_he->set_decision(org_he->decision()); + new_he->twin()->set_decision(org_he->decision()); + new_vertex->set_decision(org_he->decision()); } - if (org_he->get_aux_is_set(0)) - { - new_vertex->set_aux_source(0, org_he->get_aux_source(0)); - new_he->set_aux_source(0, org_he->get_aux_source(0)); - new_he->twin()->set_aux_source(0, org_he->twin()->get_aux_source(0)); + if (org_he->aux_is_set(0)) { + new_vertex->set_aux_source(0, org_he->aux_source(0)); + new_he->set_aux_source(0, org_he->aux_source(0)); + new_he->twin()->set_aux_source(0, org_he->twin()->aux_source(0)); } - if (org_he->get_aux_is_set(1)) - { - new_vertex->set_aux_source(1, org_he->get_aux_source(1)); - new_he->set_aux_source(1, org_he->get_aux_source(1)); - new_he->twin()->set_aux_source(1, org_he->twin()->get_aux_source(1)); + if (org_he->aux_is_set(1)) { + new_vertex->set_aux_source(1, org_he->aux_source(1)); + new_he->set_aux_source(1, org_he->aux_source(1)); + new_he->twin()->set_aux_source(1, org_he->twin()->aux_source(1)); } - /*new_he->set_is_fake(org_he->get_is_fake());*/ - /*new_he->twin()->set_is_fake(org_he->get_is_fake());*/ - /*new_vertex->set_is_fake(org_he->get_is_fake());*/ + // new_he->set_is_fake(org_he->is_fake()); + // new_he->twin()->set_is_fake(org_he->is_fake()); + // new_vertex->set_is_fake(org_he->is_fake()); // update all new bools new_he->set_is_equal_aux_data_in_face - (0, org_he->get_is_equal_aux_data_in_face(0)); + (0, org_he->is_equal_aux_data_in_face(0)); new_he->twin()->set_is_equal_aux_data_in_face - (0, org_he->twin()->get_is_equal_aux_data_in_face(0)); + (0, org_he->twin()->is_equal_aux_data_in_face(0)); new_he->set_is_equal_aux_data_in_face - (1, org_he->get_is_equal_aux_data_in_face(1)); + (1, org_he->is_equal_aux_data_in_face(1)); new_he->twin()->set_is_equal_aux_data_in_face - (1, org_he->twin()->get_is_equal_aux_data_in_face(1)); + (1, org_he->twin()->is_equal_aux_data_in_face(1)); new_he->set_has_equal_aux_data_in_face - (0, org_he->get_has_equal_aux_data_in_face(0)); + (0, org_he->has_equal_aux_data_in_face(0)); new_he->twin()->set_has_equal_aux_data_in_face - (0, org_he->twin()->get_has_equal_aux_data_in_face(0)); + (0, org_he->twin()->has_equal_aux_data_in_face(0)); new_he->set_has_equal_aux_data_in_face - (1, org_he->get_has_equal_aux_data_in_face(1)); + (1, org_he->has_equal_aux_data_in_face(1)); new_he->twin()->set_has_equal_aux_data_in_face - (1, org_he->twin()->get_has_equal_aux_data_in_face(1)); + (1, org_he->twin()->has_equal_aux_data_in_face(1)); // new_he->target is the original edge's target, and org_he->target // is the new vertex new_he->set_is_equal_aux_data_in_target - (0, org_he->get_is_equal_aux_data_in_target(0)); + (0, org_he->is_equal_aux_data_in_target(0)); new_he->set_is_equal_aux_data_in_target - (1, org_he->get_is_equal_aux_data_in_target(1)); + (1, org_he->is_equal_aux_data_in_target(1)); org_he->set_is_equal_aux_data_in_target(0, true); org_he->set_is_equal_aux_data_in_target(1, true); new_he->set_has_equal_aux_data_in_target - (0, org_he->get_has_equal_aux_data_in_target(0)); + (0, org_he->has_equal_aux_data_in_target(0)); new_he->set_has_equal_aux_data_in_target - (1, org_he->get_has_equal_aux_data_in_target(1)); + (1, org_he->has_equal_aux_data_in_target(1)); org_he->set_has_equal_aux_data_in_target (0, !base->aux_has_no_data(org_he, 0)); org_he->set_has_equal_aux_data_in_target (1, !base->aux_has_no_data(org_he, 1)); new_he->set_has_equal_aux_data_in_target_and_face - (0, org_he->get_has_equal_aux_data_in_target_and_face(0)); + (0, org_he->has_equal_aux_data_in_target_and_face(0)); new_he->set_has_equal_aux_data_in_target_and_face - (1, org_he->get_has_equal_aux_data_in_target_and_face(1)); + (1, org_he->has_equal_aux_data_in_target_and_face(1)); org_he->set_has_equal_aux_data_in_target_and_face - (0, org_he->get_has_equal_aux_data_in_face(0)); + (0, org_he->has_equal_aux_data_in_face(0)); org_he->set_has_equal_aux_data_in_target_and_face - (1, org_he->get_has_equal_aux_data_in_face(1)); + (1, org_he->has_equal_aux_data_in_face(1)); // new_he->source is the new vertex, and org_he->source is the // original vertex new_he->twin()->set_is_equal_aux_data_in_target(0, true); new_he->twin()->set_is_equal_aux_data_in_target(1, true); new_he->twin()->set_has_equal_aux_data_in_target - (0,!base->aux_has_no_data(org_he, 0)); + (0, ! base->aux_has_no_data(org_he, 0)); new_he->twin()->set_has_equal_aux_data_in_target - (1,!base->aux_has_no_data(org_he, 1)); + (1, ! base->aux_has_no_data(org_he, 1)); new_he->twin()->set_has_equal_aux_data_in_target_and_face - (0, org_he->twin()->get_has_equal_aux_data_in_face(0)); + (0, org_he->twin()->has_equal_aux_data_in_face(0)); new_he->twin()->set_has_equal_aux_data_in_target_and_face - (1, org_he->twin()->get_has_equal_aux_data_in_face(1)); + (1, org_he->twin()->has_equal_aux_data_in_face(1)); } protected: @@ -1748,14 +1527,13 @@ protected: // A BFS visitor class which collects the faces that need resolving // in a list according to the discover time // In our case graph vertices represent minimization diagram faces - template - class Faces_order_bfs_visitor : public boost::default_bfs_visitor - { + template + class Faces_order_bfs_visitor : public boost::default_bfs_visitor { public: - typedef typename Envelope_divide_and_conquer_3::Self Self; + using Self = typename Envelope_divide_and_conquer_3::Self; protected: const IndexMap* index_map; // Mapping vertices to indices @@ -1763,31 +1541,26 @@ protected: Self* base; public: - // Constructor. Faces_order_bfs_visitor(const IndexMap& imap, std::list& f, Self* b) : index_map(&imap), faces(f), base(b) - { - CGAL_assertion(base != nullptr); - } + { CGAL_assertion(base != nullptr); } // Write the discover time for a given vertex. template - void discover_vertex(Vertex fh, const Graph&) - { + void discover_vertex(Vertex fh, const Graph&) { // first we check if we can set the decision immediately // if a surface of one map doesn't exist, then we set the second surface if (base->aux_has_no_data(fh, 0) && !base->aux_has_no_data(fh, 1)) fh->set_decision(DAC_DECISION_SECOND); - else if (base->aux_has_no_data(fh, 0) && base->aux_has_no_data(fh, 1)) - { + else if (base->aux_has_no_data(fh, 0) && base->aux_has_no_data(fh, 1)) { fh->set_decision(EQUAL); - fh->set_no_data(); + fh->set_no_env_data(); } else if (!base->aux_has_no_data(fh, 0) && base->aux_has_no_data(fh, 1)) fh->set_decision(DAC_DECISION_FIRST); @@ -1801,7 +1574,7 @@ protected: #endif protected: - Envelope_resolver* resolver; + Envelope_resolver* m_resolver; const Traits* m_geom_traits; bool m_own_traits; bool m_is_lower; diff --git a/Envelope_3/include/CGAL/Envelope_3/Envelope_element_visitor_3.h b/Envelope_3/include/CGAL/Envelope_3/Envelope_element_visitor_3.h index e5184ba9a2a..815b23f6cc2 100644 --- a/Envelope_3/include/CGAL/Envelope_3/Envelope_element_visitor_3.h +++ b/Envelope_3/include/CGAL/Envelope_3/Envelope_element_visitor_3.h @@ -7,8 +7,9 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Efi Fogel #ifndef CGAL_ENVELOPE_ELEMENT_VISITOR_3_H #define CGAL_ENVELOPE_ELEMENT_VISITOR_3_H @@ -16,22 +17,21 @@ #include +#include +#include +#include +#include + #include #include #include #include -#include #include #include #include #include #include -#include -#include -#include -#include - namespace CGAL { // Return the comparison result of the halfedge's source and target vertices. @@ -42,102 +42,90 @@ namespace CGAL { // this class does the resolving of edge and face in the divide & conquer // algorithm it should handle all faces (it supports holes in the face) -template -class Envelope_element_visitor_3 -{ +template +class Envelope_element_visitor_3 { public: - typedef EnvelopeTraits_3 Traits; - typedef typename Traits::Multiplicity Multiplicity; - typedef typename Traits::Surface_3 Surface_3; - typedef typename Traits::Xy_monotone_surface_3 Xy_monotone_surface_3; - typedef typename Traits::Equal_2 Equal_2; + using Traits = EnvelopeTraits_3; + using Minimization_diagram_2 = MinimizationDiagram_2; - typedef MinimizationDiagram_2 Minimization_diagram_2; - typedef typename Traits::Point_2 Point_2; - typedef typename Traits::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Minimization_diagram_2::Are_all_sides_oblivious_category - Are_all_sides_oblivious_category; +private: + using Md2 = Minimization_diagram_2; + +public: + using Multiplicity = typename Traits::Multiplicity; + using Surface_3 = typename Traits::Surface_3; + using Xy_monotone_surface_3 = typename Traits::Xy_monotone_surface_3; + using Equal_2 = typename Traits::Equal_2; + + using Point_2 = typename Traits::Point_2; + using X_monotone_curve_2 = typename Traits::X_monotone_curve_2; + using Are_all_sides_oblivious_category = + typename Md2::Are_all_sides_oblivious_category; protected: class Copied_face_zone_visitor; - typedef Envelope_element_visitor_3 Self; - typedef typename Minimization_diagram_2::Halfedge_const_handle - Halfedge_const_handle; - typedef typename Minimization_diagram_2::Halfedge_const_iterator - Halfedge_const_iterator; - typedef typename Minimization_diagram_2::Halfedge_handle - Halfedge_handle; - typedef typename Minimization_diagram_2::Halfedge_iterator - Halfedge_iterator; - typedef typename Minimization_diagram_2::Face_const_handle - Face_const_handle; - typedef typename Minimization_diagram_2::Face_handle - Face_handle; - typedef typename Minimization_diagram_2::Face_iterator - Face_iterator; - typedef typename Minimization_diagram_2::Vertex_const_handle - Vertex_const_handle; - typedef typename Minimization_diagram_2::Vertex_handle - Vertex_handle; - typedef typename Minimization_diagram_2::Vertex_iterator - Vertex_iterator; - typedef typename Minimization_diagram_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; - typedef typename Minimization_diagram_2::Inner_ccb_iterator - Inner_ccb_iterator; - typedef typename Minimization_diagram_2::Outer_ccb_iterator - Outer_ccb_iterator; - typedef typename Minimization_diagram_2::Isolated_vertex_iterator - Isolated_vertex_iterator; - typedef typename Minimization_diagram_2::Topology_traits - Topology_traits; - typedef typename Minimization_diagram_2::Dcel Dcel; - typedef typename Minimization_diagram_2::Dcel::Dcel_data_iterator - Envelope_data_iterator; + using Self = Envelope_element_visitor_3; - typedef Arr_observer Md_observer; - typedef Arr_accessor Md_accessor; + using Vertex_handle = typename Md2::Vertex_handle; + using Halfedge_handle = typename Md2::Halfedge_handle; + using Face_handle = typename Md2::Face_handle; + using Vertex_const_handle = typename Md2::Vertex_const_handle; + using Halfedge_const_handle = typename Md2::Halfedge_const_handle; + using Face_const_handle = typename Md2::Face_const_handle; + using Vertex_iterator = typename Md2::Vertex_iterator; + using Halfedge_iterator = typename Md2::Halfedge_iterator; + using Face_iterator = typename Md2::Face_iterator; - typedef typename Topology_traits::Default_point_location_strategy - Md_point_location; - typedef typename Topology_traits::Zone_insertion_visitor - Md_insert_zone_visitor; + using Halfedge_const_iterator = typename Md2::Halfedge_const_iterator; + using Ccb_halfedge_circulator = typename Md2::Ccb_halfedge_circulator; + using Inner_ccb_iterator = typename Md2::Inner_ccb_iterator; + using Outer_ccb_iterator = typename Md2::Outer_ccb_iterator; + using Isolated_vertex_iterator = typename Md2::Isolated_vertex_iterator; + using Topology_traits = typename Md2::Topology_traits; + using Dcel = typename Md2::Dcel; + using Face = typename Dcel::Face; + using Envelope_data_iterator = typename Face::Data_iterator; - typedef std::list Halfedges_list; - typedef typename std::list::iterator Halfedges_list_iterator; + using Md_observer = typename Md2::Observer; + using Md_accessor = Arr_accessor; - typedef std::pair Halfedge_w_type; - typedef std::list Halfedges_w_type_list; + using Md_point_location = + typename Topology_traits::Default_point_location_strategy; + using Md_insert_zone_visitor = + typename Topology_traits::Zone_insertion_visitor; - typedef std::list Vertices_list; - typedef typename std::list::iterator Vertices_list_iterator; + using Halfedges_list = std::list; + using Halfedges_list_iterator = typename std::list::iterator; - typedef std::list Faces_list; - typedef typename std::list::iterator Faces_list_iterator; + using Halfedge_w_type = std::pair; + using Halfedges_w_type_list = std::list; - typedef Unique_hash_map Vertices_hash; - typedef Unique_hash_map Halfedges_hash; - typedef Unique_hash_map - Halfedges_hash_w_type; - typedef Unique_hash_map Faces_hash; + using Vertices_list = std::list; + using Vertices_list_iterator = typename std::list::iterator; - typedef Unique_hash_map Vertices_map; - typedef Unique_hash_map - Halfedges_map; - typedef Unique_hash_map Faces_map; + using Faces_list = std::list; + using Faces_list_iterator = typename std::list::iterator; - typedef Unique_hash_map - Vertices_to_edges_map; + using Vertices_hash = Unique_hash_map; + using Halfedges_hash = Unique_hash_map; + using Halfedges_hash_w_type = Unique_hash_map; + using Faces_hash = Unique_hash_map; - typedef std::pair Intersection_curve; - typedef std::list> Intersections_list; + using Vertices_map = Unique_hash_map; + using Halfedges_map = Unique_hash_map; + using Faces_map = Unique_hash_map; + + using Vertices_to_edges_map = Unique_hash_map; + + using Intersection_curve = std::pair; + using Intersections_list = + std::list>; // this is used in the resolve edge process - typedef Triple Point_2_with_info; - struct Points_compare - { + using Point_2_with_info = Triple; + + struct Points_compare { protected: const Traits* p_traits; @@ -145,22 +133,19 @@ protected: // Constructor Points_compare(const Traits& geom_traits) : p_traits(&geom_traits) {} - bool operator()(const Point_2_with_info& p1, - const Point_2_with_info& p2) const - { + bool operator()(const Point_2_with_info& p1, const Point_2_with_info& p2) + const { // The original code seemed to presume that two Points are never equal // This is not true, there are various counter examples. // e.g the intersection of surf1 and surf2 may have ending edge and // a starting edge on the to be resolved edge - return - p_traits->compare_xy_2_object()(p1.first, p2.first) == SMALLER; + return p_traits->compare_xy_2_object()(p1.first, p2.first) == SMALLER; } }; public: // c'tor - Envelope_element_visitor_3(Envelope_type t = ENVELOPE_LOWER) - { + Envelope_element_visitor_3(Envelope_type t = ENVELOPE_LOWER) { // Allocate the traits. m_traits = new Traits; own_traits = true; @@ -168,8 +153,7 @@ public: } Envelope_element_visitor_3(const Traits* tr, - Envelope_type t = ENVELOPE_LOWER) - { + Envelope_type t = ENVELOPE_LOWER) { // Set the traits. m_traits = tr; own_traits = false; @@ -177,35 +161,28 @@ public: } // virtual destructor. - virtual ~Envelope_element_visitor_3() - { - // Free the traits object, if necessary. - if (own_traits) - delete m_traits; - } + virtual ~Envelope_element_visitor_3() { if (own_traits) delete m_traits; } // get a face with 2 surfaces defined over it, and compute the arrangement // of the/ envelope of these surfaces over the face - void resolve(Face_handle face, Minimization_diagram_2& result) - { - CGAL_assertion(face->get_aux_is_set(0)); - CGAL_assertion(face->get_aux_is_set(1)); + void resolve(Face_handle face, Minimization_diagram_2& result) { + CGAL_assertion(face->aux_is_set(0)); + CGAL_assertion(face->aux_is_set(1)); // we are interested with the envelope's shape over the current face, // so we only need to check the first surface from each group, since // all the surfaces in a group overlap over the current face. - const Xy_monotone_surface_3& surf1 = get_aux_surface(face, 0); - const Xy_monotone_surface_3& surf2 = get_aux_surface(face, 1); + const Xy_monotone_surface_3& surf1 = aux_surface(face, 0); + const Xy_monotone_surface_3& surf2 = aux_surface(face, 1); // find the projected intersections of the surfaces. if none - we have // a simple case: // need only resolve non-intersecting and return std::list> inter_objs; - get_projected_intersections(surf1, surf2, std::back_inserter(inter_objs)); + projected_intersections(surf1, surf2, std::back_inserter(inter_objs)); - if (inter_objs.size() == 0) - { + if (inter_objs.size() == 0) { // here for resolve we can compare the surfaces over the edges only // (no need for left/right versions) Comparison_result cur_res = resolve_minimal_face(face); @@ -230,7 +207,7 @@ public: Vertices_map map_copied_to_orig_vertices; // here we maintain a mapping between faces in the copied arrangement and // their corresponding face from result - Faces_map map_copied_to_orig_faces; + Faces_map map_copied_to_orig_faces; // now, insert the face's boundary into the temporary minimization diagram // the face is assumed to have outer boundary, and may also have holes, @@ -244,7 +221,6 @@ public: CGAL_assertion(copied_face_arr.is_valid()); map_copied_to_orig_faces[copied_face] = face; - // we use our zone visitor, which only inserts into the arrangement the // points and curves which are inside the copied face // it updates the result arrangement at the same time (action after action @@ -258,7 +234,7 @@ public: // projected intersection that created it. Halfedges_w_type_list result_new_edges; // 3. the collection of faces that form the face before any insertion - Faces_list result_face_parts; + Faces_list result_face_parts; // 4. the collection of special vertices, which contains: // - new vertices that were created inside the original face // (both isolated and not isolated) @@ -285,10 +261,8 @@ public: Md_point_location pl(copied_face_arr); for (auto inter_objs_it = inter_objs.begin(); - inter_objs_it != inter_objs.end(); ++inter_objs_it) - { - if (const Point_2* point = std::get_if(&(*inter_objs_it))) - { + inter_objs_it != inter_objs.end(); ++inter_objs_it) { + if (const Point_2* point = std::get_if(&(*inter_objs_it))) { // intersection can be a point when the surfaces only touch each other. // we are only interested in the points that are inside the face or // on its boundary. @@ -299,15 +273,14 @@ public: // the above information is available in zone_visitor insert_point(copied_face_arr, *point, pl, zone_visitor); } - else if (const Intersection_curve* curve = std::get_if(&(*inter_objs_it))) - { + else if (const auto* curve = + std::get_if(&(*inter_objs_it))) { zone_visitor.set_current_intersection_type(curve->second); insert(copied_face_arr, curve->first, pl, zone_visitor); CGAL_assertion(copied_face_arr.is_valid()); CGAL_assertion(result.is_valid()); } - else - CGAL_error_msg( "wrong projected intersection type"); + else CGAL_error_msg( "wrong projected intersection type"); } zone_visitor.finish(); @@ -316,20 +289,18 @@ public: // in order to use resolve_minimal_face with intersection halfedge, we // go over the new edges, and set data over their faces - typename Halfedges_w_type_list::iterator new_edge_it; - for (new_edge_it = result_new_edges.begin(); - new_edge_it != result_new_edges.end(); ++new_edge_it) - { + for (auto new_edge_it = result_new_edges.begin(); + new_edge_it != result_new_edges.end(); ++new_edge_it) { Halfedge_handle new_he = (*new_edge_it).first; Halfedge_handle new_he_twin = new_he->twin(); #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS Multiplicity itype = (*new_edge_it).second; #endif // set sources of the new edge - new_he->set_aux_source(0, face->get_aux_source(0)); - new_he->set_aux_source(1, face->get_aux_source(1)); - new_he_twin->set_aux_source(0, face->get_aux_source(0)); - new_he_twin->set_aux_source(1, face->get_aux_source(1)); + new_he->set_aux_source(0, face->aux_source(0)); + new_he->set_aux_source(1, face->aux_source(1)); + new_he_twin->set_aux_source(0, face->aux_source(0)); + new_he_twin->set_aux_source(1, face->aux_source(1)); // set data on new edges new_he->set_decision(EQUAL); @@ -340,8 +311,7 @@ public: // to f1, not only the opposite Face_handle f1 = new_he->face(), f2 = new_he_twin->face(); Comparison_result res; - if (!f1->is_decision_set() && !f2->is_decision_set()) - { + if (! f1->is_decision_set() && ! f2->is_decision_set()) { res = resolve_minimal_face(f1, &new_he); copy_data_by_comparison_result(face, f1, res); } @@ -350,38 +320,32 @@ public: // if the other face doesn't have its data, we resolve it using // the former result and the intersection type (if exists) - if (!f2->is_decision_set()) - { + if (! f2->is_decision_set()) { #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS - if (itype != 0) - { - res = convert_decision_to_comparison_result(f1->get_decision()); + if (itype != 0) { + res = convert_decision_to_comparison_result(f1->decision()); res = resolve_by_intersection_type(res, itype); CGAL_expensive_assertion_code (Comparison_result tmp_res = resolve_minimal_face(f2, &new_he_twin);); CGAL_expensive_assertion(tmp_res == res); } - else - res = resolve_minimal_face(f2, &new_he_twin); + else res = resolve_minimal_face(f2, &new_he_twin); #else res = resolve_minimal_face(f2, &new_he_twin); #endif copy_data_by_comparison_result(face, f2, res); } - if (!f1->is_decision_set()) - { + if (! f1->is_decision_set()) { #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS - if (itype != 0) - { - res = convert_decision_to_comparison_result(f2->get_decision()); + if (itype != 0) { + res = convert_decision_to_comparison_result(f2->decision()); res = resolve_by_intersection_type(res, itype); CGAL_expensive_assertion_code (Comparison_result tmp_res = resolve_minimal_face(f1, &new_he)); CGAL_expensive_assertion(tmp_res == res); } - else - res = resolve_minimal_face(f1, &new_he); + else res = resolve_minimal_face(f1, &new_he); #else res = resolve_minimal_face(f1, &new_he); #endif @@ -392,35 +356,31 @@ public: // we also need to check the faces incident to the halfedges in // special_edges since the envelope data over them should be computed // using compare_left/right versions - Halfedges_list_iterator special_edge_it; - for (special_edge_it = result_special_edges.begin(); - special_edge_it != result_special_edges.end(); ++special_edge_it) - { + for (auto special_edge_it = result_special_edges.begin(); + special_edge_it != result_special_edges.end(); ++special_edge_it) { // we assume that the halfedge given points to the correct face // (which is inside the original face) Halfedge_handle special_he = *special_edge_it; Face_handle f = special_he->face(); - if (!f->is_decision_set()) - { + if (! f->is_decision_set()) { Comparison_result res = resolve_minimal_face(f, &special_he); copy_data_by_comparison_result(face, f, res); } // take care for the edge, if necessary - if (!special_he->is_decision_set() && - can_copy_decision_from_face_to_edge(special_he)) - { - // if (!special_he->get_aux_is_set(0) || !special_he->get_aux_is_set(1)) + if (! special_he->is_decision_set() && + can_copy_decision_from_face_to_edge(special_he)) { + // if (!special_he->aux_is_set(0) || !special_he->aux_is_set(1)) // { // // this can only happen when the edge is fake, since the edge is on //// the face's boundary - // CGAL_assertion(special_he->get_is_fake()); - // special_he->set_aux_source(0, face->get_aux_source(0)); - // special_he->set_aux_source(1, face->get_aux_source(1)); - // special_he->twin()->set_aux_source(0, face->get_aux_source(0)); - // special_he->twin()->set_aux_source(1, face->get_aux_source(1)); + // CGAL_assertion(special_he->is_fake()); + // special_he->set_aux_source(0, face->aux_source(0)); + // special_he->set_aux_source(1, face->aux_source(1)); + // special_he->twin()->set_aux_source(0, face->aux_source(0)); + // special_he->twin()->set_aux_source(1, face->aux_source(1)); // } - //if (special_he->get_is_fake()) + //if (special_he->is_fake()) //{ // // this edge is not fake anymore, as it coincides with a projected // // intersection @@ -433,34 +393,27 @@ public: } // update data on special vertices - Vertices_list_iterator special_vertex_it; - for (special_vertex_it = result_special_vertices.begin(); - special_vertex_it != result_special_vertices.end(); ++special_vertex_it) - { + for (auto special_vertex_it = result_special_vertices.begin(); + special_vertex_it != result_special_vertices.end(); + ++special_vertex_it) { Vertex_handle special_v = *special_vertex_it; - if (!special_v->is_decision_set()) - { - - if (special_v->get_aux_is_set(0) && special_v->get_aux_is_set(1)) + if (! special_v->is_decision_set()) { + if (special_v->aux_is_set(0) && special_v->aux_is_set(1)) set_data_by_comparison_result(special_v, EQUAL); else // this is a new vertex inside the face, so we need to update its // aux source information from face also (done in method) copy_all_data_to_vertex(face, special_v); - } else - CGAL_assertion(special_v->get_aux_is_set(0) && \ - special_v->get_aux_is_set(1)); + } + else CGAL_assertion(special_v->aux_is_set(0) && special_v->aux_is_set(1)); } // assert all new faces got data set, if not, then maybe no curve cuts // the face, and should use regular resolve_minimal_face - typename std::list::iterator new_face_it; - for (new_face_it = result_face_parts.begin(); - new_face_it != result_face_parts.end(); ++new_face_it) - { + for (auto new_face_it = result_face_parts.begin(); + new_face_it != result_face_parts.end(); ++new_face_it) { Face_handle new_face = *new_face_it; - if (!new_face->is_decision_set()) - { + if (! new_face->is_decision_set()) { Comparison_result res = resolve_minimal_face(new_face); copy_data_by_comparison_result(face, new_face, res); } @@ -474,17 +427,15 @@ public: // get an edge with 2 surfaces defined over it, and split it to get the shape // of the envelope of these surfaces over the edge - void resolve(Halfedge_handle edge, Minimization_diagram_2& result) - { - const Xy_monotone_surface_3& surf1 = get_aux_surface(edge, 0); - const Xy_monotone_surface_3& surf2 = get_aux_surface(edge, 1); + void resolve(Halfedge_handle edge, Minimization_diagram_2& result) { + const Xy_monotone_surface_3& surf1 = aux_surface(edge, 0); + const Xy_monotone_surface_3& surf2 = aux_surface(edge, 1); // find the projected intersections std::list> inter_objs; - get_projected_intersections(surf1, surf2, std::back_inserter(inter_objs)); + projected_intersections(surf1, surf2, std::back_inserter(inter_objs)); - if (inter_objs.size() == 0) - { + if (inter_objs.size() == 0) { resolve_minimal_edge(edge, edge); #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS copy_data_to_edge_endpoints(edge); @@ -497,8 +448,7 @@ public: // we want to work on the halfedge going from left to right // we use HE_COMP_RES so this code can compile both with Arr_2 // and with Aos_2. - if (HE_COMP_RES(edge) != SMALLER) - edge = edge->twin(); + if (HE_COMP_RES(edge) != SMALLER) edge = edge->twin(); Vertex_handle original_src = edge->source(); Vertex_handle original_trg = edge->target(); @@ -512,43 +462,39 @@ public: // we associate with every point 2 flags: // 1. is the point a left endpoint of an overlapping segment // 2. is the point a right endpoint of an overlapping segment - typedef std::vector Points_vec; - Points_vec split_points; + typedef std::vector Points_vec; + Points_vec split_points; bool is_min_end_at_inf = false; bool is_max_end_at_inf = false; for (auto inter_objs_it = inter_objs.begin(); - inter_objs_it != inter_objs.end(); ++inter_objs_it) - { - if (const Point_2* point = std::get_if(&(*inter_objs_it))) - { + inter_objs_it != inter_objs.end(); ++inter_objs_it) { + if (const Point_2* point = std::get_if(&(*inter_objs_it))) { // if the point is on the curve, should add it the split points // list, otherwise, it is irrelevant and should be ignored if (is_point_on_curve(*point, original_cv)) split_points.push_back(Point_2_with_info(*point, false, false)); } - else if (const Intersection_curve* icurve = std::get_if(&(*inter_objs_it))) - { + else if (const auto* icurve = + std::get_if(&(*inter_objs_it))) { const X_monotone_curve_2& x_curve = icurve->first; // find the intersection points and overlapping segments with the // original curve and insert them to the list of split points // intersect the x-monotone curve with the edge's curve - typedef std::pair Intersect_point_2; - std::list> intersections_list; + typedef std::pair Intersect_point_2; + std::list> + intersections_list; m_traits->intersect_2_object()(x_curve, original_cv, std::back_inserter(intersections_list)); - for (auto inter_it = intersections_list.begin(); inter_it != intersections_list.end(); ++inter_it) - { - if (const Intersect_point_2* ip = std::get_if(&(*inter_it))) - { + for (auto inter_it = intersections_list.begin(); + inter_it != intersections_list.end(); ++inter_it) { + if (const auto* ip = std::get_if(&(*inter_it))) split_points.push_back(Point_2_with_info(ip->first, false, false)); - } - else - { - const X_monotone_curve_2* icv = std::get_if(&(*inter_it)); + else { + const auto* icv = std::get_if(&(*inter_it)); CGAL_assertion(icv != nullptr); // we will add the *icv end points to the split_points, unless @@ -571,21 +517,18 @@ public: (*icv, ARR_MAX_END) == ARR_INTERIOR) split_points.push_back (Point_2_with_info(m_traits->construct_max_vertex_2_object() - (*icv), - false, true)); + (*icv), false, true)); else is_max_end_at_inf = true; } } } - else - CGAL_error_msg( "wrong projected intersection type"); + else CGAL_error_msg( "wrong projected intersection type"); } // if there aren't any split points, we can finish - if (split_points.empty()) - { + if (split_points.empty()) { resolve_minimal_edge(edge, edge); #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS copy_data_to_edge_endpoints(edge); @@ -606,20 +549,19 @@ public: // by checking the first point in the list bool source_is_special = false; CGAL_assertion(split_points.size() >= 1); - if ((!original_src->is_at_open_boundary() && + if ((! original_src->is_at_open_boundary() && m_traits->equal_2_object()(split_points[0].first, original_src->point())) || (original_src->is_at_open_boundary() && is_min_end_at_inf)) { source_is_special = true; - if (split_points.front().third == true) - overlaps++; + if (split_points.front().third == true) ++overlaps; } // check if target is a special vertex, by checking the last point in // the list bool target_is_special = false; - if ((!original_trg->is_at_open_boundary() && + if ((! original_trg->is_at_open_boundary() && m_traits->equal_2_object()(split_points[split_points.size()-1].first, original_trg->point())) || (original_trg->is_at_open_boundary() && is_max_end_at_inf)) @@ -637,8 +579,7 @@ public: // cur_part is the part of the original edge that might be split Halfedge_handle cur_part = edge; - for (unsigned int i = 0; i < split_points.size(); ++i) - { + for (unsigned int i = 0; i < split_points.size(); ++i) { Point_2_with_info cur_p = split_points[i]; // if we get to the target vertex, we end the loop, since no more splits @@ -650,11 +591,9 @@ public: Vertex_handle cur_src_vertex = cur_part->source(); // check that the current split point is not already a vertex - if ((!cur_src_vertex->is_at_open_boundary() && - !m_traits->equal_2_object()(cur_p.first, cur_src_vertex->point())) || - cur_src_vertex->is_at_open_boundary()) - - { + if ((! cur_src_vertex->is_at_open_boundary() && + ! m_traits->equal_2_object()(cur_p.first, cur_src_vertex->point())) || + cur_src_vertex->is_at_open_boundary()) { // split the edge in this point X_monotone_curve_2 a,b; @@ -678,24 +617,20 @@ public: // involved we can set both aux data on it. otherwise we should use // the traits compare method. Comparison_result finished_part_res; - if (overlaps > 0) - finished_part_res = EQUAL; - else - finished_part_res = resolve_minimal_edge(edge, finished_part); + if (overlaps > 0) finished_part_res = EQUAL; + else finished_part_res = resolve_minimal_edge(edge, finished_part); finished_part->set_decision(finished_part_res); finished_part->twin()->set_decision(finished_part_res); - if (finished_part == edge) - first_part_res = finished_part_res; + if (finished_part == edge) first_part_res = finished_part_res; } // check the overlaps indications - if (cur_p.second == true) - ++overlaps; // we start a new overlapping segment at this point - if (cur_p.third == true) - --overlaps; // we end an overlapping segment at this point - + // we start a new overlapping segment at this point + if (cur_p.second == true) ++overlaps; + // we end an overlapping segment at this point + if (cur_p.third == true) --overlaps; } // set envelope data on the last part (cur_part) @@ -709,8 +644,7 @@ public: cur_part->set_decision(cur_part_res); cur_part->twin()->set_decision(cur_part_res); - if (cur_part == edge) - first_part_res = cur_part_res; + if (cur_part == edge) first_part_res = cur_part_res; // if the original source and target have same aux data as the edge // we can set envelope data over them also @@ -720,9 +654,8 @@ public: // the incident edge part to source should be edge (the first part) CGAL_assertion(original_src == edge->source()); - if (!original_src->is_decision_set() && - can_copy_decision_from_edge_to_vertex(edge->twin())) - { + if (! original_src->is_decision_set() && + can_copy_decision_from_edge_to_vertex(edge->twin())) { if (source_is_special) set_data_by_comparison_result(original_src, EQUAL); #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS @@ -733,27 +666,23 @@ public: } // the incident edge part to target should be cur_part (the last part) CGAL_assertion(original_trg == cur_part->target()); - if (!original_trg->is_decision_set() && - can_copy_decision_from_edge_to_vertex(cur_part)) - { + if (! original_trg->is_decision_set() && + can_copy_decision_from_edge_to_vertex(cur_part)) { if (target_is_special) set_data_by_comparison_result(original_trg, EQUAL); #ifdef CGAL_ENVELOPE_SAVE_COMPARISONS - else - set_data_by_comparison_result(original_trg, cur_part_res); + else set_data_by_comparison_result(original_trg, cur_part_res); #endif } - } // get a vertex with 2 surfaces defined over it and decide the envelope data // on it between them - void resolve(Vertex_handle vertex) - { + void resolve(Vertex_handle vertex) { // it is enough to compare only one surface from each group (because they // all overlap over the vertex), but set all the group - const Xy_monotone_surface_3& surf1 = get_aux_surface(vertex, 0); - const Xy_monotone_surface_3& surf2 = get_aux_surface(vertex, 1); + const Xy_monotone_surface_3& surf1 = aux_surface(vertex, 0); + const Xy_monotone_surface_3& surf2 = aux_surface(vertex, 1); const Point_2& point_2 = vertex->point(); Comparison_result cur_res = compare_distance_to_envelope(point_2, surf1, surf2); @@ -769,8 +698,7 @@ protected: // visitor. Vertex_handle insert_point(Minimization_diagram_2& arr, const Point_2& p, const Md_point_location& pl, - Copied_face_zone_visitor& visitor) - { + Copied_face_zone_visitor& visitor) { const Face_const_handle* fh; const Halfedge_const_handle* hh; const Vertex_const_handle* vh; @@ -779,17 +707,13 @@ protected: auto obj = pl.locate(p); visitor.init(&arr); - if ((fh = std::get_if(&obj)) - != nullptr) - { + if ((fh = std::get_if(&obj)) != nullptr) { vh_for_p = visitor.found_point_in_face(p, arr.non_const_handle(*fh)); } - else if ((hh = std::get_if(&obj))) - { + else if ((hh = std::get_if(&obj))) { vh_for_p = visitor.found_point_on_edge(p , arr.non_const_handle(*hh)); } - else - { + else { // In this case p lies on an existing vertex, so we just update this // vertex. vh = std::get_if(&obj); @@ -798,11 +722,10 @@ protected: } // Return a handle for the vertex associated with p. - return (vh_for_p); + return vh_for_p; } - // compute Comparison_result of surfaces over the face, assuming they get // the same answer for all points in face // if we get a halfedge, it is assumed to be on the outer boundary of the @@ -814,8 +737,7 @@ protected: // In either case, we try to copy decision from an incident face, is possible // before asking the geometric question Comparison_result resolve_minimal_face(Face_handle face, - Halfedge_handle* he = nullptr) - { + Halfedge_handle* he = nullptr) { CGAL_precondition(he == nullptr || (*he)->face() == face); Comparison_result res = EQUAL; @@ -824,53 +746,43 @@ protected: success = can_copy_decision_from_boundary_edge(face, res); #endif - if (success) - return res; + if (success) return res; - const Xy_monotone_surface_3& surf1 = get_aux_surface(face, 0); - const Xy_monotone_surface_3& surf2 = get_aux_surface(face, 1); + const Xy_monotone_surface_3& surf1 = aux_surface(face, 0); + const Xy_monotone_surface_3& surf2 = aux_surface(face, 1); Ccb_halfedge_circulator hec; - if (he == nullptr) - { + if (he == nullptr) { // compare the surfaces over arbitrary edge bool found_edge = false; Outer_ccb_iterator outer_ccb = face->outer_ccbs_begin(); - for (; outer_ccb != face->outer_ccbs_end() && !found_edge; ++outer_ccb) - { + for (; outer_ccb != face->outer_ccbs_end() && !found_edge; ++outer_ccb) { hec = *outer_ccb; Ccb_halfedge_circulator curr = hec; - do - { + do { Halfedge_handle he = hec; - if(he->is_fictitious()) - ++hec; - else - { + if (he->is_fictitious()) ++hec; + else { found_edge = true; const X_monotone_curve_2& cv = hec->curve(); res = compare_distance_to_envelope(cv,surf1,surf2); - break; } } - while(curr != hec); + while (curr != hec); } - if(!found_edge) - { + if (! found_edge) { // all edges are fictitous, we have two infinite surfaces. // but still, there can be holes. - if(face->inner_ccbs_begin() != face->inner_ccbs_end()) - { + if (face->inner_ccbs_begin() != face->inner_ccbs_end()) { Inner_ccb_iterator hit = face->inner_ccbs_begin(); hec = *hit; CGAL_assertion(!hec->is_fictitious()); const X_monotone_curve_2& cv = hec->curve(); res = compare_distance_to_envelope(cv, surf1, surf2); } - else - { + else { //two infinite surfaces, no outer boundary or holes. res = compare_distance_to_envelope(surf1, surf2, @@ -883,7 +795,7 @@ protected: CGAL_assertion_code(Ccb_halfedge_circulator hec_begin = hec; ++hec; while (hec != hec_begin) { - if(hec->is_fictitious()) { + if (hec->is_fictitious()) { ++hec; continue; } @@ -899,25 +811,20 @@ protected: //assertion code end return res; } - else - { + else { // compare the surfaces over the halfedge's curve const X_monotone_curve_2& cv = (*he)->curve(); // a face is always to the left of its halfedge // we use HE_COMP_RES so this code can compile both with Arr_2 // and with Aos_2. - if (HE_COMP_RES(*he) == SMALLER) - { + if (HE_COMP_RES(*he) == SMALLER) { res = m_traits->compare_z_at_xy_above_3_object()(cv,surf1,surf2); - if(type == ENVELOPE_UPPER) - res = CGAL::opposite(res); + if (type == ENVELOPE_UPPER) res = CGAL::opposite(res); } - else - { + else { res = m_traits->compare_z_at_xy_below_3_object()(cv,surf1,surf2); - if(type == ENVELOPE_UPPER) - res = CGAL::opposite(res); + if (type == ENVELOPE_UPPER) res = CGAL::opposite(res); } } @@ -928,33 +835,25 @@ protected: // comparison result of the other side of the intersection curve, // if the first side has result "res" Comparison_result resolve_by_intersection_type(Comparison_result res, - Multiplicity itype) - { + Multiplicity itype) { itype %= 2; - if (itype == 1) - { - if (res == LARGER) - return SMALLER; - else if (res == SMALLER) - return LARGER; - else - return res; + if (itype == 1) { + if (res == LARGER) return SMALLER; + else if (res == SMALLER) return LARGER; + else return res; } - else - { + else { CGAL_assertion(itype == 0); return res; } - } // find intersections between 2 xy-monotone surfaces // use caching for repeating questions of same pair of surfaces template - OutputIterator get_projected_intersections(const Xy_monotone_surface_3& s1, - const Xy_monotone_surface_3& s2, - OutputIterator o) - { + OutputIterator projected_intersections(const Xy_monotone_surface_3& s1, + const Xy_monotone_surface_3& s2, + OutputIterator o) { return m_traits->construct_projected_intersections_2_object()(s1, s2, o); } @@ -963,8 +862,7 @@ protected: Comparison_result compare_distance_to_envelope(Geometry& g, const Xy_monotone_surface_3& s1, - const Xy_monotone_surface_3& s2) - { + const Xy_monotone_surface_3& s2) { Comparison_result res = m_traits->compare_z_at_xy_3_object()(g, s1, s2); return ((type == ENVELOPE_LOWER) ? res : CGAL::opposite(res)); } @@ -974,8 +872,7 @@ protected: Comparison_result compare_distance_to_envelope(const Xy_monotone_surface_3& s1, const Xy_monotone_surface_3& s2, - Arr_not_all_sides_oblivious_tag) - { + Arr_not_all_sides_oblivious_tag) { Comparison_result res = m_traits->compare_z_at_xy_3_object()(s1, s2); return ((type == ENVELOPE_LOWER) ? res : CGAL::opposite(res)); } @@ -983,18 +880,15 @@ protected: // compare two infinite surfaces with no boundary or holes Comparison_result compare_distance_to_envelope(const Xy_monotone_surface_3&, const Xy_monotone_surface_3&, - Arr_all_sides_oblivious_tag) - { + Arr_all_sides_oblivious_tag) { CGAL_error(); // doesn't suppose to reach here at all!!! return SMALLER; } // helper method to get the surfaces we need to work on template - const Xy_monotone_surface_3& get_aux_surface(FeatureHandle fh, - unsigned int id) - { - const Object& o = fh->get_aux_source(id); + const Xy_monotone_surface_3& aux_surface(FeatureHandle fh, unsigned int id) { + const Object& o = fh->aux_source(id); CGAL_assertion(!o.is_empty()); // aux source of a face must be a face! @@ -1003,34 +897,30 @@ protected: // this is why we start with a check for a face, then halfedge // and last vertex Face_handle f; - if (assign(f, o)) - return f->get_data(); + if (assign(f, o)) return f->env_data_front(); Halfedge_handle h; - if (assign(h, o)) - return h->get_data(); + if (assign(h, o)) return h->env_data_front(); Vertex_handle v; CGAL_assertion_code(bool b =) - assign(v, o); + assign(v, o); CGAL_assertion(b); - return v->get_data(); + return v->env_data_front(); } - bool can_copy_decision_from_face_to_edge(Halfedge_handle h) - { + bool can_copy_decision_from_face_to_edge(Halfedge_handle h) { // can copy decision from face to its incident edge if the aux // envelopes are continuous over the face and edge - return (h->get_has_equal_aux_data_in_face(0) && - h->get_has_equal_aux_data_in_face(1)); + return (h->has_equal_aux_data_in_face(0) && + h->has_equal_aux_data_in_face(1)); } - bool can_copy_decision_from_edge_to_vertex(Halfedge_handle h) - { + bool can_copy_decision_from_edge_to_vertex(Halfedge_handle h) { // can copy decision from face to its incident edge if the aux // envelopes are continuous over the face and edge - return (h->get_has_equal_aux_data_in_target(0) && - h->get_has_equal_aux_data_in_target(1)); + return (h->has_equal_aux_data_in_target(0) && + h->has_equal_aux_data_in_target(1)); } @@ -1039,58 +929,48 @@ protected: // these features later // also consider isolated vertices // "res" is the decision made on the face - void copy_data_to_face_boundary(Face_handle face) - { + void copy_data_to_face_boundary(Face_handle face) { Ccb_halfedge_circulator ccb; - Outer_ccb_iterator outer_iter = face->outer_ccbs_begin(); - for (; outer_iter != face->outer_ccbs_end(); ++outer_iter) - { + for (Outer_ccb_iterator outer_iter = face->outer_ccbs_begin(); + outer_iter != face->outer_ccbs_end(); ++outer_iter) { ccb = *outer_iter; copy_data_to_face_boundary(face, ccb); } - Inner_ccb_iterator inner_iter = face->inner_ccbs_begin(); - for (; inner_iter != face->inner_ccbs_end(); ++inner_iter) - { + for (Inner_ccb_iterator inner_iter = face->inner_ccbs_begin(); + inner_iter != face->inner_ccbs_end(); ++inner_iter) { ccb = (*inner_iter); copy_data_to_face_boundary(face, ccb); } - Isolated_vertex_iterator iso_iter = face->isolated_vertices_begin(); - for (; iso_iter != face->isolated_vertices_end(); ++iso_iter) - { + for (Isolated_vertex_iterator iso_iter = face->isolated_vertices_begin(); + iso_iter != face->isolated_vertices_end(); ++iso_iter) { Vertex_handle vh = iso_iter; - if (!vh->is_decision_set() && has_equal_aux_data_with_face(vh)) + if (! vh->is_decision_set() && has_equal_aux_data_with_face(vh)) // can copy the data from the face, since we already took care of // the vertices of projected intersections - vh->set_decision(face->get_decision()); + vh->set_decision(face->decision()); } } void copy_data_to_face_boundary(Face_handle face, - Ccb_halfedge_circulator hec) - { + Ccb_halfedge_circulator hec) { Ccb_halfedge_circulator hec_begin = hec; do { Halfedge_handle hh = hec; - if(hh->is_fictitious()) - { - ++hec; - continue; - } + if (hh->is_fictitious()) continue; CGAL_assertion(face == hh->face()); // if it is a vertical decomposition edge, copy data from face - /*if (!hh->is_decision_set() && hh->get_is_fake()) - { - hh->set_decision(face->get_decision()); - hh->twin()->set_decision(face->get_decision()); - }*/ - if (!hh->is_decision_set() && can_copy_decision_from_face_to_edge(hh)) - { + /* if (!hh->is_decision_set() && hh->is_fake()) { + * hh->set_decision(face->decision()); + * hh->twin()->set_decision(face->decision()); + * } + */ + if (! hh->is_decision_set() && can_copy_decision_from_face_to_edge(hh)) { // copy the decision from face to the edge - hh->set_decision(face->get_decision()); - hh->twin()->set_decision(hh->get_decision()); + hh->set_decision(face->decision()); + hh->twin()->set_decision(hh->decision()); } // TODO: is this correct? shouldn't we split the edge first? // I think it is correct, because there is no intersection (of @@ -1101,22 +981,19 @@ protected: // if the first map is continuous, but the second isn't (i.e. when we move // from the face to the edge, the envelope goes closer), then if the // second map wins on the face, it wins on the edge also - else if (!hh->is_decision_set() && - face->get_decision() == DAC_DECISION_SECOND && - hh->get_has_equal_aux_data_in_face(0) && - !hh->get_has_equal_aux_data_in_face(1)) - { + else if (! hh->is_decision_set() && + face->decision() == DAC_DECISION_SECOND && + hh->has_equal_aux_data_in_face(0) && + ! hh->has_equal_aux_data_in_face(1)) { hh->set_decision(DAC_DECISION_SECOND); hh->twin()->set_decision(DAC_DECISION_SECOND); - } // if the second map is continuous, but the first isn't, then if the // first map wins on the face, it wins on the edge also - else if (!hh->is_decision_set() && - face->get_decision() == DAC_DECISION_FIRST && - !hh->get_has_equal_aux_data_in_face(0) && - hh->get_has_equal_aux_data_in_face(1)) - { + else if (! hh->is_decision_set() && + face->decision() == DAC_DECISION_FIRST && + ! hh->has_equal_aux_data_in_face(0) && + hh->has_equal_aux_data_in_face(1)) { hh->set_decision(DAC_DECISION_FIRST); hh->twin()->set_decision(DAC_DECISION_FIRST); } @@ -1126,9 +1003,7 @@ protected: // conclude from one edge, bt can conclude from the other conclude_decision_to_vertex(hh->source(), hh->twin(), face, false); conclude_decision_to_vertex(hh->target(), hh, face, true); - - hec++; - } while(hec != hec_begin); + } while (++hec != hec_begin); } // try to conclude the decision from the halfedge or the face to the vertex @@ -1137,59 +1012,48 @@ protected: // the last bool indicates whether to check if possible to conclude from // face to vertex. it is only possible when hh->face == fh void conclude_decision_to_vertex(Vertex_handle vh, Halfedge_handle hh, - Face_handle fh, bool try_vertex_face) - { - if (vh->is_decision_set()) - return; - + Face_handle fh, bool try_vertex_face) { + if (vh->is_decision_set()) return; // first, we try to copy decision from edge, then from face - if (hh->is_decision_set() && - can_copy_decision_from_edge_to_vertex(hh)) - { - vh->set_decision(hh->get_decision()); - } + if (hh->is_decision_set() && can_copy_decision_from_edge_to_vertex(hh)) + vh->set_decision(hh->decision()); + // if the first map is continuous, but the second isn't (i.e. when we move // from the edge to the vertex, the envelope goes closer), then if the // second map wins on the edge, it wins on the vertex also - else if (hh->get_decision() == DAC_DECISION_SECOND && - hh->get_has_equal_aux_data_in_target(0) && - !hh->get_has_equal_aux_data_in_target(1)) - { + else if (hh->decision() == DAC_DECISION_SECOND && + hh->has_equal_aux_data_in_target(0) && + ! hh->has_equal_aux_data_in_target(1)) vh->set_decision(DAC_DECISION_SECOND); - } + // if the second map is continuous, but the first isn't, then if the // first map wins on the edge, it wins on the vertex also - else if (hh->get_decision() == DAC_DECISION_FIRST && - !hh->get_has_equal_aux_data_in_target(0) && - hh->get_has_equal_aux_data_in_target(1)) - { + else if (hh->decision() == DAC_DECISION_FIRST && + ! hh->has_equal_aux_data_in_target(0) && + hh->has_equal_aux_data_in_target(1)) vh->set_decision(DAC_DECISION_FIRST); - } + // check if we can copy from the face // todo: what if has_equal has 3 possible values? (and projected // ersection vertices have unknown flags) - else if (try_vertex_face) - { + else if (try_vertex_face) { /*CGAL_assertion(has_equal_aux_data_in_target_and_face(hh) == has_equal_aux_data(vh, fh));*/ - if (has_equal_aux_data_in_target_and_face(hh)) - { - + if (has_equal_aux_data_in_target_and_face(hh)) { // can copy the data from the face, since we already took care of // the vertices of projected intersections - vh->set_decision(fh->get_decision()); + vh->set_decision(fh->decision()); } } } // todo: this is for checking template - bool has_equal_data(const InputIterator& begin1, - const InputIterator& end1, - const InputIterator& begin2, - const InputIterator& end2) - { + bool has_equal_env_data(const InputIterator& begin1, + const InputIterator& end1, + const InputIterator& begin2, + const InputIterator& end2) { // insert the input data objects into a set std::set first(begin1, end1); std::set second(begin2, end2); @@ -1200,121 +1064,101 @@ protected: return (intersection.size() > 0); } + // todo: this is for checking template - void get_aux_data_iterators(unsigned int id, FeatureHandle fh, - Envelope_data_iterator& begin, - Envelope_data_iterator& end) - { + void aux_data_iterators(unsigned int id, FeatureHandle fh, + Envelope_data_iterator& begin, + Envelope_data_iterator& end) { Halfedge_handle h; Vertex_handle v; Face_handle f; - const Object& o = fh->get_aux_source(id); + const Object& o = fh->aux_source(id); CGAL_assertion(!o.is_empty()); - if (assign(v, o)) - { - begin = v->begin_data(); - end = v->end_data(); + if (assign(v, o)) { + begin = v->begin_env_data(); + end = v->end_env_data(); } - else if (assign(h, o)) - { - begin = h->begin_data(); - end = h->end_data(); + else if (assign(h, o)) { + begin = h->begin_env_data(); + end = h->end_env_data(); } - else - { + else { CGAL_assertion(assign(f, o)); assign(f, o); - begin = f->begin_data(); - end = f->end_data(); + begin = f->begin_env_data(); + end = f->end_env_data(); } } // todo: this is for checking template bool has_equal_aux_data(unsigned int id, FeatureHandle1 fh1, - FeatureHandle2 fh2) - { + FeatureHandle2 fh2) { Envelope_data_iterator begin1, end1, begin2, end2; - get_aux_data_iterators(id, fh1, begin1, end1); - get_aux_data_iterators(id, fh2, begin2, end2); - bool has_eq = has_equal_data(begin1, end1, begin2, end2); + aux_data_iterators(id, fh1, begin1, end1); + aux_data_iterators(id, fh2, begin2, end2); + bool has_eq = has_equal_env_data(begin1, end1, begin2, end2); return has_eq; } // todo: this is for checking template - bool has_equal_aux_data(FeatureHandle1 fh1, FeatureHandle2 fh2) - { + bool has_equal_aux_data(FeatureHandle1 fh1, FeatureHandle2 fh2) { return (has_equal_aux_data(0, fh1, fh2) && has_equal_aux_data(1, fh1, fh2)); } - // check if we can copy the decision made on a boundary edge to the face // if so, res will contain this decision's comparison result bool can_copy_decision_from_boundary_edge(Face_handle face, - Comparison_result& res) - { + Comparison_result& res) { bool result = false; // check outer boundary Ccb_halfedge_circulator hec, hec_begin; // check outer boundary Outer_ccb_iterator outer_ccb = face->outer_ccbs_begin(); - for (; outer_ccb != face->outer_ccbs_end(); ++outer_ccb) - { + for (; outer_ccb != face->outer_ccbs_end(); ++outer_ccb) { hec = *outer_ccb; hec_begin = hec; - do - { + do { Halfedge_handle hh = hec; - if(hh->is_fictitious()) - { - ++hec; - continue; - } + if (hh->is_fictitious()) continue; if (can_copy_decision_from_face_to_edge(hh) && - hh->is_decision_set() && - hh->get_decision() != DAC_DECISION_BOTH) - { - res = convert_decision_to_comparison_result(hh->get_decision()); + hh->decision() != DAC_DECISION_BOTH) { + res = convert_decision_to_comparison_result(hh->decision()); result = true; } // if the first map is continuous, but the second isn't (i.e. when we // move from the edge to the face, the envelope goes farther), then // if the first map wins on the edge, it wins on the face also else if (hh->is_decision_set() && - hh->get_decision() == DAC_DECISION_FIRST && - hh->get_has_equal_aux_data_in_face(0) && - !hh->get_has_equal_aux_data_in_face(1)) - { + hh->decision() == DAC_DECISION_FIRST && + hh->has_equal_aux_data_in_face(0) && + ! hh->has_equal_aux_data_in_face(1)) { res = convert_decision_to_comparison_result(DAC_DECISION_FIRST); result = true; } // if the second map is continuous, but the first isn't, then if the // second map wins on the edge, it wins on the face also else if (hh->is_decision_set() && - hh->get_decision() == DAC_DECISION_SECOND && - !hh->get_has_equal_aux_data_in_face(0) && - hh->get_has_equal_aux_data_in_face(1)) - { + hh->decision() == DAC_DECISION_SECOND && + !hh->has_equal_aux_data_in_face(0) && + hh->has_equal_aux_data_in_face(1)) { res = convert_decision_to_comparison_result(DAC_DECISION_SECOND); result = true; } - hec++; - } while(hec != hec_begin && !result); - if (result) - return true; + } while ((++hec != hec_begin) && ! result); + if (result) return true; } // check inner boundaries - Inner_ccb_iterator hole_iter = face->inner_ccbs_begin(); - for (; hole_iter != face->inner_ccbs_end(); ++hole_iter) - { + for (Inner_ccb_iterator hole_iter = face->inner_ccbs_begin(); + hole_iter != face->inner_ccbs_end(); ++hole_iter) { hec = (*hole_iter); hec_begin = hec; @@ -1322,36 +1166,30 @@ protected: Halfedge_handle hh = hec; if (can_copy_decision_from_face_to_edge(hh) && hh->is_decision_set() && - hh->get_decision() != DAC_DECISION_BOTH) - { - res = convert_decision_to_comparison_result(hh->get_decision()); + hh->decision() != DAC_DECISION_BOTH) { + res = convert_decision_to_comparison_result(hh->decision()); result = true; } // if the first map is continuous, but the second isn't (i.e. when we // move from the edge to the face, the envelope goes farther), then // if the first map wins on the edge, it wins on the face also else if (hh->is_decision_set() && - hh->get_decision() == DAC_DECISION_FIRST && - hh->get_has_equal_aux_data_in_face(0) && - !hh->get_has_equal_aux_data_in_face(1)) - { + hh->decision() == DAC_DECISION_FIRST && + hh->has_equal_aux_data_in_face(0) && + ! hh->has_equal_aux_data_in_face(1)) { res = convert_decision_to_comparison_result(DAC_DECISION_FIRST); - result = true; } // if the second map is continuous, but the first isn't, then if the // second map wins on the edge, it wins on the face also else if (hh->is_decision_set() && - hh->get_decision() == DAC_DECISION_SECOND && - !hh->get_has_equal_aux_data_in_face(0) && - hh->get_has_equal_aux_data_in_face(1)) - { + hh->decision() == DAC_DECISION_SECOND && + ! hh->has_equal_aux_data_in_face(0) && + hh->has_equal_aux_data_in_face(1)) { res = convert_decision_to_comparison_result(DAC_DECISION_SECOND); result = true; } - - hec++; - } while(hec != hec_begin && !result); + } while ((++hec != hec_begin) && ! result); if (result) return true; } @@ -1369,45 +1207,40 @@ protected: return EQUAL;*/ } - bool has_equal_aux_data_with_face(Vertex_handle v) - { + bool has_equal_aux_data_with_face(Vertex_handle v) { CGAL_assertion(v->is_isolated()); - return (v->get_has_equal_aux_data_in_face(0) && - v->get_has_equal_aux_data_in_face(1)); + return (v->has_equal_aux_data_in_face(0) && + v->has_equal_aux_data_in_face(1)); } - bool has_equal_aux_data_in_target_and_face(Halfedge_handle h) - { - return (h->get_has_equal_aux_data_in_target_and_face(0) && - h->get_has_equal_aux_data_in_target_and_face(1)); + bool has_equal_aux_data_in_target_and_face(Halfedge_handle h) { + return (h->has_equal_aux_data_in_target_and_face(0) && + h->has_equal_aux_data_in_target_and_face(1)); } // check the aux data on the endpoint vertices of the edge // and if it equals the aux data on the edge, copy it, to save calculations // for these features later - void copy_data_to_edge_endpoints(Halfedge_handle edge) - { + void copy_data_to_edge_endpoints(Halfedge_handle edge) { // take care for source - if (!edge->source()->is_decision_set() && + if (! edge->source()->is_decision_set() && can_copy_decision_from_edge_to_vertex(edge->twin())) // can copy the data from the edge, since we already took care of // the vertices of projected intersections - edge->source()->set_decision(edge->get_decision()); + edge->source()->set_decision(edge->decision()); // if the first map is continuous, but the second isn't (i.e. when we move // from the edge to the vertex, the envelope goes closer), then if the // second map wins on the edge, it wins on the vertex also - else if (edge->get_decision() == DAC_DECISION_SECOND && - edge->twin()->get_has_equal_aux_data_in_target(0) && - !edge->twin()->get_has_equal_aux_data_in_target(1)) - { + else if (edge->decision() == DAC_DECISION_SECOND && + edge->twin()->has_equal_aux_data_in_target(0) && + !edge->twin()->has_equal_aux_data_in_target(1)) { edge->source()->set_decision(DAC_DECISION_SECOND); } // if the second map is continuous, but the first isn't, then if the // first map wins on the edge, it wins on the vertex also - else if (edge->get_decision() == DAC_DECISION_FIRST && - !edge->twin()->get_has_equal_aux_data_in_target(0) && - edge->twin()->get_has_equal_aux_data_in_target(1)) - { + else if (edge->decision() == DAC_DECISION_FIRST && + !edge->twin()->has_equal_aux_data_in_target(0) && + edge->twin()->has_equal_aux_data_in_target(1)) { edge->source()->set_decision(DAC_DECISION_FIRST); } @@ -1416,22 +1249,20 @@ protected: can_copy_decision_from_edge_to_vertex(edge)) // can copy the data from the edge, since we already took care of // the vertices of projected intersections - edge->target()->set_decision(edge->get_decision()); + edge->target()->set_decision(edge->decision()); // if the first map is continuous, but the second isn't (i.e. when we move // from the edge to the vertex, the envelope goes closer), then if the // second map wins on the edge, it wins on the vertex also - else if (edge->get_decision() == DAC_DECISION_SECOND && - edge->get_has_equal_aux_data_in_target(0) && - !edge->get_has_equal_aux_data_in_target(1)) - { + else if (edge->decision() == DAC_DECISION_SECOND && + edge->has_equal_aux_data_in_target(0) && + !edge->has_equal_aux_data_in_target(1)) { edge->target()->set_decision(DAC_DECISION_SECOND); } // if the second map is continuous, but the first isn't, then if the // first map wins on the edge, it wins on the vertex also - else if (edge->get_decision() == DAC_DECISION_FIRST && - !edge->get_has_equal_aux_data_in_target(0) && - edge->get_has_equal_aux_data_in_target(1)) - { + else if (edge->decision() == DAC_DECISION_FIRST && + !edge->has_equal_aux_data_in_target(0) && + edge->has_equal_aux_data_in_target(1)) { edge->target()->set_decision(DAC_DECISION_FIRST); } } @@ -1440,10 +1271,9 @@ protected: // bounded traits. template Vertex_handle create_copied_vertex(Halfedge_handle hh, - Md_accessor &to_accessor, + Md_accessor& to_accessor, bool source, - Arr_all_sides_oblivious_tag) - { + Arr_all_sides_oblivious_tag) { // create the 2 vertices and connect them with the edge // copied_prev_he should be directed from copied_source to copied_target Point_2* p_p = @@ -1459,12 +1289,9 @@ protected: Vertex_handle create_copied_vertex(Halfedge_handle hh, Md_accessor& to_accessor, bool source, - Arr_not_all_sides_oblivious_tag) - { - typename Traits::Parameter_space_in_x_2 ps_x_op = - this->m_traits->parameter_space_in_x_2_object (); - typename Traits::Parameter_space_in_y_2 ps_y_op = - this->m_traits->parameter_space_in_y_2_object (); + Arr_not_all_sides_oblivious_tag) { + auto ps_x_op = this->m_traits->parameter_space_in_x_2_object (); + auto ps_y_op = this->m_traits->parameter_space_in_y_2_object (); bool is_directed_right = hh->direction() == ARR_LEFT_TO_RIGHT; @@ -1478,8 +1305,7 @@ protected: if (ps_x != ARR_INTERIOR || ps_y != ARR_INTERIOR) return to_accessor.create_boundary_vertex(hh->curve(), ind, ps_x, ps_y, true); - else - { + else { // create the 2 vertices and connect them with the edge // copied_prev_he should be directed from copied_source to copied_target Point_2* p_p = @@ -1501,7 +1327,6 @@ protected: Halfedges_map& map_orig_to_copied_halfedges, Vertices_map& map_orig_to_copied_vertices, bool is_outer_ccb) // do we copy an outer (or inner) ccb - { Md_accessor to_accessor(to); // count the number of faces that are closed by this ccb @@ -1512,22 +1337,18 @@ protected: Ccb_halfedge_circulator hec_begin = hec; bool first_he = true; Halfedge_handle copied_prev_he; - do - { + do { Halfedge_handle hh = hec; if (hh->twin()->face() == hh->face() && - map_orig_to_copied_halfedges.is_defined(hh)) - { + map_orig_to_copied_halfedges.is_defined(hh)) { // this can happen in the case of antennas, when we get to the same // antena halfedge from the other side copied_prev_he = map_orig_to_copied_halfedges[hh]; } - else - { + else { const X_monotone_curve_2& current_cv = hh->curve(); - if (first_he) - { + if (first_he) { first_he = false; // create the 2 vertices and connect them with the edge @@ -1557,8 +1378,7 @@ protected: map_copied_to_orig_vertices[copied_prev_he->target()] = hh->target(); map_orig_to_copied_vertices[hh->target()] = copied_prev_he->target(); } - else - { + else { CGAL_assertion(map_copied_to_orig_halfedges[copied_prev_he]->target() == hh->source()); @@ -1567,15 +1387,13 @@ protected: // in which case we should use insert at vertices bool use_2_vertices = false; Vertex_handle copied_v2; - if (map_orig_to_copied_vertices.is_defined(hh->target())) - { + if (map_orig_to_copied_vertices.is_defined(hh->target())) { use_2_vertices = true; copied_v2 = map_orig_to_copied_vertices[hh->target()]; } Halfedge_handle copied_new_he; - if (!use_2_vertices) - { + if (! use_2_vertices) { // create vertex for the new target, and insert the new edge Vertex_handle copied_target = create_copied_vertex(hh, to_accessor, false, @@ -1596,8 +1414,7 @@ protected: map_copied_to_orig_vertices[copied_new_he->target()] = hh->target(); map_orig_to_copied_vertices[hh->target()] = copied_new_he->target(); } - else - { + else { ++n_faces_closed; // in order to insert the new edge we should determine the prev @@ -1618,15 +1435,13 @@ protected: CGAL_assertion(tmp == copied_prev_v2); bool new_face; - if (is_outer_ccb) - { + if (is_outer_ccb) { // if it is the first face created, and the last halfedge to // insert, this is a regular outer ccb, with no special // degeneracies (around the current vertices, at least) // so we can use the accessor method if (n_faces_closed == 1 && - map_orig_to_copied_halfedges.is_defined(hh->next())) - { + map_orig_to_copied_halfedges.is_defined(hh->next())) { bool dummy_swapped_predecessors = false; copied_new_he = to_accessor.insert_at_vertices_ex (copied_prev_he, @@ -1634,13 +1449,12 @@ protected: copied_prev_v2->next(), new_face, dummy_swapped_predecessors); - // TODO EBEB 2012-08-06 do we have to care if order has been swapped, - // or do we have to disallow swapping? + // TODO EBEB 2012-08-06 do we have to care if order has been + // swapped, or do we have to disallow swapping? CGAL_assertion(new_face); } - else - { + else { // TODO:can we use accessor method? copied_new_he = to.insert_at_vertices(current_cv, copied_prev_he, @@ -1651,8 +1465,8 @@ protected: // (we should be careful in cases where more than one face is // created by the outer ccb } - else // copy inner boundary - { + else { + // copy inner boundary // should always flip the side of the edge, because the face // that we close is never the copied face, even in strane // situations like this: (two faces touch in a vertex) @@ -1669,8 +1483,8 @@ protected: copied_prev_he->next(), new_face, dummy_swapped_predecessors); - // TODO EBEB 2012-08-06 do we have to care if order has been swapped, - // or do we have to disallow swapping? + // TODO EBEB 2012-08-06 do we have to care if order has been + // swapped, or do we have to disallow swapping? CGAL_assertion(new_face); copied_new_he = copied_new_he->twin(); @@ -1688,9 +1502,7 @@ protected: copied_prev_he = copied_new_he; } } - hec++; - } while(hec != hec_begin); - + } while (++hec != hec_begin); } void copy_ccb_unbounded(Ccb_halfedge_circulator hec, @@ -1699,31 +1511,26 @@ protected: Halfedges_map& map_copied_to_orig_halfedges, Vertices_map& map_copied_to_orig_vertices, Halfedges_map& map_orig_to_copied_halfedges, - Vertices_map& map_orig_to_copied_vertices) - { + Vertices_map& map_orig_to_copied_vertices) { // Find a non-fictitous edge (if there is such one) on the CCB. - Ccb_halfedge_circulator hec_end = hec; - Halfedge_handle non_fict; + Ccb_halfedge_circulator hec_end = hec; + Halfedge_handle non_fict; - do - { - if(!hec->is_fictitious()) - { + do { + if (! hec->is_fictitious()) { non_fict = hec; break; } - ++hec; - } while(hec != hec_end); + } while (++hec != hec_end); // Find an anchor halfedge he_from along the original CCB and locate // its image he_to in the target CCB. - Md_accessor from_accessor (from); - Md_accessor to_accessor (to); - Halfedge_handle he_from; - Halfedge_handle he_to; + Md_accessor from_accessor (from); + Md_accessor to_accessor (to); + Halfedge_handle he_from; + Halfedge_handle he_to; - if (non_fict == Halfedge_handle()) - { + if (non_fict == Halfedge_handle()) { // In case all edges along the CCB are fictitious, this outer CCB // belongs to the single unbounded face in the arrangement (as it // contains no unbounded curves at current). In this case, we go @@ -1733,21 +1540,19 @@ protected: CGAL_assertion_msg ((to.number_of_faces() != 0), "if all halfedges are fictitious then there should be only one face"); - Face_handle to_uf = to.faces_begin(); - Ccb_halfedge_circulator to_uf_hec = to_uf->outer_ccb(); + Face_handle to_uf = to.faces_begin(); + Ccb_halfedge_circulator to_uf_hec = to_uf->outer_ccb(); he_from = hec; he_to = to_uf_hec; while (he_to->direction() != he_from->direction() || - he_to->next()->direction() != he_from->next()->direction()) - { + he_to->next()->direction() != he_from->next()->direction()) { he_to = he_to->next(); CGAL_assertion (he_to != to_uf_hec); } } - else - { + else { // Use the non-fictitious halfedge as an "anchor": Insert its associated // curve into the target arrangement, and keep track of the halfedge we // obtained. @@ -1759,11 +1564,10 @@ protected: // Go over all other halfedges along the copied CCB, and store all // curves associated with non-fictitious halfedges. - Halfedge_handle he; - std::list xcvs; + Halfedge_handle he; + std::list xcvs; - for (he = he_from->next(); he != he_from; he = he->next()) - { + for (he = he_from->next(); he != he_from; he = he->next()) { if (! he->is_fictitious()) xcvs.push_back (he->curve()); } @@ -1777,10 +1581,9 @@ protected: // Map the halfedges and vertices along the two CCBs. // Note that we make sure that the two CCBs are of the same size. const Halfedge_handle he_from_end = he_from; - CGAL_assertion_code(const Halfedge_handle he_to_end = he_to;); + CGAL_assertion_code(const Halfedge_handle he_to_end = he_to;); - do - { + do { map_copied_to_orig_vertices[he_to->source()] = he_from->source(); map_orig_to_copied_vertices[he_from->source()] = he_to->source(); @@ -1803,8 +1606,7 @@ protected: Face_handle copy_face(Face_handle face, Minimization_diagram_2& from, Minimization_diagram_2& to, Halfedges_map& map_copied_to_orig_halfedges, - Vertices_map& map_copied_to_orig_vertices) - { + Vertices_map& map_copied_to_orig_vertices) { CGAL_precondition(from.is_valid()); CGAL_precondition(to.is_empty()); CGAL_assertion_msg(to.number_of_faces() == 1, @@ -1814,27 +1616,24 @@ protected: // ones in the copied arrangement. Also keep track of the unbounded face // of the copied arrangement: Note that if the face we copy is bounded, // then it forms a hole in the unbounded face. - Vertices_map map_orig_to_copied_vertices; + Vertices_map map_orig_to_copied_vertices; Halfedges_map map_orig_to_copied_halfedges; - Face_handle to_uf = to.faces_begin(); + Face_handle to_uf = to.faces_begin(); // Copy outer CCB of the face, if it has one. - Face_handle copied_face; + Face_handle copied_face; - if (face->number_of_outer_ccbs() > 0) - { + if (face->number_of_outer_ccbs() > 0) { Ccb_halfedge_circulator hec = face->outer_ccb(); - if (face->is_unbounded()) - { + if (face->is_unbounded()) { copy_ccb_unbounded(hec, from, to, map_copied_to_orig_halfedges, map_copied_to_orig_vertices, map_orig_to_copied_halfedges, map_orig_to_copied_vertices); } - else - { + else { copy_ccb(hec, from, to_uf, to, map_copied_to_orig_halfedges, map_copied_to_orig_vertices, @@ -1851,17 +1650,15 @@ protected: copied_face = hec_to->face(); } - else - { + else { // In case the copied face has no outer CCB, then it must be the // single unbounded face of the arrangement. copied_face = to_uf; } // Copy the inner CCB (the holes inside the face). - Inner_ccb_iterator iccb_it = face->inner_ccbs_begin(); - for (; iccb_it != face->inner_ccbs_end(); ++iccb_it) - { + for (auto iccb_it = face->inner_ccbs_begin(); + iccb_it != face->inner_ccbs_end(); ++iccb_it) { Ccb_halfedge_circulator he = *iccb_it; copy_ccb(he, from, copied_face, to, @@ -1874,11 +1671,10 @@ protected: } // Copy the isolated vertices inside the given face. - Isolated_vertex_iterator iv_it = face->isolated_vertices_begin(); - for (; iv_it != face->isolated_vertices_end(); ++iv_it) - { - Vertex_handle iso_v = iv_it; - Vertex_handle copied_iso = + for (Isolated_vertex_iterator iv_it = face->isolated_vertices_begin(); + iv_it != face->isolated_vertices_end(); ++iv_it) { + Vertex_handle iso_v = iv_it; + Vertex_handle copied_iso = to.insert_in_face_interior (iso_v->point(), copied_face); map_copied_to_orig_vertices[copied_iso] = iso_v; @@ -1892,30 +1688,27 @@ protected: // set envelope data in face "to" according to the comparison result of the // aux data of face "from" void copy_data_by_comparison_result(Face_handle from, Face_handle to, - Comparison_result res) - { - CGAL_assertion_msg(from->get_aux_is_set(0), "aux_data(0) is not set"); - CGAL_assertion_msg(from->get_aux_is_set(1), "aux_data(1) is not set"); - to->set_aux_source(0, from->get_aux_source(0)); - to->set_aux_source(1, from->get_aux_source(1)); + Comparison_result res) { + CGAL_assertion_msg(from->aux_is_set(0), "aux_data(0) is not set"); + CGAL_assertion_msg(from->aux_is_set(1), "aux_data(1) is not set"); + to->set_aux_source(0, from->aux_source(0)); + to->set_aux_source(1, from->aux_source(1)); to->set_decision(res); } // set envelope data in vertex "v" according to the comparison result of the // aux data of "v" - void set_data_by_comparison_result(Vertex_handle v, Comparison_result res) - { - CGAL_assertion_msg(v->get_aux_is_set(0), "aux_data(0) is not set"); - CGAL_assertion_msg(v->get_aux_is_set(1), "aux_data(1) is not set"); + void set_data_by_comparison_result(Vertex_handle v, Comparison_result res) { + CGAL_assertion_msg(v->aux_is_set(0), "aux_data(0) is not set"); + CGAL_assertion_msg(v->aux_is_set(1), "aux_data(1) is not set"); v->set_decision(res); } // set envelope data in halfedge "h" according to the comparison result of // the aux data of "h" - void set_data_by_comparison_result(Halfedge_handle h, Comparison_result res) - { - CGAL_assertion_msg(h->get_aux_is_set(0), "aux_data(0) is not set"); - CGAL_assertion_msg(h->get_aux_is_set(1), "aux_data(1) is not set"); + void set_data_by_comparison_result(Halfedge_handle h, Comparison_result res) { + CGAL_assertion_msg(h->aux_is_set(0), "aux_data(0) is not set"); + CGAL_assertion_msg(h->aux_is_set(1), "aux_data(1) is not set"); h->set_decision(res); } @@ -1924,41 +1717,39 @@ protected: // FeatureHabdle should be a Face_handle, Halfedge_handle or // Vertex_handle template - void copy_all_data_to_vertex(FeatureHabdle from, Vertex_handle to) - { - CGAL_assertion_msg(from->get_aux_is_set(0), "aux_data(0) is not set"); - CGAL_assertion_msg(from->get_aux_is_set(1), "aux_data(1) is not set"); + void copy_all_data_to_vertex(FeatureHabdle from, Vertex_handle to) { + CGAL_assertion_msg(from->aux_is_set(0), "aux_data(0) is not set"); + CGAL_assertion_msg(from->aux_is_set(1), "aux_data(1) is not set"); CGAL_assertion_msg(!to->is_decision_set(), "data is set in new vertex"); - to->set_aux_source(0, from->get_aux_source(0)); - to->set_aux_source(1, from->get_aux_source(1)); + to->set_aux_source(0, from->aux_source(0)); + to->set_aux_source(1, from->aux_source(1)); to->set_decision(EQUAL); } // void deal_with_new_vertex(Halfedge_handle orig_he, Vertex_handle new_v) // { - // const Xy_monotone_surface_3& surf1 = get_aux_surface(orig_he, 0); - // const Xy_monotone_surface_3& surf2 = get_aux_surface(orig_he, 1); + // const Xy_monotone_surface_3& surf1 = aux_surface(orig_he, 0); + // const Xy_monotone_surface_3& surf2 = aux_surface(orig_he, 1); // const Point_2& p = new_v->point(); // Comparison_result res = compare_distance_to_envelope(p, surf1, surf2); - // new_v->set_aux_source(0, orig_he->get_aux_source(0)); - // new_v->set_aux_source(1, orig_he->get_aux_source(1)); + // new_v->set_aux_source(0, orig_he->aux_source(0)); + // new_v->set_aux_source(1, orig_he->aux_source(1)); // new_v->set_decision(res); // } Comparison_result resolve_minimal_edge(Halfedge_handle orig_he, - Halfedge_handle new_he) - { + Halfedge_handle new_he) { // find and set the envelope data on the new edge - const Xy_monotone_surface_3& surf1 = get_aux_surface(orig_he, 0); - const Xy_monotone_surface_3& surf2 = get_aux_surface(orig_he, 1); + const Xy_monotone_surface_3& surf1 = aux_surface(orig_he, 0); + const Xy_monotone_surface_3& surf2 = aux_surface(orig_he, 1); Comparison_result res = compare_distance_to_envelope(new_he->curve(), surf1, surf2); // the observer keeps this information when splitting an edge - CGAL_assertion(new_he->get_aux_is_set(0) && new_he->get_aux_is_set(1)); - CGAL_assertion(new_he->twin()->get_aux_is_set(0) && \ - new_he->twin()->get_aux_is_set(1)); + CGAL_assertion(new_he->aux_is_set(0) && new_he->aux_is_set(1)); + CGAL_assertion(new_he->twin()->aux_is_set(0) && \ + new_he->twin()->aux_is_set(1)); new_he->set_decision(res); new_he->twin()->set_decision(res); @@ -1967,8 +1758,7 @@ protected: // check if the point is on the curve. // we use the traits adaptor since cv can be an infinite curve - bool is_point_on_curve(const Point_2& p, const X_monotone_curve_2& cv) - { + bool is_point_on_curve(const Point_2& p, const X_monotone_curve_2& cv) { Arr_traits_adaptor_2 tr_adaptor(*m_traits); return (tr_adaptor.is_in_x_range_2_object()(cv, p) && m_traits->compare_y_at_x_2_object()(p, cv) == EQUAL); @@ -1979,14 +1769,13 @@ protected: // so we can later identify all the faces that form the original given face // it also should remember the edges of the face, that are also projected // intersections - class Copied_face_observer : public Md_observer - - { + class Copied_face_observer : public Md_observer { public: - typedef typename Minimization_diagram_2::Face_handle Face_handle; - typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle; - typedef typename Minimization_diagram_2::X_monotone_curve_2 - X_monotone_curve_2; + using Base_aos = typename Minimization_diagram_2::Base_aos; + + using Face_handle = typename Base_aos::Face_handle; + using Halfedge_handle = typename Base_aos::Halfedge_handle; + using X_monotone_curve_2 = typename Base_aos::X_monotone_curve_2; Copied_face_observer(Halfedges_map& map_h) : map_halfedges(map_h) {} @@ -1998,8 +1787,7 @@ protected: Faces_hash& parts, Vertices_hash& boundaryv, Vertices_hash& specialv, - Vertices_to_edges_map& v_to_h) - { + Vertices_to_edges_map& v_to_h) { boundary_halfedges = &boundary; special_edges = &specialh; new_edges = &newh; @@ -2010,20 +1798,16 @@ protected: } virtual void after_split_face(Face_handle org_f, - Face_handle new_f, bool) - { + Face_handle new_f, bool) override { // keep track of the face parts if (face_parts->is_defined(org_f)) (*face_parts)[new_f] = face_parts->default_value(); } virtual void after_split_edge(Halfedge_handle org_he, - Halfedge_handle new_he) - { + Halfedge_handle new_he) override { // take care of special edges that were split - if (special_edges->is_defined(org_he)) - - { + if (special_edges->is_defined(org_he)) { // if original edge was in the set, then now both split parts should // be in the set (*special_edges)[new_he] = special_edges->default_value(); @@ -2031,15 +1815,13 @@ protected: } // take care of new edges that were split - if (new_edges->is_defined(org_he)) - { + if (new_edges->is_defined(org_he)) { (*new_edges)[new_he] = (*new_edges)[org_he]; (*new_edges)[new_he->twin()] = (*new_edges)[org_he]; } // take care for boundary edges - if (boundary_halfedges->is_defined(org_he)) - { + if (boundary_halfedges->is_defined(org_he)) { (*boundary_halfedges)[new_he] = boundary_halfedges->default_value(); (*boundary_halfedges)[new_he->twin()] = boundary_halfedges->default_value(); @@ -2051,8 +1833,8 @@ protected: CGAL_assertion(map_halfedges.is_defined(org_he)); CGAL_assertion(org_he->target() == new_he->source()); - if ((map_halfedges[org_he])->get_has_equal_aux_data_in_face(0) && - (map_halfedges[org_he])->get_has_equal_aux_data_in_face(1)) + if ((map_halfedges[org_he])->has_equal_aux_data_in_face(0) && + (map_halfedges[org_he])->has_equal_aux_data_in_face(1)) (*special_vertices)[org_he->target()] = special_vertices->default_value(); @@ -2066,8 +1848,7 @@ protected: Halfedge_handle correct_side_he; if (face_parts->is_defined(org_he->face())) correct_side_he = org_he; - else - { + else { CGAL_assertion(face_parts->is_defined(new_he->twin()->face())); // new_he->twin() is directed as org_he, so on the boundary pointing // inside the face, and has the new vertex as target @@ -2078,9 +1859,11 @@ protected: (*vertices_to_halfedges)[org_he->target()] = correct_side_he; //BZBZ - /* CGAL_assertion(vertices_to_halfedges->is_defined(correct_side_he->source()) && - vertices_to_halfedges->is_defined(correct_side_he->next()->target()));*/ - (*vertices_to_halfedges)[correct_side_he->next()->target()] = correct_side_he->next(); + // CGAL_assertion + // (vertices_to_halfedges->is_defined(correct_side_he->source()) && + // vertices_to_halfedges->is_defined(correct_side_he->next()->target())); + (*vertices_to_halfedges)[correct_side_he->next()->target()] = + correct_side_he->next(); if (correct_side_he == org_he && face_parts->is_defined(org_he->twin()->face())) @@ -2100,46 +1883,42 @@ protected: Halfedges_map& map_halfedges; }; - // this observer is used in the process of resolving a face // it listens to what happens in the copied arrangement, and copies back // the actions to result arrangements very efficiently - class Copy_observer : public Md_observer - { + class Copy_observer : public Md_observer { public: - typedef typename Minimization_diagram_2::Face_handle Face_handle; - typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle; - typedef typename Minimization_diagram_2::Vertex_handle Vertex_handle; - typedef typename Minimization_diagram_2::Point_2 Point_2; - typedef typename Minimization_diagram_2::X_monotone_curve_2 - X_monotone_curve_2; - typedef typename Minimization_diagram_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; + using Base_aos = typename Minimization_diagram_2::Base_aos; - typedef typename Traits::Left_side_category Left_side_category; - typedef typename Traits::Right_side_category Right_side_category; - typedef typename Traits::Top_side_category Top_side_category; - typedef typename Traits::Bottom_side_category Bottom_side_category; + using Face_handle = typename Base_aos::Face_handle; + using Halfedge_handle = typename Base_aos::Halfedge_handle; + using Vertex_handle = typename Base_aos::Vertex_handle; + using Point_2 = typename Base_aos::Point_2; + using X_monotone_curve_2 = typename Base_aos::X_monotone_curve_2; + using Ccb_halfedge_circulator = typename Base_aos::Ccb_halfedge_circulator; + + using Left_side_category = typename Traits::Left_side_category; + using Right_side_category = typename Traits::Right_side_category; + using Top_side_category = typename Traits::Top_side_category; + using Bottom_side_category = typename Traits::Bottom_side_category; Copy_observer(Minimization_diagram_2& small_, Minimization_diagram_2& big, Halfedges_map& map_h, - Vertices_map& map_v, - Faces_map& map_f) - : small_arr(small_), big_arr(big), - big_arr_accessor(big_arr), - map_halfedges(map_h), - map_vertices(map_v), - map_faces(map_f) + Vertices_map& map_v, + Faces_map& map_f) : + small_arr(small_), big_arr(big), + big_arr_accessor(big_arr), + map_halfedges(map_h), + map_vertices(map_v), + map_faces(map_f) {} virtual ~Copy_observer() {} - virtual void before_create_vertex (const Point_2& /* p */) - {} + virtual void before_create_vertex (const Point_2& /* p */) override {} - virtual void after_create_vertex (Vertex_handle v) - { + virtual void after_create_vertex (Vertex_handle v) override { // should create a new vertex with v->point() inside Vertex_handle new_v = big_arr_accessor.create_vertex(v->point()); @@ -2150,11 +1929,11 @@ protected: new_vertices.push_back(v); } - void before_create_boundary_vertex (const X_monotone_curve_2& cv, - Arr_curve_end ind, - Arr_parameter_space in_ps_x, - Arr_parameter_space in_ps_y) - { + virtual void before_create_boundary_vertex(const X_monotone_curve_2& cv, + Arr_curve_end ind, + Arr_parameter_space in_ps_x, + Arr_parameter_space in_ps_y) + override { boundary_vertex_cv = cv; boundary_vertex_ind = ind; ps_x = in_ps_x; @@ -2164,8 +1943,7 @@ protected: bool is_bounded_impl(Arr_open_side_tag) { return false; } bool is_bounded_impl(Arr_boundary_side_tag) { return true; } - bool is_bounded() - { + bool is_bounded() { // This is the case of create boundary vertex. CGAL_assertion((ps_x != ARR_INTERIOR) || (ps_y != ARR_INTERIOR)); @@ -2185,8 +1963,7 @@ protected: return true; } - void after_create_boundary_vertex(Vertex_handle v) - { + virtual void after_create_boundary_vertex(Vertex_handle v) override { CGAL_assertion(big_arr.is_valid()); Vertex_handle new_v = big_arr_accessor.create_boundary_vertex(boundary_vertex_cv, @@ -2194,22 +1971,20 @@ protected: ps_x, ps_y, true); // add indication of a new vertex (that is not connected to anything, // and is also not isolated) - if (is_bounded()) - new_vertices.push_back(v); + if (is_bounded()) new_vertices.push_back(v); map_vertices[v] = new_v; } - void before_split_fictitious_edge(Halfedge_handle e, - Vertex_handle v) - { + virtual void + before_split_fictitious_edge(Halfedge_handle e, Vertex_handle v) override { split_fict_v = v; split_fict_e = e; } - void after_split_fictitious_edge(Halfedge_handle e1, - Halfedge_handle e2) - { + virtual void + after_split_fictitious_edge(Halfedge_handle e1, Halfedge_handle e2) + override { // find the corresponding split vertex in big_arr CGAL_assertion(map_vertices.is_defined(split_fict_v)); Vertex_handle big_v = map_vertices[split_fict_v]; @@ -2236,8 +2011,7 @@ protected: virtual void before_create_edge(const X_monotone_curve_2& /* c */, Vertex_handle v1, - Vertex_handle v2) - { + Vertex_handle v2) override { // save state for after_create_edge event create_edge_v1 = v1; create_edge_v2 = v2; @@ -2245,9 +2019,7 @@ protected: is_in_relocate = false; } - virtual void after_create_edge(Halfedge_handle e) - - { + virtual void after_create_edge(Halfedge_handle e) override { // a new edge e was created in small_arr, we should create a corresponding // edge in big_arr CGAL_assertion(map_vertices.is_defined(create_edge_v1)); @@ -2261,18 +2033,14 @@ protected: // if we have 2 new vertices, they must be new. // if we have only one, we should check which is new bool v1_is_new = false, v2_is_new = false; - if (new_vertices.size() == 1) - { - if (new_vertices.back() == create_edge_v1) - v1_is_new = true; - else - { + if (new_vertices.size() == 1) { + if (new_vertices.back() == create_edge_v1) v1_is_new = true; + else { CGAL_assertion(new_vertices.back() == create_edge_v2); v2_is_new = true; } } - if (new_vertices.size() == 2) - { + if (new_vertices.size() == 2) { v1_is_new = true; v2_is_new = true; } @@ -2286,15 +2054,13 @@ protected: // if an endpoint is not new, but is isolated, we should remove it from // its face's isolated vertices list, and treat it as new - if (!v1_is_new && big_v1->is_isolated()) - { + if (!v1_is_new && big_v1->is_isolated()) { //Face_handle f = big_v1->face(); //big_arr.incident_face(big_v1); //big_arr_accessor.find_and_erase_isolated_vertex(f, big_v1); big_arr_accessor.remove_isolated_vertex_ex(big_v1); v1_is_new = true; } - if (!v2_is_new && big_v2->is_isolated()) - { + if (! v2_is_new && big_v2->is_isolated()) { //Face_handle f = big_v2->face(); //big_arr.incident_face(big_v2); //big_arr_accessor.find_and_erase_isolated_vertex(f, big_v2); big_arr_accessor.remove_isolated_vertex_ex(big_v2); @@ -2302,8 +2068,7 @@ protected: } // now use the approppriate method to insert the new edge - if (v1_is_new && v2_is_new) - { + if (v1_is_new && v2_is_new) { // if both vertices are new - use the O(1) operation // _insert_in_face_interior (in the face mapped to by he->face()) CGAL_assertion(map_faces.is_defined(he->face())); @@ -2320,8 +2085,7 @@ protected: map_halfedges[he] = new_he; map_halfedges[he->twin()] = new_he->twin(); } - else if (!v1_is_new && !v2_is_new) - { + else if (! v1_is_new && ! v2_is_new) { // if both vertices are old - use _insert_at_vertices // this is a linear action by the size of the faces involved // we can get relevant prev halfedges from he @@ -2361,8 +2125,7 @@ protected: // if a new face was created update its mapping too // the new face is the incident face of he - if (new_face) - { + if (new_face) { map_faces[he->face()] = new_he->face(); // save state for move_hole/move_isolated_vertex events is_in_relocate = true; @@ -2373,16 +2136,14 @@ protected: CGAL_assertion(map_faces.is_defined(he->face()) && map_faces[he->face()] == new_he->face()); } - else - { + else { // only one vertex is new - use the O(1) operation _insert_from_vertex // we can get the relevant prev halfedge from e Halfedge_handle prev = he->prev(); CGAL_assertion(map_halfedges.is_defined(prev)); Halfedge_handle big_prev = map_halfedges[prev]; Halfedge_handle new_he; - if (!v1_is_new) - { + if (! v1_is_new) { new_he = big_arr_accessor.insert_from_vertex_ex(big_prev, he->curve(), (HE_COMP_RES(he) == SMALLER ? ARR_LEFT_TO_RIGHT : ARR_RIGHT_TO_LEFT), big_v2); @@ -2392,8 +2153,7 @@ protected: map_halfedges[he] = new_he; map_halfedges[he->twin()] = new_he->twin(); } - else - { + else { new_he = big_arr_accessor.insert_from_vertex_ex(big_prev, he->curve(), (HE_COMP_RES(he->twin()) == SMALLER ? ARR_LEFT_TO_RIGHT : ARR_RIGHT_TO_LEFT), @@ -2411,14 +2171,13 @@ protected: Vertex_handle v, const X_monotone_curve_2& /* c1 */, const X_monotone_curve_2& /* c2 */) - { + override { // save state info for using _split_edge in after event split_v = v; split_e = e; } - virtual void after_split_edge (Halfedge_handle e1, - Halfedge_handle e2) - { + virtual void after_split_edge(Halfedge_handle e1, + Halfedge_handle e2) override { // find the corresponding split vertex in big_arr CGAL_assertion(map_vertices.is_defined(split_v)); Vertex_handle big_v = map_vertices[split_v]; @@ -2449,15 +2208,12 @@ protected: } virtual void before_add_isolated_vertex(Face_handle f, - Vertex_handle /* v */) - { - saved_face = f; - } - virtual void after_add_isolated_vertex(Vertex_handle v) - { + Vertex_handle /* v */) override + { saved_face = f; } + + virtual void after_add_isolated_vertex(Vertex_handle v) override { // make sure it is the only new vertex right now - CGAL_assertion(new_vertices.size() == 1 && - new_vertices.back() == v); + CGAL_assertion(new_vertices.size() == 1 && new_vertices.back() == v); new_vertices.pop_back(); @@ -2467,8 +2223,7 @@ protected: // find features in big_arr Vertex_handle big_v = map_vertices[v]; - Face_handle big_face = map_faces[saved_face]; - + Face_handle big_face = map_faces[saved_face]; // can use O(1) operation _insert_isolated_vertex big_arr_accessor.insert_isolated_vertex(big_face, big_v); @@ -2476,15 +2231,14 @@ protected: virtual void before_move_inner_ccb(Face_handle from_f, Face_handle to_f, - Ccb_halfedge_circulator ) - { + Ccb_halfedge_circulator) override { // should be used after insert_at_vertices which creates a new face CGAL_assertion(is_in_relocate); move_from = from_f; move_to = to_f; } - virtual void after_move_inner_ccb(Ccb_halfedge_circulator h) - { + + virtual void after_move_inner_ccb(Ccb_halfedge_circulator h) override { CGAL_assertion(map_faces.is_defined(move_from)); CGAL_assertion(map_faces.is_defined(move_to)); CGAL_assertion(map_halfedges.is_defined(h)); @@ -2501,16 +2255,14 @@ protected: virtual void before_move_isolated_vertex(Face_handle from_f, Face_handle to_f, - Vertex_handle ) - { + Vertex_handle) override { // should be used after insert_at_vertices which creates a new face CGAL_assertion(is_in_relocate); move_from = from_f; move_to = to_f; } - virtual void after_move_isolated_vertex(Vertex_handle v) - { + virtual void after_move_isolated_vertex(Vertex_handle v) override { CGAL_assertion(map_faces.is_defined(move_from)); CGAL_assertion(map_faces.is_defined(move_to)); CGAL_assertion(map_vertices.is_defined(v)); @@ -2525,12 +2277,12 @@ protected: protected: Minimization_diagram_2& small_arr; Minimization_diagram_2& big_arr; - Md_accessor big_arr_accessor; + Md_accessor big_arr_accessor; // mappings between small_arr features to big_arr features Halfedges_map& map_halfedges; - Vertices_map& map_vertices; - Faces_map& map_faces; + Vertices_map& map_vertices; + Faces_map& map_faces; std::deque new_vertices; // state for actions @@ -2538,35 +2290,33 @@ protected: Vertex_handle create_edge_v2; Vertex_handle split_v, split_fict_v; Halfedge_handle split_e, split_fict_e; - Face_handle saved_face; - Face_handle move_from; - Face_handle move_to; + Face_handle saved_face; + Face_handle move_from; + Face_handle move_to; // for the create_vertex call-back - X_monotone_curve_2 boundary_vertex_cv; - Arr_curve_end boundary_vertex_ind; + X_monotone_curve_2 boundary_vertex_cv; + Arr_curve_end boundary_vertex_ind; Arr_parameter_space ps_x; Arr_parameter_space ps_y; bool is_in_relocate; - }; // A zone visitor for the Minimization Diagram which only inserts // parts of the curve which are inside a given face // it also remembers those parts which overlap the boundary of the original // face - class Copied_face_zone_visitor - { + class Copied_face_zone_visitor { public: - typedef typename Minimization_diagram_2::Vertex_handle Vertex_handle; - typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle; - typedef typename Minimization_diagram_2::Face_handle Face_handle; + using Vertex_handle = typename Minimization_diagram_2::Vertex_handle; + using Halfedge_handle = typename Minimization_diagram_2::Halfedge_handle; + using Face_handle = typename Minimization_diagram_2::Face_handle; - typedef typename Minimization_diagram_2::Point_2 Point_2; - typedef typename Minimization_diagram_2::X_monotone_curve_2 - X_monotone_curve_2; + using Point_2 = typename Minimization_diagram_2::Point_2; + using X_monotone_curve_2 = + typename Minimization_diagram_2::X_monotone_curve_2; - typedef std::pair Result; + using Result = std::pair; Copied_face_zone_visitor(Minimization_diagram_2& result, Minimization_diagram_2& copied, @@ -2579,27 +2329,26 @@ protected: Halfedges_w_type_list& new_edges, Faces_list& face_parts, Vertices_list& sv, // special vertices - Self* p) - : copied_arr(copied), - result_arr(result), - result_original_face(orig_face), - map_halfedges(map_h), - map_vertices(map_v), - map_faces(map_f), - result_special_edges(se), - result_new_edges(new_edges), - result_face_parts(face_parts), - result_special_vertices(sv), - md_copy_observer(copied, result, map_h, map_v, map_f), - md_observer(map_h), - parent(p) + Self* p) : + copied_arr(copied), + result_arr(result), + result_original_face(orig_face), + map_halfedges(map_h), + map_vertices(map_v), + map_faces(map_f), + result_special_edges(se), + result_new_edges(new_edges), + result_face_parts(face_parts), + result_special_vertices(sv), + md_copy_observer(copied, result, map_h, map_v, map_f), + md_observer(map_h), + parent(p) { // init maps copied_face_parts[copied_face] = copied_face_parts.default_value(); - Halfedge_iterator hi = copied_arr.halfedges_begin(); - for (; hi != copied_arr.halfedges_end(); ++hi) - { + for (auto hi = copied_arr.halfedges_begin(); + hi != copied_arr.halfedges_end(); ++hi) { copied_arr_boundary_halfedges[hi] = copied_arr_boundary_halfedges.default_value(); if (hi->face() == copied_face && @@ -2607,14 +2356,12 @@ protected: copied_vertices_to_halfedges[hi->target()] = hi; } - Vertex_iterator vi = copied_arr.vertices_begin(); - for (; vi != copied_arr.vertices_end(); ++vi) - { + for (auto vi = copied_arr.vertices_begin(); + vi != copied_arr.vertices_end(); ++vi) { copied_arr_orig_vertices[vi] = copied_arr_orig_vertices.default_value(); - if (vi->is_isolated()) - { + if (vi->is_isolated()) { CGAL_assertion(vi->face() == copied_face); copied_vertices_to_halfedges[vi] = Halfedge_handle(nullptr); } @@ -2640,14 +2387,12 @@ protected: // the zone visitor functions /*! Initialize the visitor with an arrangement object. */ - void init (Minimization_diagram_2* arr) - { + void init(Minimization_diagram_2* arr) { CGAL_assertion(&copied_arr == arr); insert_visitor.init(arr); } - /*! - * Handle the a subcurve located in the interior of a given face. + /*! Handle the a subcurve located in the interior of a given face. * \param cv The subcurve. * \param face The face containing cv's interior. * \param left_v The vertex that corresponds to the left endpoint of cv @@ -2666,11 +2411,9 @@ protected: Result found_subcurve(const X_monotone_curve_2& cv, Face_handle face, Vertex_handle left_v, Halfedge_handle left_he, - Vertex_handle right_v, Halfedge_handle right_he) - { + Vertex_handle right_v, Halfedge_handle right_he) { // insert the curve only if the face is ok - if (is_face_ok(face)) - { + if (is_face_ok(face)) { CGAL_assertion(copied_arr.is_valid()); Result base_result = insert_visitor.found_subcurve(cv, face, left_v, left_he, @@ -2711,59 +2454,55 @@ protected: // and the vertex (or the vertex info if it was isolated) // otherwise, we set flags to true since it is a new vertex inside the // original face, and have same aux data as all face parts - if (is_boundary_vertex(new_he->target())) - { + if (is_boundary_vertex(new_he->target())) { Vertex_handle cur_t = new_he->target(); CGAL_assertion(copied_vertices_to_halfedges.is_defined(cur_t)); Halfedge_handle copied_b_he = copied_vertices_to_halfedges[cur_t]; - if (copied_b_he == Halfedge_handle(nullptr)) - { + if (copied_b_he == Halfedge_handle(nullptr)) { // this was an isolated vertex, which we touch // since we have in the new edge aux sources as in the face, // we can copy the vertex-face flags from the vertex result_new_he->set_is_equal_aux_data_in_target - (0, cur_t->get_is_equal_aux_data_in_face(0)); + (0, cur_t->is_equal_aux_data_in_face(0)); result_new_he->set_is_equal_aux_data_in_target - (1, cur_t->get_is_equal_aux_data_in_face(1)); + (1, cur_t->is_equal_aux_data_in_face(1)); result_new_he->set_has_equal_aux_data_in_target - (0, cur_t->get_has_equal_aux_data_in_face(0)); + (0, cur_t->has_equal_aux_data_in_face(0)); result_new_he->set_has_equal_aux_data_in_target - (1, cur_t->get_has_equal_aux_data_in_face(1)); + (1, cur_t->has_equal_aux_data_in_face(1)); result_new_he->set_has_equal_aux_data_in_target_and_face - (0, cur_t->get_has_equal_aux_data_in_face(0)); + (0, cur_t->has_equal_aux_data_in_face(0)); result_new_he->set_has_equal_aux_data_in_target_and_face - (1, cur_t->get_has_equal_aux_data_in_face(1)); + (1, cur_t->has_equal_aux_data_in_face(1)); } - else - { + else { CGAL_assertion(copied_b_he->target() == cur_t); CGAL_assertion(is_boundary_edge(copied_b_he)); Halfedge_handle b_he = map_halfedges[copied_b_he]; bool flag; - flag = (b_he->get_is_equal_aux_data_in_face(0) && - b_he->get_is_equal_aux_data_in_target(0)); + flag = (b_he->is_equal_aux_data_in_face(0) && + b_he->is_equal_aux_data_in_target(0)); result_new_he->set_is_equal_aux_data_in_target(0, flag); - flag = (b_he->get_is_equal_aux_data_in_face(1) && - b_he->get_is_equal_aux_data_in_target(1)); + flag = (b_he->is_equal_aux_data_in_face(1) && + b_he->is_equal_aux_data_in_target(1)); result_new_he->set_is_equal_aux_data_in_target(1, flag); - flag = b_he->get_has_equal_aux_data_in_target_and_face(0); + flag = b_he->has_equal_aux_data_in_target_and_face(0); //CGAL_assertion(flag == parent->has_equal_aux_data(0, b_he->face(), b_he->target())); result_new_he->set_has_equal_aux_data_in_target(0, flag); result_new_he->set_has_equal_aux_data_in_target_and_face(0, flag); - flag = b_he->get_has_equal_aux_data_in_target_and_face(1); + flag = b_he->has_equal_aux_data_in_target_and_face(1); //CGAL_assertion(flag == parent->has_equal_aux_data(1, b_he->face(), b_he->target())); result_new_he->set_has_equal_aux_data_in_target(1, flag); result_new_he->set_has_equal_aux_data_in_target_and_face(1, flag); } } - else // not a boundary vertex - { + else { // not a boundary vertex result_new_he->set_is_equal_aux_data_in_target(0, true); result_new_he->set_is_equal_aux_data_in_target(1, true); // the face's data is not empty - so it is ok to set "true" here @@ -2773,57 +2512,53 @@ protected: result_new_he->set_has_equal_aux_data_in_target_and_face(1, true); } - if (is_boundary_vertex(new_he->source())) - { + if (is_boundary_vertex(new_he->source())) { Vertex_handle cur_t = new_he->source(); CGAL_assertion(copied_vertices_to_halfedges.is_defined(cur_t)); Halfedge_handle copied_b_he = copied_vertices_to_halfedges[cur_t]; - if (copied_b_he == Halfedge_handle(nullptr)) - { + if (copied_b_he == Halfedge_handle(nullptr)) { // this was an isolated vertex, which we touch // since we have in the new edge aux sources as in the face, // we can copy the vertex-face flags from the vertex result_new_he->twin()->set_is_equal_aux_data_in_target - (0, cur_t->get_is_equal_aux_data_in_face(0)); + (0, cur_t->is_equal_aux_data_in_face(0)); result_new_he->twin()->set_is_equal_aux_data_in_target - (1, cur_t->get_is_equal_aux_data_in_face(1)); + (1, cur_t->is_equal_aux_data_in_face(1)); result_new_he->twin()->set_has_equal_aux_data_in_target - (0, cur_t->get_has_equal_aux_data_in_face(0)); + (0, cur_t->has_equal_aux_data_in_face(0)); result_new_he->twin()->set_has_equal_aux_data_in_target - (1, cur_t->get_has_equal_aux_data_in_face(1)); + (1, cur_t->has_equal_aux_data_in_face(1)); result_new_he->twin()->set_has_equal_aux_data_in_target_and_face - (0, cur_t->get_has_equal_aux_data_in_face(0)); + (0, cur_t->has_equal_aux_data_in_face(0)); result_new_he->twin()->set_has_equal_aux_data_in_target_and_face - (1, cur_t->get_has_equal_aux_data_in_face(1)); + (1, cur_t->has_equal_aux_data_in_face(1)); } - else - { + else { CGAL_assertion(copied_b_he->target() == cur_t); CGAL_assertion(is_boundary_edge(copied_b_he)); Halfedge_handle b_he = map_halfedges[copied_b_he]; bool flag; - flag = (b_he->get_is_equal_aux_data_in_face(0) && - b_he->get_is_equal_aux_data_in_target(0)); + flag = (b_he->is_equal_aux_data_in_face(0) && + b_he->is_equal_aux_data_in_target(0)); result_new_he->twin()->set_is_equal_aux_data_in_target(0, flag); - flag = (b_he->get_is_equal_aux_data_in_face(1) && - b_he->get_is_equal_aux_data_in_target(1)); + flag = (b_he->is_equal_aux_data_in_face(1) && + b_he->is_equal_aux_data_in_target(1)); result_new_he->twin()->set_is_equal_aux_data_in_target(1, flag); - flag = b_he->get_has_equal_aux_data_in_target_and_face(0); - //CGAL_assertion(flag == parent->has_equal_aux_data(0, b_he->face(), b_he->target())); + flag = b_he->has_equal_aux_data_in_target_and_face(0); + // CGAL_assertion(flag == parent->has_equal_aux_data(0, b_he->face(), b_he->target())); result_new_he->twin()->set_has_equal_aux_data_in_target(0, flag); result_new_he->twin()->set_has_equal_aux_data_in_target_and_face(0, flag); - flag = b_he->get_has_equal_aux_data_in_target_and_face(1); + flag = b_he->has_equal_aux_data_in_target_and_face(1); //CGAL_assertion(flag == parent->has_equal_aux_data(1, b_he->face(), b_he->target())); result_new_he->twin()->set_has_equal_aux_data_in_target(1, flag); result_new_he->twin()->set_has_equal_aux_data_in_target_and_face(1, flag); } } - else - { + else { result_new_he->twin()->set_is_equal_aux_data_in_target(0, true); result_new_he->twin()->set_is_equal_aux_data_in_target(1, true); result_new_he->twin()->set_has_equal_aux_data_in_target(0, true); @@ -2834,8 +2569,7 @@ protected: return base_result; } - else - { + else { // we don't insert the subcurve, but it might touch a vertex of the // face's boundary - we need to check it and identify special vertices if (left_v != Vertex_handle(nullptr) && @@ -2853,8 +2587,7 @@ protected: } } - /*! - * Handle the a subcurve that overlaps a given edge. + /*! Handle the a subcurve that overlaps a given edge. * \param cv The overlapping subcurve. * \param he The overlapped halfedge (directed from left to right). * \param left_v The vertex that corresponds to the left endpoint of cv @@ -2868,8 +2601,7 @@ protected: */ Result found_overlap(const X_monotone_curve_2& cv, Halfedge_handle he, - Vertex_handle left_v, Vertex_handle right_v) - { + Vertex_handle left_v, Vertex_handle right_v) { // check if the halfedge is the boundary of the original face // (here we assume that this indication is dealt with in an observer // attached to the md, and implements split_edge) @@ -2892,12 +2624,10 @@ protected: copied_arr_special_vertices[overlap_he->target()] = copied_arr_special_vertices.default_value(); - if (!is_boundary) - return base_res; + if (! is_boundary) return base_res; // if he is a boundary edge, it is a special edge - if (is_boundary) - { + if (is_boundary) { copied_arr_special_edges[overlap_he] = copied_arr_special_edges.default_value(); copied_arr_special_edges[overlap_he->twin()] = @@ -2906,52 +2636,46 @@ protected: return base_res; } - /*! - - * Handle point that lies inside a given face. + /*! Handle point that lies inside a given face. * \param p The point. * \param face The face inside which the point lies. * \return A handle to the new vertex obtained from the insertion of the * point into the face, or invalid handle if the point wasn't * inserted to the arrangement. */ - Vertex_handle found_point_in_face(const Point_2& p, Face_handle face) - { + Vertex_handle found_point_in_face(const Point_2& p, Face_handle face) { // p lies inside a face: Insert it as an isolated vertex it the interior // of this face. Vertex_handle vh_for_p; - if (is_face_ok(face)) - { + if (is_face_ok(face)) { Arr_accessor arr_access (copied_arr); arr_access.notify_before_global_change(); vh_for_p = copied_arr.insert_in_face_interior(p, face); arr_access.notify_after_global_change(); - // now should set the is_equal and has_equal flags - CGAL_assertion(map_vertices.is_defined(vh_for_p)); - Vertex_handle result_new_v = map_vertices[vh_for_p]; - result_new_v->set_is_equal_aux_data_in_face(0, true); - result_new_v->set_is_equal_aux_data_in_face(1, true); + // now should set the is_equal and has_equal flags + CGAL_assertion(map_vertices.is_defined(vh_for_p)); + Vertex_handle result_new_v = map_vertices[vh_for_p]; + result_new_v->set_is_equal_aux_data_in_face(0, true); + result_new_v->set_is_equal_aux_data_in_face(1, true); result_new_v->set_has_equal_aux_data_in_face(0, true); - result_new_v->set_has_equal_aux_data_in_face(1, true); + result_new_v->set_has_equal_aux_data_in_face(1, true); } return vh_for_p; } - /*! - * Handle point that lies on a given edge. + /*! Handle point that lies on a given edge. * \param p The point. * \param he The edge on which the point lies. * \return A handle to the new vertex obtained from the insertion of the * point into the edge, or invalid handle if the point wasn't * inserted to the arrangement. */ - Vertex_handle found_point_on_edge(const Point_2& p, Halfedge_handle he) - { + Vertex_handle found_point_on_edge(const Point_2& p, Halfedge_handle he) { // p lies in the interior of an edge: Split this edge to create a new // vertex associated with p. - X_monotone_curve_2 sub_cv1, sub_cv2; - Halfedge_handle split_he; + X_monotone_curve_2 sub_cv1, sub_cv2; + Halfedge_handle split_he; copied_arr.geometry_traits()-> split_2_object() (he->curve(), p, sub_cv1, sub_cv2); @@ -2971,15 +2695,13 @@ protected: return split_he->target(); } - /*! - * Handle point that lies on a given vertex. + /*! Handle point that lies on a given vertex. * \param p The point. * \param v The vertex on which the point lies. * \return A handle to the new vertex obtained from the modifying * the existing vertex. */ - Vertex_handle found_point_on_vertex(const Point_2& p, Vertex_handle v) - { + Vertex_handle found_point_on_vertex(const Point_2& p, Vertex_handle v) { // if the vertex is a boundary vertex, then it is a special vertex // if it was created by split of a boundary edge, then it is already // marked as special. we need to mark it as special if it is an original @@ -2991,37 +2713,31 @@ protected: return copied_arr.modify_vertex (v, p); } - /*! - * Update all the output collections using the internal data saved during + /*! Update all the output collections using the internal data saved during * the previous inserts. * Should be called after all inserts have finished. */ - void finish() - { + void finish() { // result_special_edges // result_new_edges - Halfedge_iterator hi = copied_arr.halfedges_begin(); - for (; hi != copied_arr.halfedges_end(); ++hi, ++hi) - { + for (auto hi = copied_arr.halfedges_begin(); + hi != copied_arr.halfedges_end(); ++hi, ++hi) { Halfedge_handle h = hi; CGAL_assertion(map_halfedges.is_defined(h) && map_halfedges.is_defined(h->twin())); - // we need only one of the twin halfedges to represent the new edge if (copied_arr_new_edges.is_defined(h)) result_new_edges.push_back(std::make_pair(map_halfedges[h], copied_arr_new_edges[h])); - if (copied_arr_special_edges.is_defined(h)) - { + if (copied_arr_special_edges.is_defined(h)) { // we need the halfedge that its incident face is inside the original // face Face_handle f1 = h->face(); if (copied_face_parts.is_defined(f1)) result_special_edges.push_back(map_halfedges[h]); - else - { + else { CGAL_assertion_code(Face_handle f2 = h->twin()->face()); CGAL_assertion(copied_face_parts.is_defined(f2)); result_special_edges.push_back(map_halfedges[h->twin()]); @@ -3030,28 +2746,23 @@ protected: } // result_face_parts - Face_iterator fi = copied_arr.faces_begin(); - for (; fi != copied_arr.faces_end(); ++fi) - { + for (auto fi = copied_arr.faces_begin(); fi != copied_arr.faces_end(); + ++fi) { Face_handle f = fi; - if (copied_face_parts.is_defined(f)) - { + if (copied_face_parts.is_defined(f)) { CGAL_assertion(map_faces.is_defined(f)); result_face_parts.push_back(map_faces[f]); } } // result_special_vertices - Vertex_iterator vi = copied_arr.vertices_begin(); - for (; vi != copied_arr.vertices_end(); ++vi) - - { + for (auto vi = copied_arr.vertices_begin(); + vi != copied_arr.vertices_end(); ++vi) { Vertex_handle v = vi; CGAL_assertion(map_vertices.is_defined(v)); Vertex_handle result_v = map_vertices[v]; - if (copied_arr_orig_vertices.is_defined(v)) - { + if (copied_arr_orig_vertices.is_defined(v)) { // original vertex should be mapped to a boundary halfedge whose // target is the vertex CGAL_assertion(copied_vertices_to_halfedges.is_defined(v)); @@ -3074,9 +2785,8 @@ protected: result_special_vertices.push_back(result_v); } } - else - { - if (!copied_arr_new_boundary_vertices.is_defined(v)) + else { + if (! copied_arr_new_boundary_vertices.is_defined(v)) // new vertex inside the face result_special_vertices.push_back(result_v); else if (copied_arr_special_vertices.is_defined(v)) @@ -3085,30 +2795,22 @@ protected: } } - void set_current_intersection_type(Multiplicity t) - { - itype = t; - } + void set_current_intersection_type(Multiplicity t) { itype = t; } protected: - bool is_face_ok(Face_handle face) - { + bool is_face_ok(Face_handle face) { // is this face a part of the original face? // check in the copied_face_parts map return (copied_face_parts.is_defined(face)); } bool is_boundary_edge(Halfedge_handle he) - { - return (copied_arr_boundary_halfedges.is_defined(he)); - } + { return (copied_arr_boundary_halfedges.is_defined(he)); } bool is_original_boundary_vertex(Vertex_handle v) - { - return (copied_arr_orig_vertices.is_defined(v)); - } - bool is_boundary_vertex(Vertex_handle v) - { + { return (copied_arr_orig_vertices.is_defined(v)); } + + bool is_boundary_vertex(Vertex_handle v) { return (copied_arr_orig_vertices.is_defined(v) || copied_arr_new_boundary_vertices.is_defined(v)); } @@ -3135,18 +2837,18 @@ protected: Vertices_list& result_special_vertices; // helper collections (for copied_arr features) - Halfedges_hash copied_arr_boundary_halfedges; - Vertices_hash copied_arr_orig_vertices; - Vertices_hash copied_arr_new_boundary_vertices; + Halfedges_hash copied_arr_boundary_halfedges; + Vertices_hash copied_arr_orig_vertices; + Vertices_hash copied_arr_new_boundary_vertices; Vertices_to_edges_map copied_vertices_to_halfedges; - Halfedges_hash copied_arr_special_edges; + Halfedges_hash copied_arr_special_edges; Halfedges_hash_w_type copied_arr_new_edges; - Faces_hash copied_face_parts; - Vertices_hash copied_arr_special_vertices; + Faces_hash copied_face_parts; + Vertices_hash copied_arr_special_vertices; // this observer will take care of the result arrangegment - Copy_observer md_copy_observer; + Copy_observer md_copy_observer; // this observer will keep all our information in the helper collections // during the insert process @@ -3161,26 +2863,23 @@ protected: }; // this minimization diagram observer updates data in new faces created - class New_faces_observer : public Md_observer - { + class New_faces_observer : public Md_observer { public: - typedef typename Minimization_diagram_2::Face_handle Face_handle; + using Base_aos = typename Minimization_diagram_2::Base_aos; + using Face_handle = typename Base_aos::Face_handle; - New_faces_observer(Minimization_diagram_2& arr) : Md_observer(arr) {} + New_faces_observer(Base_aos& arr) : Md_observer(arr) {} virtual ~New_faces_observer() {} - virtual void after_split_face(Face_handle org_f, - Face_handle new_f, - bool) - { + virtual void after_split_face(Face_handle org_f, Face_handle new_f, bool) + override { // update the new face's aux_data from original face - if (org_f->get_aux_is_set(0)) - new_f->set_aux_source(0, org_f->get_aux_source(0)); - if (org_f->get_aux_is_set(1)) - new_f->set_aux_source(1, org_f->get_aux_source(1)); + if (org_f->aux_is_set(0)) + new_f->set_aux_source(0, org_f->aux_source(0)); + if (org_f->aux_is_set(1)) + new_f->set_aux_source(1, org_f->aux_source(1)); } - }; //! The geometry traits object. diff --git a/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_2.h b/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_2.h index 6951875249e..a7d5773ce34 100644 --- a/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_2.h +++ b/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_2.h @@ -8,8 +8,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Efi Fogel #ifndef CGAL_ENVELOPE_OVERLAY_2_H #define CGAL_ENVELOPE_OVERLAY_2_H @@ -17,40 +18,38 @@ #include +#include + #include #include -#include - namespace CGAL { -template > -class Envelope_overlay_2 -{ +template > +class Envelope_overlay_2 { public: - typedef MinimizationDiagram_2 Minimization_diagram_2; + using Minimization_diagram_2 = MinimizationDiagram_2; - typedef typename Minimization_diagram_2::Face_handle Face_handle; - typedef typename Minimization_diagram_2::Face_iterator Face_iterator; + using Face_handle = typename Minimization_diagram_2::Face_handle; + using Face_iterator = typename Minimization_diagram_2::Face_iterator; - typedef typename Minimization_diagram_2::Vertex_handle Vertex_handle; - typedef typename Minimization_diagram_2::Vertex_iterator Vertex_iterator; + using Vertex_handle = typename Minimization_diagram_2::Vertex_handle; + using Vertex_iterator = typename Minimization_diagram_2::Vertex_iterator; - typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle; - typedef typename Minimization_diagram_2::Halfedge_iterator Halfedge_iterator; + using Halfedge_handle = typename Minimization_diagram_2::Halfedge_handle; + using Halfedge_iterator = typename Minimization_diagram_2::Halfedge_iterator; + + using Overlay_functor = OverlayFunctor; - typedef OverlayFunctor Overlay_functor; protected: - typedef typename Minimization_diagram_2::Geometry_traits_2 Traits; - typedef typename Traits::Xy_monotone_surface_3 Xy_monotone_surface_3; + using Traits = typename Minimization_diagram_2::Geometry_traits_2; + using Xy_monotone_surface_3 = typename Traits::Xy_monotone_surface_3; public: - - void operator()(Minimization_diagram_2& md1, - Minimization_diagram_2& md2, - Minimization_diagram_2& result) - { + void operator()(Minimization_diagram_2& md1, Minimization_diagram_2& md2, + Minimization_diagram_2& result) { CGAL_assertion(md1.is_valid()); CGAL_assertion(md2.is_valid()); @@ -60,184 +59,157 @@ public: CGAL_assertion_code(post_test_assertions(result)); } - public: + /* void print_face(Face_handle fh) { + * std::cout << (fh->is_unbounded() ? "unbounded" : "bounded"); + * + * if (fh->is_env_set()) { + * std::cout << " #data= " << fh->env_data_size(); + * if (fh->env_data_size() > 0) + * std::cout << " data= " << fh->env_data_front(); + * } + * + * if (fh->aux_is_set(0)) { + * std::cout << " #data1= " << number_of_aux_data_objects(fh, 0); + * if (number_of_aux_data_objects(fh, 0)>0) + * std::cout << " data#1= " << aux_data(fh, 0); + * } + * if (fh->aux_is_set(1)) { + * std::cout << " #data2= " << number_of_aux_data_objects(fh, 1); + * if (number_of_aux_data_objects(fh, 1)>0) + * std::cout << " data#2= " << aux_data(fh, 1); + * } + * std::cout << std::endl; + * } + * + * // print the aux data in the faces of md + * void print_faces(Minimization_diagram_2& md) { + * Face_iterator fit = md.faces_begin(); + * for(; fit != md.faces_end(); ++fit) { + * Face_handle fh = fit; + * print_face(fh); + * } + * std::cout << std::endl; + * } + * + * void print_vertices(Minimization_diagram_2& md) { + * Vertex_iterator vit = md.vertices_begin(); + * for(; vit != md.vertices_end(); ++vit) { + * Vertex_handle vh = vit; + * std::cout << vh->point(); + * + * if (vh->is_env_set()) { + * std::cout << " #data= " << vh->env_data_size(); + * if (vh->env_data_size() > 0) + * std::cout << " data= " << vh->env_data_front(); + * } + * + * if (vh->aux_is_set(0)) { + * std::cout << " #data1= " << number_of_aux_data_objects(vh, 0); + * if (number_of_aux_data_objects(vh, 0)>0) + * std::cout << " data#1= " << aux_data(vh, 0); + * } + * if (vh->aux_is_set(1)) { + * std::cout << " #data2= " << number_of_aux_data_objects(vh, 1); + * if (number_of_aux_data_objects(vh, 1)>0) + * std::cout << " data#2= " << aux_data(vh, 1); + * } + * std::cout << std::endl; + * } + * std::cout << std::endl; + * } + * + * void print_edges(Minimization_diagram_2& md) { + * Halfedge_iterator hit = md.halfedges_begin(); + * for(; hit != md.halfedges_end(); ++hit, ++hit) { + * Halfedge_handle hh = hit; + * std::cout << hh->curve(); + * + * if (hh->is_env_set()) { + * std::cout << " #data= " << hh->env_data_size(); + * if (hh->env_data_size() > 0) + * std::cout << " data= " << hh->env_data_front(); + * } + * + * if (hh->aux_is_set(0)) { + * std::cout << " #data1= " << number_of_aux_data_objects(hh, 0); + * if (number_of_aux_data_objects(hh, 0)>0) + * std::cout << " data#1= " << aux_data(hh, 0); + * } + * if (hh->aux_is_set(1)) { + * std::cout << " #data2= " << number_of_aux_data_objects(hh, 1); + * + * if (number_of_aux_data_objects(hh, 1)>0) + * std::cout << " data#2= " << aux_data(hh, 1); + * } + * std::cout << std::endl; + * } + * std::cout << std::endl; + * } + */ - /* - void print_face(Face_handle fh) - { - std::cout << (fh->is_unbounded() ? "unbounded" : "bounded"); - - if (fh->get_is_set()) - { - std::cout << " #data= " << fh->number_of_data_objects(); - if (fh->number_of_data_objects() > 0) - std::cout << " data= " << fh->get_data(); - } - - if (fh->get_aux_is_set(0)) - { - std::cout << " #data1= " << get_number_of_aux_data_objects(fh, 0); - if (get_number_of_aux_data_objects(fh, 0)>0) - std::cout << " data#1= " << get_aux_data(fh, 0); - } - if (fh->get_aux_is_set(1)) - { - std::cout << " #data2= " << get_number_of_aux_data_objects(fh, 1); - if (get_number_of_aux_data_objects(fh, 1)>0) - std::cout << " data#2= " << get_aux_data(fh, 1); - } - std::cout << std::endl; - } - - // print the aux data in the faces of md - void print_faces(Minimization_diagram_2& md) - { - Face_iterator fit = md.faces_begin(); - for(; fit != md.faces_end(); ++fit) - { - Face_handle fh = fit; - print_face(fh); - } - std::cout << std::endl; - } - - void print_vertices(Minimization_diagram_2& md) - { - Vertex_iterator vit = md.vertices_begin(); - for(; vit != md.vertices_end(); ++vit) - { - Vertex_handle vh = vit; - std::cout << vh->point(); - - if (vh->get_is_set()) - { - std::cout << " #data= " << vh->number_of_data_objects(); - if (vh->number_of_data_objects() > 0) - std::cout << " data= " << vh->get_data(); - } - - if (vh->get_aux_is_set(0)) - { - std::cout << " #data1= " << get_number_of_aux_data_objects(vh, 0); - if (get_number_of_aux_data_objects(vh, 0)>0) - std::cout << " data#1= " << get_aux_data(vh, 0); - } - if (vh->get_aux_is_set(1)) - { - std::cout << " #data2= " << get_number_of_aux_data_objects(vh, 1); - if (get_number_of_aux_data_objects(vh, 1)>0) - std::cout << " data#2= " << get_aux_data(vh, 1); - } - std::cout << std::endl; - } - std::cout << std::endl; - } - - void print_edges(Minimization_diagram_2& md) - { - Halfedge_iterator hit = md.halfedges_begin(); - for(; hit != md.halfedges_end(); ++hit, ++hit) - { - Halfedge_handle hh = hit; - std::cout << hh->curve(); - - if (hh->get_is_set()) - { - std::cout << " #data= " << hh->number_of_data_objects(); - if (hh->number_of_data_objects() > 0) - std::cout << " data= " << hh->get_data(); - } - - - if (hh->get_aux_is_set(0)) - { - std::cout << " #data1= " << get_number_of_aux_data_objects(hh, 0); - if (get_number_of_aux_data_objects(hh, 0)>0) - std::cout << " data#1= " << get_aux_data(hh, 0); - } - if (hh->get_aux_is_set(1)) - { - std::cout << " #data2= " << get_number_of_aux_data_objects(hh, 1); - - if (get_number_of_aux_data_objects(hh, 1)>0) - std::cout << " data#2= " << get_aux_data(hh, 1); - } - std::cout << std::endl; - } - std::cout << std::endl; - } - */ - - void post_test_assertions(Minimization_diagram_2& md) - { + void post_test_assertions(Minimization_diagram_2& md) { // check that all data is filled in result - Face_iterator fi = md.faces_begin(); - for(; fi != md.faces_end(); ++fi) - { + for (auto fi = md.faces_begin(); fi != md.faces_end(); ++fi) { Face_handle fh = fi; - CGAL_assertion_msg(fh->get_aux_is_set(0), "data from md1 on face is not set"); - CGAL_assertion_msg(fh->get_aux_is_set(1), "data from md2 on face is not set"); + CGAL_assertion_msg(fh->aux_is_set(0), + "data from md1 on face is not set"); + CGAL_assertion_msg(fh->aux_is_set(1), + "data from md2 on face is not set"); } - Halfedge_iterator hi = md.halfedges_begin(); - for(; hi != md.halfedges_end(); ++hi) - { + for (auto hi = md.halfedges_begin(); hi != md.halfedges_end(); ++hi) { Halfedge_handle hh = hi; - CGAL_assertion_msg(hh->get_aux_is_set(0), "data from md1 on halfedge is not set"); - CGAL_assertion_msg(hh->get_aux_is_set(1), "data from md2 on halfedge is not set"); + CGAL_assertion_msg(hh->aux_is_set(0), + "data from md1 on halfedge is not set"); + CGAL_assertion_msg(hh->aux_is_set(1), + "data from md2 on halfedge is not set"); } - Vertex_iterator vi = md.vertices_begin(); - for(; vi != md.vertices_end(); ++vi) - { + for (auto vi = md.vertices_begin(); vi != md.vertices_end(); ++vi) { Vertex_handle vh = vi; - CGAL_assertion_msg(vh->get_aux_is_set(0), "data from md1 on vertex is not set"); - CGAL_assertion_msg(vh->get_aux_is_set(1), "data from md2 on vertex is not set"); + CGAL_assertion_msg(vh->aux_is_set(0), + "data from md1 on vertex is not set"); + CGAL_assertion_msg(vh->aux_is_set(1), + "data from md2 on vertex is not set"); } } + protected: // helper methods - template - Xy_monotone_surface_3 get_aux_data(FeatureHandle fh, unsigned int id) - { - const Object& o = fh->get_aux_source(id); + template + Xy_monotone_surface_3 aux_data(FeatureHandle fh, unsigned int id) { + const Object& o = fh->aux_source(id); Xy_monotone_surface_3 data; Halfedge_handle h; Vertex_handle v; - Face_handle f; - if (assign(v, o)) - data = v->get_data(); - else if (assign(h, o)) - data = h->get_data(); - else - { - CGAL_assertion(assign(f, o)); + Face_handle f; + if (assign(v, o)) data = v->env_data_front(); + else if (assign(h, o)) data = h->env_data_front(); + else { + CGAL_assertion(assign(f, o)); assign(f, o); - data = f->get_data(); - } + data = f->env_data_front(); + } return data; } - template - int get_number_of_aux_data_objects(FeatureHandle fh, unsigned int id) - { - const Object& o = fh->get_aux_source(id); + + template + int number_of_aux_data_objects(FeatureHandle fh, unsigned int id) { + const Object& o = fh->aux_source(id); int data; Halfedge_handle h; Vertex_handle v; - Face_handle f; - if (assign(v, o)) - data = v->number_of_data_objects(); - else if (assign(h, o)) - data = h->number_of_data_objects(); - else - { - CGAL_assertion(assign(f, o)); + Face_handle f; + if (assign(v, o)) data = v->env_data_size(); + else if (assign(h, o)) data = h->env_data_size(); + else { + CGAL_assertion(assign(f, o)); assign(f, o); - data = f->number_of_data_objects(); - } + data = f->env_data_size(); + } return data; } diff --git a/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_functor.h b/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_functor.h index 3c259c2635f..6b7c6cba674 100644 --- a/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_functor.h +++ b/Envelope_3/include/CGAL/Envelope_3/Envelope_overlay_functor.h @@ -7,8 +7,9 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Efi Fogel #ifndef CGAL_ENVELOPE_OVERLAY_FUNCTOR_H #define CGAL_ENVELOPE_OVERLAY_FUNCTOR_H @@ -20,156 +21,134 @@ namespace CGAL { -template < class MinimizationDiagram_2> -class Envelope_overlay_functor -{ +template +class Envelope_overlay_functor { public: - typedef MinimizationDiagram_2 Minimization_diagram_2; + using Minimization_diagram_2 = MinimizationDiagram_2; - typedef typename Minimization_diagram_2::Face_const_handle Face_const_handle1; - typedef typename Minimization_diagram_2::Face_const_handle Face_const_handle2; +private: + using Md2 = Minimization_diagram_2; - typedef typename Minimization_diagram_2::Vertex_const_handle Vertex_const_handle1; - typedef typename Minimization_diagram_2::Vertex_const_handle Vertex_const_handle2; +public: + using Face_const_handle1 = typename Md2::Face_const_handle; + using Face_const_handle2 = typename Md2::Face_const_handle; - typedef typename Minimization_diagram_2::Halfedge_const_handle Halfedge_const_handle1; - typedef typename Minimization_diagram_2::Halfedge_const_handle Halfedge_const_handle2; + using Vertex_const_handle1 = typename Md2::Vertex_const_handle; + using Vertex_const_handle2 = typename Md2::Vertex_const_handle; - typedef typename Minimization_diagram_2::Face_handle Face_handle; - typedef typename Minimization_diagram_2::Vertex_handle Vertex_handle; - typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle; + using Halfedge_const_handle1 = typename Md2::Halfedge_const_handle; + using Halfedge_const_handle2 = typename Md2::Halfedge_const_handle; - typedef typename Minimization_diagram_2::Face_handle Res_face_handle; - typedef typename Minimization_diagram_2::Halfedge_handle Res_halfedge_handle; - typedef typename Minimization_diagram_2::Vertex_handle Res_vertex_handle; + using Face_handle = typename Md2::Face_handle; + using Vertex_handle = typename Md2::Vertex_handle; + using Halfedge_handle = typename Md2::Halfedge_handle; + + using Res_face_handle = typename Md2::Face_handle; + using Res_halfedge_handle = typename Md2::Halfedge_handle; + using Res_vertex_handle = typename Md2::Vertex_handle; protected: + using Dcel = typename Md2::Dcel; + using Face = typename Dcel::Face; + using Envelope_data_iterator = typename Face::Data_iterator; + using Vertex_face_pair = std::pair; - typedef typename Minimization_diagram_2::Dcel::Dcel_data_iterator Envelope_data_iterator; - typedef std::pair Vertex_face_pair; - struct Less_vertex_face_pair - { - bool operator() (const Vertex_face_pair& vf1, - const Vertex_face_pair& vf2) const - { + struct Less_vertex_face_pair { + bool operator() (const Vertex_face_pair& vf1, const Vertex_face_pair& vf2) + const { Vertex_handle v1 = vf1.first, v2 = vf2.first; Face_handle f1 = vf1.second, f2= vf2.second; - return (&*v1 < &*v2 || - (&*v1 == &*v2 && &*f1 < &*f2)); + return (&*v1 < &*v2 || (&*v1 == &*v2 && &*f1 < &*f2)); } }; - typedef std::map Boundary_cache; + using Boundary_cache = + std::map; public: + Envelope_overlay_functor(Md2& md1, Md2& md2, Md2& result) : + m_1(md1), m_2(md2), m_result(result) + {} - Envelope_overlay_functor(Minimization_diagram_2& md1, - Minimization_diagram_2& md2, - Minimization_diagram_2& result) - : m_1(md1), m_2(md2), m_result(result) - { - } + ~Envelope_overlay_functor() { traversed_vertices.clear(); } - ~Envelope_overlay_functor() - { - traversed_vertices.clear(); - } - - void create_face (Face_const_handle1 f1, Face_const_handle2 f2, Res_face_handle res_f) - { + void create_face(Face_const_handle1 f1, Face_const_handle2 f2, + Res_face_handle res_f) { res_f->set_aux_source(0, m_1.non_const_handle(f1)); res_f->set_aux_source(1, m_2.non_const_handle(f2)); } - void create_vertex(Halfedge_const_handle1 h1, - Halfedge_const_handle2 h2, - Res_vertex_handle res_v) - { + void create_vertex(Halfedge_const_handle1 h1, Halfedge_const_handle2 h2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, m_1.non_const_handle(h1)); res_v->set_aux_source(1, m_2.non_const_handle(h2)); //res_v->set_is_intersection(true); // res_v cannot be isolated } - void create_vertex(Vertex_const_handle1 v1, - Vertex_const_handle2 v2, - Res_vertex_handle res_v) - { + void create_vertex(Vertex_const_handle1 v1, Vertex_const_handle2 v2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, m_1.non_const_handle(v1)); res_v->set_aux_source(1, m_2.non_const_handle(v2)); //res_v->set_is_intersection(false); - if (v1->is_isolated() && v2->is_isolated()) - { - res_v->set_is_equal_aux_data_in_face(0, v1->get_is_equal_data_in_face()); - res_v->set_is_equal_aux_data_in_face(1, v2->get_is_equal_data_in_face()); - res_v->set_has_equal_aux_data_in_face(0, v1->get_has_equal_data_in_face()); - res_v->set_has_equal_aux_data_in_face(1, v2->get_has_equal_data_in_face()); + if (v1->is_isolated() && v2->is_isolated()) { + res_v->set_is_equal_aux_data_in_face(0, v1->is_equal_env_data_in_face()); + res_v->set_is_equal_aux_data_in_face(1, v2->is_equal_env_data_in_face()); + res_v->set_has_equal_aux_data_in_face(0, v1->has_equal_env_data_in_face()); + res_v->set_has_equal_aux_data_in_face(1, v2->has_equal_env_data_in_face()); } } - void create_vertex(Vertex_const_handle1 v1, - Halfedge_const_handle2 h2, - Res_vertex_handle res_v) - { + void create_vertex(Vertex_const_handle1 v1, Halfedge_const_handle2 h2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, m_1.non_const_handle(v1)); res_v->set_aux_source(1, m_2.non_const_handle(h2)); //res_v->set_is_intersection(true); // res_v cannot be isolated } - void create_vertex(Halfedge_const_handle1 h1, - Vertex_const_handle2 v2, - Res_vertex_handle res_v) - { + void create_vertex(Halfedge_const_handle1 h1, Vertex_const_handle2 v2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, m_1.non_const_handle(h1)); res_v->set_aux_source(1, m_2.non_const_handle(v2)); //res_v->set_is_intersection(true); // res_v cannot be isolated } - void create_vertex(Face_const_handle1 f1, - Vertex_const_handle2 v2, - Res_vertex_handle res_v) - { + void create_vertex(Face_const_handle1 f1, Vertex_const_handle2 v2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, m_1.non_const_handle(f1)); res_v->set_aux_source(1, m_2.non_const_handle(v2)); //res_v->set_is_intersection(false); - if (v2->is_isolated()) - { + if (v2->is_isolated()) { // the res_v is also isolated, and we should update the is_equal/has_equal // data in face information res_v->set_is_equal_aux_data_in_face(0, true); - res_v->set_is_equal_aux_data_in_face(1, v2->get_is_equal_data_in_face()); - res_v->set_has_equal_aux_data_in_face(0, !f1->has_no_data()); - res_v->set_has_equal_aux_data_in_face(1, v2->get_has_equal_data_in_face()); + res_v->set_is_equal_aux_data_in_face(1, v2->is_equal_env_data_in_face()); + res_v->set_has_equal_aux_data_in_face(0, ! f1->has_no_env_data()); + res_v->set_has_equal_aux_data_in_face(1, v2->has_equal_env_data_in_face()); } } - void create_vertex(Vertex_const_handle1 v1, - Face_const_handle2 f2, - Res_vertex_handle res_v) - { + void create_vertex(Vertex_const_handle1 v1, Face_const_handle2 f2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, m_1.non_const_handle(v1)); res_v->set_aux_source(1, m_2.non_const_handle(f2)); //res_v->set_is_intersection(false); - if (v1->is_isolated()) - { + if (v1->is_isolated()) { // the res_v is also isolated, and we should update the is_equal/has_equal // data in face information - res_v->set_is_equal_aux_data_in_face(0, v1->get_is_equal_data_in_face()); + res_v->set_is_equal_aux_data_in_face(0, v1->is_equal_env_data_in_face()); res_v->set_is_equal_aux_data_in_face(1, true); - res_v->set_has_equal_aux_data_in_face(0, v1->get_has_equal_data_in_face()); - res_v->set_has_equal_aux_data_in_face(1, !f2->has_no_data()); + res_v->set_has_equal_aux_data_in_face(0, v1->has_equal_env_data_in_face()); + res_v->set_has_equal_aux_data_in_face(1, ! f2->has_no_env_data()); } } - void create_edge(Halfedge_const_handle1 h1, - Halfedge_const_handle2 h2, - Res_halfedge_handle res_h) - { + void create_edge(Halfedge_const_handle1 h1, Halfedge_const_handle2 h2, + Res_halfedge_handle res_h) { // update source res_h->set_aux_source(0, m_1.non_const_handle(h1)); res_h->set_aux_source(1, m_2.non_const_handle(h2)); @@ -178,15 +157,19 @@ public: res_h->twin()->set_aux_source(1, m_2.non_const_handle(h2->twin())); // update is_equal/has_equal data in face - res_h->set_is_equal_aux_data_in_face(0, h1->get_is_equal_data_in_face()); - res_h->set_is_equal_aux_data_in_face(1, h2->get_is_equal_data_in_face()); - res_h->set_has_equal_aux_data_in_face(0, h1->get_has_equal_data_in_face()); - res_h->set_has_equal_aux_data_in_face(1, h2->get_has_equal_data_in_face()); + res_h->set_is_equal_aux_data_in_face(0, h1->is_equal_env_data_in_face()); + res_h->set_is_equal_aux_data_in_face(1, h2->is_equal_env_data_in_face()); + res_h->set_has_equal_aux_data_in_face(0, h1->has_equal_env_data_in_face()); + res_h->set_has_equal_aux_data_in_face(1, h2->has_equal_env_data_in_face()); - res_h->twin()->set_is_equal_aux_data_in_face(0, h1->twin()->get_is_equal_data_in_face()); - res_h->twin()->set_is_equal_aux_data_in_face(1, h2->twin()->get_is_equal_data_in_face()); - res_h->twin()->set_has_equal_aux_data_in_face(0, h1->twin()->get_has_equal_data_in_face()); - res_h->twin()->set_has_equal_aux_data_in_face(1, h2->twin()->get_has_equal_data_in_face()); + res_h->twin()->set_is_equal_aux_data_in_face(0, h1->twin()-> + is_equal_env_data_in_face()); + res_h->twin()->set_is_equal_aux_data_in_face(1, h2->twin()-> + is_equal_env_data_in_face()); + res_h->twin()->set_has_equal_aux_data_in_face(0, h1->twin()-> + has_equal_env_data_in_face()); + res_h->twin()->set_has_equal_aux_data_in_face(1, h2->twin()-> + has_equal_env_data_in_face()); // update is_equal/has_equal data in target update_halfedge_flags_on_edge(res_h, m_1.non_const_handle(h1), 0); @@ -196,17 +179,17 @@ public: // update is_equal/has_equal data in source // update aux_data(0) - update_halfedge_flags_on_edge(res_h->twin(), m_1.non_const_handle(h1->twin()), 0); + update_halfedge_flags_on_edge(res_h->twin(), + m_1.non_const_handle(h1->twin()), 0); // update aux_data(1) - update_halfedge_flags_on_edge(res_h->twin(), m_2.non_const_handle(h2->twin()), 1); + update_halfedge_flags_on_edge(res_h->twin(), + m_2.non_const_handle(h2->twin()), 1); } - void create_edge(Halfedge_const_handle1 h1, - Face_const_handle2 f2, - Res_halfedge_handle res_h) - { + void create_edge(Halfedge_const_handle1 h1, Face_const_handle2 f2, + Res_halfedge_handle res_h) { res_h->set_aux_source(0, m_1.non_const_handle(h1)); res_h->set_aux_source(1, m_2.non_const_handle(f2)); @@ -214,21 +197,24 @@ public: res_h->twin()->set_aux_source(1, m_2.non_const_handle(f2)); // update is_equal/has_equal data in face - res_h->set_is_equal_aux_data_in_face(0, h1->get_is_equal_data_in_face()); + res_h->set_is_equal_aux_data_in_face(0, h1->is_equal_env_data_in_face()); res_h->set_is_equal_aux_data_in_face(1, true); - res_h->set_has_equal_aux_data_in_face(0, h1->get_has_equal_data_in_face()); - res_h->set_has_equal_aux_data_in_face(1, !f2->has_no_data()); + res_h->set_has_equal_aux_data_in_face(0, h1->has_equal_env_data_in_face()); + res_h->set_has_equal_aux_data_in_face(1, ! f2->has_no_env_data()); - res_h->twin()->set_is_equal_aux_data_in_face(0, h1->twin()->get_is_equal_data_in_face()); + res_h->twin()->set_is_equal_aux_data_in_face(0, h1->twin()-> + is_equal_env_data_in_face()); res_h->twin()->set_is_equal_aux_data_in_face(1, true); - res_h->twin()->set_has_equal_aux_data_in_face(0, h1->twin()->get_has_equal_data_in_face()); - res_h->twin()->set_has_equal_aux_data_in_face(1, !f2->has_no_data()); + res_h->twin()->set_has_equal_aux_data_in_face(0, h1->twin()-> + has_equal_env_data_in_face()); + res_h->twin()->set_has_equal_aux_data_in_face(1, ! f2->has_no_env_data()); // update is_equal/has_equal data in target for the first source map - update_halfedge_flags_on_edge(res_h, m_1.non_const_handle(h1), 0); + update_halfedge_flags_on_edge(res_h, m_1.non_const_handle(h1), 0); // update source - update_halfedge_flags_on_edge(res_h->twin(), m_1.non_const_handle(h1->twin()), 0); + update_halfedge_flags_on_edge(res_h->twin(), + m_1.non_const_handle(h1->twin()), 0); // update is_equal/has_equal data in target for the second source map update_halfedge_flags_in_face(res_h, m_2.non_const_handle(f2), 1); @@ -238,10 +224,8 @@ public: } - void create_edge(Face_const_handle1 f1, - Halfedge_const_handle2 h2, - Res_halfedge_handle res_h) - { + void create_edge(Face_const_handle1 f1, Halfedge_const_handle2 h2, + Res_halfedge_handle res_h) { res_h->set_aux_source(0, m_1.non_const_handle(f1)); res_h->set_aux_source(1, m_2.non_const_handle(h2)); @@ -250,20 +234,23 @@ public: // update halfedge-face flags of the new halfedge res_h->set_is_equal_aux_data_in_face(0, true); - res_h->set_is_equal_aux_data_in_face(1, h2->get_is_equal_data_in_face()); - res_h->set_has_equal_aux_data_in_face(0, !f1->has_no_data()); - res_h->set_has_equal_aux_data_in_face(1, h2->get_has_equal_data_in_face()); + res_h->set_is_equal_aux_data_in_face(1, h2->is_equal_env_data_in_face()); + res_h->set_has_equal_aux_data_in_face(0, ! f1->has_no_env_data()); + res_h->set_has_equal_aux_data_in_face(1, h2->has_equal_env_data_in_face()); res_h->twin()->set_is_equal_aux_data_in_face(0, true); - res_h->twin()->set_is_equal_aux_data_in_face(1, h2->twin()->get_is_equal_data_in_face()); - res_h->twin()->set_has_equal_aux_data_in_face(0, !f1->has_no_data()); - res_h->twin()->set_has_equal_aux_data_in_face(1, h2->twin()->get_has_equal_data_in_face()); + res_h->twin()->set_is_equal_aux_data_in_face + (1, h2->twin()->is_equal_env_data_in_face()); + res_h->twin()->set_has_equal_aux_data_in_face(0, ! f1->has_no_env_data()); + res_h->twin()->set_has_equal_aux_data_in_face + (1, h2->twin()->has_equal_env_data_in_face()); // update is_equal/has_equal data in target for the second source map - update_halfedge_flags_on_edge(res_h, m_2.non_const_handle(h2), 1); + update_halfedge_flags_on_edge(res_h, m_2.non_const_handle(h2), 1); // update source - update_halfedge_flags_on_edge(res_h->twin(), m_2.non_const_handle(h2->twin()), 1); + update_halfedge_flags_on_edge(res_h->twin(), + m_2.non_const_handle(h2->twin()), 1); // update is_equal/has_equal data in target for the first source map update_halfedge_flags_in_face(res_h, m_1.non_const_handle(f1), 0); @@ -273,39 +260,39 @@ public: protected: - template - void copy_halfedge_target_info(Halfedge_handle_t from, Res_halfedge_handle to, unsigned int id) - { - to->set_is_equal_aux_data_in_target(id, from->get_is_equal_data_in_target()); - to->set_has_equal_aux_data_in_target(id, from->get_has_equal_data_in_target()); + template + void copy_halfedge_target_info(Halfedge_handle_t from, + Res_halfedge_handle to, unsigned int id) { + to->set_is_equal_aux_data_in_target(id, from->is_equal_env_data_in_target()); + to->set_has_equal_aux_data_in_target + (id, from->has_equal_env_data_in_target()); } - void set_halfedge_target_info(Res_halfedge_handle to, unsigned int id, bool info) - { + void set_halfedge_target_info(Res_halfedge_handle to, unsigned int id, + bool info) { to->set_is_equal_aux_data_in_target(id, info); to->set_has_equal_aux_data_in_target(id, info); } - template + template void copy_halfedge_target_info_from_halfedge_face_info(Halfedge_handle_t from, Res_halfedge_handle to, - unsigned int id) - { - to->set_is_equal_aux_data_in_target(id, from->get_is_equal_data_in_face()); - to->set_has_equal_aux_data_in_target(id, from->get_has_equal_data_in_face()); - to->set_has_equal_aux_data_in_target_and_face(id, from->get_has_equal_data_in_face()); + unsigned int id) { + to->set_is_equal_aux_data_in_target(id, from->is_equal_env_data_in_face()); + to->set_has_equal_aux_data_in_target(id, from->has_equal_env_data_in_face()); + to->set_has_equal_aux_data_in_target_and_face + (id, from->has_equal_env_data_in_face()); } - template + template void copy_halfedge_target_info_from_vertex_face_info(Vertex_handle_t from, Res_halfedge_handle to, - unsigned int id) - { - to->set_is_equal_aux_data_in_target(id, from->get_is_equal_data_in_face()); - to->set_has_equal_aux_data_in_target(id, from->get_has_equal_data_in_face()); + unsigned int id) { + to->set_is_equal_aux_data_in_target(id, from->is_equal_env_data_in_face()); + to->set_has_equal_aux_data_in_target(id, from->has_equal_env_data_in_face()); } // find a halfedge that v is its target and f is its face - Halfedge_handle find_halfedge_by_vertex_and_face(Vertex_handle v, Face_handle f) - { + Halfedge_handle find_halfedge_by_vertex_and_face(Vertex_handle v, + Face_handle f) { // should always invoke this method when v is on the boundary of f // for the complexity of the total algorithm, we only loop over @@ -314,11 +301,10 @@ protected: Vertex_face_pair query(v, f); typename Boundary_cache::iterator iter = traversed_vertices.find(query); Halfedge_handle result; - if (iter == traversed_vertices.end()) - { + if (iter == traversed_vertices.end()) { // first time to check this vertex - traverse all its halfedges // and update the map - typename Minimization_diagram_2::Halfedge_around_vertex_circulator vc = + typename Md2::Halfedge_around_vertex_circulator vc = v->incident_halfedges(), vc_begin = vc; do { @@ -326,13 +312,10 @@ protected: // update the map traversed_vertices[Vertex_face_pair(v, hh->face())] = hh; // check for reult - if (hh->face() == f) - result = hh; - ++vc; - } while (vc != vc_begin); + if (hh->face() == f) result = hh; + } while (++vc != vc_begin); } - else - { + else { // take it from the map result = iter->second; } @@ -344,29 +327,26 @@ protected: // and target-face flags // id is the source diagram where on_edge comes from // (i.e. the id of the aux information to update) - void update_halfedge_flags_on_edge(Halfedge_handle new_h, Halfedge_handle on_edge, unsigned int id) - { - if(new_h->target()->is_at_open_boundary()) - return; + void update_halfedge_flags_on_edge(Halfedge_handle new_h, + Halfedge_handle on_edge, unsigned int id) { + if(new_h->target()->is_at_open_boundary()) return; Vertex_handle vh; Halfedge_handle hh; - const Object& trg_src = new_h->target()->get_aux_source(id); - if (assign(vh, trg_src)) - { - // vh is the target of on_edge, and we can copy the halfedge-target information - // from on_edge + const Object& trg_src = new_h->target()->aux_source(id); + if (assign(vh, trg_src)) { + // vh is the target of on_edge, and we can copy the halfedge-target + // information from on_edge copy_halfedge_target_info(on_edge, new_h, id); new_h->set_has_equal_aux_data_in_target_and_face - (id, on_edge->get_has_equal_data_in_target_and_face()); + (id, on_edge->has_equal_env_data_in_target_and_face()); } - else if (assign(hh, trg_src)) - { + else if (assign(hh, trg_src)) { // hh is the "HEMSHECH" of on_edge, so we need to set halfedge_target // information to true set_halfedge_target_info(new_h, id, true); - // and target-face information using the original halfedge-face information - new_h->set_has_equal_aux_data_in_target_and_face - (id, on_edge->get_has_equal_data_in_face()); + // and target-face information using the original halfedge-face information + new_h->set_has_equal_aux_data_in_target_and_face + (id, on_edge->has_equal_env_data_in_face()); } else // this cannot happen, since we need to touch an edge @@ -377,44 +357,45 @@ protected: // and target-face information // id is the source diagram where in_face comes from // (i.e. the id of the aux information to update) - void update_halfedge_flags_in_face(Halfedge_handle new_h, Face_handle in_face, unsigned int id) - { - if(new_h->target()->is_at_open_boundary()) - return; + void update_halfedge_flags_in_face(Halfedge_handle new_h, + Face_handle in_face, unsigned int id) { + if (new_h->target()->is_at_open_boundary()) return; Vertex_handle vh; Halfedge_handle hh; Face_handle fh; // update target - const Object& trg_src = new_h->target()->get_aux_source(id); - if (assign(vh, trg_src)) - { - if (vh->is_isolated()) - { + const Object& trg_src = new_h->target()->aux_source(id); + if (assign(vh, trg_src)) { + if (vh->is_isolated()) { copy_halfedge_target_info_from_vertex_face_info(vh, new_h, id); - // the target-face information is taken from vertex-face information too + // the target-face information is taken from vertex-face information too new_h->set_has_equal_aux_data_in_target_and_face - (id, vh->get_has_equal_data_in_face()); + (id, vh->has_equal_env_data_in_face()); } - else - { + else { + // we have a vertex vh on the boundary of the face in_face - // todo: get rid of this calculations: (using unknown value for has_equal flag) - /*CGAL_assertion_code( - bool calc_is_equal = vh->is_equal_data(in_face->begin_data(), in_face->end_data()); - )*/ - //bool calc_has_equal = vh->has_equal_data(in_face->begin_data(), in_face->end_data()); + // todo: get rid of this calculations: (using unknown value for + // has_equal flag) + // CGAL_assertion_code( + // bool calc_is_equal = vh->is_equal_env_data(in_face->begin_env_data(), + // in_face->end_env_data()); + // ) + // + // bool calc_has_equal = vh->has_equal_env_data(in_face->begin_env_data(), + // in_face->end_env_data()); // find the halfedge with target vh on the boundary of in_face Halfedge_handle h_of_vh_and_in_face = - find_halfedge_by_vertex_and_face(vh, in_face); + find_halfedge_by_vertex_and_face(vh, in_face); // is_equal relationship is easy: - bool is_equal = h_of_vh_and_in_face->get_is_equal_data_in_face() && - h_of_vh_and_in_face->get_is_equal_data_in_target(); + bool is_equal = h_of_vh_and_in_face->is_equal_env_data_in_face() && + h_of_vh_and_in_face->is_equal_env_data_in_target(); //CGAL_assertion(is_equal == calc_is_equal); // has_equal relationship is problematic in one case: bool has_equal = - h_of_vh_and_in_face->get_has_equal_data_in_target_and_face(); + h_of_vh_and_in_face->has_equal_env_data_in_target_and_face(); /*CGAL_assertion(has_equal == calc_has_equal); if(has_equal != calc_has_equal) @@ -427,18 +408,16 @@ protected: new_h->set_has_equal_aux_data_in_target_and_face(id, has_equal); } } - else if (assign(hh, trg_src)) + else if (assign(hh, trg_src)) { // we should find the halfedge (hh or hh>twin()) that points to face // in_face, and check the halfedge-face flags there - { CGAL_assertion(hh->face() == in_face || hh->twin()->face() == in_face); if (hh->face() == in_face) copy_halfedge_target_info_from_halfedge_face_info(hh, new_h, id); else copy_halfedge_target_info_from_halfedge_face_info(hh->twin(), new_h, id); } - else - { + else { CGAL_assertion_code(bool b =) assign(fh, trg_src); CGAL_assertion(b); @@ -447,15 +426,15 @@ protected: // the face data CGAL_assertion(fh == in_face); new_h->set_is_equal_aux_data_in_target(id, true); - new_h->set_has_equal_aux_data_in_target(id, !fh->has_no_data()); - new_h->set_has_equal_aux_data_in_target_and_face(id, !fh->has_no_data()); + new_h->set_has_equal_aux_data_in_target(id, ! fh->has_no_env_data()); + new_h->set_has_equal_aux_data_in_target_and_face(id, ! fh->has_no_env_data()); } } - Minimization_diagram_2& m_1; - Minimization_diagram_2& m_2; - Minimization_diagram_2& m_result; - Boundary_cache traversed_vertices; + Md2& m_1; + Md2& m_2; + Md2& m_result; + Boundary_cache traversed_vertices; }; } //namespace CGAL diff --git a/Envelope_3/include/CGAL/Envelope_3/Envelope_pm_dcel.h b/Envelope_3/include/CGAL/Envelope_3/Envelope_pm_dcel.h index c15c2dead3e..31e114b2f48 100644 --- a/Envelope_3/include/CGAL/Envelope_3/Envelope_pm_dcel.h +++ b/Envelope_3/include/CGAL/Envelope_3/Envelope_pm_dcel.h @@ -7,10 +7,10 @@ // $Id$ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch -// Baruch Zukerman -// Ron Wein -// Efi Fogel +// Author(s) : Michal Meyerovitch +// Baruch Zukerman +// Ron Wein +// Efi Fogel #ifndef CGAL_ENVELOPE_PM_DCEL_H #define CGAL_ENVELOPE_PM_DCEL_H @@ -21,231 +21,163 @@ #include #include -namespace CGAL -{ -namespace Envelope_3 -{ +namespace CGAL { -template -class Dcel_info -{ +namespace Envelope_3 { + +template +class Dcel_info { public: - typedef Dcel_info Self; - typedef std::list Data_container; - typedef typename Data_container::iterator Data_iterator; - typedef typename Data_container::const_iterator Data_const_iterator; + using Data = Data_; + using Self = Dcel_info; + using Data_container = std::list; + using Data_iterator = typename Data_container::iterator; + using Data_const_iterator = typename Data_container::const_iterator; protected: /*! data container */ - Data_container m_data; + Data_container m_env_data; /*! Indicates that the data (surfaces) have been set already */ - bool m_is_set; + bool m_is_env_set; // the decision that was made Dac_decision m_decision; public: /*! Constructor */ - Dcel_info() : m_is_set(false), m_decision(DAC_DECISION_NOT_SET) - {} + Dcel_info() : m_is_env_set(false), m_decision(DAC_DECISION_NOT_SET) {} /*! \brief returns true iff data has been set already */ - bool get_is_set() const { return m_is_set; } + bool is_env_set() const { return m_is_env_set; } /*! \brief resets the flag */ - void set_is_set(bool flag) { m_is_set = flag; } + void set_is_env_set(bool flag) { m_is_env_set = flag; } - bool is_decision_set() - { - return (m_decision != DAC_DECISION_NOT_SET); - } + bool is_decision_set() { return (m_decision != DAC_DECISION_NOT_SET); } - Dac_decision get_decision() const - { - return m_decision; - } + Dac_decision decision() const { return m_decision; } void set_decision(Comparison_result comp) - { - m_decision = enum_cast(comp); - } + { m_decision = enum_cast(comp); } - void set_decision(Dac_decision dec) - { - m_decision = dec; - } + void set_decision(Dac_decision dec) { m_decision = dec; } /*! User-friendly interface: */ - size_t number_of_surfaces () const - { - return (m_data.size()); + size_t number_of_surfaces() const { return m_env_data.size(); } + + Data_const_iterator surfaces_begin() const { return m_env_data.begin(); } + + Data_const_iterator surfaces_end() const { return m_env_data.end(); } + + /*! Obtain the first Xy-monotone surface associated with the face. + * \pre number_of_surfaces() is not 0. + */ + const Data& surface() const { + CGAL_precondition(m_env_data.size() > 0); + return m_env_data.front(); } - Data_const_iterator surfaces_begin () const - { - return (m_data.begin()); - } - - Data_const_iterator surfaces_end () const - { - return (m_data.end()); - } - - /*! - * Get the first Xy-monotone surface associated with the face. - * \pre number_of_surfaces() is not 0. + /*! Obtain the number of data objects associated with the cell. */ - const Data& surface() const - { - CGAL_precondition (m_data.size() > 0); - return (m_data.front()); - } + int env_data_size() const + { return static_cast(m_env_data.size()); } - /*! - * Get the number of data objects associated with the face. + /*! Check whether the data is set to be empty */ - int number_of_data_objects() const - { - return static_cast(m_data.size()); - } + bool has_no_env_data() const + { return (m_is_env_set && (env_data_size() == 0)); } - /*! - * check if the data is set to be empty + /*! Obtain the first data object associated with the cell. + * \pre m_env_data.size() is not 0. */ - bool has_no_data() const - { - return (m_is_set && number_of_data_objects() == 0); + const Data& env_data_front() const { + CGAL_precondition(m_env_data.size() > 0); + return m_env_data.front(); } - /*! - * Get the first data object associated with the face. - * \pre number_of_data_objects() is not 0. + /*! Obtain the data iterators (const version). */ - const Data& get_data() const - { - CGAL_precondition (m_data.size() > 0); + Data_const_iterator begin_env_data() const { return m_env_data.begin(); } - return (m_data.front()); - } + Data_const_iterator end_env_data() const { return m_env_data.end(); } - /*! - * Get the data iterators (const version). + /*! Obtain the data iterators (non-const version). */ - Data_const_iterator begin_data() const - { - return (m_data.begin()); - } + Data_iterator begin_env_data() { return m_env_data.begin(); } - Data_const_iterator end_data() const - { - return (m_data.end()); - } + Data_iterator end_env_data() { return m_env_data.end(); } - /*! - * Get the data iterators (non-const version). - */ - Data_iterator begin_data() - { - return (m_data.begin()); - } - - Data_iterator end_data() - { - return (m_data.end()); - } - - /*! - * Set a data object to the face. + /*! Set a data object to the face. * \param data The data object to set. */ - void set_data (const Data & data) - { - clear_data(); - add_data(data); + void set_env_data(const Data& data) { + clear_env_data(); + add_env_data(data); } - /*! - * Set a range of data objects to the face. + /*! Set a range of data objects to the face. * \param begin A begin iterator for the data range. * \param end A past-the-end iterator for the data range. */ - template - void set_data(const InputIterator & begin, const InputIterator & end) - { - clear_data(); - add_data(begin, end); + template + void set_env_data(InputIterator begin, InputIterator end) { + clear_env_data(); + add_env_data(begin, end); } - /*! - * set the data to be empty. + /*! set the data to be empty. */ - void set_no_data() - { - clear_data(); - m_is_set = true; + void set_no_env_data() { + clear_env_data(); + m_is_env_set = true; } - /*! - * Add a data object to the face. + /*! Add a data object to the face. * \param data The additional data object. */ - void add_data (const Data & data) - { - m_data.push_back(data); - m_is_set = true; + void add_env_data(const Data& data) { + m_env_data.push_back(data); + m_is_env_set = true; } - /*! - * Add a range of data objects to the face. + /*! Add a range of data objects to the face. * \param begin A begin iterator for the data range. * \param end A past-the-end iterator for the data range. */ - template - void add_data (const InputIterator & begin, const InputIterator & end) - { - InputIterator it; - for (it = begin; it != end; it++) - m_data.push_back(*it); - m_is_set = true; + template + void add_env_data(InputIterator begin, InputIterator end) { + for (auto it = begin; it != end; ++it) m_env_data.push_back(*it); + m_is_env_set = true; } - /*! - * Clear the data objects. + /*! Clear the data objects. */ - void clear_data () - { - m_data.clear(); - m_is_set = false; + void clear_env_data() { + m_env_data.clear(); + m_is_env_set = false; } - /*! - * Check if the set of data objects in the input range is equal to our + /*! Check whether the set of data objects in the input range is equal to our * set of data objects */ - template - bool is_equal_data(const InputIterator & begin, const InputIterator & end) - const - { - if (!get_is_set()) - return false; + template + bool is_equal_env_data(InputIterator begin, InputIterator end) const { + if (! is_env_set()) return false; // insert the input data objects into a set std::set input_data(begin, end); - std::set my_data(begin_data(), end_data()); - if (input_data.size() != my_data.size()) - return false; + std::set my_data(begin_env_data(), end_env_data()); + if (input_data.size() != my_data.size()) return false; return (my_data == input_data); } - template - bool has_equal_data(const InputIterator & begin, const InputIterator & end) - const - { - if (!get_is_set()) - return false; + template + bool has_equal_env_data(InputIterator begin, InputIterator end) const { + if (! is_env_set()) return false; + // insert the input data objects into a set std::set input_data(begin, end); - std::set my_data(begin_data(), end_data()); + std::set my_data(begin_env_data(), end_env_data()); std::list intersection; std::set_intersection(my_data.begin(), my_data.end(), input_data.begin(), input_data.end(), @@ -254,55 +186,51 @@ public: } protected: - /*! Place holder for the source of the overlay data */ Object m_aux_source[2]; public: template - void set_aux_source(unsigned int id, HandleType h) - { + void set_aux_source(unsigned int id, HandleType h) { CGAL_precondition(id < 2); m_aux_source[id] = make_object(h); } - void set_aux_source(unsigned int id, const Object& o) - { + + void set_aux_source(unsigned int id, const Object& o) { CGAL_precondition(id < 2); CGAL_precondition(!o.is_empty()); m_aux_source[id] = o; } - const Object& get_aux_source(unsigned int id) - { + const Object& aux_source(unsigned int id) { CGAL_precondition(id < 2); CGAL_precondition (!m_aux_source[id].is_empty()); return m_aux_source[id]; } /*! \brief returns true iff the point has been set already */ - bool get_aux_is_set(unsigned int id) const - { + bool aux_is_set(unsigned int id) const { CGAL_precondition(id < 2); - return (!m_aux_source[id].is_empty()); + return (! m_aux_source[id].is_empty()); } }; /*! Extend the planar-map vertex */ -template -class Envelope_pm_vertex : public CGAL::Arr_vertex_base, - public Dcel_info -{ - typedef CGAL::Arr_vertex_base Base_vertex; - typedef Dcel_info Base_info; - typedef Envelope_pm_vertex Self; +template +class Envelope_pm_vertex : public BaseVertex, public Dcel_info { +public: + using Base_vertex = BaseVertex; + using Vertex_data = VertexData; + +private: + using Self = Envelope_pm_vertex; protected: // all flags are bits in this variable: unsigned short flags; // the flags indications: - enum Bit_pos - { + enum Bit_pos { // for an isolated vertex only IS_EQUAL = 0, IS_EQUAL_AUX = 1, @@ -316,65 +244,41 @@ protected: // intersection points IS_INTERSECTION = 7 }; + public: + using Base_info = Dcel_info; + /*! Constructor */ - Envelope_pm_vertex() : Dcel_info(), flags(0) - {} + Envelope_pm_vertex() : Dcel_info(), flags(0) {} - /*void set_is_fake(bool b) - { - set_bit(IS_FAKE, b); - } - bool get_is_fake() const - { - return get_bit(IS_FAKE); - }*/ + /* void set_is_fake(bool b) { set_bit(IS_FAKE, b); } + * bool is_fake() const { return get_bit(IS_FAKE); } + */ - /* void set_is_intersection(bool b) - { - set_bit(IS_INTERSECTION, b); - }*/ - /*bool get_is_intersection() const - { - return get_bit(IS_FAKE); - }*/ + /* void set_is_intersection(bool b) { set_bit(IS_INTERSECTION, b); } + * bool is_intersection() const { return get_bit(IS_FAKE); } + */ - void set_is_equal_data_in_face(bool b) - { - set_bit(IS_EQUAL, b); - } - bool get_is_equal_data_in_face() const - { - return get_bit(IS_EQUAL); - } + void set_is_equal_env_data_in_face(bool b) { set_bit(IS_EQUAL, b); } + bool is_equal_env_data_in_face() const { return get_bit(IS_EQUAL); } - void set_has_equal_data_in_face(bool b) - { - set_bit(HAS_EQUAL, b); - } - bool get_has_equal_data_in_face() const - { - return get_bit(HAS_EQUAL); - } + void set_has_equal_env_data_in_face(bool b) { set_bit(HAS_EQUAL, b); } + bool has_equal_env_data_in_face() const { return get_bit(HAS_EQUAL); } - void set_is_equal_aux_data_in_face(unsigned int id, bool b) - { + void set_is_equal_aux_data_in_face(unsigned int id, bool b) { CGAL_assertion(id < 2); set_bit(IS_EQUAL_AUX+id, b); } - bool get_is_equal_aux_data_in_face(unsigned int id) const - { + bool is_equal_aux_data_in_face(unsigned int id) const { CGAL_assertion(id < 2); return get_bit(IS_EQUAL_AUX+id); } - void set_has_equal_aux_data_in_face(unsigned int id, bool b) - { + void set_has_equal_aux_data_in_face(unsigned int id, bool b) { CGAL_assertion(id < 2); set_bit(HAS_EQUAL_AUX+id, b); } - bool get_has_equal_aux_data_in_face(unsigned int id) const - { + bool has_equal_aux_data_in_face(unsigned int id) const { CGAL_assertion(id < 2); return get_bit(HAS_EQUAL_AUX+id); } @@ -382,8 +286,7 @@ public: /*! Assign from another vertex. * \param v the other vertex. */ - virtual void assign(const Base_vertex & v) - { + virtual void assign(const Base_vertex& v) { Base_vertex::assign(v); const Self & ex_v = static_cast(v); @@ -392,18 +295,13 @@ public: } protected: - void set_bit(unsigned int ind, bool b) - { - if (b) - // set bit "ind" to 1: - flags |= (1 << ind); - else - // set bit "ind" to 0: - flags &= ~(1 << ind); + void set_bit(unsigned int ind, bool b) { + // set bit "ind" to 1 or 0: + if (b) flags |= (1 << ind); + else flags &= ~(1 << ind); } - bool get_bit(unsigned int ind) const - { + bool get_bit(unsigned int ind) const { // (1 << i) is bit i on, other bits off (start counting from 0) unsigned int mask = 1 << ind; return ((flags & mask) == mask); @@ -411,23 +309,22 @@ protected: }; /*! Extend the planar-map halfedge */ -template -class -Envelope_pm_halfedge : public CGAL::Arr_halfedge_base, - public Dcel_info -{ - typedef CGAL::Arr_halfedge_base Base_halfedge; - typedef Dcel_info Base_info; - typedef Envelope_pm_halfedge Self; +template +class Envelope_pm_halfedge : public BaseHalfedge, + public Dcel_info { +public: + using Base_halfedge = BaseHalfedge; + using Halfedge_data = HalfedgeData; + +private: + using Self = Envelope_pm_halfedge; protected: - // all flags are bits in this variable: unsigned int flags; // flags indications - enum Bit_pos - { + enum Bit_pos { // indications for the Envelope algorithm // relation between halfedge and incident face IS_EQUAL_FACE = 0, @@ -448,114 +345,72 @@ protected: }; public: - Envelope_pm_halfedge() : Dcel_info(), flags(0) - {} + using Base_info = Dcel_info; - /* void set_is_fake(bool b) - { - set_bit(IS_FAKE, b); - } - bool get_is_fake() const - { - return get_bit(IS_FAKE); - }*/ + Envelope_pm_halfedge() : Dcel_info(), flags(0) {} - void set_is_equal_data_in_face(bool b) - { - set_bit(IS_EQUAL_FACE, b); - } - bool get_is_equal_data_in_face() const - { - return get_bit(IS_EQUAL_FACE); - } + /* void set_is_fake(bool b) { set_bit(IS_FAKE, b); } + * bool is_fake() const { return get_bit(IS_FAKE); } + */ - void set_has_equal_data_in_face(bool b) - { - set_bit(HAS_EQUAL_FACE, b); - } - bool get_has_equal_data_in_face() const - { - return get_bit(HAS_EQUAL_FACE); - } + void set_is_equal_env_data_in_face(bool b) { set_bit(IS_EQUAL_FACE, b); } + bool is_equal_env_data_in_face() const { return get_bit(IS_EQUAL_FACE); } - void set_is_equal_aux_data_in_face(unsigned int id, bool b) - { + void set_has_equal_env_data_in_face(bool b) { set_bit(HAS_EQUAL_FACE, b); } + bool has_equal_env_data_in_face() const { return get_bit(HAS_EQUAL_FACE); } + + void set_is_equal_aux_data_in_face(unsigned int id, bool b) { CGAL_assertion(id < 2); set_bit(IS_EQUAL_AUX_FACE+id, b); } - bool get_is_equal_aux_data_in_face(unsigned int id) const - { + bool is_equal_aux_data_in_face(unsigned int id) const { CGAL_assertion(id < 2); return get_bit(IS_EQUAL_AUX_FACE+id); } - void set_has_equal_aux_data_in_face(unsigned int id, bool b) - { + void set_has_equal_aux_data_in_face(unsigned int id, bool b) { CGAL_assertion(id < 2); set_bit(HAS_EQUAL_AUX_FACE+id, b); } - bool get_has_equal_aux_data_in_face(unsigned int id) const - { + bool has_equal_aux_data_in_face(unsigned int id) const { CGAL_assertion(id < 2); return get_bit(HAS_EQUAL_AUX_FACE+id); } - void set_is_equal_data_in_target(bool b) - { - set_bit(IS_EQUAL_TARGET, b); - } - bool get_is_equal_data_in_target() const - { - return get_bit(IS_EQUAL_TARGET); - } + void set_is_equal_env_data_in_target(bool b) { set_bit(IS_EQUAL_TARGET, b); } + bool is_equal_env_data_in_target() const { return get_bit(IS_EQUAL_TARGET); } - void set_has_equal_data_in_target(bool b) - { - set_bit(HAS_EQUAL_TARGET, b); - } - bool get_has_equal_data_in_target() const - { - return get_bit(HAS_EQUAL_TARGET); - } + void set_has_equal_env_data_in_target(bool b) { set_bit(HAS_EQUAL_TARGET, b); } + bool has_equal_env_data_in_target() const { return get_bit(HAS_EQUAL_TARGET); } - void set_is_equal_aux_data_in_target(unsigned int id, bool b) - { + void set_is_equal_aux_data_in_target(unsigned int id, bool b) { CGAL_assertion(id < 2); set_bit(IS_EQUAL_AUX_TARGET+id, b); } - bool get_is_equal_aux_data_in_target(unsigned int id) const - { + bool is_equal_aux_data_in_target(unsigned int id) const { CGAL_assertion(id < 2); return get_bit(IS_EQUAL_AUX_TARGET+id); } - void set_has_equal_aux_data_in_target(unsigned int id, bool b) - { + void set_has_equal_aux_data_in_target(unsigned int id, bool b) { CGAL_assertion(id < 2); set_bit(HAS_EQUAL_AUX_TARGET+id, b); } - bool get_has_equal_aux_data_in_target(unsigned int id) const - { + bool has_equal_aux_data_in_target(unsigned int id) const { CGAL_assertion(id < 2); return get_bit(HAS_EQUAL_AUX_TARGET+id); } // access to flags that contain relation between target and face - void set_has_equal_data_in_target_and_face(bool b) - { - set_bit(HAS_EQUAL_F_T, b); - } - bool get_has_equal_data_in_target_and_face() const - { - return get_bit(HAS_EQUAL_F_T); - } + void set_has_equal_env_data_in_target_and_face(bool b) + { set_bit(HAS_EQUAL_F_T, b); } + bool has_equal_env_data_in_target_and_face() const + { return get_bit(HAS_EQUAL_F_T); } - void set_has_equal_aux_data_in_target_and_face(unsigned int id, bool b) - { + void set_has_equal_aux_data_in_target_and_face(unsigned int id, bool b) { CGAL_assertion(id < 2); set_bit(HAS_EQUAL_AUX_F_T+id, b); } - bool get_has_equal_aux_data_in_target_and_face(unsigned int id) const - { + bool has_equal_aux_data_in_target_and_face(unsigned int id) const { CGAL_assertion(id < 2); return get_bit(HAS_EQUAL_AUX_F_T+id); } @@ -563,8 +418,7 @@ public: /*! Assign from another halfedge. * \param h the other halfedge. */ - virtual void assign(const Base_halfedge & h) - { + virtual void assign(const Base_halfedge& h) { Base_halfedge::assign(h); const Self & ex_h = static_cast(h); @@ -573,92 +427,96 @@ public: } protected: - void set_bit(unsigned int ind, bool b) - { - if (b) - // set bit "ind" to 1: - flags |= (1 << ind); - else - // set bit "ind" to 0: - flags &= ~(1 << ind); + void set_bit(unsigned int ind, bool b) { + if (b) flags |= (1 << ind); + else flags &= ~(1 << ind); CGAL_assertion(get_bit(ind) == b); } - bool get_bit(unsigned int ind) const - { + bool get_bit(unsigned int ind) const { // (1 << i) is bit i on, other bits off (start counting from 0) unsigned int mask = 1 << ind; return ((flags & mask) == mask); } }; -/*! Extend the planar-map face */ -template -class Envelope_pm_face : public CGAL::Arr_face_base, - public Dcel_info -{ - typedef CGAL::Arr_face_base Base_face; - typedef Dcel_info Base_info; - typedef Envelope_pm_face Self; + //! Extend the planar-map face. +template +class Envelope_pm_face : public BaseFace, public Dcel_info { +public: + using Base_face = BaseFace; + using Face_data = FaceData; + +private: + using Self = Envelope_pm_face; public: - typedef std::list Data_container; - typedef typename Data_container::iterator Data_iterator; - typedef typename Data_container::const_iterator Data_const_iterator; + using Base_info = Dcel_info; + using Data_container = std::list; + using Data_iterator = typename Data_container::iterator; + using Data_const_iterator = typename Data_container::const_iterator; - /*! Constructor */ - Envelope_pm_face() : Dcel_info() - {} + /*! Construct. + */ + Envelope_pm_face() : Dcel_info() {} /*! Assign from another face. * \param f the other face. */ - virtual void assign (const Base_face & f) - { + virtual void assign(const Base_face& f) { Base_face::assign(f); - const Self & ex_f = static_cast(f); + const Self& ex_f = static_cast(f); this->Base_info::operator=(ex_f); } }; /*! A new dcel builder with full Envelope features */ -template -class Envelope_pm_dcel : public -CGAL::Arr_dcel_base, - Envelope_pm_halfedge, - Envelope_pm_face > -{ +template , + typename HalfedgeBase = + Arr_halfedge_base, + typename FaceBase = Arr_face_base> +class Envelope_pm_dcel : + public CGAL::Arr_dcel_base, + Envelope_pm_halfedge, + Envelope_pm_face> { public: + using Dcel_data = DcelData; + using Vertex_base = VertexBase; + using Halfedge_base = HalfedgeBase; + using Face_base = FaceBase; - typedef Data Face_data; - typedef typename Envelope_pm_face::Data_iterator - Face_data_iterator; - typedef typename Envelope_pm_face::Data_const_iterator - Face_data_const_iterator; + using Face_data = Dcel_data; + using Env_pm_face = Envelope_pm_face; + using Face_data_iterator = typename Env_pm_face::Data_iterator; + using Face_data_const_iterator = typename Env_pm_face::Data_const_iterator; - typedef Data Edge_data; - typedef Face_data_iterator Edge_data_iterator; - typedef Face_data_const_iterator Edge_data_const_iterator; + using Edge_data = Dcel_data; + using Edge_data_iterator = Face_data_iterator; + using Edge_data_const_iterator = Face_data_const_iterator; - typedef Data Vertex_data; - typedef Face_data_iterator Vertex_data_iterator; - typedef Face_data_const_iterator Vertex_data_const_iterator; + using Vertex_data = Dcel_data; + using Vertex_data_iterator = Face_data_iterator; + using Vertex_data_const_iterator = Face_data_const_iterator; - typedef Dcel_info Dcel_elem_with_data; - - typedef Data Dcel_data; - typedef Face_data_iterator Dcel_data_iterator; - typedef Face_data_const_iterator Dcel_data_const_iterator; + using Dcel_elem_with_data = Dcel_info; + using Dcel_data_iterator = Face_data_iterator; + using Dcel_data_const_iterator = Face_data_const_iterator; /*! \struct * An auxiliary structure for rebinding the DCEL with a new traits class. */ - template - struct rebind - { - typedef Envelope_pm_dcel other; + template + struct rebind { + using Pnt = typename T::Point_2; + using Xcv = typename T::X_monotone_curve_2; + using Rebind_v = typename Vertex_base::template rebind; + using V_other = typename Rebind_v::other; + using Rebind_h = typename Halfedge_base::template rebind; + using H_other = typename Rebind_h::other; + + typedef Envelope_pm_dcel other; }; /*! Constructor */ @@ -666,6 +524,7 @@ public: }; } // namespace Envelope_3 + } // namespace CGAL #endif diff --git a/Envelope_3/include/CGAL/envelope_3.h b/Envelope_3/include/CGAL/envelope_3.h index 20cee65f047..c4487fb6c68 100644 --- a/Envelope_3/include/CGAL/envelope_3.h +++ b/Envelope_3/include/CGAL/envelope_3.h @@ -8,8 +8,9 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Ron Wein -// Baruch Zukerman +// Author(s) : Ron Wein +// Baruch Zukerman +// Efi Fogel #ifndef CGAL_ENVELOPE_3_H #define CGAL_ENVELOPE_3_H @@ -23,100 +24,86 @@ namespace CGAL { -/*! - * Construct the lower envelope of a given set of surfaces. +/*! Construct the lower envelope of a given set of surfaces. * \param begin An iterator for the first surface. * \param end A past-the-end iterator for the surfaces in the range. * \param min_diag Output: The minimization diagram. * \pre The value-type of InputIterator is Traits::Surface_3. */ -template -void lower_envelope_3 (InputIterator begin, InputIterator end, - Envelope_diagram_on_surface_2& - min_diagram) -{ - typedef GeomTraits Traits_3; - typedef typename Envelope_diagram_on_surface_2::Arrangement Envelope_diagram_2; - typedef Envelope_divide_and_conquer_3 - Envelope_algorithm; - Envelope_algorithm env_alg (min_diagram.geometry_traits(), ENVELOPE_LOWER); - env_alg.construct_lu_envelope (begin, end, min_diagram); +template +void lower_envelope_3(InputIterator begin, InputIterator end, + Envelope_diagram_on_surface_2& + min_diagram) { + using Gt = GeomTraits; + using Tt = TopolTraits; + + using Edos_2 = Envelope_diagram_on_surface_2; + using Aos = typename Edos_2::Base_aos; + using Envelope_algorithm = Envelope_divide_and_conquer_3; + Envelope_algorithm env_alg(min_diagram.geometry_traits(), ENVELOPE_LOWER); + env_alg.construct_lu_envelope(begin, end, min_diagram); } -/*! - * Construct the upper envelope of a given set of surfaces. +/*! Construct the upper envelope of a given set of surfaces. * \param begin An iterator for the first surface. * \param end A past-the-end iterator for the surfaces in the range. * \param max_diag Output: The maximization diagram. * \pre The value-type of InputIterator is Traits::Surface_3. */ -template -void upper_envelope_3 (InputIterator begin, InputIterator end, - Envelope_diagram_on_surface_2& - max_diagram) -{ - typedef GeomTraits Traits_3; - typedef typename Envelope_diagram_on_surface_2< - Traits_3, TopTraits>::Arrangement Envelope_diagram_2; - typedef Envelope_divide_and_conquer_3 - Envelope_algorithm; +template +void upper_envelope_3(InputIterator begin, InputIterator end, + Envelope_diagram_on_surface_2& + max_diagram) { + using Gt = GeomTraits; + using Tt = TopolTraits; - Envelope_algorithm env_alg (max_diagram.geometry_traits(), ENVELOPE_UPPER); + using Edos = Envelope_diagram_on_surface_2; + using Aos = typename Edos::Base_aos; + using Envelope_algorithm = Envelope_divide_and_conquer_3; + Envelope_algorithm env_alg(max_diagram.geometry_traits(), ENVELOPE_UPPER); env_alg.construct_lu_envelope (begin, end, max_diagram); } -/*! - * Construct the lower envelope of a given set of xy_monotone surfaces. +/*! Construct the lower envelope of a given set of xy_monotone surfaces. * \param begin An iterator for the first xy-monotone surface. * \param end A past-the-end iterator for the xy_monotone surfaces in the range. * \param min_diag Output: The minimization diagram. * \pre The value-type of InputIterator is GeomTraits::Surface_3. */ -template -void -lower_envelope_xy_monotone_3 (InputIterator begin, InputIterator end, - Envelope_diagram_on_surface_2& min_diagram) -{ - typedef GeomTraits Traits_3; - typedef typename Envelope_diagram_on_surface_2< - Traits_3, TopTraits>::Arrangement Envelope_diagram_2; - typedef Envelope_divide_and_conquer_3 - Envelope_algorithm; - Envelope_algorithm env_alg (min_diagram.geometry_traits(), ENVELOPE_LOWER); +template +void lower_envelope_xy_monotone_3(InputIterator begin, InputIterator end, + Envelope_diagram_on_surface_2 + & min_diagram) { + using Gt = GeomTraits; + using Tt = TopolTraits; + + using Edos = Envelope_diagram_on_surface_2; + using Aos = typename Edos::Base_aos; + using Envelope_algorithm = Envelope_divide_and_conquer_3; + Envelope_algorithm env_alg(min_diagram.geometry_traits(), ENVELOPE_LOWER); env_alg.construct_envelope_xy_monotone (begin, end, min_diagram); } -/*! - * Construct the upper envelope of a given set of xy_monotone surfaces. +/*! Construct the upper envelope of a given set of xy_monotone surfaces. * \param begin An iterator for the first xy_monotone surface. * \param end A past-the-end iterator for the xy_monotone surfaces in the range. * \param max_diag Output: The maximization diagram. * \pre The value-type of InputIterator is Traits::Surface_3. */ -template -void -upper_envelope_xy_monotone_3 (InputIterator begin, InputIterator end, - Envelope_diagram_on_surface_2& max_diagram) -{ - typedef GeomTraits Traits_3; - typedef typename Envelope_diagram_on_surface_2< - Traits_3, TopTraits>::Arrangement Envelope_diagram_2; - typedef Envelope_divide_and_conquer_3 - Envelope_algorithm; +template +void upper_envelope_xy_monotone_3(InputIterator begin, InputIterator end, + Envelope_diagram_on_surface_2 + & max_diagram) { + using Gt = GeomTraits; + using Tt = TopolTraits; - Envelope_algorithm env_alg (max_diagram.geometry_traits(), ENVELOPE_UPPER); + using Edos = Envelope_diagram_on_surface_2; + using Aos = typename Edos::Base_aos; + using Envelope_algorithm = Envelope_divide_and_conquer_3; + Envelope_algorithm env_alg(max_diagram.geometry_traits(), ENVELOPE_UPPER); env_alg.construct_envelope_xy_monotone (begin, end, max_diagram); - - return; } diff --git a/Envelope_3/test/Envelope_3/CMakeLists.txt b/Envelope_3/test/Envelope_3/CMakeLists.txt index b087dba97ef..c5eb08f87fa 100644 --- a/Envelope_3/test/Envelope_3/CMakeLists.txt +++ b/Envelope_3/test/Envelope_3/CMakeLists.txt @@ -6,11 +6,10 @@ project(Envelope_3_Tests) find_package(CGAL REQUIRED COMPONENTS Core) -# create a target per cppfile -file( - GLOB cppfiles - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) -foreach(cppfile ${cppfiles}) - create_single_source_cgal_program("${cppfile}") -endforeach() +create_single_source_cgal_program("triangles_test.cpp") + +if (CGAL_Core_FOUND) + create_single_source_cgal_program("spheres_test.cpp") +else() + message("NOTICE: A test requires CGAL_Core, and will not be compiled.") +endif() diff --git a/Envelope_3/test/Envelope_3/Envelope_test_3.h b/Envelope_3/test/Envelope_3/Envelope_test_3.h index 80656676ca7..cce5cc4656a 100644 --- a/Envelope_3/test/Envelope_3/Envelope_test_3.h +++ b/Envelope_3/test/Envelope_3/Envelope_test_3.h @@ -8,18 +8,12 @@ // $Name: $ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch +// Author(s) : Michal Meyerovitch +// Efi Fogel #ifndef CGAL_ENVELOPE_TEST_3_H #define CGAL_ENVELOPE_TEST_3_H -#include -#include "Envelope_test_overlay_functor.h" -#include - -#include -#include - #include #include #include @@ -27,148 +21,143 @@ #include #include +#include +#include "Envelope_test_overlay_functor.h" +#include + +#include +#include + //#define CGAL_DEBUG_ENVELOPE_TEST_3 -// this is a very trivial and not efficient algorithm for computing the lower envelope -// of general surfaces in 3d, used for testing. -// The algorithm projects the surfaces on the plane, and projects all the intersections -// between surfaces, to get an arrangement that is a partition of the real envelope. -// Then it computes for each part in the arrangement the surfaces on the envelope over it -// by comparing them all. +// this is a very trivial and not efficient algorithm for computing the lower +// envelope of general surfaces in 3d, used for testing. +// The algorithm projects the surfaces on the plane, and projects all the +// intersections between surfaces, to get an arrangement that is a partition of +// the real envelope. +// Then it computes for each part in the arrangement the surfaces on the +// envelope over it by comparing them all. namespace CGAL { -template -class Envelope_test_3 -{ +template +class Envelope_test_3 { public: - typedef EnvelopeTraits_3 Traits; - typedef typename Traits::Surface_3 Surface_3; - typedef typename Traits::Xy_monotone_surface_3 Xy_monotone_surface_3; + using Traits = EnvelopeTraits_3; + using Minimization_diagram_2 = MinimizationDiagram_2; - typedef MinimizationDiagram_2 Minimization_diagram_2; - typedef typename Minimization_diagram_2::Point_2 Point_2; - typedef typename Minimization_diagram_2::X_monotone_curve_2 X_monotone_curve_2; - typedef typename Traits::Curve_2 Curve_2; +private: + using Md2 = Minimization_diagram_2; + +public: + using Surface_3 = typename Traits::Surface_3; + using Xy_monotone_surface_3 = typename Traits::Xy_monotone_surface_3; + + using Point_2 = typename Md2::Point_2; + using X_monotone_curve_2 = typename Md2::X_monotone_curve_2; + using Curve_2 = typename Traits::Curve_2; protected: + using Overlay_functor = Envelope_test_overlay_functor; + using Overlay_2 = Envelope_overlay_2; - typedef Envelope_test_overlay_functor Overlay_functor; - typedef Envelope_overlay_2 Overlay_2; + using Md_point_location = Arr_walk_along_line_point_location; - typedef Arr_walk_along_line_point_location Md_point_location; + using Halfedge_const_iterator = typename Md2::Halfedge_const_iterator; + using Halfedge_const_handle = typename Md2::Halfedge_const_handle; + using Halfedge_handle = typename Md2::Halfedge_handle; + using Halfedge_iterator = typename Md2::Halfedge_iterator; + using Vertex_const_handle = typename Md2::Vertex_const_handle; + using Vertex_handle = typename Md2::Vertex_handle; + using Vertex_iterator = typename Md2::Vertex_iterator; + using Face_handle = typename Md2::Face_handle; + using Face_const_iterator = typename Md2::Face_const_iterator; + using Face_const_handle = typename Md2::Face_const_handle; + using Face_iterator = typename Md2::Face_iterator; + using Ccb_halfedge_circulator = typename Md2::Ccb_halfedge_circulator; + using Hole_iterator = typename Md2::Inner_ccb_iterator; + using Face_data_iterator = typename Md2::Dcel::Face_data_iterator; - typedef typename Minimization_diagram_2::Halfedge_const_iterator Halfedge_const_iterator; - typedef typename Minimization_diagram_2::Halfedge_const_handle Halfedge_const_handle; - typedef typename Minimization_diagram_2::Halfedge_handle Halfedge_handle; - typedef typename Minimization_diagram_2::Halfedge_iterator Halfedge_iterator; - typedef typename Minimization_diagram_2::Vertex_const_handle Vertex_const_handle; - typedef typename Minimization_diagram_2::Vertex_handle Vertex_handle; - typedef typename Minimization_diagram_2::Vertex_iterator Vertex_iterator; - typedef typename Minimization_diagram_2::Face_handle Face_handle; - typedef typename Minimization_diagram_2::Face_const_iterator Face_const_iterator; - typedef typename Minimization_diagram_2::Face_const_handle Face_const_handle; - typedef typename Minimization_diagram_2::Face_iterator Face_iterator; - typedef typename Minimization_diagram_2::Ccb_halfedge_circulator Ccb_halfedge_circulator; - typedef typename Minimization_diagram_2::Inner_ccb_iterator Hole_iterator; - typedef typename Minimization_diagram_2::Dcel::Face_data_iterator Face_data_iterator; - - typedef std::pair Intersection_curve; + using Multiplicity = typename EnvelopeTraits_3::Multiplicity; + using Intersection_curve = std::pair; public: // c'tor - Envelope_test_3() - { - } + Envelope_test_3() {} // virtual destructor. virtual ~Envelope_test_3(){} template - void construct_lu_envelope(SurfaceIterator begin, - SurfaceIterator end, - Minimization_diagram_2 &result) - { - if (begin == end) - { - return; // result is empty - } + void construct_lu_envelope(SurfaceIterator begin, SurfaceIterator end, + Minimization_diagram_2& result) { + if (begin == end) return; // result is empty std::vector surfaces; - SurfaceIterator si = begin; - for(; si != end; ++si) - { - surfaces.push_back(*si); - } + for (auto si = begin; si != end; ++si) surfaces.push_back(*si); Md_point_location pl(result); std::size_t number_of_surfaces = surfaces.size(); - std::size_t j; std::list curves_col; std::list points_col; typename std::list::iterator boundary_it; - for(std::size_t i=0; i Boundary_xcurve; std::list> boundary_list; - traits.construct_projected_boundary_2_object()(cur_surface, std::back_inserter(boundary_list)); - for(auto boundary_it = boundary_list.begin(); - boundary_it != boundary_list.end(); - ++boundary_it) - { - const Boundary_xcurve* boundary_cv = std::get_if(&(*boundary_it)); + auto ctr_proj_bnd = traits.construct_projected_boundary_2_object(); + ctr_proj_bnd(cur_surface, std::back_inserter(boundary_list)); + for (auto boundary_it = boundary_list.begin(); + boundary_it != boundary_list.end(); ++boundary_it) { + const auto* boundary_cv = std::get_if(&(*boundary_it)); assert(boundary_cv!=nullptr); curves_col.push_back(boundary_cv->first); } // second, intersect it with all surfaces before it - for(j=0; j> inter_objs; - traits.construct_projected_intersections_2_object()(cur_surface, prev_surface, std::back_inserter(inter_objs)); + traits.construct_projected_intersections_2_object() + (cur_surface, prev_surface, std::back_inserter(inter_objs)); // we collect all intersections and use sweep to insert them - for(std::size_t k=0; k(&inter_objs[k])) - { - #ifdef CGAL_DEBUG_ENVELOPE_TEST_3 - std::cout << "intersection between surfaces is a point: " << point << std::endl; - #endif + for (std::size_t k = 0; k < inter_objs.size(); ++k) { + if (const Point_2* point = std::get_if(&inter_objs[k])) { +#ifdef CGAL_DEBUG_ENVELOPE_TEST_3 + std::cout << "intersection between surfaces is a point: " + << point << std::endl; +#endif //insert_vertex(result, point, pl); points_col.push_back(*point); } - else if (const Intersection_curve* curve = std::get_if(&inter_objs[k])) - { + else if (const auto* curve = + std::get_if(&inter_objs[k])) { curves_col.push_back(curve->first); - /*#ifdef CGAL_DEBUG_ENVELOPE_TEST_3 - std::cout << "intersection between surfaces is a curve: " << curve.first << std::endl; - #endif - std::list objs; - traits.make_x_monotone_2_object()(curve.first, std::back_inserter(objs)); - std::list::iterator itr; - for(itr = objs.begin(); itr != objs.end(); ++itr) - { - X_monotone_curve_2 curr_cv; - assert(assign(curr_cv, *itr)); - assign(curr_cv, *itr); - curves_col.push_back(curr_cv); - }*/ + /* #ifdef CGAL_DEBUG_ENVELOPE_TEST_3 + * std::cout << "intersection between surfaces is a curve: " + * << curve.first << std::endl; + * #endif + * std::list objs; + * traits.make_x_monotone_2_object()(curve.first, + * std::back_inserter(objs)); + * std::list::iterator itr; + * for(itr = objs.begin(); itr != objs.end(); ++itr) { + * X_monotone_curve_2 curr_cv; + * assert(assign(curr_cv, *itr)); + * assign(curr_cv, *itr); + * curves_col.push_back(curr_cv); + * } + */ //insert(result, curve.first, pl); } - else - { - assert_msg(false, "wrong intersection type"); - } + else assert_msg(false, "wrong intersection type"); } } } @@ -176,61 +165,57 @@ public: // insert the curves insert(result, curves_col.begin(), curves_col.end()); // insert the points - typename std::list::iterator pit = points_col.begin(); - for(; pit != points_col.end(); ++pit) + for (auto pit = points_col.begin(); pit != points_col.end(); ++pit) insert_point(result, *pit, pl); m_result = &result; - // now, foreach vertex, edge and face, we should determine which surfaces are minimal over it. + // now, foreach vertex, edge and face, we should determine which surfaces + // are minimal over it. // update vertices' data - Vertex_iterator vi = result.vertices_begin(); - for(; vi != result.vertices_end(); ++vi) - { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; // first we find the surfaces that are defined over the vertex std::list defined_surfaces; - typename Traits::Is_defined_over is_defined_over = traits.is_defined_over_object(); - for(std::size_t i=0; ipoint(), surfaces[i])) defined_surfaces.push_back(surfaces[i]); // now compare them over the vertex - set_minimum_over_vertex(vh, defined_surfaces.begin(), defined_surfaces.end()); + set_minimum_over_vertex(vh, defined_surfaces.begin(), + defined_surfaces.end()); } // update edges' data - Halfedge_iterator hi = result.halfedges_begin(); - for(; hi != result.halfedges_end(); ++hi, ++hi) - { + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); + ++hi, ++hi) { Halfedge_handle hh = hi; // first we find the surfaces that are defined over the edge std::list defined_surfaces; - for(std::size_t i=0; i defined_surfaces; - for (std::size_t i=0; i + template void set_minimum_over_vertex(const Vertex_handle& v, - SurfaceIterator begin, SurfaceIterator end) - { - if (begin == end) - v->set_no_data(); - else - { - SurfaceIterator si = begin; + SurfaceIterator begin, SurfaceIterator end) { + if (begin == end) v->set_no_env_data(); + else { + auto si = begin; // we set the first surface as the minimum, and then compare all the others - v->set_data(*si); + v->set_env_data(*si); ++si; - for(; si != end; ++si) - { - Comparison_result cr = traits.compare_z_at_xy_3_object()(v->point(), v->get_data(), *si); - if (cr == EQUAL) - v->add_data(*si); - else if (cr == LARGER) - v->set_data(*si); // this erases all surfaces from vertex's list + for (; si != end; ++si) { + auto cr = traits.compare_z_at_xy_3_object()(v->point(), + v->env_data_front(), *si); + if (cr == EQUAL) v->add_env_data(*si); + // this erases all surfaces from vertex's list + else if (cr == LARGER) v->set_env_data(*si); // else - new surface has no affect on the envelope } } @@ -287,58 +265,51 @@ protected: // fill the edge with the surface on the envelope // all the surfaces are known to be defined over the edge's curve - template - void set_minimum_over_edge(const Halfedge_handle& h, SurfaceIterator begin, SurfaceIterator end) - { - if (begin == end) - h->set_no_data(); - else - { - if (h != current_edge) - compute_point_in_current_edge(h); + template + void set_minimum_over_edge(const Halfedge_handle& h, SurfaceIterator begin, + SurfaceIterator end) { + if (begin == end) h->set_no_env_data(); + else { + if (h != current_edge) compute_point_in_current_edge(h); - SurfaceIterator si = begin; + auto si = begin; // we set the first surface as the minimum, and then compare all the others - h->set_data(*si); + h->set_env_data(*si); ++si; - for(; si != end; ++si) - { - Comparison_result cr = traits.compare_z_at_xy_3_object()(current_point_inside_edge, - h->get_data(), *si); - if (cr == EQUAL) - h->add_data(*si); - else if (cr == LARGER) - h->set_data(*si); // this erases all surfaces from halfedge's list + for (; si != end; ++si) { + auto cr = traits.compare_z_at_xy_3_object()(current_point_inside_edge, + h->env_data_front(), *si); + if (cr == EQUAL) h->add_env_data(*si); + // this erases all surfaces from halfedge's list + else if (cr == LARGER) h->set_env_data(*si); // else - new surface has no affect on the envelope } // set twin's data - h->twin()->set_data(h->begin_data(), h->end_data()); + h->twin()->set_env_data(h->begin_env_data(), h->end_env_data()); } } + // fill the face with the surface on the envelope // the surfaces are known to not intersect inside the face // (but might intersect on its edges) - template - void set_minimum_over_face(const Face_handle& face, SurfaceIterator begin, SurfaceIterator end) - { - if (face->is_unbounded() || begin == end) - { - // a special case - no surface over the unbounded face, and when there are no surfaces at all - face->set_no_data(); + template + void set_minimum_over_face(const Face_handle& face, SurfaceIterator begin, + SurfaceIterator end) { + if (face->is_unbounded() || begin == end) { + // a special case - no surface over the unbounded face, and when there + // are no surfaces at all + face->set_no_env_data(); } - else - { - SurfaceIterator si = begin; + else { + auto si = begin; // we set the first surface as the minimum, and then compare all the others - face->set_data(*si); + face->set_env_data(*si); ++si; - for(; si != end; ++si) - { - Comparison_result cr = compare_surfaces_over_face(face, face->get_data(), *si); - if (cr == EQUAL) - face->add_data(*si); - else if (cr == LARGER) - face->set_data(*si); // this erases all surfaces from face's list + for (; si != end; ++si) { + auto cr = compare_surfaces_over_face(face, face->env_data_front(), *si); + if (cr == EQUAL) face->add_env_data(*si); + // this erases all surfaces from face's list + else if (cr == LARGER) face->set_env_data(*si); // else - new surface has no affect on the envelope } } @@ -349,46 +320,43 @@ protected: // LARGER if the second surface is closer to the envelope // EQUAL otherwise // this is version 2 which uses a calculated point inside the face - Comparison_result compare_surfaces_over_face(const Face_handle& face, - const Xy_monotone_surface_3 &surf1, - const Xy_monotone_surface_3& surf2) - { + Comparison_result + compare_surfaces_over_face(const Face_handle& face, + const Xy_monotone_surface_3& surf1, + const Xy_monotone_surface_3& surf2) { assert(!face->is_unbounded()); Comparison_result cur_res; - if (face != current_face) - compute_point_in_current_face(face); + if (face != current_face) compute_point_in_current_face(face); cur_res = traits.compare_z_at_xy_3_object()(current_point,surf1,surf2); #ifdef CGAL_DEBUG_ENVELOPE_TEST_3 - std::cout << "for comparison inside face, current result = " << cur_res << std::endl; + std::cout << "for comparison inside face, current result = " << cur_res + << std::endl; #endif return cur_res; } // check if the surface is defines over the edge - bool is_surface_defined_over_edge(const Halfedge_handle& h, Xy_monotone_surface_3 &surf) - { + bool is_surface_defined_over_edge(const Halfedge_handle& h, + Xy_monotone_surface_3& surf) { // check it over a point inside the edge's curve - if (h != current_edge) - compute_point_in_current_edge(h); + if (h != current_edge) compute_point_in_current_edge(h); - bool result = traits.is_defined_over_object()(current_point_inside_edge, surf); + auto def_over_obj = traits.is_defined_over_object(); + bool result = def_over_obj(current_point_inside_edge, surf); return result; } // check if the surface is defines over the face // this is version checks the point inside the face bool is_surface_defined_over_face(const Face_handle& face, - Xy_monotone_surface_3 &surf) - { + Xy_monotone_surface_3& surf) { // we always have bounded surfaces - if (face->is_unbounded()) - return false; + if (face->is_unbounded()) return false; - if (face != current_face) - compute_point_in_current_face(face); + if (face != current_face) compute_point_in_current_face(face); bool result = traits.is_defined_over_object()(current_point,surf); @@ -396,12 +364,12 @@ protected: } // compute a point inside the face of the arranegement - Point_2 compute_point_inside_face(Minimization_diagram_2 &env, Face_handle face) - { - assert(!face->is_unbounded()); + Point_2 compute_point_inside_face(Minimization_diagram_2& env, + Face_handle face) { + assert(! face->is_unbounded()); #ifdef CGAL_DEBUG_ENVELOPE_TEST_3 - std::cout << "in compute point inside face" << std::endl; + std::cout << "in compute point inside face" << std::endl; #endif // 1. find an edge on the outer ccb of the face that is not vertical @@ -409,13 +377,12 @@ protected: Ccb_halfedge_circulator hec_begin = hec; bool found = false; do { - if (!traits.is_vertical_2_object()(hec->curve())) - { + if (! traits.is_vertical_2_object()(hec->curve())) { found = true; continue; } - hec++; - } while(hec != hec_begin && !found); + ++hec; + } while ((hec != hec_begin) && ! found); assert(found); Halfedge_handle found_hh = hec; @@ -424,16 +391,16 @@ protected: // (we use the middle of the curve) Point_2 shoot_source = traits.construct_middle_point(found_hh->curve()); - // 3. ray shoot up or down, into the face - // and find the intersection point of the ray. the segment between - // the point from which we shoot, and the intersection point lies - // inside the face. we take its middle point as a point inside the face + // 3. ray shoot up or down, into the face and find the intersection point + // of the ray. the segment between the point from which we shoot, + // and the intersection point lies inside the face. + // we take its middle point as a point inside the face bool shoot_up = true; // TODO_NEW_DESIGN - check this // if (traits.compare_x(found_hh->source()->point(), found_hh->target()->point()) == LARGER) // shoot_up = false; if (traits.equal_2_object()(found_hh->source()->point(), - traits.construct_max_vertex_2_object()(found_hh->curve()))) + traits.construct_max_vertex_2_object()(found_hh->curve()))) shoot_up = false; Md_point_location pl(env); @@ -443,65 +410,54 @@ protected: Point_2 shoot_target; - if (shoot_up) - shoot_obj = pl.ray_shoot_up(shoot_source); - else - shoot_obj = pl.ray_shoot_down(shoot_source); + if (shoot_up) shoot_obj = pl.ray_shoot_up(shoot_source); + else shoot_obj = pl.ray_shoot_down(shoot_source); if (assign(shoot_hh, shoot_obj)) - { shoot_target = traits.vertical_ray_shoot_2(shoot_source, shoot_hh->curve()); - } else if (assign(shoot_vh, shoot_obj)) - { shoot_target = (env.non_const_handle(shoot_vh))->point(); - } - else - CGAL_error(); // it cannot be the unbounded face + else CGAL_error(); // it cannot be the unbounded face Point_2 res_point = traits.construct_middle_point(shoot_source, shoot_target); - #ifdef CGAL_DEBUG_ENVELOPE_TEST_3 - std::cout << "finished computing point in face" << std::endl; - - // just for checking, locate res_point in env to find face - Object test_pl_obj = pl.locate(res_point); - Face_const_handle test_fh; - assert(assign(test_fh, test_pl_obj)); - assert(test_fh == face); - #endif +#ifdef CGAL_DEBUG_ENVELOPE_TEST_3 + std::cout << "finished computing point in face" << std::endl; + // just for checking, locate res_point in env to find face + Object test_pl_obj = pl.locate(res_point); + Face_const_handle test_fh; + assert(assign(test_fh, test_pl_obj)); + assert(test_fh == face); +#endif return res_point; } - // compute a point inside the face saved in current_face // and put the result into current_point - void compute_point_in_current_face(Face_handle face) - { + void compute_point_in_current_face(Face_handle face) { current_face = face; current_point = compute_point_inside_face(*m_result, current_face); } // compute a point inside the edge saved in current_edge // and put the result into current_point_inside_edge - void compute_point_in_current_edge(Halfedge_handle h) - { + void compute_point_in_current_edge(Halfedge_handle h) { current_edge = h; current_point_inside_edge = traits.construct_middle_point(h->curve()); } protected: - Overlay_2 overlay; - Traits traits; - Minimization_diagram_2 *m_result; + Overlay_2 overlay; + Traits traits; + Minimization_diagram_2* m_result; - Face_handle current_face; - Point_2 current_point; + Face_handle current_face; + Point_2 current_point; - Halfedge_handle current_edge; - Point_2 current_point_inside_edge; + Halfedge_handle current_edge; + Point_2 current_point_inside_edge; }; } //namespace CGAL diff --git a/Envelope_3/test/Envelope_3/Envelope_test_overlay_functor.h b/Envelope_3/test/Envelope_3/Envelope_test_overlay_functor.h index c3388bed44a..aab1b001918 100644 --- a/Envelope_3/test/Envelope_3/Envelope_test_overlay_functor.h +++ b/Envelope_3/test/Envelope_3/Envelope_test_overlay_functor.h @@ -8,7 +8,8 @@ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // -// Author(s) : Michal Meyerovitch +// Author(s) : Michal Meyerovitch +// Efi Fogel #ifndef ENVELOPE_TEST_OVERLAY_FUNCTOR_H #define ENVELOPE_TEST_OVERLAY_FUNCTOR_H @@ -28,146 +29,121 @@ namespace CGAL { // this overlay functor compares the data over the 2 features that create new // features in the new map -template -class Envelope_test_overlay_functor -{ +template +class Envelope_test_overlay_functor { public: - typedef MinimizationDiagram_2 Minimization_diagram_2; + using Minimization_diagram_2 = MinimizationDiagram_2; - typedef typename Minimization_diagram_2::Face_const_handle Face_handle1; - typedef typename Minimization_diagram_2::Face_const_handle Face_handle2; +private: + using Md2 = Minimization_diagram_2; - typedef typename Minimization_diagram_2::Vertex_const_handle Vertex_handle1; - typedef typename Minimization_diagram_2::Vertex_const_handle Vertex_handle2; +public: + using Face_handle1 = typename Md2::Face_const_handle; + using Face_handle2 = typename Md2::Face_const_handle; - typedef typename Minimization_diagram_2::Halfedge_const_handle Halfedge_handle1; - typedef typename Minimization_diagram_2::Halfedge_const_handle Halfedge_handle2; + using Vertex_handle1 = typename Md2::Vertex_const_handle; + using Vertex_handle2 = typename Md2::Vertex_const_handle; - typedef typename Minimization_diagram_2::Face_handle Res_face_handle; - typedef typename Minimization_diagram_2::Halfedge_handle Res_halfedge_handle; - typedef typename Minimization_diagram_2::Vertex_handle Res_vertex_handle; + using Halfedge_handle1 = typename Md2::Halfedge_const_handle; + using Halfedge_handle2 = typename Md2::Halfedge_const_handle; + using Res_face_handle = typename Md2::Face_handle; + using Res_halfedge_handle = typename Md2::Halfedge_handle; + using Res_vertex_handle = typename Md2::Vertex_handle; - Envelope_test_overlay_functor(Minimization_diagram_2& , - Minimization_diagram_2& , - Minimization_diagram_2& ) - {} + Envelope_test_overlay_functor(Md2&, Md2&, Md2&) {} - void create_face (Face_handle1 f1, Face_handle2 f2, Res_face_handle res_f) - { + void create_face (Face_handle1 f1, Face_handle2 f2, Res_face_handle res_f) { res_f->set_aux_source(0, f1); res_f->set_aux_source(1, f2); - assert_msg(f1->is_equal_data(f2->begin_data(), f2->end_data()), - "data different over face"); + assert_msg(f1->is_equal_env_data(f2->begin_env_data(), f2->end_env_data()), + "data different over face"); } - void create_vertex(Halfedge_handle1 h1, - Halfedge_handle2 h2, - Res_vertex_handle res_v) - { + void create_vertex(Halfedge_handle1 h1, Halfedge_handle2 h2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, h1); res_v->set_aux_source(1, h2); - assert_msg(h1->is_equal_data(h2->begin_data(), h2->end_data()), - "data different over vertex"); - + assert_msg(h1->is_equal_env_data(h2->begin_env_data(), h2->end_env_data()), + "data different over vertex"); } - void create_vertex(Vertex_handle1 v1, - Vertex_handle2 v2, - Res_vertex_handle res_v) - { + void create_vertex(Vertex_handle1 v1, Vertex_handle2 v2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, v1); res_v->set_aux_source(1, v2); - assert_msg(v1->is_equal_data(v2->begin_data(), v2->end_data()), - "data different over vertex"); + assert_msg(v1->is_equal_env_data(v2->begin_env_data(), v2->end_env_data()), + "data different over vertex"); } - void create_vertex(Vertex_handle1 v1, - Halfedge_handle2 h2, - Res_vertex_handle res_v) - { + void create_vertex(Vertex_handle1 v1, Halfedge_handle2 h2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, v1); res_v->set_aux_source(1, h2); - assert_msg(v1->is_equal_data(h2->begin_data(), h2->end_data()), - "data different over vertex"); + assert_msg(v1->is_equal_env_data(h2->begin_env_data(), h2->end_env_data()), + "data different over vertex"); } - void create_vertex(Halfedge_handle1 h1, - Vertex_handle2 v2, - Res_vertex_handle res_v) - { + void create_vertex(Halfedge_handle1 h1, Vertex_handle2 v2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, h1); res_v->set_aux_source(1, v2); - assert_msg(h1->is_equal_data(v2->begin_data(), v2->end_data()), - "data different over vertex"); + assert_msg(h1->is_equal_env_data(v2->begin_env_data(), v2->end_env_data()), + "data different over vertex"); } - void create_vertex(Face_handle1 f1, - Vertex_handle2 v2, - Res_vertex_handle res_v) - { + void create_vertex(Face_handle1 f1, Vertex_handle2 v2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, f1); res_v->set_aux_source(1, v2); - assert_msg(f1->is_equal_data(v2->begin_data(), v2->end_data()), - "data different over vertex"); + assert_msg(f1->is_equal_env_data(v2->begin_env_data(), v2->end_env_data()), + "data different over vertex"); } - void create_vertex(Vertex_handle1 v1, - Face_handle2 f2, - Res_vertex_handle res_v) - { + void create_vertex(Vertex_handle1 v1, Face_handle2 f2, + Res_vertex_handle res_v) { res_v->set_aux_source(0, v1); res_v->set_aux_source(1, f2); - assert_msg(v1->is_equal_data(f2->begin_data(), f2->end_data()), - "data different over vertex"); + assert_msg(v1->is_equal_env_data(f2->begin_env_data(), f2->end_env_data()), + "data different over vertex"); } - void create_edge(Halfedge_handle1 h1, - Halfedge_handle2 h2, - Res_halfedge_handle res_h) - { + void create_edge(Halfedge_handle1 h1, Halfedge_handle2 h2, + Res_halfedge_handle res_h) { res_h->set_aux_source(0, h1); res_h->set_aux_source(1, h2); res_h->twin()->set_aux_source(0, h1->twin()); res_h->twin()->set_aux_source(1, h2->twin()); - assert_msg(h1->is_equal_data(h2->begin_data(), h2->end_data()), - "data different over edge"); + assert_msg(h1->is_equal_env_data(h2->begin_env_data(), h2->end_env_data()), + "data different over edge"); } - void create_edge(Halfedge_handle1 h1, - Face_handle2 f2, - Res_halfedge_handle res_h) - { + void create_edge(Halfedge_handle1 h1, Face_handle2 f2, + Res_halfedge_handle res_h) { res_h->set_aux_source(0, h1); res_h->set_aux_source(1, f2); res_h->twin()->set_aux_source(0, h1->twin()); res_h->twin()->set_aux_source(1, f2); - assert_msg(h1->is_equal_data(f2->begin_data(), f2->end_data()), - "data different over edge"); + assert_msg(h1->is_equal_env_data(f2->begin_env_data(), f2->end_env_data()), + "data different over edge"); } - void create_edge(Face_handle1 f1, - Halfedge_handle2 h2, - Res_halfedge_handle res_h) - { + void create_edge(Face_handle1 f1, Halfedge_handle2 h2, + Res_halfedge_handle res_h) { res_h->set_aux_source(0, f1); res_h->set_aux_source(1, h2); res_h->twin()->set_aux_source(0, f1); res_h->twin()->set_aux_source(1, h2->twin()); - assert_msg(f1->is_equal_data(h2->begin_data(), h2->end_data()), - "data different over edge"); - + assert_msg(f1->is_equal_env_data(h2->begin_env_data(), h2->end_env_data()), + "data different over edge"); } - }; } //namespace CGAL #endif - - diff --git a/Envelope_3/test/Envelope_3/Envelope_triangles_test_3.h b/Envelope_3/test/Envelope_3/Envelope_triangles_test_3.h index 194b9fb7a12..6eec83590a9 100644 --- a/Envelope_3/test/Envelope_3/Envelope_triangles_test_3.h +++ b/Envelope_3/test/Envelope_3/Envelope_triangles_test_3.h @@ -8,17 +8,12 @@ // $Name: $ // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // -// Author(s) : Michal Meyerovitch +// Author(s) : Michal Meyerovitch +// Efi Fogel #ifndef CGAL_ENVELOPE_TRIANGLES_TEST_3_H #define CGAL_ENVELOPE_TRIANGLES_TEST_3_H -#include "Envelope_test_overlay_functor.h" -#include - -#include -#include - #include #include #include @@ -26,6 +21,11 @@ #include #include +#include "Envelope_test_overlay_functor.h" +#include +#include +#include + //#define CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 // this is a very trivial and not efficient algorithm for computing the lower @@ -38,59 +38,47 @@ namespace CGAL { -template +template class Envelope_triangles_test_3 { public: - typedef EnvelopeTraits_3 Traits; - typedef typename Traits::Surface_3 Surface_3; - typedef typename Traits::Xy_monotone_surface_3 Xy_monotone_surface_3; + using Traits = EnvelopeTraits_3; + using Minimization_diagram_2 = MinimizationDiagram_2; - typedef MinimizationDiagram_2 Minimization_diagram_2; - typedef typename Minimization_diagram_2::Point_2 Point_2; - typedef typename Minimization_diagram_2::X_monotone_curve_2 - X_monotone_curve_2; - typedef typename Traits::Curve_2 Curve_2; +private: + using Md2 = Minimization_diagram_2; + +public: + using Surface_3 = typename Traits::Surface_3; + using Xy_monotone_surface_3 = typename Traits::Xy_monotone_surface_3; + + using Point_2 = typename Md2::Point_2; + using X_monotone_curve_2 = typename Md2::X_monotone_curve_2; + using Curve_2 = typename Traits::Curve_2; protected: - typedef Envelope_test_overlay_functor - Overlay_functor; - typedef Envelope_overlay_2 - Overlay_2; + using Overlay_functor = Envelope_test_overlay_functor; + using Overlay_2 = Envelope_overlay_2; - typedef Arr_walk_along_line_point_location - Md_point_location; + using Md2_point_location = Arr_walk_along_line_point_location; - typedef typename Minimization_diagram_2::Halfedge_const_iterator - Halfedge_const_iterator; - typedef typename Minimization_diagram_2::Halfedge_const_handle - Halfedge_const_handle; - typedef typename Minimization_diagram_2::Halfedge_handle - Halfedge_handle; - typedef typename Minimization_diagram_2::Halfedge_iterator - Halfedge_iterator; - typedef typename Minimization_diagram_2::Vertex_const_handle - Vertex_const_handle; - typedef typename Minimization_diagram_2::Vertex_handle - Vertex_handle; - typedef typename Minimization_diagram_2::Vertex_iterator - Vertex_iterator; - typedef typename Minimization_diagram_2::Face_handle Face_handle; - typedef typename Minimization_diagram_2::Face_const_iterator - Face_const_iterator; - typedef typename Minimization_diagram_2::Face_const_handle - Face_const_handle; - typedef typename Minimization_diagram_2::Face_iterator - Face_iterator; - typedef typename Minimization_diagram_2::Ccb_halfedge_circulator - Ccb_halfedge_circulator; - typedef typename Minimization_diagram_2::Inner_ccb_iterator - Hole_iterator; + using Halfedge_const_iterator = typename Md2::Halfedge_const_iterator; + using Halfedge_const_handle = typename Md2::Halfedge_const_handle; + using Halfedge_handle = typename Md2::Halfedge_handle; + using Halfedge_iterator = typename Md2::Halfedge_iterator; + using Vertex_const_handle = typename Md2::Vertex_const_handle; + using Vertex_handle = typename Md2::Vertex_handle; + using Vertex_iterator = typename Md2::Vertex_iterator; + using Face_handle = typename Md2::Face_handle; + using Face_const_iterator = typename Md2::Face_const_iterator; + using Face_const_handle = typename Md2::Face_const_handle; + using Face_iterator = typename Md2::Face_iterator; + using Ccb_halfedge_circulator = typename Md2::Ccb_halfedge_circulator; + using Hole_iterator = typename Md2::Inner_ccb_iterator; - typedef typename Minimization_diagram_2::Dcel::Face_data_iterator - Face_data_iterator; + using Face_data_iterator = typename Md2::Dcel::Face_data_iterator; - typedef std::pair - Intersection_curve; + using Multiplicity = typename EnvelopeTraits_3::Multiplicity; + using Intersection_curve = std::pair; public: // c'tor @@ -99,27 +87,22 @@ public: // virtual destructor. virtual ~Envelope_triangles_test_3() { } - template + template void construct_lu_envelope(SurfaceIterator begin, SurfaceIterator end, - Minimization_diagram_2 &result) - { - if (begin == end) - return; // result is empty + Minimization_diagram_2& result) { + if (begin == end) return; // result is empty std::vector surfaces; - SurfaceIterator si = begin; - for (; si != end; ++si) - surfaces.push_back(*si); + for (auto si = begin; si != end; ++si) surfaces.push_back(*si); - Md_point_location pl(result); + Md2_point_location pl(result); std::size_t number_of_surfaces = surfaces.size(); std::list curves_col; std::list points_col; - for(std::size_t i=0; i(&(*bit)); + const auto* boundary_cv = std::get_if(&(*bit)); assert(boundary_cv!=nullptr); curves_col.push_back(boundary_cv->first); } @@ -147,8 +130,7 @@ public: (cur_surface, prev_surface, std::back_inserter(inter_objs)); // we collect all intersections and use sweep to insert them - for(std::size_t k=0; k(&inter_objs[k])) { #ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 std::cout << "intersection between surfaces is a point: " @@ -157,7 +139,8 @@ public: //insert_vertex(result, point, pl); points_col.push_back(*point); } - else if (const Intersection_curve* curve = std::get_if(&inter_objs[k])) { + else if (const auto* curve = + std::get_if(&inter_objs[k])) { #ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 std::cout << "intersection between surfaces is a curve: " << curve.first << std::endl; @@ -165,26 +148,22 @@ public: curves_col.push_back(curve->first); //insert(result, curve.first, pl); } - else - { - assert_msg(false, "wrong intersection type"); - } + else assert_msg(false, "wrong intersection type"); } } } #ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 std::cout << "inserting the curves: " << std::endl; - typename std::list::iterator curves_it = curves_col.begin(); - for(; curves_it != curves_col.end(); ++curves_it) + for(auto curves_it = curves_col.begin(); curves_it != curves_col.end(); + ++curves_it) std::cout << *curves_it << std::endl; #endif // insert the curves insert(result, curves_col.begin(), curves_col.end()); // insert the points - typename std::list::iterator pit = points_col.begin(); - for (; pit != points_col.end(); ++pit) + for (auto pit = points_col.begin(); pit != points_col.end(); ++pit) insert_point(result, *pit, pl); m_result = &result; @@ -193,14 +172,12 @@ public: // are minimal over it. // update vertices' data - Vertex_iterator vi = result.vertices_begin(); - for (; vi != result.vertices_end(); ++vi) { + for (auto vi = result.vertices_begin(); vi != result.vertices_end(); ++vi) { Vertex_handle vh = vi; // first we find the surfaces that are defined over the vertex std::list defined_surfaces; - typename Traits::Is_defined_over is_defined_over = - traits.is_defined_over_object(); - for(std::size_t i=0; ipoint(), surfaces[i])) defined_surfaces.push_back(surfaces[i]); @@ -210,8 +187,8 @@ public: } // update edges' data - Halfedge_iterator hi = result.halfedges_begin(); - for (; hi != result.halfedges_end(); ++hi, ++hi) { + for (auto hi = result.halfedges_begin(); hi != result.halfedges_end(); + ++hi, ++hi) { Halfedge_handle hh = hi; // first we find the surfaces that are defined over the edge std::list defined_surfaces; @@ -229,12 +206,11 @@ public: // init current face for caching of computation current_face = Face_handle(); - Face_iterator fi; - for (fi = result.faces_begin(); fi != result.faces_end(); ++fi) { + for (auto fi = result.faces_begin(); fi != result.faces_end(); ++fi) { Face_handle fh = fi; // first we find the surfaces that are defined over the face std::list defined_surfaces; - for(std::size_t i=0; iis_unbounded()) { + if (! fh->is_unbounded()) { Point_2 inside_test = compute_point_inside_face(test_env, fh); auto pl_obj = pl.locate(inside_test); // faces of env must contain the faces of test const Face_const_handle* pl_fh = std::get_if(&pl_obj); - assert(pl_fh!=nullptr); - eq = fh->is_equal_data((*pl_fh)->begin_data(), (*pl_fh)->end_data()); + assert(pl_fh != nullptr); + auto eq = fh->is_equal_env_data((*pl_fh)->begin_env_data(), + (*pl_fh)->end_env_data()); assert(eq); result &= eq; } @@ -275,10 +250,9 @@ public: // compare the 2 envelopes by overlaying them, and then comparing the // surfaces over the faces of the result map // if faces_only = false we also compare the data over the edges & vertices - bool compare_lu_envelopes_test2(Minimization_diagram_2 &test_env, - Minimization_diagram_2 &env, - bool /* faces_only */ = true) - { + bool compare_lu_envelopes_test2(Minimization_diagram_2& test_env, + Minimization_diagram_2& env, + bool /* faces_only */ = true) { Minimization_diagram_2 overlay_map; // overlay the 2 maps, the overlay test functor does all the comparisons overlay(test_env, env, overlay_map); @@ -286,27 +260,23 @@ public: } protected: - // fill the vertex with the surface on the envelope // all the surfaces are known to be defined over the vertex' point - template + template void set_minimum_over_vertex(Vertex_handle v, SurfaceIterator begin, - SurfaceIterator end) - { - if (begin == end) - v->set_no_data(); + SurfaceIterator end) { + if (begin == end) v->set_no_env_data(); else { - SurfaceIterator si = begin; + auto si = begin; // we set the first surface as the minimum, and then compare all the others - v->set_data(*si); + v->set_env_data(*si); ++si; for (; si != end; ++si) { - Comparison_result cr = - traits.compare_z_at_xy_3_object()(v->point(), v->get_data(), *si); - if (cr == EQUAL) - v->add_data(*si); - else if (cr == LARGER) - v->set_data(*si); // this erases all surfaces from vertex's list + auto cr = traits.compare_z_at_xy_3_object()(v->point(), + v->env_data_front(), *si); + if (cr == EQUAL) v->add_env_data(*si); + // this erases all surfaces from vertex's list + else if (cr == LARGER) v->set_env_data(*si); // else - new surface has no affect on the envelope } } @@ -314,59 +284,51 @@ protected: // fill the edge with the surface on the envelope // all the surfaces are known to be defined over the edge's curve - template + template void set_minimum_over_edge(const Halfedge_handle& h, SurfaceIterator begin, - SurfaceIterator end) - { - if (begin == end) - h->set_no_data(); + SurfaceIterator end) { + if (begin == end) h->set_no_env_data(); else { - if (h != current_edge) - compute_point_in_current_edge(h); + if (h != current_edge) compute_point_in_current_edge(h); - SurfaceIterator si = begin; + auto si = begin; // we set the first surface as the minimum, and then compare all the others - h->set_data(*si); + h->set_env_data(*si); ++si; for (; si != end; ++si) { - Comparison_result cr = - traits.compare_z_at_xy_3_object()(current_point_inside_edge, - h->get_data(), *si); - if (cr == EQUAL) - h->add_data(*si); - else if (cr == LARGER) - h->set_data(*si); // this erases all surfaces from halfedge's list + auto cr = traits.compare_z_at_xy_3_object()(current_point_inside_edge, + h->env_data_front(), *si); + if (cr == EQUAL) h->add_env_data(*si); + // this erases all surfaces from halfedge's list + else if (cr == LARGER) h->set_env_data(*si); // else - new surface has no affect on the envelope } // set twin's data - h->twin()->set_data(h->begin_data(), h->end_data()); + h->twin()->set_env_data(h->begin_env_data(), h->end_env_data()); } } // fill the face with the surface on the envelope // the surfaces are known to not intersect inside the face // (but might intersect on its edges) - template + template void set_minimum_over_face(Face_handle face, SurfaceIterator begin, - SurfaceIterator end) - { + SurfaceIterator end) { if (face->is_unbounded() || begin == end) { // a special case - no surface over the unbounded face, and when there // are no surfaces at all - face->set_no_data(); + face->set_no_env_data(); } else { - SurfaceIterator si = begin; + auto si = begin; // we set the first surface as the minimum, and then compare all the // others - face->set_data(*si); + face->set_env_data(*si); ++si; for (; si != end; ++si) { - Comparison_result cr = - compare_surfaces_over_face(face, face->get_data(), *si); - if (cr == EQUAL) - face->add_data(*si); - else if (cr == LARGER) - face->set_data(*si); // this erases all surfaces from face's list + auto cr = compare_surfaces_over_face(face, face->env_data_front(), *si); + if (cr == EQUAL) face->add_env_data(*si); + // this erases all surfaces from face's list + else if (cr == LARGER) face->set_env_data(*si); // else - new surface has no affect on the envelope } } @@ -379,8 +341,7 @@ protected: Comparison_result compare_surfaces_over_face(Face_handle face, const Xy_monotone_surface_3& surf1, - const Xy_monotone_surface_3& surf2) - { + const Xy_monotone_surface_3& surf2) { Comparison_result result2 = compare_surfaces_over_face_v2(face, surf1, surf2); @@ -407,8 +368,7 @@ protected: Comparison_result compare_surfaces_over_face_v1(const Face_handle& face, const Xy_monotone_surface_3& surf1, - const Xy_monotone_surface_3& surf2) - { + const Xy_monotone_surface_3& surf2) { // TODO: this works for triangles, but not for general surfaces // in the general case, should use surface_compare_on_right and @@ -416,7 +376,7 @@ protected: // we iterate over the vertices of the face, and look for one that the // surfaces are not equal above it. (if doesn't exist, then the surfaces // overlap) - assert(!face->is_unbounded()); + assert(! face->is_unbounded()); Comparison_result cur_res; Ccb_halfedge_circulator hec = face->outer_ccb(); Ccb_halfedge_circulator hec_begin = hec; @@ -430,10 +390,9 @@ protected: << cur_res << std::endl; #endif - if (cur_res != EQUAL) - found_not_equal = true; - hec++; - } while(hec != hec_begin && !found_not_equal); + if (cur_res != EQUAL) found_not_equal = true; + ++hec; + } while ((hec != hec_begin) && ! found_not_equal); // std::cout << "for comparison on vertices, result = " << cur_res // << std::endl; @@ -448,10 +407,9 @@ protected: // this version also works only for linear surfaces Comparison_result compare_surfaces_over_face_v2(const Face_handle& face, - const Xy_monotone_surface_3 &surf1, - const Xy_monotone_surface_3& surf2) - { - assert(!face->is_unbounded()); + const Xy_monotone_surface_3& surf1, + const Xy_monotone_surface_3& surf2) { + assert(! face->is_unbounded()); Comparison_result cur_res; if (face != current_face) compute_point_in_current_face(face); @@ -468,11 +426,9 @@ protected: // check if the surface is defines over the edge bool is_surface_defined_over_edge(const Halfedge_handle& h, - Xy_monotone_surface_3 &surf) - { + Xy_monotone_surface_3& surf) { // check it over a point inside the edge's curve - if (h != current_edge) - compute_point_in_current_edge(h); + if (h != current_edge) compute_point_in_current_edge(h); bool result = traits.is_defined_over_object()(current_point_inside_edge, surf); @@ -481,11 +437,10 @@ protected: // check if the surface is defines over the face bool is_surface_defined_over_face(const Face_handle& face, - Xy_monotone_surface_3 &surf) + Xy_monotone_surface_3& surf) { // we always have bounded surfaces - if (face->is_unbounded()) - return false; + if (face->is_unbounded()) return false; bool result2 = is_surface_defined_over_face_v2(face, surf); @@ -505,16 +460,14 @@ protected: // check if the surface is defines over the face // this is version 1 which check all the vertices of the face bool is_surface_defined_over_face_v1(const Face_handle& face, - Xy_monotone_surface_3 &surf) - { + Xy_monotone_surface_3& surf) { // for now, we go over all the vertices of the face - typename Traits::Is_defined_over is_defined_over = - traits.is_defined_over_object(); + auto is_defined_over = traits.is_defined_over_object(); // check vertices on the outer ccb bool result = true; - if (!face->is_unbounded()) { + if (! face->is_unbounded()) { Ccb_halfedge_circulator hec = face->outer_ccb(); Ccb_halfedge_circulator hec_begin = hec; do { @@ -522,16 +475,15 @@ protected: bool tmp_result = is_defined_over(target_2,surf); #ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 - std::cout << "is define over returned " << tmp_result << std::endl; + std::cout << "is define over returned " << tmp_result << std::endl; #endif result &= tmp_result; - hec++; - } while(hec != hec_begin && result); + ++hec; + } while ((hec != hec_begin) && result); } - if (result == false) - return result; + if (! result) return result; // check vertices on holes boundary Hole_iterator hi; @@ -547,10 +499,9 @@ protected: #endif result &= tmp_result; - hec++; - } while(hec != hec_begin && result); - if (result == false) - return result; + ++hec; + } while ((hec != hec_begin) && result); + if (! result) return result; } return result; @@ -559,8 +510,7 @@ protected: // check if the surface is defines over the face // this is version 2 which check the point inside the face bool is_surface_defined_over_face_v2(const Face_handle& face, - Xy_monotone_surface_3 &surf) - { + Xy_monotone_surface_3& surf) { if (face != current_face) compute_point_in_current_face(face); @@ -570,10 +520,9 @@ protected: } // compute a point inside the face of the arranegement - Point_2 compute_point_inside_face(Minimization_diagram_2 &env, - Face_handle face) - { - assert(!face->is_unbounded()); + Point_2 compute_point_inside_face(Minimization_diagram_2& env, + Face_handle face) { + assert(! face->is_unbounded()); #ifdef CGAL_DEBUG_ENVELOPE_TRIANGLES_TEST_3 std::cout << "in compute point inside face" << std::endl; @@ -584,12 +533,12 @@ protected: Ccb_halfedge_circulator hec_begin = hec; bool found = false; do { - if (!traits.is_vertical_2_object()(hec->curve())) { + if (! traits.is_vertical_2_object()(hec->curve())) { found = true; continue; } - hec++; - } while (hec != hec_begin && !found); + ++hec; + } while ((hec != hec_begin) && !found); assert(found); Halfedge_handle found_hh = hec; @@ -611,17 +560,15 @@ protected: (found_hh->curve()))) shoot_up = false; - Md_point_location pl(env); + Md2_point_location pl(env); Object shoot_obj; Halfedge_const_handle shoot_hh; Vertex_const_handle shoot_vh; Point_2 shoot_target; - if (shoot_up) - shoot_obj = pl.ray_shoot_up(shoot_source); - else - shoot_obj = pl.ray_shoot_down(shoot_source); + if (shoot_up) shoot_obj = pl.ray_shoot_up(shoot_source); + else shoot_obj = pl.ray_shoot_down(shoot_source); if (assign(shoot_hh, shoot_obj)) { shoot_target = @@ -630,8 +577,7 @@ protected: else if (assign(shoot_vh, shoot_obj)) { shoot_target = (env.non_const_handle(shoot_vh))->point(); } - else - CGAL_error(); // it cannot be the unbounded face + else CGAL_error(); // it cannot be the unbounded face Point_2 res_point = traits.construct_middle_point(shoot_source, shoot_target); @@ -652,16 +598,14 @@ protected: // compute a point inside the face saved in current_face // and put the result into current_point - void compute_point_in_current_face(Face_handle face) - { + void compute_point_in_current_face(Face_handle face) { current_face = face; current_point = compute_point_inside_face(*m_result, current_face); } // compute a point inside the edge saved in current_edge // and put the result into current_point_inside_edge - void compute_point_in_current_edge(Halfedge_handle h) - { + void compute_point_in_current_edge(Halfedge_handle h) { current_edge = h; current_point_inside_edge = traits.construct_middle_point(h->curve()); } diff --git a/Envelope_3/test/Envelope_3/spheres_test.cpp b/Envelope_3/test/Envelope_3/spheres_test.cpp index 7fd2634e1a9..2d45e12526a 100644 --- a/Envelope_3/test/Envelope_3/spheres_test.cpp +++ b/Envelope_3/test/Envelope_3/spheres_test.cpp @@ -5,7 +5,7 @@ int main () { - bool UNTESTED_TRAITS_AS_CORE_IS_NOT_ISTALLED; + bool UNTESTED_TRAITS_AS_CORE_IS_NOT_INSTALLED; std::cout << std::endl << "WARNING: Core is not installed, " << "skipping the test ..." diff --git a/GraphicsView/include/CGAL/Qt/CGAL_Qt_config.h b/GraphicsView/include/CGAL/Qt/CGAL_Qt_config.h index 6aad119ecc3..a617735b67e 100644 --- a/GraphicsView/include/CGAL/Qt/CGAL_Qt_config.h +++ b/GraphicsView/include/CGAL/Qt/CGAL_Qt_config.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Laurent Rineau @@ -12,6 +12,9 @@ #ifndef CGAL_QT_CONFIG_H #define CGAL_QT_CONFIG_H +#include + + #include #if defined(CGAL_Qt6_DLL) diff --git a/GraphicsView/include/CGAL/Qt/CreateOpenGLContext.h b/GraphicsView/include/CGAL/Qt/CreateOpenGLContext.h index 5c37bffe9a0..c984b85a5d2 100644 --- a/GraphicsView/include/CGAL/Qt/CreateOpenGLContext.h +++ b/GraphicsView/include/CGAL/Qt/CreateOpenGLContext.h @@ -5,13 +5,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Laurent Rineau and Maxime Gimeno #ifndef CGAL_QT_CREATE_OPENGL_CONTEXT_H #define CGAL_QT_CREATE_OPENGL_CONTEXT_H +#include + + #include namespace CGAL{ diff --git a/GraphicsView/include/CGAL/auto_link/Qt.h b/GraphicsView/include/CGAL/auto_link/Qt.h index a08e108e2d3..a27bb073b2b 100644 --- a/GraphicsView/include/CGAL/auto_link/Qt.h +++ b/GraphicsView/include/CGAL/auto_link/Qt.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Laurent Rineau @@ -12,6 +12,9 @@ #ifndef CGAL_AUTO_LINK_QT_H #define CGAL_AUTO_LINK_QT_H +#include + + #include #include diff --git a/GraphicsView/include/CGAL/export/Qt.h b/GraphicsView/include/CGAL/export/Qt.h index a5b1c82fa19..14ea46c6380 100644 --- a/GraphicsView/include/CGAL/export/Qt.h +++ b/GraphicsView/include/CGAL/export/Qt.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri @@ -12,6 +12,9 @@ #ifndef CGAL_QT_EXPORT_H #define CGAL_QT_EXPORT_H +#include + + #include #include diff --git a/GraphicsView/package_info/GraphicsView/license.txt b/GraphicsView/package_info/GraphicsView/license.txt index 3ca1763d670..b75100428a6 100644 --- a/GraphicsView/package_info/GraphicsView/license.txt +++ b/GraphicsView/package_info/GraphicsView/license.txt @@ -1,3 +1,2 @@ GPL (v3 or later) -LGPL (v3 or later) UNKNOWN diff --git a/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/CMakeLists.txt b/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/CMakeLists.txt index e5a66d69733..15433a72b16 100644 --- a/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/CMakeLists.txt +++ b/Hyperbolic_triangulation_2/examples/Hyperbolic_triangulation_2/CMakeLists.txt @@ -5,6 +5,11 @@ cmake_minimum_required(VERSION 3.1...3.23) project(Hyperbolic_triangulation_2_Examples) find_package(CGAL REQUIRED COMPONENTS Core) +find_package(LEDA QUIET) -create_single_source_cgal_program("ht2_example.cpp") -create_single_source_cgal_program("ht2_example_color.cpp") +if (CGAL_Core_FOUND OR LEDA_FOUND) + create_single_source_cgal_program("ht2_example.cpp") + create_single_source_cgal_program("ht2_example_color.cpp") +else() + message("NOTICE: Examples require CGAL_Core (or LEDA), and will not be compiled.") +endif() diff --git a/Hyperbolic_triangulation_2/test/Hyperbolic_triangulation_2/CMakeLists.txt b/Hyperbolic_triangulation_2/test/Hyperbolic_triangulation_2/CMakeLists.txt index 451ccac8d32..b61314c788b 100644 --- a/Hyperbolic_triangulation_2/test/Hyperbolic_triangulation_2/CMakeLists.txt +++ b/Hyperbolic_triangulation_2/test/Hyperbolic_triangulation_2/CMakeLists.txt @@ -5,11 +5,16 @@ cmake_minimum_required(VERSION 3.1...3.23) project(Hyperbolic_triangulation_2_Tests) find_package(CGAL REQUIRED COMPONENTS Core) +find_package(LEDA QUIET) -create_single_source_cgal_program("ht2_test_clear.cpp") -create_single_source_cgal_program("ht2_test_locate.cpp") -create_single_source_cgal_program("ht2_test_remove.cpp") -create_single_source_cgal_program("ht2_test_swap.cpp") -create_single_source_cgal_program("ht2_test_copy.cpp") -create_single_source_cgal_program("ht2_test_hyperbolic_circulator.cpp") -create_single_source_cgal_program("ht2_test_insert_degenerate.cpp") +if (CGAL_Core_FOUND OR LEDA_FOUND) + create_single_source_cgal_program("ht2_test_clear.cpp") + create_single_source_cgal_program("ht2_test_locate.cpp") + create_single_source_cgal_program("ht2_test_remove.cpp") + create_single_source_cgal_program("ht2_test_swap.cpp") + create_single_source_cgal_program("ht2_test_copy.cpp") + create_single_source_cgal_program("ht2_test_hyperbolic_circulator.cpp") + create_single_source_cgal_program("ht2_test_insert_degenerate.cpp") +else() + message("NOTICE: Tests require CGAL_Core (or LEDA), and will not be compiled.") +endif() diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index e4421fbb878..7932846acc4 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -16,6 +16,10 @@ Release date: October 2023 - **Breaking change**: The usage of `boost::variant` has been replaced by `std::variant`. Packages affected are 2D Arrangements, and the Kernel intersection. - **Breaking change**: The file CMake file `UseCGAL.cmake` has been removed from CGAL. Usages of the CMake variables `${CGAL_USE_FILE}` and `${CGAL_LIBRARIES}` must be replaced by a link to the imported target `CGAL::CGAL`, for example: `target_link_library(the_target PRIVATE CGAL::CGAL)`. +### [Polygon Repair](https://doc.cgal.org/6.0/Manual/packages.html#PkgPolygonRepair) (new package) + +- This package provides functions to repair polygons, polygons with holes, and multipolygons with holes + using the odd-even heuristic. #### 2D Arrangements @@ -23,13 +27,15 @@ Release date: October 2023 `std::variant`. The support for the old macro `CGAL_ARR_POINT_LOCATION_VERSION` has been removed. +- Eliminated the error-prone c-type casting that was used to define observers. In general, backward compatibility was maintained; however, the former class template `Arr_observer` was replaced by an alias template. (The former class Arr_observer was renamed to Aos_observer). + +- Introduced `Arr_dcel`, which essentially replaces the former `Arr_default_dcel`. Backward compatibility was maintained by the introduction of the alias template `Arr_default_dcel`. `Arr_dcel`, as opposed to the former `Arr_default_dcel` is templated (in addition to the geometry traits) by Vertex, Halfedge, and Face template parameters, and they have default type values. All this enables the layered extension of DCEL records. + #### Envelopes of Surfaces in 3D - **Breaking change**: Construct_projected_boundary_2 in `EnvelopeTraits_3` is now using `std::variant` instead of `Object` -### [Polygon Repair](https://doc.cgal.org/6.0/Manual/packages.html#PkgPolygonRepair) (new package) - -- This package provides functions to repair polygons, polygons with holes, and multipolygons with holes - using the odd-even heuristic. +- Passed the base class of `Env_plane_traits_3` as a template parameter with a default value (being the 2D arrangement linear traits). Similarly, passed the base class of `Env_triangle_traits_3` as a template parameter with a default value (being the 2D arrangement segment traits). +>>>>>>> cgal/master ### [Combinatorial Maps](https://doc.cgal.org/6.0/Manual/packages.html#PkgCombinatorialMaps) and [Generalized Maps](https://doc.cgal.org/6.0/Manual/packages.html#PkgGeneralizedMaps) @@ -79,6 +85,13 @@ Release date: October 2023 - Added three functions `vertices()` to the class `Triangulation_3`. Each of them returns an array containing the vertices of the given triangulation simplex. +### [dD Triangulations](https://doc.cgal.org/6.0/Manual/packages.html#PkgTriangulations) +- **Breaking change**: `CGAL::TDS_full_cell_mirror_storage_policy` is now unsupported in dimension larger than 127. +- **Breaking change**: Inserting multiple unweighted points in the same + position now keeps the first one, instead of switching to the latest. This + only affects custom point types where not all points in the same position + are equivalent. + [Release 5.6](https://github.com/CGAL/cgal/releases/tag/v5.6) ----------- diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 1e912131c12..fa2102ff7c0 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -592,10 +592,9 @@ set(CGAL_INSTALL_LIB_DIR ) if(CGAL_WIN32_CMAKE_ON_CYGWIN) - exec_program( - cygpath ARGS - -w "${CMAKE_INSTALL_PREFIX}" - OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX2) + execute_process(COMMAND cygpath -w ${CMAKE_INSTALL_PREFIX} + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE CMAKE_INSTALL_PREFIX2) file(TO_CMAKE_PATH ${CMAKE_INSTALL_PREFIX2} CMAKE_INSTALL_PREFIX) endif() diff --git a/Installation/README b/Installation/README deleted file mode 100644 index be07977a7c6..00000000000 --- a/Installation/README +++ /dev/null @@ -1,32 +0,0 @@ -README -------------------------------------------------------------------------------- - -This distribution of CGAL includes: - - AUTHORS - current and former authors of CGAL - CHANGES - history of changes for the library - CMakeLists.txt - main script of the build system - INSTALL.md - information about the installation process - LICENSE - describes the license of CGAL - LICENSE.FREE_USE - text of the free use license (see LICENSE file) - LICENSE.GPL - text of GPL v3 license - LICENSE.LGPL - text of LGPL v3 license - README - this file - VERSION - version number of this release - auxiliary/ - directory containing miscellaneous things, currently only - the icons needed for the demos on MacOS X - cmake/ - some scripts needed by the build system - config/ - some test programs used during the configuration process - demo/ - many demo programs for the library's various packages. - These programs produce visual output (see INSTALL for - prerequisites). - doc_html/ - documentation, e.g. the CGAL Installation Guide - examples/ - programs illustrating the library's functionality. - These programs do not produce visual output. - include/ - the include files for the CGAL library (and other small - external libraries as well, see the LICENSE file) - scripts/ - some useful scripts for CGAL programmers - src/ - the source code for building the CGAL libraries - (as well as some external libraries, see the LICENSE file) - -------------------------------------------------------------------------------- diff --git a/Installation/README.md b/Installation/README.md new file mode 100644 index 00000000000..47b4058ec3f --- /dev/null +++ b/Installation/README.md @@ -0,0 +1,32 @@ +README +====== + +This distribution of CGAL includes: + +| File or directory | Description | +|-------------------|--------------------------------------------------------------------------------------------------| +| `AUTHORS` | current and former authors of CGAL | +| `CHANGES.md` | history of changes of CGAL | +| `CGALConfig.cmake`| [CMake package] configuration file for CGAL | +| `CGALConfigVersion.cmake` | [CMake package] version file for CGAL | +| `CMakeLists.txt` | main CMake project configuration file | +| `INSTALL.md` | information about the installation process | +| `LICENSE` | describes the license of CGAL | +| `LICENSE.BSL` | text of the Boost Software License (BSL) license | +| `LICENSE.COMMERCIAL` | text of the GeometryFactory Commercial license | +| `LICENSE.GPL` | text of the GNU General Public License (GPL) v3 license | +| `LICENSE.LGPL` | text of the GNU Lesser General Public License (LGPL) v3 license | +| `LICENSE.RFL` | text of the ETH Zurich Random Forest algorithm License (RFL) license | +| `README.md` | this file | +| `VERSION` | version number of this release of CGAL | +| `auxiliary/` | directory containing miscellaneous things, such as icons needed for the demos on macOS | +| `cmake/` | some scripts needed by the CMake build system | +| `data/` | directory containing various geometric data used by examples and demos of CGAL | +| `demo/` | many demo programs for the various packages of CGAL. These programs produce visual output. | +| `doc_html/` | documentation, such as the CGAL Installation Guide | +| `examples/` | programs illustrating the usage of various packages of CGAL. | +| `include/` | the include files for the CGAL library (as well as small external libraries, see the file `LICENSE`) | +| `lib/` | contains [CMake package] configuration files for CGAL | +| `scripts/` | some useful scripts for CGAL programmers | + +[CMake package]: https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html diff --git a/Installation/cmake/modules/CGAL_Common.cmake b/Installation/cmake/modules/CGAL_Common.cmake index ce99da6489e..df6446c92ae 100644 --- a/Installation/cmake/modules/CGAL_Common.cmake +++ b/Installation/cmake/modules/CGAL_Common.cmake @@ -20,7 +20,9 @@ if( NOT CGAL_COMMON_FILE_INCLUDED ) if ( WIN32 ) find_program(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin ) if(CMAKE_UNAME) - exec_program(uname ARGS -s OUTPUT_VARIABLE CMAKE_SYSTEM_NAME2) + execute_process(COMMAND uname -s + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE CMAKE_SYSTEM_NAME2) if ( CMAKE_SYSTEM_NAME2 MATCHES "CYGWIN" ) message( STATUS "This is the Windows CMake running within the cygwin platform." ) set( CGAL_WIN32_CMAKE_ON_CYGWIN TRUE CACHE INTERNAL "This is the cygwin platform." ) diff --git a/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake b/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake index 2a9fdc4bd87..c51173216b3 100644 --- a/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake +++ b/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake @@ -57,12 +57,6 @@ function(create_single_source_cgal_program firstfile ) set(NO_TESTING TRUE) endif() - if(NOT NO_TESTING) - cgal_add_test(${exe_name}) - else() - cgal_add_test(${exe_name} NO_EXECUTION) - endif() - add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${exe_name} ) target_link_libraries(${exe_name} PRIVATE CGAL::CGAL CGAL::Data) @@ -75,13 +69,10 @@ function(create_single_source_cgal_program firstfile ) target_link_libraries(${exe_name} PRIVATE ${CGAL_3RD_PARTY_LIBRARIES}) endif() - if(POLICY CMP0064) - # CMake 3.4 or later - if(NOT NO_TESTING) - cgal_add_test(${exe_name}) - else() - cgal_add_test(${exe_name} NO_EXECUTION) - endif() + if(NOT NO_TESTING) + cgal_add_test(${exe_name}) + else() + cgal_add_test(${exe_name} NO_EXECUTION) endif() else() diff --git a/Installation/cmake/modules/CGAL_GeneratorSpecificSettings.cmake b/Installation/cmake/modules/CGAL_GeneratorSpecificSettings.cmake index 70dc4de3e56..3b62159e5e0 100644 --- a/Installation/cmake/modules/CGAL_GeneratorSpecificSettings.cmake +++ b/Installation/cmake/modules/CGAL_GeneratorSpecificSettings.cmake @@ -39,7 +39,9 @@ if ( NOT CGAL_GENERATOR_SPECIFIC_SETTINGS_FILE_INCLUDED ) # From james Bigler, in the cmake users list. IF (APPLE) - exec_program(uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION) + execute_process(COMMAND uname -v + OUTPUT_STRIP_TRAILING_WHITESPACE + OUTPUT_VARIABLE DARWIN_VERSION) string(REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION}) message(STATUS "Running in macOS DARWIN_VERSION=${DARWIN_VERSION}") endif() diff --git a/Installation/cmake/modules/CGAL_add_test.cmake b/Installation/cmake/modules/CGAL_add_test.cmake index a163bca7891..edc7b43dbee 100644 --- a/Installation/cmake/modules/CGAL_add_test.cmake +++ b/Installation/cmake/modules/CGAL_add_test.cmake @@ -117,16 +117,15 @@ function(cgal_add_compilation_test exe_name) add_test(NAME "check build system" COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "cgal_check_build_system" --config "$") set_property(TEST "check build system" - APPEND PROPERTY LABELS "CGAL_build_system") + APPEND PROPERTY LABELS "CGAL_build_system" "Installation") set_property(TEST "check build system" PROPERTY FIXTURES_SETUP "check_build_system_SetupFixture") endif() if(TARGET CGAL_Qt6_moc_and_resources) # if CGAL_Qt6 was searched, and is header-only get_property(linked_libraries TARGET "${exe_name}" PROPERTY LINK_LIBRARIES) # message(STATUS "${exe_name} depends on ${linked_libraries}") - string(FIND "${linked_libraries}" "CGAL::CGAL_Qt6" link_with_CGAL_Qt6) - if(link_with_CGAL_Qt6 STRGREATER "-1" AND - NOT TARGET "compilation_of__CGAL_Qt6_moc_and_resources") + if( ("CGAL_Qt6" IN_LIST linked_libraries OR "CGAL::CGAL_Qt6" IN_LIST linked_libraries OR "CGAL::CGAL_Basic_viewer" IN_LIST linked_libraries) + AND NOT TARGET "compilation_of__CGAL_Qt6_moc_and_resources") # This custom target is useless. It is used only as a flag to # detect that the test has already been created. add_custom_target("compilation_of__CGAL_Qt6_moc_and_resources") @@ -134,7 +133,7 @@ function(cgal_add_compilation_test exe_name) add_test(NAME "compilation of CGAL_Qt6_moc_and_resources" COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "CGAL_Qt6_moc_and_resources" --config "$") set_property(TEST "compilation of CGAL_Qt6_moc_and_resources" - APPEND PROPERTY LABELS "CGAL_build_system") + APPEND PROPERTY LABELS "CGAL_build_system" "Installation") set_property(TEST "compilation of CGAL_Qt6_moc_and_resources" PROPERTY FIXTURES_SETUP "CGAL_Qt6_moc_and_resources_Fixture") set_property(TEST "compilation of CGAL_Qt6_moc_and_resources" diff --git a/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake b/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake index 9fd8615c2a9..671d5e23680 100644 --- a/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake +++ b/Installation/cmake/modules/CGAL_enable_end_of_configuration_hook.cmake @@ -1,5 +1,5 @@ # This module install a hook (with `variable_watch()`) on CMAKE_CURRENT_LIST_DIR -# +# # That uses the non-documented fact that CMAKE_CURRENT_LIST_DIR is cleared # by CMake at the end of the configuration process. So, if the value of # that variable gets empty, that means that CMake has reached the end of @@ -110,17 +110,42 @@ function(CGAL_hook_fix_ctest_depending_on_Qt6) continue() endif() get_property(_target_links TARGET ${_target} PROPERTY LINK_LIBRARIES) - if("CGAL_Qt6" IN_LIST _target_links OR "CGAL::CGAL_Qt6" IN_LIST _target_links) + if("CGAL_Qt6" IN_LIST _target_links OR "CGAL::CGAL_Qt6" IN_LIST _target_links OR "CGAL::CGAL_Basic_viewer" IN_LIST _target_links) set_property(TEST "compilation of ${_target}" APPEND PROPERTY FIXTURES_REQUIRED CGAL_Qt6_moc_and_resources_Fixture) endif() endforeach() endfunction() +function(CGAL_hook_fix_ctest_dependencies) + get_property(_targets DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY BUILDSYSTEM_TARGETS) + # message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR} targets: ${_targets}") + foreach(_target ${_targets}) + if(NOT TEST "compilation of ${_target}") + continue() + endif() + get_property(linked_libraries TARGET "${_target}" PROPERTY LINK_LIBRARIES) + get_property(deps TARGET "${_target}" PROPERTY MANUALLY_ADDED_DEPENDENCIES) + list(APPEND deps ${linked_libraries}) + # message(" ${_target} depends on: ${deps}") + foreach(dep ${deps}) + if(TARGET ${dep} AND NOT dep MATCHES "^CGAL::|^CGAL_|^CGAL$" ) + get_target_property(imported ${dep} IMPORTED) + if(NOT imported) + # message(STATUS "The target ${dep} is a dependency of ${_target}.") + set_property(TEST "compilation of ${_target}" + APPEND PROPERTY DEPENDS "compilation of ${dep}") + endif() + endif() + endforeach() + endforeach() +endfunction() + function(CGAL_hooks_at_end_of_all_directories) CGAL_hook_check_targets() CGAL_hook_check_unused_cpp_files() if(CGAL_ENABLE_TESTING) CGAL_hook_fix_ctest_depending_on_Qt6() + CGAL_hook_fix_ctest_dependencies() endif() endfunction() @@ -155,6 +180,11 @@ function(CGAL_run_at_the_end_of_configuration variable access value current_list endfunction() function(CGAL_install_hooks) + get_property(PROPERTY_CGAL_hooks_installed DIRECTORY PROPERTY CGAL_hooks_installed) + if(PROPERTY_CGAL_hooks_installed) + return() + endif() + # message(STATUS "Installing hooks in ${CMAKE_CURRENT_SOURCE_DIR}") if(CMAKE_VERSION VERSION_LESS 3.19) variable_watch("CMAKE_CURRENT_LIST_DIR" CGAL_run_at_the_end_of_configuration) else() @@ -163,6 +193,7 @@ function(CGAL_install_hooks) cmake_language(DEFER CALL CGAL_hook_check_CMAKE_BUILD_TYPE) endif() endif() + set_property(DIRECTORY PROPERTY CGAL_hooks_installed TRUE) endfunction() CGAL_install_hooks() diff --git a/Installation/include/CGAL/license/Polygon_mesh_processing/autorefinement.h b/Installation/include/CGAL/license/Polygon_mesh_processing/autorefinement.h new file mode 100644 index 00000000000..8f3c9cc5e3f --- /dev/null +++ b/Installation/include/CGAL/license/Polygon_mesh_processing/autorefinement.h @@ -0,0 +1,54 @@ +// Copyright (c) 2016 GeometryFactory SARL (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Andreas Fabri +// +// Warning: this file is generated, see include/CGAL/license/README.md + +#ifndef CGAL_LICENSE_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_H +#define CGAL_LICENSE_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_H + +#include +#include + +#ifdef CGAL_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_COMMERCIAL_LICENSE + +# if CGAL_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE + +# if defined(CGAL_LICENSE_WARNING) + + CGAL_pragma_warning("Your commercial license for CGAL does not cover " + "this release of the Polygon Mesh Processing - Autorefinement package.") +# endif + +# ifdef CGAL_LICENSE_ERROR +# error "Your commercial license for CGAL does not cover this release \ + of the Polygon Mesh Processing - Autorefinement package. \ + You get this error, as you defined CGAL_LICENSE_ERROR." +# endif // CGAL_LICENSE_ERROR + +# endif // CGAL_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_COMMERCIAL_LICENSE < CGAL_RELEASE_DATE + +#else // no CGAL_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_COMMERCIAL_LICENSE + +# if defined(CGAL_LICENSE_WARNING) + CGAL_pragma_warning("\nThe macro CGAL_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_COMMERCIAL_LICENSE is not defined." + "\nYou use the CGAL Polygon Mesh Processing - Autorefinement package under " + "the terms of the GPLv3+.") +# endif // CGAL_LICENSE_WARNING + +# ifdef CGAL_LICENSE_ERROR +# error "The macro CGAL_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_COMMERCIAL_LICENSE is not defined.\ + You use the CGAL Polygon Mesh Processing - Autorefinement package under the terms of \ + the GPLv3+. You get this error, as you defined CGAL_LICENSE_ERROR." +# endif // CGAL_LICENSE_ERROR + +#endif // no CGAL_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_COMMERCIAL_LICENSE + +#endif // CGAL_LICENSE_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_H diff --git a/Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvatures.h index e484daaf5ea..5bf31aaa352 100644 --- a/Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Installation/include/CGAL/license/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -9,10 +9,10 @@ // // Author(s) : Andreas Fabri // -// Warning: this file is generated, see include/CGAL/licence/README.md +// Warning: this file is generated, see include/CGAL/license/README.md -#ifndef CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H -#define CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H +#ifndef CGAL_LICENSE_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H +#define CGAL_LICENSE_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H #include #include @@ -51,4 +51,4 @@ #endif // no CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_COMMERCIAL_LICENSE -#endif // CGAL_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H +#endif // CGAL_LICENSE_POLYGON_MESH_PROCESSING_INTERPOLATED_CORRECTED_CURVATURES_H diff --git a/Installation/include/CGAL/license/SMDS_3.h b/Installation/include/CGAL/license/SMDS_3.h index 4f349c13acf..b4011300b50 100644 --- a/Installation/include/CGAL/license/SMDS_3.h +++ b/Installation/include/CGAL/license/SMDS_3.h @@ -24,12 +24,12 @@ # if defined(CGAL_LICENSE_WARNING) CGAL_pragma_warning("Your commercial license for CGAL does not cover " - "this release of the 3D Mesh Data Structure package.") + "this release of the 3D Simplicial Mesh Data Structure package.") # endif # ifdef CGAL_LICENSE_ERROR # error "Your commercial license for CGAL does not cover this release \ - of the 3D Mesh Data Structure package. \ + of the 3D Simplicial Mesh Data Structure package. \ You get this error, as you defined CGAL_LICENSE_ERROR." # endif // CGAL_LICENSE_ERROR diff --git a/Installation/include/CGAL/license/gpl_package_list.txt b/Installation/include/CGAL/license/gpl_package_list.txt index 41612d5b9fc..a66f7cdfea7 100644 --- a/Installation/include/CGAL/license/gpl_package_list.txt +++ b/Installation/include/CGAL/license/gpl_package_list.txt @@ -20,6 +20,7 @@ Convex_hull_d dD Convex Hulls and Delaunay Triangulations Envelope_2 2D Envelopes Envelope_3 3D Envelopes GraphicsView CGAL and the Qt Graphics View Framework +Heat_method_3 The Heat Method Hyperbolic_triangulation_2 2D Hyperbolic Delaunay Triangulations Inscribed_areas Inscribed Areas Interpolation 2D and Surface Function Interpolation @@ -33,9 +34,9 @@ Minkowski_sum_3 3D Minkowski Sum of Polyhedra Nef_2 2D Boolean Operations on Nef Polygons Nef_3 3D Boolean Operations on Nef Polyhedra Nef_S2 2D Boolean Operations on Nef Polygons Embedded on the Sphere -Orthtree Quadtrees, Octrees, and Orthtrees Optimal_bounding_box Optimal Bounding Box Optimal_transportation_reconstruction_2 Optimal Transportation Curve Reconstruction +Orthtree Quadtrees, Octrees, and Orthtrees Partition_2 2D Polygon Partitioning Periodic_2_triangulation_2 2D Periodic Triangulations Periodic_3_mesh_3 3D Periodic Mesh Generation @@ -45,6 +46,7 @@ Point_set_2 2D Range and Neighbor Search Point_set_3 3D Point Set Point_set_processing_3 Point Set Processing Poisson_surface_reconstruction_3 Poisson Surface Reconstruction +Polygonal_surface_reconstruction Polygonal Surface Reconstruction Polygon_mesh_processing Polygon Mesh Processing Polygon_mesh_processing/Compute_normal Polygon Mesh Processing - Normal Computation Polygon_mesh_processing/connected_components Polygon Mesh Processing - Connected Components @@ -52,15 +54,18 @@ Polygon_mesh_processing/corefinement Polygon Mesh Processing - Corefinement Polygon_mesh_processing/core Polygon Mesh Processing - Core Polygon_mesh_processing/distance Polygon Mesh Processing - Distance Polygon_mesh_processing/interpolated_corrected_curvatures Polygon Mesh Processing - Interpolated Corrected Curvatures +Polygon_mesh_processing/locate Polygon Mesh Processing - Locate Polygon_mesh_processing/measure Polygon Mesh Processing - Geometric Measure Polygon_mesh_processing/meshing_hole_filling Polygon Mesh Processing - Meshing and Hole Filling Polygon_mesh_processing/orientation Polygon Mesh Processing - Orientation +Polygon_mesh_processing/Polyhedral_envelope Polygon Mesh Processing - Polyhedral Envelope Polygon_mesh_processing/predicate Polygon Mesh Processing - Predicate Polygon_mesh_processing/combinatorial_repair Polygon Mesh Processing - Combinatorial Repair Polygon_mesh_processing/geometric_repair Polygon Mesh Processing - Geometric Repair Polygon_mesh_processing/miscellaneous Polygon Mesh Processing - Miscellaneous Polygon_mesh_processing/detect_features Polygon Mesh Processing - Feature Detection Polygon_mesh_processing/collision_detection Polygon Mesh Processing - Collision Detection +Polygon_mesh_processing/autorefinement Polygon Mesh Processing - Autorefinement Polyhedron 3D Polyhedral Surface Polyline_simplification_2 2D Polyline Simplification Polytope_distance_d Optimal Distances @@ -75,15 +80,16 @@ Set_movable_separability_2 2D Movable Separability of Sets Shape_detection Shape Detection Shape_regularization Shape Regularization Skin_surface_3 3D Skin Surface Meshing +SMDS_3 3D Simplicial Mesh Data Structure Snap_rounding_2 2D Snap Rounding Spatial_searching dD Spatial Searching Straight_skeleton_2 2D Straight Skeleton and Polygon Offsetting Straight_skeleton_extrusion_2 2D Straight Skeleton Extrusion Stream_lines_2 2D Placement of Streamlines +Surface_mesh_approximation Triangulated Surface Mesh Approximation Surface_mesh_deformation Triangulated Surface Mesh Deformation Surface_mesher 3D Surface Mesh Generation Surface_mesh Surface Mesh -Surface_mesh_approximation Triangulated Surface Mesh Approximation Surface_mesh_parameterization Triangulated Surface Mesh Parameterization Surface_mesh_segmentation Triangulated Surface Mesh Segmentation Surface_mesh_shortest_path Triangulated Surface Mesh Shortest Paths @@ -93,12 +99,11 @@ Surface_mesh_topology Surface Mesh Topology Surface_sweep_2 2D Intersection of Curves TDS_2 2D Triangulation Data Structure TDS_3 3D Triangulation Data Structure +Tetrahedral_remeshing Tetrahedral Remeshing Three Three -SMDS_3 3D Simplicial Mesh Data Structure Triangulation_2 2D Triangulation -Triangulation_on_sphere_2 2D Triangulation on Sphere Triangulation_3 3D Triangulations Triangulation dD Triangulations +Triangulation_on_sphere_2 2D Triangulation on Sphere Visibility_2 2D Visibility Computation Voronoi_diagram_2 2D Voronoi Diagram Adaptor -Tetrahedral_remeshing Tetrahedral Remeshing diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Triangle_3_Triangle_3_intersection.h b/Intersections_3/include/CGAL/Intersections_3/internal/Triangle_3_Triangle_3_intersection.h index 269c86c3e60..471904cd97a 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Triangle_3_Triangle_3_intersection.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Triangle_3_Triangle_3_intersection.h @@ -39,11 +39,15 @@ struct Point_on_triangle { // triangle points are not stored in this class but are expected // to always be passed in the same order. For a triangle pqr, - // edge 0 is pq, edge 1 qr and edge 2 rp. Point 0 is p, 1 is q and 2 is r. + // edge 1 is pq, edge 2 qr and edge 3 rp. Point -1 is p, -2 is q and -3 is r. + // + // (0,-) vertex of t2 inside t1 + // (-,-) common point of t1 and t2 + // (-,0) vertex of t1 inside t2 + // (-,+) vertex of t1 on an edge of t2 + // (+,+) edge of t1 intersecting edge of t2 + // (+,-) vertex of t2 on an edge of t1 // - // (id, -1) point on t1 - // (-1, id) point on t2 - // (id1, id2) intersection of edges std::pair t1_t2_ids; boost::container::flat_set extra_t1; // store other ids of edges containing the point typename Kernel::FT alpha; // @@ -60,16 +64,16 @@ struct Point_on_triangle { switch(id) { - case 0: + case -1: return p; - case 1: + case -2: return q; default: return r; } } - Point_on_triangle(int i1, int i2=-1, typename Kernel::FT alpha = 0.) // TODO add global zero()? + Point_on_triangle(int i1, int i2, typename Kernel::FT alpha = 0.) // TODO add global zero()? : t1_t2_ids(i1,i2) , alpha(alpha) {} @@ -85,20 +89,20 @@ struct Point_on_triangle const typename Kernel::Point_3& r2, const Kernel& k) const { - if (t1_t2_ids.first!=-1) + if (t1_t2_ids.first!=0 && t1_t2_ids.second >=0) { - if (t1_t2_ids.second==-1) + if (t1_t2_ids.first<0) return (edge_id1==t1_t2_ids.first || (edge_id1+1)%3==t1_t2_ids.first) ? ZERO:POSITIVE; // it is a point on t1 // this is an intersection point if (t1_t2_ids.first==edge_id1) return ZERO; - if (t1_t2_ids.first==(edge_id1+1)%3) + if (t1_t2_ids.first-1==(edge_id1)%3) { if (alpha==0) return ZERO; return alpha>=0 ? POSITIVE:NEGATIVE; } - CGAL_assertion((t1_t2_ids.first+1)%3==edge_id1); + CGAL_assertion((t1_t2_ids.first)%3==edge_id1-1); if (alpha==1) return ZERO; return alpha<=1?POSITIVE:NEGATIVE; } @@ -111,9 +115,13 @@ struct Point_on_triangle } } + int id1() const { return t1_t2_ids.first; } int id2() const { return t1_t2_ids.second; } + void set_id1(int i) { t1_t2_ids.first=i; } + void set_id2(int i) { t1_t2_ids.second=i; } + // construct the intersection point from the info stored typename Kernel::Point_3 point(const typename Kernel::Point_3& p1, @@ -124,12 +132,13 @@ struct Point_on_triangle const typename Kernel::Point_3& r2, const Kernel& k) const { - if (t1_t2_ids.first==-1) + if (t1_t2_ids.second<0) return point_from_id(p2,q2,r2,t1_t2_ids.second); - if (t1_t2_ids.second==-1) + if (t1_t2_ids.first<0) return point_from_id(p1,q1,r1,t1_t2_ids.first); - return k.construct_barycenter_3_object()(point_from_id(p1,q1,r1,(t1_t2_ids.first+1)%3), alpha, point_from_id(p1,q1,r1,t1_t2_ids.first)) ; + return k.construct_barycenter_3_object()(point_from_id(p1,q1,r1,-(t1_t2_ids.first)%3-1), alpha, + point_from_id(p1,q1,r1,-t1_t2_ids.first)) ; } }; @@ -155,158 +164,55 @@ intersection(const Point_on_triangle& p, #ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION std::cout << " calling intersection: "; std::cout << " (" << p.id1() << "," << p.id2() << ",[" << p.alpha << "]) -"; - std::cout << " (" << q.id1() << "," << q.id2() << ",[" << q.alpha << "]) || e" << edge_id_t1; + std::cout << " (" << q.id1() << "," << q.id2() << ",[" << q.alpha << "]) || e" << edge_id_t1 << "\n"; #endif typename Kernel::Compute_alpha_for_coplanar_triangle_intersection_3 compute_alpha = k.compute_alpha_for_coplanar_triangle_intersection_3_object(); typedef Point_on_triangle Pot; - switch(p.id1()) + + auto common_edge_id = [](int pid, int qid) { - case -1: + if (pid==0 || qid==0) return 0; + if (pid<0) { - switch(q.id1()) + if (qid<0) { - case -1: // A: (-1, ip2) - (-1, iq2) - { - CGAL_assertion((p.id2()+1)%3 == q.id2() || (q.id2()+1)%3 == p.id2()); -// CGAL_assertion(p.extra_t1.empty() && q.extra_t1.empty()); // TMP to see if it's worth implementing special case -#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " -- case 1\n"; -#endif - typename Kernel::FT alpha = compute_alpha(p1, q1, - Pot::point_from_id(p2, q2, r2, p.id2()), - Pot::point_from_id(p2, q2, r2, q.id2())); - int id2 = (p.id2()+1)%3 == q.id2() ? p.id2() : q.id2(); - return Point_on_triangle(edge_id_t1, id2, alpha); // intersection with an original edge of t2 - } - default: - if (q.id2()!=-1) // B: (-1, ip2) - (iq1, iq2) - { - if (p.id2() == q.id2() || p.id2() == (q.id2()+1)%3) - { -#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " -- case 2\n"; -#endif - // points are on the same edge of t2 --> we shorten an already cut edge - typename Kernel::FT alpha = compute_alpha(p1, q1, - Pot::point_from_id(p2, q2, r2, q.id2()), - Pot::point_from_id(p2, q2, r2, (q.id2()+1)%3)); - - return Point_on_triangle(edge_id_t1, q.id2(), alpha); - } -#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " -- case 3\n"; -#endif - // point of t1: look for an edge of t1 containing both points - CGAL_assertion( p.extra_t1.count(q.id1())!=0 || p.extra_t1.count(3-q.id1()-edge_id_t1)!=0 ); - int eid1 = p.extra_t1.count(q.id1())!=0 ? q.id1() : 3-q.id1()-edge_id_t1; - return Point_on_triangle((eid1+1)%3==edge_id_t1?edge_id_t1:(edge_id_t1+1)%3, -1); // vertex of t1 - } - // C: (-1, ip2) - (iq1, -1) - //vertex of t1, special case t1 edge passed thru a vertex of t2 - CGAL_assertion(edge_id_t1 == 2); -#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " -- case 4\n"; -#endif - CGAL_assertion(q.id1()==1); - CGAL_assertion(!p.extra_t1.empty()); - return Point_on_triangle(p.extra_t1.count(0)==1?0:2,-1); + return (-pid)%3==-qid-1 ? -pid:-qid; + } + else + { + return (-pid==qid || (qid)%3==-pid-1) ? qid : 0; } } - default: + else { - switch(p.id2()) + if (qid<0) { - case -1: - { - switch(q.id1()) - { - case -1: // G: (ip1, -1) - (-1, iq2) - //vertex of t1, special case t1 edge passed thru a vertex of t2 -#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " -- case 5\n"; -#endif - CGAL_assertion(edge_id_t1 == 2); - CGAL_assertion(p.id1()==1); - CGAL_assertion(!q.extra_t1.empty()); - return Point_on_triangle(q.extra_t1.count(0)==1?0:2,-1); - default: - { -#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " -- case 6\n"; -#endif - CGAL_assertion(q.id2()!=-1); // I: (ip1, -1) - (iq2, -1) - //H: (ip1,-1), (iq1, iq2) - CGAL_assertion(edge_id_t1==2); - // p and q are on the same edge of t1 - CGAL_assertion(p.id1()==q.id1() || p.id1()==(q.id1()+1)%3); - return Point_on_triangle((q.id1()+1)%3==edge_id_t1?edge_id_t1:(edge_id_t1+1)%3 , -1); - } - } - } - default: - { - switch(q.id1()) - { - case -1: // D: (ip1, ip2) - (-1, iq2) - { - if (q.id2() == p.id2() || q.id2() == (p.id2()+1)%3) - { -#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " -- case 7\n"; -#endif - // points are on the same edge of t2 --> we shorten an already cut edge - typename Kernel::FT alpha = compute_alpha(p1, q1, - Pot::point_from_id(p2, q2, r2, p.id2()), - Pot::point_from_id(p2, q2, r2, (p.id2()+1)%3)); - - return Point_on_triangle(edge_id_t1, p.id2(), alpha); - } -#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " -- case 8\n"; -#endif - // point of t1 - //std::cout << "q.extra_t1: "; for(int qet1 : q.extra_t1) std::cout << " " << qet1; std::cout << "\n"; - CGAL_assertion( q.extra_t1.count(p.id1())!=0 || q.extra_t1.count(3-p.id1()-edge_id_t1)!=0 ); - int eid1 = q.extra_t1.count(p.id1())!=0 ? p.id1() : 3-p.id1()-edge_id_t1; - return Point_on_triangle((eid1+1)%3==edge_id_t1?edge_id_t1:(edge_id_t1+1)%3, -1); // vertex of t1 - } - default: - { - switch(q.id2()) - { - case -1: // F: (ip1, ip2) - (iq1, -1) - { - // p and q are on the same edge of t1 - CGAL_assertion(q.id1()==p.id1() || q.id1()==(p.id1()+1)%3); -#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " -- case 9\n"; -#endif - return Point_on_triangle((p.id1()+1)%3==edge_id_t1?edge_id_t1:(edge_id_t1+1)%3 , -1); - } - default: // E: (ip1, ip2) - (iq1, iq2) - { - if (p.id2()==q.id2()) - { -#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " -- case 10\n"; -#endif - typename Kernel::FT alpha = compute_alpha(p1, q1, - Pot::point_from_id(p2, q2, r2, q.id2()), - Pot::point_from_id(p2, q2, r2, (q.id2()+1)%3)); - return Point_on_triangle(edge_id_t1, q.id2(), alpha); - } - // we are intersecting an edge of t1 - CGAL_assertion(p.id1()==q.id1() || edge_id_t1==2); - int eid1 = p.id1()==q.id1() ? p.id1() : 1; - return Point_on_triangle((eid1+1)%3==edge_id_t1?edge_id_t1:(edge_id_t1+1)%3, -1); // vertex of t1 - } - } - } - } - } + return (-qid==pid || (pid)%3==-qid-1) ? pid : 0; + } + else + { + return pid==qid ? pid : 0; } } + }; + + int common_eid1 = common_edge_id(p.id1(), q.id1()); + int common_eid2 = common_edge_id(p.id2(), q.id2()); + + if (common_eid1!=0) + { + CGAL_assertion( (common_eid1)%3==edge_id_t1-1 || (edge_id_t1)%3==common_eid1-1 ); + int pid1 = (common_eid1)%3==edge_id_t1-1? -edge_id_t1:-common_eid1; + return Point_on_triangle(pid1, common_eid2); + } + else + { + CGAL_assertion(common_eid2!=0); + typename Kernel::FT alpha = compute_alpha(p1, q1, + Pot::point_from_id(p2, q2, r2, -common_eid2), + Pot::point_from_id(p2, q2, r2, -(common_eid2)%3-1)); + return Point_on_triangle(edge_id_t1, common_eid2, alpha); } } @@ -336,8 +242,17 @@ void intersection_coplanar_triangles_cutoff(const typename Kernel::Point_3& p1, for (Point_on_triangle& pot : inter_pts) { orientations[ &pot ]=pot.orientation(p1,q1,r1,edge_id,p2,q2,r2,k); - if (pot.id1()==-1 && orientations[ &pot ]==COLLINEAR) - pot.extra_t1.insert(edge_id); + if (orientations[ &pot ]==COLLINEAR) + { + if (pot.id1()==0) + pot.set_id1(edge_id); + else + { + CGAL_assertion(pot.id1()>0); + CGAL_assertion((edge_id)%3==pot.id1()-1 || (pot.id1())%3==edge_id-1); + pot.set_id1( (edge_id)%3==pot.id1()-1 ? -pot.id1(): -edge_id ); + } + } } #ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION @@ -411,32 +326,29 @@ intersection_coplanar_triangles(const typename K::Triangle_3& t1, r2 = t2.vertex(2); std::list> inter_pts; - inter_pts.push_back(Point_on_triangle(-1,0)); - inter_pts.push_back(Point_on_triangle(-1,1)); - inter_pts.push_back(Point_on_triangle(-1,2)); + inter_pts.push_back(Point_on_triangle(0,-1)); + inter_pts.push_back(Point_on_triangle(0,-2)); + inter_pts.push_back(Point_on_triangle(0,-3)); #ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION auto print_points = [&]() { - for(auto p : inter_pts) std::cout << " (" << p.id1() << "," << p.id2() << ",[" << p.alpha << "]) "; std::cout <<"\n"; + std::cout << " ipts size: " << inter_pts.size() << "\n"; + for(auto p : inter_pts) {std::cout << " (" << p.id1() << "," << p.id2() << ",[" << p.alpha << "]) ";} std::cout <<"\n"; }; - std::cout << " ipts size: " << inter_pts.size() << "\n"; print_points(); #endif //intersect t2 with the three half planes which intersection defines t1 - intersection_coplanar_triangles_cutoff(p1,q1,r1,0,p2,q2,r2,k,inter_pts); //line pq + intersection_coplanar_triangles_cutoff(p1,q1,r1,1,p2,q2,r2,k,inter_pts); //line pq #ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " ipts size: " << inter_pts.size() << "\n"; print_points(); #endif - intersection_coplanar_triangles_cutoff(q1,r1,p1,1,p2,q2,r2,k,inter_pts); //line qr + intersection_coplanar_triangles_cutoff(q1,r1,p1,2,p2,q2,r2,k,inter_pts); //line qr #ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " ipts size: " << inter_pts.size() << "\n"; print_points(); #endif - intersection_coplanar_triangles_cutoff(r1,p1,q1,2,p2,q2,r2,k,inter_pts); //line rp + intersection_coplanar_triangles_cutoff(r1,p1,q1,3,p2,q2,r2,k,inter_pts); //line rp #ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION - std::cout << " ipts size: " << inter_pts.size() << "\n"; print_points(); #endif diff --git a/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h b/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h index 243ca48a93e..42e84e43646 100644 --- a/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h +++ b/Kernel_23/doc/Kernel_23/CGAL/Kernel/global_functions.h @@ -367,7 +367,7 @@ const CGAL::Line_2 &l2); /*! constructs the bisector plane of the two points `p` and `q`. The bisector is oriented in such a way that `p` lies on its -positive side. \pre `p != q'. +positive side. \pre `p != q`. */ template CGAL::Plane_3 bisector(const CGAL::Point_3 &p, @@ -2691,6 +2691,42 @@ const CGAL::Point_3& r); /// \defgroup squared_distance_grp CGAL::squared_distance() /// \ingroup kernel_global_function +/// \defgroup squared_length_grp CGAL::squared_length() +/// \ingroup kernel_global_function + +/// @{ + +/*! +compute the squared length of vector `v`. +*/ +template +FT +squared_length(const CGAL::Vector_2& v); + +/*! +compute the squared length of segment `s`. +*/ +template +FT +squared_length(const CGAL::Segment_2& s); + +/*! +compute the squared length of vector `v`. +*/ +template +FT +squared_length(const CGAL::Vector_3& v); + +/*! +compute the squared length of segment `s`. +*/ +template +FT +squared_length(const CGAL::Segment_3& s); + +/// @} + + /// \defgroup squared_radius_grp CGAL::squared_radius() /// \ingroup kernel_global_function /// \sa `Circle_2_grp` diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_2.h b/Kernel_23/include/CGAL/Kernel/global_functions_2.h index e974eae730d..ad67bff1041 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions_2.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions_2.h @@ -1114,6 +1114,22 @@ side_of_oriented_circle(const Point_2 &p, return internal::side_of_oriented_circle(p, q, r, t, K()); } +template < class K > +inline +typename K::FT +squared_length(const Vector_2 &v) +{ + return internal::squared_length(v, K()); +} + +template < class K > +inline +typename K::FT +squared_length(const Segment_2 &s) +{ + return internal::squared_length(s, K()); +} + template < class K > inline typename K::FT diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_3.h b/Kernel_23/include/CGAL/Kernel/global_functions_3.h index e17211e184b..aa16e5d7cb8 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions_3.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions_3.h @@ -1276,6 +1276,22 @@ squared_area(const Point_3 &p, const Point_3 &q, const Point_3 &r) return internal::squared_area(p, q, r, K()); } +template < class K > +inline +typename K::FT +squared_length(const Vector_3 &v) +{ + return internal::squared_length(v, K()); +} + +template < class K > +inline +typename K::FT +squared_length(const Segment_3 &s) +{ + return internal::squared_length(s, K()); +} + template < class K > inline typename K::FT diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_internal_2.h b/Kernel_23/include/CGAL/Kernel/global_functions_internal_2.h index 7212eb7ed60..a7407a9fd74 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions_internal_2.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions_internal_2.h @@ -988,6 +988,23 @@ side_of_oriented_circle(const typename K::Point_2 &p, return k.side_of_oriented_circle_2_object()(p, q, r, t); } + +template +inline +typename K::FT +squared_length(const typename K::Vector_2 &v, const K &k) +{ + return k.compute_squared_length_2_object()(v); +} + +template +inline +typename K::FT +squared_length(const typename K::Segment_2 &s, const K &k) +{ + return k.compute_squared_length_2_object()(s); +} + template < class K > inline typename K::FT diff --git a/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h b/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h index e48ec201f38..8ae26a9c787 100644 --- a/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h +++ b/Kernel_23/include/CGAL/Kernel/global_functions_internal_3.h @@ -1112,6 +1112,22 @@ squared_area(const typename K::Point_3 &p, return k.compute_squared_area_3_object()(p, q, r); } +template +inline +typename K::FT +squared_length(const typename K::Vector_3 &v, const K &k) +{ + return k.compute_squared_length_3_object()(v); +} + +template +inline +typename K::FT +squared_length(const typename K::Segment_3 &s, const K &k) +{ + return k.compute_squared_length_3_object()(s); +} + template < class K > inline typename K::FT diff --git a/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h b/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h index dd4e24005a4..1cc09421944 100644 --- a/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h +++ b/Kernel_23/include/CGAL/Kernel_23/internal/Projection_traits_3.h @@ -20,6 +20,7 @@ #include #include +#include namespace CGAL { @@ -1210,6 +1211,14 @@ public: }; -} } //namespace CGAL::internal + +} // namespace internal + +template +struct Triangulation_structural_filtering_traits<::CGAL::internal::Projection_traits_3 > { + typedef typename Triangulation_structural_filtering_traits::Use_structural_filtering_tag Use_structural_filtering_tag; +}; + + } //namespace CGAL #endif // CGAL_INTERNAL_PROJECTION_TRAITS_3_H diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_3.h index 02a5e6cf20c..40b992a857e 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_3.h @@ -31,6 +31,7 @@ #include "_test_cls_plane_3.h" #include "_test_cls_line_3.h" #include "_test_cls_segment_3.h" +#include "_test_fct_segment_3.h" #include "_test_cls_sphere_3.h" #include "_test_cls_ray_3.h" #include "_test_cls_triangle_3.h" @@ -51,6 +52,7 @@ _test_3(const R& r) && _test_fct_point_3(r) && _test_fct_weighted_point_3(r) && _test_fct_plane_3(r) + && _test_fct_segment_3(r) && _test_further_fct_point_plane_3(r) && _test_cls_direction_3(r) && _test_cls_plane_3( r ) diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_segment_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_segment_2.h index d97d8c0b111..9ed30767567 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_segment_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_segment_2.h @@ -111,6 +111,9 @@ _test_fct_segment_2(const R& ) assert( CGAL::compare_slope(l6, l9) == CGAL::LARGER ); assert( CGAL::compare_slope(l9, l7) == CGAL::SMALLER ); + std::cout <<'.'; + assert( CGAL::squared_distance(l9.source(), l9.target()) == CGAL::squared_length(l9) ); + std::cout << "done" << std::endl; return true; } diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_segment_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_segment_3.h new file mode 100644 index 00000000000..ad0d419ae46 --- /dev/null +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_segment_3.h @@ -0,0 +1,43 @@ +// Copyright (c) 1999 +// Utrecht University (The Netherlands), +// ETH Zurich (Switzerland), +// INRIA Sophia-Antipolis (France), +// Max-Planck-Institute Saarbruecken (Germany), +// and Tel-Aviv University (Israel). All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later +// +// +// Author(s) : Susan Hert + + +#ifndef CGAL__TEST_FCT_SEGMENT_3_H +#define CGAL__TEST_FCT_SEGMENT_3_H + +template +bool +_test_fct_segment_3(const R& ) +{ + std::cout << "Testing functions Segment_3" ; + + typedef typename R::RT RT; + + typedef typename R::Point_3 Point_3; + typedef typename R::Segment_3 Segment_3; + + Point_3 p1 ( RT(0), RT(0), RT(0), RT(1) ); + Point_3 p2 ( RT(1), RT(1), RT(1), RT(1) ); + + + Segment_3 l1(p1, p2); + assert( CGAL::squared_distance(l1.source(), l1.target()) == CGAL::squared_length(l1) ); + + std::cout << "done" << std::endl; + return true; +} + +#endif // CGAL__TEST_FCT_SEGMENT_3_H diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_vector_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_vector_2.h index 7731765f24e..3140f54902e 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_vector_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_vector_2.h @@ -87,6 +87,7 @@ _test_fct_vector_2(const R& ) assert( CGAL::scalar_product(v1, v2) == FT(30) ); assert( v1 * v0 == FT(0) ); assert( v1.squared_length() == FT(40) ); + assert( v1.squared_length() == CGAL::squared_length(v1) ); assert( CGAL::Vector_2( n1, n2) == v1 * RT(2)); assert( CGAL::Vector_2( n5, n6) == v2 * RT(3)); assert( CGAL::Vector_2( n1, n2) == RT(2) * v1); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_vector_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_vector_3.h index 70e273d1e68..d1c090353ef 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_vector_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_fct_vector_3.h @@ -101,6 +101,7 @@ _test_fct_vector_3(const R& ) std::cout << '.'; + assert( v1.squared_length() == CGAL::squared_length(v1) ); assert( v1.squared_length() == FT(49) ); assert( v1 * v2 == FT(66) ); assert( v1 * v0 == FT(0) ); diff --git a/Kernel_23/test/Kernel_23/test_Has_conversion.cpp b/Kernel_23/test/Kernel_23/test_Has_conversion.cpp index c6f393a502d..2ef8186000a 100644 --- a/Kernel_23/test/Kernel_23/test_Has_conversion.cpp +++ b/Kernel_23/test/Kernel_23/test_Has_conversion.cpp @@ -14,7 +14,9 @@ #include #include +#if defined(CGAL_USE_CORE) || defined(CGAL_USE_LEDA) #include +#endif #include #include @@ -36,13 +38,16 @@ int main() typedef CGAL::Simple_homogeneous SH; typedef CGAL::Filtered_kernel FSH; +#if defined(CGAL_USE_CORE) || defined(CGAL_USE_LEDA) typedef CGAL::Exact_predicates_exact_constructions_kernel_with_kth_root EPECK; + CGAL_USE_TYPE(EPECK); +#endif CGAL_USE_TYPE(ASC); CGAL_USE_TYPE(FSC); CGAL_USE_TYPE(SH); CGAL_USE_TYPE(FSH); - CGAL_USE_TYPE(EPECK); + assert((CGAL::Has_conversion::value)); assert((CGAL::Has_conversion::value)); @@ -55,10 +60,12 @@ int main() assert((CGAL::Has_conversion::value)); assert((CGAL::Has_conversion::value)); +#if defined(CGAL_USE_CORE) || defined(CGAL_USE_LEDA) assert((CGAL::Has_conversion::value)); assert((CGAL::Has_conversion::value)); assert(!(CGAL::Has_conversion::value)); +#endif assert(!(CGAL::Has_conversion::value)); // below will produce static assert failures diff --git a/Kernel_23/test/Kernel_23/test_approximate_dihedral_angle_3.cpp b/Kernel_23/test/Kernel_23/test_approximate_dihedral_angle_3.cpp index dc3ccdaf989..791ce36ac8c 100644 --- a/Kernel_23/test/Kernel_23/test_approximate_dihedral_angle_3.cpp +++ b/Kernel_23/test/Kernel_23/test_approximate_dihedral_angle_3.cpp @@ -53,8 +53,6 @@ int main() { Point_3 a = {0, 0, 0}; Point_3 b = {0, -1, 0}; // ab is oriented so that it sees the plan xz positively. - [[maybe_unused]] Point_3 c = {1, 0, 0}; - // c can be any point in the half-plane xy, with x>0 const query queries[] = { { { 1, 0, 0}, 0.}, @@ -69,6 +67,7 @@ int main() { auto cnt = 0u; for(double yc = -10; yc < 10; yc += 0.1) { + // c can be any point in the half-plane xy, with x>0 Point_3 c{1, yc, 0}; // std::cout << "c = " << c << '\n'; for(const auto& query : queries) { diff --git a/Kernel_d/include/CGAL/Kernel_d/Linear_algebraHd_impl.h b/Kernel_d/include/CGAL/Kernel_d/Linear_algebraHd_impl.h index df22d36cf9a..286211363bb 100644 --- a/Kernel_d/include/CGAL/Kernel_d/Linear_algebraHd_impl.h +++ b/Kernel_d/include/CGAL/Kernel_d/Linear_algebraHd_impl.h @@ -95,13 +95,13 @@ linear_solver(const Matrix& A, const Vector& b, for(i = k + 1; i < rows; i++) for (j = 0; j < rows; j++) //and all columns of |L| - L(i,j) = (L(i,j)*C(k,k) - C(i,k)*L(k,j))/denom; + L(i,j) = integral_division((L(i,j)*C(k,k) - C(i,k)*L(k,j)), denom); for(i = k + 1; i < rows; i++) { /* the following iteration uses and changes |C(i,k)| */ RT temp = C(i,k); for (j = k; j <= cols; j++) - C(i,j) = (C(i,j)*C(k,k) - temp*C(k,j))/denom; + C(i,j) = integral_division((C(i,j)*C(k,k) - temp*C(k,j)), denom); } denom = C(k,k); #ifdef CGAL_LA_SELFTEST @@ -140,7 +140,7 @@ linear_solver(const Matrix& A, const Vector& b, for (j = i + 1; j < rank; j++) { h -= C(i,j)*x[var[j]]; } - x[var[i]]= h / C(i,i); + x[var[i]]= integral_division(h, C(i,i)); } #ifdef CGAL_LA_SELFTEST CGAL_assertion( (M*x).is_zero() ); @@ -156,7 +156,7 @@ linear_solver(const Matrix& A, const Vector& b, RT_ h = - C(i,rank + l)*D; for ( j= i + 1; j #include -#if defined( CGAL_USE_LEDA) || defined ( CGAL_USE_GMP ) - typedef CGAL::Exact_integer RT; typedef CGAL::Exact_rational FT; -#else - -// The following are too slow : -// #include -// #include -// typedef CGAL::MP_Float RT; -// typedef CGAL::Quotient FT; -typedef double RT; -typedef double FT; - -#endif - int main(int argc, char* argv[]) { CGAL_KD_SETDTHREAD(151); @@ -72,8 +58,6 @@ int main(int argc, char* argv[]) Vector v21(v13),v22(v13); v21 *= 13; CGAL_TEST(v21 == NT(13)*v22){} - v21 /= 13; - CGAL_TEST(v21 == v22){} if (IOTEST) CGAL_IO_TEST(v1,v2,CGAL::IO::ASCII); } diff --git a/Kernel_d/test/Kernel_d/interface-test.cpp b/Kernel_d/test/Kernel_d/interface-test.cpp index 1429ac6ac76..c6ab8053689 100644 --- a/Kernel_d/test/Kernel_d/interface-test.cpp +++ b/Kernel_d/test/Kernel_d/interface-test.cpp @@ -5,22 +5,12 @@ #include #include -#ifdef CGAL_USE_LEDA -#include -#include -typedef leda_integer RT_; -typedef leda_rational FT_; -#else -#ifdef CGAL_USE_GMP -#include -#include -typedef CGAL::Gmpz RT_; -typedef CGAL::Quotient FT_; -#else -typedef double RT_; -typedef double FT_; -#endif -#endif +#include +#include + +typedef CGAL::Exact_integer RT_; +typedef CGAL::Exact_rational FT_; + int main() { CGAL_KD_SETDTHREAD(2); diff --git a/Kernel_d/test/Kernel_d/intersection-test.cpp b/Kernel_d/test/Kernel_d/intersection-test.cpp index 3f22d193653..1808c3daf95 100644 --- a/Kernel_d/test/Kernel_d/intersection-test.cpp +++ b/Kernel_d/test/Kernel_d/intersection-test.cpp @@ -5,28 +5,11 @@ #include #include -#ifdef CGAL_USE_LEDA +#include +#include -#include -#include -typedef leda_integer RT; -typedef leda_real FT; - -#elif defined CGAL_USE_GMP - -#include -#include -typedef CGAL::Gmpz RT; -typedef CGAL::Gmpq FT; - -#else - -#include -#include -typedef CGAL::MP_Float RT; -typedef CGAL::Quotient FT; - -#endif +typedef CGAL::Exact_integer RT; +typedef CGAL::Exact_rational FT; int main() { CGAL::IO::set_pretty_mode ( std::cerr ); @@ -383,4 +366,3 @@ int main() } CGAL_TEST_END; } - diff --git a/Maintenance/test_handling/create_testresult_page b/Maintenance/test_handling/create_testresult_page index edde28fff96..8d9a867592d 100755 --- a/Maintenance/test_handling/create_testresult_page +++ b/Maintenance/test_handling/create_testresult_page @@ -635,6 +635,8 @@ The doxygen documentation testpage (and the overview page)
        • Diff of testsuites results
        • +
        • +Summary Page
        • EOF } @@ -674,6 +676,7 @@ sub main() print_little_header(); print_platform_descriptions(); print_resultpage(); + create_summary_page(); print OUTPUT << 'EOF';

          This page has been created by the test results @@ -719,4 +722,129 @@ sub init_known_platforms() close(PLATFORMS); } +sub get_warnings_and_errors { + my ($result_file) = @_; + my $warnings_and_errors = ""; + my %seen; + if (-e $result_file) { + my $result = `zcat $result_file`; + my @lines = split("\n", $result); + foreach my $line (@lines) { + if ($line =~ /(warning|error):/i && !$seen{$line}++) { + #if ($line !~ /\b(ERROR|WARNING)\b/ && $line =~ /(warning|error):/i) { + + $warnings_and_errors .= $line . "\n"; + } + } + } else { + print "File $result_file does not exist.\n"; + } + + return $warnings_and_errors; +} + +sub create_summary_page { + my $platform_options = join("\n", map { "" } @platforms_to_do); + my $test_directory; + my @letters = ('r', 'n', 'w', 'o'); + my $letters_options = join("\n", map { "" } @letters); + my $Summary_output = <<"EOF"; + + + + + Summary + + + + + + +

          Summary Results of ${release_name}

          + + +EOF + + my $summary_page_path = "$testresult_dir/summary".substr($release_name,4).".html"; + open(my $out, '>', $summary_page_path) or die "Could not open file '$summary_page_path' $!"; + print $out $Summary_output; + + my ($platform_num, $platform) = (0, ""); + foreach $platform (@platforms_to_do) { + print $out "

          Results of $platform

          "; + foreach my $letter (@letters) { + print $out "

          $letter

          "; + foreach my $test_directory (sort keys %test_directories) { + my $resulttext = $testresults[$platform_num]->{$test_directory}; + if (defined($resulttext) && $resulttext eq $letter) { + print $out '
          '; + my $warnings_and_errors = get_warnings_and_errors("$testresult_dir/$release_name/$test_directory/TestReport_$platform.gz"); + if ($warnings_and_errors) { + print $out "
          $warnings_and_errors
          "; + } + } + } + print $out "
          "; + } + print $out "
          "; + $platform_num++; + } + + print $out "\n\n"; + close $out; +} + main(); diff --git a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h index bc9be8b3e5f..4016fda8b29 100644 --- a/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h +++ b/Mesh_3/include/CGAL/Mesh_3/Protect_edges_sizing_field.h @@ -276,6 +276,11 @@ private: const Curve_index& curve_index, const CGAL::Orientation orientation) const; + FT curve_segment_length(const Vertex_handle v1, + const Vertex_handle v2, + const Curve_index& curve, + const CGAL::Orientation orientation) const; + /// Take an iterator on Vertex_handle as input and check if the sampling /// of those vertices is ok. If not, fix it. void check_and_repopulate_edges(); @@ -1082,13 +1087,7 @@ insert_balls(const Vertex_handle& vp, const CGAL::Orientation orientation, ErasedVeOutIt out) { - typename C3T3::Triangulation::Geom_traits::Construct_point_3 cp = - c3t3_.triangulation().geom_traits().construct_point_3_object(); - // Get size of p & q - const Weighted_point& vp_wp = c3t3_.triangulation().point(vp); - const Weighted_point& vq_wp = c3t3_.triangulation().point(vq); - const FT sp = get_radius(vp); const FT sq = get_radius(vq); @@ -1098,7 +1097,7 @@ insert_balls(const Vertex_handle& vp, const FT pq_length = (vp == vq) ? domain_.curve_length(curve_index) : - domain_.curve_segment_length(cp(vp_wp), cp(vq_wp), curve_index, orientation); + curve_segment_length(vp, vq, curve_index, orientation); // Insert balls return @@ -1202,9 +1201,8 @@ insert_balls(const Vertex_handle& vp, << n << "\n between points (" << vp_wp << ") and (" << vq_wp << ") (arc length: " - << domain_.curve_segment_length(cp(vp_wp), - cp(vq_wp), - curve_index, d_sign) + << curve_segment_length(vp_wp, vq_wp, + curve_index, d_sign) << ")\n"; #endif const Bare_point new_point = @@ -1691,6 +1689,8 @@ check_and_fix_vertex_along_edge(const Vertex_handle& v, ErasedVeOutIt out) // neighbor. const Curve_index& curve_index = adjacent_vertices.front().second; + if (use_minimal_size() && adjacent_vertices.back().second != curve_index) + return out; CGAL_assertion(adjacent_vertices.back().second== curve_index); // Walk along edge to find the edge piece which is not correctly sampled @@ -1743,6 +1743,37 @@ check_and_fix_vertex_along_edge(const Vertex_handle& v, ErasedVeOutIt out) return out; } +template +typename Protect_edges_sizing_field::FT +Protect_edges_sizing_field:: +curve_segment_length(const Vertex_handle v1, + const Vertex_handle v2, + const Curve_index& curve_index, + const CGAL::Orientation orientation) const +{ + auto cp = c3t3_.triangulation().geom_traits().construct_point_3_object(); + + bool v1_valid_curve_index = true; + bool v2_valid_curve_index = true; + if(use_minimal_size()) + { + if (get_dimension(v1) == 1) + v1_valid_curve_index = (domain_.curve_index(v1->index()) == curve_index); + if (get_dimension(v2) == 1) + v2_valid_curve_index = (domain_.curve_index(v2->index()) == curve_index); + } + + const Weighted_point& v1_wp = c3t3_.triangulation().point(v1); + const Weighted_point& v2_wp = c3t3_.triangulation().point(v2); + + FT arc_length = (v1_valid_curve_index && v2_valid_curve_index) + ? domain_.curve_segment_length(cp(v1_wp), + cp(v2_wp), + curve_index, + orientation) + : compute_distance(v1, v2); //curve polyline may not be consistent + return arc_length; +} template bool @@ -1759,38 +1790,15 @@ is_sampling_dense_enough(const Vertex_handle& v1, const Vertex_handle& v2, typename GT::Compute_weight_3 cw = c3t3_.triangulation().geom_traits().compute_weight_3_object(); + FT arc_length = curve_segment_length(v1, + v2, + curve_index, + orientation); + // Get sizes FT size_v1 = get_radius(v1); FT size_v2 = get_radius(v2); - bool v1_valid_curve_index = true; - bool v2_valid_curve_index = true; - - if(use_minimal_size()) - { - v1_valid_curve_index = (get_dimension(v1) != 1 - || curve_index == domain_.curve_index(v1->index())); - v2_valid_curve_index = (get_dimension(v2) != 1 - || curve_index == domain_.curve_index(v2->index())); - } - else - { - CGAL_assertion(get_dimension(v1) != 1 || - curve_index == domain_.curve_index(v1->index())); - CGAL_assertion(get_dimension(v2) != 1 || - curve_index == domain_.curve_index(v2->index())); - } - - const Weighted_point& v1_wp = c3t3_.triangulation().point(v1); - const Weighted_point& v2_wp = c3t3_.triangulation().point(v2); - - FT arc_length = (v1_valid_curve_index && v2_valid_curve_index) - ? domain_.curve_segment_length(cp(v1_wp), - cp(v2_wp), - curve_index, - orientation) - : compute_distance(v1, v2); //curve polyline may not be consistent - // Sufficient condition so that the curve portion between v1 and v2 is // inside the union of the two balls. if(arc_length > (size_v1 + size_v2)) { @@ -1809,6 +1817,9 @@ is_sampling_dense_enough(const Vertex_handle& v1, const Vertex_handle& v2, return false; } + const Weighted_point& v1_wp = c3t3_.triangulation().point(v1); + const Weighted_point& v2_wp = c3t3_.triangulation().point(v2); + const bool cov = domain_.is_curve_segment_covered(curve_index, orientation, cp(v1_wp), cp(v2_wp), @@ -1897,6 +1908,9 @@ walk_along_edge(const Vertex_handle& start, const Vertex_handle& next, // Get next vertex along edge Vertex_handle next = next_vertex_along_curve(current,previous,curve_index); + if (next == Vertex_handle()) + break; + previous = current; current = next; } @@ -1925,8 +1939,10 @@ next_vertex_along_curve(const Vertex_handle& start, adjacent_vertices.end(), [curve_index](const auto& p){ return p.second != curve_index; }), adjacent_vertices.end()); - CGAL_assertion(adjacent_vertices.size() == 2); + if (use_minimal_size() && adjacent_vertices.size() < 2) + return Vertex_handle(); + CGAL_assertion(adjacent_vertices.size() == 2); if ( adjacent_vertices.front().first == previous ) { return adjacent_vertices.back().first; @@ -2087,20 +2103,12 @@ is_sizing_field_correct(const Vertex_handle& v1, const Curve_index& curve_index, const CGAL::Orientation orientation) const { - typename C3T3::Triangulation::Geom_traits::Construct_point_3 cp = - c3t3_.triangulation().geom_traits().construct_point_3_object(); - FT s1 = get_radius(v1); FT s2 = get_radius(v2); FT s3 = get_radius(v3); - const Weighted_point& wp1 = c3t3_.triangulation().point(v1); - const Weighted_point& wp2 = c3t3_.triangulation().point(v2); - const Weighted_point& wp3 = c3t3_.triangulation().point(v3); - FT D = domain_.curve_segment_length(cp(wp1), cp(wp3), - curve_index, orientation); - FT d = domain_.curve_segment_length(cp(wp1), cp(wp2), - curve_index, orientation); + FT D = curve_segment_length(v1, v3, curve_index, orientation); + FT d = curve_segment_length(v1, v2, curve_index, orientation); return ( s2 >= (s1 + d/D*(s3-s1)) ); } diff --git a/Mesh_3/include/CGAL/perturb_mesh_3.h b/Mesh_3/include/CGAL/perturb_mesh_3.h index 3de2ff074a9..639364cc669 100644 --- a/Mesh_3/include/CGAL/perturb_mesh_3.h +++ b/Mesh_3/include/CGAL/perturb_mesh_3.h @@ -50,7 +50,7 @@ namespace CGAL { * \tparam MD a model of the concept `MeshDomain_3` * \tparam NamedParameters a sequence of \ref bgl_namedparameters "Named Parameters" * - * @param c3t3 the initial mesh and is modified by the algorithm to represent the final optimized mesh + * @param c3t3 the initial mesh, modified by the algorithm to represent the final optimized mesh * @param domain the domain used to create the `c3t3` parameter * @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below: * @@ -60,18 +60,18 @@ namespace CGAL { * is stopped. This time is measured using the `Real_timer` class. The default value is * 0 and means that there is no time limit.} * \cgalParamType{`double`} - * \cgalParamPrecondition{`0 <= sliver_bound <= 180`} + * \cgalParamPrecondition{`time_limit >= 0`} * \cgalParamDefault{0} * \cgalParamNEnd * \cgalParamNBegin{sliver_bound} * \cgalParamDescription{is designed to give, in degrees, a targeted lower bound on dihedral angles of mesh cells. - * The exudation process considers in turn all the mesh cells that have a smallest dihedral - * angle less than sliver_bound and tries to make them disappear by weighting their vertices. - * The optimization process stops when every cell in the mesh achieves this quality. The - * default value is 0 and means that there is no targeted bound: the exuder then runs as long - * as it can improve the smallest dihedral angles of the set of cells incident to some vertices.} + * The function `perturb_mesh_3()` runs as long as steps are successful and step number + * `sliver_bound` (after which the worst tetrahedron in the mesh has a smallest angle larger + * than `sliver_bound` degrees) has not been reached. + * The default value is 0 and means that there is no targeted bound: + * the perturber then runs as long as steps are successful.} * \cgalParamType{`double`} - * \cgalParamPrecondition{`time_limit >= 0`} + * \cgalParamPrecondition{`0 <= sliver_bound <= 180`} * \cgalParamDefault{0} * \cgalParamNEnd * \cgalNamedParamsEnd diff --git a/Minkowski_sum_2/include/CGAL/Polygon_vertical_decomposition_2.h b/Minkowski_sum_2/include/CGAL/Polygon_vertical_decomposition_2.h index 5db68c8abaa..28a13dd4dcd 100644 --- a/Minkowski_sum_2/include/CGAL/Polygon_vertical_decomposition_2.h +++ b/Minkowski_sum_2/include/CGAL/Polygon_vertical_decomposition_2.h @@ -77,12 +77,15 @@ private: // An arrangement observer, used to receive notifications of face splits and // face mergers. - class My_observer : public CGAL::Arr_observer { + class My_observer : public Arrangement_2::Observer { public: - My_observer(Arrangement_2& arr) : Arr_observer(arr) {} + using Base_aos = typename Arrangement_2::Base_aos; + using Face_handle = typename Base_aos::Face_handle; + + My_observer(Base_aos& arr) : Arrangement_2::Observer(arr) {} virtual void after_split_face(Face_handle f, Face_handle new_f, - bool /* is_hole */) + bool /* is_hole */) override { if (f->contained()) new_f->set_contained(true); } }; diff --git a/Nef_2/include/CGAL/Nef_2/Polynomial.h b/Nef_2/include/CGAL/Nef_2/Polynomial.h index a389fd9aae6..ef494741b98 100644 --- a/Nef_2/include/CGAL/Nef_2/Polynomial.h +++ b/Nef_2/include/CGAL/Nef_2/Polynomial.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Michael Seel @@ -14,6 +14,9 @@ #ifndef CGAL_NEF_2_POLYNOMIAL_H #define CGAL_NEF_2_POLYNOMIAL_H +#include + + #include #include #include diff --git a/Nef_2/include/CGAL/Nef_2/Polynomial_impl.h b/Nef_2/include/CGAL/Nef_2/Polynomial_impl.h index 66417e9b99a..0e39b126b4d 100644 --- a/Nef_2/include/CGAL/Nef_2/Polynomial_impl.h +++ b/Nef_2/include/CGAL/Nef_2/Polynomial_impl.h @@ -5,12 +5,17 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Michael Seel // Andreas Fabri +#ifndef CGAL_NEF_2_POLYNOMIAL_IMPL_H +#define CGAL_NEF_2_POLYNOMIAL_IMPL_H + +#include + namespace CGAL{ @@ -202,3 +207,5 @@ Polynomial Polynomial::gcd( } // end namespace Nef }//end namespace CGAL + +#endif //CGAL_NEF_2_POLYNOMIAL_IMPL_H diff --git a/Nef_2/include/CGAL/Nef_2/debug.h b/Nef_2/include/CGAL/Nef_2/debug.h index d4ccc190ddc..001eaeaa1ef 100644 --- a/Nef_2/include/CGAL/Nef_2/debug.h +++ b/Nef_2/include/CGAL/Nef_2/debug.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Michael Seel @@ -13,6 +13,9 @@ #ifndef CGAL_NEF_2_DEBUG_H #define CGAL_NEF_2_DEBUG_H +#include + + #include #ifdef NDEBUG diff --git a/Nef_2/include/CGAL/Nef_polynomial_fwd.h b/Nef_2/include/CGAL/Nef_polynomial_fwd.h index 6e9af8ea6f9..17cc9df36f9 100644 --- a/Nef_2/include/CGAL/Nef_polynomial_fwd.h +++ b/Nef_2/include/CGAL/Nef_polynomial_fwd.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Stefan Schirra, Sylvain Pion @@ -13,6 +13,9 @@ #ifndef CGAL_NEF_POLYNOMIAL_FWD_H #define CGAL_NEF_POLYNOMIAL_FWD_H +#include + + #include // Forward declarations of functions over Polynomial and Nef_polynomial diff --git a/Nef_S2/include/CGAL/Nef_S2/OGL_base_object.h b/Nef_S2/include/CGAL/Nef_S2/OGL_base_object.h index 7973729e89e..f813b7dc9f4 100644 --- a/Nef_S2/include/CGAL/Nef_S2/OGL_base_object.h +++ b/Nef_S2/include/CGAL/Nef_S2/OGL_base_object.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Peter Hachenberger @@ -13,6 +13,9 @@ #ifndef CGAL_OGL_BASE_OBJECT_H #define CGAL_OGL_BASE_OBJECT_H +#include + + #include namespace CGAL { diff --git a/Nef_S2/test/Nef_S2/Nef_polyhedron_S2-test.cpp b/Nef_S2/test/Nef_S2/Nef_polyhedron_S2-test.cpp index e429bab74f2..0a63acc5c5c 100644 --- a/Nef_S2/test/Nef_S2/Nef_polyhedron_S2-test.cpp +++ b/Nef_S2/test/Nef_S2/Nef_polyhedron_S2-test.cpp @@ -1,14 +1,9 @@ #include #include #include +#include -#ifdef CGAL_USE_LEDA -#include -typedef leda_integer NT; -#else -#include -typedef CGAL::Gmpz NT; -#endif +typedef CGAL::Exact_integer NT; typedef CGAL::Homogeneous Kernel; typedef CGAL::Nef_polyhedron_S2 Nef_polyhedron; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h index 122cfe90885..a89d2da9b1e 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h @@ -16,6 +16,8 @@ #include // bug, should be included by the next one #include #include +#include +#include namespace CGAL { namespace SFA { // static filter adapter @@ -80,7 +82,72 @@ template struct Side_of_oriented_sphere_2 : private Store return typename internal::Static_filters_predicates::Side_of_oriented_circle_2()(P(this->kernel(),c,A),P(this->kernel(),c,B),P(this->kernel(),c,C),P(this->kernel(),c,D)); } }; -} + +template struct Adapter_3 { + typedef typename Get_type::type Point; + typedef typename Get_functor::type CC; + typedef typename Get_functor::type Orientation_base; + typedef typename Get_functor::type Side_of_oriented_sphere_base; + struct Point_3 { + R_ const&r; CC const&c; Point const& p; + Point_3(R_ const&r_, CC const&c_, Point const&p_):r(r_),c(c_),p(p_){} + decltype(auto) x()const{return c(p,0);} + decltype(auto) y()const{return c(p,1);} + decltype(auto) z()const{return c(p,2);} + }; + struct Vector_3 {}; + struct Sphere_3 {}; + struct Tetrahedron_3 {}; + struct Orientation_3 { + typedef typename Get_type::type result_type; + auto operator()(Point_3 const&A, Point_3 const&B, Point_3 const&C, Point_3 const&D)const{ + Point const* t[]={&A.p,&B.p,&C.p,&D.p}; + return Orientation_base(A.r)(make_transforming_iterator(t+0),make_transforming_iterator(t+4)); + } + }; + struct Side_of_oriented_sphere_3 { + typedef typename Get_type::type result_type; + auto operator()(Point_3 const&A, Point_3 const&B, Point_3 const&C, Point_3 const&D, Point_3 const&E)const{ + Point const* t[]={&A.p,&B.p,&C.p,&D.p}; + return Side_of_oriented_sphere_base(A.r)(make_transforming_iterator(t+0),make_transforming_iterator(t+4),E.p); + } + }; +}; +template struct Orientation_of_points_3 : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Orientation_of_points_3) + typedef typename Get_type::type Point; + typedef typename Get_type::type result_type; + typedef typename Get_functor::type CC; + typedef Adapter_3 Adapter; + template result_type operator()(Iter f, Iter CGAL_assertion_code(e))const{ + CC c(this->kernel()); + Point const& A=*f; + Point const& B=*++f; + Point const& C=*++f; + Point const& D=*++f; + CGAL_assertion(++f==e); + typedef typename Adapter::Point_3 P; + return typename internal::Static_filters_predicates::Orientation_3()(P(this->kernel(),c,A),P(this->kernel(),c,B),P(this->kernel(),c,C),P(this->kernel(),c,D)); + } +}; +template struct Side_of_oriented_sphere_3 : private Store_kernel { + CGAL_FUNCTOR_INIT_STORE(Side_of_oriented_sphere_3) + typedef typename Get_type::type Point; + typedef typename Get_type::type result_type; + typedef typename Get_functor::type CC; + typedef Adapter_3 Adapter; + template result_type operator()(Iter f, Iter CGAL_assertion_code(e), Point const& E)const{ + CC c(this->kernel()); + Point const& A=*f; + Point const& B=*++f; + Point const& C=*++f; + Point const& D=*++f; + CGAL_assertion(++f==e); + typedef typename Adapter::Point_3 P; + return typename internal::Static_filters_predicates::Side_of_oriented_sphere_3()(P(this->kernel(),c,A),P(this->kernel(),c,B),P(this->kernel(),c,C),P(this->kernel(),c,D),P(this->kernel(),c,E)); + } +}; +} // namespace SFA template struct Cartesian_static_filters : public R_ { @@ -109,6 +176,19 @@ struct Cartesian_static_filters, R_, Derived_> : public R_ { }; }; -} - +template +struct Cartesian_static_filters, R_, Derived_> : public R_ { + constexpr Cartesian_static_filters(){} + constexpr Cartesian_static_filters(int d):R_(d){} + typedef Cartesian_static_filters, R_, Derived_> Self; + typedef typename Default::Get::type Derived; + template struct Functor : Inherit_functor {}; + template struct Functor { + typedef SFA::Orientation_of_points_3 type; + }; + template struct Functor { + typedef SFA::Side_of_oriented_sphere_3 type; + }; +}; +} // namespace CGAL #endif diff --git a/Number_types/include/CGAL/Quotient.h b/Number_types/include/CGAL/Quotient.h index 8c117c2fb6d..56e3432bfba 100644 --- a/Number_types/include/CGAL/Quotient.h +++ b/Number_types/include/CGAL/Quotient.h @@ -421,7 +421,6 @@ operator>>(std::istream& in, Quotient& r) NT num,den=1; in >> num; if(!in) return in; - std::istream::sentry s(in); // skip whitespace if(in.peek()!='/'){ if(!in.good()){ in.clear(std::ios_base::eofbit); diff --git a/Number_types/test/Number_types/to_interval_test.cpp b/Number_types/test/Number_types/to_interval_test.cpp index 59752059bf6..90729d1be68 100644 --- a/Number_types/test/Number_types/to_interval_test.cpp +++ b/Number_types/test/Number_types/to_interval_test.cpp @@ -3,6 +3,9 @@ #include // That one should not be needed in the long term: +#include +#include +#include #include #ifdef CGAL_USE_LEDA @@ -16,6 +19,11 @@ #include #endif + +#include +#include +#include + #if 0 #ifdef CGAL_USE_CLN #include diff --git a/Partition_2/include/CGAL/Partition_2/Rotation_tree_2_impl.h b/Partition_2/include/CGAL/Partition_2/Rotation_tree_2_impl.h index 7f4b46ffdb7..e55e1b0d4a6 100644 --- a/Partition_2/include/CGAL/Partition_2/Rotation_tree_2_impl.h +++ b/Partition_2/include/CGAL/Partition_2/Rotation_tree_2_impl.h @@ -10,6 +10,11 @@ // // Author(s) : Susan Hert +#ifndef CGAL_PARTITION_2_ROTATION_TREE_2_IMPL_H +#define CGAL_PARTITION_2_ROTATION_TREE_2_IMPL_H + +#include + #include namespace CGAL { @@ -130,3 +135,5 @@ std::ostream& operator<<(std::ostream& os, const Rotation_tree_2& tree) } } + +#endif // CGAL_PARTITION_2_ROTATION_TREE_2_IMPL_H diff --git a/Partition_2/include/CGAL/Partition_2/Vertex_visibility_graph_2_impl.h b/Partition_2/include/CGAL/Partition_2/Vertex_visibility_graph_2_impl.h index 9d9c463a994..65bf16ac625 100644 --- a/Partition_2/include/CGAL/Partition_2/Vertex_visibility_graph_2_impl.h +++ b/Partition_2/include/CGAL/Partition_2/Vertex_visibility_graph_2_impl.h @@ -10,6 +10,11 @@ // // Author(s) : Susan Hert +#ifndef CGAL_PARTITION_2_VERTEX_VISIBILITY_GRAPH_2_IMPL_H +#define CGAL_PARTITION_2_VERTEX_VISIBILITY_GRAPH_2_IMPL_H + +#include + namespace CGAL { @@ -699,3 +704,5 @@ void Vertex_visibility_graph_2::handle(Tree_iterator p, } } + +#endif // CGAL_PARTITION_2_VERTEX_VISIBILITY_GRAPH_2_IMPL_H diff --git a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_2.h b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_2.h index 52fa86bf761..05f9da516bc 100644 --- a/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_2.h +++ b/Periodic_2_triangulation_2/doc/Periodic_2_triangulation_2/CGAL/Periodic_2_triangulation_2.h @@ -511,6 +511,7 @@ public: Converts the current triangulation into the same periodic triangulation in the 1-sheeted covering space. \pre `is_triangulation_in_1_sheet()` + \cgalAdvancedEnd */ void convert_to_1_sheeted_covering(); @@ -982,6 +983,7 @@ public: `f`. Face `f` is modified, two new faces are created. If the triangulation contains periodic copies, a point is inserted in all periodic copies. \pre The point in vertex `v` lies inside face `f`. + \cgalAdvancedEnd */ Vertex_handle insert_in_face(const Point& p, Face_handle f); @@ -990,7 +992,9 @@ public: \cgalAdvancedFunction \cgalAdvancedBegin Removes a vertex of degree three. Two of the incident faces are - destroyed, the third one is modified. \pre Vertex `v` is a vertex with degree three. + destroyed, the third one is modified. + \pre Vertex `v` is a vertex with degree three. + \cgalAdvancedEnd */ void remove_degree_3(Vertex_handle v); @@ -1012,8 +1016,8 @@ public: creates a new vertex `v` and use it to star the hole whose boundary is described by the sequence of edges `[edge_begin, edge_end]`. Returns a handle to the new vertex. - \pre The triangulation is a triangulation of 1 sheet + \cgalAdvancedEnd */ template @@ -1027,8 +1031,8 @@ public: same as above, except that the algorithm first recycles faces in the sequence `[face_begin, face_end]` and create new ones only when the sequence is exhausted. - \pre The triangulation is a triangulation of 1 sheet + \cgalAdvancedEnd */ template diff --git a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_dummy_12.h b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_dummy_12.h index 6c6c6e01a0c..465ad8c83b0 100644 --- a/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_dummy_12.h +++ b/Periodic_2_triangulation_2/include/CGAL/Periodic_2_triangulation_dummy_12.h @@ -9,6 +9,8 @@ // // Author(s) : Nico Kruithof +#include + #ifdef CGAL_INCLUDE_FROM_PERIODIC_2_TRIANGULATION_2_H #include diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_regular_triangulation_dummy_288.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_regular_triangulation_dummy_288.h index f125d86dda0..811d408a654 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_regular_triangulation_dummy_288.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_regular_triangulation_dummy_288.h @@ -10,6 +10,8 @@ // // Author(s) : Manuel Caroli +#include + #ifdef CGAL_INCLUDE_FROM_PERIODIC_3_REGULAR_TRIANGULATION_3_H std::vector dummy_points() diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_triangulation_dummy_36.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_triangulation_dummy_36.h index a2197bb2768..097a6016360 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_triangulation_dummy_36.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_triangulation_dummy_36.h @@ -10,6 +10,8 @@ // // Author(s) : Manuel Caroli +#include + #ifdef CGAL_INCLUDE_FROM_PERIODIC_3_TRIANGULATION_3_H template < class GT, class TDS > diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_triangulation_dummy_generator.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_triangulation_dummy_generator.h index b501d361cc3..1d11a29adc5 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_triangulation_dummy_generator.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Periodic_3_triangulation_dummy_generator.h @@ -10,6 +10,8 @@ // // Author(s) : Mael Rouxel-Labbé +#include + #ifdef CGAL_INCLUDE_FROM_PERIODIC_3_TRIANGULATION_3_H template < class GT, class TDS > diff --git a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Static_filters/Periodic_3_power_side_of_oriented_power_sphere_3.h b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Static_filters/Periodic_3_power_side_of_oriented_power_sphere_3.h index fa8288872a1..748034a41ab 100644 --- a/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Static_filters/Periodic_3_power_side_of_oriented_power_sphere_3.h +++ b/Periodic_3_triangulation_3/include/CGAL/Periodic_3_triangulation_3/internal/Static_filters/Periodic_3_power_side_of_oriented_power_sphere_3.h @@ -5,13 +5,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé #ifndef CGAL_INTERNAL_STATIC_FILTERS_PERIODIC_3_POWER_TEST_3_H #define CGAL_INTERNAL_STATIC_FILTERS_PERIODIC_3_POWER_TEST_3_H +#include + + #include #include #include diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index f0636f1e14b..f859ae5c43b 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -1188,6 +1188,7 @@ public: \return Returns a pair containing: the specified property map and a Boolean set to `true` or an empty property map and a Boolean set to `false` (if the property was not found). + \cgalAdvancedEnd */ template @@ -1213,6 +1214,7 @@ public: \note The normal property must have been added to the point set before calling this method (see `add_normal_map()`). + \cgalAdvancedEnd */ Vector_push_map normal_push_map () diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/LAS.h b/Point_set_3/include/CGAL/Point_set_3/IO/LAS.h index 2a48f9a3a41..1190c31eed4 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/LAS.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/LAS.h @@ -168,12 +168,6 @@ bool read_LAS(const std::string& fname, CGAL::Point_set_3& point_ #ifndef CGAL_NO_DEPRECATED_CODE -/*! - \ingroup PkgPointSet3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSet3IO `CGAL::IO::read_LAS()` \endlink should be used instead. - */ template CGAL_DEPRECATED bool read_las_point_set(std::istream& is, ///< input stream. CGAL::Point_set_3& point_set) ///< point set @@ -404,12 +398,6 @@ bool write_LAS(const std::string& fname, #ifndef CGAL_NO_DEPRECATED_CODE -/*! - \ingroup PkgPointSet3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSet3IO `CGAL::IO::write_LAS()` \endlink should be used instead. - */ template CGAL_DEPRECATED bool write_las_point_set(std::ostream& os, ///< output stream. CGAL::Point_set_3& point_set) ///< point set diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h b/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h index 7fc677cff37..e364ca3b9a7 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/OFF.h @@ -94,12 +94,6 @@ bool read_OFF(const std::string& fname, CGAL::Point_set_3& point_ #ifndef CGAL_NO_DEPRECATED_CODE -/*! - \ingroup PkgPointSet3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSet3IO `CGAL::IO::read_OFF()` \endlink should be used instead. - */ template CGAL_DEPRECATED bool read_off_point_set(std::istream& is, ///< input stream. CGAL::Point_set_3& point_set) ///< point set. @@ -190,12 +184,6 @@ bool write_OFF(const std::string& fname, const CGAL::Point_set_3& #ifndef CGAL_NO_DEPRECATED_CODE -/*! - \ingroup PkgPointSet3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSet3IO `CGAL::IO::write_OFF()` \endlink should be used instead. - */ template CGAL_DEPRECATED bool write_off_point_set(std::ostream& os, ///< output stream. const CGAL::Point_set_3& point_set) ///< point set diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h b/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h index 67aa82e161c..bbf47ca9731 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/PLY.h @@ -367,25 +367,6 @@ bool read_PLY(const std::string& fname, CGAL::Point_set_3& point_ #ifndef CGAL_NO_DEPRECATED_CODE -/*! - \ingroup PkgPointSet3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSet3IO `CGAL::IO::read_PLY()` \endlink should be used instead. - - \brief reads a point set with properties from an input stream in \ascii or binary PLY format. - - - the operator reads the vertex `point` property; - - if three PLY properties `nx`, `ny` and `nz` with type `float` - or `double` are found, the normal map is added; - - if any other PLY property is found, a "[name]" property map is - added, where `[name]` is the name of the PLY property. - - The `comments` parameter can be omitted. If provided, it will be - used to store the potential comments found in the PLY - header. Each line starting by "comment " in the header is - appended to the `comments` string (without the "comment " word). - */ template CGAL_DEPRECATED bool read_ply_point_set(std::istream& is, ///< input stream. CGAL::Point_set_3& point_set, ///< point set @@ -744,12 +725,6 @@ bool write_PLY(const std::string& fname, const CGAL::Point_set_3& #ifndef CGAL_NO_DEPRECATED_CODE -/*! - \ingroup PkgPointSet3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSet3IO `CGAL::IO::write_PLY()` \endlink should be used instead. - */ template CGAL_DEPRECATED bool write_ply_point_set(std::ostream& os, const CGAL::Point_set_3& point_set, diff --git a/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h b/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h index bdf76f541eb..965d11ff960 100644 --- a/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h +++ b/Point_set_3/include/CGAL/Point_set_3/IO/XYZ.h @@ -93,12 +93,6 @@ bool read_XYZ(const std::string& fname, CGAL::Point_set_3& point_ #ifndef CGAL_NO_DEPRECATED_CODE -/*! - \ingroup PkgPointSet3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSet3IO `CGAL::IO::read_XYZ()` \endlink should be used instead. - */ template CGAL_DEPRECATED bool read_xyz_point_set(std::istream& is, CGAL::Point_set_3& point_set) { @@ -187,12 +181,6 @@ bool write_XYZ(const std::string& fname, const CGAL::Point_set_3& #ifndef CGAL_NO_DEPRECATED_CODE -/*! - \ingroup PkgPointSet3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSet3IO `CGAL::IO::write_XYZ()` \endlink should be used instead. - */ template CGAL_DEPRECATED bool write_xyz_point_set(std::ostream& os, const CGAL::Point_set_3& point_set) { diff --git a/Point_set_3/test/Point_set_3/CMakeLists.txt b/Point_set_3/test/Point_set_3/CMakeLists.txt index 4daea00a56b..879f204e069 100644 --- a/Point_set_3/test/Point_set_3/CMakeLists.txt +++ b/Point_set_3/test/Point_set_3/CMakeLists.txt @@ -10,6 +10,7 @@ find_package(CGAL REQUIRED) create_single_source_cgal_program("point_set_test.cpp") create_single_source_cgal_program("point_set_test_join.cpp") create_single_source_cgal_program("test_deprecated_io_ps.cpp") +create_single_source_cgal_program("issue7996.cpp") #Use LAS #disable if MSVC 2017 diff --git a/Point_set_3/test/Point_set_3/issue7996.cpp b/Point_set_3/test/Point_set_3/issue7996.cpp new file mode 100644 index 00000000000..e3d4d0267c7 --- /dev/null +++ b/Point_set_3/test/Point_set_3/issue7996.cpp @@ -0,0 +1,59 @@ +#include +#include + +#include +#include + +typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; +typedef Kernel::Point_3 Point; +typedef CGAL::Point_set_3 Point_set; + + +int main() +{ + Point_set ps; + ps.insert(Point(0,0,0)); + ps.insert(Point(1,1,1)); + + Point_set::Property_map + red = ps.add_property_map("red" , 0).first, + green = ps.add_property_map("green", 0).first, + blue = ps.add_property_map("blue" , 0).first; + + + int i = 1; + for (Point_set::iterator it = ps.begin(); it != ps.end(); ++ it){ + put(red, *it, static_cast(11 * i++)); + put(green, *it, static_cast(11 * i++)); + put(blue, *it, static_cast(11 * i++)); + } + + { + std::ofstream out("ascii.ply"); + out << ps; + out.close(); + + Point_set ps2; + std::ifstream in("ascii.ply"); + in >> ps2; + + std::cout << ps2 << std::endl; + } + + { + std::ofstream out("binary.ply", std::ios::binary); + CGAL::IO::set_binary_mode(out); + out << ps; + out.close(); + + Point_set ps2; + std::ifstream in("binary.ply", std::ios::binary); + CGAL::IO::set_binary_mode(in); + in >> ps2; + + std::cout << ps2 << std::endl; + } + + + return 0; +} diff --git a/Point_set_processing_3/doc/Point_set_processing_3/PackageDescription.txt b/Point_set_processing_3/doc/Point_set_processing_3/PackageDescription.txt index f9e3c5b663e..6e01bf6a819 100644 --- a/Point_set_processing_3/doc/Point_set_processing_3/PackageDescription.txt +++ b/Point_set_processing_3/doc/Point_set_processing_3/PackageDescription.txt @@ -10,9 +10,6 @@ simplification, etc.). \defgroup PkgPointSetProcessing3IO I/O Functions \ingroup PkgPointSetProcessing3Ref -\defgroup PkgPointSetProcessing3IODeprecated I/O Functions (Deprecated) -\ingroup PkgPointSetProcessing3IO - \defgroup PkgPointSetProcessing3IOOff I/O (OFF Formats) \ingroup PkgPointSetProcessing3Ref diff --git a/Point_set_processing_3/doc/Point_set_processing_3/dependencies b/Point_set_processing_3/doc/Point_set_processing_3/dependencies index a550c93b660..4ee2cbfeadc 100644 --- a/Point_set_processing_3/doc/Point_set_processing_3/dependencies +++ b/Point_set_processing_3/doc/Point_set_processing_3/dependencies @@ -12,4 +12,5 @@ Jet_fitting_3 Solver_interface Shape_detection Advancing_front_surface_reconstruction +Point_set_3 BGL diff --git a/Point_set_processing_3/examples/Point_set_processing_3/read_write_xyz_point_set_example.cpp b/Point_set_processing_3/examples/Point_set_processing_3/read_write_xyz_point_set_example.cpp index fd14311a732..604235ffae9 100644 --- a/Point_set_processing_3/examples/Point_set_processing_3/read_write_xyz_point_set_example.cpp +++ b/Point_set_processing_3/examples/Point_set_processing_3/read_write_xyz_point_set_example.cpp @@ -22,7 +22,7 @@ int main(int argc, char*argv[]) const std::string fname = (argc>1) ? argv[1] : CGAL::data_file_path("points_3/oni.pwn"); // Reads a .xyz point set file in points[]. - // Note: read_points() requires an output iterator + // Note: read_XYZ() requires an output iterator // over points and as well as property maps to access each // point position and normal. std::vector points; diff --git a/Point_set_processing_3/include/CGAL/IO/read_las_points.h b/Point_set_processing_3/include/CGAL/IO/read_las_points.h index 0d034a6bcb1..ebc1744cc7e 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_las_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_las_points.h @@ -123,7 +123,7 @@ typedef Base I; /** \ingroup PkgPointSetProcessing3IOLas - Generates a %LAS property handler to read 3D points. Points are + generates a %LAS property handler to read 3D points. Points are constructed from the input the using 3 %LAS properties `LAS_property::X`, `LAS_property::Y` and `LAS_property::Z`. @@ -574,11 +574,7 @@ bool read_las_points(std::istream& is, ///< input stream. /// \endcond -/** - \ingroup PkgPointSetProcessing3IODeprecated - \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::read_LAS_with_properties()` should be used instead. -*/ template @@ -602,11 +598,6 @@ CGAL_DEPRECATED bool read_las_points_with_properties(std::istream& is, /// \endcond -/** - \ingroup PkgPointSetProcessing3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::read_LAS()` should be used instead. -*/ template diff --git a/Point_set_processing_3/include/CGAL/IO/read_off_points.h b/Point_set_processing_3/include/CGAL/IO/read_off_points.h index 660601cb985..e193661dffd 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_off_points.h @@ -410,12 +410,6 @@ bool read_off_points(std::istream& is, ///< input stream. /// \endcond -/*! - \ingroup PkgPointSetProcessing3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSetProcessing3IOOff `CGAL::IO::read_OFF()` \endlink should be used instead. -*/ template diff --git a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h index 93cf9c91356..d7ec7d9aa60 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_ply_points.h @@ -434,24 +434,13 @@ bool read_ply_points(std::istream& is, ///< input stream. /// \endcond -/** - \ingroup PkgPointSetProcessing3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSetProcessing3IOPly `CGAL::IO::read_PLY_with_properties()` \endlink should be used instead. - */ template CGAL_DEPRECATED bool read_ply_points_with_properties(std::istream& is, OutputIterator output, PropertyHandler&& ... properties) { return IO::read_PLY_with_properties(is, output, std::forward(properties)...); } -/** - \ingroup PkgPointSetProcessing3IODeprecated - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSetProcessing3IOPly `CGAL::IO::read_PLY()` \endlink should be used instead. - */ template CGAL_DEPRECATED bool read_ply_points(std::istream& is, OutputIterator output, const CGAL_NP_CLASS& np = parameters::default_values()) { diff --git a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h index ba023110950..5dd9fa8678f 100644 --- a/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/read_xyz_points.h @@ -245,9 +245,11 @@ bool read_XYZ(const std::string& fname, OutputIterator output, const CGAL_NP_CLA return read_XYZ::type>(is, output, np); } +/// \endcond + } // namespace IO -/// \endcond + #ifndef CGAL_NO_DEPRECATED_CODE @@ -392,14 +394,7 @@ bool read_xyz_points(std::istream& is, ///< input stream. /// \endcond -/** - \ingroup PkgPointSetProcessing3IODeprecated - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSetProcessing3IOXyz `CGAL::IO::read_XYZ()` \endlink should be used instead. - - \returns `true` if reading was successful, `false` otherwise. -*/ template diff --git a/Point_set_processing_3/include/CGAL/IO/write_las_points.h b/Point_set_processing_3/include/CGAL/IO/write_las_points.h index c1ccb1596c6..400aed2092a 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_las_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_las_points.h @@ -304,7 +304,7 @@ bool write_LAS(std::ostream& os, /** \ingroup PkgPointSetProcessing3IOLas - Saves the range of `points` (positions only), using the \ref IOStreamLAS. + writes the range of `points` (positions only), using the \ref IOStreamLAS. \tparam PointRange is a model of `ConstRange`. The value type of its iterator is the key type of the named parameter `point_map`. @@ -378,11 +378,6 @@ bool write_las_points(std::ostream& os, ///< output stream. /// \endcond -/** - \ingroup PkgPointSetProcessing3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::write_LAS_with_properties()` should be used instead. -*/ template @@ -397,11 +392,7 @@ CGAL_DEPRECATED bool write_las_points_with_properties(std::ostream& os, return IO::write_LAS_with_properties(os, points, point_property, std::forward(properties)...); } -/** - \ingroup PkgPointSetProcessing3IODeprecated - \deprecated This function is deprecated since \cgal 5.3, `CGAL::IO::write_LAS()` should be used instead. -*/ template bool write_las_points(std::ostream& os, const PointRange& points, const CGAL_NP_CLASS& np = parameters::default_values()) { diff --git a/Point_set_processing_3/include/CGAL/IO/write_off_points.h b/Point_set_processing_3/include/CGAL/IO/write_off_points.h index d5411b67fd9..941bc16d518 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_off_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_off_points.h @@ -292,12 +292,6 @@ bool write_off_points(std::ostream& os, ///< output stream. /// \endcond -/** - \ingroup PkgPointSetProcessing3IODeprecated - - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSetProcessing3IOOff `CGAL::IO::write_OFF()` \endlink should be used instead. -*/ template CGAL_DEPRECATED bool write_off_points(std::ostream& os, const PointRange& points, const CGAL_NP_CLASS& np = parameters::default_values()) { diff --git a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h index 525bc159023..0ddbb70d613 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_ply_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_ply_points.h @@ -353,12 +353,7 @@ bool write_ply_points(std::ostream& os, ///< output stream. /// \endcond -/** -\ingroup PkgPointSetProcessing3IODeprecated -\deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSetProcessing3IOPly `CGAL::IO::write_PLY_with_properties()` \endlink should be used instead. -*/ template CGAL_DEPRECATED bool write_ply_points_with_properties(std::ostream& os, ///< output stream. @@ -368,12 +363,7 @@ CGAL_DEPRECATED bool write_ply_points_with_properties(std::ostream& os, ///< out return IO::write_PLY_with_properties(os, points, std::forward(properties)...); } -/** -\ingroup PkgPointSetProcessing3IODeprecated -\deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSetProcessing3IOPly `CGAL::IO::write_PLY()` \endlink should be used instead. -*/ template CGAL_DEPRECATED bool write_ply_points(std::ostream& os, const PointRange& points, const CGAL_NP_CLASS& np = parameters::default_values()) { diff --git a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h index 43875b1a5d8..036e060367b 100644 --- a/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h +++ b/Point_set_processing_3/include/CGAL/IO/write_xyz_points.h @@ -280,12 +280,7 @@ bool write_xyz_points(std::ostream& os, ///< output stream. /// \endcond -/** - \ingroup PkgPointSetProcessing3IODeprecated - \deprecated This function is deprecated since \cgal 5.3, - \link PkgPointSetProcessing3IOXyz `CGAL::write_XYZ()` \endlink should be used instead. -*/ template CGAL_DEPRECATED bool write_xyz_points(std::ostream& os, const PointRange& points, const CGAL_NP_CLASS& np = parameters::default_values()) { diff --git a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt index ac3e94db114..e532de3e728 100644 --- a/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt +++ b/Polygon_mesh_processing/doc/Polygon_mesh_processing/Polygon_mesh_processing.txt @@ -973,6 +973,11 @@ quad meshes, and meshes with n-gon faces (for n-gons, the centroid must be insid The algorithms used prove to work well in general. Also, on meshes with noise on vertex positions, they give accurate results, under the condition that the correct vertex normals are provided. +It is worth noting that the Principal Curvatures and Directions can also be estimated using the +\ref PkgJetFitting3 package, which estimates the local differential quantities of a surface at a point +using a local polynomial fitting (fitting a d-jet). Unlike the Interpolated Corrected Curvatures, +the Jet Fitting method discards topological information and thus can be used on point clouds as well. + \subsection ICCBackground Brief Background Surface curvatures are quantities that describe the local geometry of a surface. They are important in many @@ -987,7 +992,7 @@ introduce a new way to compute curvatures on polygonal meshes. The main idea in based on decoupling the normal information from the position information, which is useful for dealing with digital surfaces, or meshes with noise on vertex positions. \cgalCite{cgal:lrtc-iccmps-20} introduces some extensions to this framework, as it uses linear interpolation on the corrected normal vector field -to derive new closed form equations for the corrected curvature measures. These interpolated +to derive new closed-form equations for the corrected curvature measures. These interpolated curvature measures are the first step for computing the curvatures. For a triangle \f$ \tau_{ijk} \f$, with vertices \a i, \a j, \a k: @@ -1011,8 +1016,13 @@ solver. The interpolated curvature measures are then computed for each vertex \f$ v \f$ as the sum of the curvature measures of the faces in a ball around \f$ v \f$ weighted by the inclusion ratio of the -triangle in the ball. If the ball radius is not specified, the sum is instead computed over the incident faces -of \f$ v \f$. +triangle in the ball. This ball radius is an optional (named) parameter of the function. There are 3 +cases for the ball radius passed value: +- A positive value is passed: it is naturally used as the radius of the ball. +- 0 is passed, a small epsilon (`average_edge_length * 1e-6`) is used +(to account for the convergence of curvatures at infinitely small balls). +- It is not specified (or negative), the sum is instead computed over the incident faces +of the vertex \f$ v \f$. To get the final curvature value for a vertex \f$ v \f$, the respective interpolated curvature measure is divided by the interpolated area measure. @@ -1030,7 +1040,7 @@ These computations are performed using (on all vertices of the mesh) `CGAL::Poly where function named parameters are used to select the curvatures (and possibly directions) to be computed. An overload function with the same name but taking a given vertex is also available in case the computation should be done only for that vertex. -\subsection ICCResults Results & Performance +\subsection ICCResults Results First, \cgalFigureRef{icc_measures} illustrates various curvature measures on a triangular mesh. @@ -1075,6 +1085,121 @@ When changing the integration ball radius, we obtain a scale space of curvature \cgalFigureCaptionEnd +\subsection ICCPerformance Performance + +The implemented algorithms exhibit a linear complexity in the number of faces of the mesh. It is worth noting that +we pre-computed the vertex normals and passed them as a named parameter to the function to better estimate the +performance of the curvature computation. For the data reported in the following table, we used a machine with an +Intel Core i7-8750H CPU @ 2.20GHz, 16GB of RAM, on Windows 11, 64 bits and compiled with Visual Studio 2019. + +\cgalFigureAnchor{icc_performance_table} +
          + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
          Ball
          Radius
          ComputationSpot
          (6k faces)
          Bunny
          (144K faces)
          Stanford Dragon
          (871K faces)
          Old Age or Winter
          (6M faces)
          vertex
          1-ring faces
          (default)
          Mean Curvature < 0.001 s0.019 s0.11 s2.68 s
          Gaussian Curvature < 0.001 s0.017 s0.10 s2.77 s
          Principal Curvatures & Directions0.002 s0.044 s0.25 s3.98 s
          All (optimized for shared computations)0.003 s0.049 s0.28 s4.52 s
          r = 0.1
          * avg_edge_length
          Mean Curvature0.017 s0.401 s2.66 s22.29 s
          Gaussian Curvature0.018 s0.406 s2.63 s21.61 s
          Principal Curvatures & Directions0.019 s0.430 s2.85 s23.55 s
          All (optimized for shared computations)0.017 s0.428 s2.89 s24.16 s
          r = 0.5
          * avg_edge_length
          Mean Curvature0.024 s0.388 s3.18 s22.79 s
          Gaussian Curvature0.024 s0.392 s3.21 s23.58 s
          Principal Curvatures & Directions0.027 s0.428 s3.41 s24.44 s
          All (optimized for shared computations)0.025 s0.417 s3.44 s23.93 s
          +
          +\cgalFigureCaptionBegin{icc_performance_table} +Performance of the curvature computation on various meshes (in seconds). The first 4 rows show the performance of the default value for the ball radius, +which is using the 1-ring of neighboring faces around each vertex, instead of actually approximating the inclusion ratio of the faces in a ball of certain radius. +The other rows show a ball radius of 0.1 (and 0.5) scaled by the average edge length of the mesh. It is clear that using the 1-ring of faces +is much faster, but it might not be as effective when used on a noisy input mesh. +\cgalFigureCaptionEnd + + \ref BGLPropertyMaps are used to record the computed curvatures as shown in examples. In the following examples, for each property map, we associate a curvature value to each vertex. @@ -1309,7 +1434,7 @@ available on 7th of October 2020. It only uses the high level algorithm of chec is covered by a set of prisms, where each prism is an offset for an input triangle. That is, the implementation in \cgal does not use indirect predicates. -The interpolated corrected curvatures were implemented during GSoC 2022. This was implemented by Hossam Saeed and under +The interpolated corrected curvatures were implemented during GSoC 2022. This was implemented by Hossam Saeed and under the supervision of David Coeurjolly, Jaques-Olivier Lachaud, and Sébastien Loriot. The implementation is based on \cgalCite{cgal:lrtc-iccmps-20}.
          DGtal's implementation was also used as a reference during the project. diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_parallel_union_meshes.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_parallel_union_meshes.cpp index 72bd328a50d..a8f3c2ea5ee 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_parallel_union_meshes.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/corefinement_parallel_union_meshes.cpp @@ -10,6 +10,7 @@ typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel; typedef Kernel::Point_3 Point_3; +typedef Kernel::Aff_transformation_3 Aff_transformation_3; typedef CGAL::Surface_mesh Mesh; namespace PMP = CGAL::Polygon_mesh_processing; @@ -23,7 +24,7 @@ int main(int argc, char** argv) in >> meshes[0]; for (int i=1; i trans(CGAL::Translation(), Kernel::Vector_3(i*0.2, 0, 0)); + Aff_transformation_3 trans(CGAL::Translation(), Kernel::Vector_3(i*0.2, 0, 0)); meshes[i]=meshes[0]; PMP::transform(trans, meshes[i]); } diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_bounded_error_distance_example.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_bounded_error_distance_example.cpp index 44f1944be0b..7fa0cbcd540 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_bounded_error_distance_example.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/hausdorff_bounded_error_distance_example.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -8,15 +7,15 @@ #include #include -using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; -using FT = typename Kernel::FT; -using Point_3 = typename Kernel::Point_3; -using Vector_3 = typename Kernel::Vector_3; - +using Kernel = CGAL::Exact_predicates_inexact_constructions_kernel; +using FT = typename Kernel::FT; +using Point_3 = typename Kernel::Point_3; +using Vector_3 = typename Kernel::Vector_3; +using Affine_transformation_3 = typename Kernel::Aff_transformation_3; using TAG = CGAL::Sequential_tag; using Surface_mesh = CGAL::Surface_mesh; using Polyhedron = CGAL::Polyhedron_3; -using Affine_transformation_3 = CGAL::Aff_transformation_3; + namespace PMP = CGAL::Polygon_mesh_processing; diff --git a/Polygon_mesh_processing/examples/Polygon_mesh_processing/soup_autorefinement.cpp b/Polygon_mesh_processing/examples/Polygon_mesh_processing/soup_autorefinement.cpp index a76e1254f6e..b1b58ae10e3 100644 --- a/Polygon_mesh_processing/examples/Polygon_mesh_processing/soup_autorefinement.cpp +++ b/Polygon_mesh_processing/examples/Polygon_mesh_processing/soup_autorefinement.cpp @@ -22,7 +22,11 @@ int main(int argc, char** argv) std::vector input_points; std::vector> input_triangles; - CGAL::IO::read_polygon_soup(filename, input_points, input_triangles); + if (!CGAL::IO::read_polygon_soup(filename, input_points, input_triangles)) + { + std::cerr << "Cannot read " << filename << "\n"; + return 1; + } PMP::repair_polygon_soup(input_points, input_triangles); PMP::triangulate_polygons(input_points, input_triangles); diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/autorefinement.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/autorefinement.h index 8a61b92f717..8de62f6b802 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/autorefinement.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/autorefinement.h @@ -14,7 +14,7 @@ #ifndef CGAL_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_H #define CGAL_POLYGON_MESH_PROCESSING_AUTOREFINEMENT_H -#include +#include #include #include @@ -55,6 +55,10 @@ #endif #endif +#ifdef CGAL_AUTOREF_USE_FIXED_PROJECTION_TRAITS +#include +#endif + #include //#define CGAL_AUTOREF_USE_DEBUG_PARALLEL_TIMERS @@ -114,7 +118,6 @@ Segment_inter_type do_coplanar_segments_intersect(std::size_t pi, std::size_t qi, std::size_t ri, std::size_t si, const std::vector& points, - const typename K::Vector_3& /* plane_normal */, const K& k = K()) { typename K::Collinear_are_ordered_along_line_3 cln_order = k.collinear_are_ordered_along_line_3_object(); @@ -249,36 +252,55 @@ do_coplanar_segments_intersect(std::size_t pi, std::size_t qi, return NO_INTERSECTION; } + // imported from Intersections_3/include/CGAL/Intersections_3/internal/Triangle_3_Triangle_3_intersection.h template void coplanar_intersections(const std::array& t1, const std::array& t2, - std::vector& inter_pts) + std::vector>& inter_pts) { - const typename K::Point_3& p1 = t1[0], q1 = t1[1], r1 = t1[2]; - const typename K::Point_3& p2 = t2[0], q2 = t2[1], r2 = t2[2]; + const typename K::Point_3& p1 = t1[0], &q1 = t1[1], &r1 = t1[2]; + const typename K::Point_3& p2 = t2[0], &q2 = t2[1], &r2 = t2[2]; std::list> l_inter_pts; - l_inter_pts.push_back(Intersections::internal::Point_on_triangle(-1,0)); - l_inter_pts.push_back(Intersections::internal::Point_on_triangle(-1,1)); - l_inter_pts.push_back(Intersections::internal::Point_on_triangle(-1,2)); + l_inter_pts.push_back(Intersections::internal::Point_on_triangle(0,-1)); + l_inter_pts.push_back(Intersections::internal::Point_on_triangle(0,-2)); + l_inter_pts.push_back(Intersections::internal::Point_on_triangle(0,-3)); +#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION + auto print_points = [&]() + { + std::cout << " ipts size: " << l_inter_pts.size() << "\n"; + for(auto p : l_inter_pts) {std::cout << " (" << p.id1() << "," << p.id2() << ",[" << p.alpha << "]) ";} std::cout <<"\n"; + }; +#endif //intersect t2 with the three half planes which intersection defines t1 K k; - Intersections::internal::intersection_coplanar_triangles_cutoff(p1,q1,r1,0,p2,q2,r2,k,l_inter_pts); //line p1q1 - Intersections::internal::intersection_coplanar_triangles_cutoff(q1,r1,p1,1,p2,q2,r2,k,l_inter_pts); //line q1r1 - Intersections::internal::intersection_coplanar_triangles_cutoff(r1,p1,q1,2,p2,q2,r2,k,l_inter_pts); //line r1p1 +#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION + print_points(); +#endif + Intersections::internal::intersection_coplanar_triangles_cutoff(p1,q1,r1,1,p2,q2,r2,k,l_inter_pts); //line p1q1 +#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION + print_points(); +#endif + Intersections::internal::intersection_coplanar_triangles_cutoff(q1,r1,p1,2,p2,q2,r2,k,l_inter_pts); //line q1r1 +#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION + print_points(); +#endif + Intersections::internal::intersection_coplanar_triangles_cutoff(r1,p1,q1,3,p2,q2,r2,k,l_inter_pts); //line r1p1 +#ifdef CGAL_DEBUG_COPLANAR_T3_T3_INTERSECTION + print_points(); +#endif for (const Intersections::internal::Point_on_triangle& pot : l_inter_pts) - inter_pts.push_back( pot.point(p1,q1,r1,p2,q2,r2,k) ); + inter_pts.emplace_back(pot.point(p1,q1,r1,p2,q2,r2,k), pot.id1(), pot.id2()); } -// imported from Polygon_mesh_processing/internal/Corefinement/intersect_triangle_segment_3.h +// imported from Polygon_mesh_processing/internal/Corefinement/intersect_triangle_and_segment_3.h template -void +std::optional> find_intersection(const typename K::Point_3& p, const typename K::Point_3& q, //segment const typename K::Point_3& a, const typename K::Point_3& b, const typename K::Point_3& c, //triangle - std::vector& inter_pts, bool is_p_coplanar=false, bool is_q_coplanar=false) // note that in coref this was wrt a halfedge not p/q { Orientation ab=orientation(p,q,a,b); @@ -286,54 +308,56 @@ find_intersection(const typename K::Point_3& p, const typename K::Point_3& q, / Orientation ca=orientation(p,q,c,a); if ( ab==POSITIVE || bc==POSITIVE || ca==POSITIVE ) - return; + return std::nullopt; int nb_coplanar=(ab==COPLANAR?1:0) + (bc==COPLANAR?1:0) + (ca==COPLANAR?1:0); - if (is_p_coplanar) - { - inter_pts.push_back(p); - return; - } - if (is_q_coplanar) - { - inter_pts.push_back(q); - return; - } - - if (nb_coplanar!=2) - { - inter_pts.push_back( - typename K::Construct_plane_line_intersection_point_3()(a, b, c, p, q) - ); - } - else + if (nb_coplanar==2) { + // even if a common point is not new it is still needed to be reported so + // that the intersection segment is known. if (ab!=COPLANAR) - { // intersection is c - inter_pts.push_back(c); - return; - } - - if (bc!=COPLANAR) - { + return std::make_pair(c, -3); + else if (bc!=COPLANAR) // intersection is a - inter_pts.push_back(a); - return; + return std::make_pair(a, -1); + else + { + CGAL_assertion(ca!=COPLANAR); + // intersection is b + return std::make_pair(b, -2); } - CGAL_assertion(ca!=COPLANAR); - // intersection is b - inter_pts.push_back(b); } + + typename K::Point_3 ipt = is_p_coplanar ? p : + is_q_coplanar ? q : + typename K::Construct_plane_line_intersection_point_3() + (a, b, c, p, q); + + if (nb_coplanar == 0) + return std::make_pair(ipt, 0); + + + CGAL_assertion(nb_coplanar==1); + + if (ab==COPLANAR) + // intersection is ab + return std::make_pair(ipt, 1); + if (bc==COPLANAR) + // intersection is bc + return std::make_pair(ipt, 2); + CGAL_assertion(ca==COPLANAR); + // intersection is ca + return std::make_pair(ipt, 3); } template -void test_edge(const typename K::Point_3& p, const typename K::Point_3& q, - const typename K::Point_3& a, const typename K::Point_3& b, const typename K::Point_3& c, - const Orientation abcp, - const Orientation abcq, - std::vector& inter_pts) +std::optional> +test_edge(const typename K::Point_3& p, const typename K::Point_3& q, + const typename K::Point_3& a, const typename K::Point_3& b, const typename K::Point_3& c, + const Orientation abcp, + const Orientation abcq) { switch ( abcp ) { case POSITIVE: @@ -341,46 +365,40 @@ void test_edge(const typename K::Point_3& p, const typename K::Point_3& q, case POSITIVE: // the segment lies in the positive open halfspaces defined by the // triangle's supporting plane - break; + return std::nullopt; case NEGATIVE: // p sees the triangle in counterclockwise order - find_intersection(p,q,a,b,c,inter_pts); - break; + return find_intersection(p,q,a,b,c); //case COPLANAR: default: // q belongs to the triangle's supporting plane // p sees the triangle in counterclockwise order - find_intersection(p,q,a,b,c,inter_pts,false,true); + return find_intersection(p,q,a,b,c,false,true); } - break; case NEGATIVE: switch ( abcq ) { case POSITIVE: // q sees the triangle in counterclockwise order - find_intersection(q,p,a,b,c,inter_pts); - break; + return find_intersection(q,p,a,b,c); case NEGATIVE: // the segment lies in the negative open halfspaces defined by the // triangle's supporting plane - break; + return std::nullopt; // case COPLANAR: default: // q belongs to the triangle's supporting plane // p sees the triangle in clockwise order - find_intersection(q,p,a,b,c,inter_pts,true,false); + return find_intersection(q,p,a,b,c,true,false); } - break; default: //case COPLANAR: // p belongs to the triangle's supporting plane switch ( abcq ) { case POSITIVE: // q sees the triangle in counterclockwise order - find_intersection(q,p,a,b,c,inter_pts,false, true); - break; + return find_intersection(q,p,a,b,c,false, true); case NEGATIVE: // q sees the triangle in clockwise order - find_intersection(p,q,a,b,c,inter_pts,true); - break; + return find_intersection(p,q,a,b,c,true); //case COPLANAR: default: // the segment is coplanar with the triangle's supporting plane @@ -392,7 +410,7 @@ void test_edge(const typename K::Point_3& p, const typename K::Point_3& q, // nothing done as coplanar case handle in collect_intersections // and other intersection points will be collected with non-coplanar edges //} - break; + return std::nullopt; } } } @@ -400,7 +418,7 @@ void test_edge(const typename K::Point_3& p, const typename K::Point_3& q, template bool collect_intersections(const std::array& t1, const std::array& t2, - std::vector& inter_pts) + std::vector>& inter_pts) { // test edges of t1 vs t2 std::array ori; @@ -409,6 +427,7 @@ bool collect_intersections(const std::array& t1, if (ori[0]== COPLANAR && ori[1]==COPLANAR && ori[2]==COPLANAR) { + coplanar_intersections(t1, t2, inter_pts); #ifdef CGAL_AUTOREF_DEBUG_DEPTH for (auto p : inter_pts) @@ -421,7 +440,17 @@ bool collect_intersections(const std::array& t1, for (int i=0; i<3; ++i) { int j=(i+1)%3; - test_edge(t1[i], t1[j], t2[0], t2[1], t2[2], ori[i], ori[j], inter_pts); + std::optional > opt = + test_edge(t1[i], t1[j], t2[0], t2[1], t2[2], ori[i], ori[j]); + if (opt) + { + if (ori[i]==COPLANAR) + inter_pts.emplace_back(opt->first, -(i+1), opt->second); + else if (ori[j]==COPLANAR) + inter_pts.emplace_back(opt->first, -(j+1), opt->second); + else + inter_pts.emplace_back(opt->first, i+1 , opt->second); + } } // test edges of t2 vs t1 @@ -430,12 +459,23 @@ bool collect_intersections(const std::array& t1, for (int i=0; i<3; ++i) { int j=(i+1)%3; - test_edge(t2[i], t2[j], t1[0], t1[1], t1[2], ori[i], ori[j], inter_pts); + std::optional > opt = + test_edge(t2[i], t2[j], t1[0], t1[1], t1[2], ori[i], ori[j]); + if (opt) + { + if (ori[i]==COPLANAR) + inter_pts.emplace_back(opt->first, opt->second, -(i+1)); + else if (ori[j]==COPLANAR) + inter_pts.emplace_back(opt->first, opt->second, -(j+1)); + else + inter_pts.emplace_back(opt->first, opt->second, i+1 ); + } } +// #warning TODO get rid of sort and unique calls // because we don't handle intersection type and can have edge-edge edge-vertex duplicates - std::sort(inter_pts.begin(), inter_pts.end()); - auto last = std::unique(inter_pts.begin(), inter_pts.end()); + std::sort(inter_pts.begin(), inter_pts.end(), [](auto p, auto q){return std::get<0>(p)(q);}); + auto last = std::unique(inter_pts.begin(), inter_pts.end(), [](auto p, auto q){return std::get<0>(p)==std::get<0>(q);}); inter_pts.erase(last, inter_pts.end()); #ifdef CGAL_AUTOREF_DEBUG_DEPTH @@ -446,45 +486,75 @@ bool collect_intersections(const std::array& t1, return false; } +struct Triangle_data +{ + using Point_3 = Exact_predicates_exact_constructions_kernel::Point_3; + std::vector points; + std::vector point_locations; + std::vector> segments; + std::vector segment_input_triangle_ids; + template + std::size_t add_point(const std::tuple& tpl) + { + if (std::get(tpl) < 0) + return -std::get(tpl)-1; + points.push_back(std::get<0>(tpl)); + point_locations.push_back(std::get(tpl)); + return points.size()-1; + } + +#ifndef NDEBUG + bool on_same_edge(std::size_t i, std::size_t j) +#else + bool on_same_edge_debug(std::size_t i, std::size_t j) +#endif + { + if (point_locations[i]==0 || point_locations[j]==0) return false; + if (point_locations[i]>0) + { + if (point_locations[j]>0) + return point_locations[i]==point_locations[j]; + return -point_locations[j]==point_locations[i] || point_locations[i]%3+1==-point_locations[j]; + } + if (point_locations[j]<0) + return true; + return -point_locations[i]==point_locations[j] || point_locations[j]%3+1==-point_locations[i]; + } +#ifdef NDEBUG + bool on_same_edge(std::size_t i, std::size_t j) + { + bool on = on_same_edge_debug(i,j); + if (!on) return false; + int eid = point_locations[i]>0 ? point_locations[i] : point_locations[j]; + if (eid<0) return true; + if (!(collinear(points[eid-1], points[(eid)%3], points[i]))) + { + std::cout << point_locations[i] << " " << point_locations[j] << " " << eid << "\n"; + } + if (!(collinear(points[eid-1], points[(eid)%3], points[j]))) + { + std::cout << point_locations[i] << " " << point_locations[j] << " " << eid << "\n"; + } + CGAL_assertion(collinear(points[eid-1], points[(eid)%3], points[i])); + CGAL_assertion(collinear(points[eid-1], points[(eid)%3], points[j])); + return true; + } +#endif +}; + template void generate_subtriangles(std::size_t ti, - std::vector>& segments, - std::vector& points, - const std::vector& in_triangle_ids, + Triangle_data& triangle_data, const std::set >& intersecting_triangles, const std::set >& coplanar_triangles, const std::vector>& triangles, PointVector& new_triangles ) { - typedef CGAL::Projection_traits_3 P_traits; - typedef CGAL::No_constraint_intersection_tag Itag; - - typedef CGAL::Constrained_Delaunay_triangulation_2 CDT_2; - //typedef CGAL::Constrained_triangulation_plus_2 CDT; - typedef CDT_2 CDT; - - const std::array& t = triangles[ti]; - - // positive triangle normal - typename EK::Vector_3 n = normal(t[0], t[1], t[2]); - typename EK::Point_3 o(CGAL::ORIGIN); - - bool orientation_flipped = false; - if ( typename EK::Less_xyz_3()(o+n,o) ) - { - n=-n; - orientation_flipped = true; - } - - P_traits cdt_traits(n); - CDT cdt(cdt_traits); - cdt.insert_outside_affine_hull(t[0]); - cdt.insert_outside_affine_hull(t[1]); - typename CDT::Vertex_handle v = cdt.tds().insert_dim_up(cdt.infinite_vertex(), orientation_flipped); - v->set_point(t[2]); - #ifdef CGAL_AUTOREFINE_DEBUG_COUNTERS struct Counter { @@ -518,7 +588,12 @@ void generate_subtriangles(std::size_t ti, #define CGAL_AUTOREF_COUNTER_INSTRUCTION(X) #endif - // pre-compute segment intersections + std::vector& points=triangle_data.points; + std::vector& point_locations=triangle_data.point_locations; + std::vector>& segments=triangle_data.segments; + std::vector& in_triangle_ids=triangle_data.segment_input_triangle_ids; + +// pre-compute segment intersections if (!segments.empty()) { std::size_t nbs = segments.size(); @@ -528,7 +603,7 @@ void generate_subtriangles(std::size_t ti, CGAL_AUTOREF_COUNTER_INSTRUCTION(counter.timer1.start();) std::map point_id_map; - +//TODO: we already have sorted the points while deduplicating segments! for (std::size_t pid=0; pidsecond; }; @@ -569,7 +647,7 @@ void generate_subtriangles(std::size_t ti, Segment_inter_type seg_inter_type = do_coplanar_segments_intersect(segments[i].first, segments[i].second, segments[j].first, segments[j].second, - points, n); + points); CGAL_AUTOREF_COUNTER_INSTRUCTION(counter.timer5.stop();) switch(seg_inter_type) @@ -739,13 +817,147 @@ void generate_subtriangles(std::size_t ti, auto last = std::unique(segments.begin(), segments.end()); segments.erase(last, segments.end()); +// init CDT + insert points and constraints CGAL_AUTOREF_COUNTER_INSTRUCTION(counter.timer3.start();) - if (segments.empty()) - cdt.insert(points.begin(), points.end()); - else - cdt.insert_constraints(points.begin(), points.end(), segments.begin(), segments.end()); +#ifdef CGAL_AUTOREF_USE_FIXED_PROJECTION_TRAITS + typedef ::CGAL::internal::Projection_traits_3 P_traits; +#else + typedef CGAL::Projection_traits_3 P_traits; +#endif + + typedef CGAL::No_constraint_intersection_tag Itag; + + typedef CGAL::Constrained_Delaunay_triangulation_2 CDT_2; + //typedef CGAL::Constrained_triangulation_plus_2 CDT; + typedef CDT_2 CDT; + + const std::array& t = triangles[ti]; + std::vector vhandles(triangle_data.points.size()); + +#ifdef CGAL_AUTOREF_USE_FIXED_PROJECTION_TRAITS + P_traits cdt_traits; + bool orientation_flipped = false; + CDT cdt(cdt_traits); + // TODO: still need to figure out why I can't make the orientation_flipped correctly + vhandles[0]=cdt.insert(t[0]); + vhandles[1]=cdt.insert(t[1]); + vhandles[2]=cdt.insert(t[2]); +#else + // positive triangle normal + typename EK::Vector_3 n = normal(t[0], t[1], t[2]); + typename EK::Point_3 o(CGAL::ORIGIN); + + bool orientation_flipped = false; + if ( typename EK::Less_xyz_3()(o+n,o) ) + { + n=-n; + orientation_flipped = true; + } + P_traits cdt_traits(n); + + CDT cdt(cdt_traits); + vhandles[0]=cdt.insert_outside_affine_hull(t[0]); + vhandles[1]=cdt.insert_outside_affine_hull(t[1]); + vhandles[2] = cdt.tds().insert_dim_up(cdt.infinite_vertex(), orientation_flipped); + vhandles[2]->set_point(t[2]); +#endif + + // insert points and fill vhandles +#if 0 + std::vector indices(triangle_data.points.size()-3); + std::iota(indices.begin(), indices.end(), 3); +#else + //start by points on edges + std::array, 3> indices_on_edges; + std::vector indices; + for (std::size_t i=3; i0 && point_locations[i]<4); + indices_on_edges[point_locations[i]-1].push_back(i); + } + } + + //sort points on edges and insert them + typename CDT::Vertex_handle vinf=cdt.infinite_vertex(); + for (int i=0; i<3; ++i) + { + if (indices_on_edges[i].empty()) continue; + std::size_t src_id=i, tgt_id=(i+1)%3; + //look for a sort axis + int coord = 0; + if (points[src_id].x()==points[tgt_id].x()) + { + coord=1; + if (points[src_id].y()==points[tgt_id].y()) + coord=2; + } + if (points[src_id][coord]>points[tgt_id][coord]) + std::swap(src_id, tgt_id); + + std::sort(indices_on_edges[i].begin(), indices_on_edges[i].end(), + [&](std::size_t id1, std::size_t id2) + { + return points[id1][coord]index(vinf)); + cdt.restore_Delaunay(vhandles[id]); // TODO maybe not each time but one global? + CGAL_assertion(cdt.is_valid()); + prev_id=id; + } + } +#endif + // then points in the interior + typedef typename Pointer_property_map::type Pmap; + typedef Spatial_sort_traits_adapter_2 Search_traits; + spatial_sort(indices.begin(), indices.end(), + Search_traits(make_property_map(points), cdt_traits)); + + typename CDT::Face_handle hint; + for (std::size_t i : indices) + { + vhandles[i] = cdt.insert(points[i], hint); + hint=vhandles[i]->face(); + } + + for (const std::pair& ids : triangle_data.segments) + { + CGAL_assertion(ids.first < vhandles.size()); + CGAL_assertion(ids.second < vhandles.size()); + CGAL_assertion( vhandles[ids.first]!= typename CDT::Vertex_handle() ); + CGAL_assertion( vhandles[ids.second]!= typename CDT::Vertex_handle() ); + cdt.insert_constraint(vhandles[ids.first], vhandles[ids.second]); + } CGAL_AUTOREF_COUNTER_INSTRUCTION(counter.timer3.stop();) +// extract new triangles for (typename CDT::Face_handle fh : cdt.finite_face_handles()) { if (orientation_flipped) @@ -895,21 +1107,30 @@ void autorefine_triangle_soup(PointRange& soup_points, // init the vector of triangles used for the autorefinement of triangles typedef CGAL::Exact_predicates_exact_constructions_kernel EK; + // even if the info is duplicated with Triangle_data::point, we keep this container + // so that we can use it in parallel calls of generate_subtriangles std::vector< std::array > triangles(tiid+1); + // vector of data for refining triangles + std::vector all_triangle_data(triangles.size()); Cartesian_converter to_exact; for(Input_TID f : intersected_faces) { - triangles[tri_inter_ids[f]]= CGAL::make_array( + std::size_t tid=tri_inter_ids[f]; + triangles[tid]= CGAL::make_array( to_exact( get(pm, soup_points[soup_triangles[f][0]]) ), to_exact( get(pm, soup_points[soup_triangles[f][1]]) ), to_exact( get(pm, soup_points[soup_triangles[f][2]]) ) ); + all_triangle_data[tid].points.resize(3); + all_triangle_data[tid].points[0]=triangles[tri_inter_ids[f]][0]; + all_triangle_data[tid].points[1]=triangles[tri_inter_ids[f]][1]; + all_triangle_data[tid].points[2]=triangles[tri_inter_ids[f]][2]; + all_triangle_data[tid].point_locations.resize(3); + all_triangle_data[tid].point_locations[0]=-1; + all_triangle_data[tid].point_locations[1]=-2; + all_triangle_data[tid].point_locations[2]=-3; } - std::vector< std::vector > > all_segments(triangles.size()); - std::vector< std::vector > all_points(triangles.size()); - std::vector< std::vector > all_in_triangle_ids(triangles.size()); - CGAL_PMP_AUTOREFINE_VERBOSE("compute intersections"); #ifdef CGAL_AUTOREF_USE_DEBUG_PARALLEL_TIMERS Real_timer t; @@ -928,7 +1149,7 @@ void autorefine_triangle_soup(PointRange& soup_points, const std::array& t1 = triangles[i1]; const std::array& t2 = triangles[i2]; - std::vector inter_pts; + std::vector> inter_pts; bool triangles_are_coplanar = autorefine_impl::collect_intersections(t1, t2, inter_pts); CGAL_assertion( @@ -941,23 +1162,54 @@ void autorefine_triangle_soup(PointRange& soup_points, switch(nbi) { case 1: - all_points[i1].push_back(inter_pts[0]); - all_points[i2].push_back(inter_pts[0]); + all_triangle_data[i1].add_point<1>(inter_pts[0]); + all_triangle_data[i2].add_point<2>(inter_pts[0]); break; case 2: - all_segments[i1].push_back(CGAL::make_array(inter_pts[0], inter_pts[1])); - all_segments[i2].push_back(CGAL::make_array(inter_pts[0], inter_pts[1])); - all_in_triangle_ids[i1].push_back(i2); - all_in_triangle_ids[i2].push_back(i1); + { + std::size_t src_id=all_triangle_data[i1].add_point<1>(inter_pts[0]), + tgt_id=all_triangle_data[i1].add_point<1>(inter_pts[1]); + if (!all_triangle_data[i1].on_same_edge(src_id, tgt_id)) + { + all_triangle_data[i1].segments.emplace_back(src_id, tgt_id); + all_triangle_data[i1].segment_input_triangle_ids.push_back(i2); + } + // + src_id=all_triangle_data[i2].add_point<2>(inter_pts[0]); + tgt_id=all_triangle_data[i2].add_point<2>(inter_pts[1]); + if (!all_triangle_data[i2].on_same_edge(src_id, tgt_id)) + { + all_triangle_data[i2].segments.emplace_back(src_id, tgt_id); + all_triangle_data[i2].segment_input_triangle_ids.push_back(i1); + } + } break; default: + { + std::vector ipt_ids1(nbi+1), ipt_ids2(nbi+1); + for (std::size_t i=0;i(inter_pts[i]); + ipt_ids2[i]=all_triangle_data[i2].add_point<2>(inter_pts[i]); } + ipt_ids1.back()=ipt_ids1.front(); + ipt_ids2.back()=ipt_ids2.front(); + + for (std::size_t i=0;i>> all_segments_ids(all_segments.size()); - auto deduplicate_inserted_segments = [&](std::size_t ti) { - if (!all_segments[ti].empty()) + if (!all_triangle_data[ti].segments.empty()) { - std::map point_id_map; + std::vector& points=all_triangle_data[ti].points; + std::vector>& segments=all_triangle_data[ti].segments; + std::vector indices(points.size()-3); + std::iota(indices.begin(), indices.end(),3); - auto get_point_id = [&](const EK::Point_3& pt) + std::sort(indices.begin(), indices.end(), [&points](std::size_t i, std::size_t j) + { return points[i] id_map(points.size()); + id_map[0]=0; + id_map[1]=1; + id_map[2]=2; + std::vector unique_ids; + unique_ids.reserve(indices.size()); + + //make points unique + create mapping between indices + for (std::size_t i=0; isecond; - }; - - - if (!all_points[ti].empty()) - { - using EPoint_3 = EK::Point_3; // workaround for MSVC 2022 bug - std::vector tmp; - tmp.swap(all_points[ti]); - for (const EPoint_3& pt : tmp) - get_point_id(pt); + std::size_t new_id=unique_ids.size()+3; + unique_ids.push_back(indices[i]); + id_map[indices[i]]=new_id; + while(i+1!=indices.size() && points[indices[i]]==points[indices[i+1]]) + { + id_map[indices[++i]]=new_id; + } } - std::size_t nbs = all_segments[ti].size(); - std::vector> filtered_segments; + CGAL_assertion(points.size() == all_triangle_data[ti].point_locations.size()); + if (unique_ids.size()==indices.size()) + // TODO: do we want to keep points sorted? if yes always swap the 3 containers + return; // no duplicates + + // now make points unique + using EPoint_3 = EK::Point_3; // workaround for MSVC 2022 bug + std::vector tmp; + std::vector tmp_locations; + tmp.reserve(unique_ids.size()+3); + tmp_locations.reserve(unique_ids.size()+3); + tmp.push_back(points[0]); + tmp.push_back(points[1]); + tmp.push_back(points[2]); + tmp_locations.push_back(-1); + tmp_locations.push_back(-2); + tmp_locations.push_back(-3); + for(std::size_t i : unique_ids) + { + tmp.push_back(points[i]); + tmp_locations.push_back(all_triangle_data[ti].point_locations[i]); + } + tmp.swap(points); + tmp_locations.swap(all_triangle_data[ti].point_locations); + CGAL_assertion(points.size() == all_triangle_data[ti].point_locations.size()); + + // now make segments unique + std::size_t nbs = segments.size(); + std::vector> filtered_segments; std::vector filtered_in_triangle_ids; filtered_segments.reserve(nbs); + filtered_in_triangle_ids.reserve(nbs); std::set> segset; for (std::size_t si=0; sisegments[si].first); + CGAL_assertion(id_map.size()>segments[si].second); + std::pair seg_ids = + CGAL::make_sorted_pair(id_map[segments[si].first], id_map[segments[si].second]); + if (segset.insert(seg_ids).second) { - all_segments_ids[ti].emplace_back(src_id, tgt_id); - filtered_in_triangle_ids.push_back(all_in_triangle_ids[ti][si]); + filtered_segments.push_back(seg_ids); + filtered_in_triangle_ids.push_back(all_triangle_data[ti].segment_input_triangle_ids[si]); } } - if (all_segments_ids[ti].size()!=nbs) - filtered_in_triangle_ids.swap(all_in_triangle_ids[ti]); + filtered_in_triangle_ids.swap(all_triangle_data[ti].segment_input_triangle_ids); + filtered_segments.swap(segments); + + CGAL_assertion(points.size()-3==std::set(std::next(points.begin(),3), points.end()).size()); + CGAL_assertion(points.size()==std::set(points.begin(), points.end()).size()); } }; @@ -1062,11 +1350,28 @@ void autorefine_triangle_soup(PointRange& soup_points, auto refine_triangles = [&](std::size_t ti) { - if (all_segments[ti].empty() && all_points[ti].empty()) + if (all_triangle_data[ti].points.size()==3) new_triangles.push_back({triangles[ti], ti}); else { - autorefine_impl::generate_subtriangles(ti, all_segments_ids[ti], all_points[ti], all_in_triangle_ids[ti], intersecting_triangles, coplanar_triangles, triangles, new_triangles); +#ifdef CGAL_AUTOREF_USE_FIXED_PROJECTION_TRAITS + const std::array& t = triangles[ti]; + typename EK::Vector_3 orth = CGAL::normal(t[0], t[1], t[2]); // TODO::avoid construction? + int c = CGAL::abs(orth[0]) > CGAL::abs(orth[1]) ? 0 : 1; + c = CGAL::abs(orth[2]) > CGAL::abs(orth[c]) ? 2 : c; + + if (c == 0) { + autorefine_impl::generate_subtriangles(ti, all_triangle_data[ti], intersecting_triangles, coplanar_triangles, triangles, new_triangles); + } + else if (c == 1) { + autorefine_impl::generate_subtriangles(ti, all_triangle_data[ti], intersecting_triangles, coplanar_triangles, triangles, new_triangles); + } + else if (c == 2) { + autorefine_impl::generate_subtriangles(ti, all_triangle_data[ti], intersecting_triangles, coplanar_triangles, triangles, new_triangles); + } +#else + autorefine_impl::generate_subtriangles(ti, all_triangle_data[ti], intersecting_triangles, coplanar_triangles, triangles, new_triangles); +#endif } #ifdef CGAL_AUTOREF_USE_PROGRESS_DISPLAY diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h index b3aaf70604f..a071b3591d0 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/distance.h @@ -1449,6 +1449,8 @@ bounded_error_squared_Hausdorff_distance_impl(const TriangleMesh1& tm1, using Point_3 = typename Kernel::Point_3; using Triangle_3 = typename Kernel::Triangle_3; + auto midpoint = Kernel().construct_midpoint_3_object(); + #ifdef CGAL_HAUSDORFF_DEBUG std::cout << " -- Bounded Hausdorff --" << std::endl; std::cout << "error bound: " << error_bound << std::endl; @@ -1645,9 +1647,9 @@ bounded_error_squared_Hausdorff_distance_impl(const TriangleMesh1& tm1, } // Subdivide the triangle into four smaller triangles. - const Point_3 v01 = CGAL::midpoint(v0, v1); - const Point_3 v02 = CGAL::midpoint(v0, v2); - const Point_3 v12 = CGAL::midpoint(v1, v2); + const Point_3 v01 = midpoint(v0, v1); + const Point_3 v02 = midpoint(v0, v2); + const Point_3 v12 = midpoint(v1, v2); const std::array sub_triangles = { Triangle_3(v0, v01, v02), Triangle_3(v1 , v01, v12), Triangle_3(v2, v02, v12), Triangle_3(v01, v02, v12) }; @@ -2372,17 +2374,19 @@ typename Kernel::FT recursive_hausdorff_subdivision(const typename Kernel::Point using FT = typename Kernel::FT; using Point_3 = typename Kernel::Point_3; + auto midpoint = Kernel().construct_midpoint_3_object(); + auto squared_distance = Kernel().compute_squared_distance_3_object(); // If all edge lengths of the triangle are below the error bound, // return the maximum of the distances of the three points to TM2 (via TM2_tree). - const FT max_squared_edge_length = (CGAL::max)((CGAL::max)(CGAL::squared_distance(p0, p1), - CGAL::squared_distance(p0, p2)), - CGAL::squared_distance(p1, p2)); + const FT max_squared_edge_length = (CGAL::max)((CGAL::max)(squared_distance(p0, p1), + squared_distance(p0, p2)), + squared_distance(p1, p2)); if(max_squared_edge_length < sq_error_bound) { - return (CGAL::max)((CGAL::max)(CGAL::squared_distance(p0, tm2_tree.closest_point(p0)), - CGAL::squared_distance(p1, tm2_tree.closest_point(p1))), - CGAL::squared_distance(p2, tm2_tree.closest_point(p2))); + return (CGAL::max)((CGAL::max)(squared_distance(p0, tm2_tree.closest_point(p0)), + squared_distance(p1, tm2_tree.closest_point(p1))), + squared_distance(p2, tm2_tree.closest_point(p2))); } // Else subdivide the triangle and proceed recursively. diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/experimental/experimental_code.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/experimental/experimental_code.h deleted file mode 100644 index a33bd8964be..00000000000 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/experimental/experimental_code.h +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright (c) 2015 GeometryFactory (France). -// All rights reserved. -// -// This file is part of CGAL (www.cgal.org). -// -// $URL$ -// $Id$ -// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial -// -// -// Author(s) : Ilker O. Yaz - -/************************************************************************ - * Currently not useful code pieces, in case there will be any need in the future. - * Also they might not work when they plugged-in due to recent changes. - ************************************************************************/ - -// It can produce a patch from both complete and incomplete lambda -// WARNING: Not working good for all cases -// For holes, this code first close them then erase them. -// However the algorithm might produce holes which are invalid to close (closing them breaks edge manifoldness, so erasing doesn't work) -template -struct Tracer_polyhedron_incomplete -{ - typedef typename Polyhedron::Halfedge_handle Halfedge_handle; - typedef typename Polyhedron::Facet_handle Facet_handle; - - Tracer_polyhedron_incomplete(OutputIteratorPatch out, - OutputIteratorHole out_hole, - Polyhedron& polyhedron, - std::vector& P) - : out(out), out_hole(out_hole), polyhedron(polyhedron), P(P) - { } - - template - void - operator()(const LookupTable& lambda, int i, int k) - { - std::vector facets_to_delete; - (*this)(lambda, i, k, facets_to_delete, true); - for(typename std::vector::iterator it = facets_to_delete.begin(); - it != facets_to_delete.end(); ++it) - { - *out_hole++=(*it)->halfedge(); // each deleted facet corresponds to a new hole - polyhedron.erase_facet((*it)->halfedge()); - } - } - -private: - template - Halfedge_handle - operator()(const LookupTable& lambda, - int i, int k, - std::vector& facets_to_delete, - bool last) - { - if(i + 1 == k) { return P[i+1]; } - - Halfedge_handle h, g; - if(i+2 == k){ - - if(last) - { h = polyhedron.fill_hole(P[i+1]); } - else - { h = polyhedron.add_facet_to_border(P[i+1]->prev(), P[i+2/*k*/]); } - - CGAL_assertion(h->facet() != Facet_handle()); - - int la = lambda.get(i, k); - if(la == -1) { - facets_to_delete.push_back(h->facet()); - } - else { - *out++ = h->facet(); - } - return h->opposite(); - } - else - { - int la = lambda.get(i, k); - if(la == -1) { - if(last) - { h = polyhedron.fill_hole(P[i+1]); } - else - { h = polyhedron.add_facet_to_border(P[i+1]->prev(), P[i+2/*k*/]); } - facets_to_delete.push_back(h->facet()); - return h->opposite(); - } - else { - h = operator()(lambda, i, la, facets_to_delete, false); - g = operator()(lambda, la, k, facets_to_delete, false); - - if(last) - { h = polyhedron.fill_hole(g); } - else - { h = polyhedron.add_facet_to_border(h->prev(), g); } - - CGAL_assertion(h->facet() != Facet_handle()); - *out++ = h->facet(); - return h->opposite(); - } - } - } - -public: - OutputIteratorPatch out; - OutputIteratorHole out_hole; - Polyhedron& polyhedron; - std::vector& P; -}; - -// Try closing holes by gathering incomplete patches together (an external approach) -template -OutputIterator -triangulate_hole_polyline_incomplete(InputIterator pbegin, InputIterator pend, - InputIterator qbegin, InputIterator qend, - OutputIterator out) -{ - - typedef typename std::iterator_traits::value_type Point_3; - typedef Weight_incomplete Weight; - typedef Weight_calculator WC; - - typedef std::vector > Facet_vector; /* deliberately not OutputIteratorValueType*/ - typedef std::back_insert_iterator OutIt; - typedef Tracer_polyline_incomplete Tracer; - typedef std::pair Range; - - std::vector P(pbegin, pend); - std::vector Q(qbegin, qend); - - if(P.front() != P.back()){ - P.push_back(P.front()); - if( !Q.empty() && P.size() > Q.size()) { - Q.push_back(Q.front()); - } - } - - std::vector patch_facets; - std::stack remaining_holes; - - remaining_holes.push(Range(0, P.size() -2)); - - while(!remaining_holes.empty()) { - Range h = remaining_holes.top(); - remaining_holes.pop(); - - std::vector P_r(&P[h.first], (&P[h.second]) + 1); - std::vector Q_r; - if(!Q.empty()) { Q_r.insert(Q_r.begin(), &Q[h.first], (&Q[h.second]) + 1); }; - - Facet_vector new_facets; - OutIt new_facets_out(new_facets); - std::vector new_holes; - std::back_insert_iterator > new_holes_out(new_holes); - Tracer tracer(new_facets_out, new_holes_out); - - triangulate_hole_polyline(P_r, Q_r, tracer, WC(), true, true); - - if(new_facets.empty()) { - new_holes.clear(); - //triangulate_hole_polyline(P_r, Q_r, tracer, WC(), false, true); - if(new_facets.empty()) { - // if no patch facets created and also we are using brute force approach, then there is nothing to do, - // leave `out` intact and return - CGAL_warning_msg(false, "Returning no output. Filling hole with incomplete patches is not successful!"); - return out; - } - } - // put new borders to remaining_holes - for(typename std::vector::iterator it = new_holes.begin(); it != new_holes.end(); ++it) { - remaining_holes.push(std::make_pair(it->first + h.first, it->second + h.first)); - } - tracer.remaining_holes.clear(); - for(Facet_vector::iterator it = new_facets.begin(); it != new_facets.end(); ++it) { - patch_facets.push_back( - OutputIteratorValueType(it->get<0>() + h.first, it->get<1>() + h.first, it->get<2>() + h.first)); - } - } - - return std::copy(patch_facets.begin(), patch_facets.end(), out); -} - -// (for Polyhedron_3) Try closing holes by gathering incomplete patches together (an external approach) -template -std::pair -triangulate_hole_Polyhedron_incomplete(Polyhedron& polyhedron, - typename Polyhedron::Halfedge_handle border_halfedge, - OutputIterator out) -{ - typedef typename Polyhedron::Halfedge_handle Halfedge_handle; - typedef typename Polyhedron::Facet_handle Facet_handle; - - Weight_min_max_dihedral_and_area weight_total = Weight_min_max_dihedral_and_area::DEFAULT(); - std::vector patch_facets; - std::stack remaining_holes; - remaining_holes.push(border_halfedge); - - while(!remaining_holes.empty()) { - Halfedge_handle h = remaining_holes.top(); - remaining_holes.pop(); - std::vector holes_h; - - std::size_t patch_facets_before = patch_facets.size(); - Weight_min_max_dihedral_and_area w = - triangulate_hole_Polyhedron(polyhedron, h, back_inserter(patch_facets), back_inserter(holes_h), true); - - if(patch_facets_before == patch_facets.size()) { - holes_h.clear(); - patch_facets_before = patch_facets.size(); - w = triangulate_hole_Polyhedron(polyhedron, h, back_inserter(patch_facets), back_inserter(holes_h), false); - if(patch_facets_before == patch_facets.size()) { - // if no patch facets created and also we are using brute force approach, then there is nothing to do, - // leave `out` intact and return - CGAL_warning_msg(false, "Returning no output. Filling hole with incomplete patches is not successful!"); - return std::make_pair(out, Weight_min_max_dihedral_and_area::NOT_VALID()); - } - } - // put new borders to remaining_holes and update weight - for(typename std::vector::iterator it = holes_h.begin(); it != holes_h.end(); ++it) { - //remaining_holes.push(*it); - } - weight_total = weight_total + w; - } - - out = std::copy(patch_facets.begin(), patch_facets.end(), out); - return std::make_pair(out, weight_total); -} diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h index a8d45d8b867..13cad81b410 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/interpolated_corrected_curvatures.h @@ -76,20 +76,6 @@ struct Principal_curvatures_and_directions { namespace internal { -template -typename GT::FT average_edge_length(const PolygonMesh& pmesh) { - const std::size_t n = edges(pmesh).size(); - if (n == 0) - return 0; - - typename GT::FT avg_edge_length = 0; - for (auto e : edges(pmesh)) - avg_edge_length += edge_length(e, pmesh); - - avg_edge_length /= static_cast(n); - return avg_edge_length; -} - template struct Vertex_measures { typename GT::FT area_measure = 0; @@ -650,7 +636,7 @@ void interpolated_corrected_curvatures_one_vertex( typename GT::FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); // calculate avg_edge_length as it is used in case radius is 0, and in the principal curvature computation later - typename GT::FT avg_edge_length = average_edge_length(pmesh); + typename GT::FT avg_edge_length = average_edge_length(pmesh); // if the radius is 0, we use a small epsilon to expand the ball (scaled with the average edge length) if (is_zero(radius)) @@ -799,7 +785,7 @@ private: // if no radius is given, we pass -1 which will make the expansion be only on the incident faces instead of a ball const FT radius = choose_parameter(get_parameter(np, internal_np::ball_radius), -1); - avg_edge_length = average_edge_length(pmesh); + avg_edge_length = average_edge_length(pmesh); set_ball_radius(radius); // check which curvature maps are provided by the user (determines which curvatures are computed) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h index 8f1c60347ee..520ebbec9be 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h @@ -217,6 +217,25 @@ squared_edge_length(typename boost::graph_traits::edge_descriptor e return squared_edge_length(halfedge(e, pmesh), pmesh, np); } +template +typename GetGeomTraits::type::FT +average_edge_length(const PolygonMesh& pmesh, + const NamedParameters& np = parameters::default_values()) +{ + typedef typename GetGeomTraits::type GT; + + const std::size_t n = edges(pmesh).size(); + CGAL_assertion(n > 0); + + typename GT::FT avg_edge_length = 0; + for (auto e : edges(pmesh)) + avg_edge_length += edge_length(e, pmesh, np); + + avg_edge_length /= static_cast(n); + return avg_edge_length; +} + /** * \ingroup PMP_measure_grp * diff --git a/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h b/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h index b9892a67f16..b883e729935 100644 --- a/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h +++ b/Polygon_mesh_processing/include/CGAL/polygon_mesh_processing.h @@ -17,6 +17,11 @@ * the free functions of this package. */ +#ifndef CGAL_POLYGON_MESH_PROCESSING_H +#define CGAL_POLYGON_MESH_PROCESSING_H + +#include + #include #include #include @@ -49,3 +54,6 @@ #include #include #include +#include + +#endif //CGAL_POLYGON_MESH_PROCESSING_H diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/delaunay_remeshing_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/delaunay_remeshing_test.cpp index d1d70fdd1e2..74a968ec095 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/delaunay_remeshing_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/delaunay_remeshing_test.cpp @@ -1,11 +1,12 @@ -#include - -#include -#include #include #include #include +#include +#include + +#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/extrude_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/extrude_test.cpp index b51bf4553f0..0bada4492f9 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/extrude_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/extrude_test.cpp @@ -1,7 +1,9 @@ +#include + #include #include #include -#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/fairing_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/fairing_test.cpp index ac066d3ae1a..df1531c6429 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/fairing_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/fairing_test.cpp @@ -1,8 +1,9 @@ -#include -#include +#include + #include -#include +#include +#include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp index 3050a34753f..e406db12ec7 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp @@ -1,11 +1,11 @@ #include -#include -#include +#include #include #include -#include +#include +#include #include @@ -376,4 +376,3 @@ int main(int argc, char* argv[]) std::cerr << "All done." << std::endl; return 0; } - diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_mesh_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_mesh_test.cpp index ce4855f964f..4c90f3a1761 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_mesh_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_mesh_test.cpp @@ -1,8 +1,10 @@ -#include -#include +#include + #include #include -#include + +#include +#include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_soup_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_soup_test.cpp index f3c541ab65c..b72e0397fb1 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_soup_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/orient_polygon_soup_test.cpp @@ -1,18 +1,20 @@ -#include -#include - -#include -#include - -#include -#include -#include #include #include #include #include #include +#include +#include + +#include +#include + +#include +#include + +#include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp index 88a70ee95c0..20a8e8993a1 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_compute_normals_test.cpp @@ -1,24 +1,25 @@ // #define CGAL_PMP_COMPUTE_NORMAL_DEBUG_PP -#include -#include +#include +#include +#include #include #include #include -#include -#include -#include + +#include +//#include #include #include typedef CGAL::Exact_predicates_inexact_constructions_kernel EPICK; -typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPECK; +//typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EPECK; typedef CGAL::Surface_mesh EPICK_SM; -typedef CGAL::Surface_mesh EPECK_SM; +//typedef CGAL::Surface_mesh EPECK_SM; namespace PMP = CGAL::Polygon_mesh_processing; @@ -100,8 +101,8 @@ void test(const Mesh& mesh, { if (PMP::is_degenerate_triangle_face(f, mesh)) { - if (std::is_same()) - assert(get(fnormals, f) == CGAL::NULL_VECTOR); +// if (std::is_same()) +// assert(get(fnormals, f) == CGAL::NULL_VECTOR); } else assert(get(fnormals, f) != CGAL::NULL_VECTOR); diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_do_intersect_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_do_intersect_test.cpp index e0696004418..f9a083c580e 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_do_intersect_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/pmp_do_intersect_test.cpp @@ -1,17 +1,17 @@ +#include + +#include + +#include +#include + +#include #include #include #include #include -#include -#include -#include - -#include - -#include - typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp index 0421bb411fc..7029c29a2f8 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_polyhedron_boundary_test.cpp @@ -1,7 +1,6 @@ - -#include #include #include +#include #include "point_inside_helpers.h" diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp index b0be112cfbc..ef7bf8f9e99 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/point_inside_surface_mesh_test.cpp @@ -1,11 +1,11 @@ +#include -#include -#include #include #include #include -#include +#include +#include #include "point_inside_helpers.h" diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp index add77378cbc..d74eb2fba20 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/polygon_mesh_slicer_test.cpp @@ -1,20 +1,23 @@ // #define USE_SURFACE_MESH -#include -#include +#include + #ifdef USE_SURFACE_MESH #include #else #include #endif + #include -#include #include #include #include #include +#include +#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_quality_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_quality_test.cpp index 7ab20cda424..ada019dee94 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_quality_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_quality_test.cpp @@ -1,9 +1,11 @@ -#include -#include #include #include #include +#include + +#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp index 40067cea512..e8d69008fb0 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test.cpp @@ -7,17 +7,18 @@ //#define CGAL_PMP_REMESHING_VERY_VERBOSE //#define CGAL_PMP_REMESHING_EXPENSIVE_DEBUG -#include - -#include - #include #include #include #include #include +#include + +#include + #include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp index eeebc63b301..91deed70c46 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_test_P_SM_OM.cpp @@ -1,14 +1,17 @@ -#include +#include + #include #include -#include -#include #include #include #include #include #include -#include + +#include + +#include +#include namespace PMP = CGAL::Polygon_mesh_processing; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_with_isolated_constraints_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_with_isolated_constraints_test.cpp index 4e7ebe96092..115f245a9bb 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_with_isolated_constraints_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/remeshing_with_isolated_constraints_test.cpp @@ -1,11 +1,12 @@ -#include -#include - -#include -#include #include #include +#include +#include +#include + +#include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp index 1d1991ee86b..1c26f47456a 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_polyhedron_test.cpp @@ -1,15 +1,15 @@ -#include -#include -#include -#include +#include + +#include +#include #include #include -#include -#include - -#include +#include +#include +#include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_surface_mesh_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_surface_mesh_test.cpp index 6e017c948c0..1e64267703a 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_surface_mesh_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_surface_mesh_test.cpp @@ -1,12 +1,13 @@ -#include -#include - -#include #include #include + +#include #include #include +#include +#include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp index e067e13c129..2cddabbdb96 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/self_intersection_triangle_soup_test.cpp @@ -1,11 +1,12 @@ -#include -#include - -#include #include #include #include + #include +#include + +#include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/surface_intersection_sm_poly.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/surface_intersection_sm_poly.cpp index 04f7ddf5ee9..646f75e85db 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/surface_intersection_sm_poly.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/surface_intersection_sm_poly.cpp @@ -1,15 +1,16 @@ -#include +#include + #include #include #include #include #include #include - -#include #include #include +#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp index 3af3402a5f2..e04e07ba556 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_autorefinement.cpp @@ -1,5 +1,3 @@ -#include -#include #include #include @@ -8,6 +6,9 @@ #include +#include +#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_coref_epic_points_identity.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_coref_epic_points_identity.cpp index 03a50620020..4c12d15f5de 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_coref_epic_points_identity.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_coref_epic_points_identity.cpp @@ -1,6 +1,6 @@ -#include -#include #include +#include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp index 31e4f9c71f2..f5f59e4419b 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefine.cpp @@ -1,7 +1,9 @@ -#include +#include + #include #include -#include + +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints.cpp index 6508c453337..b88c1c71272 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_and_constraints.cpp @@ -1,6 +1,6 @@ -#include -#include #include +#include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cpp index 8356106a9b1..49a182d2bd3 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_corefinement_bool_op.cpp @@ -2,9 +2,9 @@ // #define CGAL_COREFINEMENT_DEBUG #define CGAL_USE_DERIVED_SURFACE_MESH -#include -#include #include +#include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_decimation_of_planar_patches.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_decimation_of_planar_patches.cpp index 8666d862dc4..7ee0c486106 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_decimation_of_planar_patches.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_decimation_of_planar_patches.cpp @@ -1,9 +1,3 @@ -#include -#ifdef USE_POLYHEDRON -#include -#else -#include -#endif #include #include #include @@ -12,6 +6,14 @@ #include #include +#ifdef USE_POLYHEDRON +#include +#else +#include +#endif + +#include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_degenerate_pmp_clip_split_corefine.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_degenerate_pmp_clip_split_corefine.cpp index 0decb116499..1027c841cfb 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_degenerate_pmp_clip_split_corefine.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_degenerate_pmp_clip_split_corefine.cpp @@ -1,8 +1,7 @@ -#include #include #include #include - +#include // #define CGAL_DEBUG_PMP_CLIP // TODO: test coref diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_detect_features.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_detect_features.cpp index e2d84414b1f..5e558a287d0 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_detect_features.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_detect_features.cpp @@ -1,7 +1,7 @@ -#include -#include - #include +#include +#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_does_bound_a_volume.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_does_bound_a_volume.cpp index b19f892b98c..e8c2dbc8678 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_does_bound_a_volume.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_does_bound_a_volume.cpp @@ -1,6 +1,6 @@ -#include -#include #include +#include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_hausdorff_bounded_error_distance.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_hausdorff_bounded_error_distance.cpp index dc5269ac716..3e011b42fee 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_hausdorff_bounded_error_distance.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_hausdorff_bounded_error_distance.cpp @@ -4,22 +4,24 @@ // Use this def in order to get all DEBUG info related to the bounded-error Hausdorff code! #define CGAL_HAUSDORFF_DEBUG -#include -#include -#include -#include -#include - -#include -#include -#include #include #include #include #include #include +#include +#include +#include + #include +#include +#include + +#include +#include +#include + using SCK = CGAL::Simple_cartesian; using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel; using EPECK = CGAL::Exact_predicates_exact_constructions_kernel; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp index c6a578c795a..412443a42c7 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_interpolated_corrected_curvatures.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -6,6 +5,8 @@ #include #include +#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_is_polygon_soup_a_polygon_mesh.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_is_polygon_soup_a_polygon_mesh.cpp index ce72e576c50..a2843ecae8c 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_is_polygon_soup_a_polygon_mesh.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_is_polygon_soup_a_polygon_mesh.cpp @@ -1,17 +1,18 @@ -#include -#include - -#include -#include +#include +#include +#include #include #include #include -#include -#include -#include + #include +#include + +#include +#include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_isolevel_refinement.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_isolevel_refinement.cpp index 9e07c831435..c61697135dd 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_isolevel_refinement.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_isolevel_refinement.cpp @@ -1,9 +1,9 @@ -#include -#include - #include #include +#include +#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_merging_border_vertices.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_merging_border_vertices.cpp index 2bb8c3cc3fb..228f3b4c558 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_merging_border_vertices.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_merging_border_vertices.cpp @@ -1,12 +1,10 @@ -#include -#include - #include -#include + +#include +#include #include - typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef CGAL::Surface_mesh Surface_mesh; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_mesh_smoothing.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_mesh_smoothing.cpp index 986bdca5b53..de001979aad 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_mesh_smoothing.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_mesh_smoothing.cpp @@ -1,9 +1,10 @@ -#include +#include +#include #include #include -#include -#include + +#include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp index 827e169310b..03076dc39d6 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_orient_cc.cpp @@ -1,10 +1,12 @@ -#include -#include - -#include #include #include + +#include +#include + +#include #include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp index c564403312a..eb38a6ad144 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_clip.cpp @@ -1,10 +1,11 @@ -#include #include -#include -#include #include -#include +#include +#include + +#include + #include #include @@ -879,5 +880,3 @@ int main() std::cout << "Done!" << std::endl; return EXIT_SUCCESS; } - - diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_collision_detection.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_collision_detection.cpp index e8e28c9c2bd..986f3b8768e 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_collision_detection.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_collision_detection.cpp @@ -1,8 +1,9 @@ -#include +#include + #include #include -#include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp index d0554ebc9a6..c0b57f62449 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_locate.cpp @@ -1,6 +1,4 @@ -#include -#include -#include +#include // Graphs #include @@ -9,7 +7,9 @@ #include #include -#include +#include +#include +#include #include #include @@ -23,12 +23,11 @@ #include #include #include -#include #include #include -#include +#include #include #include #include @@ -785,7 +784,7 @@ void test_2D_surface_mesh(const std::string fname, CGAL::Random& rnd) if(!input || !(input >> tm)) { std::cerr << "Error: cannot read file."; - return; + exit(1); } test_locate(tm, rnd); @@ -805,7 +804,7 @@ void test_surface_mesh_3D(const std::string fname, CGAL::Random& rnd) if(!input || !(input >> tm)) { std::cerr << "Error: cannot read file."; - return; + exit(1); } typedef typename boost::property_map::const_type VertexPointMap; @@ -831,7 +830,7 @@ void test_surface_mesh_projection(const std::string fname, CGAL::Random& rnd) if(!input || !(input >> tm)) { std::cerr << "Error: cannot read file."; - return; + exit(1); } const auto& proj_vpm = tm.template add_property_map> poly)) { std::cerr << "Error: cannot read file."; - return; + exit(1); } test_locate(poly, rnd); @@ -870,7 +869,7 @@ void test(CGAL::Random& rnd) { test_2D_triangulation("data/stair.xy", rnd); // test_2D_surface_mesh("data/blobby_2D.off", rnd); // temporarily disabled, until Surface_mesh's IO is "fixed" - test_surface_mesh_3D("meshes/mech-holes-shark.off", rnd); + test_surface_mesh_3D(CGAL::data_file_path("meshes/mech-holes-shark.off"), rnd); test_surface_mesh_projection("data/unit-grid.off", rnd); test_polyhedron("data-coref/elephant_split_2.off", rnd); } diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_manifoldness.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_manifoldness.cpp index bd48a31364a..4bf08dd6c34 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_manifoldness.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_manifoldness.cpp @@ -1,10 +1,11 @@ -#include +#include #include #include #include -#include + +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_non_conforming_snapping.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_non_conforming_snapping.cpp index d091b7a3d25..67390e17648 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_non_conforming_snapping.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_non_conforming_snapping.cpp @@ -1,21 +1,21 @@ //#define CGAL_PMP_SNAP_DEBUG_PP //#define CGAL_PMP_SNAP_DEBUG_OUTPUT -#include -#include - -#include -#include -#include - #include #include #include #include +#include +#include +#include + #include #include +#include +#include + #include #include #include @@ -169,4 +169,3 @@ int main(int, char**) return EXIT_SUCCESS; } - diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_np_function.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_np_function.cpp index a9b59a6ffaa..ed5d9677165 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_np_function.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_np_function.cpp @@ -1,12 +1,15 @@ -#include +#include +#include +#include + #include + +#include + #include #include #include -#include -#include -#include namespace CGAL { template -#include -#include -#include -#include #include #include +#include + +#include +#include + +#include +#include namespace PMP = CGAL::Polygon_mesh_processing; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_read_polygon_mesh.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_read_polygon_mesh.cpp index 1727cdfaee4..447fe007c99 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_read_polygon_mesh.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_read_polygon_mesh.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_remove_border_edge.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_remove_border_edge.cpp index a94e1adadc6..e832627b162 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_remove_border_edge.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_remove_border_edge.cpp @@ -1,7 +1,9 @@ -#include +#include + #include #include -#include + +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_degeneracies.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_degeneracies.cpp index de7e7a2d49e..847e9dbf615 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_degeneracies.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_degeneracies.cpp @@ -1,14 +1,14 @@ #define CGAL_PMP_DEBUG_SMALL_CC_REMOVAL -#include -#include +#include +#include #include #include #include -#include -#include +#include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_self_intersections.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_self_intersections.cpp index 822ab16169a..116e0d57db1 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_self_intersections.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_repair_self_intersections.cpp @@ -3,12 +3,12 @@ #define CGAL_PMP_REMOVE_SELF_INTERSECTION_DEBUG #define CGAL_PMP_REMOVE_SELF_INTERSECTION_OUTPUT -#include -#include - #include #include +#include +#include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_snapping.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_snapping.cpp index fa5fd3ba479..3c2355717b9 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_snapping.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_snapping.cpp @@ -1,18 +1,18 @@ // #define CGAL_PMP_SNAP_DEBUG_PP -#include -#include +#include +#include +#include #include #include #include -#include -#include -#include - #include +#include +#include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_transform.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_transform.cpp index 65d64eb1cbe..695d4862623 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_transform.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_transform.cpp @@ -1,11 +1,12 @@ -#include #include -#include -#include #include #include +#include + +#include +#include namespace PMP = CGAL::Polygon_mesh_processing; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_triangle.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_triangle.cpp index 6009318480d..3bf1d761934 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_triangle.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_pmp_triangle.cpp @@ -1,8 +1,10 @@ #include -#include + #include #include +#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::Point_3 Point_3; typedef K::Triangle_3 Triangle_3; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_remove_caps_needles.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_remove_caps_needles.cpp index fa80d93caf0..505a731ed89 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_remove_caps_needles.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_remove_caps_needles.cpp @@ -1,12 +1,13 @@ -#include -#include - #include -#include #include + #include #include +#include +#include + +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_repair_polygon_soup.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_repair_polygon_soup.cpp index 4b9b0abbd3e..e57d9b6903b 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_repair_polygon_soup.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_repair_polygon_soup.cpp @@ -1,11 +1,11 @@ #define CGAL_PMP_REPAIR_POLYGON_SOUP_VERBOSE_PP -#include - #include #include +#include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_predicates.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_predicates.cpp index 7b1ef20f6a6..17228d4603f 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_predicates.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_predicates.cpp @@ -1,14 +1,15 @@ -#include +#include +#include #include -#include -#include - #include +#include + #include #include +#include typedef CGAL::Exact_predicates_inexact_constructions_kernel K; typedef K::FT FT; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_smoothing.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_smoothing.cpp index 7ed64301e90..3d726ff3d24 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_smoothing.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_shape_smoothing.cpp @@ -1,13 +1,13 @@ #define CGAL_PMP_SMOOTHING_DEBUG -#include +#include +#include #include #include #include -#include -#include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_simplify_polylines_pmp.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_simplify_polylines_pmp.cpp index de196c65e64..770b055db8d 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_simplify_polylines_pmp.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_simplify_polylines_pmp.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_split_volume.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_split_volume.cpp index 167625a4bb5..a6ef851b78d 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_split_volume.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_split_volume.cpp @@ -1,8 +1,11 @@ -#include -#include #include #include #include + +#include + +#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp index 1b78eb8ca75..d5d2fa63b9d 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/test_stitching.cpp @@ -1,15 +1,17 @@ // #define CGAL_PMP_STITCHING_DEBUG_PP -#include -#include -#include -#include +#include +#include #include #include #include -#include -#include + +#include +#include + +#include +#include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp index 66085b83c74..8b7b8f34556 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_faces_test.cpp @@ -1,6 +1,3 @@ -#include -#include -#include #include @@ -10,6 +7,11 @@ #include #include +#include + +#include +#include + #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp index 133060f0288..5b87e5dff42 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_no_delaunay_test.cpp @@ -1,23 +1,22 @@ //#define POLY -#include -#include #include +#include + #ifdef POLY #include #else #include #endif + #include - -#include - -#include - #include #include +#include +#include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp index 146eed2fd87..d2c69c01591 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_Polyhedron_3_test.cpp @@ -1,6 +1,8 @@ //#define POLY -#include +#include + + #ifdef POLY #include #else @@ -10,9 +12,10 @@ #include #include #include -#include #include +#include + #include #include #include diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp index 7e96e187d91..3cf12f05701 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_polyline_test.cpp @@ -1,6 +1,4 @@ - -#include -#include +#include #include #include @@ -10,7 +8,9 @@ #include #include -#include +#include +#include + typedef CGAL::Exact_predicates_inexact_constructions_kernel Epic; typedef CGAL::Exact_predicates_exact_constructions_kernel Epec; diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_with_cdt_2_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_with_cdt_2_test.cpp index 8f1ede58b93..06bfc441eef 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_with_cdt_2_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/triangulate_hole_with_cdt_2_test.cpp @@ -1,17 +1,20 @@ +#define CGAL_NO_CDT_2_WARNING + +#include +#include + +#include +#include + +#include +#include + #include #include #include #include #include -#define CGAL_NO_CDT_2_WARNING - -#include -#include -#include -#include -#include -#include template< class PolygonMesh, diff --git a/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction/internal/alpha_shape_mesh.h b/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction/internal/alpha_shape_mesh.h index 99fdcbdab99..20fcb339b2f 100644 --- a/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction/internal/alpha_shape_mesh.h +++ b/Polygonal_surface_reconstruction/include/CGAL/Polygonal_surface_reconstruction/internal/alpha_shape_mesh.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Liangliang Nan diff --git a/Polyhedron/demo/Polyhedron/CMakeLists.txt b/Polyhedron/demo/Polyhedron/CMakeLists.txt index a8235cdb832..172b5bd63e9 100644 --- a/Polyhedron/demo/Polyhedron/CMakeLists.txt +++ b/Polyhedron/demo/Polyhedron/CMakeLists.txt @@ -196,7 +196,19 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND) message(STATUS "Qt6WebSockets was found. Using WebSockets is therefore possible.") endif() - #compilation_of__demo_framework is defined in polyhedron_demo_macros.cmake + # This custom target is useless. It is used only as a flag to + # detect that the test has already been created. + add_custom_target("compilation_of__demo_framework") + cgal_add_compilation_test(demo_framework) + if(TEST "compilation of demo_framework") + set_property(TEST "compilation of demo_framework" + APPEND PROPERTY LABELS "CGAL_build_system" "Installation" "${PROJECT_NAME}") + set_property(TEST "compilation of demo_framework" + APPEND PROPERTY FIXTURES_SETUP "demo_framework_SetupFixture") + set_property(TEST "compilation of demo_framework" + APPEND PROPERTY DEPENDS "check build system" "compilation of CGAL_Qt6_moc_and_resources") + endif() + # Let's define `three_EXPORT` during the compilation of `demo_framework`, # in addition of `demo_framework_EXPORT` (defined automatically by # CMake). That is to deal with the visibility of symbols of @@ -219,13 +231,16 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND) ${Show_point_dialogUI_FILES}) target_link_libraries(point_dialog PUBLIC Qt6::OpenGLWidgets Qt6::Gui Qt6::Widgets) + cgal_add_compilation_test(point_dialog) macro(add_item item_name) add_library(${item_name} SHARED ${ARGN}) target_link_libraries( ${item_name} PUBLIC demo_framework CGAL::CGAL_Qt6 Qt6::OpenGLWidgets Qt6::Gui Qt6::Widgets) + cgal_add_compilation_test(${item_name}) add_to_cached_list(CGAL_EXECUTABLE_TARGETS ${item_name}) + CGAL_install_hooks() endmacro(add_item) add_item(scene_triangulation_3_item Scene_triangulation_3_item.cpp) @@ -360,9 +375,11 @@ if(CGAL_Qt6_FOUND AND Qt6_FOUND) target_compile_definitions(demo_framework PRIVATE -DCGAL_USE_WEBSOCKETS) target_link_libraries(polyhedron_demo PRIVATE Qt6::WebSockets) endif() + cgal_add_compilation_test(polyhedron_demo) add_executable(Polyhedron_3 Polyhedron_3.cpp) target_link_libraries(Polyhedron_3 PRIVATE polyhedron_demo) add_to_cached_list(CGAL_EXECUTABLE_TARGETS Polyhedron_3) + cgal_add_compilation_test(Polyhedron_3) target_link_libraries(Polyhedron_3 PRIVATE demo_framework) diff --git a/Polyhedron/demo/Polyhedron/File_loader_dialog.h b/Polyhedron/demo/Polyhedron/File_loader_dialog.h index 99fb143ab92..059938c3386 100644 --- a/Polyhedron/demo/Polyhedron/File_loader_dialog.h +++ b/Polyhedron/demo/Polyhedron/File_loader_dialog.h @@ -19,6 +19,7 @@ class File_loader_dialog : public QDialog, private Ui::FileLoaderDialog { File_loader_dialog dialog; dialog.buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); + dialog.buttonBox->button(QDialogButtonBox::Ok)->setFocus(); dialog.pluginBox->addItems(item_list); dialog.label->setText(tr("Available loaders for %1 :").arg(filename)); QFileInfo fileinfo(filename); diff --git a/Polyhedron/demo/Polyhedron/MainWindow.cpp b/Polyhedron/demo/Polyhedron/MainWindow.cpp index 1f92d97129f..f85d0355570 100644 --- a/Polyhedron/demo/Polyhedron/MainWindow.cpp +++ b/Polyhedron/demo/Polyhedron/MainWindow.cpp @@ -1102,7 +1102,7 @@ void MainWindow::open(QString filename) if ( dfs_it==default_plugin_selection.end() ) { // collect all io_plugins and offer them to load if the file extension match one name filter - // also collect all available plugin in case of a no extension match + // also collect all available plugins in case of a no extension match for(CGAL::Three::Polyhedron_demo_io_plugin_interface* io_plugin : io_plugins) { if ( file_matches_filter(io_plugin->loadNameFilters(), filename.toLower()) ) { diff --git a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp index cbff878abb7..68826d91862 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Display/Display_property_plugin.cpp @@ -90,6 +90,7 @@ private: double bI = 0.; double expand_radius = 0.; + double expand_radius_updated = false; double maxEdgeLength = -1.; Color_ramp color_ramp; @@ -912,6 +913,8 @@ private Q_SLOTS: expand_radius = (pow(base, val) - 1) * outMax / (pow(base, sliderMax) - 1); dock_widget->expandingRadiusLabel->setText(tr("Expanding Radius: %1").arg(expand_radius)); + CGAL_assertion(expand_radius >= 0); + expand_radius_updated = true; } private: @@ -933,7 +936,7 @@ private: bool non_init; SMesh::Property_map mu_i_map; std::tie(mu_i_map, non_init) = smesh.add_property_map(tied_string, 0); - if(non_init) + if(non_init || expand_radius_updated) { if(vnm_exists) { @@ -967,6 +970,8 @@ private: .ball_radius(expand_radius)); } } + + expand_radius_updated = false; } displaySMProperty(tied_string, smesh); diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp index feeef33572e..36233827a32 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/GOCAD_io_plugin.cpp @@ -85,7 +85,7 @@ Polyhedron_demo_gocad_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_sce t.stop(); std::cerr << "Reading took " << t.time() << " sec." << std::endl; if(name_and_color.first.size() == 0){ - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); } else { item->setName(name_and_color.first.c_str()); } @@ -121,7 +121,7 @@ save(QFileInfo fileinfo,QList& items) std::ofstream out(fileinfo.filePath().toUtf8()); out.precision (std::numeric_limits::digits10 + 2); SMesh* poly = const_cast(sm_item->polyhedron()); - CGAL::IO::write_GOCAD(out, qPrintable(fileinfo.baseName()), *poly); + CGAL::IO::write_GOCAD(out, qPrintable(fileinfo.completeBaseName()), *poly); items.pop_front(); return true; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp index ed9658065f7..25b5c1d7432 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Nef_io_plugin.cpp @@ -57,7 +57,7 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { // Try to read .nef3 in a polyhedron Scene_nef_polyhedron_item* item = new Scene_nef_polyhedron_item(); - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); if(fileinfo.size() == 0) { CGAL::Three::Three::warning( tr("The file you are trying to load is empty.")); diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp index e7de52da567..c413104e883 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_io_plugin.cpp @@ -215,7 +215,7 @@ Polyhedron_demo_off_plugin::load_obj(QFileInfo fileinfo) { return nullptr; } Scene_surface_mesh_item* item = new Scene_surface_mesh_item(); - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); if(item->load_obj(in)) return item; //if not polygonmesh load in soup diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp index 0f04fcd2dbf..9e6cfd399ee 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/OFF_to_nef_io_plugin.cpp @@ -50,7 +50,7 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene){ return QList()<setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(item); diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp index 3573ec548f3..75503490a2a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/Polylines_io_plugin.cpp @@ -201,7 +201,7 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene){ } Scene_polylines_item* item = new Scene_polylines_item; item->polylines = polylines; - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); item->setColor(Qt::black); item->setProperty("polylines metadata", polylines_metadata); std::cerr << "Number of polylines in item: " << item->polylines.size() << std::endl; diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp index bf3f4bf54e9..ca824a3e9ee 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/VTK_io_plugin.cpp @@ -348,7 +348,7 @@ public: || (is_polygon_mesh && is_polyline) || (is_c3t3 && is_polyline) ) { - group = new Scene_group_item(fileinfo.baseName()); + group = new Scene_group_item(fileinfo.completeBaseName()); } if(is_polygon_mesh) @@ -372,12 +372,12 @@ public: if(poly_item) { if(group) { - poly_item->setName(QString("%1_faces").arg(fileinfo.baseName())); + poly_item->setName(QString("%1_faces").arg(fileinfo.completeBaseName())); CGAL::Three::Three::scene()->addItem(poly_item); CGAL::Three::Three::scene()->changeGroup(poly_item, group); } else{ - poly_item->setName(fileinfo.baseName()); + poly_item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(poly_item); @@ -484,12 +484,12 @@ public: c3t3_item->resetCutPlane(); if(group) { - c3t3_item->setName(QString("%1_tetrahedra").arg(fileinfo.baseName())); + c3t3_item->setName(QString("%1_tetrahedra").arg(fileinfo.completeBaseName())); CGAL::Three::Three::scene()->addItem(c3t3_item); CGAL::Three::Three::scene()->changeGroup(c3t3_item, group); } else{ - c3t3_item->setName(fileinfo.baseName()); + c3t3_item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(c3t3_item); @@ -506,12 +506,12 @@ public: polyline_item->polylines.push_back(segment); if(group) { - polyline_item->setName(QString("%1_lines").arg(fileinfo.baseName())); + polyline_item->setName(QString("%1_lines").arg(fileinfo.completeBaseName())); CGAL::Three::Three::scene()->addItem(polyline_item); CGAL::Three::Three::scene()->changeGroup(polyline_item, group); } else{ - polyline_item->setName(fileinfo.baseName()); + polyline_item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(polyline_item); @@ -537,7 +537,7 @@ public: double* p = data->GetPoint(i); point_item->point_set()->insert(Point_3(p[0], p[1], p[2])); } - point_item->setName(fileinfo.baseName()); + point_item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(point_item); diff --git a/Polyhedron/demo/Polyhedron/Plugins/IO/WKT_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/IO/WKT_io_plugin.cpp index 9dbd44d2abe..8810d81942a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/IO/WKT_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/IO/WKT_io_plugin.cpp @@ -64,7 +64,7 @@ load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { Scene_polylines_item* item = new Scene_polylines_item; item->polylines = polylines; - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); item->setColor(Qt::black); std::cerr << "Number of polylines in item: " << item->polylines.size() << std::endl; item->invalidateOpenGLBuffers(); diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp index 4cadd392fd3..536545443d4 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_io_plugin.cpp @@ -96,7 +96,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load( } if(fileinfo.suffix().toLower() == "cgal") { - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); if(item->load_binary(in)) { if(add_to_scene){ @@ -134,7 +134,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load( in.open(fileinfo.filePath().toUtf8(), std::ios_base::in);//not binary CGAL_assertion(!(!in)); - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); item->set_valid(false); if(CGAL::SMDS_3::build_triangulation_from_file(in, item->c3t3().triangulation(), @@ -165,7 +165,7 @@ Polyhedron_demo_c3t3_binary_io_plugin::load( CGAL_assertion(!(!in)); } - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); if (CGAL::IO::read_AVIZO_TETRA(in, item->c3t3().triangulation())) { diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp index 795f6a247f9..8fbe68dfc4e 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/C3t3_rib_exporter_plugin.cpp @@ -387,7 +387,7 @@ save(const Scene_c3t3_item& c3t3_item, const QFileInfo& fileInfo) rib_file.precision(8); // Header - QString basename = fileInfo.baseName(); + QString basename = fileInfo.completeBaseName(); write_header(qPrintable(basename), rib_file); // Lights diff --git a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp index fd99361c290..317e15e7dc7 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Mesh_3/Io_image_plugin.cpp @@ -1356,7 +1356,7 @@ Io_image_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { //Create planes image_item = new Scene_image_item(image,0, true); - image_item->setName(fileinfo.baseName()); + image_item->setName(fileinfo.completeBaseName()); msgBox.setText("Planes created : 0/3"); msgBox.setStandardButtons(QMessageBox::NoButton); msgBox.show(); @@ -1367,7 +1367,7 @@ Io_image_plugin::load(QFileInfo fileinfo, bool& ok, bool add_to_scene) { image_item = new Scene_image_item(image,voxel_scale, false); } - image_item->setName(fileinfo.baseName()); + image_item->setName(fileinfo.completeBaseName()); if(add_to_scene) CGAL::Three::Three::scene()->addItem(image_item); @@ -1456,7 +1456,7 @@ bool Io_image_plugin::loadDirectory(const QString& dirname, { // Create planes image_item = new Scene_image_item(image,125, true); - image_item->setName(fileinfo.baseName()); + image_item->setName(fileinfo.completeBaseName()); msgBox.setText("Planes created : 0/3"); msgBox.setStandardButtons(QMessageBox::NoButton); msgBox.show(); @@ -1470,7 +1470,7 @@ bool Io_image_plugin::loadDirectory(const QString& dirname, int voxel_scale = ui.precisionList->currentIndex() + 1; image_item = new Scene_image_item(image,voxel_scale, false); - image_item->setName(fileinfo.baseName()); + image_item->setName(fileinfo.completeBaseName()); scene->addItem(image_item); } } diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp index d6d3c6a1a45..3034e7f58a3 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Distance_plugin.cpp @@ -190,13 +190,10 @@ private: for(boost::graph_traits::face_descriptor f : faces(*poly)) { Vector nf = get(nf_pmap, f); - typedef FacetTriangulator::vertex_descriptor> FT; - //compute distance with other polyhedron //sample facet std::vector sampled_points; - std::size_t nb_points = (std::max)((int)std::ceil(nb_pts_per_face * PMP::face_area(f,*poly,CGAL::parameters::geom_traits(Kernel()))), - 1); + std::size_t nb_points = (std::max)((int)std::ceil(nb_pts_per_face * PMP::face_area(f,*poly,CGAL::parameters::geom_traits(Kernel()))), 1); Kernel::Point_3 &p = get(vpmap,target(halfedge(f,*poly),*poly)); Kernel::Point_3 &q = get(vpmap,target(next(halfedge(f,*poly),*poly),*poly)); Kernel::Point_3 &r = get(vpmap,target(next(next(halfedge(f,*poly),*poly),*poly),*poly)); @@ -207,36 +204,42 @@ private: sampled_points.push_back(r); //triangle facets with sample points for color display - FT triangulation(f,sampled_points,nf,poly); + auto func = [&](auto& ffit, auto&) { + if (ffit.info().is_external) + return; - if(triangulation.cdt->dimension() != 2 ) - { - qDebug()<<"Error : cdt not right (dimension != 2). Facet not displayed"; - continue; - } - - //iterates on the internal faces to add the vertices to the positions - //and the normals to the appropriate vectors - - for(FT::CDT::Finite_faces_iterator - ffit = triangulation.cdt->finite_faces_begin(), - end = triangulation.cdt->finite_faces_end(); - ffit != end; ++ffit) - { - if(ffit->info().is_external) - continue; - - for (int i = 0; i<3; ++i) + for (int i = 0; i < 3; ++i) { - total_points.push_back(ffit->vertex(i)->point()); - m_vertices.push_back(ffit->vertex(i)->point().x()); - m_vertices.push_back(ffit->vertex(i)->point().y()); - m_vertices.push_back(ffit->vertex(i)->point().z()); + total_points.push_back(ffit.vertex(i)->point()); + m_vertices.push_back(ffit.vertex(i)->point().x()); + m_vertices.push_back(ffit.vertex(i)->point().y()); + m_vertices.push_back(ffit.vertex(i)->point().z()); normals.push_back(nf.x()); normals.push_back(nf.y()); normals.push_back(nf.z()); } + }; + + try { + FacetTriangulator::vertex_descriptor> triangulation(f, sampled_points, nf, poly); + + if (triangulation.cdt->dimension() != 2) + { + qDebug() << "Error : cdt not right (dimension != 2). Facet not displayed"; + continue; + } + triangulation.per_face(func); + } + catch (...) { + FacetTriangulator::vertex_descriptor, CGAL::Exact_intersections_tag> triangulation(f, sampled_points, nf, poly); + + if (triangulation.cdt->dimension() != 2) + { + qDebug() << "Error : cdt not right (dimension != 2). Facet not displayed"; + continue; + } + triangulation.per_face(func); } } //compute the distances diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Inside_out_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Inside_out_plugin.cpp index 7f2fa8f7dc9..93633b3ab2a 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Inside_out_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Inside_out_plugin.cpp @@ -29,7 +29,7 @@ public: { scene = scene_interface; this->mw = mw; - actionInsideOut = new QAction(tr("Inside Out"), mw); + actionInsideOut = new QAction(tr("Reverse Orientation (\"Inside Out\")"), mw); actionInsideOut->setProperty("subMenuName", "Polygon Mesh Processing"); connect(actionInsideOut, SIGNAL(triggered()), this, SLOT(on_actionInsideOut_triggered())); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp index b0ac1f85996..5d87af53f59 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Repair_polyhedron_plugin.cpp @@ -182,8 +182,7 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveIsolatedVertices_t if (poly_item) { std::size_t nbv = - CGAL::Polygon_mesh_processing::remove_isolated_vertices( - *poly_item->polyhedron()); + CGAL::Polygon_mesh_processing::remove_isolated_vertices(*poly_item->polyhedron()); CGAL::Three::Three::information(tr(" %1 isolated vertices have been removed.") .arg(nbv)); poly_item->setNbIsolatedvertices(0); @@ -369,13 +368,16 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionSnapBorders_triggered() template void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_triggered(Scene_interface::Item_id index) { - Item* poly_item = - qobject_cast(scene->item(index)); + Item* poly_item = qobject_cast(scene->item(index)); if (poly_item) { + if(! CGAL::is_triangle_mesh(*poly_item->polyhedron())) { + CGAL::Three::Three::error(QString("The mesh must have triangle faces")); + return; + } + std::size_t nbv = faces(*poly_item->polyhedron()).size(); - CGAL::Polygon_mesh_processing::remove_degenerate_faces( - *poly_item->polyhedron()); + CGAL::Polygon_mesh_processing::remove_degenerate_faces(*poly_item->polyhedron()); nbv -= faces(*poly_item->polyhedron()).size(); poly_item->invalidateOpenGLBuffers(); Q_EMIT poly_item->itemChanged(); @@ -395,10 +397,14 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveDegenerateFaces_tr template void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_triggered(Scene_interface::Item_id index) { - Item* poly_item = - qobject_cast(scene->item(index)); + Item* poly_item = qobject_cast(scene->item(index)); if (poly_item) { + if(! CGAL::is_triangle_mesh(*poly_item->polyhedron())) { + CGAL::Three::Three::error(QString("The mesh must have triangle faces")); + return; + } + bool solved = CGAL::Polygon_mesh_processing::experimental::remove_self_intersections( *poly_item->polyhedron(), CGAL::parameters::preserve_genus(false)); @@ -420,10 +426,10 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionRemoveSelfIntersections_ template void Polyhedron_demo_repair_polyhedron_plugin::on_actionAutorefine_triggered(Scene_interface::Item_id index) { - Item* poly_item = - qobject_cast(scene->item(index)); + Item* poly_item = qobject_cast(scene->item(index)); if (poly_item) { + CGAL::Polygon_mesh_processing::triangulate_faces(*poly_item->polyhedron()); try{ CGAL::Polygon_mesh_processing::experimental::autorefine(*poly_item->polyhedron()); } @@ -519,10 +525,10 @@ void Polyhedron_demo_repair_polyhedron_plugin::on_actionNewAutorefine_triggered( template void Polyhedron_demo_repair_polyhedron_plugin::on_actionAutorefineAndRMSelfIntersections_triggered(Scene_interface::Item_id index) { - Item* poly_item = - qobject_cast(scene->item(index)); + Item* poly_item = qobject_cast(scene->item(index)); if (poly_item) { + CGAL::Polygon_mesh_processing::triangulate_faces(*poly_item->polyhedron()); try{ bool solved = CGAL::Polygon_mesh_processing::experimental:: diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp index b1ffae6e97b..2c50e614ac0 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Selection_plugin.cpp @@ -111,7 +111,7 @@ public: ok = false; return QList(); } - item->setName(fileinfo.baseName()); + item->setName(fileinfo.completeBaseName()); ok = true; if(add_to_scene) CGAL::Three::Three::scene()->addItem(item); diff --git a/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp index 212f2cc60ef..70747cdddc9 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/PMP/Smoothing_plugin.cpp @@ -107,6 +107,10 @@ public: ui_widget.projection_checkBox->setChecked(true); ui_widget.area_smoothing_checkBox->setChecked(false); +#ifndef CGAL_PMP_USE_CERES_SOLVER + ui_widget.area_smoothing_checkBox->setDisabled(true); +#endif + ui_widget.flip_checkBox->setChecked(true); ui_widget.flip_checkBox->setDisabled(true); } diff --git a/Polyhedron/demo/Polyhedron/Plugins/Tetrahedral_remeshing/Tetrahedral_remeshing_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Tetrahedral_remeshing/Tetrahedral_remeshing_plugin.cpp index a64a44fa331..0a75dbae932 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Tetrahedral_remeshing/Tetrahedral_remeshing_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Tetrahedral_remeshing/Tetrahedral_remeshing_plugin.cpp @@ -3,6 +3,7 @@ //#define CGAL_TETRAHEDRAL_REMESHING_DEBUG //#define CGAL_TETRAHEDRAL_REMESHING_VERBOSE_PROGRESS //#define CGAL_TETRAHEDRAL_REMESHING_PROFILE +//#define CGAL_FLIP_ON_SURFACE_DISABLE_44_FLIP #include @@ -120,7 +121,7 @@ public Q_SLOTS: if (c3t3_item->c3t3().is_in_complex(e) || CGAL::Tetrahedral_remeshing::protecting_balls_intersect(e, c3t3)) { - Vertex_pair evv = CGAL::Tetrahedral_remeshing::make_vertex_pair(e); + Vertex_pair evv = CGAL::Tetrahedral_remeshing::make_vertex_pair(e); constraints.insert(evv); } } diff --git a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp index 8ba8813f349..7bdc0f69a0c 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polygon_soup_item.cpp @@ -137,80 +137,71 @@ Scene_polygon_soup_item_priv::triangulate_polygon(Polygons_iterator pit, int pol if (normal == CGAL::NULL_VECTOR) // No normal could be computed, return return; - typedef FacetTriangulator FT; + typedef std::pair PointAndId; std::size_t it = 0; std::size_t it_end =pit->size(); - std::vector pointIds; + std::vector pointIds; do { - FT::PointAndId pointId; + PointAndId pointId; - pointId.point = soup->points[pit->at(it)]+offset; - pointId.id = pit->at(it); + pointId.first = soup->points[pit->at(it)]+offset; + pointId.second = pit->at(it); pointIds.push_back(pointId); } while( ++it != it_end ); - //detect degenerated faces - std::vector pid_stack = pointIds; - for(std::size_t i = 0; i< pointIds.size(); ++i) - { - FT::PointAndId pid = pid_stack.back(); - pid_stack.pop_back(); - for(FT::PointAndId poai : pid_stack) - { - if (pid.point== poai.point) - { - return; - } - } - } - FT triangulation(pointIds,normal); + //iterates on the internal faces to add the vertices to the positions //and the normals to the appropriate vectors - for(FT::CDT::Finite_faces_iterator - ffit = triangulation.cdt->finite_faces_begin(), - end = triangulation.cdt->finite_faces_end(); - ffit != end; ++ffit) - { - if(ffit->info().is_external) - continue; + auto f = [&](auto& ffit, auto& v2v) { + if (ffit.info().is_external) + return; - positions_poly.push_back(ffit->vertex(0)->point().x()); - positions_poly.push_back(ffit->vertex(0)->point().y()); - positions_poly.push_back(ffit->vertex(0)->point().z()); + positions_poly.push_back(ffit.vertex(0)->point().x()); + positions_poly.push_back(ffit.vertex(0)->point().y()); + positions_poly.push_back(ffit.vertex(0)->point().z()); + positions_poly.push_back(ffit.vertex(1)->point().x()); + positions_poly.push_back(ffit.vertex(1)->point().y()); + positions_poly.push_back(ffit.vertex(1)->point().z()); - positions_poly.push_back(ffit->vertex(1)->point().x()); - positions_poly.push_back(ffit->vertex(1)->point().y()); - positions_poly.push_back(ffit->vertex(1)->point().z()); + positions_poly.push_back(ffit.vertex(2)->point().x()); + positions_poly.push_back(ffit.vertex(2)->point().y()); + positions_poly.push_back(ffit.vertex(2)->point().z()); - positions_poly.push_back(ffit->vertex(2)->point().x()); - positions_poly.push_back(ffit->vertex(2)->point().y()); - positions_poly.push_back(ffit->vertex(2)->point().z()); - - CGAL::IO::Color color; - if(!soup->fcolors.empty()) - color = soup->fcolors[polygon_id]; - for(int i=0; i<3; i++) + CGAL::IO::Color color; + if (!soup->fcolors.empty()) + color = soup->fcolors[polygon_id]; + for (int i = 0; i < 3; i++) + { + normals.push_back(normal.x()); + normals.push_back(normal.y()); + normals.push_back(normal.z()); + if (!soup->fcolors.empty()) { - normals.push_back(normal.x()); - normals.push_back(normal.y()); - normals.push_back(normal.z()); - if(!soup->fcolors.empty()) - { - f_colors.push_back(static_cast(color.red())/255); - f_colors.push_back(static_cast(color.green())/255); - f_colors.push_back(static_cast(color.blue())/255); - } - if(!soup->vcolors.empty()) - { - CGAL::IO::Color vcolor = soup->vcolors[triangulation.v2v[ffit->vertex(i)]]; - v_colors.push_back(static_cast(vcolor.red())/255); - v_colors.push_back(static_cast(vcolor.green())/255); - v_colors.push_back(static_cast(vcolor.blue())/255); - } + f_colors.push_back(static_cast(color.red()) / 255); + f_colors.push_back(static_cast(color.green()) / 255); + f_colors.push_back(static_cast(color.blue()) / 255); } + if (!soup->vcolors.empty()) + { + CGAL::IO::Color vcolor = soup->vcolors[v2v[ffit.vertex(i)]]; + v_colors.push_back(static_cast(vcolor.red()) / 255); + v_colors.push_back(static_cast(vcolor.green()) / 255); + v_colors.push_back(static_cast(vcolor.blue()) / 255); + } + } + }; + + try { + FacetTriangulator triangulation(pointIds, normal); + triangulation.per_face(f); + } + catch (...) { + FacetTriangulator triangulation(pointIds, normal); + triangulation.per_face(f); } } + void Scene_polygon_soup_item_priv::compute_normals_and_vertices() const{ diff --git a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp index 4e348918bb8..7df511b6169 100644 --- a/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_polyhedron_selection_item.cpp @@ -282,26 +282,29 @@ Scene_polyhedron_selection_item_priv::triangulate_facet(fg_face_descriptor fit,c const CGAL::qglviewer::Vec off = Three::mainViewer()->offset(); EPICK::Vector_3 offset(off.x,off.y,off.z); - typedef FacetTriangulator FT; - FT triangulation(fit,normal,poly, offset); - //iterates on the internal faces to add the vertices to the positions - //and the normals to the appropriate vectors - for(FT::CDT::Finite_faces_iterator - ffit = triangulation.cdt->finite_faces_begin(), - end = triangulation.cdt->finite_faces_end(); - ffit != end; ++ffit) - { - if(ffit->info().is_external) - continue; + //iterates on the internal faces to add the vertices to the positions + //and the normals to the appropriate vectors + auto f = [&](auto& ffit, auto& /* v2v */) { + if (ffit.info().is_external) + return; - push_back_xyz(ffit->vertex(0)->point(), p_facets); - push_back_xyz(ffit->vertex(1)->point(), p_facets); - push_back_xyz(ffit->vertex(2)->point(), p_facets); + push_back_xyz(ffit.vertex(0)->point(), p_facets); + push_back_xyz(ffit.vertex(1)->point(), p_facets); + push_back_xyz(ffit.vertex(2)->point(), p_facets); - push_back_xyz(normal, p_normals); - push_back_xyz(normal, p_normals); - push_back_xyz(normal, p_normals); - } + push_back_xyz(normal, p_normals); + push_back_xyz(normal, p_normals); + push_back_xyz(normal, p_normals); + }; + + try { + FacetTriangulator triangulation(fit, normal, poly, offset); + triangulation.per_face(f); + } + catch (...) { + FacetTriangulator triangulation(fit, normal, poly, offset); + triangulation.per_face(f); + } } diff --git a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp index 5dcd7cbc518..4bdd7f76581 100644 --- a/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp +++ b/Polyhedron/demo/Polyhedron/Scene_surface_mesh_item.cpp @@ -984,62 +984,66 @@ Scene_surface_mesh_item_priv::triangulate_facet(face_descriptor fd, return; } - typedef FacetTriangulator::vertex_descriptor> FT; const CGAL::qglviewer::Vec off = static_cast(CGAL::QGLViewer::QGLViewerPool().first())->offset(); EPICK::Vector_3 offset(off.x,off.y,off.z); - FT triangulation(fd,normal,smesh_, offset); + //iterates on the internal faces - for(FT::CDT::Finite_faces_iterator - ffit = triangulation.cdt->finite_faces_begin(), - end = triangulation.cdt->finite_faces_end(); - ffit != end; ++ffit) - { - if(ffit->info().is_external) - continue; + auto f = [&](auto& ffit, auto& v2v) { + if (ffit.info().is_external) + return; //add the vertices to the positions //adds the vertices, normals and colors to the appropriate vectors - if(!index) + if (!index) { CGAL::IO::Color* color; - if(has_fpatch_id) + if (has_fpatch_id) { - QColor c= item->color_vector()[fpatch_id_map[fd] - min_patch_id]; - color = new CGAL::IO::Color(c.red(),c.green(),c.blue()); + QColor c = item->color_vector()[fpatch_id_map[fd] - min_patch_id]; + color = new CGAL::IO::Color(c.red(), c.green(), c.blue()); } - else if(has_fcolors) + else if (has_fcolors) color = &(*fcolors)[fd]; else color = nullptr; - addFlatData(ffit->vertex(0)->point()-offset, - (*fnormals)[fd], - color, - name); - addFlatData(ffit->vertex(1)->point()-offset, - (*fnormals)[fd], - color, - name); + addFlatData(ffit.vertex(0)->point() - offset, + (*fnormals)[fd], + color, + name); + addFlatData(ffit.vertex(1)->point() - offset, + (*fnormals)[fd], + color, + name); - addFlatData(ffit->vertex(2)->point()-offset, - (*fnormals)[fd], - color, - name); - if(has_fpatch_id) + addFlatData(ffit.vertex(2)->point() - offset, + (*fnormals)[fd], + color, + name); + if (has_fpatch_id) delete color; } //adds the indices to the appropriate vector else { - if(name.testFlag(Scene_item_rendering_helper::GEOMETRY)) + if (name.testFlag(Scene_item_rendering_helper::GEOMETRY)) { - idx_data_.push_back((*im)[triangulation.v2v[ffit->vertex(0)]]); - idx_data_.push_back((*im)[triangulation.v2v[ffit->vertex(1)]]); - idx_data_.push_back((*im)[triangulation.v2v[ffit->vertex(2)]]); + idx_data_.push_back((*im)[v2v[ffit.vertex(0)]]); + idx_data_.push_back((*im)[v2v[ffit.vertex(1)]]); + idx_data_.push_back((*im)[v2v[ffit.vertex(2)]]); } } + }; + try { + FacetTriangulator::vertex_descriptor> triangulation(fd, normal, smesh_, offset); + triangulation.per_face(f); + } + catch (...) { + FacetTriangulator::vertex_descriptor, CGAL::Exact_intersections_tag> triangulation(fd, normal, smesh_, offset); + triangulation.per_face(f); } } + void delete_aabb_tree(Scene_surface_mesh_item* item) { QVariant aabb_tree_property = item->property(aabb_property_name); @@ -1356,7 +1360,6 @@ void Scene_surface_mesh_item::invalidate(Gl_data_names name) QList Scene_surface_mesh_item_priv::triangulate_primitive(face_descriptor fit, EPICK::Vector_3 normal) { - typedef FacetTriangulator::vertex_descriptor> FT; //The output list QList res; //check if normal contains NaN values @@ -1365,23 +1368,27 @@ QList Scene_surface_mesh_item_priv::triangulate_primitive(fac qDebug()<<"Warning in triangulation of the selection item: normal contains NaN values and is not valid."; return QList(); } - FT triangulation(fit,normal,smesh_); + //iterates on the internal faces to add the vertices to the positions //and the normals to the appropriate vectors - for( FT::CDT::Finite_faces_iterator - ffit = triangulation.cdt->finite_faces_begin(), - end = triangulation.cdt->finite_faces_end(); - ffit != end; ++ffit) - { - if(ffit->info().is_external) - continue; + auto f = [&](auto &ffit, auto&) { + if (ffit.info().is_external) + return; + res << EPICK::Triangle_3(ffit.vertex(0)->point(), + ffit.vertex(1)->point(), + ffit.vertex(2)->point()); + }; - res << EPICK::Triangle_3(ffit->vertex(0)->point(), - ffit->vertex(1)->point(), - ffit->vertex(2)->point()); - + try { + FacetTriangulator::vertex_descriptor> triangulation(fit, normal, smesh_); + triangulation.per_face(f); } + catch (...) { + FacetTriangulator::vertex_descriptor, CGAL::Exact_intersections_tag> triangulation(fit, normal, smesh_); + triangulation.per_face(f); + } + return res; } @@ -2619,21 +2626,24 @@ void Scene_surface_mesh_item::fill_flat_vertex_map() return; } - typedef FacetTriangulator::vertex_descriptor> FT; const CGAL::qglviewer::Vec off = static_cast(CGAL::QGLViewer::QGLViewerPool().first())->offset(); EPICK::Vector_3 offset(off.x,off.y,off.z); - FT triangulation(fd,normal,face_graph(), offset); - //iterates on the internal faces - for(FT::CDT::Finite_faces_iterator - ffit = triangulation.cdt->finite_faces_begin(), - end = triangulation.cdt->finite_faces_end(); - ffit != end; ++ffit) - { - if(ffit->info().is_external) - continue; - d->flat_vertices_map[triangulation.v2v[ffit->vertex(0)]].push_back(counter++); - d->flat_vertices_map[triangulation.v2v[ffit->vertex(1)]].push_back(counter++); - d->flat_vertices_map[triangulation.v2v[ffit->vertex(2)]].push_back(counter++); + + auto f = [&](auto ffit, auto &v2v) { + if (ffit.info().is_external) + return; + d->flat_vertices_map[v2v[ffit.vertex(0)]].push_back(counter++); + d->flat_vertices_map[v2v[ffit.vertex(1)]].push_back(counter++); + d->flat_vertices_map[v2v[ffit.vertex(2)]].push_back(counter++); + }; + + try { + FacetTriangulator::vertex_descriptor> triangulation(fd, normal, face_graph(), offset); + triangulation.per_face(f); + } + catch (...) { + FacetTriangulator::vertex_descriptor, CGAL::Exact_intersections_tag> triangulation(fd, normal, face_graph(), offset); + triangulation.per_face(f); } } } diff --git a/Polyhedron/demo/Polyhedron/polyhedron_demo_macros.cmake b/Polyhedron/demo/Polyhedron/polyhedron_demo_macros.cmake index 91f4f086637..aaea742ca1d 100644 --- a/Polyhedron/demo/Polyhedron/polyhedron_demo_macros.cmake +++ b/Polyhedron/demo/Polyhedron/polyhedron_demo_macros.cmake @@ -35,33 +35,16 @@ include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) if(TARGET demo_framework) target_link_libraries( ${plugin_name} PUBLIC demo_framework) add_dependencies(${plugin_name} demo_framework) - if(CGAL_ENABLE_TESTING AND NOT CMAKE_VS_MSBUILD_COMMAND) - if(NOT TARGET "compilation_of__demo_framework") - # This custom target is useless. It is used only as a flag to - # detect that the test has already been created. - add_custom_target("compilation_of__demo_framework") - add_dependencies( "compilation_of__demo_framework" demo_framework ) - add_test(NAME "compilation of demo_framework" - COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "demo_framework" --config "$") - - set_property(TEST "compilation of demo_framework" - APPEND PROPERTY LABELS "CGAL_build_system") - set_property(TEST "compilation of demo_framework" - APPEND PROPERTY FIXTURES_SETUP "demo_framework_SetupFixture") - set_property(TEST "compilation of demo_framework" - APPEND PROPERTY DEPENDS "compilation_of__CGAL_Qt6_moc_and_resources") - endif() - endif() else() target_link_libraries( ${plugin_name} PUBLIC Polyhedron_demo_framework) add_dependencies(${plugin_name} Polyhedron_demo_framework) endif() - if(TARGET "compilation_of__demo_framework") + if(TARGET "compilation_of__demo_framework" AND TEST "compilation of ${plugin_name}") set_property(TEST "compilation of ${plugin_name}" APPEND PROPERTY FIXTURES_REQUIRED demo_framework_SetupFixture) endif() # Link with CGAL target_link_libraries( ${plugin_name} PUBLIC CGAL::CGAL ) - if(TARGET Polyhedron_3) + if(NOT CGAL_TEST_SUITE AND TARGET Polyhedron_3) add_dependencies( ${plugin_name} Polyhedron_3 ) endif() if(NOT TARGET CGALlab_all_plugins) @@ -98,4 +81,5 @@ include(${CGAL_MODULES_DIR}/CGAL_add_test.cmake) string(TIMESTAMP VERSION "%Y-%m-%d %H:%M") file(APPEND ${filename} "\"ConfigDate\" : \"${VERSION}\" }") endif() + CGAL_install_hooks() endmacro(polyhedron_demo_plugin) diff --git a/Polyhedron/demo/Polyhedron/triangulate_primitive.h b/Polyhedron/demo/Polyhedron/triangulate_primitive.h index cf7aa8a457b..54fceb64eb3 100644 --- a/Polyhedron/demo/Polyhedron/triangulate_primitive.h +++ b/Polyhedron/demo/Polyhedron/triangulate_primitive.h @@ -6,6 +6,7 @@ #include #include #include +#include #include @@ -22,7 +23,7 @@ // @todo just use PMP::triangulate_face()...? // or at least mark_faces_in_domain() -template +template class FacetTriangulator { public: @@ -30,6 +31,8 @@ public: using Point = typename Kernel::Point_3; using Vector = typename Kernel::Vector_3; + using Index = Index_type; + using P_traits = CGAL::Projection_traits_3; using halfedge_descriptor = typename boost::graph_traits::halfedge_descriptor; @@ -45,23 +48,14 @@ public: using Fbb = CGAL::Triangulation_face_base_with_info_2; using Fb = CGAL::Constrained_triangulation_face_base_2; using TDS = CGAL::Triangulation_data_structure_2; - using Itag = CGAL::Exact_predicates_tag; - using CDT = CGAL::Constrained_Delaunay_triangulation_2; + using CDT = CGAL::Constrained_Delaunay_triangulation_2; using Vertex_handle = typename CDT::Vertex_handle; using Face_handle = typename CDT::Face_handle; - struct PointAndId - { - Point point; - Index_type id; - PointAndId() = default; - PointAndId(const Point& point, const Index_type id) : point(point), id(id) { } - }; - public: CDT* cdt; - CGAL::Unique_hash_map v2v; + CGAL::Unique_hash_map v2v; public: // Constructor @@ -70,10 +64,10 @@ public: Mesh* poly, Vector offset = Vector(0,0,0)) { - std::vector idPoints; + std::vector > idPoints; for(halfedge_descriptor he_circ : halfedges_around_face(halfedge(fd, *poly), *poly)) - idPoints.emplace_back(get(CGAL::vertex_point, *poly, source(he_circ, *poly)) + offset, - source(he_circ, *poly)); + idPoints.emplace_back(std::make_pair(get(CGAL::vertex_point, *poly, source(he_circ, *poly)) + offset, + source(he_circ, *poly))); if(!triangulate(idPoints, normal)) std::cerr << "Facet not displayed" << std::endl; @@ -85,22 +79,22 @@ public: Mesh* poly, Vector offset = Vector(0,0,0)) { - std::vector idPoints; + std::vector > idPoints; for(halfedge_descriptor he_circ : halfedges_around_face(halfedge(fd, *poly), *poly)) - idPoints.emplace_back(get(CGAL::vertex_point, *poly, source(he_circ, *poly)) + offset, - source(he_circ, *poly)); + idPoints.emplace_back(std::make_pair(get(CGAL::vertex_point, *poly, source(he_circ, *poly)) + offset, + source(he_circ, *poly))); if(!triangulate_with_points(idPoints, more_points, normal)) std::cerr << "Facet not displayed" << std::endl; } - FacetTriangulator(std::vector& idPoints, + FacetTriangulator(std::vector >& idPoints, const Vector& normal) { if(!triangulate(idPoints, normal)) std::cerr << "Facet not displayed" << std::endl; } - FacetTriangulator(std::vector& idPoints, + FacetTriangulator(std::vector < std::pair >& idPoints, const std::vector& more_points, const Vector& normal) { @@ -114,36 +108,66 @@ public: delete cdt; } + template + void per_face(const Func& f) { + for (typename CDT::Finite_faces_iterator fit = cdt->finite_faces_begin(); fit != cdt->finite_faces_end(); ++fit) + f(*fit, v2v); + } + private: - bool triangulate(std::vector& idPoints, + bool triangulate(std::vector >& idPoints, const Vector& normal) { P_traits cdt_traits(normal); cdt = new CDT(cdt_traits); + std::map, std::size_t> edge_map; + std::vector skip(idPoints.size(), false); + + for (std::size_t i = 0; i < idPoints.size(); i++) { + std::size_t prev = (i - 1 + idPoints.size()) % idPoints.size(); + if (idPoints[i].first < idPoints[prev].first) { + auto it = edge_map.emplace(std::make_pair(idPoints[i].first, idPoints[prev].first), i); + if (!it.second) { + skip[i] = true; + skip[it.first->second] = true; + } + } + else { + auto it = edge_map.emplace(std::make_pair(idPoints[prev].first, idPoints[i].first), i); + if (!it.second) { + skip[i] = true; + skip[it.first->second] = true; + } + } + } + Vertex_handle previous, first, last_inserted; // Iterate the points of the facet and decide if they must be inserted in the CDT typename Kernel::FT x(0), y(0), z(0); - for(const PointAndId& idPoint : idPoints) + for(std::size_t i = 0;i& idPoint = idPoints[i]; + x += idPoint.first.x(); + y += idPoint.first.y(); + z += idPoint.first.z(); Vertex_handle vh; // Always insert the first point, then only insert if the distance with the previous is reasonable. - if(first == Vertex_handle() || idPoint.point != previous->point()) + if(first == Vertex_handle() || idPoint.first != previous->point()) { - vh = cdt->insert(idPoint.point); - v2v[vh] = idPoint.id; - if(first == Vertex_handle()) + vh = cdt->insert(idPoint.first); + v2v[vh] = idPoint.second; + if (first == Vertex_handle()) { first = vh; + } if(previous != nullptr && previous != vh) { - cdt->insert_constraint(previous, vh); + if (!skip[i]) + cdt->insert_constraint(previous, vh); last_inserted = previous; } previous = vh; @@ -153,57 +177,73 @@ private: if(last_inserted == Vertex_handle()) return false; - if(previous != first) + if(previous != first && !skip[0]) cdt->insert_constraint(previous, first); + // ignore degenerate polygons + if (cdt->dimension() != 2) + return true; + // sets mark is_external for(Face_handle f2 : cdt->all_face_handles()) f2->info().is_external = false; - // check if the facet is external or internal - std::queue face_queue; - face_queue.push(cdt->infinite_vertex()->face()); - while(! face_queue.empty()) - { - typename CDT::Face_handle fh = face_queue.front(); - face_queue.pop(); - if(fh->info().is_external) - continue; + std::unordered_map in_domain_map; + boost::associative_property_map< std::unordered_map > in_domain(in_domain_map); + CGAL::mark_domain_in_triangulation(*cdt, in_domain); - fh->info().is_external = true; - for(int i = 0; i <3; ++i) - { - if(!cdt->is_constrained(std::make_pair(fh, i))) - face_queue.push(fh->neighbor(i)); - } - } + for (const Face_handle& fh : cdt->all_face_handles()) + fh->info().is_external = !get(in_domain, fh); return true; } - bool triangulate_with_points(std::vector& idPoints, + bool triangulate_with_points(std::vector >& idPoints, const std::vector& more_points, const Vector& normal) { P_traits cdt_traits(normal); cdt = new CDT(cdt_traits); + std::map, std::size_t> edge_map; + std::vector skip(idPoints.size(), false); + + for (std::size_t i = 0; i < idPoints.size(); i++) { + std::size_t prev = (i - 1 + idPoints.size()) % idPoints.size(); + if (idPoints[i].first < idPoints[prev].first) { + auto it = edge_map.emplace(std::make_pair(idPoints[i].first, idPoints[prev].first), i); + if (!it.second) { + skip[i] = true; + skip[it.first->second] = true; + } + } + else { + auto it = edge_map.emplace(std::make_pair(idPoints[prev].first, idPoints[i].first), i); + if (!it.second) { + skip[i] = true; + skip[it.first->second] = true; + } + } + } + // Iterate the points of the facet and decide if they must be inserted in the CDT Vertex_handle previous, first, last_inserted; - for(const PointAndId& idPoint : idPoints) + for (std::size_t i = 0; i < idPoints.size(); i++) { + const std::pair& idPoint = idPoints[i]; Vertex_handle vh; // Always insert the first point, then only insert if the distance with the previous is reasonable. - if(first == Vertex_handle() || idPoint.point != previous->point()) + if(first == Vertex_handle() || idPoint.first != previous->point()) { - vh = cdt->insert(idPoint.point); - v2v[vh] = idPoint.id; + vh = cdt->insert(idPoint.first); + v2v[vh] = idPoint.second; if(first == Vertex_handle()) first = vh; if(previous != nullptr && previous != vh) { - cdt->insert_constraint(previous, vh); + if (!skip[i]) + cdt->insert_constraint(previous, vh); last_inserted = previous; } previous = vh; @@ -213,7 +253,9 @@ private: if(last_inserted == Vertex_handle()) return false; + if (previous != first && !skip[0]) cdt->insert_constraint(previous, first); + for(const Point& point : more_points) cdt->insert(point); @@ -221,22 +263,12 @@ private: for(Face_handle f2 : cdt->all_face_handles()) f2->info().is_external = false; - // check if the facet is external or internal - std::queue face_queue; - face_queue.push(cdt->infinite_vertex()->face()); - while(!face_queue.empty()) - { - typename CDT::Face_handle fh = face_queue.front(); - face_queue.pop(); - if(fh->info().is_external) - continue; - fh->info().is_external = true; - for(int i = 0; i <3; ++i) - { - if(!cdt->is_constrained(std::make_pair(fh, i))) - face_queue.push(fh->neighbor(i)); - } - } + std::unordered_map in_domain_map; + boost::associative_property_map< std::unordered_map > in_domain(in_domain_map); + CGAL::mark_domain_in_triangulation(*cdt, in_domain); + + for (const Face_handle& fh : cdt->all_face_handles()) + fh->info().is_external = !get(in_domain, fh); return true; } diff --git a/Polyhedron/include/CGAL/Polyhedron_3_to_lcc.h b/Polyhedron/include/CGAL/Polyhedron_3_to_lcc.h index c284f6e60b1..bda362a0d2d 100644 --- a/Polyhedron/include/CGAL/Polyhedron_3_to_lcc.h +++ b/Polyhedron/include/CGAL/Polyhedron_3_to_lcc.h @@ -13,6 +13,9 @@ #ifndef CGAL_POLYHEDRON_3_TO_LCC_H #define CGAL_POLYHEDRON_3_TO_LCC_H +#include + + #include #include #include diff --git a/Polyhedron/include/CGAL/Polyhedron_items_with_id_3.h b/Polyhedron/include/CGAL/Polyhedron_items_with_id_3.h index e792a2fe3bf..2bbea002775 100644 --- a/Polyhedron/include/CGAL/Polyhedron_items_with_id_3.h +++ b/Polyhedron/include/CGAL/Polyhedron_items_with_id_3.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola #ifndef CGAL_POLYHEDRON_ITEMS_WITH_ID_3_H -#define CGAL_POLYHEDRON_ITEMS_WITH_ID_3_H 1 +#define CGAL_POLYHEDRON_ITEMS_WITH_ID_3_H + +#include + #include #include diff --git a/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h b/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h index 8cff560f0a6..f8e6e9a21ca 100644 --- a/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h +++ b/Polyhedron/include/CGAL/boost/graph/graph_traits_Polyhedron_3.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_BOOST_GRAPH_GRAPH_TRAITS_POLYHEDRON_3_H #define CGAL_BOOST_GRAPH_GRAPH_TRAITS_POLYHEDRON_3_H +#include + + #include #include diff --git a/Polyhedron/include/CGAL/boost/graph/halfedge_graph_traits_Polyhedron_3.h b/Polyhedron/include/CGAL/boost/graph/halfedge_graph_traits_Polyhedron_3.h index cd0778ea374..6d7bf94b3fb 100644 --- a/Polyhedron/include/CGAL/boost/graph/halfedge_graph_traits_Polyhedron_3.h +++ b/Polyhedron/include/CGAL/boost/graph/halfedge_graph_traits_Polyhedron_3.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -13,6 +13,9 @@ #ifndef CGAL_BOOST_GRAPH_HALFEDGE_GRAPH_TRAITS_POLYHEDRON_3_H #define CGAL_BOOST_GRAPH_HALFEDGE_GRAPH_TRAITS_POLYHEDRON_3_H +#include + + #define CGAL_DEPRECATED_HEADER "" #define CGAL_REPLACEMENT_HEADER "" #include diff --git a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h index 72fdf06ba75..b66e213400d 100644 --- a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h +++ b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_BOOST_GRAPH_PROPERTIES_POLYHEDRON_3_H #define CGAL_BOOST_GRAPH_PROPERTIES_POLYHEDRON_3_H +#include + + #define CGAL_HDS_TMPLT Gt, class I, CGAL_HDS_PARAM_, class A #define CGAL_HDS_CLASS CGAL::Polyhedron_3 diff --git a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h index 70f89908c7f..d047937ec83 100644 --- a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h +++ b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_features.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri @@ -12,6 +12,9 @@ #ifndef CGAL_PROPERTIES_POLYHEDRON_3_FEATURES_H #define CGAL_PROPERTIES_POLYHEDRON_3_FEATURES_H +#include + + #include #include diff --git a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_time_stamp.h b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_time_stamp.h index bd8ad12bc5f..8d88c8fd895 100644 --- a/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_time_stamp.h +++ b/Polyhedron/include/CGAL/boost/graph/properties_Polyhedron_3_time_stamp.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri @@ -12,6 +12,9 @@ #ifndef CGAL_PROPERTIES_POLYHEDRON_3_TIME_STAMP_H #define CGAL_PROPERTIES_POLYHEDRON_3_TIME_STAMP_H +#include + + #include #define CGAL_HDS_PARAM_ template < class Traits, class Items, class Alloc> class HDS diff --git a/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_2.h b/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_2.h index 27c168ffa39..c051cf033b3 100644 --- a/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_2.h +++ b/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_2.h @@ -9,7 +9,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Sven Schoenherr @@ -17,6 +17,9 @@ #ifndef CGAL_POLYTOPE_DISTANCE_D_TRAITS_2_H #define CGAL_POLYTOPE_DISTANCE_D_TRAITS_2_H +#include + + // includes # include # include diff --git a/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_3.h b/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_3.h index 459ea4b06df..fefc27f69ee 100644 --- a/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_3.h +++ b/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_3.h @@ -9,7 +9,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Sven Schoenherr @@ -17,6 +17,9 @@ #ifndef CGAL_POLYTOPE_DISTANCE_D_TRAITS_3_H #define CGAL_POLYTOPE_DISTANCE_D_TRAITS_3_H +#include + + // includes # include # include diff --git a/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_d.h b/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_d.h index e7de86d3009..1c88c7ee567 100644 --- a/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_d.h +++ b/Polytope_distance_d/include/CGAL/Polytope_distance_d_traits_d.h @@ -9,7 +9,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Sven Schoenherr @@ -17,6 +17,9 @@ #ifndef CGAL_POLYTOPE_DISTANCE_D_TRAITS_D_H #define CGAL_POLYTOPE_DISTANCE_D_TRAITS_D_H +#include + + // includes # include # include diff --git a/Principal_component_analysis/include/CGAL/Subiterator.h b/Principal_component_analysis/include/CGAL/Subiterator.h index 186776918be..c860be7a361 100644 --- a/Principal_component_analysis/include/CGAL/Subiterator.h +++ b/Principal_component_analysis/include/CGAL/Subiterator.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Simon Giraudot // @@ -13,6 +13,9 @@ #ifndef CGAL_PCA_SUBITERATOR_H #define CGAL_PCA_SUBITERATOR_H +#include + + #include namespace CGAL diff --git a/QP_solver/include/CGAL/QP_solver/Initialization.h b/QP_solver/include/CGAL/QP_solver/Initialization.h index 88eb0636fb3..99873022d2d 100644 --- a/QP_solver/include/CGAL/QP_solver/Initialization.h +++ b/QP_solver/include/CGAL/QP_solver/Initialization.h @@ -13,6 +13,11 @@ // Franz Wessendorp // Kaspar Fischer +#ifndef CGAL_QP_SOLVER_INITIALIZATION_H +#define CGAL_QP_SOLVER_INITIALIZATION_H + +#include + #include #include @@ -664,3 +669,5 @@ init_additional_data_members() } //namespace CGAL // ===== EOF ================================================================== + +#endif //CGAL_QP_SOLVER_INITIALIZATION_H diff --git a/QP_solver/include/CGAL/QP_solver/QP__filtered_base_impl.h b/QP_solver/include/CGAL/QP_solver/QP__filtered_base_impl.h index 194a7607e64..bffac7ad089 100644 --- a/QP_solver/include/CGAL/QP_solver/QP__filtered_base_impl.h +++ b/QP_solver/include/CGAL/QP_solver/QP__filtered_base_impl.h @@ -13,6 +13,11 @@ // Franz Wessendorp // Kaspar Fischer +#ifndef CGAL_QP_FILTERED_BASE_IMPL_H +#define CGAL_QP_FILTERED_BASE_IMPL_H + +#include + namespace CGAL { // ============================= @@ -370,3 +375,5 @@ transition( ) } //namespace CGAL // ===== EOF ================================================================== + +#endif // CGAL_QP_FILTERED_BASE_IMPL_H diff --git a/QP_solver/include/CGAL/QP_solver/QP_basis_inverse_impl.h b/QP_solver/include/CGAL/QP_solver/QP_basis_inverse_impl.h index 04e8f3f36d4..890d1ba296b 100644 --- a/QP_solver/include/CGAL/QP_solver/QP_basis_inverse_impl.h +++ b/QP_solver/include/CGAL/QP_solver/QP_basis_inverse_impl.h @@ -13,6 +13,11 @@ // Franz Wessendorp // Kaspar Fischer +#ifndef CGAL_QP_SOLVER_QP_BASIS_INVERSE_IMPL_H +#define CGAL_QP_SOLVER_QP_BASIS_INVERSE_IMPL_H + +#include + namespace CGAL { // ============================= @@ -700,3 +705,5 @@ print( ) } //namespace CGAL // ===== EOF ================================================================== + +#endif //CGAL_QP_SOLVER_QP_BASIS_INVERSE_IMPL_H diff --git a/QP_solver/include/CGAL/QP_solver/QP_solver_bounds_impl.h b/QP_solver/include/CGAL/QP_solver/QP_solver_bounds_impl.h index 1f0a73e1a49..1e67055cbf8 100644 --- a/QP_solver/include/CGAL/QP_solver/QP_solver_bounds_impl.h +++ b/QP_solver/include/CGAL/QP_solver/QP_solver_bounds_impl.h @@ -13,6 +13,11 @@ // Franz Wessendorp // Kaspar Fischer +#ifndef CGAL_QP_SOLVER_QP_SOLVER_BOUNDS_IMPL_H +#define CGAL_QP_SOLVER_QP_SOLVER_BOUNDS_IMPL_H + +#include + namespace CGAL { template < typename Q, typename ET, typename Tags > @@ -89,3 +94,5 @@ QP_solver::upper_bnd(int i) const } //namespace CGAL // ===== EOF ================================================================== + +#endif //CGAL_QP_SOLVER_QP_SOLVER_BOUNDS_IMPL_H diff --git a/QP_solver/include/CGAL/QP_solver/QP_solver_impl.h b/QP_solver/include/CGAL/QP_solver/QP_solver_impl.h index bc62b5ae88f..262e20f1ba7 100644 --- a/QP_solver/include/CGAL/QP_solver/QP_solver_impl.h +++ b/QP_solver/include/CGAL/QP_solver/QP_solver_impl.h @@ -13,6 +13,11 @@ // Franz Wessendorp // Kaspar Fischer +#ifndef CGAL_QP_SOLVER_IMPL_H +#define CGAL_QP_SOLVER_IMPL_H + +#include + #include #include @@ -3393,3 +3398,5 @@ get_l() const } //namespace CGAL // ===== EOF ================================================================== + +#endif //CGAL_QP_SOLVER_IMPL_H diff --git a/QP_solver/include/CGAL/QP_solver/QP_solver_nonstandardform_impl.h b/QP_solver/include/CGAL/QP_solver/QP_solver_nonstandardform_impl.h index 57118dac1e2..9b0b230c40a 100644 --- a/QP_solver/include/CGAL/QP_solver/QP_solver_nonstandardform_impl.h +++ b/QP_solver/include/CGAL/QP_solver/QP_solver_nonstandardform_impl.h @@ -13,6 +13,11 @@ // Franz Wessendorp // Kaspar Fischer +#ifndef CGAL_QP_SOLVER_NONSTANDARDFORM_IMPL_H +#define CGAL_QP_SOLVER_NONSTANDARDFORM_IMPL_H + +#include + namespace CGAL { // Looks in x_O_v_i which bound is present for variable i and returns @@ -219,3 +224,5 @@ init_w() } //namespace CGAL // ===== EOF ================================================================== + +#endif // CGAL_QP_SOLVER_NONSTANDARDFORM_IMPL_H diff --git a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h index a71e38f8c43..7b250380193 100644 --- a/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h +++ b/SMDS_3/include/CGAL/SMDS_3/tet_soup_to_c3t3.h @@ -596,24 +596,22 @@ bool build_triangulation_from_file(std::istream& is, bool is_CGAL_mesh = false; - while(is >> word && word != "End") + std::string line; + while(std::getline(is, line) && line != "End") { - if (word.at(0) == '#') + // remove trailing whitespace, in particular a possible '\r' from Windows + // end-of-line encoding + if(!line.empty() && std::isspace(line.back())) { + line.pop_back(); + } + if (line.size() > 0 && line.at(0) == '#' && + line.find("CGAL::Mesh_complex_3_in_triangulation_3") != std::string::npos) { - is >> word; - if (word == "End") - { - break; - } - else if (word == "CGAL::Mesh_complex_3_in_triangulation_3") - { - is_CGAL_mesh = true; // with CGAL meshes, domain 0 should be kept - continue; - } - //else skip other comments + is_CGAL_mesh = true; // with CGAL meshes, domain 0 should be kept + continue; } - if(word == "Vertices") + if(line == "Vertices") { is >> nv; for(int i=0; i> nf; for(int i=0; i> ntet; for(int i=0; i +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#define SDG_DRAW_DEBUG // debug log +#define SDG_DRAW_DUMP_FILES // print input / ouput +// #define SINGLE_INPUT_FILE // if not defined, each segment of the input has its own file + +#ifdef SDG_DRAW_DUMP_FILES_PP // also print parabolas +#define SDG_DRAW_DUMP_FILES +#endif + +typedef CGAL::Simple_cartesian CK; +typedef CK::Point_2 Point_2; +typedef CK::Segment_2 Segment_2; +typedef CGAL::Field_with_sqrt_tag CM; +typedef CGAL::Exact_predicates_exact_constructions_kernel_with_sqrt EK; +typedef CGAL::Field_with_sqrt_tag EM; +typedef CGAL::Simple_cartesian > FK; +typedef CGAL::Field_with_sqrt_tag FM; +typedef CGAL::Segment_Delaunay_graph_filtered_traits_2 Gt; +typedef CGAL::Segment_Delaunay_graph_2 SDG; + +///////////////////////////////// CODE ABOUT EXACT DUALS /////////////////////////////////////////// + +template < typename ExactSite, typename ExactKernel, + typename SDGSite, typename InputKernel > +ExactSite convert_site_to_exact(const SDGSite &site, + const InputKernel & /*k*/, + const ExactKernel & /*ek*/) +{ + using To_exact = CGAL::Cartesian_converter; + To_exact to_exact; + + // Note: in theory, a site can be constructed from more than just one or two points + // (e.g. 4 points for the segment defined by the intersection of two segments). Thus, it + // would be better to convert the input points at the very beginning and just maintain + // a type of map between the base and exact sites. + ExactSite es; + if(site.is_point()) + es = ExactSite::construct_site_2(to_exact(site.point())); + else + es = ExactSite::construct_site_2(to_exact(site.segment().source()), to_exact(site.segment().target())); + + return es; +} + +// Dual (Voronoi site) of an SDG face +template < typename FiniteFacesIterator, typename InputKernel, typename ExactKernel > +typename ExactKernel::Point_2 exact_primal(const FiniteFacesIterator sdg_f, + const InputKernel& k, + const ExactKernel& ek) +{ + using Exact_SDG_traits = CGAL::Segment_Delaunay_graph_traits_2; + using Exact_site_2 = typename Exact_SDG_traits::Site_2; + + static Exact_SDG_traits e_sdg_gt; + const Exact_site_2 es0 = convert_site_to_exact(sdg_f->vertex(0)->site(), k, ek); + const Exact_site_2 es1 = convert_site_to_exact(sdg_f->vertex(1)->site(), k, ek); + const Exact_site_2 es2 = convert_site_to_exact(sdg_f->vertex(2)->site(), k, ek); + + return e_sdg_gt.construct_svd_vertex_2_object()(es0, es1, es2); +} + +// Dual (Voronoi edge) of an SDG edge +// this function is identical 'SDG::primal()', but with a conversion to exact sites +template < typename Edge, typename InputKernel, typename ExactKernel > +CGAL::Object exact_primal(const Edge& e, + const SDG& sdg, + const InputKernel& k, + const ExactKernel& ek) +{ + using Exact_SDG_traits = CGAL::Segment_Delaunay_graph_traits_2; + using Exact_site_2 = typename Exact_SDG_traits::Site_2; + + using DT = CGAL::Field_with_sqrt_tag; + using Construct_sdg_bisector_2 = CGAL::SegmentDelaunayGraph_2::Construct_sdg_bisector_2; + using Construct_sdg_bisector_ray_2 = CGAL::SegmentDelaunayGraph_2::Construct_sdg_bisector_ray_2; + using Construct_sdg_bisector_segment_2 = CGAL::SegmentDelaunayGraph_2::Construct_sdg_bisector_segment_2; + + CGAL_precondition(!sdg.is_infinite(e)); + + if(sdg.dimension() == 1) + { + Exact_site_2 p = convert_site_to_exact((e.first)->vertex(sdg.cw(e.second))->site(), k, ek); + Exact_site_2 q = convert_site_to_exact((e.first)->vertex(sdg.ccw(e.second))->site(), k, ek); + + return make_object(Construct_sdg_bisector_2()(p, q)); + } + + // dimension == 2 + // neither of the two adjacent faces is infinite + if((!sdg.is_infinite(e.first)) && (!sdg.is_infinite(e.first->neighbor(e.second)))) + { + Exact_site_2 p = convert_site_to_exact((e.first)->vertex(sdg.ccw(e.second))->site(), k, ek); + Exact_site_2 q = convert_site_to_exact((e.first)->vertex(sdg.cw(e.second))->site(), k, ek); + Exact_site_2 r = convert_site_to_exact((e.first)->vertex(e.second)->site(), k, ek); + Exact_site_2 s = convert_site_to_exact(sdg.tds().mirror_vertex(e.first, e.second)->site(), k, ek); + + return Construct_sdg_bisector_segment_2()(p, q, r, s); + } + + // both of the adjacent faces are infinite + if(sdg.is_infinite(e.first) && sdg.is_infinite(e.first->neighbor(e.second))) + { + Exact_site_2 p = convert_site_to_exact((e.first)->vertex(sdg.cw(e.second))->site(), k, ek); + Exact_site_2 q = convert_site_to_exact((e.first)->vertex(sdg.ccw(e.second))->site(), k, ek); + + return make_object(Construct_sdg_bisector_2()(p, q)); + } + + // only one of the adjacent faces is infinite + CGAL_assertion(sdg.is_infinite(e.first) || sdg.is_infinite(e.first->neighbor(e.second))); + CGAL_assertion(!(sdg.is_infinite(e.first) && sdg.is_infinite(e.first->neighbor(e.second)))); + CGAL_assertion(sdg.is_infinite(e.first->vertex(e.second)) || sdg.is_infinite(sdg.tds().mirror_vertex(e.first, e.second))); + + Edge ee = e; + if(sdg.is_infinite(e.first->vertex(e.second))) + { + ee = Edge(e.first->neighbor(e.second), + e.first->neighbor(e.second)->index(sdg.tds().mirror_vertex(e.first, e.second))); + } + + Exact_site_2 p = convert_site_to_exact(ee.first->vertex(sdg.ccw(ee.second))->site(), k, ek); + Exact_site_2 q = convert_site_to_exact(ee.first->vertex(sdg.cw(ee.second))->site(), k, ek); + Exact_site_2 r = convert_site_to_exact(ee.first->vertex(ee.second)->site(), k, ek); + + return make_object(Construct_sdg_bisector_ray_2()(p, q, r)); +} + +///////////////////////////////// CODE TO DRAW A CROPPED DIAGRAM /////////////////////////////////// + +// Split a Voronoi edge that is a parabola (one site is a point, one site is a segment) into small segments +template +void segment_parabola(const CGAL::Parabola_segment_2& p, + const CGAL::Bbox_2& scaled_bbox, + SegmentContainer& segment_list) +{ + using FT = typename OutputKernel::FT; + using Point_2 = typename OutputKernel::Point_2; + + const Point_2& o = p.origin(); + const Point_2& c = p.center(); + + // @todo could be cached + const Point_2 mm(scaled_bbox.xmin(), scaled_bbox.ymin()); + const Point_2 mM(scaled_bbox.xmin(), scaled_bbox.ymax()); + const Point_2 Mm(scaled_bbox.xmax(), scaled_bbox.ymin()); + const Point_2 MM(scaled_bbox.xmax(), scaled_bbox.ymax()); + + FT s = CGAL::squared_distance(mm, c); + s = (std::max)(s, CGAL::squared_distance(mM, c)); + s = (std::max)(s, CGAL::squared_distance(Mm, c)); + s = (std::max)(s, CGAL::squared_distance(MM, c)); + + s = CGAL::sqrt(s) - CGAL::sqrt(CGAL::squared_distance(c, o)); + + const double lx = scaled_bbox.xmax() - scaled_bbox.xmin(); + const double ly = scaled_bbox.ymax() - scaled_bbox.ymin(); + + const double max_length = 0.001 * (std::min)(lx, ly); // max length in the discretization of a parabola + +#ifdef SDG_DRAW_DEBUG + std::cout << "origin & center: " << o << " [[]] " << c << std::endl; + std::cout << "max length " << max_length << std::endl; +#endif + + std::vector points; + p.generate_points(points, max_length, -s, s); + +#ifdef SDG_DRAW_DEBUG + std::cout << "Discretize parabola into " << points.size() << " points" << std::endl; + for(const auto& pt : points) + std::cout << CGAL::to_double(pt.x()) << " " << CGAL::to_double(pt.y()) << " 0" << std::endl; + std::cout << "end of parabola" << std::endl; +#endif + + if(points.size() < 2) + return; + + for(std::size_t i=0, ps=points.size()-1; i +void fill_Voronoi_structure(const SDG& sdg, + const CGAL::Bbox_2& scaled_bbox, + LineContainer& line_list, + RayContainer& ray_list, + SegmentContainer& segment_list) +{ + using Line_2 = typename OutputKernel::Line_2; + using Ray_2 = typename OutputKernel::Ray_2; + using Segment_2 = typename OutputKernel::Segment_2; + using SDG_traits = CGAL::Segment_Delaunay_graph_traits_2; + + CK k; + OutputKernel ek; + + Line_2 l; + Ray_2 r; + Segment_2 s; + CGAL::Parabola_segment_2 p; + + int nl = 0, ns = 0, nr = 0, np = 0; + + typename SDG::Finite_edges_iterator eit = sdg.finite_edges_begin(), + eend = sdg.finite_edges_end(); + for (; eit != eend; ++eit) + { + CGAL::Object o = exact_primal(*eit, sdg, k, ek); + + if(CGAL::assign(l, o)) { line_list.push_back(l); ++nl; } + if(CGAL::assign(s, o)) { segment_list.push_back(s); ++ns; } + if(CGAL::assign(r, o)) { ray_list.push_back(r); ++nr; } + if(CGAL::assign(p, o)) { segment_parabola(p, scaled_bbox, segment_list); ++np; } + } + +#ifdef SDG_DRAW_DEBUG + std::cout << nl << " lines" << std::endl; + std::cout << ns << " segments" << std::endl; + std::cout << nr << " rays" << std::endl; + std::cout << np << " parabolas" << std::endl; +#endif +} + +template +struct Box_clipper +{ + bool operator()(const T& obj, + const typename OutputKernel::Iso_rectangle_2& bbox, + OutputIterator oit) const + { + CGAL::Object obj_cgal = CGAL::intersection(obj, bbox); + + typename OutputKernel::Segment_2 s; + bool ret = CGAL::assign(s, obj_cgal); + if(ret) + oit++ = s; + + return ret; + } +}; + +template +struct Box_clipper +{ + bool operator()(const typename OutputKernel::Segment_2& is, + const typename OutputKernel::Iso_rectangle_2& bbox, + OutputIterator oit) const + { + if(bbox.has_on_unbounded_side(is.source()) && bbox.has_on_unbounded_side(is.target())) + return false; + + if(!bbox.has_on_unbounded_side(is.source()) && !bbox.has_on_unbounded_side(is.target())) + { + oit++ = is; + return true; + } + + CGAL::Object obj_cgal = CGAL::intersection(is, bbox); + + typename OutputKernel::Segment_2 s; + bool ret = CGAL::assign(s, obj_cgal); + if(ret) + oit++ = s; + + return ret; + } +}; + +template +void draw_dual(const LineContainer& lines, + const RayContainer& rays, + const SegmentContainer& segments, + const typename OutputKernel::Iso_rectangle_2& bbox, + OutputIterator oit) +{ + using Line_2 = typename OutputKernel::Line_2; + using Ray_2 = typename OutputKernel::Ray_2; + using Segment_2 = typename OutputKernel::Segment_2; + + typedef Box_clipper Line_clipper; + typedef Box_clipper Ray_clipper; + typedef Box_clipper Segment_clipper; + + Line_clipper lc; + Ray_clipper rc; + Segment_clipper sc; + + for(const Line_2& line : lines) + lc(line, bbox, oit); + for(const Ray_2& ray : rays) + rc(ray, bbox, oit); + for(const Segment_2& segment : segments) + sc(segment, bbox, oit); +} + +template< typename OutputKernel, typename OutputIterator > +OutputIterator draw_SDG(const SDG& sdg, + const typename OutputKernel::Iso_rectangle_2& bbox, + const CGAL::Bbox_2& scaled_bbox, + OutputIterator oit) +{ + using Line_2 = typename OutputKernel::Line_2; + using Ray_2 = typename OutputKernel::Ray_2; + using Segment_2 = typename OutputKernel::Segment_2; + + std::list line_list; + std::list ray_list; + std::list segment_list; + + fill_Voronoi_structure(sdg, scaled_bbox, line_list, ray_list, segment_list); + draw_dual(line_list, ray_list, segment_list, bbox, oit); + + return oit; +} + +int main(int argc, char** argv) +{ + std::cout.precision(17); + std::cout << std::fixed; + + if(argc < 2) + std::cout << "Usage: " << argv[0] << " input.cin" << std::endl; + +#ifdef SDG_DRAW_DUMP_FILES + // dump the input + std::ifstream input((argc > 1) ? argv[1] : "./data/sites.cin"); + assert(input); + + std::string str; + int i = 0; + +# ifdef SINGLE_INPUT_FILE + std::ofstream in_out("input.cgal"); + in_out.precision(17); +# endif + + // read line by line, and distinguish between point and segment + std::string line; + while(std::getline(input, line)) + { +# ifndef SINGLE_INPUT_FILE + std::stringstream oss; + oss << "input_" << i++ << ".cgal" << std::ends; + std::ofstream in_out(oss.str().c_str()); + in_out.precision(17); +# endif + + std::stringstream ss(line); + ss >> str; + if(str == "s") + { + double x0, y0, x1, y1; + ss >> x0 >> y0 >> x1 >> y1; + + in_out << "2 " << x0 << " " << y0 << " 0 "; + in_out << x1 << " " << y1 << " 0\n"; + } + else if(str == "p") + { + double x, y; + ss >> x >> y; + + in_out << "2 " << x << " " << y << " 0\n"; + in_out << x << " " << y << " 0\n"; // abusive 0-length polyline + } + else + { + std::cerr << "Error: Unknown input: " << str << std::endl; + return EXIT_FAILURE; + } + +# ifndef SINGLE_INPUT_FILE + in_out.close(); +# endif + } +# ifdef SINGLE_INPUT_FILE + in_out.close(); +# endif +#endif + + std::ifstream ifs((argc > 1) ? argv[1] : "./data/sites.cin"); + assert(ifs); + + // polygon points + std::set all_points; + + // segments of the polygon as a pair of point indices + std::vector points; + std::vector segments; + SDG::Site_2 site; + + // read segment input, format: + // s [x0 y0 x1 y1] + // p [x y] + + while (ifs >> site) + { + if(site.is_segment()) + { + all_points.insert(site.source_of_supporting_site()); + all_points.insert(site.target_of_supporting_site()); + segments.push_back(site.segment()); + } + else + { + all_points.insert(site.point()); + points.push_back(site.point()); + } + } + + if(points.empty() && segments.empty()) + { + std::cerr << "Nothing in input..." << std::endl; + return EXIT_SUCCESS; + } + + // insert the sites all at once using spatial sorting to speed the insertion + SDG sdg; + sdg.insert_points(points.begin(), points.end()); + sdg.insert_segments(segments.begin(), segments.end()); + assert(sdg.is_valid(true, 1)); // validate the segment Delaunay graph + + typedef EK OK; // output kernel + std::list svd_edges; + + // Get the bbox of the input points, and grow it a bit + const CGAL::Bbox_2 bbox = bbox_2(all_points.begin(), all_points.end()); + const double xmin = bbox.xmin(), xmax = bbox.xmax(); + const double ymin = bbox.ymin(), ymax = bbox.ymax(); + const double xmid = 0.5 * (xmin + xmax), ymid = 0.5 * (ymin + ymax); + const double scaling_factor = 3.; // '0.5' gives the identity + const double lx = scaling_factor * (xmax - xmin), + ly = scaling_factor * (ymax - ymin); + const CGAL::Bbox_2 scaled_bbox(xmid - lx, ymid - ly, xmid + lx, ymid + ly); + const OK::Iso_rectangle_2 bounding_iso_rec(scaled_bbox); + +#ifdef SDG_DRAW_DEBUG + std::cout << "bbox: " << bbox.xmin() << " " << bbox.ymin() << std::endl; + std::cout << "bbox: " << bbox.xmax() << " " << bbox.ymax() << std::endl; + std::cout << "lx/y: " << lx << " " << ly << std::endl; + std::cout << "Scaled bbox: " << scaled_bbox.xmin() << " " << scaled_bbox.ymin() << std::endl; + std::cout << "Scaled bbox: " << scaled_bbox.xmax() << " " << scaled_bbox.ymax() << std::endl; +#endif + + draw_SDG(sdg, bounding_iso_rec, scaled_bbox, std::back_inserter(svd_edges)); + +#ifdef SDG_DRAW_DEBUG + std::cout << "Edges of the diagram (exact form):" << std::endl; + for(const OK::Segment_2& edge : svd_edges) + std::cout << edge << "\n"; + + std::cout << "Now in the double, approximate format..." << std::endl; + for(const OK::Segment_2& edge : svd_edges) + { + std::cout << CGAL::to_double(edge.source().x()) << " "; + std::cout << CGAL::to_double(edge.source().y()) << " "; + std::cout << CGAL::to_double(edge.target().x()) << " "; + std::cout << CGAL::to_double(edge.target().y()) << "\n"; + } +#endif + +#ifdef SDG_DRAW_DUMP_FILES + // This file can be visualized with the CGAL 3D Polyhedron Demo + std::ofstream out("dual.cgal"); + out.precision(17); + for(const OK::Segment_2& edge : svd_edges) + { + out << "2 " << CGAL::to_double(edge.source().x()) << " "; + out << CGAL::to_double(edge.source().y()) << " 0 "; + out << CGAL::to_double(edge.target().x()) << " "; + out << CGAL::to_double(edge.target().y()) << " 0\n"; + } +#endif + + std::cout << "Done" << std::endl; + + return EXIT_SUCCESS; +} diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h index 1c684d32202..05a199a5bff 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2.h @@ -632,11 +632,11 @@ public: } template - static const Point_2& get_source(const Segment_2& segment){ + static Point_2 get_source(const Segment_2& segment){ return segment.source(); } template - static const Point_2& get_target(const Segment_2& segment){ + static Point_2 get_target(const Segment_2& segment){ return segment.target(); } diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h index 88d634e0324..00c2130c50a 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_2_impl.h @@ -10,6 +10,10 @@ // // Author(s) : Menelaos Karavelas +#ifndef CGAL_SEGMENT_DELAUNAY_GRAPH_2_SDG_2_IMPL_H +#define CGAL_SEGMENT_DELAUNAY_GRAPH_2_SDG_2_IMPL_H + +#include // class implementation continued //================================= @@ -3325,3 +3329,5 @@ file_input(std::istream& is, bool read_handle_vector, } //namespace CGAL // EOF + +#endif // CGAL_SEGMENT_DELAUNAY_GRAPH_2_SDG_2_IMPL_H diff --git a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h index 14697569e3c..1434020ccd9 100644 --- a/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h +++ b/Segment_Delaunay_graph_2/include/CGAL/Segment_Delaunay_graph_2/Segment_Delaunay_graph_hierarchy_2_impl.h @@ -10,7 +10,10 @@ // // Author(s) : Menelaos Karavelas +#ifndef CGAL_SEGMENT_DELAUNAY_GRAPH_2_SDG_HIERARCHY_IMPL_H +#define CGAL_SEGMENT_DELAUNAY_GRAPH_2_SDG_HIERARCHY_IMPL_H +#include // class implementation continued @@ -1145,3 +1148,5 @@ file_input(std::istream& is) // EOF + +#endif //CGAL_SEGMENT_DELAUNAY_GRAPH_2_SDG_HIERARCHY_IMPL_H diff --git a/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/issue7972.cpp b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/issue7972.cpp new file mode 100644 index 00000000000..6dd4a4e5e2b --- /dev/null +++ b/Segment_Delaunay_graph_2/test/Segment_Delaunay_graph_2/issue7972.cpp @@ -0,0 +1,21 @@ + +#include +#include +#include + +typedef CGAL::Exact_predicates_exact_constructions_kernel K; +typedef CGAL::Segment_Delaunay_graph_traits_2 Gt; +typedef CGAL::Segment_Delaunay_graph_2 SDG2; + +int main() { + auto segments = std::vector({ + CGAL::Segment_2( + CGAL::Point_2(0.0, 0.0), + CGAL::Point_2(1.0, 0.0)) + }); + + SDG2 delaunay; + delaunay.insert_segments(segments.begin(), segments.end()); + + return 0; +} diff --git a/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_2_impl.h b/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_2_impl.h index 73a5247879e..4aff29fb69b 100644 --- a/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_2_impl.h +++ b/Segment_Delaunay_graph_Linf_2/include/CGAL/Segment_Delaunay_graph_Linf_2/Segment_Delaunay_graph_Linf_2_impl.h @@ -11,6 +11,11 @@ // Author(s) : Panagiotis Cheilaris, Sandeep Kumar Dey, Evanthia Papadopoulou //philaris@gmail.com, sandeep.kr.dey@gmail.com, evanthia.papadopoulou@usi.ch +#ifndef CGAL_SEGMENT_DELAUNAY_GRAPH_LINF_2_SDG_LINF_2_IMPL_H +#define CGAL_SEGMENT_DELAUNAY_GRAPH_LINF_2_SDG_LINF_2_IMPL_H + +#include + namespace CGAL { // print face in standard output @@ -759,3 +764,5 @@ insert_point_on_segment(const Storage_site_2& ss, const Site_2& , } //namespace CGAL // EOF + +#endif // CGAL_SEGMENT_DELAUNAY_GRAPH_LINF_2_SDG_LINF_2_IMPL_H diff --git a/Shape_detection/include/CGAL/Polygon_mesh_processing/region_growing.h b/Shape_detection/include/CGAL/Polygon_mesh_processing/region_growing.h index 92571c43b1d..fc594b9122f 100644 --- a/Shape_detection/include/CGAL/Polygon_mesh_processing/region_growing.h +++ b/Shape_detection/include/CGAL/Polygon_mesh_processing/region_growing.h @@ -106,7 +106,8 @@ private: @param mesh the polygon mesh whose faces are used for region growing @param region_map a property map storing the region index of each face. Values start at `0` up to the value returned minus `1`. - `std::size_t(-1)` is put for faces with no region assigned (can only happen if `minimum_region_size > 1`). + `std::size_t(-1)` is put for faces with no region assigned (it can happen if `minimum_region_size > 1` or for a non-triangular + face having a fitting plane not satisfying the maximum distance criterium). @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below @return the number of regions detected diff --git a/Straight_skeleton_2/examples/Straight_skeleton_2/extrude_skeleton.cpp b/Straight_skeleton_2/examples/Straight_skeleton_2/extrude_skeleton.cpp index cc73aa7493b..6fb5ad59dd4 100644 --- a/Straight_skeleton_2/examples/Straight_skeleton_2/extrude_skeleton.cpp +++ b/Straight_skeleton_2/examples/Straight_skeleton_2/extrude_skeleton.cpp @@ -1,6 +1,6 @@ #include #include -#include +//#include #include #include diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/Dxf_stream.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/Dxf_stream.h index 6240cdb1a2e..61b3eed75b2 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/Dxf_stream.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/Dxf_stream.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Fernando Cacciola @@ -15,6 +15,9 @@ #ifndef CGAL_DXF_STREAM_H #define CGAL_DXF_STREAM_H +#include + + #include #include diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/Dxf_writer.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/Dxf_writer.h index 11a41b3a204..2251dbe09e2 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/Dxf_writer.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/Dxf_writer.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Fernando Cacciola @@ -15,6 +15,9 @@ #ifndef CGAL_IO_DXF_WRITER_H #define CGAL_IO_DXF_WRITER_H +#include + + #include #include diff --git a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/print.h b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/print.h index a36df07b51e..6c9c493ae87 100644 --- a/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/print.h +++ b/Straight_skeleton_2/include/CGAL/Straight_skeleton_2/IO/print.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_SLS_IO_PRINT_H #define CGAL_SLS_IO_PRINT_H +#include + + #include #include #include diff --git a/Straight_skeleton_2/include/CGAL/certified_numeric_predicates.h b/Straight_skeleton_2/include/CGAL/certified_numeric_predicates.h index a88aea91d79..f7d82b3c093 100644 --- a/Straight_skeleton_2/include/CGAL/certified_numeric_predicates.h +++ b/Straight_skeleton_2/include/CGAL/certified_numeric_predicates.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Fernando Cacciola // #ifndef CGAL_CERTIFIED_NUMERIC_PREDICATES_H #define CGAL_CERTIFIED_NUMERIC_PREDICATES_H +#include + + #include #include #include diff --git a/Straight_skeleton_2/include/CGAL/certified_quotient_predicates.h b/Straight_skeleton_2/include/CGAL/certified_quotient_predicates.h index d6896189349..5ecf764b5d8 100644 --- a/Straight_skeleton_2/include/CGAL/certified_quotient_predicates.h +++ b/Straight_skeleton_2/include/CGAL/certified_quotient_predicates.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Fernando Cacciola // #ifndef CGAL_CERTIFIED_QUOTIENT_PREDICATES_H #define CGAL_CERTIFIED_QUOTIENT_PREDICATES_H +#include + + #include #include diff --git a/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt b/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt index 6138c50d054..20fdb058a7b 100644 --- a/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt +++ b/Straight_skeleton_2/test/Straight_skeleton_2/CMakeLists.txt @@ -5,23 +5,34 @@ cmake_minimum_required(VERSION 3.1...3.23) project(Straight_skeleton_2_Tests) find_package(CGAL REQUIRED COMPONENTS Qt6 Core) +find_package(LEDA QUIET) include_directories(BEFORE "include") -# create a target per cppfile -file( - GLOB cppfiles - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) -foreach(cppfile ${cppfiles}) - create_single_source_cgal_program("${cppfile}") -endforeach() +create_single_source_cgal_program("issue4533.cpp") +create_single_source_cgal_program("issue4684.cpp") +create_single_source_cgal_program("test_sls.cpp") +create_single_source_cgal_program("test_sls_previous_issues.cpp") +create_single_source_cgal_program("test_sls_traits.cpp") +create_single_source_cgal_program("test_straight_skeleton_copy.cpp") if(CGAL_Qt6_FOUND) target_link_libraries(issue4684 PUBLIC CGAL::CGAL_Basic_viewer) - target_link_libraries(issue7149 PUBLIC CGAL::CGAL_Basic_viewer) - target_link_libraries(issue7284 PUBLIC CGAL::CGAL_Basic_viewer) target_link_libraries(test_sls_previous_issues PUBLIC CGAL::CGAL_Basic_viewer) - target_link_libraries(test_sls_offset PUBLIC CGAL::CGAL_Basic_viewer) - target_link_libraries(test_sls_weighted_polygons_with_holes PUBLIC CGAL::CGAL_Basic_viewer) +endif() + +if (CGAL_Core_FOUND OR LEDA_FOUND) + create_single_source_cgal_program("test_sls_offset.cpp") + create_single_source_cgal_program("issue7284.cpp") + create_single_source_cgal_program("test_sls_simple.cpp") + create_single_source_cgal_program("test_sls_weighted_polygons_with_holes.cpp") + create_single_source_cgal_program("issue7149.cpp") + if(CGAL_Qt6_FOUND) + target_link_libraries(issue7149 PUBLIC CGAL::CGAL_Basic_viewer) + target_link_libraries(issue7284 PUBLIC CGAL::CGAL_Basic_viewer) + target_link_libraries(test_sls_offset PUBLIC CGAL::CGAL_Basic_viewer) + target_link_libraries(test_sls_weighted_polygons_with_holes PUBLIC CGAL::CGAL_Basic_viewer) + endif() +else() + message("NOTICE: Some test require CGAL_Core (or LEDA), and will not be compiled.") endif() diff --git a/Straight_skeleton_extrusion_2/test/Straight_skeleton_extrusion_2/CMakeLists.txt b/Straight_skeleton_extrusion_2/test/Straight_skeleton_extrusion_2/CMakeLists.txt index 8dd920fdf64..bfc26d7ea20 100644 --- a/Straight_skeleton_extrusion_2/test/Straight_skeleton_extrusion_2/CMakeLists.txt +++ b/Straight_skeleton_extrusion_2/test/Straight_skeleton_extrusion_2/CMakeLists.txt @@ -5,18 +5,15 @@ cmake_minimum_required(VERSION 3.1...3.23) project(Straight_skeleton_extrusion_2_Tests) find_package(CGAL REQUIRED COMPONENTS Qt6 Core) +find_package(LEDA QUIET) include_directories(BEFORE "include") -# create a target per cppfile -file( - GLOB cppfiles - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) -foreach(cppfile ${cppfiles}) - create_single_source_cgal_program("${cppfile}") -endforeach() - -if(CGAL_Qt6_FOUND) - target_link_libraries(test_sls_extrude PUBLIC CGAL::CGAL_Basic_viewer) +if (CGAL_Core_FOUND OR LEDA_FOUND) + create_single_source_cgal_program("test_sls_extrude.cpp") + if(CGAL_Qt6_FOUND) + target_link_libraries(test_sls_extrude PUBLIC CGAL::CGAL_Basic_viewer) + endif() +else() + message("NOTICE: Tests require CGAL_Core (or LEDA), and will not be compiled.") endif() diff --git a/Stream_support/include/CGAL/IO/PLY/PLY_writer.h b/Stream_support/include/CGAL/IO/PLY/PLY_writer.h index be015411a56..126c12ab773 100644 --- a/Stream_support/include/CGAL/IO/PLY/PLY_writer.h +++ b/Stream_support/include/CGAL/IO/PLY/PLY_writer.h @@ -266,7 +266,7 @@ public: virtual void print(std::ostream& stream, const Index& index) { if(get_mode(stream) == CGAL::IO::ASCII) - stream << get(m_pmap, index); + stream << no_char_character(get(m_pmap, index)); else { Type t = Type(get(m_pmap, index)); diff --git a/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h b/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h index d044c38a557..b46df17715b 100644 --- a/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h +++ b/Surface_mesh/include/CGAL/boost/graph/graph_traits_Surface_mesh.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Philipp Moeller diff --git a/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh.h b/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh.h index 281c2b37093..785cec65003 100644 --- a/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh.h +++ b/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Philipp Möller diff --git a/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_features.h b/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_features.h index b6fbb66f968..1484943f078 100644 --- a/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_features.h +++ b/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_features.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri @@ -12,6 +12,9 @@ #ifndef CGAL_PROPERTIES_SURFACE_MESH_FEATURES_H #define CGAL_PROPERTIES_SURFACE_MESH_FEATURES_H +#include + + #ifndef DOXYGEN_RUNNING #include diff --git a/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_time_stamp.h b/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_time_stamp.h index d1df35ed90f..de779d13a28 100644 --- a/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_time_stamp.h +++ b/Surface_mesh/include/CGAL/boost/graph/properties_Surface_mesh_time_stamp.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri @@ -12,6 +12,9 @@ #ifndef CGAL_PROPERTIES_SURFACE_MESH_TIME_STAMP_H #define CGAL_PROPERTIES_SURFACE_MESH_TIME_STAMP_H +#include + + #ifndef DOXYGEN_RUNNING #include diff --git a/Surface_mesh_deformation/include/CGAL/Deformation_Eigen_closest_rotation_traits_3.h b/Surface_mesh_deformation/include/CGAL/Deformation_Eigen_closest_rotation_traits_3.h index 60c52e52e7f..b74261b1250 100644 --- a/Surface_mesh_deformation/include/CGAL/Deformation_Eigen_closest_rotation_traits_3.h +++ b/Surface_mesh_deformation/include/CGAL/Deformation_Eigen_closest_rotation_traits_3.h @@ -13,6 +13,8 @@ #ifndef CGAL_DEFORMATION_EIGEN_CLOSEST_ROTATION_TRAITS_3_H #define CGAL_DEFORMATION_EIGEN_CLOSEST_ROTATION_TRAITS_3_H +#include + #include #include diff --git a/Surface_mesh_deformation/include/CGAL/Deformation_Eigen_polar_closest_rotation_traits_3.h b/Surface_mesh_deformation/include/CGAL/Deformation_Eigen_polar_closest_rotation_traits_3.h index a73d8225bdb..9a94375100e 100644 --- a/Surface_mesh_deformation/include/CGAL/Deformation_Eigen_polar_closest_rotation_traits_3.h +++ b/Surface_mesh_deformation/include/CGAL/Deformation_Eigen_polar_closest_rotation_traits_3.h @@ -13,6 +13,8 @@ #ifndef CGAL_DEFORMATION_EIGEN_POLAR_CLOSEST_ROTATION_TRAITS_3_H #define CGAL_DEFORMATION_EIGEN_POLAR_CLOSEST_ROTATION_TRAITS_3_H +#include + #include #include #include diff --git a/Surface_mesh_parameterization/include/CGAL/surface_mesh_parameterization.h b/Surface_mesh_parameterization/include/CGAL/surface_mesh_parameterization.h index 09980d6e6dd..e5b31167532 100644 --- a/Surface_mesh_parameterization/include/CGAL/surface_mesh_parameterization.h +++ b/Surface_mesh_parameterization/include/CGAL/surface_mesh_parameterization.h @@ -10,6 +10,11 @@ // // Author(s) : Mael Rouxel-Labbé +#ifndef CGAL_SURFACE_MESH_PARAMETERIZATION_H +#define CGAL_SURFACE_MESH_PARAMETERIZATION_H + +#include + /** * \ingroup PkgSurfaceMeshParameterizationRef * \file CGAL/surface_mesh_parameterization.h @@ -17,7 +22,6 @@ * the free functions of this package. */ - #include #include #include @@ -34,3 +38,5 @@ #include #include #include + +#endif // CGAL_SURFACE_MESH_PARAMETERIZATION_H diff --git a/Surface_mesh_skeletonization/include/CGAL/Mean_curvature_flow_skeletonization.h b/Surface_mesh_skeletonization/include/CGAL/Mean_curvature_flow_skeletonization.h index 44b422ac0c9..39b928852ea 100644 --- a/Surface_mesh_skeletonization/include/CGAL/Mean_curvature_flow_skeletonization.h +++ b/Surface_mesh_skeletonization/include/CGAL/Mean_curvature_flow_skeletonization.h @@ -528,6 +528,7 @@ public: /// after a number of `contract_geometry()`, keeping the specified /// vertices fixed in place. /// \tparam InputIterator a model of `InputIterator` with `boost::graph_traits::%vertex_descriptor` as value type. + /// /// \cgalAdvancedEnd template void set_fixed_vertices(InputIterator begin, InputIterator end) diff --git a/Surface_mesher/include/CGAL/Surface_mesher/Profile_counter.h b/Surface_mesher/include/CGAL/Surface_mesher/Profile_counter.h index 81f88f84017..12a0c01cc94 100644 --- a/Surface_mesher/include/CGAL/Surface_mesher/Profile_counter.h +++ b/Surface_mesher/include/CGAL/Surface_mesher/Profile_counter.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Laurent Rineau @@ -16,6 +16,9 @@ #ifndef CGAL_SURFACE_MESHER_PROFILE_COUNTER_H #define CGAL_SURFACE_MESHER_PROFILE_COUNTER_H +#include + + #include #ifdef CGAL_SURFACE_MESHER_PROFILE diff --git a/Surface_mesher/include/CGAL/make_piecewise_smooth_surface_mesh.h b/Surface_mesher/include/CGAL/make_piecewise_smooth_surface_mesh.h index 33f4683b534..ee7f4c54f0b 100644 --- a/Surface_mesher/include/CGAL/make_piecewise_smooth_surface_mesh.h +++ b/Surface_mesher/include/CGAL/make_piecewise_smooth_surface_mesh.h @@ -9,4 +9,11 @@ // // Author(s) : Laurent Rineau +#ifndef CGAL_MAKE_PIECEWISE_SMOOTH_SURFACE_MESH_H +#define CGAL_MAKE_PIECEWISE_SMOOTH_SURFACE_MESH_H + +#include + #include + +#endif //CGAL_MAKE_PIECEWISE_SMOOTH_SURFACE_MESH_H diff --git a/Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt b/Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt index 977e7abec55..a6de52b8c0d 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/CMakeLists.txt @@ -49,7 +49,7 @@ endfunction() compile_and_run_sweep(test_sweep test_sweep.cpp ${NAIVE} ${CGAL_SEGMENT_TRAITS} "data/segments_tight") -compile_and_run_sweep(test_sweep_conic test_sweep_conic.cpp ${NAIVE} +compile_and_run_sweep(test_sweep_conic test_sweep.cpp ${NAIVE} ${CGAL_CONIC_TRAITS} "data/conics") compile_and_run_sweep(test_sweep_polyline test_sweep.cpp ${NAIVE} ${CGAL_POLYLINE_TRAITS} "data/polylines") diff --git a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con01.txt b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con01.txt index a3464614b95..1ff457efdb1 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con01.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con01.txt @@ -8,4 +8,3 @@ e 3 3 7 5 4 5 10 5 {1*x^2 + 1*y^2 + 0*xy + -14*x + -10*y + 65} : (4.66667,6.88562) --cw--> (10,5) 5 1 - diff --git a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con02.txt b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con02.txt index f3ca4fd2817..c404b51caa1 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con02.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con02.txt @@ -10,5 +10,3 @@ e 3 3 4 9 7 9 1 9 {1*x^2 + 1*y^2 + 0*xy + -8*x + -18*y + 88} : (7,9) --cw--> (5.45237,6.375) 6 2 - - diff --git a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con03.txt b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con03.txt index 6ed5fcbab23..599a66f9b14 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con03.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con03.txt @@ -12,8 +12,3 @@ f 3 3 4 9 {1*x^2 + 1*y^2 + 0*xy + -8*x + -18*y + 88} : (1,9) --cw--> (7,9) 6 2 - - - - - diff --git a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con04.txt b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con04.txt index d9a9875cdeb..eb6a5c18711 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con04.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con04.txt @@ -12,6 +12,4 @@ f 1 1 3 2 {1*x^2 + 1*y^2 + 0*xy + -6*x + -4*y + 12} : (4,2) --cw--> (2,2) {1*x^2 + 1*y^2 + 0*xy + -6*x + -4*y + 12} : (2,2) --cw--> (4,2) 6 -0 - - +1 diff --git a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con05.txt b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con05.txt index 224bbc2397a..e68e06cb488 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con05.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con05.txt @@ -12,7 +12,3 @@ f 3 3 4 9 {1*x^2 + 1*y^2 + 0*xy + -8*x + -18*y + 88} : (1,9) --cw--> (7,9) 6 2 - - - - diff --git a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con06.txt b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con06.txt index 59ac8c5f663..f82851db1c1 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con06.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con06.txt @@ -14,4 +14,3 @@ f 1 1 1 1 {1*x^2 + 1*y^2 + 0*xy + -4*x + 0*y + 3} : (2,1) --cw--> (3,0) 5 3 - diff --git a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con07.txt b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con07.txt index 2b2253b5594..e884bd40154 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con07.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con07.txt @@ -10,4 +10,3 @@ f 2 2 2 2 {1*x^2 + 1*y^2 + 0*xy + -4*x + -4*y + 4} : (0,2) --cw--> (4,2) 5 1 - diff --git a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con08.txt b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con08.txt index 54aae8118a0..63063346910 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con08.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con08.txt @@ -26,5 +26,3 @@ f 3 1 0 0 {4*x^2 + 25*y^2 + 0*xy + -16*x + 0*y + -84} : (2.75552,1.97704) --cw--> (7,0) 10 6 - - diff --git a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con09.txt b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con09.txt index 543d1cff813..6afc8ee809c 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con09.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con09.txt @@ -121,5 +121,4 @@ f 1 1 -4 0 {1*x^2 + 1*y^2 + 0*xy + -8*x + 0*y + 0} : (8,0) --cw--> (4.5,-3.96863) {1*x^2 + 1*y^2 + 0*xy + -8*x + 0*y + 0} : (4.5,3.96863) --cw--> (8,0) 59 -34 - +41 diff --git a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con10.txt b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con10.txt index 51c9e3ffb2a..d5f29cc3101 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/data/conics/con10.txt +++ b/Surface_sweep_2/test/Surface_sweep_2/data/conics/con10.txt @@ -18,5 +18,4 @@ s 7 -2 3 2 {1*x^2 + 1*y^2 + 0*xy + -14*x + 2*y + 49} : (8,-1) --cw--> (7,-2) {1*x^2 + 1*y^2 + 0*xy + -14*x + 2*y + 49} : (7,0) --cw--> (8,-1) 8 -7 - +5 diff --git a/Surface_sweep_2/test/Surface_sweep_2/test_sweep.cpp b/Surface_sweep_2/test/Surface_sweep_2/test_sweep.cpp index 326307f8461..1171fabe614 100644 --- a/Surface_sweep_2/test/Surface_sweep_2/test_sweep.cpp +++ b/Surface_sweep_2/test/Surface_sweep_2/test_sweep.cpp @@ -8,6 +8,8 @@ #include #include +#include +// #include #define CGAL_SEGMENT_TRAITS 1 #define CGAL_POLYLINE_TRAITS 11 @@ -101,8 +103,8 @@ typedef Rat_kernel::Segment_2 Rat_segment_2; typedef Rat_kernel::Circle_2 Rat_circle_2; typedef CGAL::Cartesian Alg_kernel; typedef CGAL::Arr_conic_traits_2 - Traits_2; -#elif CGAL_ARR_TEST_TRAITS == CGAL_POLYCURVE_TRAITS + Traits; +#elif CGAL_ARR_TEST_TRAITS == CGAL_POLYCONIC_TRAITS typedef CGAL::CORE_algebraic_number_traits Nt_traits; typedef Nt_traits::Rational Rational; typedef Nt_traits::Algebraic Algebraic; @@ -125,10 +127,6 @@ typedef std::list Points; typedef std::list Curves; typedef std::list X_monotone_curves; -bool read_curves(std::ifstream& inp, Curves& curves, const Traits& traits); -bool read_xcurves(std::ifstream& inp, X_monotone_curves& xcurves, - const Traits& traits); -bool read_points(std::ifstream& inp, Points& points, const Traits& traits); bool curves_identical(X_monotone_curves& list1, X_monotone_curves& list2); bool points_identical(Points& list1, Points& list2); @@ -148,109 +146,31 @@ std::istream& skip_comment(std::istream& in) { return in; } -int main(int argc, char* argv[]) { - if (argc != 2) { - std::cout << "Specify a file name " << std::endl; - return -1; +#if CGAL_ARR_TEST_TRAITS != CGAL_CONIC_TRAITS + +bool read_points(std::ifstream& inp, Points& points, const Traits&) { + int count; + inp >> skip_comment >> count; + + // std::cout << "read_points " << count << "\n"; + for (int i = 0; i < count; i++) { + NT x, y; + inp >> skip_comment >> x >> y; + Point_2 p(x, y); + // std::cout << p << "\n"; + points.push_back(p); } - - std::ifstream inp(argv[1]); - if (! inp.is_open()) { - std::cerr << "Error: Cannot open file " << argv[1] << "!" << std::endl; - return -1; - } - - Traits tr; - - Curves curves; - if (! read_curves(inp, curves, tr)) return -1; - - // Test subcurves w/o overlapping - X_monotone_curves curves_no_overlap_out; - CGAL::compute_subcurves(curves.begin(), curves.end(), - std::back_inserter(curves_no_overlap_out), - false, tr); - - - X_monotone_curves curves_no_overlap; - if (! read_xcurves(inp, curves_no_overlap, tr)) return -1; - - if (! compare_lists(curves_no_overlap_out, curves_no_overlap, tr)) { - std::cerr << "Curves w/o overlapping do not match!\n"; - for (const auto& xcv : curves_no_overlap_out) std::cerr << xcv << std::endl; - return -1; - } - - // Test intersection points (with endpoints) - Points points_with_ends_out; - CGAL::compute_intersection_points(curves.begin(), curves.end(), - std::back_inserter(points_with_ends_out), - true, tr); - - Points points_with_ends; - if (! read_points(inp, points_with_ends, tr)) return -1; - - if (! compare_lists(points_with_ends_out, points_with_ends, tr)) { - std::cerr << "Endpoints do not match!\n"; - for (const auto& p : points_with_ends_out) std::cerr << p << std::endl; - return -1; - } - - // Test intersection points w/o end points - Points points_without_ends_out; - CGAL::compute_intersection_points(curves.begin(), curves.end(), - std::back_inserter(points_without_ends_out), - false, tr); - - Points points_without_ends; - if (! read_points(inp, points_without_ends, tr)) return -1; - - if (! compare_lists(points_without_ends_out, points_without_ends, tr)) { - std::cerr << "Intersection points do not match!\n"; - for (const auto& p : points_without_ends_out) std::cerr << p << std::endl; - return -1; - } - - // Test subcurves w/ overlapping - X_monotone_curves curves_with_overlap_out; - CGAL::compute_subcurves(curves.begin(), curves.end(), - std::back_inserter(curves_with_overlap_out), - true, tr); - - X_monotone_curves curves_with_overlap; - if (! read_xcurves(inp, curves_with_overlap, tr)) return -1; - - if (! compare_lists(curves_with_overlap_out, curves_with_overlap, tr)) { - std::cerr << "Curves w/ overlapping do not match!\n"; - for (const auto& xcv : curves_with_overlap_out) - std::cerr << xcv << std::endl; - return -1; - } - - // Test the do_curves_intersecting method - bool do_intersect_out = - CGAL::do_curves_intersect(curves.begin(), curves.end()); - - bool do_intersect = false; - if ((points_without_ends.size() != 0) || - (curves_no_overlap_out.size() != curves_with_overlap_out.size())) - do_intersect = true; - - if (do_intersect_out != do_intersect) { - std::cerr << "Error: do_intersect()\n"; - return -1; - } - - std::cout << "Passed\n"; - return 0; + return true; } +#endif + #if CGAL_ARR_TEST_TRAITS == CGAL_SEGMENT_TRAITS bool read_curves(std::ifstream& inp, Curves& curves, const Traits&) { int count; inp >> skip_comment >> count; - std::cout << "read_curves " << count << "\n"; + // std::cout << "read_curves " << count << "\n"; for (int i = 0; i < count; ++i) { NT x0, y0, x1, y1; @@ -259,7 +179,7 @@ bool read_curves(std::ifstream& inp, Curves& curves, const Traits&) { Point_2 p2(x1, y1); Curve_2 curve(p1, p2); curves.push_back(curve); - std::cout << curve << "\n"; + // std::cout << curve << "\n"; } return true; } @@ -302,23 +222,320 @@ bool read_xcurves(std::ifstream& inp, X_monotone_curves& xcurves, return read_curves_(inp, xcurves, traits, ctr_xcv); } -#else -#error No traits defined for test -#endif +#elif CGAL_ARR_TEST_TRAITS == CGAL_CONIC_TRAITS -bool read_points(std::ifstream& inp, Points& points, const Traits&) { +void read_curve(std::ifstream& is, Curve_2& cv, const Traits& traits) { + // Read a line from the input file. + char one_line[128]; + auto ctr_curve_2 = traits.construct_curve_2_object(); + + is >> skip_comment; + is.getline(one_line, 128); + std::string stringvalues(one_line); + std::istringstream str_line(stringvalues, std::istringstream::in); + + // Get the arc type. + // Supported types are: 'f' - Full ellipse (or circle). + // 'e' - Elliptic arc (or circular arc). + // 's' - Line segment. + char type; + bool is_circle = false; // Is this a circle. + Rat_circle_2 circle; + Rational r, s, t, u, v, w; // The conic coefficients. + + str_line >> type; + + // An ellipse (full ellipse or a partial ellipse): + if (type == 'f' || type == 'F' || type == 'e' || type == 'E') { + // Read the ellipse (using the format "a b x0 y0"): + // + // x - x0 2 y - y0 2 + // ( -------- ) + ( -------- ) = 1 + // a b + // + int a, b, x0, y0; + + str_line >> a >> b >> x0 >> y0; + + Rational a_sq = Rational(a*a); + Rational b_sq = Rational(b*b); + + if (a == b) { + is_circle = true; + circle = + Rat_circle_2(Rat_point_2(Rational(x0), Rational(y0)), Rational(a*b)); + } + else { + r = b_sq; + s = a_sq; + t = 0; + u = Rational(-2*x0*b_sq); + v = Rational(-2*y0*a_sq); + w = Rational(x0*x0*b_sq + y0*y0*a_sq - a_sq*b_sq); + } + + if (type == 'f' || type == 'F') { + // Create a full ellipse (or circle). + if (is_circle) cv = ctr_curve_2(circle); + else cv = ctr_curve_2(r, s, t, u, v, w); + } + else { + // Read the endpointd of the arc. + int x1, y1, x2, y2; + + str_line >> x1 >> y1 >> x2 >> y2; + + Point_2 source = Point_2(Algebraic(x1), Algebraic(y1)); + Point_2 target = Point_2(Algebraic(x2), Algebraic(y2)); + + // Create the arc. Note that it is always clockwise oriented. + if (is_circle) cv = ctr_curve_2(circle, CGAL::CLOCKWISE, source, target); + else cv = ctr_curve_2(r, s, t, u, v, w, CGAL::CLOCKWISE, source, target); + } + } + else if (type == 's' || type == 'S') { + // Read a segment, given by its endpoints (x1,y1) and (x2,y2); + int x1, y1, x2, y2; + + str_line >> x1 >> y1 >> x2 >> y2; + + // Create the segment. + Rat_point_2 source = Rat_point_2 (Rational(x1), Rational(y1)); + Rat_point_2 target = Rat_point_2 (Rational(x2), Rational(y2)); + + cv = ctr_curve_2(Rat_segment_2 (source, target)); + } + + // std::cout << cv << std::endl; +} + +/*! Read curves. + */ +bool read_curves(std::ifstream& inp, Curves& curves, const Traits& traits) { + // auto ctr_cv = traits.construct_curve_2_object(); int count; inp >> skip_comment >> count; - - // std::cout << "read_points " << count << "\n"; - for (int i = 0; i < count; i++) { - NT x, y; - inp >> skip_comment >> x >> y; - Point_2 p(x, y); - // std::cout << p << "\n"; - points.push_back(p); + Curve_2 cv; + char dummy[256]; + inp.getline(dummy, sizeof(dummy)); + for (int i = 0; i < count; ++i) { + read_curve(inp, cv, traits); + curves.push_back(cv); } return true; } +#else +#error No traits defined for test +#endif + +#if CGAL_ARR_TEST_TRAITS != CGAL_CONIC_TRAITS + +// Test subcurves w/o overlapping +bool test_curves_no_overlap(std::ifstream& inp, Curves& /* curves */, + const X_monotone_curves& curves_no_overlap_out, + const Traits& tr) { + X_monotone_curves curves_no_overlap; + if (! read_xcurves(inp, curves_no_overlap, tr)) return false; + + if (! compare_lists(curves_no_overlap_out, curves_no_overlap, tr)) { + std::cerr << "Error: Curves w/o overlapping do not match!\n"; + for (const auto& xcv : curves_no_overlap_out) std::cerr << xcv << std::endl; + return false; + } + + return true; +} + +// Test subcurves w/ overlapping +bool test_curves_with_overlap(std::ifstream& inp, Curves& /* curves */, + const X_monotone_curves& curves_with_overlap_out, + const Traits& tr) { + X_monotone_curves curves_with_overlap; + if (! read_xcurves(inp, curves_with_overlap, tr)) return false; + + if (! compare_lists(curves_with_overlap_out, curves_with_overlap, tr)) { + std::cerr << "Error: Curves w/ overlapping do not match!\n"; + for (const auto& xcv : curves_with_overlap_out) + std::cerr << xcv << std::endl; + return false; + } + + return true; +} + +// Test intersection points (with endpoints) +bool test_points_with_ends(std::ifstream& inp, Curves& /* curves */, + const Points& points_with_ends_out, + const Traits& tr) { + Points points_with_ends; + if (! read_points(inp, points_with_ends, tr)) return false; + + if (! compare_lists(points_with_ends_out, points_with_ends, tr)) { + std::cerr << "Error: Endpoints do not match!\n"; + for (const auto& p : points_with_ends_out) std::cerr << p << std::endl; + return false; + } + + return true; +} + +// Test intersection points w/o end points +bool test_points_no_ends(std::ifstream& inp, Curves& /* curves */, + const Points& points_no_ends_out, + const Traits& tr) { + Points points_no_ends; + if (! read_points(inp, points_no_ends, tr)) return false; + + if (! compare_lists(points_no_ends_out, points_no_ends, tr)) { + std::cerr << "Error: Intersection points do not match!\n"; + for (const auto& p : points_no_ends_out) std::cerr << p << std::endl; + return false; + } + + return true; +} + +#else + +/*! Test the surface sweep with conic traits. + */ +bool test_conic(std::ifstream& inp, Curves& curves, + const X_monotone_curves& curves_no_overlap_out, + const Points& points_with_ends_out, + const Points& points_no_ends_out, + const Traits& traits) { + auto ctr_bbox_2 = traits.construct_bbox_2_object(); + CGAL::Bbox_2 bbox = ctr_bbox_2(curves.front()); + for (auto it = std::next(curves.begin()); it != curves.end(); ++it) + bbox = bbox + ctr_bbox_2(*it); + + // generate the string for the output + std::stringstream out1; + for (const auto& xcv : curves_no_overlap_out) out1 << xcv << "\n"; + + // read the output from the file + std::stringstream out2; + char buf[1024]; + int count = 0; + + inp >> count; + inp.getline(buf, 1024); // to get rid of the new line + for (int i = 0; i < count; ++i) { + inp.getline(buf, 1024); + out2 << buf << "\n"; + } + + // std::cout << "Result: \n" << curves_no_overlap_out.size() << "\n"; + // for (const auto& xcv : curves_no_overlap_out) + // std::cout << xcv << "\n"; + + std::string calculated = out1.str(); + std::string infile = out2.str(); + + if (infile != calculated) { + std::cerr << "Error\n"; + std::cerr << "\ncalculated:\n"; + std::cerr << calculated << std::endl; + std::cerr << "\nin file:\n"; + std::cerr << infile << std::endl; + std::cerr << "--" << std::endl; + return false; + } + + std::size_t points_with_ends_size, points_no_ends_size; + inp >> skip_comment >> points_with_ends_size >> points_no_ends_size; + + auto points_with_ends_out_size = points_with_ends_out.size(); + if (points_with_ends_size != points_with_ends_out_size ) { + std::cerr << "Error: Number of endpoints do not match (" + << points_with_ends_out_size << ", " + << points_with_ends_size << ")\n"; + return false; + } + + auto points_no_ends_out_size = points_no_ends_out.size(); + if (points_no_ends_size != points_no_ends_out_size) { + std::cerr << "Error: Number of intersection points do not match (" + << points_no_ends_out_size << ", " + << points_no_ends_size << ")\n"; + return false; + } + + return true; +} + +#endif + +int main(int argc, char* argv[]) { + if (argc != 2) { + std::cout << "Specify a file name " << std::endl; + return -1; + } + + std::ifstream inp(argv[1]); + if (! inp.is_open()) { + std::cerr << "Error: Cannot open file " << argv[1] << "!" << std::endl; + return -1; + } + + Traits tr; + + Curves curves; + if (! read_curves(inp, curves, tr)) return -1; + + // { + // using Arrangement = CGAL::Arrangement_2; + // Arrangement arr(&tr); + // CGAL::insert(arr, curves.begin(), curves.end()); + // CGAL::draw(arr, "conics", true); + // } + + X_monotone_curves curves_no_overlap_out; + CGAL::compute_subcurves(curves.begin(), curves.end(), + std::back_inserter(curves_no_overlap_out), + false, tr); + + X_monotone_curves curves_with_overlap_out; + CGAL::compute_subcurves(curves.begin(), curves.end(), + std::back_inserter(curves_with_overlap_out), + true, tr); + + Points points_with_ends_out; + CGAL::compute_intersection_points(curves.begin(), curves.end(), + std::back_inserter(points_with_ends_out), + true, tr); + + Points points_no_ends_out; + CGAL::compute_intersection_points(curves.begin(), curves.end(), + std::back_inserter(points_no_ends_out), + false, tr); + +#if CGAL_ARR_TEST_TRAITS == CGAL_CONIC_TRAITS + if (! test_conic(inp, curves, curves_no_overlap_out, + points_with_ends_out, points_no_ends_out, tr)) + return -1; +#else + if (! test_curves_no_overlap(inp, curves, curves_no_overlap_out, tr)) + return -1; + if (! test_points_with_ends(inp, curves, points_with_ends_out, tr)) return -1; + if (! test_points_no_ends(inp, curves, points_no_ends_out, tr)) return -1; + if (! test_curves_with_overlap(inp, curves, curves_with_overlap_out, tr)) + return -1; +#endif + + // Test the do_curves_intersecting method + bool do_intersect_out = + CGAL::do_curves_intersect(curves.begin(), curves.end()); + bool do_intersect = ! points_no_ends_out.empty() || + (curves_no_overlap_out.size() != curves_with_overlap_out.size()); + if (do_intersect_out != do_intersect) { + std::cerr << "Error: do_intersect()\n"; + return -1; + } + + std::cout << "Passed\n"; + return 0; +} + #endif diff --git a/Surface_sweep_2/test/Surface_sweep_2/test_sweep_conic.cpp b/Surface_sweep_2/test/Surface_sweep_2/test_sweep_conic.cpp deleted file mode 100644 index 90866e1a98d..00000000000 --- a/Surface_sweep_2/test/Surface_sweep_2/test_sweep_conic.cpp +++ /dev/null @@ -1,259 +0,0 @@ -#include - -#if !defined(CGAL_USE_CORE) -#include -int main() -{ - std::cout << "CORE is not installed. Test aborted!" << std::endl; - return 0; -} -#else - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -typedef CGAL::CORE_algebraic_number_traits Nt_traits; -typedef Nt_traits::Rational Rational; -typedef Nt_traits::Algebraic Algebraic; -typedef CGAL::Cartesian Rat_kernel; -typedef Rat_kernel::Point_2 Rat_point_2; -typedef Rat_kernel::Segment_2 Rat_segment_2; -typedef Rat_kernel::Circle_2 Rat_circle_2; -typedef CGAL::Cartesian Alg_kernel; -typedef CGAL::Arr_conic_traits_2 - Traits_2; - -typedef Traits_2::Curve_2 Curve_2; -typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2; -typedef Traits_2::Point_2 Point_2; -typedef std::list CurveList; - -typedef std::list PointList; -typedef PointList::iterator PointListIter; - -/*! Conic reader */ -template -class Conic_reader { -private: - Traits_2 m_traits; - -public: - int read_data(const char* filename, CurveList& curves, CGAL::Bbox_2& bbox, - const Traits& traits) { - Curve_2 cv; - char dummy[256]; - - std::ifstream inp(filename); - if (!inp.is_open()) { - std::cerr << "Cannot open file " << filename << "!" << std::endl; - return -1; - } - int count; - inp >> count; - inp.getline(dummy, sizeof(dummy)); - for (int i = 0; i < count; ++i) { - read_curve(inp, cv); - curves.push_back(cv); - CGAL::Bbox_2 curve_bbox = traits.construct_bbox_2_object()(cv); - if (i == 0) bbox = curve_bbox; - else bbox = bbox + curve_bbox; - } - inp.close(); - return 0; - } - - void read_curve(std::ifstream& is, Curve_2& cv) { - auto ctr_cv = m_traits.construct_curve_2_object(); - - // Read a line from the input file. - char one_line[128]; - - skip_comments(is, one_line); - std::string stringvalues(one_line); - std::istringstream str_line(stringvalues, std::istringstream::in); - - // Get the arc type. - // Supported types are: 'f' - Full ellipse (or circle). - // 'e' - Elliptic arc (or circular arc). - // 's' - Line segment. - bool is_circle(false); // Is this a circle. - Rat_circle_2 circle; - Rational r, s, t, u, v, w; // The conic coefficients. - - char type; - str_line >> type; - - // An ellipse (full ellipse or a partial ellipse): - if (type == 'f' || type == 'F' || type == 'e' || type == 'E') { - // Read the ellipse (using the format "a b x0 y0"): - // - // x - x0 2 y - y0 2 - // ( -------- ) + ( -------- ) = 1 - // a b - // - int a, b, x0, y0; - str_line >> a >> b >> x0 >> y0; - - Rational a_sq = Rational(a*a); - Rational b_sq = Rational(b*b); - - if (a == b) { - is_circle = true; - circle = - Rat_circle_2(Rat_point_2(Rational(x0), Rational(y0)), Rational(a*b)); - } - else { - r = b_sq; - s = a_sq; - t = 0; - u = Rational(-2*x0*b_sq); - v = Rational(-2*y0*a_sq); - w = Rational(x0*x0*b_sq + y0*y0*a_sq - a_sq*b_sq); - } - - if (type == 'f' || type == 'F') { - // Create a full ellipse (or circle). - cv = (is_circle) ? ctr_cv(circle) : ctr_cv(r, s, t, u, v, w); - return; - } - - // Read the endpointd of the arc. - int x1, y1, x2, y2; - str_line >> x1 >> y1 >> x2 >> y2; - - Point_2 source = Point_2 (Algebraic(x1), Algebraic(y1)); - Point_2 target = Point_2 (Algebraic(x2), Algebraic(y2)); - - // Create the arc. Note that it is always clockwise oriented. - cv = (is_circle) ? - ctr_cv(circle, CGAL::CLOCKWISE, source, target) : - ctr_cv(r, s, t, u, v, w, CGAL::CLOCKWISE, source, target); - return; - } - - if (type == 's' || type == 'S') { - // Read a segment, given by its endpoints (x1,y1) and (x2,y2); - int x1, y1, x2, y2; - str_line >> x1 >> y1 >> x2 >> y2; - - // Create the segment. - Rat_point_2 source = Rat_point_2(Rational(x1), Rational(y1)); - Rat_point_2 target = Rat_point_2(Rational(x2), Rational(y2)); - - cv = ctr_cv(Rat_segment_2(source, target)); - return; - } - - std::cerr << "Invalid type (" << type << ")" << std::endl; - } - - void skip_comments( std::ifstream& is, char* one_line) { - while( !is.eof() ){ - is.getline( one_line, 128 ); - if( one_line[0] != '#' ){ - break; - } - } - } -}; - -//--------------------------------------------------------------------------- -// The main: -// -int main(int argc, char* argv[]) { - bool verbose = false; - - // Define a test objects to read the conic arcs from it. - if (argc<2) { - std::cerr << "Usage: Conic_traits_test " << std::endl; - exit(1); - } - - Traits_2 traits; - CGAL::Bbox_2 bbox; - CurveList curves; - - Conic_reader reader; - reader.read_data(argv[1], curves, bbox, traits); - - // run the sweep - std::list mylist; - - CGAL::compute_subcurves(curves.begin(), curves.end(), - std::back_inserter(mylist), false); - - - PointList point_list_with_ends; - CGAL::compute_intersection_points(curves.begin(), curves.end(), - std::back_inserter(point_list_with_ends), - true); - std::size_t point_count_with_ends_calculated = point_list_with_ends.size(); - - // generate the string for the output - std::stringstream out1; - for (auto iter = mylist.begin(); iter != mylist.end(); ++iter) - out1 << *iter << "\n"; - - // read the output from the file - std::stringstream out2; - char buf[1024]; - int count = 0; - - std::ifstream in_file(argv[1]); - in_file >> count; - in_file.getline(buf, 1024); // to get rid of the new line - for (int i = 0 ; i < count ; ++i) in_file.getline(buf, 1024); - in_file >> count; - in_file.getline(buf, 1024); // to get rid of the new line - for (int i = 0; i < count; ++i) { - in_file.getline(buf, 1024); - out2 << buf << "\n"; - } - std::size_t point_count_with_ends_from_file = 0; - in_file >> point_count_with_ends_from_file; - in_file.close(); - - if (verbose) { - std::cout << "Result: \n" << mylist.size() << "\n"; - for (auto i = mylist.begin(); i != mylist.end() ; ++i) - std::cout << *i << "\n"; - } - - std::string calculated = out1.str(); - std::string infile = out2.str(); - - if (infile == calculated) { - if (point_count_with_ends_from_file != point_count_with_ends_calculated) { - std::cout << "number of intersection points (with ends):" - << point_count_with_ends_calculated << ". Should be " - << point_count_with_ends_from_file << "\n"; - std::cout << argv[1] << " Error\n"; - return -1; - } - else { - std::cout << argv[1] << " OK!\n"; - } - } - else { - std::cout << argv[1] << " Error\n"; - std::cout << "\ncalculated:\n"; - std::cout << calculated << std::endl; - std::cout << "\nin file:\n"; - std::cout << infile << std::endl; - std::cout << "--" << std::endl; - return -1; - } - - return 0; -} - -#endif diff --git a/TDS_2/include/CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h b/TDS_2/include/CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h index 738013e2489..55ff0388bcf 100644 --- a/TDS_2/include/CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/boost/graph/graph_traits_Triangulation_data_structure_2.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_GRAPH_TRAITS_TRIANGULATION_DATA_STRUCTURE_2_H #define CGAL_GRAPH_TRAITS_TRIANGULATION_DATA_STRUCTURE_2_H +#include + + // include this to avoid a VC15 warning #include #include diff --git a/TDS_2/include/CGAL/boost/graph/internal/graph_traits_2D_TDS_helper.h b/TDS_2/include/CGAL/boost/graph/internal/graph_traits_2D_TDS_helper.h index 9b5f303250d..1c0b1ae4b40 100644 --- a/TDS_2/include/CGAL/boost/graph/internal/graph_traits_2D_TDS_helper.h +++ b/TDS_2/include/CGAL/boost/graph/internal/graph_traits_2D_TDS_helper.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé @@ -19,8 +19,11 @@ #include #include -#ifndef CGAL_GRAPH_TRAITS_2D_TDS_HELPERS -#define CGAL_GRAPH_TRAITS_2D_TDS_HELPERS +#ifndef CGAL_GRAPH_TRAITS_2D_TDS_HELPERS_H +#define CGAL_GRAPH_TRAITS_2D_TDS_HELPERS_H + +#include + namespace CGAL { namespace internal { @@ -319,4 +322,4 @@ struct hash > } // namespace std -#endif // CGAL_GRAPH_TRAITS_2D_TDS_HELPERS +#endif // CGAL_GRAPH_TRAITS_2D_TDS_HELPERS_H diff --git a/TDS_2/include/CGAL/boost/graph/properties_Triangulation_data_structure_2.h b/TDS_2/include/CGAL/boost/graph/properties_Triangulation_data_structure_2.h index 0beda7ff5e2..91ba969bd6d 100644 --- a/TDS_2/include/CGAL/boost/graph/properties_Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/boost/graph/properties_Triangulation_data_structure_2.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé #ifndef CGAL_PROPERTIES_TRIANGULATION_DATA_STRUCTURE_2_H #define CGAL_PROPERTIES_TRIANGULATION_DATA_STRUCTURE_2_H +#include + + #include #include #include diff --git a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h index bdd21ca6d4b..03e4ad24928 100644 --- a/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h +++ b/TDS_3/doc/TDS_3/Concepts/TriangulationDataStructure_3.h @@ -130,6 +130,7 @@ data structure that only changes the vertex type. It has to define a type `Rebind_vertex::%Other` which is a rebound triangulation data structure, that is, the one whose `TriangulationDSVertexBase_3` will be `Vb2`. \note It can be implemented using a nested template class. + \cgalAdvancedEnd */ template @@ -143,6 +144,7 @@ data structure that only changes the cell type. It has to define a type `Rebind_cell::%Other` which is a rebound triangulation data structure, that is, the one whose `TriangulationDSCellBase_3` will be `Cb2`. \note It can be implemented using a nested template class. + \cgalAdvancedEnd */ template diff --git a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp index b5a10784e92..96abe70b90d 100644 --- a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp +++ b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_c3t3.cpp @@ -12,33 +12,35 @@ #include // Domain -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Mesh_polyhedron_3::type Polyhedron; -typedef CGAL::Polyhedral_mesh_domain_with_features_3 Mesh_domain; +using K = CGAL::Exact_predicates_inexact_constructions_kernel; +using Polyhedron = CGAL::Mesh_polyhedron_3::type; +using Mesh_domain = CGAL::Polyhedral_mesh_domain_with_features_3; #ifdef CGAL_CONCURRENT_MESH_3 -typedef CGAL::Parallel_tag Concurrency_tag; +using Concurrency_tag = CGAL::Parallel_tag; #else -typedef CGAL::Sequential_tag Concurrency_tag; +using Concurrency_tag = CGAL::Sequential_tag; #endif // Triangulation for Meshing -typedef CGAL::Mesh_triangulation_3::type Tr; -typedef CGAL::Mesh_complex_3_in_triangulation_3< - Tr, Mesh_domain::Corner_index, Mesh_domain::Curve_index> C3t3; +using Tr = CGAL::Mesh_triangulation_3::type; +using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3< + Tr, Mesh_domain::Corner_index, Mesh_domain::Curve_index>; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +using Mesh_criteria = CGAL::Mesh_criteria_3; // Triangulation for Remeshing -typedef CGAL::Triangulation_3 Triangulation_3; +using Triangulation_3 = CGAL::Triangulation_3; using Vertex_handle = Triangulation_3::Vertex_handle; using Vertex_pair = std::pair; using Constraints_set = std::unordered_set>; using Constraints_pmap = CGAL::Boolean_property_map; +using Corners_set = std::unordered_set>; +using Corners_pmap = CGAL::Boolean_property_map; // To avoid verbose function and named parameters call using namespace CGAL::parameters; @@ -68,13 +70,16 @@ int main(int argc, char* argv[]) // Mesh generation C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria); - CGAL::dump_c3t3(c3t3, "out"); - + // Property map of constraints Constraints_set constraints; Constraints_pmap constraints_pmap(constraints); + Corners_set corners; + Corners_pmap corners_pmap(corners); + Triangulation_3 tr = CGAL::convert_to_triangulation_3(std::move(c3t3), - CGAL::parameters::edge_is_constrained_map(constraints_pmap)); + CGAL::parameters::edge_is_constrained_map(constraints_pmap). + vertex_is_constrained_map(corners_pmap)); //note we use the move semantic, with std::move(c3t3), // to avoid a copy of the triangulation by the function diff --git a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_polyhedral_domain_with_features.cpp b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_polyhedral_domain_with_features.cpp index 5880052b43c..2014827dd51 100644 --- a/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_polyhedral_domain_with_features.cpp +++ b/Tetrahedral_remeshing/examples/Tetrahedral_remeshing/mesh_and_remesh_polyhedral_domain_with_features.cpp @@ -4,42 +4,52 @@ #include #include +#include #include -#include +#include #include + // Domain -typedef CGAL::Exact_predicates_inexact_constructions_kernel K; -typedef CGAL::Mesh_polyhedron_3::type Polyhedron; -typedef CGAL::Polyhedral_mesh_domain_with_features_3 Mesh_domain; +using K = CGAL::Exact_predicates_inexact_constructions_kernel; +using Polyhedron = CGAL::Surface_mesh; +using Mesh_domain = CGAL::Polyhedral_mesh_domain_with_features_3; #ifdef CGAL_CONCURRENT_MESH_3 -typedef CGAL::Parallel_tag Concurrency_tag; +using Concurrency_tag = CGAL::Parallel_tag; #else -typedef CGAL::Sequential_tag Concurrency_tag; +using Concurrency_tag = CGAL::Sequential_tag; #endif -// Triangulation for Meshing -typedef CGAL::Mesh_triangulation_3::type Tr; -typedef CGAL::Mesh_complex_3_in_triangulation_3< - Tr, Mesh_domain::Corner_index, Mesh_domain::Curve_index> C3t3; +// Triangulation +using Tr = CGAL::Mesh_triangulation_3::type; +using C3t3 = CGAL::Mesh_complex_3_in_triangulation_3< + Tr, Mesh_domain::Corner_index, Mesh_domain::Curve_index>; // Criteria -typedef CGAL::Mesh_criteria_3 Mesh_criteria; +using Mesh_criteria = CGAL::Mesh_criteria_3; // Triangulation for Remeshing -typedef CGAL::Triangulation_3 Triangulation_3; +using Triangulation_3 = CGAL::Triangulation_3; +using Vertex_handle = Triangulation_3::Vertex_handle; +using Vertex_pair = std::pair; +using Constraints_set = std::unordered_set>; +using Constraints_pmap = CGAL::Boolean_property_map; // To avoid verbose function and named parameters call using namespace CGAL::parameters; int main(int argc, char* argv[]) { - const std::string fname = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/fandisk.off"); + const std::string fname = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/anchor.off"); + const int nb_iter = (argc > 2) ? atoi(argv[2]) : 5; + std::ifstream input(fname); Polyhedron polyhedron; + + std::string filename(fname); input >> polyhedron; if (input.fail()) { std::cerr << "Error: Cannot read file " << fname << std::endl; @@ -58,24 +68,29 @@ int main(int argc, char* argv[]) 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); + const double size = 0.072; + Mesh_criteria criteria(edge_size = size, + facet_angle = 25, + facet_size = size, + cell_radius_edge_ratio = 2, + cell_size = size); // Mesh generation - C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria); + C3t3 c3t3 = CGAL::make_mesh_3(domain, criteria, no_perturb(), no_exude()); - Triangulation_3 tr = CGAL::convert_to_triangulation_3(std::move(c3t3)); - //note we use the move semantic, with std::move(c3t3), - // to avoid a copy of the triangulation by the function - // `CGAL::convert_to_triangulation_3()` - // After the call to this function, c3t3 is an empty and valid C3t3. - //It is possible to use : CGAL::convert_to_triangulation_3(c3t3), - // Then the triangulation is copied and duplicated, and c3t3 remains as is. + Constraints_set constraints; + Constraints_pmap constraints_pmap(constraints); - const double target_edge_length = 0.1;//coarsen the mesh - CGAL::tetrahedral_isotropic_remeshing(tr, target_edge_length, - CGAL::parameters::number_of_iterations(3)); + Triangulation_3 tr = CGAL::convert_to_triangulation_3(std::move(c3t3), + CGAL::parameters::edge_is_constrained_map(constraints_pmap)); + + // Remeshing + CGAL::tetrahedral_isotropic_remeshing(tr, size, + CGAL::parameters::number_of_iterations(nb_iter)); + + std::ofstream out("out_remeshed.mesh"); + CGAL::IO::write_MEDIT(out, tr); + out.close(); return EXIT_SUCCESS; } diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h index d2ababd2779..c36603287bc 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/collapse_short_edges.h @@ -44,6 +44,7 @@ enum Edge_type { FEATURE, BOUNDARY, INSIDE, MIXTE, enum Collapse_type { TO_MIDPOINT, TO_V0, TO_V1, IMPOSSIBLE }; enum Result_type { VALID, V_PROBLEM, C_PROBLEM, E_PROBLEM, + ANGLE_PROBLEM, TOPOLOGICAL_PROBLEM, ORIENTATION_PROBLEM, SHARED_NEIGHBOR_PROBLEM }; template @@ -214,6 +215,15 @@ public: } while (++circ != done); +#ifdef PROTECT_ANGLES_FROM_COLLAPSE + Dihedral_angle_cosine curr_max_cos + = max_cos_dihedral_angle(triangulation, cells_to_remove[0]); + for (std::size_t i = 1; i < cells_to_remove.size(); ++i) + { + curr_max_cos = (std::max)(curr_max_cos, + max_cos_dihedral_angle(triangulation, cells_to_remove[i])); + } +#endif vh0->set_point(Point_3(v0_new_pos.x(), v0_new_pos.y(), v0_new_pos.z())); vh1->set_point(Point_3(v0_new_pos.x(), v0_new_pos.y(), v0_new_pos.z())); @@ -269,6 +279,10 @@ public: return ORIENTATION_PROBLEM; if (!triangulation.tds().is_valid(cit, true)) return C_PROBLEM; +#ifdef PROTECT_ANGLES_FROM_COLLAPSE + if (curr_max_cos < max_cos_dihedral_angle(triangulation, cit)) + return ANGLE_PROBLEM; +#endif } for (Vertex_handle vit : triangulation.finite_vertex_handles()) @@ -791,6 +805,9 @@ collapse(const typename C3t3::Cell_handle ch, } while (++circ != done); + if(c3t3.is_in_complex(ch->vertex(from), ch->vertex(to))) + c3t3.remove_from_complex(ch->vertex(from), ch->vertex(to)); + bool valid = true; std::vector cells_to_remove; std::unordered_set invalid_cells; @@ -1109,11 +1126,9 @@ typename C3t3::Vertex_handle collapse_edge(typename C3t3::Edge& edge, if (are_edge_lengths_valid(edge, c3t3, new_pos, sqhigh, cell_selector/*, adaptive = false*/) && collapse_preserves_surface_star(edge, c3t3, new_pos, cell_selector)) { - CGAL_assertion_code(typename Tr::Cell_handle dc); - CGAL_assertion_code(int di); - CGAL_assertion_code(int dj); - CGAL_assertion(c3t3.triangulation().is_edge(edge.first->vertex(edge.second), - edge.first->vertex(edge.third), dc, di, dj)); + CGAL_assertion(c3t3.triangulation().tds().is_edge( + edge.first->vertex(edge.second), + edge.first->vertex(edge.third))); Vertex_handle v0_init = edge.first->vertex(edge.second); Vertex_handle v1_init = edge.first->vertex(edge.third); @@ -1223,7 +1238,7 @@ void collapse_short_edges(C3T3& c3t3, FT sqlen = sql(tr.segment(e)); if (sqlen < sq_low) - short_edges.insert(short_edge(make_vertex_pair(e), sqlen)); + short_edges.insert(short_edge(make_vertex_pair(e), sqlen)); } #ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG @@ -1285,7 +1300,7 @@ void collapse_short_edges(C3T3& c3t3, const FT sqlen = sql(tr.segment(eshort)); if (sqlen < sq_low) - short_edges.insert(short_edge(make_vertex_pair(eshort), sqlen)); + short_edges.insert(short_edge(make_vertex_pair(eshort), sqlen)); } //debug::dump_c3t3(c3t3, "dump_after_collapse"); diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h index 798284fa04e..a80a883fa17 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/flip_edges.h @@ -21,7 +21,6 @@ #include #include -#include #include #include @@ -38,12 +37,6 @@ namespace internal enum Flip_Criterion{ MIN_ANGLE_BASED, AVERAGE_ANGLE_BASED, VALENCE_BASED, VALENCE_MIN_DH_BASED }; -//template -//void flip_inside_edges(std::vector&) -//{ -// //TODO -//} - //outer_mirror_facets contains the set of facets of the outer hull //of the set of cells modified by the flip operation, //"seen from" outside @@ -88,13 +81,13 @@ void update_c3t3_facets(C3t3& c3t3, } } -template +template Sliver_removal_result flip_3_to_2(typename C3t3::Edge& edge, C3t3& c3t3, const std::vector& vertices_around_edge, const Flip_Criterion& criterion, IncCellsVectorMap& inc_cells, - Cell_selector& cell_selector) + CellSelector& cell_selector) { typedef typename C3t3::Triangulation Tr; typedef typename C3t3::Facet Facet; @@ -317,7 +310,7 @@ Sliver_removal_result flip_3_to_2(typename C3t3::Edge& edge, } ch->vertex(v)->set_cell(ch); - inc_cells[ch->vertex(v)] = std::nullopt; + inc_cells[ch->vertex(v)].clear(); ch->reset_cache_validity(); } } @@ -385,7 +378,6 @@ void find_best_flip_to_improve_dh(C3t3& c3t3, { typedef typename C3t3::Triangulation Tr; typedef typename C3t3::Vertex_handle Vertex_handle; - typedef typename C3t3::Cell_handle Cell_handle; typedef typename C3t3::Facet Facet; typedef typename Tr::Facet_circulator Facet_circulator; typedef typename Tr::Cell_circulator Cell_circulator; @@ -431,9 +423,7 @@ void find_best_flip_to_improve_dh(C3t3& c3t3, indices(facet_circulator->second, j)); if (curr != vh0 && curr != vh1) { - Cell_handle ch; - int i0, i1; - if (tr.is_edge(curr, vh, ch, i0, i1)) + if (tr.tds().is_edge(curr, vh)) is_edge = true; } } @@ -456,12 +446,12 @@ void find_best_flip_to_improve_dh(C3t3& c3t3, Cell_circulator cell_circulator = tr.incident_cells(edge); Cell_circulator done = cell_circulator; - boost::container::small_vector facets; for (std::size_t i = 0; i < opposite_vertices.size(); ++i) { Vertex_handle vh = opposite_vertices[i]; bool keep = true; + boost::container::small_vector facets; do { //Store it if it do not have vh @@ -482,7 +472,7 @@ void find_best_flip_to_improve_dh(C3t3& c3t3, Dihedral_angle_cosine max_flip_cos_dh(CGAL::NEGATIVE, 1., 1.); for (const Facet& fi : facets) { - if (!tr.is_infinite(fi.first)) + if (!tr.is_infinite(fi.first) && c3t3.is_in_complex(fi.first)) { if (is_well_oriented(tr, vh, fi.first->vertex(indices(fi.second, 0)), fi.first->vertex(indices(fi.second, 1)), @@ -596,13 +586,9 @@ void find_best_flip_to_improve_dh(C3t3& c3t3, if(tr.is_infinite(vh)) continue; - std::optional>& o_inc_vh = inc_cells[vh]; - if (o_inc_vh == std::nullopt) - { - boost::container::small_vector inc_vec; - tr.incident_cells(vh, std::back_inserter(inc_vec)); - o_inc_vh = inc_vec; - } + boost::container::small_vector& o_inc_vh = inc_cells[vh]; + if (o_inc_vh.empty()) + tr.incident_cells(vh, std::back_inserter(o_inc_vh)); Facet_circulator facet_circulator = curr_fcirc; Facet_circulator facet_done = curr_fcirc; @@ -620,7 +606,7 @@ void find_best_flip_to_improve_dh(C3t3& c3t3, indices(facet_circulator->second, i)); if (curr_vertex != vh0 && curr_vertex != vh1) { - if (is_edge_uv(vh, curr_vertex, o_inc_vh.value())) + if (is_edge_uv(vh, curr_vertex, o_inc_vh)) { is_edge = true; break; @@ -707,13 +693,13 @@ void find_best_flip_to_improve_dh(C3t3& c3t3, template Sliver_removal_result flip_n_to_m(C3t3& c3t3, typename C3t3::Edge& edge, typename C3t3::Vertex_handle vh, IncCellsVectorMap& inc_cells, - Cell_selector& cell_selector, + CellSelector& cell_selector, Visitor& visitor, bool check_validity = false) { @@ -728,19 +714,26 @@ Sliver_removal_result flip_n_to_m(C3t3& c3t3, Tr& tr = c3t3.triangulation(); - Vertex_handle vh0 = edge.first->vertex(edge.second); - Vertex_handle vh1 = edge.first->vertex(edge.third); + const Vertex_handle vh0 = edge.first->vertex(edge.second); + const Vertex_handle vh1 = edge.first->vertex(edge.third); //This vertex will have its valence augmenting a lot, //TODO take the best one //TODO!!!! Check that the created edges do not exist!!! + boost::container::small_vector facets_in_complex; + Facet_circulator facet_circulator = tr.incident_facets(edge); Facet_circulator done_facet_circulator = facet_circulator; bool look_for_vh_iterator = true; do { + if (c3t3.is_in_complex(*facet_circulator)) + { + facets_in_complex.push_back(*facet_circulator); + } + facet_circulator++; //Get the ids of the opposite vertices @@ -749,6 +742,7 @@ Sliver_removal_result flip_n_to_m(C3t3& c3t3, if (facet_circulator->first->vertex(indices(facet_circulator->second, i)) == vh) look_for_vh_iterator = false; } + } while (facet_circulator != done_facet_circulator && look_for_vh_iterator); if (look_for_vh_iterator) { @@ -761,13 +755,9 @@ Sliver_removal_result flip_n_to_m(C3t3& c3t3, facet_circulator++; facet_circulator++; - std::optional>& o_inc_vh = inc_cells[vh]; - if (o_inc_vh == std::nullopt) - { - boost::container::small_vector inc_vec; - tr.incident_cells(vh, std::back_inserter(inc_vec)); - o_inc_vh = inc_vec; - } + boost::container::small_vector& o_inc_vh = inc_cells[vh]; + if (o_inc_vh.empty()) + tr.incident_cells(vh, std::back_inserter(o_inc_vh)); do { @@ -778,7 +768,7 @@ Sliver_removal_result flip_n_to_m(C3t3& c3t3, indices(facet_circulator->second, i)); if (curr_vertex != vh0 && curr_vertex != vh1) { - if (is_edge_uv(vh, curr_vertex, o_inc_vh.value())) + if (is_edge_uv(vh, curr_vertex, o_inc_vh)) return NOT_FLIPPABLE; } } @@ -866,16 +856,16 @@ Sliver_removal_result flip_n_to_m(C3t3& c3t3, //} ///*************************************************************/ - //Subdomain index? - typename C3t3::Subdomain_index subdomain = to_remove[0]->subdomain_index(); + //Surface + for (const Facet& f : facets_in_complex) + c3t3.remove_from_complex(f); + + //Subdomain index + typedef typename C3t3::Subdomain_index Subdomain_index; + const Subdomain_index subdomain = to_remove[0]->subdomain_index(); bool selected = get(cell_selector, to_remove[0]); visitor.before_flip(to_remove[0]); -#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG - for (std::size_t i = 1; i < to_remove.size(); ++i) - CGAL_assertion(subdomain == to_remove[i]->subdomain_index()); -#endif - std::vector cells_to_update; //Create new cells @@ -948,9 +938,9 @@ Sliver_removal_result flip_n_to_m(C3t3& c3t3, } ch->vertex(v)->set_cell(ch); - inc_cells[ch->vertex(v)] = std::nullopt; - ch->reset_cache_validity(); + inc_cells[ch->vertex(v)].clear(); } + ch->reset_cache_validity(); } // Update c3t3 @@ -960,6 +950,7 @@ Sliver_removal_result flip_n_to_m(C3t3& c3t3, for (Cell_handle ch : to_remove) { treat_before_delete(ch, cell_selector, c3t3); + ch->reset_cache_validity(); tr.tds().delete_cell(ch); } @@ -1045,16 +1036,16 @@ Sliver_removal_result flip_n_to_m(typename C3t3::Edge& edge, Cell_circulator done = circ; Dihedral_angle_cosine curr_max_cosdh = max_cos_dihedral_angle(tr, circ++); - while (circ != done) + do { - curr_max_cosdh = (std::max)(curr_max_cosdh, max_cos_dihedral_angle(tr, circ++)); - } + curr_max_cosdh = (std::max)(curr_max_cosdh, max_cos_dihedral_angle(tr, circ)); + } while (++circ != done); + if (boundary_vertices.size() == 2) find_best_flip_to_improve_dh(c3t3, edge, boundary_vertices[0], boundary_vertices[1], candidates, curr_max_cosdh); else - find_best_flip_to_improve_dh(c3t3, edge, candidates, curr_max_cosdh, - inc_cells); + find_best_flip_to_improve_dh(c3t3, edge, candidates, curr_max_cosdh, inc_cells); bool flip_performed = false; while (!candidates.empty() && !flip_performed) @@ -1062,10 +1053,10 @@ Sliver_removal_result flip_n_to_m(typename C3t3::Edge& edge, CosAngle_and_vertex curr_cost_vpair = candidates.top(); candidates.pop(); -// std::cout << "\tcurrent cos = " << curr_max_cosdh -// << "\t angle = " << std::acos(curr_max_cosdh) * 180./CGAL_PI << std::endl; -// std::cout << "\tcandidate cos = " << curr_cost_vpair.first -// << "\t angle = " << std::acos(curr_cost_vpair.first) * 180./CGAL_PI << std::endl; +// std::cout << "\tcurrent cos = " << curr_max_cosdh.value() +// << "\t angle = " << std::acos(curr_max_cosdh.value()) * 180./CGAL_PI << std::endl; +// std::cout << "\tcandidate cos = " << curr_cost_vpair.first.value() +// << "\t angle = " << std::acos(curr_cost_vpair.first.value()) * 180./CGAL_PI << std::endl; // std::cout << std::endl; if (curr_max_cosdh <= curr_cost_vpair.first) @@ -1082,12 +1073,12 @@ Sliver_removal_result flip_n_to_m(typename C3t3::Edge& edge, return result; } -template +template Sliver_removal_result find_best_flip(typename C3t3::Edge& edge, C3t3& c3t3, const Flip_Criterion& criterion, IncCellsVectorMap& inc_cells, - Cell_selector& cell_selector, + CellSelector& cell_selector, Visitor& visitor) { typedef typename C3t3::Triangulation Tr; @@ -1171,38 +1162,31 @@ Sliver_removal_result find_best_flip(typename C3t3::Edge& edge, } -template +template std::size_t flip_all_edges(const std::vector& edges, C3t3& c3t3, + IncidentCellsVectorMap& inc_cells, const Flip_Criterion& criterion, - Cell_selector& cell_selector, + CellSelector& cell_selector, Visitor& visitor) { typedef typename C3t3::Triangulation Tr; typedef typename Tr::Cell_handle Cell_handle; - typedef typename Tr::Vertex_handle Vertex_handle; typedef typename Tr::Edge Edge; Tr& tr = c3t3.triangulation(); - std::unordered_map > > inc_cells; - std::size_t count = 0; for (const VertexPair& vp : edges) { - std::optional>& - o_inc_vh = inc_cells[vp.first]; - if (o_inc_vh == std::nullopt) - { - boost::container::small_vector inc_vec; - tr.incident_cells(vp.first, std::back_inserter(inc_vec)); - o_inc_vh = inc_vec; - } + boost::container::small_vector& o_inc_vh = inc_cells[vp.first]; + if (o_inc_vh.empty()) + tr.incident_cells(vp.first, std::back_inserter(o_inc_vh)); Cell_handle ch; int i0, i1; - if (is_edge_uv(vp.first, vp.second, o_inc_vh.value(), ch, i0, i1)) + if (is_edge_uv(vp.first, vp.second, o_inc_vh, ch, i0, i1)) { Edge edge(ch, i0, i1); @@ -1225,10 +1209,684 @@ std::size_t flip_all_edges(const std::vector& edges, } } - for(Cell_handle c : c3t3.triangulation().finite_cell_handles()) + return count; +} + +template +void collect_subdomains_on_boundary(const C3t3& c3t3, + boost::unordered_map >& vertices_subdomain_indices) +{ + for (auto c : c3t3.triangulation().all_cell_handles()) + { + for (auto v : c3t3.triangulation().vertices(c)) + { + const int dim = v->in_dimension(); + if(dim >= 0 && dim < 3) + vertices_subdomain_indices[v].insert(c->subdomain_index()); + } + } +} + +template +void collectBoundaryEdgesAndComputeVerticesValences( + const C3T3& c3t3, + const CellSelector& cell_selector, + std::vector& boundary_edges, + boost::unordered_map >& + boundary_vertices_valences, + boost::unordered_map >& + vertices_subdomain_indices) +{ + typedef typename C3T3::Surface_patch_index Surface_patch_index; + typedef typename C3T3::Vertex_handle Vertex_handle; + typedef typename C3T3::Edge Edge; + typedef typename C3T3::Triangulation::Facet_circulator Facet_circulator; + + const typename C3T3::Triangulation& tr = c3t3.triangulation(); + + boundary_edges.clear(); + boundary_vertices_valences.clear(); + + for (const Edge& e : tr.finite_edges()) + { + if (is_boundary(c3t3, e, cell_selector)) + boundary_edges.push_back(e); + } + +#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG + CGAL::Tetrahedral_remeshing::debug::dump_edges(boundary_edges, + "boundary_edges.polylines.txt"); +#endif + + // collect incident subdomain indices at vertices + collect_subdomains_on_boundary(c3t3, vertices_subdomain_indices); + + for (const Edge& e : boundary_edges) + { + const Vertex_handle v0 = e.first->vertex(e.second); + const Vertex_handle v1 = e.first->vertex(e.third); + + //In case of feature edge + if (vertices_subdomain_indices[v0].size() > 2 + && vertices_subdomain_indices[v1].size() > 2) + { + Facet_circulator facet_circulator = tr.incident_facets(e); + Facet_circulator done(facet_circulator); + do + { + if (c3t3.is_in_complex(*facet_circulator)) + { + Surface_patch_index surfi = c3t3.surface_patch_index(*facet_circulator); + boundary_vertices_valences[v0][surfi]++; + boundary_vertices_valences[v1][surfi]++; + } + } while (++facet_circulator != done); + } + else if (vertices_subdomain_indices[v0].size() == 2 + || vertices_subdomain_indices[v1].size() == 2) + { + Facet_circulator facet_circulator = tr.incident_facets(e); + Facet_circulator done(facet_circulator); + Surface_patch_index first_patch = Surface_patch_index(); + do + { + if (c3t3.is_in_complex(*facet_circulator)) + { + Surface_patch_index surfi = c3t3.surface_patch_index(*facet_circulator); + if (first_patch == Surface_patch_index()) + first_patch = surfi; + else if (first_patch == surfi) + continue; + + boundary_vertices_valences[v0][surfi]++; + boundary_vertices_valences[v1][surfi]++; + } + } while (++facet_circulator != done); + } + } +} + +template +Sliver_removal_result flip_n_to_m_on_surface(typename C3T3::Edge& edge, + C3T3& c3t3, + typename C3T3::Vertex_handle v0i,//v0 of new edge that will replace edge + typename C3T3::Vertex_handle v1i,//v1 of new edge that will replace edge + const IncCellsVector& cells_around_edge, + Flip_Criterion /*flip_criterion*/, + Visitor& /*visitor*/) +{ + typedef typename C3T3::Vertex_handle Vertex_handle; + typedef typename C3T3::Cell_handle Cell_handle; + + typename C3T3::Triangulation& tr = c3t3.triangulation(); + + const Vertex_handle u = edge.first->vertex(edge.second); + const Vertex_handle v = edge.first->vertex(edge.third); + + typedef std::pair IndInCell; + std::map indices; + for (Cell_handle c : cells_around_edge) + { + indices[c] = std::make_pair(c->index(u), c->index(v)); + } + + for (Cell_handle c : cells_around_edge) + { + int i = indices[c].first; + int j = indices[c].second; + c->set_vertex(i, v0i); + c->set_vertex(j, v1i); + + if (!is_well_oriented(tr, c)) + { + c->set_vertex(j, v0i); + c->set_vertex(i, v1i); + if (!is_well_oriented(tr, c)) + { + //rollback all changes + for (Cell_handle cc : cells_around_edge) + { + const int ii = indices[cc].first; + if (cc->vertex(ii) != u) + { + cc->set_vertex(ii, u); + cc->set_vertex(indices[cc].second, v); + } + } + return NOT_FLIPPABLE; + } + } + } + + for (Cell_handle c : cells_around_edge) c->reset_cache_validity(); - return count; + return VALID_FLIP; +} + +//v0i and v1i are the vertices opposite to `edge` +//on facets of the surface +template +Sliver_removal_result flip_on_surface(C3T3& c3t3, + typename C3T3::Edge& edge, + typename C3T3::Vertex_handle v0i,//v0 of new edge that will replace edge + typename C3T3::Vertex_handle v1i,//v1 of new edge that will replace edge + IncCellsVectorMap& inc_cells, + Flip_Criterion flip_criterion, + Visitor& visitor) +{ + typedef typename C3T3::Triangulation Tr; + typedef typename Tr::Cell_handle Cell_handle; + typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename Tr::Cell_circulator Cell_circulator; + + Tr& tr = c3t3.triangulation(); + Cell_circulator circ = tr.incident_cells(edge); + Cell_circulator done(circ); + + std::vector cells_around_edge; + do + { + cells_around_edge.push_back(circ); + } while (++circ != done); + + if (cells_around_edge.size() != 4) + { + if (cells_around_edge.size() > 4){ +////// if (flip_criterion == VALENCE_BASED){ +////// return find_best_n_m_flip(edge, vh0_index, vh1_index); +////// } +////// else { +// std::vector boundary_vertices; +// boundary_vertices.push_back(v0i); +// boundary_vertices.push_back(v1i); +#ifdef CGAL_FLIP_ON_SURFACE_DISABLE_NM_FLIP + return NOT_FLIPPABLE; +#else + return flip_n_to_m_on_surface(edge, c3t3, v0i, v1i, + cells_around_edge, flip_criterion, + visitor); +#endif +////// } + } + else + return NOT_FLIPPABLE; + } + +#ifdef CGAL_FLIP_ON_SURFACE_DISABLE_44_FLIP + return NOT_FLIPPABLE; +#endif + + inc_cells[edge.first->vertex(edge.second)].clear(); + inc_cells[edge.first->vertex(edge.third)].clear(); + + Cell_handle ch0, ch1, ch2, ch3; + ch0 = cells_around_edge[0]; + ch1 = cells_around_edge[1]; + ch2 = cells_around_edge[2]; + ch3 = cells_around_edge[3]; + + Dihedral_angle_cosine curr_max_cosdh = max_cos_dihedral_angle(tr, ch0); + for (int i = 1; i < 4; ++i) + curr_max_cosdh = (std::max)(curr_max_cosdh, + max_cos_dihedral_angle(tr, cells_around_edge[i])); + + Vertex_handle vh0, vh1, vh2, vh3, vh4, vh5; + + int ivh4_in_ch0 = ch0->index(ch1); + vh4 = ch0->vertex(ivh4_in_ch0); + + int ivh2_in_ch0 = ch0->index(ch3); + vh2 = ch0->vertex(ivh2_in_ch0); + + vh5 = ch1->vertex(ch1->index(ch0)); + vh0 = ch2->vertex(ch2->index(ch1)); + + for (int j = 0; j < 3; j++){ + if (indices(ivh4_in_ch0, j) == ivh2_in_ch0){ + int j1 = (j + 1) % 3; + int j2 = (j + 2) % 3; + vh1 = ch0->vertex(indices(ivh4_in_ch0, j1)); + vh3 = ch0->vertex(indices(ivh4_in_ch0, j2)); + break; + } + } + + bool planar_flip; + if ((vh0 == v0i && vh2 == v1i) || (vh2 == v0i && vh0 == v1i)) + planar_flip = true; + else if ((vh4 == v0i && vh5 == v1i) || (vh5 == v0i && vh4 == v1i)) + planar_flip = false; + else + return NOT_FLIPPABLE; + + typedef typename C3T3::Facet Facet; + typedef typename C3T3::Surface_patch_index Surface_patch_index; + + if (planar_flip) + { +#ifdef CGAL_FLIP_ON_SURFACE_DISABLE_PLANAR_44_FLIP + return NOT_FLIPPABLE; +#endif + Surface_patch_index patch = c3t3.surface_patch_index(ch0, ch0->index(vh4)); + CGAL_assertion(patch != Surface_patch_index()); + CGAL_assertion(c3t3.is_in_complex(ch0, ch0->index(vh4))); + c3t3.remove_from_complex(ch0, ch0->index(vh4)); + CGAL_assertion(c3t3.is_in_complex(ch3, ch3->index(vh4))); + c3t3.remove_from_complex(ch3, ch3->index(vh4)); + + boost::unordered_map opposite_facet_in_complex; + for (Cell_handle chi : cells_around_edge) + { + Facet f1(chi, chi->index(vh1)); + Facet f2(chi, chi->index(vh3)); + + if (c3t3.is_in_complex(f1)) + { + Surface_patch_index spi = c3t3.surface_patch_index(f1); + opposite_facet_in_complex[c3t3.triangulation().mirror_facet(f1)] = spi; + c3t3.remove_from_complex(f1); + } + if (c3t3.is_in_complex(f2)) + { + Surface_patch_index spi = c3t3.surface_patch_index(f2); + opposite_facet_in_complex[c3t3.triangulation().mirror_facet(f2)] = spi; + c3t3.remove_from_complex(f2); + } + } + + Cell_handle n_ch3_vh1 = ch3->neighbor(ch3->index(vh1)); + Cell_handle n_ch0_vh3 = ch0->neighbor(ch0->index(vh3)); + + Cell_handle n_ch2_vh1 = ch2->neighbor(ch2->index(vh1)); + Cell_handle n_ch1_vh3 = ch1->neighbor(ch1->index(vh3)); + + ch3->set_vertex(ch3->index(vh3), vh2); + ch0->set_vertex(ch0->index(vh1), vh0); + ch2->set_vertex(ch2->index(vh3), vh2); + ch1->set_vertex(ch1->index(vh1), vh0); + + Sliver_removal_result db = VALID_FLIP; + if (!is_well_oriented(tr, ch0) + || !is_well_oriented(tr, ch1) + || !is_well_oriented(tr, ch2) + || !is_well_oriented(tr, ch3)) + db = NOT_FLIPPABLE; + else if (curr_max_cosdh < max_cos_dihedral_angle(tr, ch0, false) + || curr_max_cosdh < max_cos_dihedral_angle(tr, ch1, false) + || curr_max_cosdh < max_cos_dihedral_angle(tr, ch2, false) + || curr_max_cosdh < max_cos_dihedral_angle(tr, ch3, false)) + db = NO_BEST_CONFIGURATION; + + if(db != VALID_FLIP) + { + ch3->set_vertex(ch3->index(vh2), vh3); + ch0->set_vertex(ch0->index(vh0), vh1); + ch2->set_vertex(ch2->index(vh2), vh3); + ch1->set_vertex(ch1->index(vh0), vh1); + + c3t3.add_to_complex(ch0, ch0->index(vh4), patch); + c3t3.add_to_complex(ch3, ch3->index(vh4), patch); + + for (Cell_handle chi : cells_around_edge) + { + Facet f1(chi, chi->index(vh1)); + Facet f2(chi, chi->index(vh3)); + + auto it = opposite_facet_in_complex.find(c3t3.triangulation().mirror_facet(f1)); + if (it != opposite_facet_in_complex.end()) + c3t3.add_to_complex(f1, it->second); + + it = opposite_facet_in_complex.find(c3t3.triangulation().mirror_facet(f2)); + if (it != opposite_facet_in_complex.end()) + c3t3.add_to_complex(f2, it->second); + } + + return db; + } + + //Top cells 2-2 flip + ch3->set_neighbor(ch3->index(vh1), ch0); + ch3->set_neighbor(ch3->index(vh0), n_ch0_vh3); + n_ch0_vh3->set_neighbor(n_ch0_vh3->index(ch0), ch3); + + ch0->set_neighbor(ch0->index(vh3), ch3); + ch0->set_neighbor(ch0->index(vh2), n_ch3_vh1); + n_ch3_vh1->set_neighbor(n_ch3_vh1->index(ch3), ch0); + + //Bottom cells 2-2 flip + ch2->set_neighbor(ch2->index(vh1), ch1); + ch2->set_neighbor(ch2->index(vh0), n_ch1_vh3); + n_ch1_vh3->set_neighbor(n_ch1_vh3->index(ch1), ch2); + + ch1->set_neighbor(ch1->index(vh3), ch2); + ch1->set_neighbor(ch1->index(vh2), n_ch2_vh1); + n_ch2_vh1->set_neighbor(n_ch2_vh1->index(ch2), ch1); + + for (Cell_handle ci : cells_around_edge) + { + for (int j = 0; j < 4; j++) + ci->vertex(j)->set_cell(ci); + } + + c3t3.add_to_complex(ch0, ch0->index(vh4), patch); + c3t3.add_to_complex(ch3, ch3->index(vh4), patch); + + for (Cell_handle chi : cells_around_edge) + { + Facet f1(chi, chi->index(vh0)); + Facet f2(chi, chi->index(vh2)); + + auto it = opposite_facet_in_complex.find(c3t3.triangulation().mirror_facet(f1)); + if (it != opposite_facet_in_complex.end()) + c3t3.add_to_complex(f1, it->second); + + it = opposite_facet_in_complex.find(c3t3.triangulation().mirror_facet(f2)); + if (it != opposite_facet_in_complex.end()) + c3t3.add_to_complex(f2, it->second); + } + + for(Cell_handle c : cells_around_edge) + c->reset_cache_validity(); + + return db; + } + else //Non planar flip + { +#ifdef CGAL_FLIP_ON_SURFACE_DISABLE_NON_PLANAR_44_FLIP + return NOT_FLIPPABLE; +#endif + typename C3T3::Surface_patch_index patch = c3t3.surface_patch_index(ch0, ch0->index(vh2)); + CGAL_assertion(patch != typename C3T3::Surface_patch_index()); + + CGAL_assertion(c3t3.is_in_complex(ch0, ch0->index(vh2))); + c3t3.remove_from_complex(ch0, ch0->index(vh2)); + CGAL_assertion(c3t3.is_in_complex(ch1, ch1->index(vh2))); + c3t3.remove_from_complex(ch1, ch1->index(vh2)); + + boost::unordered_map opposite_facet_in_complex; + for (Cell_handle chi : cells_around_edge) + { + Facet f1(chi, chi->index(vh1)); + Facet f2(chi, chi->index(vh3)); + + if (c3t3.is_in_complex(f1)) + { + Surface_patch_index spi = c3t3.surface_patch_index(f1); + opposite_facet_in_complex[c3t3.triangulation().mirror_facet(f1)] = spi; + c3t3.remove_from_complex(f1); + } + if (c3t3.is_in_complex(f2)) + { + Surface_patch_index spi = c3t3.surface_patch_index(f2); + opposite_facet_in_complex[c3t3.triangulation().mirror_facet(f2)] = spi; + c3t3.remove_from_complex(f2); + } + } + + // Top Flip + ch3->set_vertex(ch3->index(vh1), vh5); + ch2->set_vertex(ch2->index(vh3), vh4); + ch0->set_vertex(ch0->index(vh1), vh5); + ch1->set_vertex(ch1->index(vh3), vh4); + + Sliver_removal_result db = VALID_FLIP; + if (!is_well_oriented(tr, ch0) + || !is_well_oriented(tr, ch1) + || !is_well_oriented(tr, ch2) + || !is_well_oriented(tr, ch3)) + db = NOT_FLIPPABLE; + else if (curr_max_cosdh < max_cos_dihedral_angle(tr, ch0, false) + || curr_max_cosdh < max_cos_dihedral_angle(tr, ch1, false) + || curr_max_cosdh < max_cos_dihedral_angle(tr, ch2, false) + || curr_max_cosdh < max_cos_dihedral_angle(tr, ch3, false)) + db = NO_BEST_CONFIGURATION; + + if (db == NOT_FLIPPABLE || db == NO_BEST_CONFIGURATION) + { + ch3->set_vertex(ch3->index(vh5), vh1); + ch2->set_vertex(ch2->index(vh4), vh3); + ch0->set_vertex(ch0->index(vh5), vh1); + ch1->set_vertex(ch1->index(vh4), vh3); + + c3t3.add_to_complex(ch0, ch0->index(vh2), patch); + c3t3.add_to_complex(ch1, ch1->index(vh2), patch); + + for (Cell_handle chi : cells_around_edge) + { + Facet f1(chi, chi->index(vh1)); + Facet f2(chi, chi->index(vh3)); + + auto it = opposite_facet_in_complex.find(c3t3.triangulation().mirror_facet(f1)); + if (it != opposite_facet_in_complex.end()) + c3t3.add_to_complex(f1, it->second); + + it = opposite_facet_in_complex.find(c3t3.triangulation().mirror_facet(f2)); + if (it != opposite_facet_in_complex.end()) + c3t3.add_to_complex(f2, it->second); + } + + return db; + } + + //Left cells 2-2 flip + Cell_handle n_ch3_vh3 = ch3->neighbor(ch3->index(vh3)); + Cell_handle n_ch2_vh1 = ch2->neighbor(ch2->index(vh1)); + + ch3->set_neighbor(ch3->index(vh3), ch2); + ch3->set_neighbor(ch3->index(vh4), n_ch2_vh1); + n_ch2_vh1->set_neighbor(n_ch2_vh1->index(ch2), ch3); + + ch2->set_neighbor(ch2->index(vh1), ch3); + ch2->set_neighbor(ch2->index(vh5), n_ch3_vh3); + n_ch3_vh3->set_neighbor(n_ch3_vh3->index(ch3), ch2); + + //Right cells 2-2 flip + Cell_handle n_ch0_vh3 = ch0->neighbor(ch0->index(vh3)); + Cell_handle n_ch1_vh1 = ch1->neighbor(ch1->index(vh1)); + + ch0->set_neighbor(ch0->index(vh3), ch1); + ch0->set_neighbor(ch0->index(vh4), n_ch1_vh1); + n_ch1_vh1->set_neighbor(n_ch1_vh1->index(ch1), ch0); + + ch1->set_neighbor(ch1->index(vh1), ch0); + ch1->set_neighbor(ch1->index(vh5), n_ch0_vh3); + n_ch0_vh3->set_neighbor(n_ch0_vh3->index(ch0), ch1); + + for (const Cell_handle ce : cells_around_edge) + { + for (int j = 0; j < 4; j++) + ce->vertex(j)->set_cell(ce); + } + + c3t3.add_to_complex(ch0, ch0->index(vh2), patch); + c3t3.add_to_complex(ch1, ch1->index(vh2), patch); + + for (Cell_handle chi : cells_around_edge) + { + Facet f1(chi, chi->index(vh4)); + Facet f2(chi, chi->index(vh5)); + + auto it = opposite_facet_in_complex.find(c3t3.triangulation().mirror_facet(f1)); + if (it != opposite_facet_in_complex.end()) + c3t3.add_to_complex(f1, it->second); + + it = opposite_facet_in_complex.find(c3t3.triangulation().mirror_facet(f2)); + if (it != opposite_facet_in_complex.end()) + c3t3.add_to_complex(f2, it->second); + } + + for (Cell_handle c : cells_around_edge) + c->reset_cache_validity(); + + return VALID_FLIP; + } + + return NOT_FLIPPABLE; +} + +template +std::size_t flipBoundaryEdges( + C3T3& c3t3, + const std::vector& boundary_edges, + SurfaceIndexMapMap& boundary_vertices_valences, + IncidentCellsVectorMap& inc_cells, + const Flip_Criterion& flip_criterion, + CellSelector& cell_selector, + Visitor& visitor) +{ + typedef typename C3T3::Vertex_handle Vertex_handle; + typedef typename C3T3::Cell_handle Cell_handle; + typedef typename C3T3::Facet Facet; + typedef typename C3T3::Edge Edge; + typedef typename C3T3::Surface_patch_index Surface_patch_index; + typedef typename C3T3::Triangulation Tr; + typedef std::pair Edge_vv; + + std::size_t nb_success = 0; + + Tr& tr = c3t3.triangulation(); + + std::vector candidate_edges_for_flip; + for (const Edge& e : boundary_edges) + { + if (!c3t3.is_in_complex(e)) + candidate_edges_for_flip.push_back(make_vertex_pair(e)); + } + + for (const auto& [vh0, vh1] : candidate_edges_for_flip) + { + boost::container::small_vector& inc_vh0 = inc_cells[vh0]; + if (inc_vh0.empty()) + tr.incident_cells(vh0, std::back_inserter(inc_vh0)); + + Cell_handle c; + int i, j; + if (!is_edge_uv(vh0, vh1, inc_vh0, c, i, j)) + continue; + + Edge edge(c, i, j); + std::vector boundary_facets; + const bool on_boundary = is_boundary_edge(edge, c3t3, cell_selector, boundary_facets); + +// if (on_boundary && boundary_facets.empty()) +// { +// std::cerr << vh0->point().point() << "\t " << vh1->point().point() << std::endl; +// bool b = is_boundary_edge(vh0, vh1, c3t3, cell_selector); +// CGAL::Tetrahedral_remeshing::debug::dump_c3t3(c3t3, "dump_c3t3_about_boundary_"); +// CGAL::Tetrahedral_remeshing::debug::dump_facets_in_complex(c3t3, "dump_facets_about_boundary_.off"); +// CGAL::Tetrahedral_remeshing::debug::dump_facets_from_selection( +// c3t3, cell_selector, "dump_facets_from_selection_.off"); +// std::cerr << "valid = " << tr.tds().is_valid(true) << std::endl; +// std::cerr << "boundary = " << b << std::endl; +// CGAL_assertion(on_boundary); +// } +// else if (on_boundary && boundary_facets.size() != 2) +// { +// std::cerr << vh0->point().point() << "\t " << vh1->point().point() << std::endl; +// CGAL::Tetrahedral_remeshing::debug::dump_c3t3(c3t3, "dump_c3t3_about_boundary_"); +// CGAL::Tetrahedral_remeshing::debug::dump_facets(boundary_facets, "dump_boundary_facets.polylines.txt"); +// std::vector dummy_facets; +// bool b = is_boundary_edge(edge, c3t3, cell_selector, dummy_facets, true/**/); +// std::cerr << "boundary = " << b << std::endl; +// } + + if (!on_boundary) + continue; + CGAL_assertion(boundary_facets.size() == 2); + + const Facet& f0 = boundary_facets[0]; + const Facet& f1 = boundary_facets[1]; + + // find 3rd and 4th vertices to flip on surface + const Vertex_handle vh2 = third_vertex(f0, vh0, vh1, tr); + const Vertex_handle vh3 = third_vertex(f1, vh0, vh1, tr); + + CGAL_assertion_code(debug::check_facets(vh0, vh1, vh2, vh3, c3t3)); + + if (!tr.tds().is_edge(vh2, vh3)) // most-likely to happen early exit + { + const Surface_patch_index surfi = c3t3.surface_patch_index(boundary_facets[0]); + + int v0 = boundary_vertices_valences.at(vh0)[surfi]; + int v1 = boundary_vertices_valences.at(vh1)[surfi]; + int v2 = boundary_vertices_valences.at(vh2)[surfi]; + int v3 = boundary_vertices_valences.at(vh3)[surfi]; + int m0 = (boundary_vertices_valences.at(vh0).size() > 1 ? 4 : 6); + int m1 = (boundary_vertices_valences.at(vh1).size() > 1 ? 4 : 6); + int m2 = (boundary_vertices_valences.at(vh2).size() > 1 ? 4 : 6); + int m3 = (boundary_vertices_valences.at(vh3).size() > 1 ? 4 : 6); + + int initial_cost = (v0 - m0)*(v0 - m0) + + (v1 - m1)*(v1 - m1) + + (v2 - m2)*(v2 - m2) + + (v3 - m3)*(v3 - m3); + v0--; + v1--; + v2++; + v3++; + + int final_cost = (v0 - m0)*(v0 - m0) + + (v1 - m1)*(v1 - m1) + + (v2 - m2)*(v2 - m2) + + (v3 - m3)*(v3 - m3); + if (initial_cost > final_cost) + { + CGAL_assertion_code(std::size_t nbf = + std::distance(c3t3.facets_in_complex_begin(), + c3t3.facets_in_complex_end())); + CGAL_assertion_code(std::size_t nbe = + std::distance(c3t3.edges_in_complex_begin(), + c3t3.edges_in_complex_end())); + + Sliver_removal_result db = flip_on_surface(c3t3, edge, vh2, vh3, + inc_cells, + flip_criterion, + visitor); + if (db == VALID_FLIP) + { + CGAL_assertion(tr.tds().is_edge(vh2, vh3)); + Cell_handle c; + int li, lj, lk; + CGAL_assertion_code(bool b =) + tr.tds().is_facet(vh2, vh3, vh0, c, li, lj, lk); + CGAL_assertion(b); + c3t3.add_to_complex(c, (6 - li - lj - lk), surfi); + + CGAL_assertion_code(b = ) + tr.tds().is_facet(vh2, vh3, vh1, c, li, lj, lk); + CGAL_assertion(b); + c3t3.add_to_complex(c, (6 - li - lj - lk), surfi); + + CGAL_assertion_code(std::size_t nbf_post = + std::distance(c3t3.facets_in_complex_begin(), + c3t3.facets_in_complex_end())); + CGAL_assertion(nbf == nbf_post); + CGAL_assertion_code(std::size_t nbe_post = + std::distance(c3t3.edges_in_complex_begin(), + c3t3.edges_in_complex_end())); + CGAL_assertion(nbe == nbe_post); + + boundary_vertices_valences[vh0][surfi]--; + boundary_vertices_valences[vh1][surfi]--; + boundary_vertices_valences[vh2][surfi]++; + boundary_vertices_valences[vh3][surfi]++; + + nb_success++; + } + else + continue; + } + } + } + CGAL_assertion(tr.tds().is_valid()); + + return nb_success; } template @@ -1240,54 +1898,82 @@ void flip_edges(C3T3& c3t3, CGAL_USE(protect_boundaries); typedef typename C3T3::Triangulation T3; typedef typename T3::Vertex_handle Vertex_handle; + typedef typename T3::Cell_handle Cell_handle; + typedef typename T3::Edge Edge; typedef typename std::pair Edge_vv; + typedef typename C3T3::Subdomain_index Subdomain_index; #ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE std::cout << "Flip edges..."; std::cout.flush(); - std::size_t nb_flips = 0; + std::size_t nb_flips_in_volume = 0; + std::size_t nb_flips_on_surface = 0; #endif + for (auto c : c3t3.cells_in_complex()) + c->reset_cache_validity();//we will use sliver_value + //to store the cos_dihedral_angle + //const Flip_Criterion criterion = VALENCE_MIN_DH_BASED; - //compute vertices normals map? - - // typedef typename C3T3::Surface_patch_index Surface_patch_index; - // typedef std::unordered_map Spi_map; - //if (!protect_boundaries) - //{ - // std::cout << "\tBoundary flips" << std::endl; - // //Boundary flip - // std::vector boundary_vertices_valences; - // std::vector boundary_edges; - - // collectBoundaryEdges(boundary_edges); - - // computeVerticesValences(boundary_vertices_valences); - - // if (criterion == VALENCE_BASED) - // flipBoundaryEdges(boundary_edges, boundary_vertices_valences, VALENCE_BASED); - // else - // flipBoundaryEdges(boundary_edges, boundary_vertices_valences, MIN_ANGLE_BASED); - //} - std::vector inside_edges; get_internal_edges(c3t3, cell_selector, std::back_inserter(inside_edges)); - //if (criterion == VALENCE_BASED) - // flip_inside_edges(inside_edges); - //else - //{ -#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE - nb_flips = -#endif - flip_all_edges(inside_edges, c3t3, MIN_ANGLE_BASED, cell_selector, visitor); - //} +// //if (criterion == VALENCE_BASED) +// // flip_inside_edges(inside_edges); +// //else +// //{ +//#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE +// nb_flips += +//#endif +// flip_all_edges(inside_edges, c3t3, MIN_ANGLE_BASED, visitor); +// //} + + std::unordered_map > inc_cells; #ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE - std::cout << " done (" << nb_flips << " flips)." << std::endl; + nb_flips_in_volume += +#endif + flip_all_edges(inside_edges, c3t3, inc_cells, MIN_ANGLE_BASED, cell_selector, visitor); + if (!protect_boundaries) + { + typedef typename C3T3::Surface_patch_index Surface_patch_index; + typedef boost::unordered_map Spi_map; + + //Boundary flip + std::vector boundary_edges; + boost::unordered_map boundary_vertices_valences; + boost::unordered_map > vertices_subdomain_indices; + collectBoundaryEdgesAndComputeVerticesValences(c3t3, + cell_selector, + boundary_edges, + boundary_vertices_valences, + vertices_subdomain_indices); + +#ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG + if(!debug::are_cell_orientations_valid(c3t3.triangulation())) + std::cerr << "ERROR in ORIENTATION" << std::endl; +#endif + + // if (criterion == VALENCE_BASED) + // flipBoundaryEdges(boundary_edges, boundary_vertices_valences, VALENCE_BASED); + // else +#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE + nb_flips_on_surface += +#endif + flipBoundaryEdges(c3t3, boundary_edges, boundary_vertices_valences, + inc_cells, + MIN_ANGLE_BASED, + cell_selector, visitor); + } + +#ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE + std::cout << "\rFlip edges... done (" + << nb_flips_on_surface << "/" + << nb_flips_in_volume << " surface/volume flips done)." << std::endl; #endif } diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h index 5106fb1835b..197753c9784 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/split_long_edges.h @@ -41,6 +41,7 @@ typename C3t3::Vertex_handle split_edge(const typename C3t3::Edge& e, typedef typename C3t3::Triangulation Tr; typedef typename C3t3::Subdomain_index Subdomain_index; typedef typename C3t3::Surface_patch_index Surface_patch_index; + typedef typename C3t3::Curve_index Curve_index; typedef typename Tr::Geom_traits::Point_3 Point; typedef typename Tr::Facet Facet; typedef typename Tr::Vertex_handle Vertex_handle; @@ -70,6 +71,11 @@ typename C3t3::Vertex_handle split_edge(const typename C3t3::Edge& e, } CGAL_assertion(dimension > 0); + // remove complex edge before splitting + const Curve_index curve_index = (dimension == 1) ? c3t3.curve_index(e) : Curve_index(); + if (dimension == 1) + c3t3.remove_from_complex(e); + struct Cell_info { Subdomain_index subdomain_index_; bool selected_; @@ -194,6 +200,13 @@ typename C3t3::Vertex_handle split_edge(const typename C3t3::Edge& e, // will have its patch tagged from the other side, if needed } + // re-insert complex sub-edges + if (dimension == 1) + { + c3t3.add_to_complex(new_v, v1, curve_index); + c3t3.add_to_complex(new_v, v2, curve_index); + } + set_index(new_v, c3t3); return new_v; @@ -273,7 +286,7 @@ void split_long_edges(C3T3& c3t3, = tr.geom_traits().compute_squared_length_3_object(); FT sqlen = sql(tr.segment(e)); if (sqlen > sq_high) - long_edges.insert(long_edge(make_vertex_pair(e), sqlen)); + long_edges.insert(long_edge(make_vertex_pair(e), sqlen)); } #ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h index 7a905092870..5912bb67575 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_adaptive_remeshing_impl.h @@ -32,6 +32,7 @@ #include #include +#include namespace CGAL { @@ -76,6 +77,7 @@ struct All_cells_selected template(e)) + if (get(ecmap, CGAL::Tetrahedral_remeshing::make_vertex_pair(e)) || m_c3t3.is_in_complex(e) || nb_incident_subdomains(e, m_c3t3) > 2 - || nb_incident_surface_patches(e, m_c3t3) > 1) + || nb_incident_surface_patches(e, m_c3t3) > 1 + || nb_incident_complex_facets(e, m_c3t3) > 2)//non-manifold edges { const bool in_complex = m_c3t3.is_in_complex(e); typename C3t3::Curve_index curve_id = in_complex @@ -430,8 +444,13 @@ private: Corner_index corner_id = 0; for (Vertex_handle vit : tr().finite_vertex_handles()) { - if ( vit->in_dimension() == 0 - || nb_incident_complex_edges(vit, m_c3t3) > 2) + boost::container::small_vector incident_edges; + incident_complex_edges(vit, m_c3t3, std::back_inserter(incident_edges)); + if ( incident_edges.size() == 1 //tip or endpoint + || incident_edges.size() > 2 //corner + || get(vcmap, vit) // constrained vertex + || (incident_edges.size() == 2 + && edges_form_a_sharp_angle(incident_edges, 60, m_c3t3))) { if (!m_c3t3.is_in_complex(vit)) m_c3t3.add_to_complex(vit, ++corner_id); @@ -455,6 +474,8 @@ private: std::cout << "\t facets = " << nbf << std::endl; std::cout << "\t edges = " << nbe << std::endl; std::cout << "\t vertices = " << nbv << std::endl; + const double mdh = CGAL::Tetrahedral_remeshing::min_dihedral_angle(m_c3t3); + std::cout << "\t Min dihedral angle = " << mdh << std::endl; CGAL::Tetrahedral_remeshing::debug::dump_vertices_by_dimension( m_c3t3.triangulation(), "0-c3t3_vertices_after_init_"); @@ -600,6 +621,9 @@ public: ossi << "statistics_" << it_nb << ".txt"; Tetrahedral_remeshing::internal::compute_statistics( tr(), m_cell_selector, ossi.str().c_str()); + std::ostringstream oss_it; + oss_it << "iteration_" << it_nb; + Tetrahedral_remeshing::debug::dump_c3t3(m_c3t3, oss_it.str().c_str()); #endif #ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG CGAL::Tetrahedral_remeshing::debug::check_surface_patch_indices(m_c3t3); diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h index 9ea06ce7d4e..cef3b46ed4a 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/internal/tetrahedral_remeshing_helpers.h @@ -37,7 +37,7 @@ namespace Tetrahedral_remeshing { enum Subdomain_relation { EQUAL, DIFFERENT, INCLUDED, INCLUDES }; -enum Sliver_removal_result { INVALID_ORIENTATION, INVALID_CELL, INVALID_VERTEX, +enum Sliver_removal_result { INVALID_ORIENTATION = 1, INVALID_CELL, INVALID_VERTEX, NOT_FLIPPABLE, EDGE_PROBLEM, VALID_FLIP, NO_BEST_CONFIGURATION, EXISTING_EDGE }; template @@ -79,6 +79,23 @@ inline int indices(const int& i, const int& j) return 0; } +template +typename Tr::Vertex_handle +third_vertex(const typename Tr::Facet& f, + const typename Tr::Vertex_handle v0, + const typename Tr::Vertex_handle v1, + const Tr& tr) +{ + for(auto v : tr.vertices(f)) + if(v != v0 && v != v1) + return v; + + CGAL_assertion(false); + return + typename Tr::Vertex_handle(); +} + +// returns angle in degrees template std::array vertices(const typename Tr::Edge& e , const Tr&) @@ -164,6 +181,8 @@ template typename Tr::Geom_traits::FT min_dihedral_angle(const Tr& tr, const typename Tr::Cell_handle c) { + if (tr.is_infinite(c)) + return 180.; return min_dihedral_angle(tr, c->vertex(0), c->vertex(1), @@ -171,6 +190,18 @@ typename Tr::Geom_traits::FT min_dihedral_angle(const Tr& tr, c->vertex(3)); } +template +typename C3t3::Triangulation::Geom_traits::FT min_dihedral_angle(const C3t3& c3t3) +{ + typename C3t3::Triangulation::Geom_traits::FT min_dh = 180.; + + for (const auto c : c3t3.cells_in_complex()) + min_dh = (std::min)(min_dh, min_dihedral_angle(c3t3.triangulation(), c)); + + return min_dh; +} + + struct Dihedral_angle_cosine { CGAL::Sign m_sgn; @@ -201,6 +232,20 @@ struct Dihedral_angle_cosine }; } + double value() const + { + switch (m_sgn) + { + case CGAL::POSITIVE: + return CGAL::approximate_sqrt(m_sq_num / m_sq_den); + case CGAL::ZERO: + return 0.; + default: + CGAL_assertion(m_sgn == CGAL::NEGATIVE); + return -1. * CGAL::approximate_sqrt(m_sq_num / m_sq_den); + }; + } + friend bool operator<(const Dihedral_angle_cosine& l, const Dihedral_angle_cosine& r) { @@ -276,8 +321,12 @@ Dihedral_angle_cosine cos_dihedral_angle(const typename Gt::Point_3& i, const double sqden = CGAL::to_double( scalar_product(ijik, ijik) * scalar_product(ilij, ilij)); + const double sqnum = CGAL::square(CGAL::to_double(num)); - return Dihedral_angle_cosine(CGAL::sign(num), CGAL::square(num), sqden); + if(sqnum > sqden) + return Dihedral_angle_cosine(CGAL::sign(num), 1., 1.);//snap to 1 or -1 + else + return Dihedral_angle_cosine(CGAL::sign(num), CGAL::square(num), sqden); } template @@ -310,6 +359,9 @@ Dihedral_angle_cosine max_cos_dihedral_angle(const Point& p, a = cos_dihedral_angle(r, s, p, q, gt); if (max_cos_dh < a) max_cos_dh = a; + CGAL_assertion(max_cos_dh.value() <= 1.); + CGAL_assertion(max_cos_dh.value() >= -1.); + return max_cos_dh; } @@ -329,21 +381,84 @@ Dihedral_angle_cosine max_cos_dihedral_angle(const Tr& tr, template Dihedral_angle_cosine max_cos_dihedral_angle(const Tr& tr, - const typename Tr::Cell_handle c) + const typename Tr::Cell_handle c, + const bool use_cache = true) { - if (c->is_cache_valid()) + if (use_cache && c->is_cache_valid()) return Dihedral_angle_cosine(CGAL::sign(c->sliver_value()), CGAL::abs(c->sliver_value()), 1.); + else if(tr.is_infinite(c)) + return Dihedral_angle_cosine(CGAL::ZERO, 0., 1.); + + typedef typename Tr::Triangulation_data_structure::Cell::Subdomain_index Subdomain_index; + if(c->subdomain_index() == Subdomain_index()) + return Dihedral_angle_cosine(CGAL::ZERO, 0., 1.); Dihedral_angle_cosine cos_dh = max_cos_dihedral_angle(tr, c->vertex(0), c->vertex(1), c->vertex(2), c->vertex(3)); - c->set_sliver_value(cos_dh.signed_square_value()); + if(use_cache) + c->set_sliver_value(cos_dh.signed_square_value()); return cos_dh; } +// incident_edges must share a vertex +template +bool edges_form_a_sharp_angle(const EdgesVector& incident_edges, + const double angle_bound, + const C3t3& c3t3) +{ + CGAL_assertion(incident_edges.size() == 2); + + typedef typename C3t3::Vertex_handle Vertex_handle; + + const std::array ev0 + = c3t3.triangulation().vertices(incident_edges[0]); + const std::array ev1 + = c3t3.triangulation().vertices(incident_edges[1]); + + Vertex_handle shared_vertex, v1, v2; + if (ev0[0] == ev1[0]) + { + shared_vertex = ev0[0]; + v1 = ev0[1]; + v2 = ev1[1]; + } + else if(ev0[0] == ev1[1]) + { + shared_vertex = ev0[0]; + v1 = ev0[1]; + v2 = ev1[0]; + } + else if(ev0[1] == ev1[0]) + { + shared_vertex = ev0[1]; + v1 = ev0[0]; + v2 = ev1[1]; + } + else if(ev0[1] == ev1[1]) + { + shared_vertex = ev0[1]; + v1 = ev0[0]; + v2 = ev1[0]; + } + else + { + CGAL_assertion(false); + return false; + } + CGAL_assertion(shared_vertex != v1); + CGAL_assertion(shared_vertex != v2); + CGAL_assertion(v1 != v2); + + const double angle = CGAL::approximate_angle(point(v1->point()), + point(shared_vertex->point()), + point(v2->point())); + return angle < angle_bound; +} + template bool is_peelable(const C3t3& c3t3, const typename C3t3::Cell_handle ch, @@ -398,14 +513,10 @@ std::pair make_vertex_pair(const Vh v1, const Vh v2) else return std::make_pair(v1, v2); } -template -std::pair -make_vertex_pair(const typename Tr::Edge& e) +template +auto make_vertex_pair(const Edge& e) { - typedef typename Tr::Vertex_handle Vertex_handle; - Vertex_handle v1 = e.first->vertex(e.second); - Vertex_handle v2 = e.first->vertex(e.third); - return make_vertex_pair(v1, v2); + return make_vertex_pair(e.first->vertex(e.second), e.first->vertex(e.third)); } template @@ -460,23 +571,45 @@ bool is_well_oriented(const Tr& tr, template bool is_well_oriented(const Tr& tr, const typename Tr::Cell_handle ch) { - return is_well_oriented(tr, ch->vertex(0), ch->vertex(1), - ch->vertex(2), ch->vertex(3)); + return tr.is_infinite(ch) + || is_well_oriented(tr, + ch->vertex(0), + ch->vertex(1), + ch->vertex(2), + ch->vertex(3)); } template bool is_boundary(const C3T3& c3t3, const typename C3T3::Facet& f, - const CellSelector& cell_selector) + const CellSelector& cell_selector, + const bool verbose = false) { - return c3t3.is_in_complex(f) - || get(cell_selector, f.first) != get(cell_selector, f.first->neighbor(f.second)); + if (c3t3.triangulation().is_infinite(f)) + return false; + + const auto& mf = c3t3.triangulation().mirror_facet(f); + const bool res = c3t3.is_in_complex(f) + || get(cell_selector, f.first) != get(cell_selector, mf.first); + + if (verbose && res) + { + std::cout << "is_boundary(f) :" + << "\n\t in_complex = " << c3t3.is_in_complex(f) + << "\n\t selector(f.first) = " << get(cell_selector, f.first) + << "\n\t selector(mirror ) = " << get(cell_selector, mf.first) + << "\n\t subdomain(f.first)= " << f.first->subdomain_index() + << "\n\t subdomain(mirror) = " << mf.first->subdomain_index() + << std::endl; + } + + return res; } template bool is_boundary(const C3T3& c3t3, const typename C3T3::Triangulation::Edge& e, - CellSelector cell_selector) + const CellSelector& cell_selector) { typedef typename C3T3::Triangulation Tr; typedef typename Tr::Facet_circulator Facet_circulator; @@ -496,6 +629,23 @@ bool is_boundary(const C3T3& c3t3, return false; } +template +typename C3T3::Edge get_edge(const typename C3T3::Vertex_handle v0, + const typename C3T3::Vertex_handle v1, + const C3T3& c3t3) +{ + typedef typename C3T3::Edge Edge; + typedef typename C3T3::Cell_handle Cell_handle; + + Cell_handle cell; + int i0, i1; + if (c3t3.triangulation().tds().is_edge(v0, v1, cell, i0, i1)) + return Edge(cell, i0, i1); + else + CGAL_assertion(false); + return Edge(); +} + template bool is_boundary_edge(const typename C3t3::Vertex_handle& v0, const typename C3t3::Vertex_handle& v1, @@ -513,6 +663,33 @@ bool is_boundary_edge(const typename C3t3::Vertex_handle& v0, return false; } +template +bool is_boundary_edge(const typename C3t3::Edge& e, + const C3t3& c3t3, + const CellSelector& cell_selector, + std::vector& boundary_facets, + const bool verbose = false) +{ + using Facet = typename C3t3::Facet; + + auto fcirc = c3t3.triangulation().incident_facets(e); + auto fend = fcirc; + bool result = false; + + do + { + const Facet& f = *fcirc; + if (is_boundary(c3t3, f, cell_selector, verbose)) + { + boundary_facets.push_back(f); + result = true; + } + } + while (++fcirc != fend); + + return result; +} + template bool is_boundary_vertex(const typename C3t3::Vertex_handle& v, const C3t3& c3t3, @@ -665,6 +842,27 @@ OutputIterator incident_surface_patches(const typename C3t3::Edge& e, return oit; } +template +OutputIterator incident_surface_patches(const typename C3t3::Vertex_handle& v, + const C3t3& c3t3, + OutputIterator oit) +{ + typedef typename C3t3::Triangulation::Facet Facet; + boost::unordered_set facets; + c3t3.triangulation().incident_facets(v, std::inserter(facets, facets.begin())); + + for (typename boost::unordered_set::iterator fit = facets.begin(); + fit != facets.end(); + ++fit) + { + const Facet& f = *fit; + if (c3t3.is_in_complex(f)) + *oit++ = c3t3.surface_patch_index(f); + } + + return oit; +} + template std::size_t nb_incident_subdomains(const typename C3t3::Vertex_handle v, const C3t3& c3t3) @@ -701,6 +899,23 @@ std::size_t nb_incident_surface_patches(const typename C3t3::Edge& e, return indices.size(); } +template +OutputIterator incident_complex_edges(const typename C3t3::Vertex_handle v, + const C3t3& c3t3, + OutputIterator oit) +{ + typedef typename C3t3::Edge Edge; + std::unordered_set edges; + c3t3.triangulation().finite_incident_edges(v, std::inserter(edges, edges.begin())); + + for (const Edge& e : edges) + { + if (c3t3.is_in_complex(e)) + *oit++ = e; + } + return oit; +} + template std::size_t nb_incident_complex_edges(const typename C3t3::Vertex_handle v, const C3t3& c3t3) @@ -718,6 +933,23 @@ std::size_t nb_incident_complex_edges(const typename C3t3::Vertex_handle v, return count; } +template +std::size_t nb_incident_complex_facets(const typename C3t3::Edge& e, + const C3t3& c3t3) +{ + typedef typename C3t3::Triangulation::Facet_circulator Facet_circulator; + Facet_circulator circ = c3t3.triangulation().incident_facets(e); + Facet_circulator end = circ; + std::size_t count = 0; + do + { + const typename C3t3::Facet& f = *circ; + if (c3t3.is_in_complex(f)) + ++count; + } + while (++circ != end); + return count; +} template bool is_feature(const typename C3t3::Vertex_handle v, @@ -944,7 +1176,7 @@ OutputIterator get_internal_edges(const C3t3& c3t3, const typename C3t3::Edge& e = *eit; if (is_internal(e, c3t3, cell_selector)) { - *oit++ = make_vertex_pair(e); + *oit++ = make_vertex_pair(e); } } return oit; @@ -1189,6 +1421,20 @@ void get_edge_info(const typename C3t3::Edge& edge, } } +template +std::array +cell_edges(const typename Tr::Cell_handle c, const Tr&) +{ + using Edge = typename Tr::Edge; + std::array edges_array = { { Edge(c, 0, 1), + Edge(c, 0, 2), + Edge(c, 0, 3), + Edge(c, 1, 2), + Edge(c, 1, 3), + Edge(c, 2, 3) } }; + return edges_array; +} + namespace internal { template @@ -1211,6 +1457,9 @@ namespace internal { //update C3t3 using Subdomain_index = typename C3t3::Subdomain_index; + if(c3t3.is_in_complex(c)) + c3t3.remove_from_complex(c); + if (Subdomain_index() != subdomain) c3t3.add_to_complex(c, subdomain); else @@ -1224,6 +1473,24 @@ namespace internal namespace debug { +template +bool check_facets(const typename C3t3::Vertex_handle vh0, + const typename C3t3::Vertex_handle vh1, + const typename C3t3::Vertex_handle vh2, + const typename C3t3::Vertex_handle vh3, + const C3t3& c3t3) +{ + int li, lj, lk; + typename C3t3::Cell_handle c; + + bool b1 = c3t3.triangulation().is_facet(vh0, vh1, vh2, c, li, lj, lk); + bool b2 = c3t3.is_in_complex(c, (6 - li - lj - lk)); + bool b3 = c3t3.triangulation().is_facet(vh0, vh1, vh3, c, li, lj, lk); + bool b4 = c3t3.is_in_complex(c, (6 - li - lj - lk)); + + return b1 && b2 && b3 && b4; +} + // forward-declaration template void dump_cells(const CellRange& cells, const char* filename); @@ -1242,6 +1509,20 @@ void dump_edges(const Bimap& edges, const char* filename) ofs.close(); } +template +void dump_edges(const std::vector& edges, const char* filename) +{ + std::ofstream ofs(filename); + ofs.precision(17); + + for (const Edge& e : edges) + { + ofs << "2 " << point(e.first->vertex(e.second)->point()) + << " " << point(e.first->vertex(e.third)->point()) << std::endl; + } + ofs.close(); +} + template void dump_facet(const Facet& f, OutputStream& os) { @@ -1264,6 +1545,20 @@ void dump_facets(const FacetRange& facets, const char* filename) os.close(); } +template +void dump_facets_from_selection(const C3t3& c3t3, + const CellSelector& selector, + const char* filename) +{ + std::vector facets; + for (const auto& f : c3t3.triangulation().finite_facets()) + { + if (get(selector, f.first) != get(selector, f.first->neighbor(f.second))) + facets.push_back(f); + } + dump_facets(facets, filename); +} + template void dump_polylines(const CellRange& cells, const char* filename) { diff --git a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h index d11d72973b6..451cab5ee57 100644 --- a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h +++ b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h @@ -107,6 +107,15 @@ namespace CGAL * by `Remeshing_edge_is_constrained_map` and `Remeshing_facet_is_constrained_map`.} * \cgalParamNEnd * +* \cgalParamNBegin{facet_is_constrained_map} +* \cgalParamDescription{a property map containing the constrained-or-not status of each facet of `tr`.} +* \cgalParamType{a class model of `ReadablePropertyMap` with `Triangulation_3::Facet` +* as key type and `bool` as value type. It must be default constructible.} +* \cgalParamDefault{a default property map where no facet is constrained} +* \cgalParamExtra{A constrained facet can be split or collapsed, but not flipped.} +* \cgalParamExtra{This map, contrary to the others, is not updated throughout the remeshing process.} +* \cgalParamNEnd +* * \cgalParamNBegin{edge_is_constrained_map} * \cgalParamDescription{a property map containing the constrained-or-not status of each edge of `tr`.} * \cgalParamType{a class model of `ReadWritePropertyMap` with `std::pair` @@ -118,13 +127,12 @@ namespace CGAL * with edge splits and collapses, so the property map must be writable.} * \cgalParamNEnd * -* \cgalParamNBegin{facet_is_constrained_map} -* \cgalParamDescription{a property map containing the constrained-or-not status of each facet of `tr`.} -* \cgalParamType{a class model of `ReadablePropertyMap` with `Triangulation_3::Facet` +* \cgalParamNBegin{vertex_is_constrained_map} +* \cgalParamDescription{a property map containing the constrained-or-not status of each vertex of `tr`.} +* \cgalParamType{a class model of `ReadWritePropertyMap` with `Triangulation_3::Vertex_handle` * as key type and `bool` as value type. It must be default constructible.} -* \cgalParamDefault{a default property map where no facet is constrained} -* \cgalParamExtra{A constrained facet can be split or collapsed, but not flipped.} -* \cgalParamExtra{This map, contrary to the others, is not updated throughout the remeshing process.} +* \cgalParamDefault{a default property map where no vertex is constrained} +* \cgalParamExtra{A constrained vertex cannot be removed by collapse, nor moved by smoothing.} * \cgalParamNEnd * * \cgalParamNBegin{cell_is_selected_map} @@ -147,7 +155,8 @@ namespace CGAL * \cgalParamExtra{The endvertices of constraints listed * by `edge_is_constrained_map`, and edges incident to at least three subdomains * are made eligible to one dimensional smoothing, along the constrained polylines they belong to. -* Corners (i.e. vertices incident to more than 2 constrained edges) are not allowed +* Corners (i.e. vertices listed by `vertex_is_constrained_map` or +* incident to more than 2 constrained edges) are not allowed * to move at all.\n * Note that activating the smoothing step on polyline constraints tends to reduce * the quality of the minimal dihedral angle in the mesh.\n @@ -225,6 +234,15 @@ void tetrahedral_isotropic_remeshing( = choose_parameter(get_parameter(np, internal_np::cell_selector), Tetrahedral_remeshing::internal::All_cells_selected()); + typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename internal_np::Lookup_named_param_def < + internal_np::vertex_is_constrained_t, + NamedParameters, + Constant_property_map//default + > ::type VCMap; + VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), + Constant_property_map(false)); + typedef std::pair Edge_vv; typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, @@ -263,9 +281,9 @@ void tetrahedral_isotropic_remeshing( #endif typedef Tetrahedral_remeshing::internal::Adaptive_remesher< - Tr, SizingFunction, ECMap, FCMap, SelectionFunctor, Visitor> Remesher; + Tr, SizingFunction, VCMap, ECMap, FCMap, SelectionFunctor, Visitor> Remesher; Remesher remesher(tr, sizing, protect - , ecmap, fcmap + , vcmap, ecmap, fcmap , smooth_constrained_edges , cell_select , visitor); @@ -280,6 +298,10 @@ void tetrahedral_isotropic_remeshing( // perform remeshing std::size_t nb_extra_iterations = 3; +#ifdef CGAL_TETRAHEDRAL_REMESHING_NO_EXTRA_ITERATIONS + nb_extra_iterations = 0; +#endif + remesher.remesh(max_it, nb_extra_iterations); #ifdef CGAL_TETRAHEDRAL_REMESHING_DEBUG @@ -327,7 +349,16 @@ void tetrahedral_isotropic_remeshing( * as key type and `bool` as value type. It must be default constructible.} * \cgalParamDefault{a default property map where no edge is constrained} * \cgalParamNEnd -* +* \cgalParamNBegin{vertex_is_constrained_map} +* \cgalParamDescription{a property map containing the constrained-or-not status of each vertex of +* `c3t3.triangulation()`. +* For each vertex `v` for which `c3t3.is_in_complex(v)` returns `true`, +* the constrained status of `v` is set to `true`.} +* \cgalParamType{a class model of `ReadWritePropertyMap` +* with `Triangulation_3::Vertex_handle` +* as key type and `bool` as value type. It must be default constructible.} +* \cgalParamDefault{a default property map where no vertex is constrained} +* \cgalParamNEnd * \cgalNamedParamsEnd */ @@ -349,24 +380,40 @@ convert_to_triangulation_3( using Vertex_handle = typename Tr::Vertex_handle; using Edge_vv = std::pair; - using Default_pmap = Constant_property_map; + using Default_edge_pmap = Constant_property_map; using ECMap = typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, NamedParameters, - Default_pmap + Default_edge_pmap + >::type; + using Default_vertex_pmap = Constant_property_map; + using VCMap = typename internal_np::Lookup_named_param_def < + internal_np::vertex_is_constrained_t, + NamedParameters, + Default_vertex_pmap >::type; - ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), - Default_pmap(false)); - if (!std::is_same_v) + ECMap ecmap = choose_parameter(get_parameter(np, internal_np::edge_is_constrained), + Default_edge_pmap(false)); + VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), + Default_vertex_pmap(false)); + + if (!std::is_same_v) { for (auto e : c3t3.edges_in_complex()) { const Edge_vv evv - = CGAL::Tetrahedral_remeshing::make_vertex_pair(e);//ordered pair + = CGAL::Tetrahedral_remeshing::make_vertex_pair(e);//ordered pair put(ecmap, evv, true); } } + if (!std::is_same_v) + { + for (auto v : c3t3.vertices_in_complex()) + { + put(vcmap, v, true); + } + } CGAL::Triangulation_3 tr; tr.swap(c3t3.triangulation()); @@ -444,6 +491,15 @@ void tetrahedral_isotropic_remeshing( = choose_parameter(get_parameter(np, internal_np::cell_selector), Tetrahedral_remeshing::internal::All_cells_selected()); + typedef typename Tr::Vertex_handle Vertex_handle; + typedef typename internal_np::Lookup_named_param_def < + internal_np::vertex_is_constrained_t, + NamedParameters, + Constant_property_map//default + > ::type VCMap; + VCMap vcmap = choose_parameter(get_parameter(np, internal_np::vertex_is_constrained), + Constant_property_map(false)); + typedef std::pair Edge_vv; typedef typename internal_np::Lookup_named_param_def < internal_np::edge_is_constrained_t, @@ -482,12 +538,9 @@ void tetrahedral_isotropic_remeshing( #endif typedef Tetrahedral_remeshing::internal::Adaptive_remesher< - Tr, SizingFunction, ECMap, FCMap, SelectionFunctor, - Visitor, - CornerIndex, CurveIndex - > Remesher; + Tr, SizingFunction, VCMap, ECMap, FCMap, SelectionFunctor, Visitor> Remesher; Remesher remesher(c3t3, sizing, protect - , ecmap, fcmap + , vcmap, ecmap, fcmap , smooth_constrained_edges , cell_select , visitor); @@ -501,6 +554,10 @@ void tetrahedral_isotropic_remeshing( // perform remeshing std::size_t nb_extra_iterations = 3; +#ifdef CGAL_TETRAHEDRAL_REMESHING_NO_EXTRA_ITERATIONS + nb_extra_iterations = 0; +#endif + remesher.remesh(max_it, nb_extra_iterations); #ifdef CGAL_TETRAHEDRAL_REMESHING_VERBOSE diff --git a/Triangulation/doc/Triangulation/CGAL/Delaunay_triangulation.h b/Triangulation/doc/Triangulation/CGAL/Delaunay_triangulation.h index 322cfb51756..e5f08dd1d5e 100644 --- a/Triangulation/doc/Triangulation/CGAL/Delaunay_triangulation.h +++ b/Triangulation/doc/Triangulation/CGAL/Delaunay_triangulation.h @@ -125,8 +125,8 @@ value of `lt`:
          `OUTSIDE_AFFINE_HULL`
          Point `p` is inserted so as to increase the current dimension of the Delaunay triangulation. -
          `ON_VERTEX`
          The position of the vertex `v` described by `f` -is set to `p`. `v` is returned.
          Anything else
          The point `p` +
          `ON_VERTEX`
          The triangulation remains unchanged. +
          Anything else
          The point `p` is inserted. the full cell `c` is assumed to be in conflict with `p`. diff --git a/Triangulation/doc/Triangulation/CGAL/Triangulation.h b/Triangulation/doc/Triangulation/CGAL/Triangulation.h index 1d7b0e1a65d..32188c44323 100644 --- a/Triangulation/doc/Triangulation/CGAL/Triangulation.h +++ b/Triangulation/doc/Triangulation/CGAL/Triangulation.h @@ -556,8 +556,7 @@ Inserts point `p` into the triangulation and returns a handle to the `Vertex` at that position. The action taken depends on the value of `loc_type`: -
          `ON_VERTEX`
          The point of the -p`Vertex` described by `f` is set to `p`. +
          `ON_VERTEX`
          The triangulation remains unchanged.
          `IN_FACE`
          The point `p` is inserted in the `Face f`.
          `IN_FACET`
          The point `p` is inserted in the `Facet ft`.
          Anything else
          The point `p` is inserted in the triangulation according to the value diff --git a/Triangulation/doc/Triangulation/CGAL/Triangulation_data_structure.h b/Triangulation/doc/Triangulation/CGAL/Triangulation_data_structure.h index 666f6ece70c..842bdbbf31e 100644 --- a/Triangulation/doc/Triangulation/CGAL/Triangulation_data_structure.h +++ b/Triangulation/doc/Triangulation/CGAL/Triangulation_data_structure.h @@ -81,6 +81,7 @@ data structure that only changes the vertex type. It has to define a type `Other` which is a rebound triangulation data structure with `Vb2` as vertex type. \note It can be implemented using a nested template class. + \cgalAdvancedEnd */ template @@ -94,6 +95,7 @@ data structure that only changes the full cell type. It has to define a type `Other` which is a rebound triangulation data structure with `Fcb2` as full cell type. \note It can be implemented using a nested template class. + \cgalAdvancedEnd */ template @@ -112,8 +114,9 @@ A set `C` of full cells satisfying the same condition as in method method creates new full cells from vertex `v` to the boundary of `C`. The boundary is recognized by checking the mark of the full cells. This method is used by `Triangulation_data_structure::insert_in_hole()`. -s + \pre same as `TriangulationDataStructure::insert_in_hole()` + \cgalAdvancedEnd */ diff --git a/Triangulation/doc/Triangulation/CGAL/Triangulation_ds_full_cell.h b/Triangulation/doc/Triangulation/CGAL/Triangulation_ds_full_cell.h index 148985c11b7..9aab53b759f 100644 --- a/Triangulation/doc/Triangulation/CGAL/Triangulation_ds_full_cell.h +++ b/Triangulation/doc/Triangulation/CGAL/Triangulation_ds_full_cell.h @@ -37,7 +37,7 @@ indices are not stored).
        • `CGAL::TDS_full_cell_default_storage_policy`. In that case, the mirror indices are not stored.
        • `CGAL::TDS_full_cell_mirror_storage_policy`. In that case, the mirror -indices are stored. +indices are stored. This last policy is not supported when the dimension is larger than 127. See the user manual for how to choose the second option. diff --git a/Triangulation/include/CGAL/Delaunay_triangulation.h b/Triangulation/include/CGAL/Delaunay_triangulation.h index 8fa25e4d08c..7a10b57b12f 100644 --- a/Triangulation/include/CGAL/Delaunay_triangulation.h +++ b/Triangulation/include/CGAL/Delaunay_triangulation.h @@ -673,7 +673,6 @@ Delaunay_triangulation case Base::ON_VERTEX: { Vertex_handle v = s->vertex(f.index(0)); - v->set_point(p); return v; break; } @@ -762,7 +761,7 @@ Delaunay_triangulation Inserts the point `p` in the Delaunay triangulation. Returns a handle to the (possibly newly created) vertex at that position. -\pre The point `p` must be in conflict with the full cell `c`. +\pre The point `p` must be in conflict with the full cell `s`. */ template< typename DCTraits, typename TDS > typename Delaunay_triangulation::Vertex_handle diff --git a/Triangulation/include/CGAL/IO/Triangulation_off_ostream.h b/Triangulation/include/CGAL/IO/Triangulation_off_ostream.h index 3098d831022..36fc501daf0 100644 --- a/Triangulation/include/CGAL/IO/Triangulation_off_ostream.h +++ b/Triangulation/include/CGAL/IO/Triangulation_off_ostream.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Clement Jamin @@ -13,6 +13,9 @@ #ifndef CGAL_TRIANGULATION_IO_H #define CGAL_TRIANGULATION_IO_H +#include + + #include #include #include diff --git a/Triangulation/include/CGAL/TDS_full_cell_mirror_storage_policy.h b/Triangulation/include/CGAL/TDS_full_cell_mirror_storage_policy.h index f3e3bf770d1..63176f5ed30 100644 --- a/Triangulation/include/CGAL/TDS_full_cell_mirror_storage_policy.h +++ b/Triangulation/include/CGAL/TDS_full_cell_mirror_storage_policy.h @@ -14,8 +14,8 @@ #include - #include +#include namespace CGAL { @@ -30,7 +30,7 @@ struct TFC_data< Vertex_handle, Full_cell_handle, Maximal_dimension, TDS_full_ typedef TFC_data< Vertex_handle, Full_cell_handle, Maximal_dimension, TDS_full_cell_default_storage_policy > Base; typedef typename Base::Vertex_handle_array Vertex_handle_array; typedef typename Base::Full_cell_handle_array Full_cell_handle_array; - typedef typename internal::S_or_D_array< int, typename Base::Dimen_plus > Int_array; + typedef typename internal::S_or_D_array< std::int_least8_t, typename Base::Dimen_plus > Int_array; private: Int_array mirror_vertices_; @@ -42,7 +42,7 @@ public: void set_mirror_index(const int i, const int index) { - mirror_vertices_[i] = index; + mirror_vertices_[i] = static_cast(index); } int mirror_index(const int i) const { diff --git a/Triangulation/include/CGAL/Triangulation.h b/Triangulation/include/CGAL/Triangulation.h index 1c1bff78370..10d71f3b549 100644 --- a/Triangulation/include/CGAL/Triangulation.h +++ b/Triangulation/include/CGAL/Triangulation.h @@ -843,7 +843,6 @@ Triangulation return insert_in_face(p, f); break; case ON_VERTEX: - s->vertex(f.index(0))->set_point(p); return s->vertex(f.index(0)); break; } @@ -993,7 +992,7 @@ Triangulation // Otherwise, let's find the right infinite cell else { - inf_v_cell = inf_v_cell->neighbor((inf_v_index + 1) % 2); + inf_v_cell = inf_v_cell->neighbor((inf_v_index + 1) & 1); inf_v_index = inf_v_cell->index(infinite_vertex()); // Is "inf_v_cell" the right infinite cell? // Then inf_v_index should be 1 @@ -1096,9 +1095,14 @@ Triangulation // For the remembering stochastic walk, we need to start trying // with a random index: int j, i = rng_.get_int(0, cur_dim); - // we check |p| against all the full_cell's hyperplanes in turn - for(j = 0; j <= cur_dim; ++j, i = (i + 1) % (cur_dim + 1) ) + // i = (i + 1) % m where 0 <= i < m + auto incr_mod = [] (int&i, int m) { + if( ++i >= m ) i = 0; // >= or == + }; + + // we check |p| against all the full_cell's hyperplanes in turn + for(j = 0; j <= cur_dim; ++j, incr_mod(i, cur_dim + 1)) { Full_cell_handle next = s->neighbor(i); if( previous == next ) @@ -1127,6 +1131,9 @@ Triangulation // full_cell because orientation_[i] == NEGATIVE previous = s; s = next; + // We only need to test is_infinite(next->vertex(next->index(previous))) + // or equivalently is_infinite(next->vertex(previous->mirror_index(i))) + // but it does not seem to help, even when storing mirror indices. if( is_infinite(next) ) { // we have arrived OUTSIDE the convex hull of the triangulation, // so we stop the search diff --git a/Triangulation/include/CGAL/Triangulation_ds_full_cell.h b/Triangulation/include/CGAL/Triangulation_ds_full_cell.h index 3e84630dbd9..cb361f856e3 100644 --- a/Triangulation/include/CGAL/Triangulation_ds_full_cell.h +++ b/Triangulation/include/CGAL/Triangulation_ds_full_cell.h @@ -249,7 +249,9 @@ private: const Vertex_handle_array & vertices() const {return combinatorics_.vertices_; } // DATA MEMBERS - Combinatorics combinatorics_; + // With the Itanium ABI, [[no_unique_address]] allows tda_data_ to reuse the + // padding bytes at the end of combinatorics_ when using the mirror policy. + CGAL_NO_UNIQUE_ADDRESS Combinatorics combinatorics_; mutable TDS_data tds_data_; }; diff --git a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h index 3318770f962..29d2b48d745 100644 --- a/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/doc/Triangulation_2/CGAL/Constrained_triangulation_plus_2.h @@ -516,6 +516,7 @@ constraints based on a cost and stop function. \pre The vertex referred by vicq is not contained in any other constraint. \pre Let `vip` and `vir` be defined as `vip = std::prev(vicq)` and `vir = std::next(vicr)`. \pre The line segment between `*vicp->point()` and `*vicr->point()` must not intersect any constraint. + \cgalAdvancedEnd */ void diff --git a/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h index 52c14ea54b7..714e9295b61 100644 --- a/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h @@ -342,6 +342,25 @@ public: return number_of_vertices() - n; } + // function usable only if no constraint has been inserted + void restore_Delaunay(Vertex_handle v) + { + if(this->dimension() <= 1) return; + + Face_handle f=v->face(); + Face_handle next; + int i; + Face_handle start(f); + do { + i = f->index(v); + next = f->neighbor(ccw(i)); // turn ccw around v + propagating_flip(f,i); + f = next; + } while(next != start); + return; + } + + #ifndef CGAL_TRIANGULATION_2_DONT_INSERT_RANGE_OF_POINTS_WITH_INFO private: //top stands for tuple-or-pair diff --git a/Triangulation_2/include/CGAL/IO/Triangulation_off_ostream_2.h b/Triangulation_2/include/CGAL/IO/Triangulation_off_ostream_2.h index 0274a227cc1..6fdcb5b03c4 100644 --- a/Triangulation_2/include/CGAL/IO/Triangulation_off_ostream_2.h +++ b/Triangulation_2/include/CGAL/IO/Triangulation_off_ostream_2.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Clement Jamin @@ -13,6 +13,9 @@ #ifndef CGAL_TRIANGULATION_OFF_OSTREAM_2_H #define CGAL_TRIANGULATION_OFF_OSTREAM_2_H +#include + + #include #include #include diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index 14e8604640f..c0f2c7ba50e 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -434,6 +435,81 @@ protected: bool has_inexact_negative_orientation(const Point &p, const Point &q, const Point &r) const; + + +template +inline +bool +projection_traits_has_inexact_negative_orientation(const Point &p, const Point &q, const Point &r, + const T& ) const +{ + // So that this code works well with Lazy_kernel + internal::Static_filters_predicates::Get_approx get_approx; + + const double px = to_double(get_approx(p).x()); + const double py = to_double(get_approx(p).y()); + const double qx = to_double(get_approx(q).x()); + const double qy = to_double(get_approx(q).y()); + const double rx = to_double(get_approx(r).x()); + const double ry = to_double(get_approx(r).y()); + + const double pqx = qx - px; + const double pqy = qy - py; + const double prx = rx - px; + const double pry = ry - py; + + return ( determinant(pqx, pqy, prx, pry) < 0); +} + +template +inline +bool +projection_traits_has_inexact_negative_orientation(const Point &p, const Point &q, const Point &r, + const ::CGAL::internal::Projection_traits_3& ) const +{ // So that this code works well with Lazy_kernel + internal::Static_filters_predicates::Get_approx get_approx; + + const double px = to_double(get_approx(p).y()); + const double py = to_double(get_approx(p).z()); + const double qx = to_double(get_approx(q).y()); + const double qy = to_double(get_approx(q).z()); + const double rx = to_double(get_approx(r).y()); + const double ry = to_double(get_approx(r).z()); + + const double pqx = qx - px; + const double pqy = qy - py; + const double prx = rx - px; + const double pry = ry - py; + + return ( determinant(pqx, pqy, prx, pry) < 0); +} + + +template +inline +bool +projection_traits_has_inexact_negative_orientation(const Point &p, const Point &q, const Point &r, + const ::CGAL::internal::Projection_traits_3& ) const +{ // So that this code works well with Lazy_kernel + internal::Static_filters_predicates::Get_approx get_approx; + + const double px = to_double(get_approx(p).x()); + const double py = to_double(get_approx(p).z()); + const double qx = to_double(get_approx(q).x()); + const double qy = to_double(get_approx(q).z()); + const double rx = to_double(get_approx(r).x()); + const double ry = to_double(get_approx(r).z()); + + const double pqx = qx - px; + const double pqy = qy - py; + const double prx = rx - px; + const double pry = ry - py; + + return ( determinant(pqx, pqy, prx, pry) < 0); +} + + + public: Face_handle inexact_locate(const Point& p, @@ -3152,6 +3228,7 @@ inexact_locate(const Point & t, Face_handle start, int n_of_turns) const return c; } + template inline bool @@ -3159,22 +3236,8 @@ Triangulation_2:: has_inexact_negative_orientation(const Point &p, const Point &q, const Point &r) const { - // So that this code works well with Lazy_kernel - internal::Static_filters_predicates::Get_approx get_approx; - - const double px = to_double(get_approx(p).x()); - const double py = to_double(get_approx(p).y()); - const double qx = to_double(get_approx(q).x()); - const double qy = to_double(get_approx(q).y()); - const double rx = to_double(get_approx(r).x()); - const double ry = to_double(get_approx(r).y()); - - const double pqx = qx - px; - const double pqy = qy - py; - const double prx = rx - px; - const double pry = ry - py; - - return ( determinant(pqx, pqy, prx, pry) < 0); + Gt gt; + return projection_traits_has_inexact_negative_orientation(p,q,r,gt); } #endif diff --git a/Triangulation_2/include/CGAL/Triangulation_2/internal/CTP2_subconstraint_graph.h b/Triangulation_2/include/CGAL/Triangulation_2/internal/CTP2_subconstraint_graph.h index 77e212b9f04..5eab13d4c1e 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2/internal/CTP2_subconstraint_graph.h +++ b/Triangulation_2/include/CGAL/Triangulation_2/internal/CTP2_subconstraint_graph.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Simon Giraudot diff --git a/Triangulation_2/include/CGAL/Triangulation_2_to_lcc.h b/Triangulation_2/include/CGAL/Triangulation_2_to_lcc.h index 86d9a71f51e..21607148403 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2_to_lcc.h +++ b/Triangulation_2/include/CGAL/Triangulation_2_to_lcc.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Guillaume Damiand // @@ -13,6 +13,9 @@ #ifndef CGAL_TRIANGULATION_2_TO_LCC_H #define CGAL_TRIANGULATION_2_TO_LCC_H +#include + + #include #include diff --git a/Triangulation_2/include/CGAL/Triangulation_face_base_with_id_2.h b/Triangulation_2/include/CGAL/Triangulation_face_base_with_id_2.h index d5d344c8aa8..eec9abb65c3 100644 --- a/Triangulation_2/include/CGAL/Triangulation_face_base_with_id_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_face_base_with_id_2.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Mael Rouxel-Labbé @@ -12,6 +12,9 @@ #ifndef CGAL_TRIANGULATION_FACE_BASE_WITH_ID_2_H #define CGAL_TRIANGULATION_FACE_BASE_WITH_ID_2_H +#include + + #include namespace CGAL { diff --git a/Triangulation_2/include/CGAL/Triangulation_vertex_base_with_id_2.h b/Triangulation_2/include/CGAL/Triangulation_vertex_base_with_id_2.h index 290fad8db5f..310d3c158e4 100644 --- a/Triangulation_2/include/CGAL/Triangulation_vertex_base_with_id_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_vertex_base_with_id_2.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_TRIANGULATION_VERTEX_BASE_WITH_ID_2_H #define CGAL_TRIANGULATION_VERTEX_BASE_WITH_ID_2_H +#include + + #include namespace CGAL { diff --git a/Triangulation_2/include/CGAL/apply_to_range.h b/Triangulation_2/include/CGAL/apply_to_range.h index f09433e7d57..fc235d47a48 100644 --- a/Triangulation_2/include/CGAL/apply_to_range.h +++ b/Triangulation_2/include/CGAL/apply_to_range.h @@ -5,13 +5,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Radu Ursu -#ifndef CGAL_apply_to_range_h -#define CGAL_apply_to_range_h +#ifndef CGAL_APPLY_TO_RANGE_H +#define CGAL_APPLY_TO_RANGE_H + +#include + #include #include @@ -151,4 +154,4 @@ void apply_to_range(const Tr &t, }//end namespace -#endif +#endif //CGAL_APPLY_TO_RANGE_H diff --git a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_Delaunay_triangulation_2.h index d1d82115ec8..ae3cdba64d3 100644 --- a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_Delaunay_triangulation_2.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_GRAPH_TRAITS_CONSTRAINED_DELAUNAY_TRIANGULATION_2_H #define CGAL_GRAPH_TRAITS_CONSTRAINED_DELAUNAY_TRIANGULATION_2_H +#include + + #include #include diff --git a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_triangulation_2.h b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_triangulation_2.h index 67419f0d761..50b31a0d05f 100644 --- a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_triangulation_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_triangulation_2.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_GRAPH_TRAITS_CONSTRAINED_TRIANGULATION_2_H #define CGAL_GRAPH_TRAITS_CONSTRAINED_TRIANGULATION_2_H +#include + + #include #include diff --git a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_triangulation_plus_2.h index 6cb7c45d8b2..fb21cff567a 100644 --- a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Constrained_triangulation_plus_2.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_GRAPH_TRAITS_CONSTRAINED_TRIANGULATION_PLUS_2_H #define CGAL_GRAPH_TRAITS_CONSTRAINED_TRIANGULATION_PLUS_2_H +#include + + #include #include diff --git a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h index 26caf574e03..22b95fd4cfd 100644 --- a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Delaunay_triangulation_2.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_GRAPH_TRAITS_DELAUNAY_TRIANGULATION_2_H #define CGAL_GRAPH_TRAITS_DELAUNAY_TRIANGULATION_2_H +#include + + #include #include diff --git a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Regular_triangulation_2.h b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Regular_triangulation_2.h index 572bbeaebbb..127a345a9e2 100644 --- a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Regular_triangulation_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Regular_triangulation_2.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_GRAPH_TRAITS_REGULAR_TRIANGULATION_2_H #define CGAL_GRAPH_TRAITS_REGULAR_TRIANGULATION_2_H +#include + + #include #include diff --git a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_2.h b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_2.h index 99312b8323f..8a50f96e3df 100644 --- a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_2.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_GRAPH_TRAITS_TRIANGULATION_2_H #define CGAL_GRAPH_TRAITS_TRIANGULATION_2_H +#include + + #include #include diff --git a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_hierarchy_2.h b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_hierarchy_2.h index e3ae435381b..eae9f93cefe 100644 --- a/Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/graph_traits_Triangulation_hierarchy_2.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // // Author(s) : Andreas Fabri, Fernando Cacciola @@ -12,6 +12,9 @@ #ifndef CGAL_GRAPH_TRAITS_TRIANGULATION_HIERARCHY_2_H #define CGAL_GRAPH_TRAITS_TRIANGULATION_HIERARCHY_2_H +#include + + #include #include diff --git a/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation.h b/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation.h index 27a5994dcaa..976c6741e63 100644 --- a/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation.h +++ b/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation.h @@ -4,12 +4,14 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé, // Andreas Fabri, // Fernando Cacciola +#include + #ifndef CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS #error CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS is not defined #endif diff --git a/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation_helper.h b/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation_helper.h index 0c2904243c5..22a4a4c2f3c 100644 --- a/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation_helper.h +++ b/Triangulation_2/include/CGAL/boost/graph/internal/graph_traits_2D_triangulation_helper.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé @@ -17,8 +17,11 @@ #include -#ifndef CGAL_GRAPH_TRAITS_2D_TRIANGULATION_HELPERS -#define CGAL_GRAPH_TRAITS_2D_TRIANGULATION_HELPERS +#ifndef CGAL_GRAPH_TRAITS_2D_TRIANGULATION_HELPERS_H +#define CGAL_GRAPH_TRAITS_2D_TRIANGULATION_HELPERS_H + +#include + namespace CGAL { namespace internal { @@ -181,4 +184,4 @@ private: } // namespace internal } // namespace CGAL -#endif // CGAL_GRAPH_TRAITS_2D_TRIANGULATION_HELPERS +#endif // CGAL_GRAPH_TRAITS_2D_TRIANGULATION_HELPERS_H diff --git a/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h b/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h index 7111e237ef6..2ac267ebcf8 100644 --- a/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h +++ b/Triangulation_2/include/CGAL/boost/graph/internal/properties_2D_triangulation.h @@ -4,7 +4,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé @@ -26,6 +26,9 @@ #ifndef CGAL_BOOST_GRAPH_PROPERTIES_2D_TRIANGULATION_H #define CGAL_BOOST_GRAPH_PROPERTIES_2D_TRIANGULATION_H +#include + + namespace CGAL { namespace internal { diff --git a/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_Delaunay_triangulation_2.h index 8aa35398240..e3ee3e3bb67 100644 --- a/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_Delaunay_triangulation_2.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé #ifndef CGAL_PROPERTIES_CONSTRAINED_DELAUNAY_TRIANGULATION_2_H #define CGAL_PROPERTIES_CONSTRAINED_DELAUNAY_TRIANGULATION_2_H +#include + + #include #define CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS typename GT, typename TDS, typename Itag diff --git a/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_triangulation_2.h b/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_triangulation_2.h index 7f95526668a..0fdc55290c2 100644 --- a/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_triangulation_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_triangulation_2.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé #ifndef CGAL_PROPERTIES_CONSTRAINED_TRIANGULATION_2_H #define CGAL_PROPERTIES_CONSTRAINED_TRIANGULATION_2_H +#include + + #include #define CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS typename GT, typename TDS, typename Itag diff --git a/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_triangulation_plus_2.h index 915d45b6519..8d2df8776c9 100644 --- a/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/properties_Constrained_triangulation_plus_2.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé #ifndef CGAL_PROPERTIES_CONSTRAINED_TRIANGULATION_PLUS_2_H #define CGAL_PROPERTIES_CONSTRAINED_TRIANGULATION_PLUS_2_H +#include + + #include #define CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS typename Tr diff --git a/Triangulation_2/include/CGAL/boost/graph/properties_Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/boost/graph/properties_Delaunay_triangulation_2.h index 000995d9ca9..a040184b4b8 100644 --- a/Triangulation_2/include/CGAL/boost/graph/properties_Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/properties_Delaunay_triangulation_2.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé #ifndef CGAL_PROPERTIES_DELAUNAY_TRIANGULATION_2_H #define CGAL_PROPERTIES_DELAUNAY_TRIANGULATION_2_H +#include + + #include #define CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS typename GT, typename TDS diff --git a/Triangulation_2/include/CGAL/boost/graph/properties_Regular_triangulation_2.h b/Triangulation_2/include/CGAL/boost/graph/properties_Regular_triangulation_2.h index 5030385656c..a4d0f9a4acc 100644 --- a/Triangulation_2/include/CGAL/boost/graph/properties_Regular_triangulation_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/properties_Regular_triangulation_2.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé #ifndef CGAL_PROPERTIES_REGULAR_TRIANGULATION_2_H #define CGAL_PROPERTIES_REGULAR_TRIANGULATION_2_H +#include + + #include #define CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS typename GT, typename TDS diff --git a/Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_2.h b/Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_2.h index 2a076b16cd6..6c111297bfa 100644 --- a/Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_2.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé #ifndef CGAL_PROPERTIES_TRIANGULATION_2_H #define CGAL_PROPERTIES_TRIANGULATION_2_H +#include + + #include #define CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS typename GT, typename TDS diff --git a/Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_hierarchy_2.h b/Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_hierarchy_2.h index f20cef1d9f4..830c4f8f6b5 100644 --- a/Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/boost/graph/properties_Triangulation_hierarchy_2.h @@ -4,13 +4,16 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Mael Rouxel-Labbé #ifndef CGAL_PROPERTIES_TRIANGULATION_HIERARCHY_2_H #define CGAL_PROPERTIES_TRIANGULATION_HIERARCHY_2_H +#include + + #include #define CGAL_2D_TRIANGULATION_TEMPLATE_PARAMETERS typename Tr diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h index 558f714c546..53900137363 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_constrained_triangulation_2.h @@ -21,7 +21,7 @@ // // coordinator : INRIA Sophia-Antipolis Mariette.Yvinec@sophia.inria.fr // ============================================================================ - +#include #include #include #include @@ -222,54 +222,42 @@ _test_cls_constrained_triangulation(const Triang &) /******** I/O *******/ std::cout << "output to a file" << std::endl; - std::ofstream of0_1("T01.triangulation", std::ios::out); - CGAL::IO::set_ascii_mode(of0_1); - of0_1 << T0_1; of0_1.close(); + std::stringstream ss0_1; + ss0_1 << T0_1; - std::ofstream of0_2("T02.triangulation"); - CGAL::IO::set_ascii_mode(of0_2); - of0_2 << T0_2; of0_2.close(); + std::stringstream ss0_2; + ss0_2 << T0_2; - std::ofstream of1_1("T11.triangulation"); - CGAL::IO::set_ascii_mode(of1_1); - of1_1 << T1_1; of1_1.close(); + std::stringstream ss1_1; + ss1_1 << T1_1; - std::ofstream of1_2("T12.triangulation"); - CGAL::IO::set_ascii_mode(of1_2); - of1_2 << T1_2; of1_2.close(); + std::stringstream ss1_2; + ss1_2 << T1_2; - std::ofstream of2_1("T21.triangulation"); - CGAL::IO::set_ascii_mode(of2_1); - of2_1 << T2_1; of2_1.close(); + std::stringstream ss2_1; + ss2_1 << T2_1; - std::ofstream of2_2("T22.triangulation"); - CGAL::IO::set_ascii_mode(of2_2); - of2_2 << T2_2; of2_2.close(); + std::stringstream ss2_2; + ss2_2 << T2_2; std::cout << "input from a file" << std::endl; - std::ifstream if0_1("T01.triangulation"); CGAL::IO::set_ascii_mode(if0_1); - Triang T0_1_copy; if0_1 >> T0_1_copy; - std::ifstream if0_2("T02.triangulation"); CGAL::IO::set_ascii_mode(if0_2); - Triang T0_2_copy; if0_2 >> T0_2_copy; + Triang T0_1_copy; ss0_1 >> T0_1_copy; - std::ifstream if1_1("T11.triangulation"); CGAL::IO::set_ascii_mode(if1_1); - Triang T1_1_copy; if1_1 >> T1_1_copy; + Triang T0_2_copy; ss0_2 >> T0_2_copy; - std::ifstream if1_2("T12.triangulation"); CGAL::IO::set_ascii_mode(if1_2); - Triang T1_2_copy; if1_2 >> T1_2_copy; + Triang T1_1_copy; ss1_1 >> T1_1_copy; - std::ifstream if2_1("T21.triangulation"); CGAL::IO::set_ascii_mode(if2_1); - Triang T2_1_copy; if2_1 >> T2_1_copy; + Triang T1_2_copy; ss1_2 >> T1_2_copy; - std::ifstream if2_2("T22.triangulation"); CGAL::IO::set_ascii_mode(if2_2); - Triang T2_2_copy; if2_2 >> T2_2_copy; + Triang T2_1_copy; ss2_1 >> T2_1_copy; + + Triang T2_2_copy; ss2_2 >> T2_2_copy; // test copy of constrained Triangulation - Triang T2_4(T2_2); - std::ofstream of2_2_bis("T22.triangulation"); - CGAL::IO::set_ascii_mode(of2_2_bis); - of2_2_bis << T2_4; of2_2_bis.close(); + Triang T2_4(T2_2); + std::stringstream of2_2_bis; + of2_2_bis << T2_4; All_faces_iterator fit2 = T2_2.all_faces_begin(); All_faces_iterator fit2_bis = T2_4.all_faces_begin(); for( ; fit2 != T2_2.all_faces_end(); ++fit2, ++fit2_bis) { diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.h index 2d5656c93b2..762070693ee 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_regular_triangulation_2.h @@ -749,23 +749,23 @@ _test_cls_regular_triangulation_2( const Triangulation & ) // input output have not yet been overload // so they do not input output hidden vertices std::cout << " output to a file" << std::endl; - std::ofstream of1_5("T15.triangulation"); + std::ofstream of1_5("T15rt.triangulation"); CGAL::IO::set_ascii_mode(of1_5); of1_5 << T1_5; of1_5.close(); - std::ofstream of2_3("T23.triangulation"); + std::ofstream of2_3("T23rt.triangulation"); CGAL::IO::set_ascii_mode(of2_3); of2_3 << T2_3; of2_3.close(); // std::cout << " input from a file" << std::endl; -// std::ifstream if1_5("T15.triangulation"); CGAL::IO::set_ascii_mode(if1_5); +// std::ifstream if1_5("T15rt.triangulation"); CGAL::IO::set_ascii_mode(if1_5); // Cls T1_5_copy; if1_5 >> T1_5_copy; // assert( T1_5_copy.is_valid(verbose) && // T1_5_copy.number_of_vertices() == // T1_5.number_of_vertices() - T1_5.number_of_hidden_vertices()); -// std::ifstream if2_3("T23.triangulation"); CGAL::IO::set_ascii_mode(if2_3); +// std::ifstream if2_3("T23rt.triangulation"); CGAL::IO::set_ascii_mode(if2_3); // Cls T2_3_copy; if2_3 >> T2_3_copy; // assert( T2_3_copy.is_valid(verbose) && // T2_3_copy.number_of_vertices() == diff --git a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_short_2.h b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_short_2.h index 61fbb042389..08725583a25 100644 --- a/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_short_2.h +++ b/Triangulation_2/test/Triangulation_2/include/CGAL/_test_cls_triangulation_short_2.h @@ -24,7 +24,8 @@ #include #include - +#include +#include #include #include @@ -475,23 +476,31 @@ _test_cls_triangulation_short_2( const Triangul &) /********************/ /******** I/O *******/ + std::string T15fname, T23fname; + std::stringstream ss15; + ss15 << "T15" << &T1_5 << ".triangulation"; + ss15 >> T15fname; + std::stringstream ss23; + ss23 << "T23" << &T2_3 << ".triangulation"; + ss23 >> T23fname; + std::cout << " output to a file" << std::endl; - std::ofstream of1_5("T15.triangulation"); + std::ofstream of1_5(T15fname.c_str()); CGAL::IO::set_ascii_mode(of1_5); of1_5 << T1_5; of1_5.close(); - std::ofstream of2_3("T23.triangulation"); + std::ofstream of2_3(T23fname.c_str()); CGAL::IO::set_ascii_mode(of2_3); of2_3 << T2_3; of2_3.close(); std::cout << " input from a file" << std::endl; - std::ifstream if1_5("T15.triangulation"); CGAL::IO::set_ascii_mode(if1_5); + std::ifstream if1_5(T15fname.c_str()); CGAL::IO::set_ascii_mode(if1_5); Triangul T1_5_copy; if1_5 >> T1_5_copy; assert( T1_5_copy.is_valid() && T1_5_copy.number_of_vertices() == T1_5.number_of_vertices() ); - std::ifstream if2_3("T23.triangulation"); CGAL::IO::set_ascii_mode(if2_3); + std::ifstream if2_3(T23fname.c_str()); CGAL::IO::set_ascii_mode(if2_3); Triangul T2_3_copy; if2_3 >> T2_3_copy; assert( T2_3_copy.is_valid() && T2_3_copy.number_of_vertices() == T2_3.number_of_vertices() ); diff --git a/Triangulation_3/include/CGAL/IO/Triangulation_off_ostream_3.h b/Triangulation_3/include/CGAL/IO/Triangulation_off_ostream_3.h index d18ffbb7fea..55f1b953a5d 100644 --- a/Triangulation_3/include/CGAL/IO/Triangulation_off_ostream_3.h +++ b/Triangulation_3/include/CGAL/IO/Triangulation_off_ostream_3.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Clement Jamin @@ -13,6 +13,9 @@ #ifndef CGAL_TRIANGULATION_OFF_OSTREAM_3_H #define CGAL_TRIANGULATION_OFF_OSTREAM_3_H +#include + + #include #include #include diff --git a/Triangulation_3/include/CGAL/Triangulation_3_to_lcc.h b/Triangulation_3/include/CGAL/Triangulation_3_to_lcc.h index 14f718f0b13..19f495dbfbe 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3_to_lcc.h +++ b/Triangulation_3/include/CGAL/Triangulation_3_to_lcc.h @@ -5,7 +5,7 @@ // // $URL$ // $Id$ -// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial // // Author(s) : Guillaume Damiand // @@ -13,6 +13,9 @@ #ifndef CGAL_TRIANGULATION_3_TO_LCC_H #define CGAL_TRIANGULATION_3_TO_LCC_H +#include + + #include #include #include diff --git a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h index 01f08ac186c..646bc24d221 100644 --- a/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h +++ b/Triangulation_3/test/Triangulation_3/include/CGAL/_test_cls_delaunay_3.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include #include @@ -293,12 +293,9 @@ _test_cls_delaunay_3(const Triangulation &) { Cls Tfromfile; std::cout << " I/O" << std::endl; - { - std::ofstream oFileT1("Test1_triangulation_IO_3",std::ios::out); - oFileT1 << T0 << std::endl; - } - std::ifstream iFileT1("Test1_triangulation_IO_3",std::ios::in); - iFileT1 >> Tfromfile; + std::stringstream ss; + ss << T0; + ss >> Tfromfile; assert(Tfromfile.is_valid()); assert(Tfromfile.dimension() == -1); assert(Tfromfile.number_of_vertices() == 0); @@ -314,12 +311,9 @@ _test_cls_delaunay_3(const Triangulation &) { Cls Tfromfile; std::cout << " I/O" << std::endl; - { - std::ofstream oFileT2("Test2_triangulation_IO_3",std::ios::out); - oFileT2 << T0 << std::endl; - } - std::ifstream iFileT2("Test2_triangulation_IO_3",std::ios::in); - iFileT2 >> Tfromfile; + std::stringstream ss; + ss << T0; + ss >> Tfromfile; assert(Tfromfile.is_valid()); assert(Tfromfile.dimension() == 0); assert(Tfromfile.number_of_vertices() == 1); @@ -336,12 +330,9 @@ _test_cls_delaunay_3(const Triangulation &) { Cls Tfromfile; std::cout << " I/O" << std::endl; - { - std::ofstream oFileT3("Test3_triangulation_IO_3",std::ios::out); - oFileT3 << T0 << std::endl; - } - std::ifstream iFileT3("Test3_triangulation_IO_3",std::ios::in); - iFileT3 >> Tfromfile; + std::stringstream ss; + ss << T0; + ss >> Tfromfile; assert(Tfromfile.is_valid()); assert(Tfromfile.dimension() == 1); assert(Tfromfile.number_of_vertices() == 2); @@ -358,12 +349,9 @@ _test_cls_delaunay_3(const Triangulation &) { Cls Tfromfile; std::cout << " I/O" << std::endl; - { - std::ofstream oFileT4("Test4_triangulation_IO_3",std::ios::out); - oFileT4 << T0; - } - std::ifstream iFileT4("Test4_triangulation_IO_3",std::ios::in); - iFileT4 >> Tfromfile; + std::stringstream ss; + ss << T0; + ss >> Tfromfile; assert(Tfromfile.is_valid()); assert(Tfromfile.dimension() == 2); assert(Tfromfile.number_of_vertices() == 3); @@ -380,12 +368,9 @@ _test_cls_delaunay_3(const Triangulation &) { Cls Tfromfile; std::cout << " I/O" << std::endl; - { - std::ofstream oFileT5("Test5_triangulation_IO_3",std::ios::out); - oFileT5 << T0; - } - std::ifstream iFileT5("Test5_triangulation_IO_3",std::ios::in); - iFileT5 >> Tfromfile; + std::stringstream ss; + ss << T0; + ss >> Tfromfile; assert(Tfromfile.is_valid()); assert(Tfromfile.dimension() == 3); assert(Tfromfile.number_of_vertices() == 4); @@ -463,12 +448,9 @@ _test_cls_delaunay_3(const Triangulation &) { Cls Tfromfile; std::cout << " I/O" << std::endl; - { - std::ofstream oFileT6("Test6_triangulation_IO_3",std::ios::out); - oFileT6 << T1_2; - } - std::ifstream iFileT6("Test6_triangulation_IO_3",std::ios::in); - iFileT6 >> Tfromfile; + std::stringstream ss; + ss << T1_2; + ss >> Tfromfile; assert(Tfromfile.is_valid()); assert(Tfromfile.dimension() == 1); assert(Tfromfile.number_of_vertices() == n); @@ -510,12 +492,10 @@ _test_cls_delaunay_3(const Triangulation &) { Cls Tfromfile; std::cout << " I/O" << std::endl; - { - std::ofstream oFileT7("Test7_triangulation_IO_3",std::ios::out); - oFileT7 << T2_0; - } - std::ifstream iFileT7("Test7_triangulation_IO_3",std::ios::in); - iFileT7 >> Tfromfile; + + std::stringstream ss; + ss << T2_0; + ss >> Tfromfile; assert(Tfromfile.is_valid()); assert(Tfromfile.dimension() == 2); assert(Tfromfile.number_of_vertices() == 8); @@ -586,12 +566,9 @@ _test_cls_delaunay_3(const Triangulation &) { Cls Tfromfile; std::cout << " I/O" << std::endl; - { - std::ofstream oFileT8("Test8_triangulation_IO_3",std::ios::out); - oFileT8 << T3_1; - } - std::ifstream iFileT8("Test8_triangulation_IO_3",std::ios::in); - iFileT8 >> Tfromfile; + std::stringstream ss; + ss << T3_1; + ss >> Tfromfile; assert(Tfromfile.is_valid()); assert(Tfromfile.dimension() == 3); assert(Tfromfile.number_of_vertices() == 22); @@ -677,12 +654,9 @@ _test_cls_delaunay_3(const Triangulation &) { Cls Tfromfile; std::cout << " I/O" << std::endl; - { - std::ofstream oFileT8("Test13_triangulation_IO_3",std::ios::out); - oFileT8 << T3_13; - } - std::ifstream iFileT8("Test13_triangulation_IO_3",std::ios::in); - iFileT8 >> Tfromfile; + std::stringstream ss; + ss << T3_13; + ss >> Tfromfile; assert(Tfromfile.is_valid()); assert(Tfromfile.dimension() == 3); assert(Tfromfile.number_of_vertices() == 22); diff --git a/Triangulation_on_sphere_2/examples/Triangulation_on_sphere_2/CMakeLists.txt b/Triangulation_on_sphere_2/examples/Triangulation_on_sphere_2/CMakeLists.txt index 3d3d7367f53..65ed31daad1 100644 --- a/Triangulation_on_sphere_2/examples/Triangulation_on_sphere_2/CMakeLists.txt +++ b/Triangulation_on_sphere_2/examples/Triangulation_on_sphere_2/CMakeLists.txt @@ -3,9 +3,15 @@ cmake_minimum_required(VERSION 3.1...3.23) project( Triangulation_on_sphere_2_Examples ) find_package(CGAL REQUIRED COMPONENTS Core) +find_package(LEDA QUIET) create_single_source_cgal_program( "triang_on_sphere.cpp" ) create_single_source_cgal_program( "triang_on_sphere_range.cpp" ) -create_single_source_cgal_program( "triang_on_sphere_exact.cpp" ) create_single_source_cgal_program( "triang_on_sphere_proj.cpp" ) create_single_source_cgal_program( "triang_on_sphere_geo.cpp" ) + +if (CGAL_Core_FOUND OR LEDA_FOUND) + create_single_source_cgal_program( "triang_on_sphere_exact.cpp" ) +else() + message("NOTICE: Some tests require CGAL_Core (or LEDA), and will not be compiled.") +endif() diff --git a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/CMakeLists.txt b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/CMakeLists.txt index 6e26394bee1..0353327dfbe 100644 --- a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/CMakeLists.txt +++ b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/CMakeLists.txt @@ -3,14 +3,20 @@ cmake_minimum_required(VERSION 3.1...3.23) project( Triangulation_on_sphere_2_Tests ) find_package(CGAL REQUIRED COMPONENTS Core) +find_package(LEDA QUIET) create_single_source_cgal_program( "test_dtos.cpp" ) create_single_source_cgal_program( "test_dtos2_remove.cpp" ) -create_single_source_cgal_program( "test_dtos_degenerate_cases.cpp" ) create_single_source_cgal_program( "test_dtos_illegal_points.cpp" ) create_single_source_cgal_program( "test_dtos_projection_traits.cpp" ) create_single_source_cgal_program( "test_dtos_traits.cpp" ) +if (CGAL_Core_FOUND OR LEDA_FOUND) + create_single_source_cgal_program( "test_dtos_degenerate_cases.cpp" ) +else() + message("NOTICE: Some tests require CGAL_Core (or LEDA), and will not be compiled.") +endif() + find_package(Eigen3 3.1.0 QUIET) #(requires 3.1.0 or greater) include(CGAL_Eigen3_support) if(TARGET CGAL::Eigen3_support) diff --git a/Visibility_2/include/CGAL/Triangular_expansion_visibility_2.h b/Visibility_2/include/CGAL/Triangular_expansion_visibility_2.h index 408bf95c847..b1b552a0290 100644 --- a/Visibility_2/include/CGAL/Triangular_expansion_visibility_2.h +++ b/Visibility_2/include/CGAL/Triangular_expansion_visibility_2.h @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -86,63 +85,83 @@ private: }; // Observer to track any changes of the attached arrangement. - class Observer : public Arr_observer + class Observer : public Arrangement_2::Observer { - - typedef Arr_observer Base; - typedef Observer Self; - + using Base = typename Arrangement_2::Observer; + using Self = Observer; public: + using Base_aos = typename Arrangement_2::Base_aos; + using Vertex_handle = typename Base_aos::Vertex_handle; + using Halfedge_handle = typename Base_aos::Halfedge_handle; + using Face_handle = typename Base_aos::Face_handle; + using Ccb_halfedge_circulator = typename Base_aos::Ccb_halfedge_circulator; + bool has_changed; - Observer() : Base(), has_changed(false) + Observer() : Base(), has_changed(false) {} + + Observer(const Base_aos& arr) : + Base(const_cast(arr)), has_changed(false) {} - Observer(const Arrangement_2& arr) - : Base(const_cast(arr)), has_changed(false) - {} + // Aos_observer interface - // Arr_observer interface + virtual void after_attach() override { has_changed = false; } - void after_attach() { has_changed = false; } - - - void after_global_change() { has_changed = true; } - void after_create_vertex(Vertex_handle) { has_changed = true; } - void after_create_boundary_vertex(Vertex_handle) { has_changed = true; } - void after_create_edge(Halfedge_handle) { has_changed = true; } - void after_modify_vertex(Vertex_handle) { has_changed = true; } - void after_modify_edge(Halfedge_handle) { has_changed = true; } - void after_split_edge(Halfedge_handle, Halfedge_handle) { - has_changed = true; } - void after_split_fictitious_edge(Halfedge_handle, Halfedge_handle) { - has_changed = true; } - void after_split_face(Face_handle, Face_handle, bool) { - has_changed = true; } - void after_split_outer_ccb(Face_handle, Ccb_halfedge_circulator, - Ccb_halfedge_circulator) { - has_changed = true; } - void after_split_inner_ccb(Face_handle, Ccb_halfedge_circulator, - Ccb_halfedge_circulator) { - has_changed = true; } - void after_add_outer_ccb(Ccb_halfedge_circulator) { has_changed = true; } - void after_add_inner_ccb(Ccb_halfedge_circulator) { has_changed = true; } - void after_add_isolated_vertex(Vertex_handle) { has_changed = true; } - void after_merge_edge(Halfedge_handle) { has_changed = true; } - void after_merge_fictitious_edge(Halfedge_handle) { has_changed = true; } - void after_merge_face(Face_handle) { has_changed = true; } - void after_merge_outer_ccb(Face_handle, Ccb_halfedge_circulator) { - has_changed = true; } - void after_merge_inner_ccb(Face_handle, Ccb_halfedge_circulator) { - has_changed = true; } - void after_move_outer_ccb(Ccb_halfedge_circulator) { has_changed = true; } - void after_move_inner_ccb(Ccb_halfedge_circulator) { has_changed = true; } - void after_move_isolated_vertex(Vertex_handle) { has_changed = true; } - void after_remove_vertex() { has_changed = true; } - void after_remove_edge() { has_changed = true; } - void after_remove_outer_ccb(Face_handle) { has_changed = true; } - void after_remove_inner_ccb(Face_handle) { has_changed = true; } + virtual void after_global_change() override { has_changed = true; } + virtual void after_create_vertex(Vertex_handle) override + { has_changed = true; } + virtual void after_create_boundary_vertex(Vertex_handle) override + { has_changed = true; } + virtual void after_create_edge(Halfedge_handle) override + { has_changed = true; } + virtual void after_modify_vertex(Vertex_handle) override + { has_changed = true; } + virtual void after_modify_edge(Halfedge_handle) override + { has_changed = true; } + virtual void after_split_edge(Halfedge_handle, Halfedge_handle) override + { has_changed = true; } + virtual void after_split_fictitious_edge(Halfedge_handle, Halfedge_handle) + override + { has_changed = true; } + virtual void after_split_face(Face_handle, Face_handle, bool) override + { has_changed = true; } + virtual void after_split_outer_ccb(Face_handle, Ccb_halfedge_circulator, + Ccb_halfedge_circulator) override + { has_changed = true; } + virtual void after_split_inner_ccb(Face_handle, Ccb_halfedge_circulator, + Ccb_halfedge_circulator) override + { has_changed = true; } + virtual void after_add_outer_ccb(Ccb_halfedge_circulator) override + { has_changed = true; } + virtual void after_add_inner_ccb(Ccb_halfedge_circulator) override + { has_changed = true; } + virtual void after_add_isolated_vertex(Vertex_handle) override + { has_changed = true; } + virtual void after_merge_edge(Halfedge_handle) override + { has_changed = true; } + virtual void after_merge_fictitious_edge(Halfedge_handle) override + { has_changed = true; } + virtual void after_merge_face(Face_handle) override { has_changed = true; } + virtual void after_merge_outer_ccb(Face_handle, Ccb_halfedge_circulator) + override + { has_changed = true; } + virtual void after_merge_inner_ccb(Face_handle, Ccb_halfedge_circulator) + override + { has_changed = true; } + virtual void after_move_outer_ccb(Ccb_halfedge_circulator) override + { has_changed = true; } + virtual void after_move_inner_ccb(Ccb_halfedge_circulator) override + { has_changed = true; } + virtual void after_move_isolated_vertex(Vertex_handle) override + { has_changed = true; } + virtual void after_remove_vertex() override { has_changed = true; } + virtual void after_remove_edge() override { has_changed = true; } + virtual void after_remove_outer_ccb(Face_handle) override + { has_changed = true; } + virtual void after_remove_inner_ccb(Face_handle) override + { has_changed = true; } }; diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in index d00a5166581..62bd37f80fd 100644 --- a/cmake_uninstall.cmake.in +++ b/cmake_uninstall.cmake.in @@ -12,10 +12,11 @@ string(REGEX REPLACE "\n" ";" files "${files}") foreach(file ${files}) message(STATUS "Uninstalling $ENV{DESTDIR}${file}") if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - exec_program( - "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" + execute_process( + COMMAND "@CMAKE_COMMAND@" -E remove "$ENV{DESTDIR}${file}" + OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval + RESULT_VARIABLE rm_retval ) if(NOT "${rm_retval}" STREQUAL 0) message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")