Salome HOME
Merge remote-tracking branch 'remotes/origin/Filters_Development_2'
[modules/shaper.git] / src / SketchAPI / SketchAPI_Sketch.h
index 545095521762a3209bf3e5306123323bbaa9db17..8b3237f7f04df08e3cb8e3da1dbf4a4e49185f90 100644 (file)
@@ -1,8 +1,21 @@
-// Name   : SketchAPI_Sketch.h
-// Purpose: 
+// Copyright (C) 2014-2019  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
-// History:
-// 07/06/16 - Sergey POKHODENKO - Creation of the file
 
 #ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
 #define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
@@ -23,9 +36,12 @@ class ModelAPI_Object;
 class ModelHighAPI_Double;
 class ModelHighAPI_Integer;
 class ModelHighAPI_RefAttr;
+class ModelHighAPI_Reference;
 class ModelHighAPI_Selection;
 class SketchAPI_Arc;
+class SketchAPI_MacroArc;
 class SketchAPI_Circle;
+class SketchAPI_MacroCircle;
 class SketchAPI_IntersectionPoint;
 class SketchAPI_Line;
 class SketchAPI_Mirror;
@@ -62,19 +78,31 @@ public:
   virtual ~SketchAPI_Sketch();
 
   INTERFACE_7(SketchPlugin_Sketch::ID(),
-              origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */,
-              dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */,
-              normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */,
-              features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */,
-              external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */,
-              solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */,
-              solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */
+              origin, SketchPlugin_Sketch::ORIGIN_ID(),
+              GeomDataAPI_Point, /** Origin point */,
+              dirX, SketchPlugin_Sketch::DIRX_ID(),
+              GeomDataAPI_Dir, /** Direction of X */,
+              normal, SketchPlugin_Sketch::NORM_ID(),
+              GeomDataAPI_Dir, /** Normal */,
+              features, SketchPlugin_Sketch::FEATURES_ID(),
+              ModelAPI_AttributeRefList, /** Features */,
+              external, SketchPlugin_SketchEntity::EXTERNAL_ID(),
+              ModelAPI_AttributeSelection, /** External */,
+              solverError, SketchPlugin_Sketch::SOLVER_ERROR(),
+              ModelAPI_AttributeString, /** Solver error */,
+              solverDOF, SketchPlugin_Sketch::SOLVER_DOF(),
+              ModelAPI_AttributeString, /** Solver DOF */
   )
 
   /// Set plane
   SKETCHAPI_EXPORT
   void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
 
+  /// Change sketch plane
+  SKETCHAPI_EXPORT
+  void setPlane(const ModelHighAPI_Selection & thePlane,
+                bool theRemoveExternalDependency = false);
+
   /// Set external
   SKETCHAPI_EXPORT
   void setExternal(const ModelHighAPI_Selection & theExternal);
@@ -83,6 +111,10 @@ public:
   SKETCHAPI_EXPORT
   void setExternal(std::shared_ptr<ModelAPI_Object> thePlaneObject);
 
+  /// List points not connected by constraints with other sketch entitites
+  SKETCHAPI_EXPORT
+  std::list< std::shared_ptr<SketchAPI_Point> > getFreePoints();
+
   /// Add point
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_Point> addPoint(
@@ -100,10 +132,14 @@ public:
 
   /// Add intersection point
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const ModelHighAPI_Selection & theExternal);
+  std::shared_ptr<SketchAPI_IntersectionPoint>
+    addIntersectionPoint(const ModelHighAPI_Selection & theExternal,
+                         bool theKeepResult = false);
   /// Add point
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_IntersectionPoint> addIntersectionPoint(const std::string & theExternalName);
+  std::shared_ptr<SketchAPI_IntersectionPoint>
+    addIntersectionPoint(const std::string & theExternalName,
+                         bool theKeepResult = false);
 
   /// Add line
   SKETCHAPI_EXPORT
@@ -143,13 +179,23 @@ public:
       double theRadius);
   /// Add circle
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Circle> addCircle(
+  std::shared_ptr<SketchAPI_MacroCircle> addCircle(
+      double theCenterX, double theCenterY,
+      double thePassedX, double thePassedY);
+  /// Add circle
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_MacroCircle> addCircle(
+      const std::shared_ptr<GeomAPI_Pnt2d>& theCenterPoint,
+      const std::shared_ptr<GeomAPI_Pnt2d>& thePassedPoint);
+  /// Add circle
+  SKETCHAPI_EXPORT
+  std::shared_ptr<SketchAPI_MacroCircle> addCircle(
       double theX1, double theY1,
       double theX2, double theY2,
       double theX3, double theY3);
   /// Add circle
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Circle> addCircle(
+  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);
@@ -178,28 +224,28 @@ public:
 
   /// Add arc
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Arc> addArc(
+  std::shared_ptr<SketchAPI_MacroArc> addArc(
       double theStartX, double theStartY,
       double theEndX, double theEndY,
       double thePassedX, double thePassedY);
 
   /// Add arc
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Arc> addArc(
+  std::shared_ptr<SketchAPI_MacroArc> addArc(
       const std::shared_ptr<GeomAPI_Pnt2d>& theStart,
       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
       const std::shared_ptr<GeomAPI_Pnt2d>& thePassed);
 
   /// Add arc
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Arc> addArc(
+  std::shared_ptr<SketchAPI_MacroArc> addArc(
       const ModelHighAPI_RefAttr& theTangentPoint,
       double theEndX, double theEndY,
       bool theInversed);
 
   /// Add arc
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Arc> addArc(
+  std::shared_ptr<SketchAPI_MacroArc> addArc(
       const ModelHighAPI_RefAttr& theTangentPoint,
       const std::shared_ptr<GeomAPI_Pnt2d>& theEnd,
       bool theInversed);
@@ -215,11 +261,13 @@ public:
   /// Add projection
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_Projection> addProjection(
-      const ModelHighAPI_Selection & theExternalFeature);
+      const ModelHighAPI_Selection & theExternalFeature,
+      bool theKeepResult = false);
 
   /// Add projection
   SKETCHAPI_EXPORT
-  std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName);
+  std::shared_ptr<SketchAPI_Projection> addProjection(const std::string & theExternalName,
+                                                      bool theKeepResult = false);
 
   /// Add mirror
   SKETCHAPI_EXPORT
@@ -243,117 +291,177 @@ public:
       const ModelHighAPI_RefAttr & theCenter,
       const ModelHighAPI_Double & theAngle,
       const ModelHighAPI_Integer & theNumberOfObjects,
-      bool theFullValue = false);
+      bool theFullValue = false,
+      bool theReversed  = false);
+
+  /// Add split
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelHighAPI_Interface> addSplit(
+      const ModelHighAPI_Reference& theFeature,
+      const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
+
+  /// Add trim
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelHighAPI_Interface> addTrim(
+      const ModelHighAPI_Reference& theFeature,
+      const std::shared_ptr<GeomAPI_Pnt2d>& thePositionPoint);
 
   /// Set angle
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setAngle(
+  std::shared_ptr<ModelHighAPI_Interface> setAngle(
       const ModelHighAPI_RefAttr & theLine1,
       const ModelHighAPI_RefAttr & theLine2,
       const ModelHighAPI_Double & theValue);
 
   /// Set complementary angle
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setAngleComplementary(
+  std::shared_ptr<ModelHighAPI_Interface> setAngleComplementary(
       const ModelHighAPI_RefAttr & theLine1,
       const ModelHighAPI_RefAttr & theLine2,
       const ModelHighAPI_Double & theValue);
 
   /// Set backward angle (= 360 - angle)
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setAngleBackward(
+  std::shared_ptr<ModelHighAPI_Interface> setAngleBackward(
       const ModelHighAPI_RefAttr & theLine1,
       const ModelHighAPI_RefAttr & theLine2,
       const ModelHighAPI_Double & theValue);
 
   /// Set coincident
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setCoincident(
+  std::shared_ptr<ModelHighAPI_Interface> setCoincident(
       const ModelHighAPI_RefAttr & thePoint1,
       const ModelHighAPI_RefAttr & thePoint2);
 
   /// Set collinear
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setCollinear(
+  std::shared_ptr<ModelHighAPI_Interface> setCollinear(
       const ModelHighAPI_RefAttr & theLine1,
       const ModelHighAPI_RefAttr & theLine2);
 
   /// Set distance
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setDistance(
+  std::shared_ptr<ModelHighAPI_Interface> setDistance(
       const ModelHighAPI_RefAttr & thePoint,
       const ModelHighAPI_RefAttr & thePointOrLine,
+      const ModelHighAPI_Double & theValue,
+      bool isSigned = false);
+
+  /// Set signed distance
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelHighAPI_Interface> setSignedDistance(
+      const ModelHighAPI_RefAttr & thePoint,
+      const ModelHighAPI_RefAttr & thePointOrLine,
+      const ModelHighAPI_Double & theValue);
+
+  /// Set unsigned distance
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelHighAPI_Interface> setUnsignedDistance(
+      const ModelHighAPI_RefAttr & thePoint,
+      const ModelHighAPI_RefAttr & thePointOrLine,
+      const ModelHighAPI_Double & theValue);
+
+  /// Set horizontal distance
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelHighAPI_Interface> setHorizontalDistance(
+      const ModelHighAPI_RefAttr & thePoint1,
+      const ModelHighAPI_RefAttr & thePoint2,
+      const ModelHighAPI_Double & theValue);
+
+  /// Set vertical distance
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelHighAPI_Interface> setVerticalDistance(
+      const ModelHighAPI_RefAttr & thePoint1,
+      const ModelHighAPI_RefAttr & thePoint2,
       const ModelHighAPI_Double & theValue);
 
   /// Set equal
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setEqual(
+  std::shared_ptr<ModelHighAPI_Interface> setEqual(
       const ModelHighAPI_RefAttr & theObject1,
       const ModelHighAPI_RefAttr & theObject2);
 
   /// Set fillet
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setFillet(
-      const std::list<ModelHighAPI_RefAttr> & thePoints,
+  std::shared_ptr<ModelHighAPI_Interface> setFillet(
+      const ModelHighAPI_RefAttr & thePoint);
+
+  /// Set fillet with additional radius constraint
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelHighAPI_Interface> setFilletWithRadius(
+      const ModelHighAPI_RefAttr & thePoint,
       const ModelHighAPI_Double & theRadius);
 
   /// Set fixed
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setFixed(
+  std::shared_ptr<ModelHighAPI_Interface> setFixed(
       const ModelHighAPI_RefAttr & theObject);
 
   /// Set horizontal
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setHorizontal(
+  std::shared_ptr<ModelHighAPI_Interface> setHorizontal(
       const ModelHighAPI_RefAttr & theLine);
 
   /// Set length
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setLength(
+  std::shared_ptr<ModelHighAPI_Interface> setLength(
       const ModelHighAPI_RefAttr & theLine,
       const ModelHighAPI_Double & theValue);
 
   /// Set middle
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setMiddlePoint(
+  std::shared_ptr<ModelHighAPI_Interface> setMiddlePoint(
       const ModelHighAPI_RefAttr & thePoint,
       const ModelHighAPI_RefAttr & theLine);
 
   /// Set parallel
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setParallel(
+  std::shared_ptr<ModelHighAPI_Interface> setParallel(
       const ModelHighAPI_RefAttr & theLine1,
       const ModelHighAPI_RefAttr & theLine2);
 
   /// Set perpendicular
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setPerpendicular(
+  std::shared_ptr<ModelHighAPI_Interface> setPerpendicular(
       const ModelHighAPI_RefAttr & theLine1,
       const ModelHighAPI_RefAttr & theLine2);
 
   /// Set radius
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setRadius(
+  std::shared_ptr<ModelHighAPI_Interface> setRadius(
       const ModelHighAPI_RefAttr & theCircleOrArc,
       const ModelHighAPI_Double & theValue);
 
   /// Set tangent
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setTangent(
+  std::shared_ptr<ModelHighAPI_Interface> setTangent(
       const ModelHighAPI_RefAttr & theLine,
       const ModelHighAPI_RefAttr & theCircle);
 
   /// Set vertical
   SKETCHAPI_EXPORT
-  std::shared_ptr<ModelAPI_Feature> setVertical(
+  std::shared_ptr<ModelHighAPI_Interface> setVertical(
       const ModelHighAPI_RefAttr & theLine);
 
   /// Set constraint value
   SKETCHAPI_EXPORT
   void setValue(
-      const std::shared_ptr<ModelAPI_Feature> & theConstraint,
+      const std::shared_ptr<ModelHighAPI_Interface> & theConstraint,
       const ModelHighAPI_Double & theValue);
 
+  /// Move point or sketch feature
+  SKETCHAPI_EXPORT
+  void move(const ModelHighAPI_RefAttr& theMovedEntity,
+            const std::shared_ptr<GeomAPI_Pnt2d>& theTargetPoint);
+
+  /// Move point or sketch feature
+  SKETCHAPI_EXPORT
+  void move(const ModelHighAPI_RefAttr& theMovedEntity,
+            double theTargetX, double theTargetY);
+
+  SKETCHAPI_EXPORT
+  std::shared_ptr<GeomAPI_Pnt2d> to2D(const std::shared_ptr<GeomAPI_Pnt>& thePoint);
+
   // TODO(spo): rename to selectFaces() or faces() (or add faces() -> list to SWIG)
   /// Select face
   SKETCHAPI_EXPORT