Salome HOME
bos#35152 [EDF] (2023-T1) Sketch Circle should allow user to position construction...
[modules/shaper.git] / src / SketchAPI / SketchAPI_Sketch.h
index ddbb1829186f83da593adb0520b1716aeed821cd..7f2fa98ea31fef627833078d25504f9835eee8c9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 
 #include <SketchPlugin_Sketch.h>
 #include <SketchPlugin_SketchEntity.h>
+#include <SketchPlugin_Offset.h>
 
+#include <ModelHighAPI_Double.h>
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
 #include <ModelHighAPI_Selection.h>
 //--------------------------------------------------------------------------------------
 class ModelAPI_CompositeFeature;
 class ModelAPI_Object;
-class ModelHighAPI_Double;
 class ModelHighAPI_Integer;
 class ModelHighAPI_RefAttr;
 class ModelHighAPI_Reference;
@@ -50,11 +51,16 @@ class SketchAPI_BSpline;
 class SketchAPI_IntersectionPoint;
 class SketchAPI_Line;
 class SketchAPI_Mirror;
+class SketchAPI_Offset;
 class SketchAPI_Point;
 class SketchAPI_Projection;
 class SketchAPI_Rectangle;
 class SketchAPI_Rotation;
 class SketchAPI_Translation;
+class SketchAPI_MacroMiddlePoint;
+
+//--------------------------------------------------------------------------------------
+typedef std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> PointOrReference;
 //--------------------------------------------------------------------------------------
 /**\class SketchAPI_Sketch
  * \ingroup CPPHighAPI
@@ -137,7 +143,7 @@ public:
   std::shared_ptr<SketchAPI_Point> addPoint(const ModelHighAPI_Selection & theExternal);
   /// Add point
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Point> addPoint(const std::string & theExternalName);
+  std::shared_ptr<SketchAPI_Point> addPoint(const std::wstring & theExternalName);
 
   /// Add intersection point
   SKETCHAPI_EXPORT
@@ -147,7 +153,7 @@ public:
   /// Add point
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_IntersectionPoint>
-    addIntersectionPoint(const std::string & theExternalName,
+    addIntersectionPoint(const std::wstring & theExternalName,
                          bool theKeepResult = false);
 
   /// Add line
@@ -164,7 +170,7 @@ public:
   std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
   /// Add line
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
+  std::shared_ptr<SketchAPI_Line> addLine(const std::wstring & theExternalName);
 
   /// Add rectangle
   SKETCHAPI_EXPORT
@@ -175,45 +181,101 @@ public:
   std::shared_ptr<SketchAPI_Rectangle> addRectangle(
       const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
       const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
+  /// Add rectangle
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Rectangle> addRectangleCentered(
+      const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & theCenter,
+      const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr> & theCorner);
 
-  /// Add circle
+  /// Add circle.
+  /// [DEPRECATED]: use addCircleWithPoint() instead.
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_Circle> addCircle(
       double theCenterX, double theCenterY,
       double theRadius);
-  /// Add circle
+  /// Add circle.
+  /// [DEPRECATED]: use addCircleWithPoint() instead.
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_Circle> addCircle(
       const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
       double theRadius);
-  /// Add circle
+  /// Add circle.
+  /// [DEPRECATED]: use addCircleWithPoint() instead.
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
       double theCenterX, double theCenterY,
       double thePassedX, double thePassedY);
-  /// Add circle
+  /// Add circle.
+  /// [DEPRECATED]: use addCircleWithPoint() instead.
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
       const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
       const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
-  /// Add circle
+  /// Add circle.
+  /// [DEPRECATED]: use addCircleWithPoint() instead.
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
       double theX1, double theY1,
       double theX2, double theY2,
       double theX3, double theY3);
-  /// Add circle
+  /// Add circle.
+  /// [DEPRECATED]: use addCircleWithPoint() instead.
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_MacroCircle> addCircle(
       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
       const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3);
-  /// Add circle
+  /// Add circle.
+  /// [DEPRECATED]: use addCircleWithPoint() instead.
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_Circle> addCircle(const ModelHighAPI_Selection & theExternal);
-  /// Add circle
+  /// Add circle.
+  /// [DEPRECATED]: use addCircleWithPoint() instead.
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_Circle> addCircle(const std::wstring & theExternalName);
+
+  /// Add circle with point
+  SKETCHAPI_EXPORT
+    std::shared_ptr<SketchAPI_Circle> addCircleWithPoint(
+      double theCenterX, double theCenterY,
+      double theRadius, double theAngle);
+  /// Add circle with point
+  SKETCHAPI_EXPORT
+    std::shared_ptr<SketchAPI_Circle> addCircleWithPoint(
+      const std::shared_ptr<GeomAPI_Pnt2d>& theCenter,
+      double theRadius, double theAngle);
+  /// Add circle with point
+  SKETCHAPI_EXPORT
+    std::shared_ptr<SketchAPI_MacroCircle> addCircleWithPoint(
+      double theCenterX, double theCenterY,
+      double thePassedX, double thePassedY,
+      double theAngle);
+  /// Add circle with point
+  SKETCHAPI_EXPORT
+    std::shared_ptr<SketchAPI_MacroCircle> addCircleWithPoint(
+      const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
+      const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint,
+      double theAngle);
+  /// Add circle with point
+  SKETCHAPI_EXPORT
+    std::shared_ptr<SketchAPI_MacroCircle> addCircleWithPoint(
+      double theX1, double theY1,
+      double theX2, double theY2,
+      double theX3, double theY3,
+      double theAngle);
+  /// Add circle with point
+  SKETCHAPI_EXPORT
+    std::shared_ptr<SketchAPI_MacroCircle> addCircleWithPoint(
+      const std::shared_ptr<GeomAPI_Pnt2d>& thePoint1,
+      const std::shared_ptr<GeomAPI_Pnt2d>& thePoint2,
+      const std::shared_ptr<GeomAPI_Pnt2d>& thePoint3,
+      double theAngle);
+  /// Add circle with point
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Circle> addCircle(const std::string & theExternalName);
+    std::shared_ptr<SketchAPI_Circle> addCircleWithPoint(const ModelHighAPI_Selection& theExternal);
+  /// Add circle with point
+  SKETCHAPI_EXPORT
+    std::shared_ptr<SketchAPI_Circle> addCircleWithPoint(const std::wstring& theExternalName);
 
   /// Add arc
   SKETCHAPI_EXPORT
@@ -267,7 +329,7 @@ public:
 
   /// Add arc
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
+  std::shared_ptr<SketchAPI_Arc> addArc(const std::wstring & theExternalName);
 
   /// Add ellipse
   SKETCHAPI_EXPORT
@@ -291,16 +353,16 @@ public:
   /// Add ellipse
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_MacroEllipse> addEllipse(
-      const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePoint1,
-      const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePoint2,
-      const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& thePassedPoint,
+      const PointOrReference& thePoint1,
+      const PointOrReference& thePoint2,
+      const PointOrReference& thePassedPoint,
       bool isPoint1Center = true);
   /// Add ellipse
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_Ellipse> addEllipse(const ModelHighAPI_Selection & theExternal);
   /// Add ellipse
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Ellipse> addEllipse(const std::string & theExternalName);
+  std::shared_ptr<SketchAPI_Ellipse> addEllipse(const std::wstring & theExternalName);
 
   /// Add elliptic arc
   SKETCHAPI_EXPORT
@@ -313,40 +375,50 @@ public:
   /// Add elliptic arc
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_MacroEllipticArc> addEllipticArc(
-      const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theCenter,
-      const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theMajorAxisPoint,
-      const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theStartPoint,
-      const std::pair<std::shared_ptr<GeomAPI_Pnt2d>, ModelHighAPI_RefAttr>& theEndPoint,
+      const PointOrReference& theCenter,
+      const PointOrReference& theMajorAxisPoint,
+      const PointOrReference& theStartPoint,
+      const PointOrReference& theEndPoint,
       bool theInversed = false);
   /// Add elliptic arc
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(const ModelHighAPI_Selection & theExternal);
   /// Add elliptic arc
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(const std::string & theExternalName);
+  std::shared_ptr<SketchAPI_EllipticArc> addEllipticArc(const std::wstring & theExternalName);
 
   /// Add B-spline
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_BSpline> addSpline(
       const ModelHighAPI_Selection & external = ModelHighAPI_Selection(),
       const int degree = -1,
-      const std::list<std::shared_ptr<GeomAPI_Pnt2d> >& poles =
-                                          std::list<std::shared_ptr<GeomAPI_Pnt2d> >(),
+      const std::list<PointOrReference>& poles = std::list<PointOrReference>(),
       const std::list<ModelHighAPI_Double>& weights = std::list<ModelHighAPI_Double>(),
       const std::list<ModelHighAPI_Double>& knots = std::list<ModelHighAPI_Double>(),
       const std::list<ModelHighAPI_Integer>& multiplicities = std::list<ModelHighAPI_Integer>(),
       const bool periodic = false);
 
-  /// Add projection
+  /// Add interpolation feature
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Projection> addProjection(
-      const ModelHighAPI_Selection & theExternalFeature,
-      bool theKeepResult = false);
+  std::shared_ptr<SketchAPI_BSpline> addInterpolation(
+      const std::list<ModelHighAPI_RefAttr>& points,
+      const bool periodic = false,
+      const bool closed = false);
+
+  /// Add approximation feature
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_BSpline> addApproximation(
+      const std::list<ModelHighAPI_RefAttr>& points,
+      const ModelHighAPI_Double& precision = ModelHighAPI_Double(1.e-3),
+      const bool periodic = false,
+      const bool closed = false);
 
   /// Add projection
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
-                                                      bool theKeepResult = false);
+  std::shared_ptr<SketchAPI_Projection> addProjection(
+      const ModelHighAPI_Selection & theExternalFeature,
+      bool keepResult = false,
+      bool keepRefToOriginal = true);
 
   /// Add mirror
   SKETCHAPI_EXPORT
@@ -354,6 +426,15 @@ public:
       const ModelHighAPI_RefAttr & theMirrorLine,
       const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects);
 
+  /// Add offset
+  SKETCHAPI_EXPORT
+    std::shared_ptr<SketchAPI_Offset> addOffset(
+      const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects,
+      const ModelHighAPI_Double & theValue,
+      const bool theReversed = false,
+      const std::string & theJointType = SketchPlugin_Offset::JOINT_KEEP_DISTANCE(),
+      const bool theApprox = false);
+
   /// Add translation
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_Translation> addTranslation(
@@ -494,6 +575,11 @@ public:
       const ModelHighAPI_RefAttr & thePoint,
       const ModelHighAPI_RefAttr & theLine);
 
+  /// Set middle
+  SKETCHAPI_EXPORT
+    std::shared_ptr<SketchAPI_MacroMiddlePoint> setMiddlePoint(
+      const ModelHighAPI_RefAttr& theLine);
+
   /// Set parallel
   SKETCHAPI_EXPORT
   std::shared_ptr<ModelHighAPI_Interface> setParallel(
@@ -559,6 +645,8 @@ protected:
 //! Pointer on Sketch object
 typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
 
+//--------------------------------------------------------------------------------------
+
 /**\ingroup CPPHighAPI
  * \brief Create Sketch feature
  */
@@ -578,7 +666,7 @@ SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
  */
 SKETCHAPI_EXPORT
 SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
-                    const std::string & theExternalName);
+                    const std::wstring & theExternalName);
 
 /**\ingroup CPPHighAPI
  * \brief Create Sketch feature
@@ -588,5 +676,13 @@ SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
                     std::shared_ptr<ModelAPI_Object> thePlaneObject);
 
 //--------------------------------------------------------------------------------------
+
+/** \ingroup CPPHighAPI
+ *  \brief Copy sketch with all its sub-features
+ */
+SKETCHAPI_EXPORT
+SketchPtr copySketch(const std::shared_ptr<ModelAPI_Document> & thePart,
+                     const SketchPtr & theSketch);
+
 //--------------------------------------------------------------------------------------
 #endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */