modif for skeleton: template for polygon

This commit is contained in:
Sébastien Loriot 2009-06-18 20:58:29 +00:00
parent f8d199ad6d
commit 79e7dffd6e
3 changed files with 13 additions and 11 deletions

View File

@ -5,7 +5,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY .build/ipelets)
find_package(CGAL)
find_package(CGAL QUIET COMPONENTS Core )
find_package(IPE)
if ( CGAL_FOUND )
@ -38,7 +38,7 @@ if ( CGAL_FOUND )
foreach(IPELET ${CGAL_IPELETS})
add_library(CGAL_${IPELET} MODULE ${IPELET}.cpp)
target_link_libraries( CGAL_${IPELET} ipe )
target_link_libraries( CGAL_${IPELET} ipe)
if ( IPELET_INSTALL_DIR )
install(TARGETS CGAL_${IPELET} DESTINATION ${IPELET_INSTALL_DIR})
endif ()

View File

@ -40,12 +40,13 @@ const std::string Hmsg[] = {
class SkeletonIpelet
: public CGAL::Ipelet_base<Kernel,3>{
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef boost::shared_ptr<Polygon_2> PolygonPtr ;
typedef CGAL::Polygon_2<Kernel> Polygon_2_with_vector;
typedef boost::shared_ptr<Polygon_2_with_vector> PolygonPtr ;
typedef std::vector<PolygonPtr> PolygonPtrVector ;
public:
SkeletonIpelet()
:CGAL::Ipelet_base<Kernel,3>("Polygon Partition",Slab,Hmsg){}
:CGAL::Ipelet_base<Kernel,3>("Skeleton and offset",Slab,Hmsg){}
void protected_run(int);
};
@ -69,7 +70,7 @@ void SkeletonIpelet::protected_run(int fn)
}
for (std::list<Polygon_2>::iterator itp=pol_list.begin();itp!=pol_list.end();++itp){
Polygon_2 polygon=*itp;
Polygon_2_with_vector polygon(itp->vertices_begin(),itp->vertices_end());
if (!polygon.is_simple()){
print_error_message("Polygon must be simple");
@ -86,10 +87,10 @@ void SkeletonIpelet::protected_run(int fn)
typedef std::vector< boost::shared_ptr< Polygon_2 > > PolygonVector ;
typedef std::vector< boost::shared_ptr< Polygon_2_with_vector > > PolygonVector ;
for( PolygonVector::const_iterator pi = inner_offset_polygons.begin() ; pi != inner_offset_polygons.end() ; ++ pi ){
Polygon_2 poly=**pi;
draw_in_ipe(poly);//not working because not using the same polynomial type. Try a template of the container in the function
Polygon_2_with_vector poly=**pi;
draw_in_ipe(poly);
}

View File

@ -381,11 +381,12 @@ public:
if (deselect_all) (--_page->end())->SetSelect(IpePgObject::ENone);
}
template<class Container>
void
draw_in_ipe(const Polygon_2& poly,bool deselect_all=false) const
draw_in_ipe(const CGAL::Polygon_2<Kernel,Container>& poly,bool deselect_all=false) const
{
std::list<Point_2> LP;
for (typename Polygon_2::iterator it=poly.vertices_begin();it!= poly.vertices_end();++it)
for (typename CGAL::Polygon_2<Kernel,Container>::iterator it=poly.vertices_begin();it!= poly.vertices_end();++it)
LP.push_back(*it);
draw_polyline_in_ipe(LP.begin(),LP.end(),true,deselect_all,false);
}