]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make points with parameters placed on lines from another group (issue #1025)
authorazv <azv@opencascade.com>
Tue, 29 Sep 2015 12:06:11 +0000 (15:06 +0300)
committerazv <azv@opencascade.com>
Tue, 29 Sep 2015 12:11:50 +0000 (15:11 +0300)
src/SketchSolver/SketchSolver_ConstraintParametric.cpp
src/SketchSolver/SketchSolver_Group.cpp

index d730429660ad215a68a0b83dc6b5e484b83ed49b..bd533ce8e44e1b0bba45936e2431b2231cbdf705 100644 (file)
@@ -36,11 +36,6 @@ void SketchSolver_ConstraintParametric::process()
   if (!aPoint->textX().empty()) {
     // Create vertical line with fixed boundary point
     Slvs_Entity aLine = createLine(aPoint->x(), -100.0, aPoint->x(), 100.0);
-    fixPoint(aLine.point[0]);
-    Slvs_Constraint aVertConstr = Slvs_MakeConstraint(SLVS_C_UNKNOWN, myGroup->getId(),
-        SLVS_C_VERTICAL, myGroup->getWorkplaneId(), 0.0, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN,
-        aLine.h, SLVS_E_UNKNOWN);
-    myStorage->addConstraint(aVertConstr);
     // Place point on line
     Slvs_Constraint aConstraint = Slvs_MakeConstraint(SLVS_C_UNKNOWN, myGroup->getId(),
         SLVS_C_PT_ON_LINE, myGroup->getWorkplaneId(), 0.0, anAttrID, SLVS_E_UNKNOWN,
@@ -53,11 +48,6 @@ void SketchSolver_ConstraintParametric::process()
   if (!aPoint->textY().empty()) {
     // Create horizontal line with fixed boundary points
     Slvs_Entity aLine = createLine(-100.0, aPoint->y(), 100.0, aPoint->y());
-    fixPoint(aLine.point[0]);
-    Slvs_Constraint aHorizConstr = Slvs_MakeConstraint(SLVS_C_UNKNOWN, myGroup->getId(),
-        SLVS_C_HORIZONTAL, myGroup->getWorkplaneId(), 0.0, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN,
-        aLine.h, SLVS_E_UNKNOWN);
-    myStorage->addConstraint(aHorizConstr);
     // Place point on line
     Slvs_Constraint aConstraint = Slvs_MakeConstraint(SLVS_C_UNKNOWN, myGroup->getId(),
         SLVS_C_PT_ON_LINE, myGroup->getWorkplaneId(), 0.0, anAttrID, SLVS_E_UNKNOWN,
@@ -93,8 +83,8 @@ void SketchSolver_ConstraintParametric::update(ConstraintPtr theConstraint)
   if (!theConstraint || theConstraint == myBaseConstraint) {
     std::shared_ptr<GeomDataAPI_Point2D> aPoint =
         std::dynamic_pointer_cast<GeomDataAPI_Point2D>(myBaseAttribute);
-    if (aPoint && ((!aPoint->textX().empty() && myVertLineID != SLVS_E_UNKNOWN) || 
-        (!aPoint->textY().empty() && myHorizLineID != SLVS_E_UNKNOWN))) {
+    if (aPoint && ((!aPoint->textX().empty() && myVertLineID == SLVS_E_UNKNOWN) || 
+        (!aPoint->textY().empty() && myHorizLineID == SLVS_E_UNKNOWN))) {
       remove();
       process();
       return;
@@ -156,25 +146,25 @@ Slvs_Entity SketchSolver_ConstraintParametric::createLine(
     double theStartX, double theStartY, double theEndX, double theEndY)
 {
   // Start point
-  Slvs_Param aParX = Slvs_MakeParam(SLVS_E_UNKNOWN, myGroup->getId(), theStartX);
-  Slvs_Param aParY = Slvs_MakeParam(SLVS_E_UNKNOWN, myGroup->getId(), theStartY);
+  Slvs_Param aParX = Slvs_MakeParam(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP, theStartX);
+  Slvs_Param aParY = Slvs_MakeParam(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP, theStartY);
   aParX.h = myStorage->addParameter(aParX);
   aParY.h = myStorage->addParameter(aParY);
-  Slvs_Entity aStartPoint = Slvs_MakePoint2d(SLVS_E_UNKNOWN, myGroup->getId(),
+  Slvs_Entity aStartPoint = Slvs_MakePoint2d(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP,
     myGroup->getWorkplaneId(), aParX.h, aParY.h);
   aStartPoint.h = myStorage->addEntity(aStartPoint);
 
   // End point
-  aParX = Slvs_MakeParam(SLVS_E_UNKNOWN, myGroup->getId(), theEndX);
-  aParY = Slvs_MakeParam(SLVS_E_UNKNOWN, myGroup->getId(), theEndY);
+  aParX = Slvs_MakeParam(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP, theEndX);
+  aParY = Slvs_MakeParam(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP, theEndY);
   aParX.h = myStorage->addParameter(aParX);
   aParY.h = myStorage->addParameter(aParY);
-  Slvs_Entity aEndPoint = Slvs_MakePoint2d(SLVS_E_UNKNOWN, myGroup->getId(),
+  Slvs_Entity aEndPoint = Slvs_MakePoint2d(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP,
     myGroup->getWorkplaneId(), aParX.h, aParY.h);
   aEndPoint.h = myStorage->addEntity(aEndPoint);
 
   // Line
-  Slvs_Entity aLine = Slvs_MakeLineSegment(SLVS_E_UNKNOWN, myGroup->getId(),
+  Slvs_Entity aLine = Slvs_MakeLineSegment(SLVS_E_UNKNOWN, SLVS_G_OUTOFGROUP,
     myGroup->getWorkplaneId(), aStartPoint.h, aEndPoint.h);
   aLine.h = myStorage->addEntity(aLine);
   return aLine;
index 67b9d31ddee87f6c679f365c4a3f118192b391b3..b767b3bb8bcd00b8870d57afa21edc335c222500 100644 (file)
@@ -304,23 +304,32 @@ bool SketchSolver_Group::changeConstraint(
   for (; anAttrIt != anAttributes.end(); ++anAttrIt) {
     AttributeRefAttrPtr aRefAttr =
         std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anAttrIt);
-    if (!aRefAttr || aRefAttr->isObject())
+    if (!aRefAttr)
       continue;
-    std::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aRefAttr->attr());
+
+    std::shared_ptr<GeomDataAPI_Point2D> aPoint;
+    if (aRefAttr->isObject()) {
+      FeaturePtr aFeat = ModelAPI_Feature::feature(aRefAttr->object());
+      if (aFeat->getKind() != SketchPlugin_Point::ID())
+        continue;
+      aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+          aFeat->attribute(SketchPlugin_Point::COORD_ID()));
+    } else
+      aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aRefAttr->attr());
+
     if (!aPoint || (aPoint->textX().empty() && aPoint->textY().empty()))
       continue;
 
     std::map<AttributePtr, SolverConstraintPtr>::iterator aFound =
-        myParametricConstraints.find(aRefAttr->attr());
+        myParametricConstraints.find(aPoint);
     if (aFound == myParametricConstraints.end()) {
       SolverConstraintPtr aConstraint =
-          SketchSolver_Builder::getInstance()->createParametricConstraint(aRefAttr->attr());
+          SketchSolver_Builder::getInstance()->createParametricConstraint(aPoint);
       if (!aConstraint)
         continue;
       aConstraint->setGroup(this);
       aConstraint->setStorage(myStorage);
-      myParametricConstraints[aRefAttr->attr()] = aConstraint;
+      myParametricConstraints[aPoint] = aConstraint;
     } else
       aFound->second->update();
   }