SHAPER  9.15.0
GeomAlgoAPI_ShapeTools Class Reference

Useful tools for working with shapes. More...

Public Types

typedef std::map< std::shared_ptr< GeomAPI_Pnt >, std::pair< std::list< std::shared_ptr< GeomDataAPI_Point2D > >, std::list< std::shared_ptr< ModelAPI_Object > > > > PointToRefsMap
 

Static Public Member Functions

static double length (const std::shared_ptr< GeomAPI_Shape > theShape)
 
static double volume (const std::shared_ptr< GeomAPI_Shape > theShape)
 
static double area (const std::shared_ptr< GeomAPI_Shape > theShape)
 
static bool isContinuousFaces (const GeomShapePtr &theFace1, const GeomShapePtr &theFace2, const GeomPointPtr &thePoint, const double &theAngle, std::string &theError)
 indicate if two faces are continuous with an angular tolerance used for G1 continuity to compare the angle between the normals More...
 
static std::shared_ptr< GeomAPI_PntcentreOfMass (const std::shared_ptr< GeomAPI_Shape > theShape)
 
static double radius (const std::shared_ptr< GeomAPI_Face > &theCylinder)
 Obtain radius of cylindrical face. More...
 
static double minimalDistance (const GeomShapePtr &theShape1, const GeomShapePtr &theShape2)
 Calculate minimal distance between shapes. More...
 
static double minimalDistance (const GeomShapePtr &theShape1, const GeomShapePtr &theShape2, std::array< double, 3 > &fromShape1To2)
 
static double shapeProximity (const GeomShapePtr &theShape1, const GeomShapePtr &theShape2)
 Calculate maximal value of all possible distances between shapes. More...
 
static std::shared_ptr< GeomAPI_ShapecombineShapes (const std::shared_ptr< GeomAPI_Shape > theCompound, const GeomAPI_Shape::ShapeType theType, ListOfShape &theResults)
 Combines faces with common edges to shells, or solids to compsolids. More...
 
static std::shared_ptr< GeomAPI_ShapegroupSharedTopology (const std::shared_ptr< GeomAPI_Shape > theCompound)
 Groups shapes with shared topology to compounds. More...
 
static bool hasSharedTopology (const ListOfShape &theShapes, const GeomAPI_Shape::ShapeType theShapeType)
 Check group of shapes has shared sub-shapes of the given type. More...
 
static std::list< std::shared_ptr< GeomAPI_Pnt > > getBoundingBox (const ListOfShape &theShapes, const double theEnlarge=0.0)
 Calculates bounding box for theShapes. More...
 
static std::shared_ptr< GeomAPI_FacefitPlaneToBox (const std::shared_ptr< GeomAPI_Shape > thePlane, const std::list< std::shared_ptr< GeomAPI_Pnt > > &thePoints)
 Enlarges or reduces plane to fit bounding box. More...
 
static void findBounds (const std::shared_ptr< GeomAPI_Shape > theShape, std::shared_ptr< GeomAPI_Vertex > &theV1, std::shared_ptr< GeomAPI_Vertex > &theV2)
 Finds the start and end vertices of theShape. More...
 
static void makeFacesWithHoles (const std::shared_ptr< GeomAPI_Pnt > theOrigin, const std::shared_ptr< GeomAPI_Dir > theDirection, const ListOfShape &theWires, ListOfShape &theFaces)
 Creates faces with holes from wires. More...
 
static std::shared_ptr< GeomAPI_PlnfindPlane (const ListOfShape &theShapes)
 Return a plane for list of shapes if they are all planar. More...
 
static bool isSubShapeInsideShape (const std::shared_ptr< GeomAPI_Shape > theSubShape, const std::shared_ptr< GeomAPI_Shape > theBaseShape)
 Checks that vertex/edge is inside face or vertex inside wire. More...
 
static bool isShapeValid (const std::shared_ptr< GeomAPI_Shape > theShape)
 
static std::shared_ptr< GeomAPI_ShapegetFaceOuterWire (const std::shared_ptr< GeomAPI_Shape > theFace)
 
static bool isTangent (const std::shared_ptr< GeomAPI_Edge > theEdge1, const std::shared_ptr< GeomAPI_Edge > theEdge2, const std::shared_ptr< GeomAPI_Vertex > theTgPoint)
 
static bool isParallel (const std::shared_ptr< GeomAPI_Edge > theEdge, const std::shared_ptr< GeomAPI_Face > theFace)
 
static std::list< std::shared_ptr< GeomAPI_Vertex > > intersect (const std::shared_ptr< GeomAPI_Edge > theEdge, const std::shared_ptr< GeomAPI_Face > theFace)
 Computes intersection point between the edge curve and a face surface (only one point, with preferences to point that belongs to edge and face boundaries. More...
 
static void splitShape (const std::shared_ptr< GeomAPI_Shape > &theBaseShape, const PointToRefsMap &thePointsInfo, std::set< std::shared_ptr< GeomAPI_Shape > > &theShapes)
 Performs the split of the shape by points. More...
 
static void splitShape_p (const std::shared_ptr< GeomAPI_Shape > &theBaseShape, const std::list< std::shared_ptr< GeomAPI_Pnt > > &thePoints, std::set< std::shared_ptr< GeomAPI_Shape > > &theShapes)
 Performs the split of the shape by points. More...
 
static std::shared_ptr< GeomAPI_ShapefindShape (const std::list< std::shared_ptr< GeomAPI_Pnt > > &thePoints, const std::set< std::shared_ptr< GeomAPI_Shape > > &theShapes)
 
static std::shared_ptr< GeomAPI_EdgewireToEdge (const std::shared_ptr< GeomAPI_Wire > &theWire)
 Re-approximate a wire to build a single edge. More...
 
static ListOfShape getLowLevelSubShapes (const GeomShapePtr &theShape)
 Get non-composite sub-shapes of the given shape. More...
 
static void computeThroughAll (const ListOfShape &theObjects, const ListOfShape &theBaseShapes, const std::shared_ptr< GeomAPI_Dir > theDir, double &theToSize, double &theFromSize)
 Calculate prism sizes to ensure that it passes through all objects. More...
 
static ListOfShape getSharedFaces (const GeomShapePtr &theShape)
 Get shared faces of a shape. More...
 

Detailed Description

Useful tools for working with shapes.

Member Function Documentation

◆ length()

double GeomAlgoAPI_ShapeTools::length ( const std::shared_ptr< GeomAPI_Shape theShape)
static
Returns
the length of the edges of the current shape or 0.0 if it cannot be computed.

◆ volume()

double GeomAlgoAPI_ShapeTools::volume ( const std::shared_ptr< GeomAPI_Shape theShape)
static
Returns
the total volume of the solids of the current shape or 0.0 if it cannot be computed.

◆ area()

double GeomAlgoAPI_ShapeTools::area ( const std::shared_ptr< GeomAPI_Shape theShape)
static
Returns
the total area of the faces of the current shape or 0.0 if it cannot be computed.

◆ isContinuousFaces()

bool GeomAlgoAPI_ShapeTools::isContinuousFaces ( const GeomShapePtr &  theFace1,
const GeomShapePtr &  theFace2,
const GeomPointPtr &  thePoint,
const double &  theAngle,
std::string &  theError 
)
static

indicate if two faces are continuous with an angular tolerance used for G1 continuity to compare the angle between the normals

Parameters
theFace1the first face
theFace2the second face
thePointthe point for the normal
theAnglethe angular tolerance
theErrorerror

◆ centreOfMass()

std::shared_ptr< GeomAPI_Pnt > GeomAlgoAPI_ShapeTools::centreOfMass ( const std::shared_ptr< GeomAPI_Shape theShape)
static
Returns
the center of mass of the current face. The coordinates returned for the center of mass are expressed in the absolute Cartesian coordinate system. (This function works only for surfaces).

◆ radius()

double GeomAlgoAPI_ShapeTools::radius ( const std::shared_ptr< GeomAPI_Face > &  theCylinder)
static

Obtain radius of cylindrical face.

Return negative value if the face is not a cylinder

◆ minimalDistance()

double GeomAlgoAPI_ShapeTools::minimalDistance ( const GeomShapePtr &  theShape1,
const GeomShapePtr &  theShape2 
)
static

Calculate minimal distance between shapes.

◆ shapeProximity()

double GeomAlgoAPI_ShapeTools::shapeProximity ( const GeomShapePtr &  theShape1,
const GeomShapePtr &  theShape2 
)
static

Calculate maximal value of all possible distances between shapes.

The shapes can be two edges or two faces only.

◆ combineShapes()

std::shared_ptr< GeomAPI_Shape > GeomAlgoAPI_ShapeTools::combineShapes ( const std::shared_ptr< GeomAPI_Shape theCompound,
const GeomAPI_Shape::ShapeType  theType,
ListOfShape &  theResults 
)
static

Combines faces with common edges to shells, or solids to compsolids.

Parameters
[in]theCompoundcompound of shapes.
[in]theTypetype of combine.
[out]theResultsresulting shapes.

◆ groupSharedTopology()

std::shared_ptr< GeomAPI_Shape > GeomAlgoAPI_ShapeTools::groupSharedTopology ( const std::shared_ptr< GeomAPI_Shape theCompound)
static

Groups shapes with shared topology to compounds.

Parameters
[in]theCompoundcompound of shapes.
Returns
compound of compounds with shared topology.

◆ hasSharedTopology()

bool GeomAlgoAPI_ShapeTools::hasSharedTopology ( const ListOfShape &  theShapes,
const GeomAPI_Shape::ShapeType  theShapeType 
)
static

Check group of shapes has shared sub-shapes of the given type.

Parameters
[in]theShapeslist of shapes
[in]theShapeTypetype of sub-shapes to check
Returns
true if shared topology exists

◆ getBoundingBox()

std::list< std::shared_ptr< GeomAPI_Pnt > > GeomAlgoAPI_ShapeTools::getBoundingBox ( const ListOfShape &  theShapes,
const double  theEnlarge = 0.0 
)
static

Calculates bounding box for theShapes.

Returns
list of eight points.
Parameters
[in]theShapeslist of shapes.
[in]theEnlargeenlarges bounding box size.

◆ fitPlaneToBox()

std::shared_ptr< GeomAPI_Face > GeomAlgoAPI_ShapeTools::fitPlaneToBox ( const std::shared_ptr< GeomAPI_Shape thePlane,
const std::list< std::shared_ptr< GeomAPI_Pnt > > &  thePoints 
)
static

Enlarges or reduces plane to fit bounding box.

Returns
plane that fits to bounding box.
Parameters
[in]thePlanebase plane.
[in]thePointsbounding box points (should be eight).

◆ findBounds()

void GeomAlgoAPI_ShapeTools::findBounds ( const std::shared_ptr< GeomAPI_Shape theShape,
std::shared_ptr< GeomAPI_Vertex > &  theV1,
std::shared_ptr< GeomAPI_Vertex > &  theV2 
)
static

Finds the start and end vertices of theShape.

theShape can be of the following type:
Vertex: theV1 and theV2 are the same and equal to theShape;
Edge : theV1 is start and theV2 is end vertex;
Wire : theV1 is start vertex of the first edge, theV2 is end vertex of the last edge. If wire contains no edges theV1 and theV2 are nullified.
If none of the above theV1 and theV2 are nullified.

◆ makeFacesWithHoles()

void GeomAlgoAPI_ShapeTools::makeFacesWithHoles ( const std::shared_ptr< GeomAPI_Pnt theOrigin,
const std::shared_ptr< GeomAPI_Dir theDirection,
const ListOfShape &  theWires,
ListOfShape &  theFaces 
)
static

Creates faces with holes from wires.

Parameters
[in]theWiresbase wires.
[out]theFacesresulting faces.

◆ findPlane()

std::shared_ptr< GeomAPI_Pln > GeomAlgoAPI_ShapeTools::findPlane ( const ListOfShape &  theShapes)
static

Return a plane for list of shapes if they are all planar.

Parameters
[in]theShapesshapes to find plane.
Returns
plane where all shapes lie or empty pointer if they not planar.

◆ isSubShapeInsideShape()

bool GeomAlgoAPI_ShapeTools::isSubShapeInsideShape ( const std::shared_ptr< GeomAPI_Shape theSubShape,
const std::shared_ptr< GeomAPI_Shape theBaseShape 
)
static

Checks that vertex/edge is inside face or vertex inside wire.

Parameters
[in]theSubShapeshape that should be inside.
[in]theBaseShapebase shape.
Returns
true if edge inside the face.

◆ isShapeValid()

bool GeomAlgoAPI_ShapeTools::isShapeValid ( const std::shared_ptr< GeomAPI_Shape theShape)
static
Returns
true if theShape is valid.

◆ getFaceOuterWire()

std::shared_ptr< GeomAPI_Shape > GeomAlgoAPI_ShapeTools::getFaceOuterWire ( const std::shared_ptr< GeomAPI_Shape theFace)
static
Returns
outer wire for face. If theShape has different type returns empty pointer.

◆ isTangent()

bool GeomAlgoAPI_ShapeTools::isTangent ( const std::shared_ptr< GeomAPI_Edge theEdge1,
const std::shared_ptr< GeomAPI_Edge theEdge2,
const std::shared_ptr< GeomAPI_Vertex theTgPoint 
)
static
Returns
true if edges are tangent in the specified point

◆ isParallel()

bool GeomAlgoAPI_ShapeTools::isParallel ( const std::shared_ptr< GeomAPI_Edge theEdge,
const std::shared_ptr< GeomAPI_Face theFace 
)
static
Returns
true if edge is parallel to face.

◆ intersect()

std::list< std::shared_ptr< GeomAPI_Vertex > > GeomAlgoAPI_ShapeTools::intersect ( const std::shared_ptr< GeomAPI_Edge theEdge,
const std::shared_ptr< GeomAPI_Face theFace 
)
static

Computes intersection point between the edge curve and a face surface (only one point, with preferences to point that belongs to edge and face boundaries.

Returns
null if there is no intersection

◆ splitShape()

void GeomAlgoAPI_ShapeTools::splitShape ( const std::shared_ptr< GeomAPI_Shape > &  theBaseShape,
const PointToRefsMap &  thePointsInfo,
std::set< std::shared_ptr< GeomAPI_Shape > > &  theShapes 
)
static

Performs the split of the shape by points.

Parameters
[in]theBaseShapeshape that should be divided.
[in]thePointscontainer of points to split
[out]theShapescontainer of shapes after split

◆ splitShape_p()

void GeomAlgoAPI_ShapeTools::splitShape_p ( const std::shared_ptr< GeomAPI_Shape > &  theBaseShape,
const std::list< std::shared_ptr< GeomAPI_Pnt > > &  thePoints,
std::set< std::shared_ptr< GeomAPI_Shape > > &  theShapes 
)
static

Performs the split of the shape by points.

Parameters
[in]theBaseShapeshape that should be divided.
[in]thePointscontainer of points to split
[out]theShapescontainer of shapes after split

◆ wireToEdge()

std::shared_ptr< GeomAPI_Edge > GeomAlgoAPI_ShapeTools::wireToEdge ( const std::shared_ptr< GeomAPI_Wire > &  theWire)
static

Re-approximate a wire to build a single edge.

◆ getLowLevelSubShapes()

ListOfShape GeomAlgoAPI_ShapeTools::getLowLevelSubShapes ( const GeomShapePtr &  theShape)
static

Get non-composite sub-shapes of the given shape.

Parameters
[in]theShapeshape that should be exploded
Returns
list of sub-shapes (vertices, edges, faces, solids)

◆ computeThroughAll()

void GeomAlgoAPI_ShapeTools::computeThroughAll ( const ListOfShape &  theObjects,
const ListOfShape &  theBaseShapes,
const std::shared_ptr< GeomAPI_Dir theDir,
double &  theToSize,
double &  theFromSize 
)
static

Calculate prism sizes to ensure that it passes through all objects.

Parameters
[in]theObjectsobjects to be joined/cut by the prism
[in]theBaseShapesbases of the prism
[in]theDirdirection of the prism
[out]theToSizeupper offset of the prism
[out]theFromSizelower offset of the prism

◆ getSharedFaces()

ListOfShape GeomAlgoAPI_ShapeTools::getSharedFaces ( const GeomShapePtr &  theShape)
static

Get shared faces of a shape.

Parameters
[in]theShapeshape that should be exploded
Returns
list of shared faces