mirror of https://github.com/CGAL/cgal
overlay with different geometry traits
This commit is contained in:
parent
8db83a466a
commit
0081acb19a
|
|
@ -16,11 +16,15 @@ see, e.g.,~\cite{cgal:behhms-cbcab-02}).
|
|||
The function \ccc{overlay (arr_a, arr_b, ovl_arr, ovl_traits)} accepts
|
||||
two input arrangement instances \ccc{arr_a} and \ccc{arr_b}, and constructs
|
||||
their overlay instance \ccc{ovl_arr}. All three arrangements must use the
|
||||
same geometric primitives. In other words, their types must be defined
|
||||
using the same geometric traits-class. Let us assume that \ccc{arr_a} is of
|
||||
type \ccc{Arrangement_2<Traits,Dcel_A>}, \ccc{arr_b} is of type
|
||||
\ccc{Arrangement_2<Traits,Dcel_B>} and the resulting \ccc{ovl_arr} is of type
|
||||
\ccc{Arrangement_2<Traits,Dcel_R>}. The \ccc{ovl_traits} parameter is
|
||||
same geometric primitives. More precisely, let \ccc{arr_a} be of
|
||||
type \ccc{Arrangement_2<Traits_A,Dcel_A>}, \ccc{arr_b} be of type
|
||||
\ccc{Arrangement_2<Traits_B,Dcel_B>} and the resulting \ccc{ovl_arr} be of type
|
||||
\ccc{Arrangement_2<Traits_R,Dcel_R>}. All types nested in geometry
|
||||
traits \ccc{Traits_A}, e.g., \ccc{Point_2} and
|
||||
\ccc{X_monotone_curve_2}, must be convertible to the corresponding
|
||||
types nested in geometry traits \ccc{Traits_R}. The same holds for all
|
||||
types nested in geometry traits \ccc{Traits_B}.
|
||||
The \ccc{ovl_traits} parameter is
|
||||
an instance of an {\em overlay traits-class}, which enables the creation of
|
||||
\ccc{Dcel_R} records in the overlaid arrangement from the \dcel\ features
|
||||
of \ccc{arr_a} and \ccc{arr_b} that they correspond to.
|
||||
|
|
|
|||
|
|
@ -5,22 +5,29 @@
|
|||
\ccDefinition
|
||||
|
||||
The function \ccRefName\ computes the overlay of two input arrangement
|
||||
objects, and returns the overlaid arrangement. All three arrangements
|
||||
are instantiated using the same geometric traits class, but may be
|
||||
represented using different \dcel{} classes. A given overlay-traits object
|
||||
is used to properly construct the overlaid \dcel{} that represents the
|
||||
resulting arrangement.
|
||||
objects, and returns the overlaid arrangement.
|
||||
All three arrangements can be instantiated with different geometric
|
||||
traits classes and different \dcel{} (encapsulated in the various
|
||||
topology-traits classes) classes.
|
||||
The geometry traits of the result arrangement is
|
||||
used to construct the result arrangement. This means that all
|
||||
the types (e.g., \ccc{Traits::Point_2}, \ccc{Traits::Curve_2} and
|
||||
\ccc{Traits::Point_2}) of both input arrangements have to convertible
|
||||
to the types in the result arrangement.
|
||||
A given overlay-traits object is used to properly construct the
|
||||
overlaid \dcel{} that represents the resulting arrangement.
|
||||
|
||||
%%%%
|
||||
|
||||
\ccInclude{CGAL/Arr_overlay.h}
|
||||
\ccInclude{CGAL/Arr_overlay_2.h}
|
||||
|
||||
\ccGlobalFunction{template<typename Traits, typename Dcel1, typename Dcel2,
|
||||
typename ResDcel, typename OverlayTraits>
|
||||
void overlay (const Arrangement_2<Traits,Dcel1>& arr1,
|
||||
const Arrangement_2<Traits,Dcel2>& arr2,
|
||||
Arrangement_2<Traits,ResDcel>& res,
|
||||
OverlayTraits& ovl_tr);}
|
||||
\ccGlobalFunction{template <class GeomTraitsA, class GeomTraitsB,
|
||||
class GeomTraitsRes, class TopTraitsA, class TopTraitsB, class
|
||||
TopTraitsRes, class OverlayTraits>
|
||||
void overlay (const Arrangement_on_surface_2<GeomTraitsA, TopTraitsA>& arr1,
|
||||
const Arrangement_on_surface_2<GeomTraitsB, TopTraitsB>& arr2,
|
||||
Arrangement_on_surface_2<GeomTraitsRes, TopTraitsRes>& arr_res,
|
||||
OverlayTraits& ovl_tr);}
|
||||
Computes the overlay of two arrangements \ccc{arr1} and \ccc{arr2}, and sets
|
||||
the output arrangement \ccc{res} to represent the overlaid arrangement.
|
||||
\ccPrecond{\ccc{res} does not refer to either \ccc{arr1} or \ccc{arr2}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,10 @@
|
|||
|
||||
#include <vector>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/mpl/or.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
|
|
@ -40,26 +43,47 @@ CGAL_BEGIN_NAMESPACE
|
|||
* \param arr1 The first arrangement.
|
||||
* \param arr2 The second arrangement.
|
||||
* \param arr_res Output: The resulting arrangement.
|
||||
* \param ovl_tr An overlay-traits class. As arr1, arr2 and res are all
|
||||
* templated with the same arrangement-traits class but with
|
||||
* \param ovl_tr An overlay-traits class. As arr1, arr2 and res can be
|
||||
* templated with different geometry-traits class and
|
||||
* different DCELs (encapsulated in the various topology-traits
|
||||
* classes), the overlay-traits class defines the various
|
||||
* classes). The geometry-traits of the result arrangement is
|
||||
* used to construct the result arrangement. This means that all
|
||||
* the types (e.g., Point_2, Curve_2 and X_monotone_2) of both
|
||||
* arr1 and arr2 have to be convertible to the types
|
||||
* in the result geometry-traits.
|
||||
* The overlay-traits class defines the various
|
||||
* overlay operations of pairs of DCEL features from
|
||||
* TopTraitsA and TopTraitsB to the resulting ResDcel.
|
||||
*/
|
||||
template <class GeomTraits,
|
||||
template <class GeomTraitsA,
|
||||
class GeomTraitsB,
|
||||
class GeomTraitsRes,
|
||||
class TopTraitsA,
|
||||
class TopTraitsB,
|
||||
class TopTraitsRes,
|
||||
class OverlayTraits>
|
||||
void overlay (const Arrangement_on_surface_2<GeomTraits, TopTraitsA>& arr1,
|
||||
const Arrangement_on_surface_2<GeomTraits, TopTraitsB>& arr2,
|
||||
Arrangement_on_surface_2<GeomTraits, TopTraitsRes>& arr_res,
|
||||
void overlay (const Arrangement_on_surface_2<GeomTraitsA, TopTraitsA>& arr1,
|
||||
const Arrangement_on_surface_2<GeomTraitsB, TopTraitsB>& arr2,
|
||||
Arrangement_on_surface_2<GeomTraitsRes, TopTraitsRes>& arr_res,
|
||||
OverlayTraits& ovl_tr)
|
||||
{
|
||||
typedef Arrangement_on_surface_2<GeomTraits, TopTraitsA> ArrA;
|
||||
typedef Arrangement_on_surface_2<GeomTraits, TopTraitsB> ArrB;
|
||||
typedef Arrangement_on_surface_2<GeomTraits, TopTraitsRes> ArrRes;
|
||||
typedef Arrangement_on_surface_2<GeomTraitsA, TopTraitsA> ArrA;
|
||||
typedef Arrangement_on_surface_2<GeomTraitsB, TopTraitsB> ArrB;
|
||||
typedef Arrangement_on_surface_2<GeomTraitsRes, TopTraitsRes> ArrRes;
|
||||
|
||||
// some type assertions (not all, but better then nothing).
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible< \
|
||||
typename GeomTraitsA::Point_2, \
|
||||
typename GeomTraitsRes::Point_2 >::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible< \
|
||||
typename GeomTraitsB::Point_2, \
|
||||
typename GeomTraitsRes::Point_2 >::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible< \
|
||||
typename GeomTraitsA::X_monotone_curve_2, \
|
||||
typename GeomTraitsRes::X_monotone_curve_2 >::value));
|
||||
BOOST_STATIC_ASSERT((boost::is_convertible< \
|
||||
typename GeomTraitsB::X_monotone_curve_2, \
|
||||
typename GeomTraitsRes::X_monotone_curve_2 >::value));
|
||||
|
||||
typedef typename TopTraitsRes::template
|
||||
Sweep_line_overlay_visitor<ArrA, ArrB, OverlayTraits>
|
||||
|
|
@ -107,7 +131,7 @@ void overlay (const Arrangement_on_surface_2<GeomTraits, TopTraitsA>& arr1,
|
|||
}
|
||||
|
||||
// Obtain a extended traits-class object and define the sweep-line visitor.
|
||||
GeomTraits *geom_traits = arr_res.geometry_traits();
|
||||
GeomTraitsRes *geom_traits = arr_res.geometry_traits();
|
||||
|
||||
/* We would like to avoid copy construction of the geometry traits class.
|
||||
* Copy construction is undesired, because it may results with data
|
||||
|
|
@ -121,7 +145,7 @@ void overlay (const Arrangement_on_surface_2<GeomTraits, TopTraitsA>& arr1,
|
|||
* Use the form 'A a(*b);' and not ''A a = b;' to handle the case where A has
|
||||
* only an implicit constructor, (which takes *b as a parameter).
|
||||
*/
|
||||
typename boost::mpl::if_<boost::is_same<GeomTraits, Ovl_traits_2>,
|
||||
typename boost::mpl::if_<boost::is_same<GeomTraitsRes, Ovl_traits_2>,
|
||||
Ovl_traits_2&, Ovl_traits_2>::type
|
||||
ex_traits(*geom_traits);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue