const Kernel::FT volume( const Geometry& g ) { if ( g.isEmpty() ) { return 0; } SFCGAL_ASSERT_GEOMETRY_VALIDITY( g ); switch ( g.geometryTypeId() ) { case TYPE_POINT: case TYPE_LINESTRING: case TYPE_POLYGON: case TYPE_TRIANGLE: case TYPE_MULTIPOINT: case TYPE_MULTILINESTRING: case TYPE_MULTIPOLYGON: case TYPE_TRIANGULATEDSURFACE: case TYPE_POLYHEDRALSURFACE: return 0; case TYPE_SOLID: return volume( g.as<Solid>(), NoValidityCheck() ); case TYPE_MULTISOLID: case TYPE_GEOMETRYCOLLECTION: Kernel::FT v=0; const GeometryCollection& c = g.as<GeometryCollection>(); for ( size_t i=0; i<c.numGeometries(); i++ ) { if ( c.geometryN( i ).is<Solid>() ) { v = v + volume( c.geometryN( i ).as<Solid>(), NoValidityCheck() ); } } return v; } BOOST_THROW_EXCEPTION( Exception( ( boost::format( "volume( %s ) is not defined" ) % g.geometryType() ).str() ) ); return 0; // to avoid warning }
void triangulatePolygon3D( const Geometry& g, TriangulatedSurface& triangulatedSurface ) { if ( g.isEmpty() ) { return; } SFCGAL_ASSERT_GEOMETRY_VALIDITY( g ); switch ( g.geometryTypeId() ) { case TYPE_TRIANGLE: return triangulatePolygon3D( g.as< Triangle >(), triangulatedSurface ); case TYPE_POLYGON: return triangulatePolygon3D( g.as< Polygon >(), triangulatedSurface ); case TYPE_TRIANGULATEDSURFACE: return triangulatePolygon3D( g.as< TriangulatedSurface >(), triangulatedSurface ); case TYPE_POLYHEDRALSURFACE: return triangulatePolygon3D( g.as< PolyhedralSurface >(), triangulatedSurface ); case TYPE_SOLID: return triangulatePolygon3D( g.as< Solid >(), triangulatedSurface ); case TYPE_MULTIPOLYGON: case TYPE_MULTISOLID: case TYPE_GEOMETRYCOLLECTION: { for ( size_t i = 0; i < g.numGeometries(); i++ ) { triangulatePolygon3D( g.geometryN( i ), triangulatedSurface ) ; } return ; } default: BOOST_THROW_EXCEPTION( InappropriateGeometryException( ( boost::format( "can't triangulate 3d polygons for type '%1%'" ) % g.geometryType() ).str() ) ); } }
std::auto_ptr< Geometry > extrude( const Geometry& g, Kernel::FT dx, Kernel::FT dy, Kernel::FT dz ) { SFCGAL_ASSERT_GEOMETRY_VALIDITY( g ); return extrude( g, dx, dy, dz, NoValidityCheck() ); }
std::auto_ptr<Geometry> tesselate( const Geometry& g ) { SFCGAL_ASSERT_GEOMETRY_VALIDITY( g ); return tesselate( g, NoValidityCheck() ); }