]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Code cleanup in SketchPlugin and SketchSolver.
authorazv <azv@opencascade.com>
Wed, 20 Jan 2016 11:12:47 +0000 (14:12 +0300)
committerdbv <dbv@opencascade.com>
Tue, 16 Feb 2016 14:04:23 +0000 (17:04 +0300)
Update unit tests for code coverage.

src/SketchPlugin/Test/TestConstraintDistance.py
src/SketchPlugin/Test/TestConstraintEqual.py
src/SketchPlugin/Test/TestConstraintRadius.py
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Builder.cpp
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp
src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.h

index f1fa087b12ca7f89003731ff9660944572a664bb..e9703fa63e5911217ed65ce9cccf409095a14740 100644 (file)
@@ -100,6 +100,8 @@ assert (not refattrA.isInitialized())
 assert (not refattrB.isInitialized())
 aLineResult = aSketchLine.firstResult()
 assert (aLineResult is not None)
+# the following line is necessary to check automatic calculation of a distance
+aConstraint.execute()
 refattrA.setAttr(aSketchPointCoords)
 refattrB.setAttr(aLineAStartPoint)
 aSession.finishOperation()
index cd3fb37ca6b0f06d08d3526037e8e939a754d135..959a0be1cbaf8736916862d5d1320a405c7f639b 100644 (file)
@@ -48,6 +48,16 @@ def lineLength(theLine):
     aVecY = aLineStart.y() - aLineEnd.y()
     return math.hypot(aVecX, aVecY)
 
+def arcLength(theArc):
+    aCenter = geomDataAPI_Point2D(theArc.attribute("ArcCenter"))
+    aStart  = geomDataAPI_Point2D(theArc.attribute("ArcStartPoint"))
+    aEnd    = geomDataAPI_Point2D(theArc.attribute("ArcEndPoint"))
+    # use the law of cosines to calculate angular length of arc
+    aRadius = math.hypot(aStart.x() - aCenter.x(), aStart.y() - aCenter.y())
+    aDist2 = (aEnd.x()-aStart.x())**2 + (aEnd.y()-aStart.y())**2
+    anAngle = math.acos(1. - aDist2 / (2. * aRadius**2))
+    return aRadius * anAngle
+
 
 #=========================================================================
 # Start of test
@@ -205,6 +215,28 @@ aLine1Len = lineLength(aSketchLine1)
 aLine2Len = lineLength(aSketchLine2)
 assert (math.fabs(aLine1Len - anExtLineLen) < 1.e-10)
 assert (math.fabs(aLine2Len - anExtLineLen) < 1.e-10)
+
+#=========================================================================
+# A constraint to make equal lengths of line and arc
+#=========================================================================
+# Third Line
+aSession.startOperation()
+aSketchLine3 = aSketchFeature.addFeature("SketchLine")
+aLine3StartPoint = geomDataAPI_Point2D(aSketchLine3.attribute("StartPoint"))
+aLine3EndPoint = geomDataAPI_Point2D(aSketchLine3.attribute("EndPoint"))
+aLine3StartPoint.setValue(20., 15.)
+aLine3EndPoint.setValue(20., 25.)
+aSession.finishOperation()
+aSession.startOperation()
+anEqArcLineLen = aSketchFeature.addFeature("SketchConstraintEqual")
+aRefObjectA = anEqArcLineLen.refattr("ConstraintEntityA")
+aRefObjectB = anEqArcLineLen.refattr("ConstraintEntityB")
+aRefObjectA.setObject(aSketchArc.lastResult())
+aRefObjectB.setObject(aSketchLine3.lastResult())
+aSession.finishOperation()
+aLine3Len = lineLength(aSketchLine3)
+anArcLen = arcLength(aSketchArc)
+assert (math.fabs(aLine3Len - anArcLen) < 1.e-7)
 #=========================================================================
 # End of test
 #=========================================================================
index 9349352b32b4f4512ec674be73e694b5b1252517..b3bacf265df1ad06a8da2a779f79d8708aa3b861 100644 (file)
@@ -53,6 +53,17 @@ anArcStartPoint.setValue(0., 50.)
 anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
 anArcEndPoint.setValue(50., 0.)
 aSession.finishOperation()
+# Test changing the arc start/end point
+aSession.startOperation()
+anArcStartPoint.setValue(anArcStartPoint.x(), 40.)
+anArcStartPoint.setValue(0., 50.)
+assert (math.hypot(anArcStartPoint.x() - 0., anArcStartPoint.y() - 50.) < 1.e-10)
+aSession.finishOperation()
+aSession.startOperation()
+anArcEndPoint.setValue(40., anArcEndPoint.y())
+anArcEndPoint.setValue(50., 0.)
+assert (math.hypot(anArcEndPoint.x() - 50., anArcEndPoint.y() - 0.) < 1.e-10)
+aSession.finishOperation()
 # Circle
 aSession.startOperation()
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
index fccec67afe7f75637dd77c6c5b4635a50f5f44ef..dd1d542fbdb80acf6478c9d32df7ebd2b6e4889a 100644 (file)
@@ -135,10 +135,6 @@ static ConstraintWrapperPtr
 static void adjustAngle(ConstraintWrapperPtr theConstraint);
 /// \brief Update mirror points
 static void adjustMirror(ConstraintWrapperPtr theConstraint);
-/// \brief Update positions of rotated features
-static void adjustMultiRotation(ConstraintWrapperPtr theConstraint);
-/// \brief Update positions of translated features
-static void adjustMultiTranslation(ConstraintWrapperPtr theConstraint);
 
 /// \brief Transform points to be symmetric regarding to the mirror line
 static void makeMirrorPoints(EntityWrapperPtr theOriginal,
@@ -443,12 +439,6 @@ void PlaneGCSSolver_Builder::adjustConstraint(ConstraintWrapperPtr theConstraint
   // Update flags and parameters in constraints
   if (aType == CONSTRAINT_ANGLE)
     adjustAngle(theConstraint);
-  //else if (aType == CONSTRAINT_SYMMETRIC)
-  //  adjustMirror(theConstraint);
-  else if (aType == CONSTRAINT_MULTI_ROTATION)
-    adjustMultiRotation(theConstraint);
-  else if (aType == CONSTRAINT_MULTI_TRANSLATION)
-    adjustMultiTranslation(theConstraint);
 }
 
 EntityWrapperPtr PlaneGCSSolver_Builder::createFeature(
@@ -1095,23 +1085,6 @@ void adjustAngle(ConstraintWrapperPtr theConstraint)
   }
 }
 
-////void adjustMirror(ConstraintWrapperPtr theConstraint)
-////{
-////  std::vector<EntityWrapperPtr> aPoints;
-////  EntityWrapperPtr aMirrorLine;
-////
-////  const std::list<EntityWrapperPtr>& aSubs = theConstraint->entities();
-////  std::list<EntityWrapperPtr>::const_iterator anIt = aSubs.begin();
-////  for (; anIt != aSubs.end(); ++anIt) {
-////    if ((*anIt)->type() == ENTITY_POINT)
-////      aPoints.push_back(*anIt);
-////    else if ((*anIt)->type() == ENTITY_LINE)
-////      aMirrorLine = *anIt;
-////  }
-////
-////  makeMirrorPoints(aPoints[0], aPoints[1], aMirrorLine);
-////}
-
 void makeMirrorPoints(EntityWrapperPtr theOriginal,
                       EntityWrapperPtr theMirrored,
                       EntityWrapperPtr theMirrorLine)
@@ -1140,105 +1113,3 @@ void makeMirrorPoints(EntityWrapperPtr theOriginal,
   }
 }
 
-static void rotate(EntityWrapperPtr theSource, EntityWrapperPtr theDest,
-                   std::shared_ptr<GeomAPI_Pnt2d> theCenter,
-                   double theSin, double theCos)
-{
-  if (theSource->type() == ENTITY_POINT) {
-    // Rotate single point
-    std::shared_ptr<GeomDataAPI_Point2D> aSrcAttr =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theSource->baseAttribute());
-    std::shared_ptr<GeomDataAPI_Point2D> aDstAttr =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theDest->baseAttribute());
-    if (aSrcAttr && aDstAttr) {
-      std::shared_ptr<GeomAPI_XY> aVec = aSrcAttr->pnt()->xy()->decreased(theCenter->xy());
-      double aNewX = aVec->x() * theCos - aVec->y() * theSin;
-      double aNewY = aVec->x() * theSin + aVec->y() * theCos;
-      aDstAttr->setValue(theCenter->x() + aNewX, theCenter->y() + aNewY);
-      // set also parameters of the solver
-      double aCoord[2] = {aDstAttr->x(), aDstAttr->y()};
-      std::list<ParameterWrapperPtr>::const_iterator aDIt = theDest->parameters().begin();
-      for (int i = 0; aDIt != theDest->parameters().end(); ++aDIt, ++i)
-        (*aDIt)->setValue(aCoord[i]);
-    }
-    return;
-  }
-
-  FeaturePtr aDestFeature = theDest->baseFeature();
-  if (aDestFeature)
-    aDestFeature->data()->blockSendAttributeUpdated(true);
-
-  // Rotate points of the feature
-  const std::list<EntityWrapperPtr>& aSrcSubs = theSource->subEntities();
-  const std::list<EntityWrapperPtr>& aDstSubs = theDest->subEntities();
-  std::list<EntityWrapperPtr>::const_iterator aSrcIt, aDstIt;
-  for (aSrcIt = aSrcSubs.begin(), aDstIt = aDstSubs.begin();
-       aSrcIt != aSrcSubs.end() && aDstIt != aDstSubs.end(); ++aSrcIt, ++aDstIt)
-    rotate(*aSrcIt, *aDstIt, theCenter, theSin, theCos);
-
-  if (aDestFeature)
-    aDestFeature->data()->blockSendAttributeUpdated(false);
-}
-
-static void translate(EntityWrapperPtr theSource, EntityWrapperPtr theDest,
-                      std::shared_ptr<GeomAPI_XY> theDelta)
-{
-  if (theSource->type() == ENTITY_POINT) {
-    // Translate single point
-    std::shared_ptr<GeomDataAPI_Point2D> aSrcAttr =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theSource->baseAttribute());
-    std::shared_ptr<GeomDataAPI_Point2D> aDstAttr =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(theDest->baseAttribute());
-    if (aSrcAttr && aDstAttr)
-      aDstAttr->setValue(aSrcAttr->x() + theDelta->x(), aSrcAttr->y() + theDelta->y());
-    return;
-  }
-
-  FeaturePtr aDestFeature = theDest->baseFeature();
-  if (aDestFeature)
-    aDestFeature->data()->blockSendAttributeUpdated(true);
-
-  // Translate points of the feature
-  const std::list<EntityWrapperPtr>& aSrcSubs = theSource->subEntities();
-  const std::list<EntityWrapperPtr>& aDstSubs = theDest->subEntities();
-  std::list<EntityWrapperPtr>::const_iterator aSrcIt, aDstIt;
-  for (aSrcIt = aSrcSubs.begin(), aDstIt = aDstSubs.begin();
-       aSrcIt != aSrcSubs.end() && aDstIt != aDstSubs.end(); ++aSrcIt, ++aDstIt)
-    translate(*aSrcIt, *aDstIt, theDelta);
-
-  if (aDestFeature)
-    aDestFeature->data()->blockSendAttributeUpdated(false);
-}
-
-void adjustMultiRotation(ConstraintWrapperPtr theConstraint)
-{
-  BuilderPtr aBuilder = PlaneGCSSolver_Builder::getInstance();
-
-  double anAngleRad = theConstraint->value() * PI / 180.0;
-  double aSin = sin(anAngleRad);
-  double aCos = cos(anAngleRad);
-
-  const std::list<EntityWrapperPtr>& aSubs = theConstraint->entities();
-  std::list<EntityWrapperPtr>::const_iterator aSIt = aSubs.begin();
-
-  std::shared_ptr<GeomAPI_Pnt2d> aCenter = aBuilder->point(*aSIt++);
-  std::list<EntityWrapperPtr>::const_iterator aPrevIt = aSIt++;
-  for (; aSIt != aSubs.end(); ++aPrevIt, ++aSIt)
-    rotate(*aPrevIt, *aSIt, aCenter, aSin, aCos);
-}
-
-void adjustMultiTranslation(ConstraintWrapperPtr theConstraint)
-{
-  BuilderPtr aBuilder = PlaneGCSSolver_Builder::getInstance();
-
-  const std::list<EntityWrapperPtr>& aSubs = theConstraint->entities();
-  std::list<EntityWrapperPtr>::const_iterator aSIt = aSubs.begin();
-
-  std::shared_ptr<GeomAPI_Pnt2d> aStartPnt = aBuilder->point(*aSIt++);
-  std::shared_ptr<GeomAPI_Pnt2d> aEndPnt = aBuilder->point(*aSIt++);
-  std::shared_ptr<GeomAPI_XY> aDelta = aEndPnt->xy()->decreased(aStartPnt->xy());
-
-  std::list<EntityWrapperPtr>::const_iterator aPrevIt = aSIt++;
-  for (; aSIt != aSubs.end(); ++aPrevIt, ++aSIt)
-    translate(*aPrevIt, *aSIt, aDelta);
-}
index c74580b07a479099cbdb40dfe0bac6cada2ca8bb..34fb4d17b525179faf294141fff76a7bb9c23f5e 100644 (file)
@@ -516,18 +516,6 @@ void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint)
     myConstraints.erase(aCIter);
 }
 
-// ============================================================================
-//  Function: isComplexConstraint
-//  Class:    SketchSolver_Group
-//  Purpose:  verifies the constraint is complex, i.e. it needs another constraints to be created before
-// ============================================================================
-bool SketchSolver_Group::isComplexConstraint(FeaturePtr theConstraint)
-{
-  return theConstraint->getKind() == SketchPlugin_ConstraintFillet::ID() ||
-         theConstraint->getKind() == SketchPlugin_ConstraintMirror::ID() ||
-         theConstraint->getKind() == SketchPlugin_ConstraintTangent::ID();
-}
-
 // ============================================================================
 //  Function: setTemporary
 //  Class:    SketchSolver_Group
index 7544fbaa2c7600d32348054ea90f37449e15ea96..6d7dff33926702865e2210582e7686e7cccfe48f 100644 (file)
@@ -61,9 +61,6 @@ class SketchSolver_Group
     return mySketch->data() && mySketch->data()->isValid();
   }
 
-  /// \brief Verifies the constraint is complex, i.e. it needs another constraints to be created before
-  static bool isComplexConstraint(FeaturePtr theConstraint);
-
   /** \brief Adds or updates a constraint in the group
    *  \param[in] theConstraint constraint to be changed
    *  \return \c true if the constraint added or updated successfully
index 704b4b0d53e2c10dee70736c302b2ee9ffa304c5..9d7339ac7223e10813a2931ae2bd302eeeaaec99 100644 (file)
@@ -51,10 +51,6 @@ static void adjustTangency(ConstraintWrapperPtr theConstraint);
 static void adjustAngle(ConstraintWrapperPtr theConstraint);
 /// \brief Update mirror points
 static void adjustMirror(ConstraintWrapperPtr theConstraint);
-/// \brief Update positions of rotated features
-static void adjustMultiRotation(ConstraintWrapperPtr theConstraint);
-/// \brief Update positions of translated features
-static void adjustMultiTranslation(ConstraintWrapperPtr theConstraint);
 
 /// \brief Transform points to be symmetric regarding to the mirror line
 static void makeMirrorPoints(EntityWrapperPtr theOriginal,
@@ -121,6 +117,7 @@ std::list<ConstraintWrapperPtr> SolveSpaceSolver_Builder::createConstraint(
       SLVS_C_UNKNOWN, (Slvs_hGroup)theGroupID, aType, (Slvs_hEntity)theSketchID,
       theValue, aSlvsEntities[0], aSlvsEntities[1], aSlvsEntities[2], aSlvsEntities[3]);
   ConstraintWrapperPtr aResult(new SolveSpaceSolver_ConstraintWrapper(theConstraint, aConstraint));
+  aResult->setGroup(theGroupID);
   aResult->setValue(theValue);
   aResult->setEntities(aConstrAttrList);
   adjustConstraint(aResult);
@@ -156,6 +153,7 @@ std::list<ConstraintWrapperPtr> SolveSpaceSolver_Builder::createConstraint(
   aConstrAttrList.push_front(thePoint1);
 
   ConstraintWrapperPtr aResult(new SolveSpaceSolver_ConstraintWrapper(theConstraint, aConstraint));
+  aResult->setGroup(theGroupID);
   aResult->setValue(theValue);
   aResult->setIsFullValue(theFullValue);
   aResult->setEntities(aConstrAttrList);
@@ -189,6 +187,7 @@ std::list<ConstraintWrapperPtr> SolveSpaceSolver_Builder::createMirror(
 
     ConstraintWrapperPtr aWrapper(new SolveSpaceSolver_ConstraintWrapper(
         theConstraint, aConstraint));
+    aWrapper->setGroup(theGroupID);
     aWrapper->setEntities(aConstrAttrList);
     aResult.push_back(aWrapper);
   }
@@ -265,10 +264,6 @@ void SolveSpaceSolver_Builder::adjustConstraint(ConstraintWrapperPtr theConstrai
     adjustAngle(theConstraint);
   else if (aType == CONSTRAINT_SYMMETRIC)
     adjustMirror(theConstraint);
-  else if (aType == CONSTRAINT_MULTI_ROTATION)
-    adjustMultiRotation(theConstraint);
-  else if (aType == CONSTRAINT_MULTI_TRANSLATION)
-    adjustMultiTranslation(theConstraint);
 }
 
 EntityWrapperPtr SolveSpaceSolver_Builder::createFeature(
@@ -789,126 +784,3 @@ void makeMirrorPoints(EntityWrapperPtr theOriginal,
     aMirroredPnt->setValue(aCoord[0], aCoord[1]);
   }
 }
-
-static void rotate(EntityWrapperPtr theSource, EntityWrapperPtr theDest,
-                   std::shared_ptr<GeomAPI_Pnt2d> theCenter,
-                   double theSin, double theCos)
-{
-  std::shared_ptr<SolveSpaceSolver_EntityWrapper> aSource =
-      std::dynamic_pointer_cast<SolveSpaceSolver_EntityWrapper>(theSource);
-  std::shared_ptr<SolveSpaceSolver_EntityWrapper> aDest =
-      std::dynamic_pointer_cast<SolveSpaceSolver_EntityWrapper>(theDest);
-
-  if (theSource->type() == ENTITY_POINT) {
-    // Rotate single point
-    std::shared_ptr<GeomDataAPI_Point2D> aSrcAttr =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aSource->baseAttribute());
-    std::shared_ptr<GeomDataAPI_Point2D> aDstAttr =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aDest->baseAttribute());
-    if (aSrcAttr && aDstAttr) {
-      std::shared_ptr<GeomAPI_XY> aVec = aSrcAttr->pnt()->xy()->decreased(theCenter->xy());
-      double aNewX = aVec->x() * theCos - aVec->y() * theSin;
-      double aNewY = aVec->x() * theSin + aVec->y() * theCos;
-      aDstAttr->setValue(theCenter->x() + aNewX, theCenter->y() + aNewY);
-    }
-    return;
-  }
-
-  FeaturePtr aDestFeature = aDest->baseFeature();
-  if (aDestFeature)
-    aDestFeature->data()->blockSendAttributeUpdated(true);
-
-  // Rotate points of the feature
-  const std::list<EntityWrapperPtr>& aSrcSubs = theSource->subEntities();
-  const std::list<EntityWrapperPtr>& aDstSubs = theDest->subEntities();
-  std::list<EntityWrapperPtr>::const_iterator aSrcIt, aDstIt;
-  for (aSrcIt = aSrcSubs.begin(), aDstIt = aDstSubs.begin();
-       aSrcIt != aSrcSubs.end() && aDstIt != aDstSubs.end(); ++aSrcIt, ++aDstIt)
-    rotate(*aSrcIt, *aDstIt, theCenter, theSin, theCos);
-
-  if (aDestFeature)
-    aDestFeature->data()->blockSendAttributeUpdated(false);
-}
-
-static void translate(EntityWrapperPtr theSource, EntityWrapperPtr theDest,
-                      std::shared_ptr<GeomAPI_XY> theDelta)
-{
-  std::shared_ptr<SolveSpaceSolver_EntityWrapper> aSource =
-      std::dynamic_pointer_cast<SolveSpaceSolver_EntityWrapper>(theSource);
-  std::shared_ptr<SolveSpaceSolver_EntityWrapper> aDest =
-      std::dynamic_pointer_cast<SolveSpaceSolver_EntityWrapper>(theDest);
-
-  if (theSource->type() == ENTITY_POINT) {
-    // Translate single point
-    std::shared_ptr<GeomDataAPI_Point2D> aSrcAttr =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aSource->baseAttribute());
-    std::shared_ptr<GeomDataAPI_Point2D> aDstAttr =
-        std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aDest->baseAttribute());
-    if (aSrcAttr && aDstAttr)
-      aDstAttr->setValue(aSrcAttr->x() + theDelta->x(), aSrcAttr->y() + theDelta->y());
-    return;
-  }
-
-  FeaturePtr aDestFeature = aDest->baseFeature();
-  if (aDestFeature)
-    aDestFeature->data()->blockSendAttributeUpdated(true);
-
-  // Translate points of the feature
-  const std::list<EntityWrapperPtr>& aSrcSubs = theSource->subEntities();
-  const std::list<EntityWrapperPtr>& aDstSubs = theDest->subEntities();
-  std::list<EntityWrapperPtr>::const_iterator aSrcIt, aDstIt;
-  for (aSrcIt = aSrcSubs.begin(), aDstIt = aDstSubs.begin();
-       aSrcIt != aSrcSubs.end() && aDstIt != aDstSubs.end(); ++aSrcIt, ++aDstIt)
-    translate(*aSrcIt, *aDstIt, theDelta);
-
-  if (aDestFeature)
-    aDestFeature->data()->blockSendAttributeUpdated(false);
-}
-
-void adjustMultiRotation(ConstraintWrapperPtr theConstraint)
-{
-  BuilderPtr aBuilder = SolveSpaceSolver_Builder::getInstance();
-
-  double anAngleValue = theConstraint->value();
-  const std::list<EntityWrapperPtr>& aSubs = theConstraint->entities();
-
-  bool isFullValue = theConstraint->isFullValue();
-  int aNbObjects = aSubs.size()-2;
-  if (isFullValue && aNbObjects > 0) {
-    anAngleValue /= aNbObjects;
-  }
-
-  double anAngleRad = anAngleValue * PI / 180.0;
-  double aSin = sin(anAngleRad);
-  double aCos = cos(anAngleRad);
-
-  std::list<EntityWrapperPtr>::const_iterator aSIt = aSubs.begin();
-
-  std::shared_ptr<GeomAPI_Pnt2d> aCenter = aBuilder->point(*aSIt++);
-  std::list<EntityWrapperPtr>::const_iterator aPrevIt = aSIt++;
-  for (; aSIt != aSubs.end(); ++aPrevIt, ++aSIt)
-    rotate(*aPrevIt, *aSIt, aCenter, aSin, aCos);
-}
-
-void adjustMultiTranslation(ConstraintWrapperPtr theConstraint)
-{
-  BuilderPtr aBuilder = SolveSpaceSolver_Builder::getInstance();
-
-  const std::list<EntityWrapperPtr>& aSubs = theConstraint->entities();
-  std::list<EntityWrapperPtr>::const_iterator aSIt = aSubs.begin();
-
-  std::shared_ptr<GeomAPI_Pnt2d> aStartPnt = aBuilder->point(*aSIt++);
-  std::shared_ptr<GeomAPI_Pnt2d> aEndPnt = aBuilder->point(*aSIt++);
-  std::shared_ptr<GeomAPI_XY> aDelta = aEndPnt->xy()->decreased(aStartPnt->xy());
-
-  bool isFullValue = theConstraint->isFullValue();
-  int aNbObjects = aSubs.size()-3;
-  if (isFullValue && aNbObjects > 0) {
-    aDelta->setX(aDelta->x()/aNbObjects);
-    aDelta->setY(aDelta->y()/aNbObjects);
-  }
-
-  std::list<EntityWrapperPtr>::const_iterator aPrevIt = aSIt++;
-  for (; aSIt != aSubs.end(); ++aPrevIt, ++aSIt)
-    translate(*aPrevIt, *aSIt, aDelta);
-}
index e065fd245a7233bb4c5670124d34dd77396fea83..fcd53d0e62361d13dd037a35b77bd543c7bb8b4d 100644 (file)
@@ -741,105 +741,6 @@ bool SolveSpaceSolver_Storage::removeEntity(const Slvs_hEntity& theEntityID)
   return aResult;
 }
 
-void SolveSpaceSolver_Storage::removeUnusedEntities()
-{
-  std::set<Slvs_hEntity> anUnusedEntities;
-  std::vector<Slvs_Entity>::const_iterator aEIt = myEntities.begin();
-  for (; aEIt != myEntities.end(); ++aEIt) {
-    if (aEIt->h == aEIt->wrkpl) {
-      // don't remove workplane
-      anUnusedEntities.erase(aEIt->point[0]);
-      anUnusedEntities.erase(aEIt->normal);
-      continue;
-    }
-    anUnusedEntities.insert(aEIt->h);
-  }
-
-  std::vector<Slvs_Constraint>::const_iterator aCIt = myConstraints.begin();
-  for (; aCIt != myConstraints.end(); ++aCIt) {
-    Slvs_hEntity aSubs[6] = {
-        aCIt->entityA, aCIt->entityB,
-        aCIt->entityC, aCIt->entityD,
-        aCIt->ptA,     aCIt->ptB};
-    for (int i = 0; i < 6; i++) {
-      if (aSubs[i] != SLVS_E_UNKNOWN) {
-        anUnusedEntities.erase(aSubs[i]);
-        int aPos = Search(aSubs[i], myEntities);
-        if (aPos >= 0 && aPos < (int)myEntities.size()) {
-          for (int j = 0; j < 4; j++)
-            if (myEntities[aPos].point[j] != SLVS_E_UNKNOWN)
-              anUnusedEntities.erase(myEntities[aPos].point[j]);
-          if (myEntities[aPos].distance != SLVS_E_UNKNOWN)
-            anUnusedEntities.erase(myEntities[aPos].distance);
-        }
-      }
-    }
-  }
-
-  std::set<Slvs_hEntity>::const_iterator anEntIt = anUnusedEntities.begin();
-  while (anEntIt != anUnusedEntities.end()) {
-    int aPos = Search(*anEntIt, myEntities);
-    if (aPos < 0 && aPos >= (int)myEntities.size())
-      continue;
-    Slvs_Entity anEntity = myEntities[aPos];
-    // Remove entity if and only if all its parameters unused
-    bool isUsed = false;
-    if (anEntity.distance != SLVS_E_UNKNOWN && 
-      anUnusedEntities.find(anEntity.distance) == anUnusedEntities.end())
-      isUsed = true;
-    for (int i = 0; i < 4 && !isUsed; i++)
-      if (anEntity.point[i] != SLVS_E_UNKNOWN &&
-          anUnusedEntities.find(anEntity.point[i]) == anUnusedEntities.end())
-        isUsed = true;
-    if (isUsed) {
-      anUnusedEntities.erase(anEntity.distance);
-      for (int i = 0; i < 4; i++)
-        if (anEntity.point[i] != SLVS_E_UNKNOWN)
-          anUnusedEntities.erase(anEntity.point[i]);
-      std::set<Slvs_hEntity>::iterator aRemoveIt = anEntIt++;
-      anUnusedEntities.erase(aRemoveIt);
-      continue;
-    }
-    ++anEntIt;
-  }
-
-  for (anEntIt = anUnusedEntities.begin(); anEntIt != anUnusedEntities.end(); ++anEntIt) {
-    int aPos = Search(*anEntIt, myEntities);
-    if (aPos >= 0 && aPos < (int)myEntities.size()) {
-      // Remove entity and its parameters
-      Slvs_Entity anEntity = myEntities[aPos];
-      myEntities.erase(myEntities.begin() + aPos);
-      myEntityMaxID = myEntities.empty() ? SLVS_E_UNKNOWN : myEntities.back().h;
-      if (anEntity.distance != SLVS_E_UNKNOWN)
-        removeParameter(anEntity.distance);
-      for (int i = 0; i < 4; i++)
-        if (anEntity.param[i] != SLVS_E_UNKNOWN)
-          removeParameter(anEntity.param[i]);
-      for (int i = 0; i < 4; i++)
-        if (anEntity.point[i] != SLVS_E_UNKNOWN)
-          removeEntity(anEntity.point[i]);
-    }
-  }
-
-  if (!anUnusedEntities.empty())
-    myNeedToResolve = true;
-}
-
-bool SolveSpaceSolver_Storage::isUsedByConstraints(const Slvs_hEntity& theEntityID) const
-{
-  std::vector<Slvs_Constraint>::const_iterator aCIt = myConstraints.begin();
-  for (; aCIt != myConstraints.end(); ++aCIt) {
-    Slvs_hEntity aSubs[6] = {
-        aCIt->entityA, aCIt->entityB,
-        aCIt->entityC, aCIt->entityD,
-        aCIt->ptA,     aCIt->ptB};
-    for (int i = 0; i < 6; i++)
-      if (aSubs[i] != SLVS_E_UNKNOWN && aSubs[i] == theEntityID)
-        return true;
-  }
-  return false;
-}
-
 const Slvs_Entity& SolveSpaceSolver_Storage::getEntity(const Slvs_hEntity& theEntityID) const
 {
   int aPos = Search(theEntityID, myEntities);
@@ -852,59 +753,6 @@ const Slvs_Entity& SolveSpaceSolver_Storage::getEntity(const Slvs_hEntity& theEn
   return aDummy;
 }
 
-Slvs_hEntity SolveSpaceSolver_Storage::copyEntity(const Slvs_hEntity& theCopied)
-{
-  int aPos = Search(theCopied, myEntities);
-  if (aPos < 0 || aPos >= (int)myEntities.size())
-    return SLVS_E_UNKNOWN;
-
-  Slvs_Entity aCopy = myEntities[aPos];
-  aCopy.h = SLVS_E_UNKNOWN;
-  int i = 0;
-  while (aCopy.point[i] != SLVS_E_UNKNOWN) {
-    aCopy.point[i] = copyEntity(aCopy.point[i]);
-    i++;
-  }
-  if (aCopy.param[0] != SLVS_E_UNKNOWN) {
-    aPos = Search(aCopy.param[0], myParameters);
-    i = 0;
-    while (aCopy.param[i] != SLVS_E_UNKNOWN) {
-      Slvs_Param aNewParam = myParameters[aPos];
-      aNewParam.h = SLVS_E_UNKNOWN;
-      aCopy.param[i] = addParameter(aNewParam);
-      i++;
-      aPos++;
-    }
-  }
-  return addEntity(aCopy);
-}
-
-void SolveSpaceSolver_Storage::copyEntity(const Slvs_hEntity& theFrom, const Slvs_hEntity& theTo)
-{
-  int aPosFrom = Search(theFrom, myEntities);
-  int aPosTo = Search(theTo, myEntities);
-  if (aPosFrom < 0 || aPosFrom >= (int)myEntities.size() || 
-      aPosTo < 0 || aPosTo >= (int)myEntities.size())
-    return;
-
-  Slvs_Entity aEntFrom = myEntities[aPosFrom];
-  Slvs_Entity aEntTo = myEntities[aPosTo];
-  int i = 0;
-  while (aEntFrom.point[i] != SLVS_E_UNKNOWN) {
-    copyEntity(aEntFrom.point[i], aEntTo.point[i]);
-    i++;
-  }
-  if (aEntFrom.param[0] != SLVS_E_UNKNOWN) {
-    aPosFrom = Search(aEntFrom.param[0], myParameters);
-    aPosTo = Search(aEntTo.param[0], myParameters);
-    i = 0;
-    while (aEntFrom.param[i] != SLVS_E_UNKNOWN) {
-      myParameters[aPosTo++].val = myParameters[aPosFrom++].val;
-      i++;
-    }
-  }
-}
-
 
 Slvs_hConstraint SolveSpaceSolver_Storage::addConstraint(const Slvs_Constraint& theConstraint)
 {
index a6646caa05dc5a198e9964c12a0fbed0300a83ea..b9937ce21219ecd02e556f566a6199603c31c72f 100644 (file)
@@ -112,17 +112,8 @@ public:
    *  \return \c true if the entity was successfully removed
    */
   bool removeEntity(const Slvs_hEntity& theEntityID);
-  /** \brief Remove all entities, which are not used in constraints
-   */
-  void removeUnusedEntities();
   /// \brief Returns the entity by its ID
   const Slvs_Entity& getEntity(const Slvs_hEntity& theEntityID) const;
-  /// \brief Makes a full copy of the given entity
-  Slvs_hEntity copyEntity(const Slvs_hEntity& theCopied);
-  /// \brief Copy one entity to another
-  void copyEntity(const Slvs_hEntity& theFrom, const Slvs_hEntity& theTo);
-  /// \brief Check the entity is used in constraints
-  bool isUsedByConstraints(const Slvs_hEntity& theEntityID) const;
   /// \brief Returns maximal ID of entities in this storage
   const Slvs_hEntity& entityMaxID() const
   { return myEntityMaxID; }