Salome HOME
Copyright update 2021
[modules/shaper.git] / src / GeomAlgoAPI / GeomAlgoAPI_ShapeTools.h
index 4c80a6e7cc4bcb402d1c652a382925b98683c77f..4fa50be493088e9bf4895c2833b49da3a389919c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2021  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #ifndef GeomAlgoAPI_ShapeTools_H_
@@ -46,13 +45,16 @@ class ModelAPI_Object;
 class GeomAlgoAPI_ShapeTools
 {
 public:
+  /// \return the lenth of the edges of the current shape or 0.0 if it can be computed.
+  GEOMALGOAPI_EXPORT static double length(const std::shared_ptr<GeomAPI_Shape> theShape);
+
   /// \return the total volume of the solids of the current shape or 0.0 if it can be computed.
   GEOMALGOAPI_EXPORT static double volume(const std::shared_ptr<GeomAPI_Shape> theShape);
 
   /// \return the total area of the faces of the current shape or 0.0 if it can be computed.
   GEOMALGOAPI_EXPORT static double area(const std::shared_ptr<GeomAPI_Shape> theShape);
 
-  /// \return the centre of mass of the current face.
+  /// \return 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).
@@ -70,13 +72,10 @@ public:
   /// \brief Combines faces with common edges to shells, or solids to compsolids.
   /// \param[in] theCompound compound of shapes.
   /// \param[in] theType type of combine.
-  /// \param[out] theCombinedShapes resulting shapes.
-  /// \param[out] theFreeShapes shapes that does not have common subshapes.
+  /// \param[out] theResults resulting shapes.
   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> combineShapes(
     const std::shared_ptr<GeomAPI_Shape> theCompound,
-    const GeomAPI_Shape::ShapeType theType,
-    ListOfShape& theCombinedShapes,
-    ListOfShape& theFreeShapes);
+    const GeomAPI_Shape::ShapeType theType, ListOfShape& theResults);
 
   /// \brief Groups shapes with shared topology to compounds.
   /// \param[in] theCompound compound of shapes.
@@ -84,6 +83,13 @@ public:
   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape>
     groupSharedTopology(const std::shared_ptr<GeomAPI_Shape> theCompound);
 
+  /// \brief Check group of shapes has shared sub-shapes of the given type
+  /// \param[in] theShapes    list of shapes
+  /// \param[in] theShapeType type of sub-shapes to check
+  /// \return \c true if shared topology exists
+  GEOMALGOAPI_EXPORT static bool hasSharedTopology(const ListOfShape& theShapes,
+                                                   const GeomAPI_Shape::ShapeType theShapeType);
+
   /// \brief Calculates bounding box for theShapes
   /// \return list of eight points.
   /// \param[in] theShapes list of shapes.
@@ -95,7 +101,7 @@ public:
   /// \brief Enlarges or reduces plane to fit bounding box.
   /// \return plane that fits to bounding box.
   /// \param[in] thePlane base plane.
-  /// \param[in] thePoints bounding box points (shoud be eight).
+  /// \param[in] thePoints bounding box points (should be eight).
   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Face> fitPlaneToBox(
     const std::shared_ptr<GeomAPI_Shape> thePlane,
     const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints);
@@ -120,10 +126,10 @@ public:
 
   /// \brief Return a plane for list of shapes if they are all planar.
   /// \param[in] theShapes shapes to find plane.
-  /// \return plane where all shapes lie or empty ptr if they not planar.
+  /// \return plane where all shapes lie or empty pointer if they not planar.
   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Pln> findPlane(const ListOfShape& theShapes);
 
-  /// \brief Checks that vertex/edge is inside face or vertext inside wire.
+  /// \brief Checks that vertex/edge is inside face or vertex inside wire.
   /// \param[in] theSubShape shape that should be inside.
   /// \param[in] theBaseShape base shape.
   /// \return true if edge inside the face.
@@ -138,22 +144,26 @@ public:
   GEOMALGOAPI_EXPORT static
     std::shared_ptr<GeomAPI_Shape> getFaceOuterWire(const std::shared_ptr<GeomAPI_Shape> theFace);
 
+  /// \return \c true if edges are tangent in the specified point
+  GEOMALGOAPI_EXPORT static bool isTangent(const std::shared_ptr<GeomAPI_Edge> theEdge1,
+                                           const std::shared_ptr<GeomAPI_Edge> theEdge2,
+                                           const std::shared_ptr<GeomAPI_Vertex> theTgPoint);
+
   /// \return true if edge is parallel to face.
   GEOMALGOAPI_EXPORT static bool isParallel(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.
+  /// 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
   GEOMALGOAPI_EXPORT static std::list<std::shared_ptr<GeomAPI_Vertex> > intersect(
-    const std::shared_ptr<GeomAPI_Edge> theEdge, const std::shared_ptr<GeomAPI_Face> theFace,
-    const bool thePointsOutsideFace);
+    const std::shared_ptr<GeomAPI_Edge> theEdge, const std::shared_ptr<GeomAPI_Face> theFace);
 
   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;
   /// \brief Performs the split of the shape by points.
-  /// \param[in] theBaseShape shape that should be splitted.
+  /// \param[in] theBaseShape shape that should be divided.
   /// \param[in] thePoints container of points to split
   /// \param[out] theShapes container of shapes after split
   GEOMALGOAPI_EXPORT static void splitShape(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
@@ -161,7 +171,7 @@ public:
                                       std::set<std::shared_ptr<GeomAPI_Shape> >& theShapes);
 
   /// \brief Performs the split of the shape by points.
-  /// \param[in] theBaseShape shape that should be splitted.
+  /// \param[in] theBaseShape shape that should be divided.
   /// \param[in] thePoints container of points to split
   /// \param[out] theShapes container of shapes after split
   GEOMALGOAPI_EXPORT static void splitShape_p(const std::shared_ptr<GeomAPI_Shape>& theBaseShape,
@@ -173,7 +183,7 @@ public:
                                     const std::set<std::shared_ptr<GeomAPI_Shape> >& theShapes);
 
 #ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS
-  /// \brief Returns a dir from a shape and an axis.
+  /// \brief Returns a direction from a shape and an axis.
   /// \param[in] theBaseShape shape whose center of mass serves as the starting point of the dir.
   /// \param[in] theAxis axis that serves as a direction for the dir
   /// \return dir that builds from center of mass of the base shape and the axis
@@ -182,7 +192,7 @@ public:
                                     const std::shared_ptr<GeomAPI_Ax1> theAxis);
 #endif
 
-  /// \brief Reapproximate a wire to build a single edge
+  /// \brief Re-approximate a wire to build a single edge
   GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Edge> wireToEdge(
       const std::shared_ptr<GeomAPI_Wire>& theWire);
 
@@ -190,6 +200,17 @@ public:
   /// \param[in] theShape shape that should be exploded
   /// \return list of sub-shapes (vertices, edges, faces, solids)
   GEOMALGOAPI_EXPORT static ListOfShape getLowLevelSubShapes(const GeomShapePtr& theShape);
+
+  /// \brief Calculate prism sizes to ensure that it passes through all objects
+  /// \param[in] theObjects objects to be joined/cutted by the prism
+  /// \param[in] theBaseShapes bases of the prism
+  /// \param[in] theDir direction of the prism
+  /// \param[out] theToSize upper offset of the prism
+  /// \param[out] theFromSize lower offset of the prism
+  GEOMALGOAPI_EXPORT static void computeThroughAll(const ListOfShape& theObjects,
+                                                   const ListOfShape& theBaseShapes,
+                                                   const std::shared_ptr<GeomAPI_Dir> theDir,
+                                                   double& theToSize, double& theFromSize);
 };
 
 #endif