Salome HOME
Receive DoF from the solver. Update test cases to check DoF.
authorazv <azv@opencascade.com>
Mon, 27 Feb 2017 14:27:11 +0000 (17:27 +0300)
committerazv <azv@opencascade.com>
Tue, 28 Feb 2017 10:55:31 +0000 (13:55 +0300)
36 files changed:
src/PythonAPI/model/sketcher/__init__.py
src/PythonAPI/model/sketcher/tools.py
src/SketchAPI/SketchAPI_Projection.cpp
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/Test/TestConstraintAngle.py
src/SketchPlugin/Test/TestConstraintCoincidence.py
src/SketchPlugin/Test/TestConstraintCollinear.py
src/SketchPlugin/Test/TestConstraintDistance.py
src/SketchPlugin/Test/TestConstraintEqual.py
src/SketchPlugin/Test/TestConstraintFixed.py [new file with mode: 0644]
src/SketchPlugin/Test/TestConstraintHorizontal.py
src/SketchPlugin/Test/TestConstraintLength.py
src/SketchPlugin/Test/TestConstraintMiddlePoint.py
src/SketchPlugin/Test/TestConstraintMirror.py
src/SketchPlugin/Test/TestConstraintParallel.py
src/SketchPlugin/Test/TestConstraintPerpendicular.py
src/SketchPlugin/Test/TestConstraintRadius.py
src/SketchPlugin/Test/TestConstraintRigid.py [deleted file]
src/SketchPlugin/Test/TestConstraintTangent.py
src/SketchPlugin/Test/TestConstraintVertical.py
src/SketchPlugin/Test/TestFillet.py
src/SketchPlugin/Test/TestHighload.py
src/SketchPlugin/Test/TestMultiRotation.py
src/SketchPlugin/Test/TestMultiTranslation.py
src/SketchPlugin/Test/TestProjection.py
src/SketchPlugin/Test/TestRectangle.py
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_FeatureBuilder.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Solver.h
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp
src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.h
src/SketchSolver/SketchSolver_ConstraintEqual.cpp
src/SketchSolver/SketchSolver_Group.cpp
src/SketchSolver/SketchSolver_Group.h
src/SketchSolver/SketchSolver_ISolver.h
src/SketchSolver/SketchSolver_Storage.h

index 7aa9934344907a8229d5091b0bcc5fc7edc7680f..994ecc6f11ef8b05af65e40c5659c59a7b302be7 100644 (file)
@@ -2,4 +2,4 @@
 """
 
 from SketchAPI import addSketch
-from tools import addPolyline, addPolygon
+from tools import addPolyline, addPolygon, dof
index fc0e39a2572e290f8fb425803b9a71c4e86a3917..31efc0f2837f28290a468aea7c0d2e3643b833ae 100644 (file)
@@ -39,4 +39,9 @@ def addPolygon(sketch, *coords):
         ln.endPoint(), pg[0].startPoint()
         )
     pg.append(ln)
-    return pg
\ No newline at end of file
+    return pg
+
+def dof(sketch):
+    """ Extract degrees of freedom for the given sketch
+    """
+    return int(filter(str.isdigit, sketch.string("SolverDOF").value()))
\ No newline at end of file
index 0b3021f79bebd5b58e9f7906f9a9b66bc058cc74..7a074c020fad3fb610c79936fb0aaa045ac9213d 100644 (file)
@@ -56,14 +56,14 @@ void SketchAPI_Projection::setExternalFeature(const ModelHighAPI_Selection & the
 {
   fillAttribute(theExternalFeature, externalFeature());
 
-  execute();
+  execute(true);
 }
 
 void SketchAPI_Projection::setByExternalName(const std::string& theExternalName)
 {
   fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
 
-  execute();
+  execute(true);
 }
 
 //--------------------------------------------------------------------------------------
index 90d57ff702d58a332e94fce8d905fe112cb81665..c72d4ef9efa23525768bed5b2de58b082135a7c5 100644 (file)
@@ -127,7 +127,7 @@ ADD_UNIT_TESTS(TestSketchPointLine.py
                TestConstraintParallel.py
                TestConstraintPerpendicular.py
                TestConstraintRadius.py
-               TestConstraintRigid.py
+               TestConstraintFixed.py
                TestConstraintHorizontal.py
                TestConstraintVertical.py
                TestConstraintEqual.py
index 83a3335464937a7833c6e31ed3464c9f2441d2c1..0d88ec14f1816e3bd9a9d657ad84045d1059729b 100644 (file)
@@ -13,8 +13,8 @@
 """
 from GeomDataAPI import *
 from ModelAPI import *
-import os
 import math
+from salome.shaper import model
 
 #=========================================================================
 # Auxiliary functions
@@ -81,6 +81,7 @@ aEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
 aStartPoint.setValue(-10., 15.)
 aEndPoint.setValue(80., 50.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Make a constraint to keep the angle
 #=========================================================================
@@ -108,6 +109,7 @@ assert (anAngleVal.isInitialized())
 assert (refattrA.isInitialized())
 assert (refattrB.isInitialized())
 assert (angle(aSketchLineA, aSketchLineB) == ANGLE_DEGREE)
+assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
 # Move line, check that angle is constant
 #=========================================================================
@@ -117,6 +119,7 @@ aStartPoint.setValue(0., -30.)
 aConstraint.execute()
 aSession.finishOperation()
 assert (angle(aSketchLineA, aSketchLineB) == ANGLE_DEGREE)
+assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
 # Change angle value and check the lines are moved
 #=========================================================================
@@ -126,6 +129,7 @@ anAngleVal.setValue(NEW_ANGLE_DEGREE)
 aConstraint.execute()
 aSession.finishOperation()
 assert (angle(aSketchLineA, aSketchLineB) == NEW_ANGLE_DEGREE)
+assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
 # Change angle type
 #=========================================================================
@@ -137,17 +141,21 @@ aSession.startOperation()
 aConstraint.integer("AngleType").setValue(ANGLE_BACKWARD)
 aSession.finishOperation()
 assert (angle(aSketchLineA, aSketchLineB) == NEW_ANGLE_DEGREE)
+assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
-# TODO: improve test
-# 1. remove constraint, move line's start point to
-#    check that constraint are not applied
-# 2. check constrained distance between:
-#    * point and line
-#    * two lines
+# Remove constraint, move line's point to check the constraint is not applied
 #=========================================================================
+aSession.startOperation()
+aDocument.removeFeature(aConstraint)
+aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
+aSession.startOperation()
+aStartPoint.setValue(-30., 0.)
+aSession.finishOperation()
+assert (angle(aSketchLineA, aSketchLineB) != NEW_ANGLE_DEGREE)
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index f416f5d26a0d5f0a40cb65a3665e91c9447df479..0ee20f691de2f3413b968b203730bce1f35706be 100644 (file)
@@ -19,6 +19,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -97,6 +99,7 @@ aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 aLineStartPoint.setValue(50., 0.)
 aLineEndPoint.setValue(100., 25.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 9)
 #=========================================================================
 # Link arc's end and line's start points with concidence constraint
 #=========================================================================
@@ -108,6 +111,7 @@ reflistA.setAttr(anArcEndPoint)
 reflistB.setAttr(aLineStartPoint)
 aConstraint.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
 # Check values and move one constrainted object
 #=========================================================================
@@ -124,6 +128,7 @@ aSession.finishOperation()
 # check that arc's points are moved also
 assert (anArcEndPoint.x() == aLineStartPoint.x())
 assert (anArcEndPoint.y() == aLineStartPoint.y())
+assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
 # Remove coincidence and move the line
 #=========================================================================
@@ -134,6 +139,7 @@ aSession.startOperation()
 aLineStartPoint.setValue(70., 0.)
 aSession.finishOperation()
 assert (anArcEndPoint.x() != aLineStartPoint.x() or anArcEndPoint.y() != aLineStartPoint.y())
+assert (model.dof(aSketchFeature) == 9)
 
 #=========================================================================
 # Add constraint point-on-line
@@ -147,6 +153,7 @@ reflistB.setObject(aSketchLine.lastResult())
 aConstraint.execute()
 aSession.finishOperation()
 checkPointOnLine(anArcStartPoint, aSketchLine)
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Add constraint point-on-circle
 #=========================================================================
@@ -158,6 +165,7 @@ aCircleRadius = aSketchCircle.real("CircleRadius")
 aCircleCenter.setValue(10., 10.)
 aCircleRadius.setValue(25.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 11)
 # create origin
 aSession.startOperation()
 anOrigRes = modelAPI_Result(aDocument.objectByName("Construction", anOriginName))
@@ -169,6 +177,7 @@ anOriginCoord = geomDataAPI_Point2D(anOrigin.attribute("PointCoordindates"))
 anOriginCoord.setValue(0., 0.)
 anOrigin.selection("External").setValue(anOrigRes, anOrigShape)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 11)
 # coincidence between center of circle and the origin
 aSession.startOperation()
 aConstraint = aSketchFeature.addFeature("SketchConstraintCoincidence")
@@ -177,6 +186,7 @@ reflistB = aConstraint.refattr("ConstraintEntityB")
 reflistA.setAttr(aCircleCenter)
 reflistB.setObject(anOrigin.lastResult())
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 9)
 # point-on-circle
 aSession.startOperation()
 aConstraint = aSketchFeature.addFeature("SketchConstraintCoincidence")
@@ -187,6 +197,7 @@ reflistB.setAttr(aLineEndPoint)
 aConstraint.execute()
 aSession.finishOperation()
 checkPointOnCircle(aLineEndPoint, aSketchCircle)
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Add constraint point-on-arc
 #=========================================================================
@@ -201,6 +212,7 @@ aSession.finishOperation()
 checkPointOnArc(aCircleCenter, aSketchArc)
 # check center of circle is still in origin
 assert (aCircleCenter.x() == 0. and aCircleCenter.y() == 0.)
+assert (model.dof(aSketchFeature) == 7)
 
 #=========================================================================
 # Create two more lines and set multi-coincidence between their extremities
@@ -219,6 +231,7 @@ aLine3EndPoint = geomDataAPI_Point2D(aLine3.attribute("EndPoint"))
 aLine3StartPoint.setValue(50., 0.)
 aLine3EndPoint.setValue(0., 100.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 15)
 # coincidences between extremities of lines
 aSession.startOperation()
 aConstraint12 = aSketchFeature.addFeature("SketchConstraintCoincidence")
@@ -240,6 +253,7 @@ aSession.finishOperation()
 # check the points have same coordinates
 assert (aLineStartPoint.x() == aLine2StartPoint.x() and aLineStartPoint.y() == aLine2StartPoint.y())
 assert (aLineStartPoint.x() == aLine3StartPoint.x() and aLineStartPoint.y() == aLine3StartPoint.y())
+assert (model.dof(aSketchFeature) == 11)
 #=========================================================================
 # Move one line and check other have been updated too
 #=========================================================================
@@ -251,6 +265,7 @@ aLine3EndPoint.setValue(aLine3EndPoint.x() + deltaX,
 aSession.finishOperation()
 assert (aLineStartPoint.x() == aLine2StartPoint.x() and aLineStartPoint.y() == aLine2StartPoint.y())
 assert (aLineStartPoint.x() == aLine3StartPoint.x() and aLineStartPoint.y() == aLine3StartPoint.y())
+assert (model.dof(aSketchFeature) == 11)
 #=========================================================================
 # Fix a line and move another connected segment
 #=========================================================================
@@ -271,6 +286,7 @@ aSession.finishOperation()
 assert (aLineStartPoint.x() == coordX and aLineStartPoint.y() == coordY)
 assert (aLine2StartPoint.x() == coordX and aLine2StartPoint.y() == coordY)
 assert (aLine3StartPoint.x() == coordX and aLine3StartPoint.y() == coordY)
+assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
 # Detach fixed line and move one of remaining
 #=========================================================================
@@ -289,10 +305,10 @@ aLineEndPoint.setValue(aLineEndPoint.x() + deltaX,
 aSession.finishOperation()
 assert (aLineStartPoint.x() != aLine2StartPoint.x() or aLineStartPoint.y() != aLine2StartPoint.y())
 assert (aLineStartPoint.x() == aLine3StartPoint.x() and aLineStartPoint.y() == aLine3StartPoint.y())
+assert (model.dof(aSketchFeature) == 9)
 
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index cb7e090ecec8447803b1c69e1aec14b63b2400b8..8097c8e62eac83f795d54c1258959bda54307803 100644 (file)
@@ -11,6 +11,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -71,6 +73,7 @@ aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
 aLineBStartPoint.setValue(0., 50)
 aLineBEndPoint.setValue(80., 75)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Link lines with collinear constraint
 #=========================================================================
@@ -83,6 +86,7 @@ refattrB.setObject(aSketchLineB.firstResult())
 aParallelConstraint.execute()
 aSession.finishOperation()
 checkCollinear(aSketchLineA, aSketchLineB)
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # Check values and move one constrainted object
 #=========================================================================
@@ -97,9 +101,9 @@ aLineAEndPoint.setValue(aLineAEndPoint.x() - deltaX,
                         aLineAEndPoint.y() - deltaY)
 aSession.finishOperation()
 checkCollinear(aSketchLineA, aSketchLineB)
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index 738bab161a07189322e31ed046b2f79152e5202d..2c8b5c6a02b0e2c68354bc08e25c3274cdf53cb8 100644 (file)
@@ -22,6 +22,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -84,6 +86,7 @@ aLineAEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 aLineAStartPoint.setValue(0., 25.)
 aLineAEndPoint.setValue(100., 25.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # Make a constraint to keep the distance
 #=========================================================================
@@ -105,6 +108,7 @@ aConstraint.execute()
 refattrA.setAttr(aSketchPointCoords)
 refattrB.setAttr(aLineAStartPoint)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 5)
 # set flyout point then abort operation, after that check the Distance is correct
 aSession.startOperation()
 aFlyoutPoint = geomDataAPI_Point2D(aConstraint.attribute("ConstraintFlyoutValuePnt"))
@@ -114,6 +118,7 @@ assert (refattrA.isInitialized())
 assert (refattrB.isInitialized())
 assert (aDistance.isInitialized())
 assert math.fabs(aDistance.value() - aDist) < 1.e-4, "Distance values are different: {0} != {1}".format(aDistance.value(), aDist)
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Change distance value
 #=========================================================================
@@ -121,6 +126,7 @@ aSession.startOperation()
 aDistance.setValue(PT_PT_DIST)
 aSession.finishOperation()
 assert (math.fabs(distancePointPoint(aSketchPointCoords, aLineAStartPoint) - PT_PT_DIST) < 1.e-10)
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Move line, check that distance is constant
 #=========================================================================
@@ -129,6 +135,7 @@ aLineAStartPoint.setValue(0., 40.)
 aLineAEndPoint.setValue(100., 40.)
 aSession.finishOperation()
 assert (math.fabs(distancePointPoint(aSketchPointCoords, aLineAStartPoint) - PT_PT_DIST) < 1.e-10)
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Remove constraint, check the points are unconstrained now
 #=========================================================================
@@ -139,6 +146,7 @@ aSession.startOperation()
 aSketchPointCoords.setValue(0., 0.)
 aSession.finishOperation()
 assert (math.fabs(distancePointPoint(aSketchPointCoords, aLineAStartPoint) - PT_PT_DIST) > 1.e-10)
+assert (model.dof(aSketchFeature) == 6)
 
 #=========================================================================
 # Add distance between point and line
@@ -158,6 +166,7 @@ assert (aLineResult is not None)
 refattrA.setObject(aLineResult)
 refattrB.setAttr(aSketchPointCoords)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 5)
 # set flyout point then abort operation, after that check the Distance is correct
 aSession.startOperation()
 aFlyoutPoint = geomDataAPI_Point2D(aConstraint.attribute("ConstraintFlyoutValuePnt"))
@@ -167,6 +176,7 @@ assert (refattrA.isInitialized())
 assert (refattrB.isInitialized())
 assert (aDistance.isInitialized())
 assert math.fabs(aDistance.value() - aDist) < 1.e-4, "Distance values are different: {0} != {1}".format(aDistance.value(), aDist)
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Change distance value
 #=========================================================================
@@ -174,6 +184,7 @@ aSession.startOperation()
 aDistance.setValue(PT_LINE_DIST)
 aSession.finishOperation()
 assert (math.fabs(distancePointLine(aSketchPointCoords, aSketchLine) - PT_LINE_DIST) < 1.e-10)
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Set distance between line boundaries
 #=========================================================================
@@ -182,9 +193,9 @@ refattrA.setAttr(aLineAStartPoint)
 refattrB.setAttr(aLineAEndPoint)
 aSession.finishOperation()
 assert (math.fabs(distancePointPoint(aLineAStartPoint, aLineAEndPoint) - PT_LINE_DIST) < 1.e-10)
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index e78dd6837a102712f047601b6cc5768a98e58e2c..c8d4917b4c36ec9900225bfb6e763f1a22a0df55 100644 (file)
@@ -11,6 +11,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -85,6 +87,7 @@ anArcStartPoint.setValue(0., 50.)
 anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
 anArcEndPoint.setValue(50., 0.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 5)
 # Circle
 aSession.startOperation()
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
@@ -93,6 +96,7 @@ aCircleRadius = aSketchCircle.real("CircleRadius")
 anCircleCentr.setValue(-25., -25.)
 aCircleRadius.setValue(25.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # A constraint to make equal radii of arc and circle
 #=========================================================================
@@ -113,6 +117,7 @@ anArcVecX = anArcStartPoint.x() - anArcCentr.x()
 anArcVecY = anArcStartPoint.y() - anArcCentr.y()
 anArcRadius = math.sqrt(anArcVecX**2 + anArcVecY**2)
 assert (math.fabs(aCircRadius - anArcRadius) <= 1.e-10)
+assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
 # A constraint to make equal radii of arc and external circle
 #=========================================================================
@@ -124,6 +129,7 @@ anExtCircleCenter.setValue(-50., 50.)
 anExtCircleRadius.setValue(10.)
 anExtCircle.selection("External").selectSubShape("EDGE", "Sketch_1/Edge-SketchCircle_1_2")
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 7)
 aSession.startOperation()
 aConstraintEqRad2 = aSketchFeature.addFeature("SketchConstraintEqual")
 aRefObjectA = aConstraintEqRad2.refattr("ConstraintEntityA")
@@ -136,6 +142,7 @@ anArcVecX = anArcStartPoint.x() - anArcCentr.x()
 anArcVecY = anArcStartPoint.y() - anArcCentr.y()
 anArcRadius = math.sqrt(anArcVecX**2 + anArcVecY**2)
 assert (math.fabs(anExtCircleRadius.value() - anArcRadius) <= 1.e-10)
+assert (model.dof(aSketchFeature) == 6)
 
 #=========================================================================
 # Creation of two different lines
@@ -156,6 +163,7 @@ aLine2EndPoint = geomDataAPI_Point2D(aSketchLine2.attribute("EndPoint"))
 aLine2StartPoint.setValue(0., 0.)
 aLine2EndPoint.setValue(-1., 10.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 14)
 #=========================================================================
 # A constraint to make equal lengths of lines
 #=========================================================================
@@ -174,6 +182,7 @@ aSession.finishOperation()
 aLine1Len = lineLength(aSketchLine1)
 aLine2Len = lineLength(aSketchLine2)
 assert (math.fabs(aLine1Len - aLine2Len) < 1.e-10)
+assert (model.dof(aSketchFeature) == 13)
 #=========================================================================
 # A constraint to make equal length of line with external line
 #=========================================================================
@@ -186,6 +195,7 @@ anExtLineEnd.setValue(-60., 25.)
 anExtLine.selection("External").selectSubShape("EDGE", "Sketch_1/Edge-SketchLine_1")
 anExtLineLen = lineLength(anExtLine)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 13)
 aSession.startOperation()
 aConstraintEqLen2 = aSketchFeature.addFeature("SketchConstraintEqual")
 aRefObjectA = aConstraintEqLen2.refattr("ConstraintEntityA")
@@ -197,9 +207,9 @@ aLine1Len = lineLength(aSketchLine1)
 aLine2Len = lineLength(aSketchLine2)
 assert (math.fabs(aLine1Len - anExtLineLen) < 1.e-10)
 assert (math.fabs(aLine2Len - anExtLineLen) < 1.e-10)
+assert (model.dof(aSketchFeature) == 12)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
diff --git a/src/SketchPlugin/Test/TestConstraintFixed.py b/src/SketchPlugin/Test/TestConstraintFixed.py
new file mode 100644 (file)
index 0000000..d3b6315
--- /dev/null
@@ -0,0 +1,156 @@
+"""
+    TestConstraintRigid.py
+    Unit test of SketchPlugin_ConstraintRigid class
+
+    SketchPlugin_Constraint
+        static const std::string MY_CONSTRAINT_VALUE("ConstraintValue");
+        static const std::string MY_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt");
+        static const std::string MY_ENTITY_A("ConstraintEntityA");
+        static const std::string MY_ENTITY_B("ConstraintEntityB");
+        static const std::string MY_ENTITY_C("ConstraintEntityC");
+        static const std::string MY_ENTITY_D("ConstraintEntityD");
+
+    SketchPlugin_ConstraintRigid
+        static const std::string MY_CONSTRAINT_RIGID_ID("SketchConstraintRigid");
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+
+"""
+from GeomDataAPI import *
+from ModelAPI import *
+from GeomAPI import *
+from salome.shaper import model
+
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+
+__updated__ = "2014-11-21"
+
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+#=========================================================================
+# Creation of a sketch
+#=========================================================================
+aSession.startOperation()
+aSketchCommonFeature = aDocument.addFeature("Sketch")
+aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aSession.finishOperation()
+#=========================================================================
+# Create a triangle ABC
+#=========================================================================
+aSession.startOperation()
+aSketchLineA = aSketchFeature.addFeature("SketchLine")
+aSketchLineB = aSketchFeature.addFeature("SketchLine")
+aSketchLineC = aSketchFeature.addFeature("SketchLine")
+aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
+aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint"))
+aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
+aLineCStartPoint = geomDataAPI_Point2D(aSketchLineC.attribute("StartPoint"))
+aLineCEndPoint = geomDataAPI_Point2D(aSketchLineC.attribute("EndPoint"))
+aLineAStartPoint.setValue(25., 25.)
+aLineAEndPoint.setValue(100., 25.)
+aLineBStartPoint.setValue(100., 25.)
+aLineBEndPoint.setValue(60., 75.)
+aLineCStartPoint.setValue(60., 75.)
+aLineCEndPoint.setValue(25., 25.)
+aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 12)
+# Store initial values of lines
+kLineAStart = (aLineAStartPoint.x(), aLineAStartPoint.y())
+kLineAEnd = (aLineAEndPoint.x(),   aLineAEndPoint.y())
+kLineBStart = (aLineBStartPoint.x(), aLineBStartPoint.y())
+kLineBEnd = (aLineBEndPoint.x(),   aLineBEndPoint.y())
+kLineCStart = (aLineCStartPoint.x(), aLineCStartPoint.y())
+kLineCEnd = (aLineCEndPoint.x(),   aLineCEndPoint.y())
+#=========================================================================
+# Link triange lines with concidence
+#=========================================================================
+concidenceLinks = zip([aLineBStartPoint, aLineCStartPoint, aLineAStartPoint],
+                      [aLineAEndPoint, aLineBEndPoint, aLineCEndPoint])
+aSession.startOperation()
+for eachLink in concidenceLinks:
+    aConstraint = aSketchFeature.addFeature("SketchConstraintCoincidence")
+    reflistA = aConstraint.refattr("ConstraintEntityA")
+    reflistB = aConstraint.refattr("ConstraintEntityB")
+    reflistA.setAttr(eachLink[0])
+    reflistB.setAttr(eachLink[1])
+    aConstraint.execute()
+aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 6)
+
+# Check that constarints doesn't affected lines' values
+assert (kLineAStart == (aLineAStartPoint.x(), aLineAStartPoint.y()))
+assert (kLineAEnd == (aLineAEndPoint.x(),   aLineAEndPoint.y()))
+assert (kLineBStart == (aLineBStartPoint.x(), aLineBStartPoint.y()))
+assert (kLineBEnd == (aLineBEndPoint.x(),   aLineBEndPoint.y()))
+assert (kLineCStart == (aLineCStartPoint.x(), aLineCStartPoint.y()))
+assert (kLineCEnd == (aLineCEndPoint.x(),   aLineCEndPoint.y()))
+#=========================================================================
+# Make line A rigid
+#=========================================================================
+aSession.startOperation()
+aRigidConstraint = aSketchFeature.addFeature("SketchConstraintRigid")
+eachRefattr = aRigidConstraint.refattr("ConstraintEntityA")
+lineResults = aSketchLineA.results()
+for eachResult in lineResults:
+    if eachResult.shape().isEdge():
+        break
+aResult = modelAPI_ResultConstruction(eachResult)
+assert (aResult is not None)
+eachRefattr.setObject(aResult)
+# aRigidConstraint.execute()
+aSession.finishOperation()
+
+# Check that constarints doesn't affected lines' values
+assert ((aLineAStartPoint.x(), aLineAStartPoint.y()) == (aLineCEndPoint.x(), aLineCEndPoint.y()))
+assert ((aLineBStartPoint.x(), aLineBStartPoint.y()) == (aLineAEndPoint.x(), aLineAEndPoint.y()))
+assert ((aLineCStartPoint.x(), aLineCStartPoint.y()) == (aLineBEndPoint.x(), aLineBEndPoint.y()))
+assert (model.dof(aSketchFeature) == 2)
+
+#=========================================================================
+# Check that moving line A does not affect lines
+#=========================================================================
+aSession.startOperation()
+aLineAEndPoint.setValue(90., 0.)
+aSession.finishOperation()
+# Check that constarint keep features' values
+assert ((aLineAStartPoint.x(), aLineAStartPoint.y()) == (aLineCEndPoint.x(), aLineCEndPoint.y()))
+assert ((aLineBStartPoint.x(), aLineBStartPoint.y()) == (aLineAEndPoint.x(), aLineAEndPoint.y()))
+assert ((aLineCStartPoint.x(), aLineCStartPoint.y()) == (aLineBEndPoint.x(), aLineBEndPoint.y()))
+assert (model.dof(aSketchFeature) == 2)
+
+#=========================================================================
+# Check that moving line B does not affect lines
+#=========================================================================
+aSession.startOperation()
+aLineBEndPoint.setValue(90., 150.)
+aSession.finishOperation()
+# Check that constarint keep features' values
+assert ((aLineAStartPoint.x(), aLineAStartPoint.y()) == (aLineCEndPoint.x(), aLineCEndPoint.y()))
+assert ((aLineBStartPoint.x(), aLineBStartPoint.y()) == (aLineAEndPoint.x(), aLineAEndPoint.y()))
+assert ((aLineCStartPoint.x(), aLineCStartPoint.y()) == (aLineBEndPoint.x(), aLineBEndPoint.y()))
+assert (model.dof(aSketchFeature) == 2)
+
+#=========================================================================
+# Remove constraint, move line to check that it is not fixed
+#=========================================================================
+aSession.startOperation()
+aDocument.removeFeature(aRigidConstraint)
+aLineBEndPoint.setValue(90., 150.)
+aSession.finishOperation()
+assert ((aLineAStartPoint.x(), aLineAStartPoint.y()) == (aLineCEndPoint.x(), aLineCEndPoint.y()))
+assert ((aLineBStartPoint.x(), aLineBStartPoint.y()) == (aLineAEndPoint.x(), aLineAEndPoint.y()))
+assert ((aLineCStartPoint.x(), aLineCStartPoint.y()) == (aLineBEndPoint.x(), aLineBEndPoint.y()))
+assert (model.dof(aSketchFeature) == 6)
+#=========================================================================
+# End of test
+#=========================================================================
+
+assert(model.checkPythonDump())
index f0a55dfe755d3a64368dee4776a3889f33b733aa..fa7c6cc04b73c3b40fc8ba69f85e6abf4294a169 100644 (file)
@@ -9,6 +9,8 @@
 """
 from GeomDataAPI import *
 from ModelAPI import *
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -40,6 +42,7 @@ aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 aLineStartPoint.setValue(0., 15.)
 aLineEndPoint.setValue(20., 25.)
 aSession.finishOperation()
+assert(model.dof(aSketchFeature) == 4)
 #=========================================================================
 # Assign horizontal constraint for a line
 #=========================================================================
@@ -52,6 +55,7 @@ refattrA.setObject(aResult)
 aHorizontalConstraint.execute()
 aSession.finishOperation()
 assert(aLineStartPoint.y() == aLineEndPoint.y())
+assert(model.dof(aSketchFeature) == 3)
 #=========================================================================
 # Move one of boundary points of a line
 #=========================================================================
@@ -61,6 +65,7 @@ aLineStartPoint.setValue(aLineStartPoint.x() + deltaX,
                          aLineStartPoint.y() + deltaY)
 aSession.finishOperation()
 assert(aLineStartPoint.y() == aLineEndPoint.y())
+assert(model.dof(aSketchFeature) == 3)
 #=========================================================================
 # Move other boundary point of a line
 #=========================================================================
@@ -71,9 +76,9 @@ aLineEndPoint.setValue(aLineEndPoint.x() + deltaX,
                        aLineEndPoint.y() + deltaY)
 aSession.finishOperation()
 assert(aLineStartPoint.y() == aLineEndPoint.y())
+assert(model.dof(aSketchFeature) == 3)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index 3d49d531734a91dfaf15e6d996cb03c36a95ff32..ac1345d4dfb1c7a381ce3f4cf23e027bc8d4d695 100644 (file)
@@ -12,6 +12,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -43,6 +45,7 @@ aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
 aLineAStartPoint.setValue(0., 25.)
 aLineAEndPoint.setValue(100., 25.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 4)
 #=========================================================================
 # Make a constraint to keep the length
 #=========================================================================
@@ -61,6 +64,7 @@ aLengthConstraint.execute()
 aSession.finishOperation()
 assert (aLength.isInitialized())
 assert (refattrA.isInitialized())
+assert (model.dof(aSketchFeature) == 3)
 #=========================================================================
 # Check values and move one constrainted object
 #=========================================================================
@@ -74,6 +78,7 @@ aSession.startOperation()
 aLineAStartPoint.setValue(aLineAStartPoint.x() + deltaX,
                           aLineAStartPoint.y())
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 3)
 assert (aLineAStartPoint.y() == 25)
 assert (aLineAEndPoint.y() == 25)
 # length of the line is the same
@@ -86,6 +91,7 @@ aLength.setValue(140.)
 aLengthConstraint.execute()
 aSession.finishOperation()
 assert (math.fabs(aLineAEndPoint.x() - aLineAStartPoint.x() - 140) < 1.e-10)
+assert (model.dof(aSketchFeature) == 3)
 #=========================================================================
 # TODO: improve test
 # 1. remove constraint, move line's start point to
@@ -95,5 +101,4 @@ assert (math.fabs(aLineAEndPoint.x() - aLineAStartPoint.x() - 140) < 1.e-10)
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index b9b0e70b7b802bd7223695aac0df100fc826100f..d8e69beb82929c1f2368bbad14398aa2a5c3d188 100644 (file)
@@ -19,6 +19,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -78,6 +80,7 @@ aEndPoint2 = geomDataAPI_Point2D(aLine2.attribute("EndPoint"))
 aStartPoint2.setValue(10., 100.)
 aEndPoint2.setValue(100., 25.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Make end point of second line middle point on first line
 #=========================================================================
@@ -106,6 +109,7 @@ reflistA.setAttr(aEndPoint2)
 reflistB.setObject(aLine1.lastResult())
 aConstraint.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 6)
 
 #=========================================================================
 # Check values and move one constrainted object
@@ -116,6 +120,7 @@ aSession.startOperation()
 aStartPoint1.setValue(aStartPoint1.x() + deltaX, aStartPoint1.y() + deltaY)
 aSession.finishOperation()
 checkMiddlePoint(aEndPoint2, aLine1)
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # Remove constraint and move the line
 #=========================================================================
@@ -123,10 +128,12 @@ aCurX, aCurY = aEndPoint2.x(), aEndPoint2.y()
 aSession.startOperation()
 aDocument.removeFeature(aConstraint)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 aSession.startOperation()
 aEndPoint1.setValue(90., 0.)
 aSession.finishOperation()
 assert (aEndPoint2.x() == aCurX and aEndPoint2.y() == aCurY)
+assert (model.dof(aSketchFeature) == 8)
 
 #=========================================================================
 # Set external point as a middle point
@@ -142,6 +149,7 @@ anOriginCoord = geomDataAPI_Point2D(anOrigin.attribute("PointCoordindates"))
 anOriginCoord.setValue(0., 0.)
 anOrigin.selection("External").setValue(anOrigRes, anOrigShape)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 # middle point constraint
 aSession.startOperation()
 aConstraint = aSketchFeature.addFeature("SketchConstraintMiddle")
@@ -151,6 +159,7 @@ reflistA.setObject(aLine2.lastResult())
 reflistB.setObject(anOrigin.lastResult())
 aSession.finishOperation()
 checkMiddlePoint(anOriginCoord, aLine2)
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # Check origin coordinates does not changed
 #=========================================================================
@@ -171,6 +180,7 @@ reflistB = aCoincidence.refattr("ConstraintEntityB")
 reflistA.setAttr(aEndPoint3)
 reflistB.setObject(aLine1.lastResult())
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 9)
 #=========================================================================
 # Set Middle point
 #=========================================================================
@@ -183,6 +193,7 @@ reflistB.setObject(aLine1.lastResult())
 aSession.finishOperation()
 # check the point, and no error message
 assert aSketchFeature.string("SolverError").value() == ""
+assert (model.dof(aSketchFeature) == 8)
 checkMiddlePoint(aEndPoint3, aLine1)
 #=========================================================================
 # Remove coincidence and move one line
@@ -196,10 +207,10 @@ aStartPoint1.setValue(aStartPoint1.x() + deltaX, aStartPoint1.y() + deltaY)
 aEndPoint1.setValue(aEndPoint1.x() + deltaX, aEndPoint1.y() + deltaY)
 aSession.finishOperation()
 checkMiddlePoint(aEndPoint3, aLine1)
+assert (model.dof(aSketchFeature) == 8)
 
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index e357e38988a6c82fe4c8f12b94e9ff31d700856b..78fe2fbdc344b2c68fcef3b371a6c2ce851771e7 100644 (file)
@@ -12,6 +12,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -109,6 +111,7 @@ aLine2EndPoint = geomDataAPI_Point2D(aSketchLine2.attribute("EndPoint"))
 aLine2StartPoint.setValue(50., 0.)
 aLine2EndPoint.setValue(100., 0.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 13)
 #=========================================================================
 # Link arc points and lines points by the coincidence constraint
 #=========================================================================
@@ -128,6 +131,7 @@ reflistA.setAttr(anArcEndPoint)
 reflistB.setAttr(aLine2StartPoint)
 aConstraint.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 9)
 #=========================================================================
 # Add tangency constraint and check correctness
 #=========================================================================
@@ -143,6 +147,7 @@ aRefObjectA.setObject(anObjectA)
 aRefObjectB.setObject(anObjectB)
 aTangency.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Create mirror line
 #=========================================================================
@@ -153,6 +158,7 @@ aLineEndPoint = geomDataAPI_Point2D(aMirrorLine.attribute("EndPoint"))
 aLineStartPoint.setValue(100., 0.)
 aLineEndPoint.setValue(100., 100.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 12)
 #=========================================================================
 # Make mirror for objects created above
 #=========================================================================
@@ -166,6 +172,7 @@ aRefListInitial.append(aSketchArc1.lastResult())
 aRefListInitial.append(aSketchLine2.lastResult())
 aMirror.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 12)
 #=========================================================================
 # Verify the simmetricity of all mirrored objects
 #=========================================================================
@@ -174,6 +181,7 @@ aRefListC = aMirror.reflist("ConstraintEntityC")
 assert (aRefListB.size() == 3)
 assert (aRefListC.size() == 3)
 checkMirror(aRefListB, aRefListC, aMirrorLine)
+assert (model.dof(aSketchFeature) == 12)
 
 #=========================================================================
 # Remove object from mirror
@@ -184,6 +192,7 @@ aSession.finishOperation()
 assert (aRefListB.size() == 2)
 assert (aRefListC.size() == 2)
 checkMirror(aRefListB, aRefListC, aMirrorLine)
+assert (model.dof(aSketchFeature) == 12)
 
 #=========================================================================
 # Clear list of mirrored features
@@ -198,30 +207,9 @@ aSession.finishOperation()
 assert (aRefListB.size() == 1)
 assert (aRefListC.size() == 1)
 checkMirror(aRefListB, aRefListC, aMirrorLine)
+assert (model.dof(aSketchFeature) == 12)
 #=========================================================================
 # End of test
 #=========================================================================
 
-
-# make second line fixed
-aSession.startOperation()
-aFixed = aSketchFeature.addFeature("SketchConstraintRigid")
-aRefObjectA = aFixed.refattr("ConstraintEntityA")
-anObjectA = modelAPI_ResultConstruction(aSketchLine2.lastResult())
-assert (anObjectA is not None)
-aRefObjectA.setObject(anObjectA)
-aFixed.execute()
-aSession.finishOperation()
-# set mirror for first line to check dumping
-aSession.startOperation()
-aRefListInitial.clear()
-assert (aRefListB.size() == 0)
-assert (aRefListC.size() == 0)
-aRefListInitial.append(aSketchLine1.lastResult())
-aSession.finishOperation()
-assert (aRefListB.size() == 1)
-assert (aRefListC.size() == 1)
-checkMirror(aRefListB, aRefListC, aMirrorLine)
-
-from salome.shaper import model
 assert(model.checkPythonDump())
index 2dd6ce202acedd6c1608ce9ad27df7b984705d0f..0570ec3fc6866b909d31b48f16b9b4fd4953c587 100644 (file)
@@ -11,6 +11,8 @@
 """
 from GeomDataAPI import *
 from ModelAPI import *
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -49,6 +51,7 @@ aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
 aLineBStartPoint.setValue(0., 50)
 aLineBEndPoint.setValue(80., 75)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Make a constraint to keep the length of the line constant
 # to parallel perpendicular constraint collapsing line to point
@@ -71,6 +74,7 @@ assert (aLineBStartPoint.x() == 0)
 assert (aLineBStartPoint.y() == 50)
 assert (aLineBEndPoint.x() == 80)
 assert (aLineBEndPoint.y() == 75)
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # Link lines with parallel constraint
 #=========================================================================
@@ -87,6 +91,7 @@ refattrA.setObject(aResultA)
 refattrB.setObject(aResultB)
 aParallelConstraint.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Check values and move one constrainted object
 #=========================================================================
@@ -105,9 +110,9 @@ aLineBEndPointNew = (aLineBEndPoint.x(), aLineBEndPoint.y())
 
 assert (aLineBStartPointPrev != aLineBStartPointNew)
 assert (aLineBEndPointPrev != aLineBEndPointNew)
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index f1d321362471c29050b8f5098e7e5d20ea726366..43fa7aaf3de1e6d5ec9d469bf0cdb2ec7ac64d25 100644 (file)
@@ -18,6 +18,8 @@
 """
 from GeomDataAPI import *
 from ModelAPI import *
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -56,6 +58,7 @@ aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
 aLineBStartPoint.setValue(25., 40.)
 aLineBEndPoint.setValue(25., 125.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Make a constraint to keep the length of the line constant
 # to prevent perpendicular constraint collapsing line to point
@@ -79,6 +82,7 @@ assert (aLineBStartPoint.x() == 25)
 assert (aLineBStartPoint.y() == 40)
 assert (aLineBEndPoint.x() == 25)
 assert (aLineBEndPoint.y() == 125)
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # Link lines with perpendicular constraint
 #=========================================================================
@@ -94,6 +98,7 @@ refattrA.setObject(aResultA)
 refattrB.setObject(aResultB)
 aPerpendicularConstraint.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Check values and move one constrainted object
 #=========================================================================
@@ -118,9 +123,9 @@ aLineAEndPoint.setValue(aLineAEndPoint.x() - deltaX, aLineAEndPoint.y() - deltaY
 aSession.finishOperation()
 assert (aLineBStartPointPrev != (aLineBStartPoint.x(), aLineBStartPoint.y()))
 assert (aLineBEndPointPrev   != (aLineBEndPoint.x(),   aLineBEndPoint.y()))
+assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index 9513b01ea8810eea306d6838c366d356a14d46c2..9ba906752f4c4210ffdc93479bae3e83d25752ae 100644 (file)
@@ -20,6 +20,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -63,6 +65,7 @@ anArcStartPoint.setValue(0., 50.)
 anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
 anArcEndPoint.setValue(50., 0.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 5)
 # Test changing the arc start/end point
 aSession.startOperation()
 anArcStartPoint.setValue(anArcStartPoint.x(), 40.)
@@ -74,6 +77,7 @@ anArcEndPoint.setValue(40., anArcEndPoint.y())
 anArcEndPoint.setValue(50., 0.)
 assert (math.hypot(anArcEndPoint.x() - 50., anArcEndPoint.y() - 0.) < 1.e-10)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 5)
 # Circle
 aSession.startOperation()
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
@@ -82,12 +86,14 @@ aCircleRadius = aSketchCircle.real("CircleRadius")
 anCircleCentr.setValue(-25., -25)
 aCircleRadius.setValue(25.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 # Change the radius of the arc
 aSession.startOperation()
 RADIUS = 40
 anArcRadius = aSketchArc.real("ArcRadius")
 anArcRadius.setValue(RADIUS)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Make a constraint to keep the radius of the arc
 #=========================================================================
@@ -102,6 +108,7 @@ aConstraint.execute()
 aSession.finishOperation()
 assert (aRadius.isInitialized())
 assert (aRefObject.isInitialized())
+assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
 # Make a constraint to keep the radius of the circle
 #=========================================================================
@@ -116,6 +123,7 @@ aConstraint.execute()
 aSession.finishOperation()
 assert (aRadius.isInitialized())
 assert (aRefObject.isInitialized())
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # Perform some actions and checks:
 # 1. Check that constraints does not changes values
@@ -134,6 +142,7 @@ assert (anArcEndPoint.x() != anArcPrevEndPointX)
 assert (anArcEndPoint.y() != anArcPrevEndPointY)
 assert (math.fabs(distancePointPoint(anArcCentr, anArcStartPoint) - RADIUS) < 1.e-10)
 assert (math.fabs(distancePointPoint(anArcCentr, anArcEndPoint) - RADIUS) < 1.e-10)
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # 4. Move the centr or the point of the arc
 # 5. Check radius is the same
@@ -147,9 +156,9 @@ aSession.finishOperation()
 assert (anCircleCentr.x() == 100)
 assert (anCircleCentr.y() == 100)
 assert (aCircleRadius.value() == 25)
+assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
diff --git a/src/SketchPlugin/Test/TestConstraintRigid.py b/src/SketchPlugin/Test/TestConstraintRigid.py
deleted file mode 100644 (file)
index e3f43b5..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-"""
-    TestConstraintRigid.py
-    Unit test of SketchPlugin_ConstraintRigid class
-    
-    SketchPlugin_Constraint
-        static const std::string MY_CONSTRAINT_VALUE("ConstraintValue");
-        static const std::string MY_FLYOUT_VALUE_PNT("ConstraintFlyoutValuePnt");
-        static const std::string MY_ENTITY_A("ConstraintEntityA");
-        static const std::string MY_ENTITY_B("ConstraintEntityB");
-        static const std::string MY_ENTITY_C("ConstraintEntityC");
-        static const std::string MY_ENTITY_D("ConstraintEntityD");
-        
-    SketchPlugin_ConstraintRigid
-        static const std::string MY_CONSTRAINT_RIGID_ID("SketchConstraintRigid");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
-
-"""
-from GeomDataAPI import *
-from ModelAPI import *
-from GeomAPI import *
-#=========================================================================
-# Initialization of the test
-#=========================================================================
-
-__updated__ = "2014-11-21"
-
-aSession = ModelAPI_Session.get()
-aDocument = aSession.moduleDocument()
-#=========================================================================
-# Creation of a sketch
-#=========================================================================
-aSession.startOperation()
-aSketchCommonFeature = aDocument.addFeature("Sketch")
-aSketchFeature = featureToCompositeFeature(aSketchCommonFeature)
-origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
-origin.setValue(0, 0, 0)
-dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
-dirx.setValue(1, 0, 0)
-norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
-norm.setValue(0, 0, 1)
-aSession.finishOperation()
-#=========================================================================
-# Create a triangle ABC
-#=========================================================================
-aSession.startOperation()
-aSketchLineA = aSketchFeature.addFeature("SketchLine")
-aSketchLineB = aSketchFeature.addFeature("SketchLine")
-aSketchLineC = aSketchFeature.addFeature("SketchLine")
-aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
-aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
-aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint"))
-aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
-aLineCStartPoint = geomDataAPI_Point2D(aSketchLineC.attribute("StartPoint"))
-aLineCEndPoint = geomDataAPI_Point2D(aSketchLineC.attribute("EndPoint"))
-aLineAStartPoint.setValue(25., 25.)
-aLineAEndPoint.setValue(100., 25.)
-aLineBStartPoint.setValue(100., 25.)
-aLineBEndPoint.setValue(60., 75.)
-aLineCStartPoint.setValue(60., 75.)
-aLineCEndPoint.setValue(25., 25.)
-aSession.finishOperation()
-# Store initial values of lines
-kLineAStart = (aLineAStartPoint.x(), aLineAStartPoint.y())
-kLineAEnd = (aLineAEndPoint.x(),   aLineAEndPoint.y())
-kLineBStart = (aLineBStartPoint.x(), aLineBStartPoint.y())
-kLineBEnd = (aLineBEndPoint.x(),   aLineBEndPoint.y())
-kLineCStart = (aLineCStartPoint.x(), aLineCStartPoint.y())
-kLineCEnd = (aLineCEndPoint.x(),   aLineCEndPoint.y())
-#=========================================================================
-# Link triange lines with concidence
-#=========================================================================
-concidenceLinks = zip([aLineBStartPoint, aLineCStartPoint, aLineAStartPoint],
-                      [aLineAEndPoint, aLineBEndPoint, aLineCEndPoint])
-aSession.startOperation()
-for eachLink in concidenceLinks:
-    aConstraint = aSketchFeature.addFeature("SketchConstraintCoincidence")
-    reflistA = aConstraint.refattr("ConstraintEntityA")
-    reflistB = aConstraint.refattr("ConstraintEntityB")
-    reflistA.setAttr(eachLink[0])
-    reflistB.setAttr(eachLink[1])
-    aConstraint.execute()
-aSession.finishOperation()
-
-# Check that constarints doesn't affected lines' values
-assert (kLineAStart == (aLineAStartPoint.x(), aLineAStartPoint.y()))
-assert (kLineAEnd == (aLineAEndPoint.x(),   aLineAEndPoint.y()))
-assert (kLineBStart == (aLineBStartPoint.x(), aLineBStartPoint.y()))
-assert (kLineBEnd == (aLineBEndPoint.x(),   aLineBEndPoint.y()))
-assert (kLineCStart == (aLineCStartPoint.x(), aLineCStartPoint.y()))
-assert (kLineCEnd == (aLineCEndPoint.x(),   aLineCEndPoint.y()))
-#=========================================================================
-# Make line A rigid
-#=========================================================================
-aSession.startOperation()
-aRigidConstraint = aSketchFeature.addFeature("SketchConstraintRigid")
-eachRefattr = aRigidConstraint.refattr("ConstraintEntityA")
-lineResults = aSketchLineA.results()
-for eachResult in lineResults:
-    if eachResult.shape().isEdge():
-        break
-aResult = modelAPI_ResultConstruction(eachResult)
-assert (aResult is not None)
-eachRefattr.setObject(aResult)
-# aRigidConstraint.execute()
-aSession.finishOperation()
-
-# Check that constarints doesn't affected lines' values
-assert ((aLineAStartPoint.x(), aLineAStartPoint.y()) == (aLineCEndPoint.x(), aLineCEndPoint.y()))
-assert ((aLineBStartPoint.x(), aLineBStartPoint.y()) == (aLineAEndPoint.x(), aLineAEndPoint.y()))
-assert ((aLineCStartPoint.x(), aLineCStartPoint.y()) == (aLineBEndPoint.x(), aLineBEndPoint.y()))
-#=========================================================================
-# Check that moving line A does not affect lines
-#=========================================================================
-aSession.startOperation()
-aLineAEndPoint.setValue(90., 0.)
-aSession.finishOperation()
-# Check that constarint keep features' values
-assert ((aLineAStartPoint.x(), aLineAStartPoint.y()) == (aLineCEndPoint.x(), aLineCEndPoint.y()))
-assert ((aLineBStartPoint.x(), aLineBStartPoint.y()) == (aLineAEndPoint.x(), aLineAEndPoint.y()))
-assert ((aLineCStartPoint.x(), aLineCStartPoint.y()) == (aLineBEndPoint.x(), aLineBEndPoint.y()))
-#=========================================================================
-# Check that moving line B does not affect lines
-#=========================================================================
-aSession.startOperation()
-aLineBEndPoint.setValue(90., 150.)
-aSession.finishOperation()
-# Check that constarint keep features' values
-assert ((aLineAStartPoint.x(), aLineAStartPoint.y()) == (aLineCEndPoint.x(), aLineCEndPoint.y()))
-assert ((aLineBStartPoint.x(), aLineBStartPoint.y()) == (aLineAEndPoint.x(), aLineAEndPoint.y()))
-assert ((aLineCStartPoint.x(), aLineCStartPoint.y()) == (aLineBEndPoint.x(), aLineBEndPoint.y()))
-#=========================================================================
-# TODO: improve test
-# 1. remove constraint, move line to check that constraint are not applied
-#=========================================================================
-#=========================================================================
-# End of test
-#=========================================================================
-
-from salome.shaper import model
-assert(model.checkPythonDump())
index 90d6cd8facb8b7e44bf960eef35b8daedfe21145..03c9334f38ead1abd4355036c0829d4e6ad445fe 100644 (file)
@@ -12,6 +12,8 @@ from GeomDataAPI import *
 from GeomAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -82,6 +84,7 @@ aLine2EndPoint = geomDataAPI_Point2D(aSketchLine2.attribute("EndPoint"))
 aLine2StartPoint.setValue(50., 0.)
 aLine2EndPoint.setValue(100., 0.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 13)
 #=========================================================================
 # Link arc points and lines points by the coincidence constraint
 #=========================================================================
@@ -101,6 +104,7 @@ reflistA.setAttr(anArcEndPoint)
 reflistB.setAttr(aLine2StartPoint)
 aConstraint.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 9)
 #=========================================================================
 # Add tangency constraint and check correctness
 #=========================================================================
@@ -124,6 +128,7 @@ aLineVecY = aLine1EndPoint.y() - aLine1StartPoint.y()
 aLen = aLen * math.sqrt(aLineVecX**2 + aLineVecY**2)
 aDot = anArcVecX * aLineVecX + anArcVecY * aLineVecY
 assert math.fabs(aDot) <= 2.e-6 * aLen, "Observed dot product: {0}".format(aDot)
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Add tangency constraint for arc and second line and check correctness
 #=========================================================================
@@ -147,6 +152,7 @@ aLineVecY = aLine2EndPoint.y() - aLine2StartPoint.y()
 aLen = aLen * math.sqrt(aLineVecX**2 + aLineVecY**2)
 aDot = anArcVecX * aLineVecX + anArcVecY * aLineVecY
 assert math.fabs(aDot) <= 2.e-6 * aLen, "Observed dot product: {0}".format(aDot)
+assert (model.dof(aSketchFeature) == 7)
 
 #=========================================================================
 # TEST 2. Arc-arc tangency
@@ -175,6 +181,7 @@ anArc2EndPoint.setValue(-50., 0.)
 anArc2PassedPoint = geomDataAPI_Point2D(aSketchArc2.attribute("ArcPassedPoint"))
 anArc2PassedPoint.setValue(-40., 40.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 17)
 #=========================================================================
 # Link points of arcs by the coincidence constraint
 #=========================================================================
@@ -186,6 +193,7 @@ reflistA.setAttr(anArc1EndPoint)
 reflistB.setAttr(anArc2StartPoint)
 aConstraint.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 15)
 #=========================================================================
 # Add tangency constraint and check correctness
 #=========================================================================
@@ -209,6 +217,7 @@ anArc2VecY = anArc2StartPoint.y() - anArc2Centr.y()
 aLen = aLen * math.sqrt(anArc2VecX**2 + anArc2VecY**2)
 aCross = anArc1VecX * anArc2VecY - anArc1VecY * anArc2VecX
 assert math.fabs(aCross) <= 2.e-6 * aLen, "Observed cross product: {0}".format(aCross)
+assert (model.dof(aSketchFeature) == 14)
 
 #=========================================================================
 # TEST 3. Tangency between non-connected objects should be wrong
@@ -245,9 +254,11 @@ assert(aLine2EndPointNew == aLine2EndPointPrev)
 assert(anArc2CenterNew == anArc2CenterPrev)
 assert(anArc2StartPointNew == anArc2StartPointPrev)
 assert(anArc2EndPointNew == anArc2EndPointPrev)
+assert (model.dof(aSketchFeature) == 14)
 aSession.startOperation()
 aDocument.removeFeature(aTangency)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 14)
 
 #=========================================================================
 # TEST 4. Creating of tangency arc by the option of the SketchArc feature
@@ -271,6 +282,7 @@ anArc3VecY = anArc3StartPoint.y() - anArc3Center.y()
 aLen = aLen * math.sqrt(anArc3VecX**2 + anArc3VecY**2)
 aCross = anArc1VecX * anArc3VecY - anArc1VecY * anArc3VecX
 assert math.fabs(aCross) <= 2.e-6 * aLen, "Observed cross product: {0}".format(aCross)
+assert (model.dof(aSketchFeature) == 19)
 
 #=========================================================================
 # TEST 5. Creating of tangency between line and circle
@@ -287,6 +299,7 @@ aCircleRadius = aCircle.real("CircleRadius")
 aCircleCenter.setValue(150., 100.)
 aCircleRadius.setValue(20.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 26)
 
 aSession.startOperation()
 aTangency = aSketchFeature.addFeature("SketchConstraintTangent")
@@ -302,9 +315,9 @@ aTangency.execute()
 aSession.finishOperation()
 
 assert(math.fabs(distancePointLine(aCircleCenter, aLine) - round(aCircleRadius.value(), 5)) < 1.e-10)
+assert (model.dof(aSketchFeature) == 25)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index 8bbc541cd94b15fc4e32e04668dcfc36a0acee3b..1fe6af2722b3759595e30bf056f4f6eab329a8d1 100644 (file)
@@ -9,6 +9,8 @@
 """
 from GeomDataAPI import *
 from ModelAPI import *
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -40,6 +42,7 @@ aLineEndPoint = geomDataAPI_Point2D(aSketchLine.attribute("EndPoint"))
 aLineStartPoint.setValue(0., 15.)
 aLineEndPoint.setValue(20., 25.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 4)
 #=========================================================================
 # Assign vertical constraint for a line
 #=========================================================================
@@ -52,6 +55,7 @@ refattrA.setObject(aResult)
 aVerticalConstraint.execute()
 aSession.finishOperation()
 assert(aLineStartPoint.x() == aLineEndPoint.x())
+assert (model.dof(aSketchFeature) == 3)
 #=========================================================================
 # Move one of boundary points of a line
 #=========================================================================
@@ -61,6 +65,7 @@ aLineStartPoint.setValue(aLineStartPoint.x() + deltaX,
                          aLineStartPoint.y() + deltaY)
 aSession.finishOperation()
 assert(aLineStartPoint.x() == aLineEndPoint.x())
+assert (model.dof(aSketchFeature) == 3)
 #=========================================================================
 # Move other boundary point of a line
 #=========================================================================
@@ -71,9 +76,9 @@ aLineEndPoint.setValue(aLineEndPoint.x() + deltaX,
                        aLineEndPoint.y() + deltaY)
 aSession.finishOperation()
 assert(aLineStartPoint.x() == aLineEndPoint.x())
+assert (model.dof(aSketchFeature) == 3)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index e005bee4e65d41c73ed51e260055a55ea05e9fee..e58e27ba8e9af3040c76258fa86e67acf88f1452 100644 (file)
@@ -13,6 +13,7 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
 
 #=========================================================================
 # Auxiliary functions
@@ -21,7 +22,7 @@ aStartPoint1 = []
 
 def createSketch1(theSketch):
     global aEndPoint1, aEndPoint2
-    # Initialize sketch by two lines with coincident boundary
+    # Initialize sketch by three lines with coincident boundaries
     allFeatures = []
     # Line1
     aSketchLine1 = theSketch.addFeature("SketchLine")
@@ -178,7 +179,7 @@ norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSession.finishOperation()
 #=========================================================================
-# Initialize sketch by two lines
+# Initialize sketch by three connected lines
 #=========================================================================
 aSession.startOperation()
 aFeaturesList = createSketch1(aSketchFeature)
@@ -186,6 +187,7 @@ aSession.finishOperation()
 aSketchSubFeatures = []
 for aSubIndex in range(0, aSketchFeature.numberOfSubs()):
     aSketchSubFeatures.append(aSketchFeature.subFeature(aSubIndex))
+assert (model.dof(aSketchFeature) == 8)
 #=========================================================================
 # Global variables
 #=========================================================================
@@ -215,6 +217,7 @@ for aSubIndex in range(0, aSketchFeature.numberOfSubs()):
 #=========================================================================
 assert(aResObjects)
 checkFillet(aResObjects, FILLET_RADIUS1)
+assert model.dof(aSketchFeature) == 8, "PlaneGCS limitation: if you see this message, then PlaneGCS has solved DoF for sketch with fillet correctly (expected DoF = 10, observed = {0}".format(model.dof(aSketchFeature))
 #=========================================================================
 # Change Fillet radius
 #=========================================================================
@@ -222,6 +225,7 @@ aRadius.setValue(FILLET_RADIUS2)
 aFillet.execute()
 aSession.finishOperation()
 checkFillet(aResObjects, FILLET_RADIUS2)
+assert model.dof(aSketchFeature) == 14, "PlaneGCS limitation: if you see this message, then PlaneGCS has solved DoF for sketch with fillet correctly (expected DoF = 10, observed = {0}".format(model.dof(aSketchFeature))
 
 #=========================================================================
 # Create another sketch
@@ -245,6 +249,7 @@ aSession.finishOperation()
 aSketchSubFeatures = []
 for aSubIndex in range(0, aSketchFeature.numberOfSubs()):
     aSketchSubFeatures.append(aSketchFeature.subFeature(aSubIndex))
+assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
 # Create the Fillet
 #=========================================================================
@@ -268,6 +273,7 @@ for aSubIndex in range(0, aSketchFeature.numberOfSubs()):
 #=========================================================================
 assert(aResObjects)
 checkFillet(aResObjects, FILLET_RADIUS1)
+assert model.dof(aSketchFeature) == 7, "PlaneGCS limitation: if you see this message, then PlaneGCS has solved DoF for sketch with fillet correctly (expected DoF = 8, observed = {0}".format(model.dof(aSketchFeature))
 #=========================================================================
 # Change Fillet radius
 #=========================================================================
@@ -275,9 +281,9 @@ aRadius.setValue(FILLET_RADIUS2)
 aFillet.execute()
 aSession.finishOperation()
 checkFillet(aResObjects, FILLET_RADIUS2)
+assert model.dof(aSketchFeature) == 11, "PlaneGCS limitation: if you see this message, then PlaneGCS has solved DoF for sketch with fillet correctly (expected DoF = 8, observed = {0}".format(model.dof(aSketchFeature))
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index f78be7ff246eff69ab09cb889587920d697dc98c..0825ff115aa2cf69acf95747700baaedb3754d47 100644 (file)
@@ -102,6 +102,7 @@ aSession.finishOperation()
 #=========================================================================
 # Create 4x4 polygons N = {5, 21}
 #=========================================================================
+aDOF = 0
 deltaX = deltaY = 50.
 n = 5
 aSession.startOperation()
@@ -110,6 +111,7 @@ for i in xrange(4):
         allNangleLines = createNAngle(aSketchFeature, n, 50)
         fixLineLength(aSketchFeature, allNangleLines)
         moveTo(allNangleLines, deltaX, deltaY)
+        aDOF += n
         n += 1
         deltaX += 110.
     deltaY += 110.
@@ -122,4 +124,5 @@ aSession.finishOperation()
 #=========================================================================
 
 from salome.shaper import model
+assert(model.dof(aSketchFeature) == aDOF)
 assert(model.checkPythonDump())
index 2a61103ec79195e7a2ce3d9560e5406ccba37380..7328e497cc6774babc28be4f4a09bc5523f781c5 100644 (file)
@@ -16,6 +16,7 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
 
 #=========================================================================
 # Auxiliary functions
@@ -114,6 +115,7 @@ aSession.finishOperation()
 aSession.startOperation()
 aFeaturesList = createSketch(aSketchFeature)
 aSession.finishOperation()
+assert(model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Global variables
 #=========================================================================
@@ -128,6 +130,7 @@ aRotationPoint = aSketchFeature.addFeature("SketchPoint")
 aRotationPointPoint = geomDataAPI_Point2D(aRotationPoint.attribute("PointCoordindates"))
 aRotationPointPoint.setValue(CENTER_X, CENTER_Y)
 aSession.finishOperation()
+assert(model.dof(aSketchFeature) == 7)
 #=========================================================================
 # Create the Rotation constraint
 #=========================================================================
@@ -155,6 +158,7 @@ aNbCopies = aMultiRotation.integer("MultiRotationObjects")
 aNbCopies.setValue(2)
 aMultiRotation.execute()
 aSession.finishOperation()
+assert(model.dof(aSketchFeature) == 7)
 #=========================================================================
 # Verify the objects are moved for the specified distance
 #=========================================================================
@@ -168,6 +172,7 @@ aNbCopies.setValue(3)
 aSession.finishOperation()
 aRotated = aMultiRotation.reflist("ConstraintEntityB")
 checkRotation(aRotated, aNbCopies.value(), CENTER_X, CENTER_Y, ANGLE)
+assert(model.dof(aSketchFeature) == 7)
 
 #=========================================================================
 # Create new feature and add it into the Rotation
@@ -181,6 +186,7 @@ assert(aResult is not None)
 aRotList.append(aResult)
 aSession.finishOperation()
 checkRotation(aRotated, aNbCopies.value(), CENTER_X, CENTER_Y, ANGLE)
+assert(model.dof(aSketchFeature) == 11)
 #=========================================================================
 # Move line and check the copies are moved too
 #=========================================================================
@@ -189,6 +195,7 @@ aStartPoint = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
 aStartPoint.setValue(12., 5.)
 aSession.finishOperation()
 checkRotation(aRotated, aNbCopies.value(), CENTER_X, CENTER_Y, ANGLE)
+assert(model.dof(aSketchFeature) == 11)
 #=========================================================================
 # Change number of copies and verify Rotation
 #=========================================================================
@@ -196,6 +203,7 @@ aSession.startOperation()
 aNbCopies.setValue(2)
 aSession.finishOperation()
 checkRotation(aRotated, aNbCopies.value(), CENTER_X, CENTER_Y, ANGLE)
+assert(model.dof(aSketchFeature) == 11)
 
 #=========================================================================
 # Remove a feature from the Rotation
@@ -205,6 +213,7 @@ aRemoveIt = aRotList.object(0)
 aRotList.remove(aRemoveIt)
 aSession.finishOperation()
 checkRotation(aRotated, aNbCopies.value(), CENTER_X, CENTER_Y, ANGLE)
+assert(model.dof(aSketchFeature) == 11)
 
 #=========================================================================
 # Clear the list of rotated features
@@ -216,9 +225,9 @@ checkRotation(aRotated, 1, CENTER_X, CENTER_Y, ANGLE)
 aRotList.append(aResult)
 aSession.finishOperation()
 checkRotation(aRotated, aNbCopies.value(), CENTER_X, CENTER_Y, ANGLE)
+assert(model.dof(aSketchFeature) == 11)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index edb25d517e9aba7ed3d0b3b39f6fa3166f9f684b..80eb90ed108f2315aa34c739d78c5802e4ee3ed1 100644 (file)
@@ -15,6 +15,7 @@
 """
 from GeomDataAPI import *
 from ModelAPI import *
+from salome.shaper import model
 
 #=========================================================================
 # Auxiliary functions
@@ -106,6 +107,7 @@ aSession.finishOperation()
 aSession.startOperation()
 aFeaturesList = createSketch(aSketchFeature)
 aSession.finishOperation()
+assert(model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Global variables
 #=========================================================================
@@ -125,6 +127,7 @@ aTransLineEndPoint = geomDataAPI_Point2D(aTransLine.attribute("EndPoint"))
 aTransLineStartPoint.setValue(START_X, START_Y)
 aTransLineEndPoint.setValue(START_X + DELTA_X, START_Y + DELTA_Y)
 aSession.finishOperation()
+assert(model.dof(aSketchFeature) == 9)
 #=========================================================================
 # Create the Translation constraint
 #=========================================================================
@@ -146,6 +149,7 @@ aNbCopies = aMultiTranslation.integer("MultiTranslationObjects")
 aNbCopies.setValue(2)
 aMultiTranslation.execute()
 aSession.finishOperation()
+assert(model.dof(aSketchFeature) == 9)
 #=========================================================================
 # Verify the objects are moved for the specified distance
 #=========================================================================
@@ -159,6 +163,7 @@ aNbCopies.setValue(3)
 aSession.finishOperation()
 aTranslated = aMultiTranslation.reflist("ConstraintEntityB")
 checkTranslation(aTranslated, aNbCopies.value(), DELTA_X, DELTA_Y)
+assert(model.dof(aSketchFeature) == 9)
 
 #=========================================================================
 # Create new feature and add it into the Rotation
@@ -172,6 +177,7 @@ assert(aResult is not None)
 aTransList.append(aResult)
 aSession.finishOperation()
 checkTranslation(aTranslated, aNbCopies.value(), DELTA_X, DELTA_Y)
+assert(model.dof(aSketchFeature) == 13)
 #=========================================================================
 # Move line and check the copies are moved too
 #=========================================================================
@@ -180,6 +186,7 @@ aStartPoint = geomDataAPI_Point2D(aLine.attribute("StartPoint"))
 aStartPoint.setValue(12., 5.)
 aSession.finishOperation()
 checkTranslation(aTranslated, aNbCopies.value(), DELTA_X, DELTA_Y)
+assert(model.dof(aSketchFeature) == 13)
 #=========================================================================
 # Change number of copies and verify Rotation
 #=========================================================================
@@ -187,6 +194,7 @@ aSession.startOperation()
 aNbCopies.setValue(2)
 aSession.finishOperation()
 checkTranslation(aTranslated, aNbCopies.value(), DELTA_X, DELTA_Y)
+assert(model.dof(aSketchFeature) == 13)
 
 #=========================================================================
 # Remove a feature from the Rotation
@@ -196,6 +204,7 @@ aRemoveIt = aTransList.object(0)
 aTransList.remove(aRemoveIt)
 aSession.finishOperation()
 checkTranslation(aTranslated, aNbCopies.value(), DELTA_X, DELTA_Y)
+assert(model.dof(aSketchFeature) == 13)
 
 #=========================================================================
 # Clear the list of rotated features
@@ -207,9 +216,9 @@ checkTranslation(aTranslated, 1, DELTA_X, DELTA_Y)
 aTransList.append(aResult)
 aSession.finishOperation()
 checkTranslation(aTranslated, aNbCopies.value(), DELTA_X, DELTA_Y)
+assert(model.dof(aSketchFeature) == 13)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index eddc1e7448798b1155926ea8b6ead15c67b22f1b..9477cdc741d0b609308b00ebd5cc70032369e669 100644 (file)
@@ -6,6 +6,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -54,6 +56,7 @@ anArcCenter.setValue(10., 10.)
 anArcStart.setValue(50., 0.)
 anArcEnd.setValue(0., 50.)
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 12)
 #=========================================================================
 # Create another sketch
 #=========================================================================
@@ -82,6 +85,7 @@ anArcProjector = aSketchFeature.addFeature("SketchProjection")
 anArcProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/Edge-SketchArc_1_2")
 anArcProjector.execute()
 aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 0)
 #=========================================================================
 # Check projection coordinates
 #=========================================================================
@@ -122,9 +126,9 @@ assert(math.fabs(aProjLineStart.x() - aLineStart.x()) < 1.e-10)
 assert(math.fabs(aProjLineStart.y() - aLineStart.y()) < 1.e-10)
 assert(math.fabs(aProjLineEnd.x() - aLineEnd.x()) < 1.e-10)
 assert(math.fabs(aProjLineEnd.y() - aLineEnd.y()) < 1.e-10)
+assert (model.dof(aSketchFeature) == 0)
 #=========================================================================
 # End of test
 #=========================================================================
 
-#from salome.shaper import model
-#assert(model.checkPythonDump())
+assert(model.checkPythonDump())
index a2edbe9d37a49516bd9aa50daa8b6c47e7619d72..69ebc56a770c81b89f9818bc917956085ac8ad3d 100644 (file)
@@ -6,6 +6,8 @@
 from GeomDataAPI import *
 from ModelAPI import *
 import math
+from salome.shaper import model
+
 #=========================================================================
 # Initialization of the test
 #=========================================================================
@@ -66,6 +68,7 @@ for i in range (0, aNbSubs):
         assert (isHorizontal(aLastLine) or isVertical(aLastLine))
         aNbLines = aNbLines + 1
 assert (aNbLines == 4)
+assert (model.dof(aSketchFeature) == 4)
 #=========================================================================
 # Move one of lines
 #=========================================================================
@@ -85,9 +88,9 @@ for i in range (0, aNbSubs):
         assert (isHorizontal(aLastLine) or isVertical(aLastLine))
         aNbLines = aNbLines + 1
 assert (aNbLines == 4)
+assert (model.dof(aSketchFeature) == 4)
 #=========================================================================
 # End of test
 #=========================================================================
 
-from salome.shaper import model
 assert(model.checkPythonDump())
index fdcc98b4429e7e86e8e53c30fcc0c997e00783e5..a0ffc362f8f68ef8f9426a5c588952f137e7981b 100644 (file)
@@ -19,6 +19,9 @@
 #include <GeomAPI_Pnt2d.h>
 #include <GeomAPI_XY.h>
 
+static bool isAttributeApplicable(const std::string& theAttrName,
+                                  const std::string& theOwnerName);
+
 static EntityWrapperPtr createLine(const AttributeEntityMap& theAttributes);
 static EntityWrapperPtr createCircle(const AttributeEntityMap& theAttributes);
 static EntityWrapperPtr createArc(const AttributeEntityMap&    theAttributes,
@@ -40,7 +43,10 @@ PlaneGCSSolver_FeatureBuilder::PlaneGCSSolver_FeatureBuilder(const StoragePtr& t
 EntityWrapperPtr PlaneGCSSolver_FeatureBuilder::createAttribute(
     AttributePtr theAttribute)
 {
-  EntityWrapperPtr anAttr = PlaneGCSSolver_AttributeBuilder::createAttribute(theAttribute);
+  FeaturePtr anOwner = ModelAPI_Feature::feature(theAttribute->owner());
+  EntityWrapperPtr anAttr;
+  if (isAttributeApplicable(theAttribute->id(), anOwner->getKind()))
+    anAttr = PlaneGCSSolver_AttributeBuilder::createAttribute(theAttribute);
   if (anAttr)
     myAttributes[theAttribute] = anAttr;
   return anAttr;
@@ -199,3 +205,23 @@ EntityWrapperPtr createArc(const AttributeEntityMap&    theAttributes,
 
   return EntityWrapperPtr(new PlaneGCSSolver_EntityWrapper(aNewArc));
 }
+
+bool isAttributeApplicable(const std::string& theAttrName, const std::string& theOwnerName)
+{
+  if (theOwnerName == SketchPlugin_Arc::ID()) {
+    return theAttrName == SketchPlugin_Arc::CENTER_ID() ||
+           theAttrName == SketchPlugin_Arc::START_ID() ||
+           theAttrName == SketchPlugin_Arc::END_ID();
+  }
+  else if (theOwnerName == SketchPlugin_Circle::ID()) {
+    return theAttrName == SketchPlugin_Circle::CENTER_ID() ||
+           theAttrName == SketchPlugin_Circle::RADIUS_ID();
+  }
+  else if (theOwnerName == SketchPlugin_Line::ID()) {
+    return theAttrName == SketchPlugin_Line::START_ID() ||
+           theAttrName == SketchPlugin_Line::END_ID();
+  }
+
+  // suppose that all remaining features are points
+  return theAttrName == SketchPlugin_Point::COORD_ID();
+}
index 9181f43dd1abd9ec92f5c31e627d80dab1da4347..1193ad3573218d9577ca04df2035b156ce31c82b 100644 (file)
@@ -10,7 +10,8 @@
 
 PlaneGCSSolver_Solver::PlaneGCSSolver_Solver()
   : myEquationSystem(new GCS::System),
-    myConfCollected(false)
+    myConfCollected(false),
+    myDOF(0)
 {
 }
 
@@ -23,18 +24,46 @@ void PlaneGCSSolver_Solver::clear()
 {
   myEquationSystem->clear();
   myParameters.clear();
-  myEqualConstraints.clear();
-  myEqualParameters.clear();
+  myConstraints.clear();
+  myConflictingIDs.clear();
+  myDOF = 0;
 }
 
 void PlaneGCSSolver_Solver::addConstraint(GCSConstraintPtr theConstraint)
 {
   myEquationSystem->addConstraint(theConstraint.get());
+  myConstraints[theConstraint->getTag()].insert(theConstraint);
+  myDOF = -1;
 }
 
 void PlaneGCSSolver_Solver::removeConstraint(ConstraintID theID)
 {
-  myEquationSystem->clearByTag(theID);
+  myConstraints.erase(theID);
+  if (myConstraints.empty()) {
+    myEquationSystem->clear();
+    myDOF = (int)myParameters.size();
+  } else {
+    myEquationSystem->clearByTag(theID);
+    myDOF = -1;
+  }
+}
+
+double* PlaneGCSSolver_Solver::createParameter()
+{
+  double* aResult = new double(0);
+  myParameters.push_back(aResult);
+  if (myDOF >= 0)
+    ++myDOF;
+  return aResult;
+}
+
+void PlaneGCSSolver_Solver::removeParameters(const GCS::SET_pD& theParams)
+{
+  for (int i = (int)myParameters.size() - 1; i >= 0; --i)
+    if (theParams.find(myParameters[i]) != theParams.end()) {
+      myParameters.erase(myParameters.begin() + i);
+      --myDOF;
+    }
 }
 
 SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve()
@@ -56,6 +85,8 @@ SketchSolver_SolveStatus PlaneGCSSolver_Solver::solve()
   SketchSolver_SolveStatus aStatus;
   if (aResult == GCS::Success) {
     myEquationSystem->applySolution();
+    if (myDOF < 0)
+      myDOF = myEquationSystem->dofsNumber();
     aStatus = STATUS_OK;
   } else
     aStatus = STATUS_FAILED;
@@ -87,7 +118,9 @@ void PlaneGCSSolver_Solver::collectConflicting()
   myConfCollected = true;
 }
 
-int PlaneGCSSolver_Solver::dof() const
+int PlaneGCSSolver_Solver::dof()
 {
-  return const_cast<PlaneGCSSolver_Solver*>(this)->myEquationSystem->dofsNumber();
+  if (myDOF < 0 && !myConstraints.empty())
+    solve();
+  return myDOF;
 }
index 481cc082685f449d8146ac70bdc5647e5a607f02..9c25caf722e06ee3300856f8edef641f6cec9bdb 100644 (file)
@@ -29,9 +29,10 @@ public:
   /// \brief Remove constraint from the system of equations
   void removeConstraint(ConstraintID theID);
 
-  /// \brief Initialize list of unknowns
-  void setParameters(const GCS::VEC_pD& theParams)
-  { myParameters = theParams; }
+  /// \brief Initialize memory for new solver's parameter
+  double* createParameter();
+  /// \brief Release memory occupied by parameters
+  void removeParameters(const GCS::SET_pD& theParams);
 
   /// \brief Solve the set of equations
   /// \return identifier whether solution succeeded
@@ -48,13 +49,17 @@ public:
   virtual bool isConflicting(const ConstraintID& theConstraint) const;
 
   /// \brief Degrees of freedom
-  virtual int dof() const;
+  virtual int dof();
 
 private:
   void collectConflicting();
 
 private:
+  typedef std::map<ConstraintID, std::set<GCSConstraintPtr> > ConstraintMap;
+
   GCS::VEC_pD                  myParameters;     ///< list of unknowns
+  ConstraintMap                myConstraints;    ///< list of constraints
+
   std::shared_ptr<GCS::System> myEquationSystem; ///< set of equations for solving in FreeGCS
 
   GCS::SET_I                   myConflictingIDs; ///< list of IDs of conflicting constraints
@@ -62,10 +67,7 @@ private:
   /// specifies the conflicting constraints are already collected
   bool                         myConfCollected;
 
-  /// lists of parameters used in the Equal constraints (to avoid multiple equalities)
-  std::list<GCS::SET_pD>       myEqualParameters;
-  /// lists of the Equal constraints
-  std::map<ConstraintID, std::set<GCSConstraintPtr> > myEqualConstraints;
+  int                          myDOF;            ///< degrees of freedom
 };
 
 #endif
index 89c5bd29fa13184f322e4c2668a6fcef87ee75e6..67ada87702e88c6bc449b636a7b1a6777bb2af48 100644 (file)
@@ -246,8 +246,8 @@ bool PlaneGCSSolver_Storage::update(AttributePtr theAttribute, bool theForce)
     if (aFeature && myFeatureMap.find(aFeature) == myFeatureMap.end())
       return update(aFeature, theForce); // theAttribute has been processed while adding feature
 
-    PlaneGCSSolver_AttributeBuilder aBuilder(this);
-    aRelated = createAttribute(anAttribute, &aBuilder);
+////    PlaneGCSSolver_AttributeBuilder aBuilder(this);
+////    aRelated = createAttribute(anAttribute, &aBuilder);
     return aRelated.get() != 0;
   }
 
@@ -338,16 +338,12 @@ void PlaneGCSSolver_Storage::removeInvalidEntities()
 
 double* PlaneGCSSolver_Storage::createParameter()
 {
-  double* aResult = new double(0);
-  myParameters.push_back(aResult);
-  return aResult;
+  return std::dynamic_pointer_cast<PlaneGCSSolver_Solver>(mySketchSolver)->createParameter();
 }
 
 void PlaneGCSSolver_Storage::removeParameters(const GCS::SET_pD& theParams)
 {
-  for (int i = (int)myParameters.size() - 1; i >= 0; --i)
-    if (theParams.find(myParameters[i]) != theParams.end())
-      myParameters.erase(myParameters.begin() + i);
+  std::dynamic_pointer_cast<PlaneGCSSolver_Solver>(mySketchSolver)->removeParameters(theParams);
 }
 
 
@@ -404,14 +400,6 @@ bool PlaneGCSSolver_Storage::isRedundant(
   return false;
 }
 
-void PlaneGCSSolver_Storage::initializeSolver()
-{
-  std::shared_ptr<PlaneGCSSolver_Solver> aSolver =
-      std::dynamic_pointer_cast<PlaneGCSSolver_Solver>(mySketchSolver);
-  if (aSolver)
-    aSolver->setParameters(myParameters);
-}
-
 // indicates attribute containing in the external feature
 bool isExternalAttribute(const AttributePtr& theAttribute)
 {
index 05139cf760b7e4632f3d929e3dc07e6e3b0aeae7..ca8fa22212ae247acadaed0fbbeae88068075669 100644 (file)
@@ -59,9 +59,6 @@ public:
   /// \brief Update SketchPlugin features after resolving constraints
   virtual void refresh() const;
 
-  /// \brief Initialize solver by constraints, entities and parameters
-  virtual void initializeSolver();
-
   /// \brief Initialize memory for new solver's parameter
   double* createParameter();
   /// \brief Release memory occupied by parameters
@@ -88,7 +85,6 @@ private:
                                    PlaneGCSSolver_EntityBuilder* theBuilder);
 
 private:
-  GCS::VEC_pD  myParameters;         ///< list of parameters
   ConstraintID myConstraintLastID;   ///< identifier of last added constraint
 
   /// additional constraints for correct processing of the arcs
index b2cfa0a712c752a6e11d73e5d6f2e5e7da97575a..d3317d9acd814a74ca02931d739cbfab63650300 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <SketchSolver_ConstraintEqual.h>
 #include <SketchSolver_Error.h>
+#include <PlaneGCSSolver_AttributeBuilder.h>
 
 #include <ModelAPI_AttributeRefAttr.h>
 #include <SketchPlugin_Line.h>
@@ -59,9 +60,10 @@ void SketchSolver_ConstraintEqual::getAttributes(
         myBaseConstraint->refattr(SketchPlugin_Constraint::ENTITY_A());
     FeaturePtr aLine1 = ModelAPI_Feature::feature(aRefLine1->object());
     if (aLine1) {
+      PlaneGCSSolver_AttributeBuilder aBuilder(myStorage);
       // store length of first line as a value for constraint
       // (will be used to make equal lengths of lines)
-      theValue = myStorage->entity(aLine1->attribute(SketchPlugin_Line::LENGTH_ID()));
+      theValue = aBuilder.createAttribute(aLine1->attribute(SketchPlugin_Line::LENGTH_ID()));
     }
     break;
   }
index 8db65a33778b44e35b1c96c13c9a72a33376ce10..c5418065bc13ad9cb93e92aff9c14719cd3921ac 100644 (file)
@@ -123,7 +123,7 @@ bool SketchSolver_Group::resolveConstraints()
 ////      mySketchSolver = SketchSolver_Manager::instance()->builder()->createSolver();
 
 ////    mySketchSolver->calculateFailedConstraints(false);
-    myStorage->initializeSolver();
+////    myStorage->initializeSolver();
 ////    mySketchSolver->prepare();
 
     SketchSolver_SolveStatus aResult = STATUS_OK;
@@ -144,7 +144,7 @@ bool SketchSolver_Group::resolveConstraints()
 
           removeTemporaryConstraints();
           mySketchSolver->calculateFailedConstraints(true); // something failed => need to find it
-          myStorage->initializeSolver();
+////          myStorage->initializeSolver();
         }
       }
     } catch (...) {
@@ -176,6 +176,9 @@ bool SketchSolver_Group::resolveConstraints()
         // the error message should be changed before sending the message
         sendMessage(EVENT_SOLVER_REPAIRED, aConflicting);
       }
+
+      // show degrees of freedom
+      computeDoF();
     } else {
       mySketchSolver->undo();
       if (!myConstraints.empty()) {
@@ -217,12 +220,29 @@ bool SketchSolver_Group::resolveConstraints()
       }
     if (aCIt == myConstraints.end())
       myStorage->refresh();
-  }
+  } else if (isGroupEmpty)
+    computeDoF();
   removeTemporaryConstraints();
   myStorage->setNeedToResolve(false);
   return aResolved;
 }
 
+// ============================================================================
+//  Function: computeDoF
+//  Class:    SketchSolver_Group
+//  Purpose:  compute DoF of the sketch and set corresponding field
+// ============================================================================
+void SketchSolver_Group::computeDoF() const
+{
+  std::ostringstream aDoFMsg;
+  int aDoF = /*isEmpty() ? myStorage->numberOfParameters() :*/ mySketchSolver->dof();
+  if (aDoF == 0)
+    aDoFMsg << "Sketch is fully fixed (DoF = 0)";
+  else
+    aDoFMsg << "DoF (degrees of freedom) = " << aDoF;
+  mySketch->string(SketchPlugin_Sketch::SOLVER_DOF())->setValue(aDoFMsg.str());
+}
+
 // ============================================================================
 //  Function: repairConsistency
 //  Class:    SketchSolver_Group
@@ -244,6 +264,9 @@ void SketchSolver_Group::repairConsistency()
 
     // remove invalid features
     myStorage->removeInvalidEntities();
+
+    // show DoF
+    computeDoF();
   }
 }
 
index c37524fa24663a90803f514199e26a7e3677f4f2..c795c5e9f80168c6a27a144f8f2c095fb26c8079 100644 (file)
@@ -94,6 +94,9 @@ private:
   /// \brief Append given constraint to the group of temporary constraints
   void setTemporary(SolverConstraintPtr theConstraint);
 
+  /// \brief Compute DoF of the sketch and set corresponding field
+  void computeDoF() const;
+
 private:
   CompositeFeaturePtr mySketch; ///< Sketch for this group
   ConstraintConstraintMap myConstraints; ///< List of constraints
index c1c21bffa8f7974f7332583e20676d4bba10d528..da9c5041e109aecdee801f858c7e0f104bf53116 100644 (file)
@@ -47,7 +47,7 @@ public:
   virtual bool isConflicting(const ConstraintID& theConstraint) const = 0;
 
   /// \brief Degrees of freedom
-  virtual int dof() const = 0;
+  virtual int dof() = 0;
 
 protected:
   bool    myFindFaileds; ///< flag to find conflicting or inappropriate constraints
index 8c227cba5e23f8e0c4bc893bf00e5da6b6aeb86f..332bd39af63f5aef76972a56671cb652c0ea2447 100644 (file)
@@ -108,8 +108,6 @@ public:
   void setNeedToResolve(bool theFlag)
   { myNeedToResolve = theFlag; }
 
-  /// \brief Initialize solver by constraints, entities and parameters
-  virtual void initializeSolver() = 0;
   /// \brief Return list of conflicting constraints
   std::set<ObjectPtr> getConflictingConstraints(SolverPtr theSolver) const;