]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
SketchPlugin refactoring
authorazv <azv@opencascade.com>
Tue, 26 Dec 2017 06:46:33 +0000 (09:46 +0300)
committerazv <azv@opencascade.com>
Tue, 26 Dec 2017 10:08:50 +0000 (13:08 +0300)
src/SketchPlugin/SketchPlugin_Fillet.cpp
src/SketchPlugin/SketchPlugin_Fillet.h
src/SketchPlugin/SketchPlugin_MacroArc.cpp
src/SketchPlugin/SketchPlugin_MacroCircle.cpp
src/SketchPlugin/SketchPlugin_MacroEllipse.cpp
src/SketchPlugin/SketchPlugin_Split.cpp
src/SketchPlugin/SketchPlugin_Split.h
src/SketchPlugin/SketchPlugin_Tools.cpp
src/SketchPlugin/SketchPlugin_Tools.h
src/SketchPlugin/SketchPlugin_Trim.cpp
src/SketchPlugin/SketchPlugin_Trim.h

index 36e6714ab563d594961690f23d02bb054de1eeac..ab0dedbea5517d3032d159e993a513d760a644e0 100644 (file)
@@ -75,9 +75,6 @@ static void calculateFilletCenter(FeaturePtr theFilletFeatures[2],
                                   std::shared_ptr<GeomAPI_XY>& theTangentA,
                                   std::shared_ptr<GeomAPI_XY>& theTangentB);
 
-/// Get coincide edges for fillet
-static std::set<FeaturePtr> getCoincides(const FeaturePtr& theConstraintCoincidence);
-
 static std::set<FeaturePtr> findFeaturesToRemove(const FeaturePtr theFeature,
                                                  const AttributePtr theAttribute);
 
@@ -102,33 +99,8 @@ void SketchPlugin_Fillet::execute()
   // set flag here to avoid building Fillet presentation if "Redisplay" event appears
   myFilletCreated = true;
 
-  // Calculate Fillet parameters if does not yet
-  if (!myBaseFeatures[0] || !myBaseFeatures[1])
-    calculateFilletParameters();
-
-  // Create arc feature.
-  FeaturePtr aFilletArc = sketch()->addFeature(SketchPlugin_Arc::ID());
-
-  // Set arc attributes.
-  bool aWasBlocked = aFilletArc->data()->blockSendAttributeUpdated(true);
-  std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-      aFilletArc->attribute(SketchPlugin_Arc::CENTER_ID()))->setValue(myCenterXY->x(),
-                                                                      myCenterXY->y());
-  std::shared_ptr<GeomDataAPI_Point2D> aStartPoint =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-          aFilletArc->attribute(SketchPlugin_Arc::START_ID()));
-  std::shared_ptr<GeomDataAPI_Point2D> aEndPoint =
-      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
-          aFilletArc->attribute(SketchPlugin_Arc::END_ID()));
-  if(aStartPoint->isInitialized() && aEndPoint->isInitialized()
-      && (aStartPoint->pnt()->xy()->distance(myTangentXY1) > tolerance
-      || aEndPoint->pnt()->xy()->distance(myTangentXY2) > tolerance)) {
-    std::dynamic_pointer_cast<SketchPlugin_Arc>(aFilletArc)->setReversed(false);
-  }
-  aStartPoint->setValue(myTangentXY1->x(), myTangentXY1->y());
-  aEndPoint->setValue(myTangentXY2->x(), myTangentXY2->y());
-  aFilletArc->data()->blockSendAttributeUpdated(aWasBlocked);
-  aFilletArc->execute();
+  // create feature for fillet arc
+  FeaturePtr aFilletArc = createFilletArc();
 
   // Delete features with refs to points of edges.
   std::shared_ptr<GeomDataAPI_Point2D> aStartPoint1;
@@ -157,37 +129,26 @@ void SketchPlugin_Fillet::execute()
   recalculateAttributes(aFilletArc, SketchPlugin_Arc::END_ID(),
                         myBaseFeatures[aFeatInd2], myFeatAttributes[anAttrInd2]);
 
+  FeaturePtr aConstraint;
+
   // Create coincidence features.
-  FeaturePtr aConstraint = sketch()->addFeature(SketchPlugin_ConstraintCoincidence::ID());
-  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-      aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  aRefAttr->setAttr(aFilletArc->attribute(SketchPlugin_Arc::START_ID()));
-  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-      aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  aRefAttr->setAttr(myBaseFeatures[aFeatInd1]->attribute(myFeatAttributes[anAttrInd1]));
-  aConstraint->execute();
+  aConstraint = SketchPlugin_Tools::createConstraint(sketch(),
+                    SketchPlugin_ConstraintCoincidence::ID(),
+                    aFilletArc->attribute(SketchPlugin_Arc::START_ID()),
+                    myBaseFeatures[aFeatInd1]->attribute(myFeatAttributes[anAttrInd1]));
   ModelAPI_EventCreator::get()->sendUpdated(aConstraint, anUpdateEvent);
-  aConstraint = sketch()->addFeature(SketchPlugin_ConstraintCoincidence::ID());
-  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-      aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  aRefAttr->setAttr(aFilletArc->attribute(SketchPlugin_Arc::END_ID()));
-  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-      aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  aRefAttr->setAttr(myBaseFeatures[aFeatInd2]->attribute(myFeatAttributes[anAttrInd2]));
-  aConstraint->execute();
+  aConstraint = SketchPlugin_Tools::createConstraint(sketch(),
+                    SketchPlugin_ConstraintCoincidence::ID(),
+                    aFilletArc->attribute(SketchPlugin_Arc::END_ID()),
+                    myBaseFeatures[aFeatInd2]->attribute(myFeatAttributes[anAttrInd2]));
   ModelAPI_EventCreator::get()->sendUpdated(aConstraint, anUpdateEvent);
 
   // Create tangent features.
   for (int i = 0; i < 2; i++) {
-    aConstraint = sketch()->addFeature(SketchPlugin_ConstraintTangent::ID());
-    aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-        aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
-    aRefAttr->setObject(aFilletArc->lastResult());
-    aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-        aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
-    bool isArc = myBaseFeatures[i]->getKind() == SketchPlugin_Arc::ID();
-    aRefAttr->setObject(isArc ? myBaseFeatures[i]->lastResult() :
-                                myBaseFeatures[i]->firstResult());
+    aConstraint = SketchPlugin_Tools::createConstraint(sketch(),
+                      SketchPlugin_ConstraintTangent::ID(),
+                      aFilletArc->lastResult(),
+                      myBaseFeatures[i]->lastResult());
     aConstraint->execute();
     ModelAPI_EventCreator::get()->sendUpdated(aConstraint, anUpdateEvent);
   }
@@ -242,11 +203,17 @@ bool SketchPlugin_Fillet::calculateFilletParameters()
   if (!aFilletPoint2D.get())
     return false;
 
-  if (!findFeaturesContainingFilletPoint(aFilletPoint2D)) {
+  std::set<FeaturePtr> aFilletFeatures =
+      SketchPlugin_Tools::findFeaturesCoincidentToPoint(aFilletPoint2D);
+  if (aFilletFeatures.size() != 2) {
     setError("Error: Selected point does not have two suitable edges for fillet.");
     return false;
   }
 
+  std::set<FeaturePtr>::iterator aFIt = aFilletFeatures.begin();
+  myBaseFeatures[0] = *aFIt;
+  myBaseFeatures[1] = *(++aFIt);
+
   std::shared_ptr<GeomAPI_Pnt2d> aFilletPnt2d = aFilletPoint2D->pnt();
   double aRadius = calculateFilletRadius(myBaseFeatures);
 
@@ -326,49 +293,37 @@ bool SketchPlugin_Fillet::calculateFilletParameters()
   return true;
 }
 
-bool SketchPlugin_Fillet::findFeaturesContainingFilletPoint(
-    std::shared_ptr<GeomDataAPI_Point2D> theFilletPoint)
+FeaturePtr SketchPlugin_Fillet::createFilletArc()
 {
-  // Obtain constraint coincidence for the fillet point.
-  FeaturePtr aConstraintCoincidence;
-  const std::set<AttributePtr>& aRefsList = theFilletPoint->owner()->data()->refsToMe();
-  for(std::set<AttributePtr>::const_iterator anIt = aRefsList.cbegin();
-      anIt != aRefsList.cend();
-      ++anIt) {
-    std::shared_ptr<ModelAPI_Attribute> anAttr = (*anIt);
-    FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->owner());
-    if(aFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
-      AttributeRefAttrPtr anAttrRefA =
-          aFeature->refattr(SketchPlugin_ConstraintCoincidence::ENTITY_A());
-      AttributeRefAttrPtr anAttrRefB =
-          aFeature->refattr(SketchPlugin_ConstraintCoincidence::ENTITY_B());
-      if(anAttrRefA.get() && !anAttrRefA->isObject()) {
-        AttributePtr anAttrA = anAttrRefA->attr();
-        if(theFilletPoint == anAttrA) {
-          aConstraintCoincidence = aFeature;
-          break;
-        }
-      }
-      if(anAttrRefB.get() && !anAttrRefB->isObject()) {
-        AttributePtr anAttrB = anAttrRefB->attr();
-        if(theFilletPoint == anAttrB) {
-          aConstraintCoincidence = aFeature;
-          break;
-        }
-      }
-    }
-  }
+  // Calculate Fillet parameters if does not yet
+  if (!myBaseFeatures[0] || !myBaseFeatures[1])
+    calculateFilletParameters();
 
-  if(!aConstraintCoincidence.get())
-    return false;
+  // Create arc feature.
+  FeaturePtr aFilletArc = sketch()->addFeature(SketchPlugin_Arc::ID());
 
-  // Get coincide edges.
-  std::set<FeaturePtr> anEdgeFeatures = getCoincides(aConstraintCoincidence);
-  std::set<FeaturePtr>::iterator aLinesIt = anEdgeFeatures.begin();
-  for (int i = 0; aLinesIt != anEdgeFeatures.end() && i < 2; ++aLinesIt, ++i)
-    myBaseFeatures[i] = *aLinesIt;
+  // Set arc attributes.
+  bool aWasBlocked = aFilletArc->data()->blockSendAttributeUpdated(true);
+  std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+      aFilletArc->attribute(SketchPlugin_Arc::CENTER_ID()))->setValue(myCenterXY->x(),
+                                                                      myCenterXY->y());
+  std::shared_ptr<GeomDataAPI_Point2D> aStartPoint =
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+          aFilletArc->attribute(SketchPlugin_Arc::START_ID()));
+  std::shared_ptr<GeomDataAPI_Point2D> aEndPoint =
+      std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+          aFilletArc->attribute(SketchPlugin_Arc::END_ID()));
+  if(aStartPoint->isInitialized() && aEndPoint->isInitialized()
+      && (aStartPoint->pnt()->xy()->distance(myTangentXY1) > tolerance
+      || aEndPoint->pnt()->xy()->distance(myTangentXY2) > tolerance)) {
+    std::dynamic_pointer_cast<SketchPlugin_Arc>(aFilletArc)->setReversed(false);
+  }
+  aStartPoint->setValue(myTangentXY1->x(), myTangentXY1->y());
+  aEndPoint->setValue(myTangentXY2->x(), myTangentXY2->y());
+  aFilletArc->data()->blockSendAttributeUpdated(aWasBlocked);
+  aFilletArc->execute();
 
-  return myBaseFeatures[0] && myBaseFeatures[1];
+  return aFilletArc;
 }
 
 // =========   Auxiliary functions   =================
@@ -465,59 +420,6 @@ double calculateFilletRadius(FeaturePtr theFilletFeatures[2])
   return std::min(aLengths[0], aLengths[1]) / 6.0;
 }
 
-std::set<FeaturePtr> getCoincides(const FeaturePtr& theConstraintCoincidence)
-{
-  std::set<FeaturePtr> aCoincides;
-
-  std::shared_ptr<GeomAPI_Pnt2d> aFilletPnt =
-    SketchPlugin_Tools::getCoincidencePoint(theConstraintCoincidence);
-
-  SketchPlugin_Tools::findCoincidences(theConstraintCoincidence,
-                                       SketchPlugin_ConstraintCoincidence::ENTITY_A(),
-                                       aCoincides,
-                                       true);
-  SketchPlugin_Tools::findCoincidences(theConstraintCoincidence,
-                                       SketchPlugin_ConstraintCoincidence::ENTITY_B(),
-                                       aCoincides,
-                                       true);
-
-  // Remove points from set of coincides.
-  std::set<FeaturePtr> aNewSetOfCoincides;
-  for(std::set<FeaturePtr>::iterator anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) {
-    std::shared_ptr<SketchPlugin_SketchEntity> aSketchEntity =
-      std::dynamic_pointer_cast<SketchPlugin_SketchEntity>(*anIt);
-    if(aSketchEntity.get() && (aSketchEntity->isCopy() || aSketchEntity->isExternal())) {
-      continue;
-    }
-    if((*anIt)->getKind() == SketchPlugin_Line::ID()) {
-      aNewSetOfCoincides.insert(*anIt);
-    } else if((*anIt)->getKind() == SketchPlugin_Arc::ID()) {
-      AttributePtr anAttrCenter = (*anIt)->attribute(SketchPlugin_Arc::CENTER_ID());
-      std::shared_ptr<GeomDataAPI_Point2D> aPointCenter2D =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttrCenter);
-      if(aPointCenter2D.get() && aFilletPnt->isEqual(aPointCenter2D->pnt())) {
-        continue;
-      }
-      aNewSetOfCoincides.insert(*anIt);
-    }
-  }
-  aCoincides = aNewSetOfCoincides;
-
-  // If we still have more than two coincides remove auxilary entities from set of coincides.
-  if(aCoincides.size() > 2) {
-    aNewSetOfCoincides.clear();
-    for(std::set<FeaturePtr>::iterator
-        anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) {
-      if(!(*anIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) {
-        aNewSetOfCoincides.insert(*anIt);
-      }
-    }
-    aCoincides = aNewSetOfCoincides;
-  }
-
-  return aCoincides;
-}
-
 std::set<FeaturePtr> findFeaturesToRemove(const FeaturePtr theFeature,
                                           const AttributePtr theAttribute) {
   std::set<FeaturePtr> aFeaturesToBeRemoved;
index d178933e84809635044537151db53bfa84878fca..dfd4c4b0c118cbb4f48906c15575a0725831dbba 100644 (file)
@@ -83,6 +83,11 @@ class SketchPlugin_Fillet: public SketchPlugin_SketchEntity, public GeomAPI_IPre
 private:
   bool calculateFilletParameters();
 
+  /// Create new feature presenting a fillet arc and initialize its parameters
+  FeaturePtr createFilletArc();
+
+  void createCoincidenceWithFilletArc();
+
   bool findFeaturesContainingFilletPoint(std::shared_ptr<GeomDataAPI_Point2D> theFilletPoint);
 
 private:
index cae5ca0f4da4dfbc086b9c61673a22a820ed208b..8016c335395c701a1275e50b496c62415f0f5267 100644 (file)
@@ -309,40 +309,40 @@ void SketchPlugin_MacroArc::execute()
   // Create constraints.
   std::string anArcType = string(ARC_TYPE())->value();
   if(anArcType == ARC_TYPE_BY_CENTER_AND_POINTS()) {
-    SketchPlugin_Tools::createConstraint(this,
+    SketchPlugin_Tools::createCoincidenceOrTangency(this,
                                          CENTER_POINT_REF_ID(),
                                          anArcFeature->attribute(SketchPlugin_Arc::CENTER_ID()),
                                          ObjectPtr(),
                                          false);
-    SketchPlugin_Tools::createConstraint(this,
+    SketchPlugin_Tools::createCoincidenceOrTangency(this,
                                          START_POINT_REF_ID(),
                                          anArcFeature->attribute(SketchPlugin_Arc::START_ID()),
                                          ObjectPtr(),
                                          false);
-    SketchPlugin_Tools::createConstraint(this,
+    SketchPlugin_Tools::createCoincidenceOrTangency(this,
                                          END_POINT_REF_ID(),
                                          anArcFeature->attribute(SketchPlugin_Arc::END_ID()),
                                          ObjectPtr(),
                                          false);
   } else if(anArcType == ARC_TYPE_BY_THREE_POINTS()) {
-    SketchPlugin_Tools::createConstraint(this,
+    SketchPlugin_Tools::createCoincidenceOrTangency(this,
                                          START_POINT_REF_ID(),
                                          anArcFeature->attribute(SketchPlugin_Arc::START_ID()),
                                          ObjectPtr(),
                                          false);
-    SketchPlugin_Tools::createConstraint(this,
+    SketchPlugin_Tools::createCoincidenceOrTangency(this,
                                          END_POINT_REF_ID(),
                                          anArcFeature->attribute(SketchPlugin_Arc::END_ID()),
                                          ObjectPtr(),
                                          false);
-    SketchPlugin_Tools::createConstraint(this,
+    SketchPlugin_Tools::createCoincidenceOrTangency(this,
                                          PASSED_POINT_REF_ID(),
                                          AttributePtr(),
                                          anArcFeature->lastResult(),
                                          true);
   } else if(anArcType == ARC_TYPE_BY_TANGENT_EDGE()) {
     // constraints for tangent arc
-    SketchPlugin_Tools::createConstraint(this,
+    SketchPlugin_Tools::createCoincidenceOrTangency(this,
                                          TANGENT_POINT_ID(),
                                          anArcFeature->attribute(SketchPlugin_Arc::START_ID()),
                                          ObjectPtr(),
@@ -355,7 +355,7 @@ void SketchPlugin_MacroArc::execute()
     AttributeRefAttrPtr aRefAttrB = aTangent->refattr(SketchPlugin_Constraint::ENTITY_B());
     aRefAttrB->setObject(anArcFeature->lastResult());
     // constraint for end point
-    SketchPlugin_Tools::createConstraint(this,
+    SketchPlugin_Tools::createCoincidenceOrTangency(this,
                                          END_POINT_REF_ID(),
                                          anArcFeature->attribute(SketchPlugin_Arc::END_ID()),
                                          ObjectPtr(),
index 2b6829c729a7f62aa6058e1698f71e9dd6e1ad25..b584a004eb5afae582a801a631b3771df3973b30 100644 (file)
@@ -186,11 +186,11 @@ std::string SketchPlugin_MacroCircle::processEvent(
 void SketchPlugin_MacroCircle::constraintsForCircleByCenterAndPassed(FeaturePtr theCircleFeature)
 {
   // Create constraints.
-  SketchPlugin_Tools::createConstraint(
+  SketchPlugin_Tools::createCoincidenceOrTangency(
       this, CENTER_POINT_REF_ID(),
       theCircleFeature->attribute(SketchPlugin_Circle::CENTER_ID()),
       ObjectPtr(), false);
-  SketchPlugin_Tools::createConstraint(
+  SketchPlugin_Tools::createCoincidenceOrTangency(
       this, PASSED_POINT_REF_ID(), AttributePtr(),
       theCircleFeature->lastResult(), true);
 }
@@ -203,8 +203,10 @@ void SketchPlugin_MacroCircle::constraintsForCircleByThreePoints(FeaturePtr theC
 
   // Create constraints.
   ResultPtr aCircleResult = theCircleFeature->lastResult();
-  for (int i = 0; i < 3; ++i)
-    SketchPlugin_Tools::createConstraint(this, aPointRef[i], AttributePtr(), aCircleResult, true);
+  for (int i = 0; i < 3; ++i) {
+    SketchPlugin_Tools::createCoincidenceOrTangency(
+        this, aPointRef[i], AttributePtr(), aCircleResult, true);
+  }
 }
 
 FeaturePtr SketchPlugin_MacroCircle::createCircleFeature()
index 37ea7aa31462cd88932a8b1d50a7e9eb7783b8e3..ac07fa6642958c047b6e7aad68cb6ec398cbee85 100644 (file)
@@ -193,14 +193,14 @@ std::string SketchPlugin_MacroEllipse::processEvent(
 void SketchPlugin_MacroEllipse::constraintsForEllipse(FeaturePtr theEllipseFeature)
 {
   // Create constraints.
-  SketchPlugin_Tools::createConstraint(
+  SketchPlugin_Tools::createCoincidenceOrTangency(
       this, CENTER_POINT_REF_ID(),
       theEllipseFeature->attribute(SketchPlugin_Ellipse::CENTER_ID()),
       ObjectPtr(), false);
-  SketchPlugin_Tools::createConstraint(
+  SketchPlugin_Tools::createCoincidenceOrTangency(
       this, MAJOR_AXIS_POINT_REF_ID(), AttributePtr(),
       theEllipseFeature->lastResult(), true);
-  SketchPlugin_Tools::createConstraint(
+  SketchPlugin_Tools::createCoincidenceOrTangency(
       this, PASSED_POINT_REF_ID(), AttributePtr(),
       theEllipseFeature->lastResult(), true);
 }
index b254d63d4bc890b7e9ca5d45fcb1cef3c6c77f37..7da9ca15fb04e393536d58e2369ddf0f01bbedbe 100644 (file)
@@ -55,6 +55,7 @@
 #include <SketchPlugin_MultiRotation.h>
 #include <SketchPlugin_MultiTranslation.h>
 #include <SketchPlugin_Point.h>
+#include <SketchPlugin_Tools.h>
 
 #include <ModelGeomAlgo_Point2D.h>
 #include <ModelAPI_EventReentrantMessage.h>
@@ -64,7 +65,6 @@
 
 //#define CREATE_CONSTRAINTS
 
-//#define DEBUG_SPLIT
 #ifdef DEBUG_SPLIT
 #include <iostream>
 #endif
@@ -914,7 +914,8 @@ void SketchPlugin_Split::updateCoincidenceConstraintsToFeature(
     }
     if (aFeaturePointAttribute.get()) {
       // create new constraint and remove the current
-      aCoincFeature = createConstraint(SketchPlugin_ConstraintCoincidence::ID(),
+      aCoincFeature = SketchPlugin_Tools::createConstraint(sketch(),
+          SketchPlugin_ConstraintCoincidence::ID(),
           aFeaturePointAttribute, aCoincFeature->refattr(aSecondAttribute)->attr());
       theFeaturesToDelete.insert(aCIt->first);
       // create new coincidences to split feature points
@@ -923,7 +924,7 @@ void SketchPlugin_Split::updateCoincidenceConstraintsToFeature(
       for (; aSFIt != aSFLast; aSFIt++) {
         AttributePoint2DPtr aSFAttribute = *aSFIt;
         if (aCoincPnt->isEqual(aSFAttribute->pnt())) {
-          createConstraint(SketchPlugin_ConstraintCoincidence::ID(),
+          SketchPlugin_Tools::createConstraint(sketch(), SketchPlugin_ConstraintCoincidence::ID(),
                            aSFAttribute, aCoincFeature->refattr(aSecondAttribute)->attr());
         }
       }
@@ -1081,7 +1082,8 @@ FeaturePtr SketchPlugin_Split::splitLine(FeaturePtr& theSplitFeature,
                                              aFeature->attribute(SketchPlugin_Line::END_ID())));
       anNewFeature = aFeature;
     }
-    aConstraintFeature = createConstraint(SketchPlugin_ConstraintCoincidence::ID(),
+    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+                     SketchPlugin_ConstraintCoincidence::ID(),
                      theSplitFeature->attribute(SketchPlugin_Line::END_ID()),
                      aFeature->attribute(SketchPlugin_Line::START_ID()));
     theCreatedFeatures.insert(aConstraintFeature);
@@ -1110,7 +1112,8 @@ FeaturePtr SketchPlugin_Split::splitLine(FeaturePtr& theSplitFeature,
     fillAttribute(theBaseFeatureModified->attribute(SketchPlugin_Line::END_ID()),
                                                     aFirstPointAttrOfSplit);
     theBaseFeatureModified->execute(); // to update result
-    aConstraintFeature = createConstraint(SketchPlugin_ConstraintCoincidence::ID(),
+    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+                     SketchPlugin_ConstraintCoincidence::ID(),
                      theBaseFeatureModified->attribute(SketchPlugin_Line::END_ID()),
                      theSplitFeature->attribute(SketchPlugin_Line::START_ID()));
     theCreatedFeatures.insert(aConstraintFeature);
@@ -1126,14 +1129,16 @@ FeaturePtr SketchPlugin_Split::splitLine(FeaturePtr& theSplitFeature,
 
 #ifdef CREATE_CONSTRAINTS
   // additional constraints between split and base features
-  aConstraintFeature = createConstraintForObjects(SketchPlugin_ConstraintParallel::ID(),
-                                                       getFeatureResult(aBaseFeature),
-                                                       getFeatureResult(theSplitFeature));
+  aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+          SketchPlugin_ConstraintParallel::ID(),
+          getFeatureResult(aBaseFeature),
+          getFeatureResult(theSplitFeature));
   theCreatedFeatures.insert(aConstraintFeature);
   if (theAfterFeature.get()) {
-    aConstraintFeature = createConstraintForObjects(SketchPlugin_ConstraintParallel::ID(),
-                                                    getFeatureResult(aBaseFeature),
-                                                    getFeatureResult(theAfterFeature));
+    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+          SketchPlugin_ConstraintParallel::ID(),
+          getFeatureResult(aBaseFeature),
+          getFeatureResult(theAfterFeature));
     theCreatedFeatures.insert(aConstraintFeature);
   }
 #endif
@@ -1220,7 +1225,8 @@ FeaturePtr SketchPlugin_Split::splitArc(FeaturePtr& theSplitFeature,
                                                   aFeature->attribute(SketchPlugin_Arc::END_ID())));
       anNewFeature = aFeature;
     }
-    aConstraintFeature = createConstraint(SketchPlugin_ConstraintCoincidence::ID(),
+    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+                     SketchPlugin_ConstraintCoincidence::ID(),
                      theSplitFeature->attribute(SketchPlugin_Arc::END_ID()),
                      aFeature->attribute(SketchPlugin_Arc::START_ID()));
     theCreatedFeatures.insert(aConstraintFeature);
@@ -1249,7 +1255,8 @@ FeaturePtr SketchPlugin_Split::splitArc(FeaturePtr& theSplitFeature,
     fillAttribute(theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID()),
                                                     aFirstPointAttrOfSplit);
     theBaseFeatureModified->execute(); // to update result
-    aConstraintFeature = createConstraint(SketchPlugin_ConstraintCoincidence::ID(),
+    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+                     SketchPlugin_ConstraintCoincidence::ID(),
                      theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID()),
                      theSplitFeature->attribute(SketchPlugin_Arc::START_ID()));
     theCreatedFeatures.insert(aConstraintFeature);
@@ -1265,22 +1272,26 @@ FeaturePtr SketchPlugin_Split::splitArc(FeaturePtr& theSplitFeature,
 
   // additional constraints between split and base features
 #ifdef CREATE_CONSTRAINTS
-  aConstraintFeature = createConstraintForObjects(SketchPlugin_ConstraintEqual::ID(),
-                                                       getFeatureResult(aBaseFeature),
-                                                       getFeatureResult(theSplitFeature));
+  aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+          SketchPlugin_ConstraintEqual::ID(),
+          getFeatureResult(aBaseFeature),
+          getFeatureResult(theSplitFeature));
   theCreatedFeatures.insert(aConstraintFeature);
-  aConstraintFeature = createConstraintForObjects(SketchPlugin_ConstraintTangent::ID(),
-                                                       getFeatureResult(theSplitFeature),
-                                                       getFeatureResult(aBaseFeature));
+  aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+          SketchPlugin_ConstraintTangent::ID(),
+          getFeatureResult(theSplitFeature),
+          getFeatureResult(aBaseFeature));
   theCreatedFeatures.insert(aConstraintFeature);
   if (theAfterFeature.get()) {
-    aConstraintFeature = createConstraintForObjects(SketchPlugin_ConstraintEqual::ID(),
-                                                    getFeatureResult(aBaseFeature),
-                                                    getFeatureResult(theAfterFeature));
+    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+                SketchPlugin_ConstraintEqual::ID(),
+                getFeatureResult(aBaseFeature),
+                getFeatureResult(theAfterFeature));
     theCreatedFeatures.insert(aConstraintFeature);
-    aConstraintFeature = createConstraintForObjects(SketchPlugin_ConstraintTangent::ID(),
-                                                    getFeatureResult(theSplitFeature),
-                                                    getFeatureResult(theAfterFeature));
+    aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+                SketchPlugin_ConstraintTangent::ID(),
+                getFeatureResult(theSplitFeature),
+                getFeatureResult(theAfterFeature));
     theCreatedFeatures.insert(aConstraintFeature);
   }
 #endif
@@ -1344,19 +1355,22 @@ FeaturePtr SketchPlugin_Split::splitCircle(FeaturePtr& theSplitFeature,
                              (theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID())));
 
   // additional constraints between split and base features
-  aConstraintFeature = createConstraint(SketchPlugin_ConstraintCoincidence::ID(),
+  aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+                     SketchPlugin_ConstraintCoincidence::ID(),
                      theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID()),
                      theSplitFeature->attribute(SketchPlugin_Arc::END_ID()));
   theCreatedFeatures.insert(aConstraintFeature);
-  aConstraintFeature = createConstraint(SketchPlugin_ConstraintCoincidence::ID(),
+  aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+                     SketchPlugin_ConstraintCoincidence::ID(),
                      theBaseFeatureModified->attribute(SketchPlugin_Arc::START_ID()),
                      theSplitFeature->attribute(SketchPlugin_Arc::START_ID()));
   theCreatedFeatures.insert(aConstraintFeature);
 
 #ifdef CREATE_CONSTRAINTS
-  aConstraintFeature = createConstraintForObjects(SketchPlugin_ConstraintTangent::ID(),
-                                                       getFeatureResult(theSplitFeature),
-                                                       getFeatureResult(theBaseFeatureModified));
+  aConstraintFeature = SketchPlugin_Tools::createConstraint(sketch(),
+                     SketchPlugin_ConstraintTangent::ID(),
+                     getFeatureResult(theSplitFeature),
+                     getFeatureResult(theBaseFeatureModified));
   theCreatedFeatures.insert(aConstraintFeature);
 #endif
   return anNewFeature;
@@ -1503,39 +1517,6 @@ FeaturePtr SketchPlugin_Split::createArcFeature(const FeaturePtr& theBaseFeature
   return aFeature;
 }
 
-FeaturePtr SketchPlugin_Split::createConstraint(const std::string& theConstraintId,
-                                                    const AttributePtr& theFirstAttribute,
-                                                    const AttributePtr& theSecondAttribute)
-{
-  FeaturePtr aConstraint = sketch()->addFeature(theConstraintId);
-  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  aRefAttr->setAttr(theFirstAttribute);
-
-  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  aRefAttr->setAttr(theSecondAttribute);
-
-  return aConstraint;
-}
-
-FeaturePtr SketchPlugin_Split::createConstraintForObjects(
-                                                    const std::string& theConstraintId,
-                                                    const ObjectPtr& theFirstObject,
-                                                    const ObjectPtr& theSecondObject)
-{
-  FeaturePtr aConstraint = sketch()->addFeature(theConstraintId);
-  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  aRefAttr->setObject(theFirstObject);
-
-  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  aRefAttr->setObject(theSecondObject);
-
-  return aConstraint;
-}
-
 void SketchPlugin_Split::updateFeaturesAfterSplit(
                                                    const std::set<FeaturePtr>& theFeaturesToUpdate)
 {
index 37f1e1659c98c331bf483df8a1b8fbc4183a7e09..363db36458a37f3051af9524741a864d2d490eec 100644 (file)
@@ -297,22 +297,6 @@ private:
                               const AttributePtr& theFirstPointAttr,
                               const AttributePtr& theSecondPointAttr);
 
-  /// Add feature coincidence constraint between given attributes
-  /// \param theConstraintId a constraint index
-  /// \param theFirstAttribute an attribute of further coincidence
-  /// \param theSecondAttribute an attribute of further coincidence
-  std::shared_ptr<ModelAPI_Feature> createConstraint(const std::string& theConstraintId,
-                        const std::shared_ptr<ModelAPI_Attribute>& theFirstAttribute,
-                        const std::shared_ptr<ModelAPI_Attribute>& theSecondAttribute);
-
-  /// Add feature coincidence constraint between given attributes
-  /// \param theConstraintId a constraint index
-  /// \param theFirstAttribute an attribute of further coincidence
-  /// \param theFirstAttribute an attribute of further coincidence
-  std::shared_ptr<ModelAPI_Feature> createConstraintForObjects(const std::string& theConstraintId,
-                        const std::shared_ptr<ModelAPI_Object>& theFirstObject,
-                        const std::shared_ptr<ModelAPI_Object>& theSecondObject);
-
   /// Add feature coincidence constraint between given attributes
   /// \param theFeaturesToUpdate a constraint index
   void updateFeaturesAfterSplit(const std::set<FeaturePtr>& theFeaturesToUpdate);
index c798ea4a81e073b7807ea8a30257ce966399f6fc..7a3895a34e38990d561099810e75f8fe9f1b4981 100644 (file)
 #include <GeomDataAPI_Point.h>
 #include <GeomDataAPI_Point2D.h>
 
+#ifdef DEBUG_TRIM
+#include <iostream>
+#endif
+
 namespace SketchPlugin_Tools {
 
 void clearExpressions(AttributeDoublePtr theAttribute)
@@ -252,11 +256,11 @@ void resetAttribute(SketchPlugin_Feature* theFeature,
   }
 }
 
-void createConstraint(SketchPlugin_Feature* theFeature,
-                      const std::string& theId,
-                      const AttributePtr theAttr,
-                      const ObjectPtr theObject,
-                      const bool theIsCanBeTangent)
+void createCoincidenceOrTangency(SketchPlugin_Feature* theFeature,
+                                 const std::string& theId,
+                                 const AttributePtr theAttr,
+                                 const ObjectPtr theObject,
+                                 const bool theIsCanBeTangent)
 {
   AttributeRefAttrPtr aRefAttr = theFeature->refattr(theId);
   if(aRefAttr.get() && aRefAttr->isInitialized()) {
@@ -313,4 +317,77 @@ void convertRefAttrToPointOrTangentCurve(const AttributeRefAttrPtr&      theRefA
   thePassingPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr)->pnt();
 }
 
+
+FeaturePtr createConstraint(SketchPlugin_Sketch* theSketch,
+                            const std::string& theConstraintId,
+                            const AttributePtr& theFirstAttribute,
+                            const AttributePtr& theSecondAttribute)
+{
+  FeaturePtr aConstraint = theSketch->addFeature(theConstraintId);
+  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
+                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
+  aRefAttr->setAttr(theFirstAttribute);
+
+  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
+                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
+  aRefAttr->setAttr(theSecondAttribute);
+
+#if defined(DEBUG_TRIM) || defined(DEBUG_SPLIT)
+  std::cout << "<createConstraint to attribute> :"
+            << " first attribute - " << theFirstAttribute->id()
+            << " second attribute - " << theSecondAttribute->id()
+            << std::endl;
+#endif
+
+  return aConstraint;
+}
+
+FeaturePtr createConstraint(SketchPlugin_Sketch* theSketch,
+                            const std::string& theConstraintId,
+                            const AttributePtr& theFirstAttribute,
+                            const ObjectPtr& theSecondObject)
+{
+  FeaturePtr aConstraint = theSketch->addFeature(theConstraintId);
+  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
+                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
+  aRefAttr->setAttr(theFirstAttribute);
+
+  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
+                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
+  aRefAttr->setObject(theSecondObject);
+
+#if defined(DEBUG_TRIM) || defined(DEBUG_SPLIT)
+  std::cout << "<createConstraint to attribute> :"
+            << " first attribute - " << theFirstAttribute->id()
+            << " second object - " << ModelAPI_Feature::feature(theSecondObject)->getKind()
+            << std::endl;
+#endif
+
+  return aConstraint;
+}
+
+FeaturePtr createConstraint(SketchPlugin_Sketch* theSketch,
+                            const std::string& theConstraintId,
+                            const ObjectPtr& theFirstObject,
+                            const ObjectPtr& theSecondObject)
+{
+  FeaturePtr aConstraint = theSketch->addFeature(theConstraintId);
+  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
+                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
+  aRefAttr->setObject(theFirstObject);
+
+  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
+                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
+  aRefAttr->setObject(theSecondObject);
+
+#if defined(DEBUG_TRIM) || defined(DEBUG_SPLIT)
+  std::cout << "<createConstraint to attribute> :"
+            << " first object - " << ModelAPI_Feature::feature(theFirstObject)->getKind()
+            << " second object - " << ModelAPI_Feature::feature(theSecondObject)->getKind()
+            << std::endl;
+#endif
+
+  return aConstraint;
+}
+
 } // namespace SketchPlugin_Tools
index 07ea391dfa86ffa0516efd302f4e57d8e9d46ec6..6653b44ff349611d4e3ad338e5f519c8a91ca490 100644 (file)
@@ -29,6 +29,7 @@
 #include <GeomDataAPI_Point2D.h>
 
 class SketchPlugin_Feature;
+class SketchPlugin_Sketch;
 
 namespace SketchPlugin_Tools {
 
@@ -60,17 +61,47 @@ std::set<AttributePoint2DPtr> findPointsCoincidentToPoint(const AttributePoint2D
 
 void resetAttribute(SketchPlugin_Feature* theFeature, const std::string& theId);
 
+/// Create new constraint between given attributes
+/// \param[in] theSketch          a sketch where the constraint will be created
+/// \param[in] theConstraintId    a constraint identifier
+/// \param[in] theFirstAttribute  an attribute of further constraint
+/// \param[in] theSecondAttribute an attribute of further constraint
+FeaturePtr createConstraint(SketchPlugin_Sketch* theSketch,
+                            const std::string& theConstraintId,
+                            const AttributePtr& theFirstAttribute,
+                            const AttributePtr& theSecondAttribute);
+
+/// Create new constraint between given attribute and object
+/// \param[in] theSketch         a sketch where the constraint will be created
+/// \param[in] theConstraintId   a constraint identifier
+/// \param[in] theFirstAttribute an attribute of further constraint
+/// \param[in] theSecondObject   an attribute of further constraint
+FeaturePtr createConstraint(SketchPlugin_Sketch* theSketch,
+                            const std::string& theConstraintId,
+                            const AttributePtr& theFirstAttribute,
+                            const ObjectPtr& theSecondObject);
+
+/// Create new constraint between given objects
+/// \param[in] theSketch       a sketch where the constraint will be created
+/// \param[in] theConstraintId a constraint identifier
+/// \param[in] theFirstObject  an attribute of further constraint
+/// \param[in] theSecondObject an attribute of further constraint
+FeaturePtr createConstraint(SketchPlugin_Sketch* theSketch,
+                            const std::string& theConstraintId,
+                            const ObjectPtr& theFirstObject,
+                            const ObjectPtr& theSecondObject);
+
 /// Creates coincidence or tangent constraint.
 /// \param[in] theFeature to get selected attribute or object
 /// \param[in] theId ID of attribute where selection is.
 /// \param[in] theObject object for constraint
 /// \param[in] theIsCanBeTangent if true constraint can be tangent or coincidence, depending on
 ///                              the selection in the attribute with passed ID.
-void createConstraint(SketchPlugin_Feature* theFeature,
-                      const std::string& theId,
-                      const AttributePtr theAttr,
-                      const ObjectPtr theObject,
-                      const bool theIsCanBeTangent);
+void createCoincidenceOrTangency(SketchPlugin_Feature* theFeature,
+                                 const std::string& theId,
+                                 const AttributePtr theAttr,
+                                 const ObjectPtr theObject,
+                                 const bool theIsCanBeTangent);
 
 /// Creates passing point or tangent curve basing on the given attributes are initialized.
 /// \param[in]  theRefAttr       prefered attribute to be converted
index 74be0dc1f4854be50af6d6ec28101fe528128e65..ec57b93934eac4c2986db93b30e25b247c036657 100644 (file)
@@ -45,7 +45,6 @@
 #include <SketchPlugin_Circle.h>
 #include <SketchPlugin_ConstraintCoincidence.h>
 #include <SketchPlugin_ConstraintEqual.h>
-//#include <SketchPlugin_ConstraintParallel.h>
 #include <SketchPlugin_ConstraintTangent.h>
 #include <SketchPlugin_ConstraintLength.h>
 #include <SketchPlugin_ConstraintMirror.h>
@@ -55,6 +54,7 @@
 #include <SketchPlugin_MultiTranslation.h>
 #include <SketchPlugin_Point.h>
 #include <SketchPlugin_Projection.h>
+#include <SketchPlugin_Tools.h>
 
 #include <ModelAPI_EventReentrantMessage.h>
 
@@ -68,9 +68,6 @@
 
 #include <cmath>
 
-//#define DEBUG_TRIM_METHODS
-//#define DEBUG_TRIM
-
 #ifdef DEBUG_TRIM
 #include <iostream>
 #endif
@@ -362,8 +359,8 @@ void SketchPlugin_Trim::execute()
     const std::list<ObjectPtr>& anObjects = anInfo.second;
     for (std::list<ObjectPtr>::const_iterator anObjectIt = anObjects.begin();
       anObjectIt != anObjects.end(); anObjectIt++) {
-      createConstraintToObject(SketchPlugin_ConstraintCoincidence::ID(), aPointAttribute,
-                               *anObjectIt);
+      SketchPlugin_Tools::createConstraint(sketch(), SketchPlugin_ConstraintCoincidence::ID(),
+                                           aPointAttribute, *anObjectIt);
     }
   }
 
@@ -553,7 +550,8 @@ bool SketchPlugin_Trim::setCoincidenceToAttribute(const AttributePtr& theAttribu
     std::shared_ptr<GeomAPI_Pnt2d> aPoint2d = aPointAttribute->pnt();
     if (aPoint2d->isEqual(aRefPnt2d)) {
       // create new coincidence and then remove the old one
-      createConstraint(SketchPlugin_ConstraintCoincidence::ID(), aRefPointAttr, aPointAttribute);
+      SketchPlugin_Tools::createConstraint(sketch(), SketchPlugin_ConstraintCoincidence::ID(),
+                                           aRefPointAttr, aPointAttribute);
       theFeaturesToDelete.insert(aFeature);
     }
   }
@@ -964,10 +962,9 @@ FeaturePtr SketchPlugin_Trim::trimLine(const std::shared_ptr<GeomAPI_Pnt2d>& the
                                (aBaseFeature->attribute(aModifiedAttribute)));
 
     // Collinear constraint for lines
-    createConstraintForObjects(SketchPlugin_ConstraintCollinear::ID(),
-                               getFeatureResult(aBaseFeature),
-                               getFeatureResult(anNewFeature));
-
+    SketchPlugin_Tools::createConstraint(sketch(), SketchPlugin_ConstraintCollinear::ID(),
+                                         getFeatureResult(aBaseFeature),
+                                         getFeatureResult(anNewFeature));
   }
   return anNewFeature;
 }
@@ -1049,13 +1046,13 @@ FeaturePtr SketchPlugin_Trim::trimArc(const std::shared_ptr<GeomAPI_Pnt2d>& theS
                                (aBaseFeature->attribute(aModifiedAttribute)));
 
     // equal Radius constraint for arcs
-    createConstraintForObjects(SketchPlugin_ConstraintEqual::ID(),
-                               getFeatureResult(aBaseFeature),
-                               getFeatureResult(anNewFeature));
+    SketchPlugin_Tools::createConstraint(sketch(), SketchPlugin_ConstraintEqual::ID(),
+                                         getFeatureResult(aBaseFeature),
+                                         getFeatureResult(anNewFeature));
     // coincident centers constraint
-    createConstraint(SketchPlugin_ConstraintCoincidence::ID(),
-                     aBaseFeature->attribute(SketchPlugin_Arc::CENTER_ID()),
-                     anNewFeature->attribute(SketchPlugin_Arc::CENTER_ID()));
+    SketchPlugin_Tools::createConstraint(sketch(), SketchPlugin_ConstraintCoincidence::ID(),
+                                         aBaseFeature->attribute(SketchPlugin_Arc::CENTER_ID()),
+                                         anNewFeature->attribute(SketchPlugin_Arc::CENTER_ID()));
 
 #ifdef DEBUG_TRIM
     std::cout << "Created arc on points:" << std::endl;
@@ -1292,69 +1289,6 @@ FeaturePtr SketchPlugin_Trim::createArcFeature(const FeaturePtr& theBaseFeature,
   return aFeature;
 }
 
-FeaturePtr SketchPlugin_Trim::createConstraint(const std::string& theConstraintId,
-                                               const AttributePtr& theFirstAttribute,
-                                               const AttributePtr& theSecondAttribute)
-{
-  FeaturePtr aConstraint = sketch()->addFeature(theConstraintId);
-  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  aRefAttr->setAttr(theFirstAttribute);
-
-  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  aRefAttr->setAttr(theSecondAttribute);
-
-#ifdef DEBUG_TRIM
-  std::cout << "<createConstraint to attribute> :"
-            << "first attribute - " << theFirstAttribute->id()
-            << "second attribute - " << theSecondAttribute->id()
-            << std::endl;
-#endif
-
-  return aConstraint;
-}
-
-FeaturePtr SketchPlugin_Trim::createConstraintToObject(const std::string& theConstraintId,
-                                               const AttributePtr& theFirstAttribute,
-                                               const ObjectPtr& theSecondObject)
-{
-  FeaturePtr aConstraint = sketch()->addFeature(theConstraintId);
-  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  aRefAttr->setAttr(theFirstAttribute);
-
-  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  aRefAttr->setObject(theSecondObject);
-
-#ifdef DEBUG_TRIM
-  std::cout << "<createConstraint to attribute> :"
-            << "first attribute - " << theFirstAttribute->id()
-            << "second object - " << ModelAPI_Feature::feature(theSecondObject)->getKind()
-            << std::endl;
-#endif
-
-  return aConstraint;
-}
-
-FeaturePtr SketchPlugin_Trim::createConstraintForObjects(
-                                                    const std::string& theConstraintId,
-                                                    const ObjectPtr& theFirstObject,
-                                                    const ObjectPtr& theSecondObject)
-{
-  FeaturePtr aConstraint = sketch()->addFeature(theConstraintId);
-  AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  aRefAttr->setObject(theFirstObject);
-
-  aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
-                                 aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B()));
-  aRefAttr->setObject(theSecondObject);
-
-  return aConstraint;
-}
-
 std::shared_ptr<ModelAPI_Result> SketchPlugin_Trim::getFeatureResult(
                                     const std::shared_ptr<ModelAPI_Feature>& theFeature)
 {
index 6ad6a58c4f9b9967966fd24798ecd8dcc92a6f6c..40090b40ee0dbfeb9b6bf230364488ad4161bba7 100644 (file)
@@ -255,30 +255,6 @@ private:
                               const std::shared_ptr<GeomAPI_Pnt2d>& theFirstPoint,
                               const std::shared_ptr<GeomAPI_Pnt2d>& theSecondPoint);
 
-  /// Add feature coincidence constraint between given attributes
-  /// \param theConstraintId a constraint index
-  /// \param theFirstAttribute an attribute of further coincidence
-  /// \param theSecondAttribute an attribute of further coincidence
-  std::shared_ptr<ModelAPI_Feature> createConstraint(const std::string& theConstraintId,
-                        const std::shared_ptr<ModelAPI_Attribute>& theFirstAttribute,
-                        const std::shared_ptr<ModelAPI_Attribute>& theSecondAttribute);
-
-  /// Add feature coincidence constraint between given attributes
-  /// \param theConstraintId a constraint index
-  /// \param theFirstAttribute an attribute of further coincidence
-  /// \param theSecondObject an object of further coincidence
-  std::shared_ptr<ModelAPI_Feature> createConstraintToObject(const std::string& theConstraintId,
-                        const std::shared_ptr<ModelAPI_Attribute>& theFirstAttribute,
-                        const std::shared_ptr<ModelAPI_Object>& theSecondObject);
-
-  /// Add feature coincidence constraint between given attributes
-  /// \param theConstraintId a constraint index
-  /// \param theFirstAttribute an attribute of further coincidence
-  /// \param theFirstAttribute an attribute of further coincidence
-  std::shared_ptr<ModelAPI_Feature> createConstraintForObjects(const std::string& theConstraintId,
-                        const std::shared_ptr<ModelAPI_Object>& theFirstObject,
-                        const std::shared_ptr<ModelAPI_Object>& theSecondObject);
-
   /// Result result of the feature to build constraint with. For arc, circle it is an edge result.
   /// \param theFeature a feature
   /// \return result object