Esempio n. 1
0
std::auto_ptr< Geometry > minkowskiSum( const Geometry& gA, const Polygon& gB )
{
    SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( gA );
    SFCGAL_ASSERT_GEOMETRY_VALIDITY_2D( gB );

    return minkowskiSum( gA, gB, NoValidityCheck() );
}
Esempio n. 2
0
std::auto_ptr<Geometry> intersection3D( const Geometry& ga, const Geometry& gb )
{
    SFCGAL_ASSERT_GEOMETRY_VALIDITY_3D( ga );
    SFCGAL_ASSERT_GEOMETRY_VALIDITY_3D( gb );

    return intersection3D( ga, gb, NoValidityCheck() );
}
Esempio n. 3
0
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
}
Esempio n. 4
0
const Kernel::FT volume( const Solid& solid, NoValidityCheck )
{
    Kernel::FT vol = 0;
    const CGAL::Point_3<Kernel> origin( 0,0,0 );
    const size_t numShells = solid.numShells();

    for ( size_t i=0; i<numShells; i++ ) {
        std::auto_ptr<Geometry> t( tesselate( solid.shellN( i ), NoValidityCheck() ) );
        const TriangulatedSurface& tin = t->as<TriangulatedSurface>();
        const size_t numTriangles = tin.numTriangles();

        for ( size_t j=0; j<numTriangles; j++ ) {
            const Triangle& tri = tin.triangleN( j );
            vol = vol + CGAL::volume( origin, tri.vertex( 0 ).toPoint_3(),
                                      tri.vertex( 1 ).toPoint_3(),
                                      tri.vertex( 2 ).toPoint_3() );
        }
    }

    return vol;
}
Esempio n. 5
0
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() );
}
Esempio n. 6
0
std::auto_ptr<Geometry> tesselate( const Geometry& g )
{
    SFCGAL_ASSERT_GEOMETRY_VALIDITY( g );

    return tesselate( g, NoValidityCheck() );
}