Skip to content

Commit

Permalink
add clipped dual function
Browse files Browse the repository at this point in the history
  • Loading branch information
sloriot committed Mar 13, 2023
1 parent 852770b commit dad11f0
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
4 changes: 2 additions & 2 deletions SWIG_CGAL/Triangulation_2/CGAL_Triangulation_2.i
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
// Copyright (c) 2011 GeometryFactory (FRANCE)
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------

%define T2_DOCSTRING
"SWIG wrapper for the CGAL 2D Triangulation package provided under the GPL-3.0+ license"
Expand Down Expand Up @@ -41,7 +41,7 @@ SWIG_CGAL_package_common()
%include "SWIG_CGAL/Triangulation_2/Constrained_triangulation_plus_2.h"
%include "SWIG_CGAL/Triangulation_2/triangulation_handles.h"

%pragma(java) jniclassimports=%{import CGAL.Kernel.Point_2; import CGAL.Kernel.Polygon_2; import CGAL.Kernel.Ref_int; import CGAL.Kernel.Weighted_point_2; import CGAL.Kernel.Segment_2; import CGAL.Kernel.Triangle_2; import java.util.Iterator; import java.util.Collection; import CGAL.Java.JavaData;%}
%pragma(java) jniclassimports=%{import CGAL.Kernel.Point_2; import CGAL.Kernel.Polygon_2; import CGAL.Kernel.Ref_int; import CGAL.Kernel.Weighted_point_2; import CGAL.Kernel.Segment_2; import CGAL.Kernel.Triangle_2; import CGAL.Kernel.Iso_rectangle_2; import java.util.Iterator; import java.util.Collection; import CGAL.Java.JavaData;%}

//References
%include "SWIG_CGAL/Triangulation_2/Reference_wrappers.i"
Expand Down
29 changes: 28 additions & 1 deletion SWIG_CGAL/Triangulation_2/Delaunay_triangulation_2.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#define SWIG_CGAL_TRIANGULATION_2_DELAUNAY_TRIANGULATION_2_H

#include <SWIG_CGAL/Triangulation_2/Triangulation_2.h>

#include <SWIG_CGAL/Kernel/Iso_rectangle_2.h>

#include <CGAL/Delaunay_triangulation_2.h>
#include <SWIG_CGAL/Common/Output_iterator_wrapper.h>
Expand Down Expand Up @@ -54,6 +54,33 @@ class Delaunay_triangulation_2_wrapper: public Triangulation_2_wrapper<Triangula
// Voronoi diagram
SWIG_CGAL_FORWARD_CALL_AND_REF_1(Point_2,dual,Face_handle)
SWIG_CGAL_FORWARD_CALL_AND_REF_1(Object,dual,Edge)
Segment_2 dual(const Edge& e, const Iso_rectangle_2& ir)
{
CGAL::Object d = this->get_data().dual(std::make_pair(e.first.get_data(), e.second));

if (const EPIC_Kernel::Segment_2* ss = CGAL::object_cast<EPIC_Kernel::Segment_2>(&d))
{
auto res = CGAL::intersection(*ss,ir.get_data());
if (!res) return EPIC_Kernel::Segment_2(EPIC_Kernel::Point_2(0,0), EPIC_Kernel::Point_2(0,0));
if (const EPIC_Kernel::Segment_2* s = boost::get<EPIC_Kernel::Segment_2>(&(*res)))
return *s;
}
if (const EPIC_Kernel::Line_2* l = CGAL::object_cast<EPIC_Kernel::Line_2>(&d))
{
auto res = CGAL::intersection(*l,ir.get_data());
if (!res) return EPIC_Kernel::Segment_2(EPIC_Kernel::Point_2(0,0), EPIC_Kernel::Point_2(0,0));
if (const EPIC_Kernel::Segment_2* s = boost::get<EPIC_Kernel::Segment_2>(&(*res)))
return *s;
}
const EPIC_Kernel::Ray_2* r = CGAL::object_cast<EPIC_Kernel::Ray_2>(&d);
CGAL_assertion(r);
auto res = CGAL::intersection(*r,ir.get_data());
if (res)
if (const EPIC_Kernel::Segment_2* s = boost::get<EPIC_Kernel::Segment_2>(&(*res)))
return *s;
return EPIC_Kernel::Segment_2(EPIC_Kernel::Point_2(0,0), EPIC_Kernel::Point_2(0,0));
}

//Deep copy
#ifndef CGAL_DO_NOT_DEFINE_FOR_ALPHA_SHAPE_2
typedef Delaunay_triangulation_2_wrapper<Triangulation,Vertex_handle,Face_handle> Self;
Expand Down
14 changes: 7 additions & 7 deletions SWIG_CGAL/Triangulation_2/Triangulation_2.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ------------------------------------------------------------------------------
// Copyright (c) 2011 GeometryFactory (FRANCE)
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial
// ------------------------------------------------------------------------------
// ------------------------------------------------------------------------------


#ifndef SWIG_CGAL_TRIANGULATION_2_TRIANGULATION_2_H
Expand Down Expand Up @@ -51,7 +51,7 @@ class Triangulation_2_wrapper
BOOST_STATIC_ASSERT( (boost::is_same<Weighted_tag,typename Triangulation::Weighted_tag>::value) );
#endif


protected :
boost::shared_ptr<Triangulation> data_sptr;
public:
Expand Down Expand Up @@ -84,12 +84,12 @@ protected :
boost::shared_ptr<cpp_base> shared_ptr() {return data_sptr;}
#endif

// Creation
// Creation
SWIG_CGAL_FORWARD_CALL_0(void, clear)
SWIG_CGAL_FORWARD_CALL_0(int, dimension)
SWIG_CGAL_FORWARD_CALL_0(int, number_of_vertices)
SWIG_CGAL_FORWARD_CALL_0(int, number_of_faces)
// Access Functions
// Access Functions
SWIG_CGAL_FORWARD_CALL_AND_REF_0(Face_handle,infinite_face)
SWIG_CGAL_FORWARD_CALL_AND_REF_0(Vertex_handle,infinite_vertex)
SWIG_CGAL_FORWARD_CALL_AND_REF_0(Vertex_handle,finite_vertex)
Expand Down Expand Up @@ -136,15 +136,15 @@ protected :
SWIG_CGAL_FORWARD_CALL_1(Face_handle,locate,Point)
SWIG_CGAL_FORWARD_CALL_AND_REF_2(Face_handle,locate,Point,Face_handle)
SWIG_CGAL_FORWARD_CALL_2(Oriented_side,oriented_side,Face_handle,Point)
SWIG_CGAL_FORWARD_CALL_2(Oriented_side,side_of_oriented_circle,Face_handle,Point)
SWIG_CGAL_FORWARD_CALL_2(Oriented_side,side_of_oriented_circle,Face_handle,Point)
Face_handle locate(const Point& query, Reference_wrapper<SWIG_Triangulation_2::Locate_type>& lt, Reference_wrapper<int>& li,Face_handle hint=Face_handle()) const {
typename cpp_base::Locate_type cgal_lt;
typename Face_handle::cpp_base res = get_data().locate(query.get_data(),cgal_lt,li.object(),hint.get_data());
lt.set(CGAL::enum_cast<SWIG_Triangulation_2::Locate_type>(cgal_lt));
return Face_handle(res);
}
// Modifiers
// SWIG_CGAL_FORWARD_CALL_2(void,flip,Face_handle,int) TODO: ambiguous call in CDT (their exist an overload with Face_handle&)
// SWIG_CGAL_FORWARD_CALL_2(void,flip,Face_handle,int) TODO: ambiguous call in CDT (their exist an overload with Face_handle&)
#ifndef CGAL_DO_NOT_DEFINE_FOR_ALPHA_SHAPE_2
SWIG_CGAL_FORWARD_CALL_AND_REF_1(Vertex_handle,insert,Point)
SWIG_CGAL_FORWARD_CALL_AND_REF_2(Vertex_handle,insert,Point,Face_handle)
Expand All @@ -163,7 +163,7 @@ protected :
int insert(Point_range range){
return get_data().insert(SWIG_CGAL::get_begin(range),SWIG_CGAL::get_end(range));
}
#endif
#endif
// Traversal of the Triangulation
Finite_vertices_iterator finite_vertices(){return Finite_vertices_iterator(get_data().finite_vertices_begin(),get_data().finite_vertices_end());}
Finite_edges_iterator finite_edges(){return Finite_edges_iterator(get_data().finite_edges_begin(),get_data().finite_edges_end());}
Expand Down

0 comments on commit dad11f0

Please sign in to comment.