From 79e7dffd6e359c3953dfc70209dcce824d2e6787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 18 Jun 2009 20:58:29 +0000 Subject: [PATCH] modif for skeleton: template for polygon --- CGAL_ipelets/demo/CGAL_ipelets/CMakeLists.txt | 4 ++-- CGAL_ipelets/demo/CGAL_ipelets/skeleton.cpp | 15 ++++++++------- CGAL_ipelets/include/CGAL/CGAL_Ipelet_base.h | 5 +++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CGAL_ipelets/demo/CGAL_ipelets/CMakeLists.txt b/CGAL_ipelets/demo/CGAL_ipelets/CMakeLists.txt index f9d43b7be48..9a0b79e3f5a 100644 --- a/CGAL_ipelets/demo/CGAL_ipelets/CMakeLists.txt +++ b/CGAL_ipelets/demo/CGAL_ipelets/CMakeLists.txt @@ -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 () diff --git a/CGAL_ipelets/demo/CGAL_ipelets/skeleton.cpp b/CGAL_ipelets/demo/CGAL_ipelets/skeleton.cpp index dc3766450ab..b3f8ba7c4ab 100644 --- a/CGAL_ipelets/demo/CGAL_ipelets/skeleton.cpp +++ b/CGAL_ipelets/demo/CGAL_ipelets/skeleton.cpp @@ -40,12 +40,13 @@ const std::string Hmsg[] = { class SkeletonIpelet : public CGAL::Ipelet_base{ - typedef CGAL::Polygon_2 Polygon_2; - typedef boost::shared_ptr PolygonPtr ; + typedef CGAL::Polygon_2 Polygon_2_with_vector; + + typedef boost::shared_ptr PolygonPtr ; typedef std::vector PolygonPtrVector ; public: SkeletonIpelet() - :CGAL::Ipelet_base("Polygon Partition",Slab,Hmsg){} + :CGAL::Ipelet_base("Skeleton and offset",Slab,Hmsg){} void protected_run(int); }; @@ -69,7 +70,7 @@ void SkeletonIpelet::protected_run(int fn) } for (std::list::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); } diff --git a/CGAL_ipelets/include/CGAL/CGAL_Ipelet_base.h b/CGAL_ipelets/include/CGAL/CGAL_Ipelet_base.h index 7f97b03ee05..e03ffcd3818 100644 --- a/CGAL_ipelets/include/CGAL/CGAL_Ipelet_base.h +++ b/CGAL_ipelets/include/CGAL/CGAL_Ipelet_base.h @@ -381,11 +381,12 @@ public: if (deselect_all) (--_page->end())->SetSelect(IpePgObject::ENone); } + template void - draw_in_ipe(const Polygon_2& poly,bool deselect_all=false) const + draw_in_ipe(const CGAL::Polygon_2& poly,bool deselect_all=false) const { std::list LP; - for (typename Polygon_2::iterator it=poly.vertices_begin();it!= poly.vertices_end();++it) + for (typename CGAL::Polygon_2::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); }