Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Fix for CGAL 4.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Mercier committed Sep 8, 2017
1 parent aa5c4d7 commit 4ff7cea
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -134,7 +134,7 @@ include_directories( ${CMAKE_BINARY_DIR}/include )
# They will overwrite files from the CGAL installation
if( "${CGAL_VERSION}" VERSION_LESS "4.3" )
include_directories( patches/CGAL-4.2 )
else()
elseif( "${CGAL_VERSION}" VERSION_LESS "4.10")
include_directories( patches/CGAL-4.3 )
add_definitions( "-DCGAL_INTERSECTION_VERSION=1" )
endif()
Expand Down
32 changes: 28 additions & 4 deletions src/algorithm/Intersection3D.cpp
Expand Up @@ -31,6 +31,7 @@
#include <SFCGAL/detail/triangulate/triangulateInGeometrySet.h>

#include <CGAL/IO/Polyhedron_iostream.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>

#include <SFCGAL/detail/Point_inside_polyhedron.h>

Expand Down Expand Up @@ -108,10 +109,13 @@ void _intersection_solid_segment( const PrimitiveHandle<3>& pa, const PrimitiveH
}


#if CGAL_VERSION_NR < 1040301000 // version 4.3
#if CGAL_VERSION_NR < 1040301000 // 4.3

// Before 4.3, we pass CGAL::Tag_true to mark boundary halfedges
typedef CGAL::Node_visitor_refine_polyhedra<MarkedPolyhedron, Kernel, CGAL::Tag_true> Split_visitor;
#else

#elif CGAL_VERSION_NR < 1041001000 // < 4.10

// Starting with 4.3, we must now pass a property_map
template<class Polyhedron>
struct Edge_mark_property_map {
Expand All @@ -128,6 +132,25 @@ struct Edge_mark_property_map {
}
};
typedef CGAL::Node_visitor_refine_polyhedra<MarkedPolyhedron,Kernel,Edge_mark_property_map<MarkedPolyhedron> > Split_visitor;

#else

template<class Polyhedron>
struct Edge_mark_property_map {
typedef bool value_type;
typedef value_type reference;
typedef std::pair<typename Polyhedron::Halfedge_handle,Polyhedron*> key_type;
typedef boost::read_write_property_map_tag category;

friend reference get( Edge_mark_property_map,const key_type& key ) {
return key.first->mark;
}
friend void put( Edge_mark_property_map,key_type key,value_type v ) {
key.first->mark=v;
}
};
typedef CGAL::Node_visitor_refine_polyhedra<MarkedPolyhedron, CGAL::Default, CGAL::Default,Edge_mark_property_map<MarkedPolyhedron> > Split_visitor;

#endif

typedef std::vector<Kernel::Point_3> Polyline_3;
Expand All @@ -138,10 +161,11 @@ struct Is_not_marked {
}
};


void _intersection_solid_triangle( const MarkedPolyhedron& pa, const CGAL::Triangle_3<Kernel>& tri, GeometrySet<3>& output )
{
BOOST_ASSERT( pa.is_closed() );
Split_visitor visitor( NULL, true );
Split_visitor visitor;

MarkedPolyhedron polyb;
polyb.make_triangle( tri.vertex( 0 ), tri.vertex( 1 ), tri.vertex( 2 ) );
Expand Down Expand Up @@ -258,7 +282,7 @@ void _intersection_solid_triangle( const MarkedPolyhedron& pa, const CGAL::Trian
output.addPrimitive( seg );
}
}
}
}
}

void _intersection_solid_solid( const MarkedPolyhedron& pa, const MarkedPolyhedron& pb, GeometrySet<3>& output )
Expand Down
8 changes: 6 additions & 2 deletions src/algorithm/distance3d.cpp
Expand Up @@ -682,6 +682,9 @@ squared_distance_t squaredDistancePointTriangle3D(
const Triangle_3& abc
)
{
#if CGAL_VERSION_NR >= 1041001000 // >= 4.10
return CGAL::squared_distance(p, abc);
#else
Point_3 a = abc.vertex( 0 );
Point_3 b = abc.vertex( 1 );
Point_3 c = abc.vertex( 2 );
Expand All @@ -706,6 +709,7 @@ squared_distance_t squaredDistancePointTriangle3D(
}

return dMin ;
#endif
}

///
Expand Down Expand Up @@ -759,7 +763,7 @@ squared_distance_t squaredDistanceSegmentTriangle3D(
/*
* If [sAsB] intersects the triangle (tA,tB,tC), distance is 0.0
*/
if ( ! CGAL::intersection( sAB, tABC ).empty() ) {
if ( boost::none != CGAL::intersection( sAB, tABC ) ) {
return 0.0 ;
}

Expand Down Expand Up @@ -817,7 +821,7 @@ squared_distance_t squaredDistanceTriangleTriangle3D(
const Triangle_3& triangleB
)
{
if ( ! CGAL::intersection( triangleA, triangleB ).empty() ) {
if ( boost::none != CGAL::intersection( triangleA, triangleB ) ) {
return squared_distance_t( 0 );
}

Expand Down

0 comments on commit 4ff7cea

Please sign in to comment.