Hi,

 

I have asked this question before – about a year ago. Just checking if there is any news in this regard: I would like to be able to apply a functor to every point in a multi-polygon, e.g., in order to transform an int-based polygon into a double-base polygon. This seems to be a canonical operation, like boost::adaptors::transform on ranges, and yet as far as I know there is no algorithm for this in geometry. This is how I currently do it:

 

reserve( polygon.size() ); // vector of polygons

for( std::vector< _TPolygon< S >::polygon_type >::const_iterator itp=polygon.begin(); itp!=polygon.end(); ++itp ) {

       emplace_back( polygon_type() );

       back().outer().reserve( itp->outer().size() ); // vector of points describing polygon outline

       for( _TPolygon< S >::polygon_type::ring_type::const_iterator itouter=itp->outer().begin(); itouter!=itp->outer().end(); ++itouter ) {

             back().outer().emplace_back( _TPoint< T >(*itouter) );

       }

       back().inners().reserve( itp->inners().size() ); // vector of holes

       for( _TPolygon< S >::polygon_type::inner_container_type::const_iterator itinners=itp->inners().begin(); itinners!=itp->inners().end(); ++itinners ) {

             back().inners().emplace_back( polygon_type::ring_type() );

             back().inners().back().reserve( itinners->size() ); // vector of points describing a hole

             for( _TPolygon< S >::polygon_type::ring_type::const_iterator itinner=itinners->begin(); itinner!=itinners->end(); ++itinner ) {

                    back().inners().back().emplace_back( _TPoint< T >(*itinner) );

             }

       }

}

 

Is there an algorithm in geometry 1.52.0 that I did not find? Do you plan to add an algorithm for this task at some point?

Thanks

   Volker

--
Volker Schöch | vschoech@think-cell.com
Senior Software Engineer



think-cell Software GmbH http://www.think-cell.com
Chausseestr. 8/E phone / fax +49 30 666473-10 / -19
10115 Berlin, Germany US phone / fax +1 800 891 8091 / +1 212 504 3039
Amtsgericht Berlin-Charlottenburg, HRB 85229 | European Union VAT Id DE813474306
Directors: Dr. Markus Hannebauer, Dr. Arno Schödl