SHAPER  9.12.0
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See or email :
18 //
20 #ifndef GeomAlgoAPI_ShapeTools_H_
21 #define GeomAlgoAPI_ShapeTools_H_
23 #include "GeomAlgoAPI.h"
25 #include <GeomAPI_Shape.h>
26 #include <GeomAPI_Vertex.h>
27 #include <GeomAPI_Pnt.h>
28 #include <map>
29 #include <set>
30 #ifdef WIN32
31 #include<array>
32 #endif
34 class GeomAPI_Ax1;
35 class GeomAPI_Edge;
36 class GeomAPI_Dir;
37 class GeomAPI_Face;
39 class GeomAPI_Pln;
40 class GeomAPI_Pnt;
41 class GeomAPI_Wire;
43 class ModelAPI_Object;
49 {
50 public:
52  GEOMALGOAPI_EXPORT static double length(const std::shared_ptr<GeomAPI_Shape> theShape);
55  GEOMALGOAPI_EXPORT static double volume(const std::shared_ptr<GeomAPI_Shape> theShape);
58  GEOMALGOAPI_EXPORT static double area(const std::shared_ptr<GeomAPI_Shape> theShape);
67  GEOMALGOAPI_EXPORT static bool isContinuousFaces(const GeomShapePtr& theFace1,
68  const GeomShapePtr& theFace2,
69  const GeomPointPtr& thePoint,
70  const double & theAngle,
71  std::string& theError);
77  GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Pnt>
78  centreOfMass(const std::shared_ptr<GeomAPI_Shape> theShape);
82  GEOMALGOAPI_EXPORT static double radius(const std::shared_ptr<GeomAPI_Face>& theCylinder);
85  GEOMALGOAPI_EXPORT static double minimalDistance(const GeomShapePtr& theShape1,
86  const GeomShapePtr& theShape2);
87  GEOMALGOAPI_EXPORT static double minimalDistance(const GeomShapePtr& theShape1,
88  const GeomShapePtr& theShape2,
89  std::array<double, 3> & fromShape1To2);
93  GEOMALGOAPI_EXPORT static double shapeProximity(const GeomShapePtr& theShape1,
94  const GeomShapePtr& theShape2);
100  GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> combineShapes(
101  const std::shared_ptr<GeomAPI_Shape> theCompound,
102  const GeomAPI_Shape::ShapeType theType, ListOfShape& theResults);
107  GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape>
108  groupSharedTopology(const std::shared_ptr<GeomAPI_Shape> theCompound);
114  GEOMALGOAPI_EXPORT static bool hasSharedTopology(const ListOfShape& theShapes,
115  const GeomAPI_Shape::ShapeType theShapeType);
122  std::list<std::shared_ptr<GeomAPI_Pnt> > getBoundingBox(const ListOfShape& theShapes,
123  const double theEnlarge = 0.0);
129  GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Face> fitPlaneToBox(
130  const std::shared_ptr<GeomAPI_Shape> thePlane,
131  const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints);
139  GEOMALGOAPI_EXPORT static void findBounds(const std::shared_ptr<GeomAPI_Shape> theShape,
140  std::shared_ptr<GeomAPI_Vertex>& theV1,
141  std::shared_ptr<GeomAPI_Vertex>& theV2);
146  GEOMALGOAPI_EXPORT static void makeFacesWithHoles(const std::shared_ptr<GeomAPI_Pnt> theOrigin,
147  const std::shared_ptr<GeomAPI_Dir> theDirection,
148  const ListOfShape& theWires,
149  ListOfShape& theFaces);
154  GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Pln> findPlane(const ListOfShape& theShapes);
160  GEOMALGOAPI_EXPORT static bool isSubShapeInsideShape(
161  const std::shared_ptr<GeomAPI_Shape> theSubShape,
162  const std::shared_ptr<GeomAPI_Shape> theBaseShape);
165  GEOMALGOAPI_EXPORT static bool isShapeValid(const std::shared_ptr<GeomAPI_Shape> theShape);
169  std::shared_ptr<GeomAPI_Shape> getFaceOuterWire(const std::shared_ptr<GeomAPI_Shape> theFace);
172  GEOMALGOAPI_EXPORT static bool isTangent(const std::shared_ptr<GeomAPI_Edge> theEdge1,
173  const std::shared_ptr<GeomAPI_Edge> theEdge2,
174  const std::shared_ptr<GeomAPI_Vertex> theTgPoint);
177  GEOMALGOAPI_EXPORT static bool isParallel(const std::shared_ptr<GeomAPI_Edge> theEdge,
178  const std::shared_ptr<GeomAPI_Face> theFace);
183  GEOMALGOAPI_EXPORT static std::list<std::shared_ptr<GeomAPI_Vertex> > intersect(
184  const std::shared_ptr<GeomAPI_Edge> theEdge, const std::shared_ptr<GeomAPI_Face> theFace);
186  typedef std::map<std::shared_ptr<GeomAPI_Pnt>,
187  std::pair<std::list<std::shared_ptr<GeomDataAPI_Point2D> >,
188  std::list<std::shared_ptr<ModelAPI_Object> > > > PointToRefsMap;
193  GEOMALGOAPI_EXPORT static void splitShape(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
194  const PointToRefsMap& thePointsInfo,
195  std::set<std::shared_ptr<GeomAPI_Shape> >& theShapes);
201  GEOMALGOAPI_EXPORT static void splitShape_p(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
202  const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints,
203  std::set<std::shared_ptr<GeomAPI_Shape> >& theShapes);
205  GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> findShape(
206  const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints,
207  const std::set<std::shared_ptr<GeomAPI_Shape> >& theShapes);
214  GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Dir> buildDirFromAxisAndShape(
215  const std::shared_ptr<GeomAPI_Shape> theBaseShape,
216  const std::shared_ptr<GeomAPI_Ax1> theAxis);
217 #endif
220  GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Edge> wireToEdge(
221  const std::shared_ptr<GeomAPI_Wire>& theWire);
226  GEOMALGOAPI_EXPORT static ListOfShape getLowLevelSubShapes(const GeomShapePtr& theShape);
234  GEOMALGOAPI_EXPORT static void computeThroughAll(const ListOfShape& theObjects,
235  const ListOfShape& theBaseShapes,
236  const std::shared_ptr<GeomAPI_Dir> theDir,
237  double& theToSize, double& theFromSize);
242  GEOMALGOAPI_EXPORT static ListOfShape getSharedFaces(const GeomShapePtr& theShape);
243 };
245 #endif
The class represents an axis in 3D space.
Definition: GeomAPI_Ax1.h:31
3D direction defined by three normalized coordinates
Definition: GeomAPI_Dir.h:34
Interface to the edge object.
Definition: GeomAPI_Edge.h:38
Interface to the face object.
Definition: GeomAPI_Face.h:36
Interface to the set of edges located in one plane.
Definition: GeomAPI_PlanarEdges.h:40
3D point defined by three coordinates
Definition: GeomAPI_Pln.h:37
3D point defined by three coordinates
Definition: GeomAPI_Pnt.h:38
Shape type enum.
Definition: GeomAPI_Shape.h:46
Interface to the wire object.
Definition: GeomAPI_Wire.h:31
Useful tools for working with shapes.
Definition: GeomAlgoAPI_ShapeTools.h:49
static double minimalDistance(const GeomShapePtr &theShape1, const GeomShapePtr &theShape2)
Calculate minimal distance between shapes.
Definition: GeomAlgoAPI_ShapeTools.cpp:530
static std::shared_ptr< GeomAPI_Pln > findPlane(const ListOfShape &theShapes)
Return a plane for list of shapes if they are all planar.
Definition: GeomAlgoAPI_ShapeTools.cpp:1177
static double area(const std::shared_ptr< GeomAPI_Shape > theShape)
Definition: GeomAlgoAPI_ShapeTools.cpp:186
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.
Definition: GeomAlgoAPI_ShapeTools.cpp:1446
static bool isShapeValid(const std::shared_ptr< GeomAPI_Shape > theShape)
Definition: GeomAlgoAPI_ShapeTools.cpp:1279
static ListOfShape getLowLevelSubShapes(const GeomShapePtr &theShape)
Get non-composite sub-shapes of the given shape.
Definition: GeomAlgoAPI_ShapeTools.cpp:1636
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.
Definition: GeomAlgoAPI_ShapeTools.cpp:1677
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.
Definition: GeomAlgoAPI_ShapeTools.cpp:1205
static bool isTangent(const std::shared_ptr< GeomAPI_Edge > theEdge1, const std::shared_ptr< GeomAPI_Edge > theEdge2, const std::shared_ptr< GeomAPI_Vertex > theTgPoint)
Definition: GeomAlgoAPI_ShapeTools.cpp:1332
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.
Definition: GeomAlgoAPI_ShapeTools.cpp:1118
static std::shared_ptr< GeomAPI_Shape > getFaceOuterWire(const std::shared_ptr< GeomAPI_Shape > theFace)
Definition: GeomAlgoAPI_ShapeTools.cpp:1291
static std::shared_ptr< GeomAPI_Pnt > centreOfMass(const std::shared_ptr< GeomAPI_Shape > theShape)
Definition: GeomAlgoAPI_ShapeTools.cpp:303
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 ...
Definition: GeomAlgoAPI_ShapeTools.cpp:203
static std::shared_ptr< GeomAPI_Shape > combineShapes(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.
Definition: GeomAlgoAPI_ShapeTools.cpp:668
static ListOfShape getSharedFaces(const GeomShapePtr &theShape)
Get shared faces of a shape.
Definition: GeomAlgoAPI_ShapeTools.cpp:1785
static double radius(const std::shared_ptr< GeomAPI_Face > &theCylinder)
Obtain radius of cylindrical face.
Definition: GeomAlgoAPI_ShapeTools.cpp:325
static std::shared_ptr< GeomAPI_Face > fitPlaneToBox(const std::shared_ptr< GeomAPI_Shape > thePlane, const std::list< std::shared_ptr< GeomAPI_Pnt > > &thePoints)
Enlarges or reduces plane to fit bounding box.
Definition: GeomAlgoAPI_ShapeTools.cpp:1063
static double volume(const std::shared_ptr< GeomAPI_Shape > theShape)
Definition: GeomAlgoAPI_ShapeTools.cpp:166
static bool hasSharedTopology(const ListOfShape &theShapes, const GeomAPI_Shape::ShapeType theShapeType)
Check group of shapes has shared sub-shapes of the given type.
Definition: GeomAlgoAPI_ShapeTools.cpp:1010
static bool isParallel(const std::shared_ptr< GeomAPI_Edge > theEdge, const std::shared_ptr< GeomAPI_Face > theFace)
Definition: GeomAlgoAPI_ShapeTools.cpp:1347
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.
Definition: GeomAlgoAPI_ShapeTools.cpp:1145
static std::shared_ptr< GeomAPI_Edge > wireToEdge(const std::shared_ptr< GeomAPI_Wire > &theWire)
Re-approximate a wire to build a single edge.
Definition: GeomAlgoAPI_ShapeTools.cpp:1576
static double length(const std::shared_ptr< GeomAPI_Shape > theShape)
Definition: GeomAlgoAPI_ShapeTools.cpp:150
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.
Definition: GeomAlgoAPI_ShapeTools.cpp:1396
static double shapeProximity(const GeomShapePtr &theShape1, const GeomShapePtr &theShape2)
Calculate maximal value of all possible distances between shapes.
Definition: GeomAlgoAPI_ShapeTools.cpp:551
static std::shared_ptr< GeomAPI_Shape > groupSharedTopology(const std::shared_ptr< GeomAPI_Shape > theCompound)
Groups shapes with shared topology to compounds.
Definition: GeomAlgoAPI_ShapeTools.cpp:880
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,...
Definition: GeomAlgoAPI_ShapeTools.cpp:1362
static std::list< std::shared_ptr< GeomAPI_Pnt > > getBoundingBox(const ListOfShape &theShapes, const double theEnlarge=0.0)
Calculates bounding box for theShapes.
Definition: GeomAlgoAPI_ShapeTools.cpp:1029
Attribute that contains 2D point coordinates.
Definition: GeomDataAPI_Point2D.h:37
Represents any object in the data model and in the object browser.
Definition: ModelAPI_Object.h:45