]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add setAngle, setCollinear, setEqual, setMiddlePoint, setRadius, setTangent
authorspo <sergey.pokhodenko@opencascade.com>
Wed, 15 Jun 2016 14:19:06 +0000 (17:19 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Fri, 17 Jun 2016 11:41:10 +0000 (14:41 +0300)
src/SketchAPI/SketchAPI_Sketch.cpp
src/SketchAPI/SketchAPI_Sketch.h

index cdac5d4c5912966298d2224773e8fa8f351caf56..bf9fdd1c51395fe384334a6fad2192b507caa4a0 100644 (file)
@@ -314,6 +314,21 @@ std::shared_ptr<SketchAPI_Arc> SketchAPI_Sketch::addArc(const std::string & theE
 }
 
 //--------------------------------------------------------------------------------------
+std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setAngle(
+    const ModelHighAPI_RefAttr & theLine1,
+    const ModelHighAPI_RefAttr & theLine2,
+    const ModelHighAPI_Double & theValue)
+{
+  // TODO(spo): is support of angle type necessary?
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+      compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
+  fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
+  fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
+  fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
+  aFeature->execute();
+  return aFeature;
+}
+
 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setCoincident(
     const ModelHighAPI_RefAttr & thePoint1,
     const ModelHighAPI_RefAttr & thePoint2)
@@ -326,20 +341,44 @@ std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setCoincident(
   return aFeature;
 }
 
+std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setCollinear(
+    const ModelHighAPI_RefAttr & theLine1,
+    const ModelHighAPI_RefAttr & theLine2)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+      compositeFeature()->addFeature(SketchPlugin_ConstraintCollinear::ID());
+  fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
+  fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
+  aFeature->execute();
+  return aFeature;
+}
+
 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setDistance(
     const ModelHighAPI_RefAttr & thePoint,
-    const ModelHighAPI_RefAttr & theLine,
+    const ModelHighAPI_RefAttr & thePointOrLine,
     const ModelHighAPI_Double & theValue)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature =
       compositeFeature()->addFeature(SketchPlugin_ConstraintDistance::ID());
   fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
-  fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
+  fillAttribute(thePointOrLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
   fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
   aFeature->execute();
   return aFeature;
 }
 
+std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setEqual(
+    const ModelHighAPI_RefAttr & theObject1,
+    const ModelHighAPI_RefAttr & theObject2)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+      compositeFeature()->addFeature(SketchPlugin_ConstraintEqual::ID());
+  fillAttribute(theObject1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
+  fillAttribute(theObject2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
+  aFeature->execute();
+  return aFeature;
+}
+
 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setFillet(
     const std::list<ModelHighAPI_RefAttr> & thePoints,
     const ModelHighAPI_Double & theRadius)
@@ -374,6 +413,18 @@ std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setLength(
   return aFeature;
 }
 
+std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setMiddlePoint(
+    const ModelHighAPI_RefAttr & thePoint,
+    const ModelHighAPI_RefAttr & theLine)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+      compositeFeature()->addFeature(SketchPlugin_ConstraintMiddle::ID());
+  fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
+  fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
+  aFeature->execute();
+  return aFeature;
+}
+
 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setParallel(
     const ModelHighAPI_RefAttr & theLine1,
     const ModelHighAPI_RefAttr & theLine2)
@@ -398,9 +449,22 @@ std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setPerpendicular(
   return aFeature;
 }
 
+std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setRadius(
+    const ModelHighAPI_RefAttr & theCircleOrArc,
+    const ModelHighAPI_Double & theValue)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+      compositeFeature()->addFeature(SketchPlugin_ConstraintRadius::ID());
+  fillAttribute(theCircleOrArc, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
+  fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
+  aFeature->execute();
+  return aFeature;
+}
+
 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setRigid(
     const ModelHighAPI_RefAttr & theObject)
 {
+  // TODO(spo): should it be renamed to Fixed?
   std::shared_ptr<ModelAPI_Feature> aFeature =
       compositeFeature()->addFeature(SketchPlugin_ConstraintRigid::ID());
   fillAttribute(theObject, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
@@ -408,6 +472,18 @@ std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setRigid(
   return aFeature;
 }
 
+std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setTangent(
+    const ModelHighAPI_RefAttr & theLine,
+    const ModelHighAPI_RefAttr & theCircle)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature =
+      compositeFeature()->addFeature(SketchPlugin_ConstraintTangent::ID());
+  fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
+  fillAttribute(theCircle, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
+  aFeature->execute();
+  return aFeature;
+}
+
 std::shared_ptr<ModelAPI_Feature> SketchAPI_Sketch::setVertical(
     const ModelHighAPI_RefAttr & theLine)
 {
index 8108524abea2ec975e3fb05e4a0ad732ddb957f9..50d17a36474513071c154b054f35799498ffc1f9 100644 (file)
@@ -181,19 +181,38 @@ public:
   SKETCHAPI_EXPORT
   std::shared_ptr<SketchAPI_Arc> addArc(const std::string & theExternalName);
 
+  /// Set angle
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelAPI_Feature> setAngle(
+      const ModelHighAPI_RefAttr & theLine1,
+      const ModelHighAPI_RefAttr & theLine2,
+      const ModelHighAPI_Double & theValue);
+
   /// Set coincident
   SKETCHAPI_EXPORT
   std::shared_ptr<ModelAPI_Feature> setCoincident(
       const ModelHighAPI_RefAttr & thePoint1,
       const ModelHighAPI_RefAttr & thePoint2);
 
+  /// Set collinear
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelAPI_Feature> setCollinear(
+      const ModelHighAPI_RefAttr & theLine1,
+      const ModelHighAPI_RefAttr & theLine2);
+
   /// Set distance
   SKETCHAPI_EXPORT
   std::shared_ptr<ModelAPI_Feature> setDistance(
       const ModelHighAPI_RefAttr & thePoint,
-      const ModelHighAPI_RefAttr & theLine,
+      const ModelHighAPI_RefAttr & thePointOrLine,
       const ModelHighAPI_Double & theValue);
 
+  /// Set equal
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelAPI_Feature> setEqual(
+      const ModelHighAPI_RefAttr & theObject1,
+      const ModelHighAPI_RefAttr & theObject2);
+
   /// Set fillet
   SKETCHAPI_EXPORT
   std::shared_ptr<ModelAPI_Feature> setFillet(
@@ -211,6 +230,14 @@ public:
       const ModelHighAPI_RefAttr & theLine,
       const ModelHighAPI_Double & theValue);
 
+  /// Set middle
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelAPI_Feature> setMiddlePoint(
+      const ModelHighAPI_RefAttr & thePoint,
+      const ModelHighAPI_RefAttr & theLine);
+
+  // TODO(spo): setMirror
+
   /// Set parallel
   SKETCHAPI_EXPORT
   std::shared_ptr<ModelAPI_Feature> setParallel(
@@ -223,19 +250,29 @@ public:
       const ModelHighAPI_RefAttr & theLine1,
       const ModelHighAPI_RefAttr & theLine2);
 
+  /// Set radius
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelAPI_Feature> setRadius(
+      const ModelHighAPI_RefAttr & theCircleOrArc,
+      const ModelHighAPI_Double & theValue);
+
   /// Set rigid
   SKETCHAPI_EXPORT
   std::shared_ptr<ModelAPI_Feature> setRigid(
       const ModelHighAPI_RefAttr & theObject);
 
+  /// Set tangent
+  SKETCHAPI_EXPORT
+  std::shared_ptr<ModelAPI_Feature> setTangent(
+      const ModelHighAPI_RefAttr & theLine,
+      const ModelHighAPI_RefAttr & theCircle);
+
   /// Set vertical
   SKETCHAPI_EXPORT
   std::shared_ptr<ModelAPI_Feature> setVertical(
       const ModelHighAPI_RefAttr & theLine);
 
-  // TODO(spo): set* (constraints)
-
-  // TODO(spo): addMirror
+  // TODO(spo): addRectagle, projection, Translation, Rotation
 
   /// Set constraint value
   SKETCHAPI_EXPORT