std::auto_ptr<Geometry> collect( const Geometry& ga, const Geometry& gb ) { if ( ga.geometryTypeId() == gb.geometryTypeId() ) { if ( ga.geometryTypeId() == TYPE_POINT ) { MultiPoint *mp = new MultiPoint; mp->addGeometry( ga ); mp->addGeometry( gb ); return std::auto_ptr<Geometry>(mp); } else if ( ga.geometryTypeId() == TYPE_LINESTRING ) { MultiLineString *mls = new MultiLineString(); mls->addGeometry(ga); mls->addGeometry(gb); return std::auto_ptr<Geometry>( mls ); } else if ( ga.geometryTypeId() == TYPE_POLYGON ) { MultiPolygon *mp = new MultiPolygon(); mp->addGeometry(ga); mp->addGeometry(gb); return std::auto_ptr<Geometry>( mp ); } else if ( ga.geometryTypeId() == TYPE_SOLID ) { MultiSolid *mp = new MultiSolid(); mp->addGeometry(ga); mp->addGeometry(gb); return std::auto_ptr<Geometry>( mp ); } } // else GeometryCollection* coll = new GeometryCollection(); coll->addGeometry(ga); coll->addGeometry(gb); return std::auto_ptr<Geometry>( coll ); }
void straightSkeletonToMultiLineString( const CGAL::Straight_skeleton_2<K> & ss, MultiLineString& result ) { typedef CGAL::Straight_skeleton_2<K> Ss ; typedef typename Ss::Vertex_const_handle Vertex_const_handle ; typedef typename Ss::Halfedge_const_handle Halfedge_const_handle ; typedef typename Ss::Halfedge_const_iterator Halfedge_const_iterator ; Halfedge_const_handle null_halfedge ; Vertex_const_handle null_vertex ; for ( Halfedge_const_iterator it = ss.halfedges_begin(); it != ss.halfedges_end(); ++it ){ // skip contour edge if ( ! it->is_bisector() ){ continue ; } // avoid duplicates if ( it->opposite() < it ){ continue ; } result.addGeometry( new LineString( Point( it->opposite()->vertex()->point() ), Point( it->vertex()->point() ) ) ); } }