本文整理汇总了C++中Geometry::accept方法的典型用法代码示例。如果您正苦于以下问题:C++ Geometry::accept方法的具体用法?C++ Geometry::accept怎么用?C++ Geometry::accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geometry
的用法示例。
在下文中一共展示了Geometry::accept方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
///
/// Function used to compare geometries
/// FIXME
/// Since we do not have (yet) a real "equals" operator, we only compare points coordinates
bool operator == ( const Geometry& ga, const Geometry& gb )
{
if ( ga.geometryTypeId() != gb.geometryTypeId() ) {
return false;
}
detail::GetPointsVisitor get_points_a, get_points_b;
ga.accept( get_points_a );
gb.accept( get_points_b );
if ( get_points_a.points.size() != get_points_b.points.size() ) {
return false;
}
for ( size_t i = 0; i < get_points_a.points.size(); ++i ) {
bool found = false;
for ( size_t j = 0; j < get_points_b.points.size(); ++j ) {
const Point& pta = *( get_points_a.points[i] );
const Point& ptb = *( get_points_b.points[j] );
if ( pta == ptb ) {
found = true;
break;
}
}
if ( ! found ) {
return false;
}
}
return true;
}
示例2: translate
void translate( Geometry& g, const Kernel::Vector_3& v )
{
transform::AffineTransform3 visitor(
CGAL::Aff_transformation_3< Kernel >( CGAL::TRANSLATION, v )
);
g.accept( visitor ) ;
}
示例3: collectionToMulti
// Use of auto_ptr :
// If nothing has to be built, g will be moved to the result without copy and new allocation.
// Otherwise, a new geometry is built and the old one is deleted
std::auto_ptr<Geometry> collectionToMulti( std::auto_ptr<Geometry> g )
{
if ( ! g->is<GeometryCollection>() ) {
// not a collection, nothing to do
return g;
}
const GeometryCollection& coll = g->as<GeometryCollection>();
// if it is empty, do not do anything
if ( coll.isEmpty() ) {
return g;
}
bool has2d = false;
bool has3d = false;
for ( size_t i = 0; i < coll.numGeometries(); ++i ) {
const Geometry& gi = coll.geometryN( i );
if ( !has3d && gi.is3D() ) {
has3d = true;
}
if ( !has2d && !gi.is3D() ) {
has2d = true;
}
if ( !gi.isEmpty() && ( gi.geometryTypeId() != TYPE_POLYGON ) &&
( gi.geometryTypeId() != TYPE_TRIANGLE ) &&
( gi.geometryTypeId() != TYPE_POLYHEDRALSURFACE ) &&
( gi.geometryTypeId() != TYPE_TRIANGULATEDSURFACE ) ) {
// it contains a bad type, abort
return g;
}
}
bool force3d = has2d && has3d;
MultiPolygon* ret_geo = new MultiPolygon;
// copy each geometry
for ( size_t i = 0; i < coll.numGeometries(); ++i ) {
Geometry* gi = coll.geometryN( i ).clone();
if ( force3d && !gi->is3D() ) {
transform::ForceZ forceZ;
gi->accept( forceZ );
}
switch ( gi->geometryTypeId() ) {
case TYPE_TRIANGLE:
ret_geo->addGeometry( Polygon( gi->as<Triangle>() ) );
break;
case TYPE_TRIANGULATEDSURFACE: {
for ( size_t j = 0; j < gi->numGeometries(); ++j ) {
ret_geo->addGeometry( Polygon( gi->geometryN( j ).as<Triangle>() ) );
}
}
break;
case TYPE_POLYHEDRALSURFACE: {
for ( size_t j = 0; j < gi->numGeometries(); ++j ) {
ret_geo->addGeometry( gi->geometryN( j ) );
}
}
break;
case TYPE_GEOMETRYCOLLECTION:
// do not include empty geometrycollection
if ( gi->isEmpty() ) {
continue;
}
default:
ret_geo->addGeometry( *gi );
}
}
return std::auto_ptr<Geometry>( ret_geo );
}
示例4: force3D
void force3D( Geometry& g, const Kernel::FT& defaultZ )
{
transform::ForceZ t( defaultZ ) ;
g.accept( t ) ;
}