Skip to content

Commit

Permalink
Issue Oslandia#96: Temporarily reverted changed from PR Oslandia#92.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcu888 committed Jun 15, 2020
1 parent 1681da5 commit 278a061
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions src/algorithm/straightSkeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ typedef CGAL::Straight_skeleton_2<Kernel> Straight_skeleton_2 ;
namespace { // anonymous

template<class K, bool outputDistanceInM>
void straightSkeletonToMultiLineString(
const CGAL::Straight_skeleton_2<K>& ss,
MultiLineString& result,
bool innerOnly,
Kernel::Vector_2& translate
void straightSkeletonToMultiLineString( const CGAL::Straight_skeleton_2<K>& ss
, MultiLineString& result
, bool innerOnly
#if 0
, Kernel::Vector_2& translate
#endif
)
{
typedef CGAL::Straight_skeleton_2<K> Ss ;
Expand Down Expand Up @@ -91,7 +92,9 @@ void straightSkeletonToMultiLineString(
else {
ls = new LineString( it->opposite()->vertex()->point(), it->vertex()->point() );
}
#if 0
algorithm::translate( *ls, translate );
#endif
result.addGeometry( ls );
}
}
Expand Down Expand Up @@ -301,8 +304,12 @@ std::unique_ptr< MultiLineString > straightSkeleton( const Polygon& g, bool /*au
return result ;
}

#if 0
Kernel::Vector_2 trans;
Polygon_with_holes_2 polygon = preparePolygon( g, trans );
#else
Polygon_with_holes_2 polygon = g.toPolygon_with_holes_2();
#endif
boost::shared_ptr< Straight_skeleton_2 > skeleton =
straightSkeleton( polygon );

Expand All @@ -311,9 +318,17 @@ std::unique_ptr< MultiLineString > straightSkeleton( const Polygon& g, bool /*au
}

if ( outputDistanceInM )
#if 0
straightSkeletonToMultiLineString<Kernel, true> ( *skeleton, *result, innerOnly, trans ) ;
else
#else
straightSkeletonToMultiLineString<Kernel, true> ( *skeleton, *result, innerOnly);
#endif
else
#if 0
straightSkeletonToMultiLineString<Kernel, false> ( *skeleton, *result, innerOnly, trans ) ;
#else
straightSkeletonToMultiLineString<Kernel, true> ( *skeleton, *result, innerOnly);
#endif
return result ;
}

Expand All @@ -326,18 +341,30 @@ std::unique_ptr< MultiLineString > straightSkeleton( const MultiPolygon& g, bool
std::unique_ptr< MultiLineString > result( new MultiLineString );

for ( size_t i = 0; i < g.numGeometries(); i++ ) {
#if 0
Kernel::Vector_2 trans;
Polygon_with_holes_2 polygon = preparePolygon( g.polygonN( i ), trans );
#else
Polygon_with_holes_2 polygon = g.polygonN( i ).toPolygon_with_holes_2();
#endif
boost::shared_ptr< Straight_skeleton_2 > skeleton = straightSkeleton( polygon ) ;

if ( !skeleton.get() ) {
BOOST_THROW_EXCEPTION( Exception( "CGAL failed to create straightSkeleton" ) ) ;
}

if ( outputDistanceInM )
#if 0
straightSkeletonToMultiLineString<Kernel, true>( *skeleton, *result, innerOnly, trans ) ;
else
#else
straightSkeletonToMultiLineString<Kernel, true>( *skeleton, *result, innerOnly);
#endif
else
#if 0
straightSkeletonToMultiLineString<Kernel, false>( *skeleton, *result, innerOnly, trans ) ;
#else
straightSkeletonToMultiLineString<Kernel, false>( *skeleton, *result, innerOnly);
#endif
}

return result ;
Expand Down

0 comments on commit 278a061

Please # to comment.