]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Adjust test cases according to redesigned Arc and Circle features
authorazv <azv@opencascade.com>
Tue, 28 Mar 2017 07:52:50 +0000 (10:52 +0300)
committerazv <azv@opencascade.com>
Tue, 28 Mar 2017 08:39:29 +0000 (11:39 +0300)
49 files changed:
src/CollectionPlugin/Test/TestGroup.py
src/ConstructionPlugin/Test/TestAxisCreation.py
src/FeaturesPlugin/Test/TestBoolean.py
src/FeaturesPlugin/Test/TestBooleanCompSolids.py
src/FeaturesPlugin/Test/TestBooleanSmash.py
src/FeaturesPlugin/Test/TestCompositeFeaturesOnCompSolids.py
src/FeaturesPlugin/Test/TestExtrusion.py
src/FeaturesPlugin/Test/TestExtrusionCut.py
src/FeaturesPlugin/Test/TestExtrusionFuse.py
src/FeaturesPlugin/Test/TestIntersection.py
src/FeaturesPlugin/Test/TestMultiBoolean.py
src/FeaturesPlugin/Test/TestPartition.py
src/FeaturesPlugin/Test/TestPipe.py
src/FeaturesPlugin/Test/TestRemoveSubShapes.py
src/FeaturesPlugin/Test/TestRevolution.py
src/FeaturesPlugin/Test/TestRevolutionCut.py
src/FeaturesPlugin/Test/TestRevolutionFuse.py
src/FeaturesPlugin/Test/TestRotation.py
src/FeaturesPlugin/Test/TestSerialBoolean.py
src/FeaturesPlugin/Test/TestTranslation.py
src/FeaturesPlugin/Test/TestUnion.py
src/ModelAPI/Test/Test1512.py
src/ParametersPlugin/Test/TestParameterChangeValue.py
src/ParametersPlugin/Test/TestParameterCreation.py
src/ParametersPlugin/Test/TestParameterRename.py
src/PythonAPI/Test/TestSketcherAddMirror.py
src/PythonAPI/Test/TestSketcherSetTangent.py
src/PythonAPI/model/sketcher/__init__.py
src/PythonAPI/model/sketcher/tools.py
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Arc.cpp
src/SketchPlugin/SketchPlugin_msg_en.ts
src/SketchPlugin/Test/TestArcBehavior.py
src/SketchPlugin/Test/TestConstraintCoincidence.py
src/SketchPlugin/Test/TestConstraintDistance.py
src/SketchPlugin/Test/TestConstraintEqual.py
src/SketchPlugin/Test/TestConstraintMirror.py [deleted file]
src/SketchPlugin/Test/TestConstraintRadius.py
src/SketchPlugin/Test/TestConstraintTangent.py
src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py [new file with mode: 0644]
src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py
src/SketchPlugin/Test/TestCreateCircleByThreePoints.py
src/SketchPlugin/Test/TestCreateCircleChangeType.py
src/SketchPlugin/Test/TestFillet.py
src/SketchPlugin/Test/TestFilletInteracting.py
src/SketchPlugin/Test/TestMirror.py [new file with mode: 0644]
src/SketchPlugin/Test/TestMultiRotation.py
src/SketchPlugin/Test/TestMultiTranslation.py
src/SketchPlugin/Test/TestProjection.py

index 4c21a570a3a3ab323b0a8c96677fc00fff5e7aaf..a5e078821835a0007080a0cc7eb4be86814adfb4 100644 (file)
@@ -177,8 +177,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0., 57.74)
 aCircleRadius.setValue(50.)
 aSession.finishOperation()
index f9ef91118aae8d624499ca51ae1d9e4f47a13e93..0db452f9cb2bf493baa9518959cc02b53e7b60ef 100644 (file)
@@ -81,8 +81,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(50)
 aSession.finishOperation()
index 968263eaa732fa79c2d7f3ad4e561be1a7a08ce1..0d3426549cdd584c12db7a0e3db3f5e8b3fffcdb 100644 (file)
@@ -40,8 +40,8 @@ dirx.setValue(1, 0, 0)
 norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(10., 10.)
 aCircleRadius.setValue(50.)
 aSession.finishOperation()
index 414498fb4b47828860aaa1e787b05fd37638c65c..d4c5864f6423a008ab7f3e7076de5a4aee1374a2 100644 (file)
@@ -27,8 +27,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-aCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+aCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 aCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(50)
 
index 02d0606c71c1a4477e42bb02a77393a33ee3ed51..9570b1cd8f83d581852d27ac7c20159838ea62ff 100644 (file)
@@ -24,8 +24,8 @@ dirx.setValue(1, 0, 0)
 norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(10., 10.)
 aCircleRadius.setValue(50.)
 aSession.finishOperation()
index fceb782ff3c7ad881e575e1e6883a8523470927b..ef74d83916124bdc1c215a5722ee1161a8be309d 100644 (file)
@@ -28,8 +28,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-aCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+aCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 aCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(50)
 
@@ -118,8 +118,8 @@ norm.setValue(0, 0, 1)
 aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1")
 aSession.startOperation()
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(10)
 aSession.finishOperation()
@@ -195,8 +195,8 @@ norm.setValue(0, 0, 1)
 aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1")
 aSession.startOperation()
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(10)
 aSession.finishOperation()
index 527dafeacefc3de82bc6b86c340d20d30d50694d..efe7f293c9a1f3c185ba2e9a944600ab873ba351 100644 (file)
@@ -57,8 +57,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(50., 50)
 aCircleRadius.setValue(20.)
 aSession.finishOperation()
index e461c50e1ae800cdbcb4bf22cdcfa2ed336ed6e9..1d62b41c9b2694ec62916fa655d10e10fecf9e1b 100644 (file)
@@ -33,8 +33,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(20)
 aSession.finishOperation()
@@ -91,8 +91,8 @@ norm.setValue(0, 0, 1)
 aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1")
 aSession.startOperation()
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(10)
 aSession.finishOperation()
index 12693b837380cb3a272c3c9f0993a832b0e8df25..c05adb3e9e0cf45c3afa4c0fad8977674b060e7b 100644 (file)
@@ -33,8 +33,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(20)
 aSession.finishOperation()
@@ -91,8 +91,8 @@ norm.setValue(0, 0, 1)
 aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1")
 aSession.startOperation()
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(10)
 aSession.finishOperation()
index d1c0043a6ac44343e24bb4648b808fd6467c8007..1bcd0a6be53fad9da966ca3c615958f6d3e19ce4 100644 (file)
@@ -32,8 +32,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(-10, 0)
 aCircleRadius.setValue(50)
 aSession.finishOperation()
@@ -86,8 +86,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(10, 0)
 aCircleRadius.setValue(50)
 aSession.finishOperation()
index aa36d86280812bc8b1492249212b0355ba9e5bee..a7ea2cabd01b23280dad5290dfdaddc708daaf44 100644 (file)
@@ -58,8 +58,8 @@ for i in xrange(0, N):
         norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
         norm.setValue(0, 0, 1)
         aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-        anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-        aCircleRadius = aSketchCircle.real("CircleRadius")
+        anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+        aCircleRadius = aSketchCircle.real("circle_radius")
         anCircleCentr.setValue(0.5 + step * (0.5 + i), 0.5 + step * (0.5 + j))
         aCircleRadius.setValue(radius)
         aSketchFeatures.append(aSketchFeature)
index 127209b2afe39d574d799c26a68d4f8a92cade80..b21298a33fc4ed85903d2da21bcddb9576bb5e80 100644 (file)
@@ -34,8 +34,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(50)
 aSession.finishOperation()
index 21ba065e16f3e837a3d868d11eb133b9c13bd609..b6d59e23e0348097ef7ee143c0121aa086bae4fc 100644 (file)
@@ -27,8 +27,8 @@ norm.setValue(0, 0, 1)
 
 # Create circle
 aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("CircleCenter"))
-aCircleRadius = aSketchCircleFeature.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center"))
+aCircleRadius = aSketchCircleFeature.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(10)
 aSession.finishOperation()
@@ -65,10 +65,9 @@ aSketchLineEndPoint.setValue(0, 200)
 
 # Create arc
 aSketchArcFeature = aSketchFeature.addFeature("SketchArc")
-aSketchArcFeature.string("ArcType").setValue("CenterStartEnd")
-aSketchArcCenterPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("ArcCenter"))
-aSketchArcStartPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("ArcStartPoint"))
-aSketchArcEndPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("ArcEndPoint"))
+aSketchArcCenterPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("center_point"))
+aSketchArcStartPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("start_point"))
+aSketchArcEndPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("end_point"))
 aSketchArcCenterPoint.setValue(100, 200)
 aSketchArcStartPoint.setValue(200, 200)
 aSketchArcEndPoint.setValue(0, 200)
@@ -132,8 +131,8 @@ norm.setValue(0, 0, 1)
 
 # Create circle
 aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("CircleCenter"))
-aCircleRadius = aSketchCircleFeature.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center"))
+aCircleRadius = aSketchCircleFeature.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(20)
 aSession.finishOperation()
index 6227d4580e65876a3943c2f4b173de96978d691b..4d36094ff14aa91eec659cc098d37b46990e1b75 100644 (file)
@@ -33,13 +33,13 @@ norm.setValue(0, 0, 1)
 
 # Create circles
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(-25, 0)
 aCircleRadius.setValue(50)
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(25, 0)
 aCircleRadius.setValue(50)
 aSession.finishOperation()
index 28aba7762db84a42c6900e2dc144cdf831923250..306f1803e76494f6595e6b99d70b675c3008eb07 100644 (file)
@@ -59,8 +59,8 @@ norm.setValue(0, 0, 1)
 
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0., 0.)
 aCircleRadius.setValue(30.)
 aSession.finishOperation()
index c9b10c8feacfcd70a32a51922d6cb4cb741c27f9..c2d337e26a2ec41868263200540c17713b5b695a 100644 (file)
@@ -33,8 +33,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(20)
 aSession.finishOperation()
@@ -117,8 +117,8 @@ norm.setValue(0, 0, 1)
 aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1")
 aSession.startOperation()
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(10)
 aSession.finishOperation()
index 863d2a6d0d11affe61e3a4ddd181770d67ac45ed..1512f87f3fb38a4ed4c8f98266e52ee5299d7387 100644 (file)
@@ -61,8 +61,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(20)
 aSession.finishOperation()
@@ -145,8 +145,8 @@ norm.setValue(0, 0, 1)
 aCircleSketchFeature.selection("External").selectSubShape("face", "Extrusion_1/To_Face_1")
 aSession.startOperation()
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(10)
 aSession.finishOperation()
index 175b08fdf86e696e59924fa5c67084d0bc3fec12..c33308acb21a5cf4c0ff8f584d479c847785705f 100644 (file)
@@ -46,8 +46,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(50, 50)
 aCircleRadius.setValue(20)
 aSession.finishOperation()
index 7adf336245fcb522d8d82f0cbd019ef3e15053d6..2fef110c0411604a7a4e9a49c10d205a79f3baa9 100644 (file)
@@ -58,8 +58,8 @@ for i in xrange(0, N):
         norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
         norm.setValue(0, 0, 1)
         aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-        anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-        aCircleRadius = aSketchCircle.real("CircleRadius")
+        anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+        aCircleRadius = aSketchCircle.real("circle_radius")
         anCircleCentr.setValue(0.5 + step * (0.5 + i), 0.5 + step * (0.5 + j))
         aCircleRadius.setValue(radius)
         aSketchFeatures.append(aSketchFeature)
index f6d95033d504cd45abab887b0d4fbce565d2572a..d981d535f256005cd6cbe3d0d028482fe3c70dc1 100644 (file)
@@ -46,8 +46,8 @@ norm = geomDataAPI_Dir(aCircleSketchFeature.attribute("Norm"))
 norm.setValue(0, 0, 1)
 # Create circle
 aSketchCircle = aCircleSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(50, 50)
 aCircleRadius.setValue(20)
 aSession.finishOperation()
index 2b6f931ac779978cd7a84cc65bc5ed6cfdd43530..3ccfd563b76bc26095e94b72cb01d08fc891b041 100644 (file)
@@ -33,13 +33,13 @@ norm.setValue(0, 0, 1)
 
 # Create circles
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(-25, 0)
 aCircleRadius.setValue(50)
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(25, 0)
 aCircleRadius.setValue(50)
 aSession.finishOperation()
index 21fce85e8ec2b847e2b3629e71e88f5cc02ae7f8..bce23fd6a121ef14c48345478fef291e331b213d 100755 (executable)
@@ -65,8 +65,8 @@ aSession.startOperation()
 aSketchFeature2 = featureToCompositeFeature(aPart.addFeature("Sketch"))
 aSketchFeature2.selection("External").setValue(aXOYPlane, None);
 aCirc1 = aSketchFeature2.addFeature("SketchCircle")
-geomDataAPI_Point2D(aCirc1.attribute("CircleCenter")).setValue(100, 50)
-aCirc1.real("CircleRadius").setValue(40)
+geomDataAPI_Point2D(aCirc1.attribute("circle_center")).setValue(100, 50)
+aCirc1.real("circle_radius").setValue(40)
 aSession.finishOperation()
 
 #=========================================================================
@@ -97,8 +97,8 @@ aSession.startOperation()
 aSketchFeature3 = featureToCompositeFeature(aPart.addFeature("Sketch"))
 aSketchFeature3.selection("External").setValue(aXOYPlane, None);
 aCirc2 = aSketchFeature3.addFeature("SketchCircle")
-geomDataAPI_Point2D(aCirc2.attribute("CircleCenter")).setValue(20, 20)
-aCirc2.real("CircleRadius").setValue(10)
+geomDataAPI_Point2D(aCirc2.attribute("circle_center")).setValue(20, 20)
+aCirc2.real("circle_radius").setValue(10)
 aSession.finishOperation()
 
 #=========================================================================
index 3d6d9e23056a22dd0bd9380a53dd3847a01beca3..2eca3f077527b1af01e1acf371052fb6c0220137 100644 (file)
@@ -79,8 +79,8 @@ class TestParameterRename(unittest.TestCase):
         norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
         norm.setValue(0, 0, 1)
         aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-        anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-        aRadiusAttr = aSketchCircle.real("CircleRadius")
+        anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+        aRadiusAttr = aSketchCircle.real("circle_radius")
         anCircleCentr.setValue(10., 20.)
         aRadiusAttr.setValue(10.)
         self.aSession.finishOperation()
index ad85bdf51cfe8464d2ceeb52713eacbf577d1abf..69574c10aceca5459fc76dbb2b09bcd6afbbd468 100644 (file)
@@ -118,8 +118,8 @@ assert (aTmValue == round(2 * math.pi, 6))
 #=========================================================================
 aSession.startOperation()
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aRadiusAttr = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aRadiusAttr = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(250., 250)
 aRadiusAttr.setValue(25.)
 aSession.finishOperation()
index 4141338293245ce6f1d9ab46b56727746a99f0e0..0f2f90174a2879a273ba0ecb391ecac5fcc62cf7 100644 (file)
@@ -82,8 +82,8 @@ class TestParameterRename(unittest.TestCase):
         norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
         norm.setValue(0, 0, 1)
         aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-        anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-        aRadiusAttr = aSketchCircle.real("CircleRadius")
+        anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+        aRadiusAttr = aSketchCircle.real("circle_radius")
         anCircleCentr.setValue(10., 20.)
         aRadiusAttr.setValue(10.)
         self.aSession.finishOperation()
index 032bff2374ace8872a5ba954f81895e82bfa1b6f..65d7e3dc8e2fab364fa94e6b81041de60d0a4ecf 100644 (file)
@@ -19,10 +19,10 @@ class SketcherAddLine(SketcherTestCase):
         mirrored_objects = mirror.mirroredObjects()
         mirrored_circle = mirrored_objects.object(0)
         circle_feature = ModelAPI_Feature.feature(mirrored_circle)
-        center = geomDataAPI_Point2D(circle_feature.attribute("CircleCenter"))
+        center = geomDataAPI_Point2D(circle_feature.attribute("circle_center"))
         self.assertEqual(center.x(), -30)
         # dir(mirrored_circle)
-        # center = geomDataAPI_Point2D(mirrored_circle.data().attribute("CircleCenter"))
+        # center = geomDataAPI_Point2D(mirrored_circle.data().attribute("circle_center"))
         # self.assertEqual(center.x(), -30, msg="%s"%(dir(mirrored_circle)))
         # self.assertTrue(False,  msg="%s" % (dir(mirrored_circle)))
 
index b2464370d633c2db784c18bd250985bb7700583a..d92d6433c0f65c25f840ae3b72e4b2a418e6f32b 100644 (file)
@@ -6,9 +6,9 @@ class SketcherSetTangent(SketcherTestCase):
     def setUp(self):
         SketcherTestCase.setUp(self)
         self.line = self.sketch.addLine(0, 0, 0, 1)
-        self.arc = self.sketch.addArc(0, 1, 0, 0, 1, 1)
+        self.arc = self.sketch.addArc(0, 1, 0, 0, 1, 1, False)
         self.sketch.setCoincident(
-            self.line.endPoint(), self.arc.startPoint()
+            self.line.startPoint(), self.arc.startPoint()
             )
         
     def test_set_tangent(self):
index 994ecc6f11ef8b05af65e40c5659c59a7b302be7..b015b4278170b469d81fa7d734d14f4812bb448f 100644 (file)
@@ -2,4 +2,4 @@
 """
 
 from SketchAPI import addSketch
-from tools import addPolyline, addPolygon, dof
+from tools import *
index 3603f20061b35215c312877b8a5b94ec66671af3..0a17f6aeaede8eafbefdd10bd541440af51b9ef0 100644 (file)
@@ -2,6 +2,7 @@
 # Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
 import ModelHighAPI
+import GeomDataAPI
 
 def addPolyline(sketch, *coords):
     """Add a poly-line to sketch.
@@ -48,4 +49,22 @@ def dof(sketch):
     aSketch = sketch
     if issubclass(type(aSketch), ModelHighAPI.ModelHighAPI_Interface):
         aSketch = sketch.feature()
-    return int(filter(str.isdigit, aSketch.string("SolverDOF").value()))
\ No newline at end of file
+    return int(filter(str.isdigit, aSketch.string("SolverDOF").value()))
+
+def distancePointPoint(thePoint1, thePoint2):
+    aGeomPnt1 = thePoint1
+    aGeomPnt2 = thePoint2
+    if issubclass(type(thePoint1), GeomDataAPI.GeomDataAPI_Point2D):
+        aGeomPnt1 = thePoint1.pnt()
+    if issubclass(type(thePoint2), GeomDataAPI.GeomDataAPI_Point2D):
+        aGeomPnt2 = thePoint2.pnt()
+    return aGeomPnt1.distance(aGeomPnt2)
+
+def lastSubFeature(theSketch, theKind):
+    """
+    obtains last feature of given kind from the sketch
+    """
+    for anIndex in range(theSketch.numberOfSubs() - 1, -1, -1):
+        aSub = theSketch.subFeature(anIndex)
+        if (aSub.getKind() == theKind):
+            return aSub
index 84349b45b3b4b2e7f89de2c3f0ef99d2c0374504..8ac8414eef33291978f8c44b9494faada2b5ae43 100644 (file)
@@ -125,7 +125,10 @@ INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Sketc
 INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
 
 ADD_UNIT_TESTS(TestSketchPointLine.py
-               TestCreateArc.py
+               TestCreateArcByCenterStartEnd.py
+               TestCreateArcByThreePoints.py
+               TestCreateArcByTangentEdge.py
+               TestCreateArcChangeType.py
                TestCreateCircleByCenterAndPassed.py
                TestCreateCircleByThreePoints.py
                TestCreateCircleChangeType.py
@@ -141,9 +144,9 @@ ADD_UNIT_TESTS(TestSketchPointLine.py
                TestConstraintVertical.py
                TestConstraintEqual.py
                TestConstraintTangent.py
-               TestConstraintMirror.py
                TestConstraintAngle.py
                TestConstraintMiddlePoint.py
+               TestMirror.py
                TestMultiRotation.py
                TestMultiTranslation.py
                TestFillet.py
index 9ebf16eb34205e343f114a511be0a5eb0e9ba60f..1890400ce34dec026540fe287b3b2ae79d0f8f3e 100644 (file)
@@ -190,8 +190,17 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID)
         aCirc->parameter(anEdge->firstPoint(), paramTolerance, aStartParam);
         aCirc->parameter(aMinPnt, paramTolerance, aMidParam);
         aCirc->parameter(anEdge->lastPoint(), paramTolerance, anEndParam);
+
+        // adjust period
+        anEndParam -= aStartParam;
+        aMidParam -= aStartParam;
+        if (anEndParam < 0.0)
+          anEndParam += 2.0 * PI;
+        if (aMidParam < 0.0)
+          aMidParam += 2.0 * PI;
+
         aWasBlocked = data()->blockSendAttributeUpdated(true);
-        if(aStartParam < aMidParam && aMidParam < anEndParam) {
+        if(aMidParam < anEndParam) {
           setReversed(false);
         } else {
           setReversed(true);
index 994eba6d54054f0e63cb76dbd7b58813d16ada5a..f4f41f841efdfa4808309881a5ead0a33f995bdb 100755 (executable)
@@ -82,7 +82,7 @@
   <context>
     <name>SketchMacroCircle:Model_FeatureValidator</name>
     <message>
-      <source>Attribute "CircleCenter" is not initialized.</source>
+      <source>Attribute "circle_center" is not initialized.</source>
       <translation>A center point is not selected</translation>
     </message>
   </context>
   <context>
     <name>SketchMacroCircle:CircleCenter</name>
     <message>
-      <source>Attribute "CircleCenter" is locked by modification value in the viewer.</source>
+      <source>Attribute "circle_center" is locked by modification value in the viewer.</source>
       <translation>Select a center point</translation>
     </message>
   </context>
   <context>
     <name>SketchMacroCircle:CircleRadius</name>
     <message>
-      <source>Attribute "CircleRadius" is locked by modification value in the viewer.</source>
+      <source>Attribute "circle_radius" is locked by modification value in the viewer.</source>
       <translation>Select a radius distance</translation>
     </message>
   </context>
   <context>
     <name>SketchMacroCircle:Model_FeatureValidator</name>
     <message>
-      <source>Attribute "CircleRadius" is not initialized.</source>
+      <source>Attribute "circle_radius" is not initialized.</source>
       <translation>Set the circle radius</translation>
     </message>
   </context>
   <context>
     <name>SketchArc:ArcCenter</name>
     <message>
-      <source>Attribute "ArcCenter" is locked by modification value in the viewer.</source>
+      <source>Attribute "center_point" is locked by modification value in the viewer.</source>
       <translation>Select a center point</translation>
     </message>
   </context>
   <context>
     <name>SketchArc:ArcCenter</name>
     <message>
-      <source>Attribute "ArcCenter" is not initialized.</source>
+      <source>Attribute "center_point" is not initialized.</source>
       <translation>Center point is not defined</translation>
     </message>
   </context>
   <context>
     <name>SketchArc:Model_FeatureValidator</name>
     <message>
-      <source>Attribute "ArcCenter" is not initialized.</source>
+      <source>Attribute "center_point" is not initialized.</source>
       <translation>Select an arc center</translation>
     </message>
   </context>
   <context>
     <name>SketchArc:Model_FeatureValidator:ArcStartPoint</name>
     <message>
-      <source>Attribute "ArcStartPoint" is not initialized.</source>
+      <source>Attribute "start_point" is not initialized.</source>
       <translation>Select an arc start point</translation>
     </message>
   </context>
   <context>
     <name>SketchArc:Model_FeatureValidator</name>
     <message>
-      <source>Attribute "ArcEndPoint" is not initialized.</source>
+      <source>Attribute "end_point" is not initialized.</source>
       <translation>Select an arc end point</translation>
     </message>
   </context>
index 24014cae24ef3b1139ebfa4ccd7c2275319594b8..b0e31d72978fec2954acaa5b47889144424b5b62 100644 (file)
@@ -35,11 +35,11 @@ aSession.finishOperation()
 #=========================================================================
 aSession.startOperation()
 aSketchArc = aSketchFeature.addFeature("SketchArc")
-anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
+anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("center_point"))
 anArcCentr.setValue(0., 0.)
-anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint"))
+anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("start_point"))
 anArcStartPoint.setValue(0., 10.)
-anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("end_point"))
 anArcEndPoint.setValue(1., 10.)
 aSession.finishOperation()
 # the arc must be small, not near to the whole circle
@@ -94,11 +94,11 @@ assert shapeToEdge(aSketchArc.lastResult().shape()).length() > 60.
 # check from the scratch that from initial state to counterclockwise position also works
 aSession.startOperation()
 aSketchArc = aSketchFeature.addFeature("SketchArc")
-anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
+anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("center_point"))
 anArcCentr.setValue(0., 0.)
-anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint"))
+anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("start_point"))
 anArcStartPoint.setValue(0., 10.)
-anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("end_point"))
 anArcEndPoint.setValue(-1., 10.)
 aSession.finishOperation()
 # the arc must be small, not near to the whole circle
@@ -108,29 +108,29 @@ assert shapeToEdge(aSketchArc.lastResult().shape()).length() < 2.
 #=========================================================================
 aSession.startOperation()
 aSketchArc = aSketchFeature.addFeature("SketchArc")
-anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
+anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("center_point"))
 anArcCentr.setValue(0., 0.)
-anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint"))
+anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("start_point"))
 anArcStartPoint.setValue(0., 10.)
-anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("end_point"))
 anArcEndPoint.setValue(10, 0.)
 aSession.finishOperation()
-anInversed = aSketchArc.boolean("InversedArc").value()
+anInversed = aSketchArc.boolean("reversed").value()
 for aCenterCoords in range(1, 20):
   aSession.startOperation()
   anArcCentr.setValue(aCenterCoords, aCenterCoords/2) # move center
   aSession.finishOperation()
-  assert aSketchArc.boolean("InversedArc").value() == anInversed
+  assert aSketchArc.boolean("reversed").value() == anInversed
 for aCenterCoords in range(20, -20, -1):
   aSession.startOperation()
   anArcCentr.setValue(aCenterCoords, aCenterCoords/2) # move center
   aSession.finishOperation()
-  assert aSketchArc.boolean("InversedArc").value() == anInversed
+  assert aSketchArc.boolean("reversed").value() == anInversed
 for aCenterCoords in range(-20, 20):
   aSession.startOperation()
   anArcCentr.setValue(aCenterCoords, aCenterCoords/2) # move center
   aSession.finishOperation()
-  assert aSketchArc.boolean("InversedArc").value() == anInversed
+  assert aSketchArc.boolean("reversed").value() == anInversed
 #=========================================================================
 # Test that movement of start point of arc does not change central point
 #=========================================================================
index 0ee20f691de2f3413b968b203730bce1f35706be..893242aa9a935ebc385e05fda518089e79c68054 100644 (file)
@@ -42,14 +42,14 @@ def checkPointOnLine(point, line):
     assert (math.fabs(aDirX * aVecY - aDirY * aVecX) <= TOLERANCE)
 
 def checkPointOnCircle(point, circle):
-    aCenter = geomDataAPI_Point2D(circle.attribute("CircleCenter"))
-    aRadius = circle.real("CircleRadius").value()
+    aCenter = geomDataAPI_Point2D(circle.attribute("circle_center"))
+    aRadius = circle.real("circle_radius").value()
     aDist = math.hypot(point.x() - aCenter.x(), point.y() - aCenter.y())
     assert (math.fabs(aDist - aRadius) <= TOLERANCE)
 
 def checkPointOnArc(point, arc):
-    aStart  = geomDataAPI_Point2D(arc.attribute("ArcStartPoint"))
-    aCenter = geomDataAPI_Point2D(arc.attribute("ArcCenter"))
+    aStart  = geomDataAPI_Point2D(arc.attribute("start_point"))
+    aCenter = geomDataAPI_Point2D(arc.attribute("center_point"))
     aRadius = math.hypot(aStart.x() - aCenter.x(), aStart.y() - aCenter.y())
     aDist = math.hypot(point.x() - aCenter.x(), point.y() - aCenter.y())
     assert (math.fabs(aDist - aRadius) <= TOLERANCE)
@@ -86,9 +86,9 @@ aSession.finishOperation()
 #=========================================================================
 aSession.startOperation()
 aSketchArc = aSketchFeature.addFeature("SketchArc")
-anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
-anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint"))
-anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
+anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("center_point"))
+anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("start_point"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("end_point"))
 anArcCentr.setValue(10., 10.)
 anArcStartPoint.setValue(0., 50.)
 anArcEndPoint.setValue(50., 0.)
@@ -160,8 +160,8 @@ assert (model.dof(aSketchFeature) == 8)
 aSession.startOperation()
 # create circle with center coincident with origin
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-aCircleCenter = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+aCircleCenter = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 aCircleCenter.setValue(10., 10.)
 aCircleRadius.setValue(25.)
 aSession.finishOperation()
index 2c8b5c6a02b0e2c68354bc08e25c3274cdf53cb8..47a67e6ec779b8ccb87c9b82d1060127fd208a57 100644 (file)
@@ -31,15 +31,6 @@ from salome.shaper import model
 __updated__ = "2014-10-28"
 
 
-def distancePointPoint(pointA, pointB):
-    """
-    subroutine to calculate distance between two points
-    result of calculated distance is has 10**-5 precision
-    """
-    xdiff = math.pow((pointA.x() - pointB.x()), 2)
-    ydiff = math.pow((pointA.y() - pointB.y()), 2)
-    return round(math.sqrt(xdiff + ydiff), 5)
-
 def distancePointLine(point, line):
     """
     subroutine to calculate distance between point and line
@@ -91,7 +82,7 @@ assert (model.dof(aSketchFeature) == 6)
 # Make a constraint to keep the distance
 #=========================================================================
 PT_PT_DIST = 25.
-aDist = distancePointPoint(aSketchPointCoords, aLineAStartPoint);
+aDist = model.distancePointPoint(aSketchPointCoords, aLineAStartPoint);
 assert (aDist != PT_PT_DIST)
 aSession.startOperation()
 aConstraint = aSketchFeature.addFeature("SketchConstraintDistance")
@@ -125,7 +116,7 @@ assert (model.dof(aSketchFeature) == 5)
 aSession.startOperation()
 aDistance.setValue(PT_PT_DIST)
 aSession.finishOperation()
-assert (math.fabs(distancePointPoint(aSketchPointCoords, aLineAStartPoint) - PT_PT_DIST) < 1.e-10)
+assert (math.fabs(model.distancePointPoint(aSketchPointCoords, aLineAStartPoint) - PT_PT_DIST) < 1.e-10)
 assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Move line, check that distance is constant
@@ -134,7 +125,7 @@ aSession.startOperation()
 aLineAStartPoint.setValue(0., 40.)
 aLineAEndPoint.setValue(100., 40.)
 aSession.finishOperation()
-assert (math.fabs(distancePointPoint(aSketchPointCoords, aLineAStartPoint) - PT_PT_DIST) < 1.e-10)
+assert (math.fabs(model.distancePointPoint(aSketchPointCoords, aLineAStartPoint) - PT_PT_DIST) < 1.e-10)
 assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # Remove constraint, check the points are unconstrained now
@@ -145,7 +136,7 @@ aSession.finishOperation()
 aSession.startOperation()
 aSketchPointCoords.setValue(0., 0.)
 aSession.finishOperation()
-assert (math.fabs(distancePointPoint(aSketchPointCoords, aLineAStartPoint) - PT_PT_DIST) > 1.e-10)
+assert (math.fabs(model.distancePointPoint(aSketchPointCoords, aLineAStartPoint) - PT_PT_DIST) > 1.e-10)
 assert (model.dof(aSketchFeature) == 6)
 
 #=========================================================================
@@ -192,7 +183,7 @@ aSession.startOperation()
 refattrA.setAttr(aLineAStartPoint)
 refattrB.setAttr(aLineAEndPoint)
 aSession.finishOperation()
-assert (math.fabs(distancePointPoint(aLineAStartPoint, aLineAEndPoint) - PT_LINE_DIST) < 1.e-10)
+assert (math.fabs(model.distancePointPoint(aLineAStartPoint, aLineAEndPoint) - PT_LINE_DIST) < 1.e-10)
 assert (model.dof(aSketchFeature) == 5)
 #=========================================================================
 # End of test
index 49bf176586198358d9f30b70e2ac1ad7cc200760..5c518e99a8bc0505c0e41dda7bf60c1f234f2b08 100644 (file)
@@ -31,11 +31,11 @@ def externalSketch(theDoc):
     norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
     norm.setValue(0, 0, 1)
     # add circle defined by 3 points
-    circle = aSketchFeature.addFeature("SketchCircle")
-    circle.string("CircleType").setValue("ThreePoints")
-    geomDataAPI_Point2D(circle.attribute("FirstPoint")).setValue(-40., 50.)
-    geomDataAPI_Point2D(circle.attribute("SecondPoint")).setValue(-50., 60.)
-    geomDataAPI_Point2D(circle.attribute("ThirdPoint")).setValue(-60., 50.)
+    circle = aSketchFeature.addFeature("SketchMacroCircle")
+    circle.string("circle_type").setValue("circle_type_by_three_points")
+    geomDataAPI_Point2D(circle.attribute("first_point")).setValue(-40., 50.)
+    geomDataAPI_Point2D(circle.attribute("second_point")).setValue(-50., 60.)
+    geomDataAPI_Point2D(circle.attribute("third_point")).setValue(-60., 50.)
     # add line
     line = aSketchFeature.addFeature("SketchLine")
     lineStart = geomDataAPI_Point2D(line.attribute("StartPoint"))
@@ -80,19 +80,19 @@ aSession.finishOperation()
 #=========================================================================
 aSession.startOperation()
 aSketchArc = aSketchFeature.addFeature("SketchArc")
-anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
+anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("center_point"))
 anArcCentr.setValue(10., 10.)
-anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint"))
+anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("start_point"))
 anArcStartPoint.setValue(0., 50.)
-anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("end_point"))
 anArcEndPoint.setValue(50., 0.)
 aSession.finishOperation()
 assert (model.dof(aSketchFeature) == 5)
 # Circle
 aSession.startOperation()
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 anCircleCentr.setValue(-25., -25.)
 aCircleRadius.setValue(25.)
 aSession.finishOperation()
@@ -123,8 +123,8 @@ assert (model.dof(aSketchFeature) == 7)
 #=========================================================================
 aSession.startOperation()
 anExtCircle = aSketchFeature.addFeature("SketchCircle")
-anExtCircleCenter = geomDataAPI_Point2D(anExtCircle.attribute("CircleCenter"))
-anExtCircleRadius = anExtCircle.real("CircleRadius")
+anExtCircleCenter = geomDataAPI_Point2D(anExtCircle.attribute("circle_center"))
+anExtCircleRadius = anExtCircle.real("circle_radius")
 anExtCircleCenter.setValue(-50., 50.)
 anExtCircleRadius.setValue(10.)
 anExtCircle.selection("External").selectSubShape("EDGE", "Sketch_1/Edge-SketchCircle_1_2")
diff --git a/src/SketchPlugin/Test/TestConstraintMirror.py b/src/SketchPlugin/Test/TestConstraintMirror.py
deleted file mode 100644 (file)
index 78fe2fb..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-"""
-    TestConstraintMirror.py
-    Unit test of SketchPlugin_ConstraintMirror class
-        
-    SketchPlugin_ConstraintMirror
-        static const std::string MY_CONSTRAINT_MIRROR_ID("SketchConstraintMirror");
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefListAttr::typeId());
-        data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefListAttr::typeId());
-
-"""
-from GeomDataAPI import *
-from ModelAPI import *
-import math
-from salome.shaper import model
-
-#=========================================================================
-# Initialization of the test
-#=========================================================================
-
-__updated__ = "2015-03-17"
-
-#=========================================================================
-# Auxiliary functions
-#=========================================================================
-def normalize(theDir):
-    aLen = math.hypot(theDir[0], theDir[1])
-    if aLen < 1.e-10:
-        aLen = 1.0
-    return [theDir[0] / aLen, theDir[1] / aLen]
-
-def checkMirror(theListInit, theListMirr, theMirrorLine):
-    TOL = 6.e-5
-    aListSize = theListInit.size()
-    
-    aLineStartPoint = geomDataAPI_Point2D(theMirrorLine.attribute("StartPoint"))
-    aLineEndPoint = geomDataAPI_Point2D(theMirrorLine.attribute("EndPoint"))
-    aLineDir = [aLineEndPoint.x() - aLineStartPoint.x(), aLineEndPoint.y() - aLineStartPoint.y()]
-    aLineDir = normalize(aLineDir)
-
-    for ind in range(0, aListSize):
-        aFeatureB = ModelAPI_Feature.feature(theListInit.object(ind))
-        aFeatureC = ModelAPI_Feature.feature(theListMirr.object(ind))
-        assert(aFeatureB is not None)
-        assert(aFeatureC is not None)
-        assert(aFeatureB.getKind() == aFeatureC.getKind())
-        
-        anAttributes = []
-        if (aFeatureB.getKind() == "SketchLine"):
-            anAttributes = ['StartPoint', 'EndPoint']
-        elif (aFeatureB.getKind() == "SketchArc"):
-            anAttributes = ['ArcCenter', 'ArcStartPoint', 'ArcEndPoint']
-        
-        for key in anAttributes:
-            aPointB = geomDataAPI_Point2D(aFeatureB.attribute(key))
-            aPointC = geomDataAPI_Point2D(aFeatureC.attribute(key))
-            aDir = [aPointC.x() - aPointB.x(), aPointC.y() - aPointB.y()]
-            aDir = normalize(aDir)
-            aDot = aLineDir[0] * aDir[0] + aLineDir[1] * aDir[1]
-            assert math.fabs(aDot) < TOL, "aDot = {0}".format(aDot)
-            aDir[0] = aLineEndPoint.x() - 0.5 * (aPointB.x() + aPointC.x())
-            aDir[1] = aLineEndPoint.y() - 0.5 * (aPointB.y() + aPointC.y())
-            aCross = aLineDir[0] * aDir[1] - aLineDir[1] * aDir[0]
-            assert math.fabs(aCross) < TOL, "aCross = {0}".format(aCross)
-
-
-#=========================================================================
-# Start of test
-#=========================================================================
-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()
-#=========================================================================
-# Creation of an arc and two lines
-#=========================================================================
-# Arc
-aSession.startOperation()
-aSketchArc1 = aSketchFeature.addFeature("SketchArc")
-anArcCentr = geomDataAPI_Point2D(aSketchArc1.attribute("ArcCenter"))
-anArcCentr.setValue(10., 10.)
-anArcStartPoint = geomDataAPI_Point2D(aSketchArc1.attribute("ArcStartPoint"))
-anArcStartPoint.setValue(0., 50.)
-anArcEndPoint = geomDataAPI_Point2D(aSketchArc1.attribute("ArcEndPoint"))
-anArcEndPoint.setValue(50., 0.)
-aSession.finishOperation()
-# Line 1
-aSession.startOperation()
-aSketchLine1 = aSketchFeature.addFeature("SketchLine")
-aLine1StartPoint = geomDataAPI_Point2D(aSketchLine1.attribute("StartPoint"))
-aLine1EndPoint = geomDataAPI_Point2D(aSketchLine1.attribute("EndPoint"))
-aLine1StartPoint.setValue(0., 50.)
-aLine1EndPoint.setValue(0., 100.)
-aSession.finishOperation()
-# Line 2
-aSession.startOperation()
-aSketchLine2 = aSketchFeature.addFeature("SketchLine")
-aLine2StartPoint = geomDataAPI_Point2D(aSketchLine2.attribute("StartPoint"))
-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
-#=========================================================================
-aSession.startOperation()
-aConstraint = aSketchFeature.addFeature("SketchConstraintCoincidence")
-reflistA = aConstraint.refattr("ConstraintEntityA")
-reflistB = aConstraint.refattr("ConstraintEntityB")
-reflistA.setAttr(anArcStartPoint)
-reflistB.setAttr(aLine1StartPoint)
-aConstraint.execute()
-aSession.finishOperation()
-aSession.startOperation()
-aConstraint = aSketchFeature.addFeature("SketchConstraintCoincidence")
-reflistA = aConstraint.refattr("ConstraintEntityA")
-reflistB = aConstraint.refattr("ConstraintEntityB")
-reflistA.setAttr(anArcEndPoint)
-reflistB.setAttr(aLine2StartPoint)
-aConstraint.execute()
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 9)
-#=========================================================================
-# Add tangency constraint and check correctness
-#=========================================================================
-aSession.startOperation()
-aTangency = aSketchFeature.addFeature("SketchConstraintTangent")
-aRefObjectA = aTangency.refattr("ConstraintEntityA")
-aRefObjectB = aTangency.refattr("ConstraintEntityB")
-anObjectA = modelAPI_ResultConstruction(aSketchArc1.lastResult())
-anObjectB = modelAPI_ResultConstruction(aSketchLine1.lastResult())
-assert (anObjectA is not None)
-assert (anObjectB is not None)
-aRefObjectA.setObject(anObjectA)
-aRefObjectB.setObject(anObjectB)
-aTangency.execute()
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 8)
-#=========================================================================
-# Create mirror line
-#=========================================================================
-aSession.startOperation()
-aMirrorLine = aSketchFeature.addFeature("SketchLine")
-aLineStartPoint = geomDataAPI_Point2D(aMirrorLine.attribute("StartPoint"))
-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
-#=========================================================================
-aSession.startOperation()
-aMirror = aSketchFeature.addFeature("SketchConstraintMirror")
-aRefObjectA = aMirror.refattr("ConstraintEntityA")
-aRefObjectA.setObject(modelAPI_ResultConstruction(aMirrorLine.firstResult()))
-aRefListInitial = aMirror.reflist("ConstraintMirrorList")
-aRefListInitial.append(aSketchLine1.lastResult())
-aRefListInitial.append(aSketchArc1.lastResult())
-aRefListInitial.append(aSketchLine2.lastResult())
-aMirror.execute()
-aSession.finishOperation()
-assert (model.dof(aSketchFeature) == 12)
-#=========================================================================
-# Verify the simmetricity of all mirrored objects
-#=========================================================================
-aRefListB = aMirror.reflist("ConstraintEntityB")
-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
-#=========================================================================
-aSession.startOperation()
-aRefListInitial.remove(aSketchLine2.lastResult())
-aSession.finishOperation()
-assert (aRefListB.size() == 2)
-assert (aRefListC.size() == 2)
-checkMirror(aRefListB, aRefListC, aMirrorLine)
-assert (model.dof(aSketchFeature) == 12)
-
-#=========================================================================
-# Clear list of mirrored features
-#=========================================================================
-aSession.startOperation()
-aRefListInitial.clear()
-assert (aRefListB.size() == 0)
-assert (aRefListC.size() == 0)
-# add arc once again
-aRefListInitial.append(aSketchArc1.lastResult())
-aSession.finishOperation()
-assert (aRefListB.size() == 1)
-assert (aRefListC.size() == 1)
-checkMirror(aRefListB, aRefListC, aMirrorLine)
-assert (model.dof(aSketchFeature) == 12)
-#=========================================================================
-# End of test
-#=========================================================================
-
-assert(model.checkPythonDump())
index 9ba906752f4c4210ffdc93479bae3e83d25752ae..f11cf74c908f519d1b1dde7dc515b3f939ef8d46 100644 (file)
@@ -28,15 +28,6 @@ from salome.shaper import model
 
 __updated__ = "2014-10-28"
 
-def distancePointPoint(pointA, pointB):
-    """
-    subroutine to calculate distance between two points
-    result of calculated distance is has 10**-5 precision
-    """
-    xdiff = math.pow((pointA.x() - pointB.x()), 2)
-    ydiff = math.pow((pointA.y() - pointB.y()), 2)
-    return round(math.sqrt(xdiff + ydiff), 5)
-
 
 aSession = ModelAPI_Session.get()
 aDocument = aSession.moduleDocument()
@@ -58,11 +49,11 @@ aSession.finishOperation()
 #=========================================================================
 aSession.startOperation()
 aSketchArc = aSketchFeature.addFeature("SketchArc")
-anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
+anArcCentr = geomDataAPI_Point2D(aSketchArc.attribute("center_point"))
 anArcCentr.setValue(10., 10.)
-anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint"))
+anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("start_point"))
 anArcStartPoint.setValue(0., 50.)
-anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("end_point"))
 anArcEndPoint.setValue(50., 0.)
 aSession.finishOperation()
 assert (model.dof(aSketchFeature) == 5)
@@ -81,22 +72,16 @@ assert (model.dof(aSketchFeature) == 5)
 # Circle
 aSession.startOperation()
 aSketchCircle = aSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter"))
-aCircleRadius = aSketchCircle.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center"))
+aCircleRadius = aSketchCircle.real("circle_radius")
 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
 #=========================================================================
+RADIUS = 40
 aSession.startOperation()
 aConstraint = aSketchFeature.addFeature("SketchConstraintRadius")
 aRadius = aConstraint.real("ConstraintValue")
@@ -104,7 +89,7 @@ aRefObject = aConstraint.refattr("ConstraintEntityA")
 aResult = aSketchArc.lastResult()
 assert (aResult is not None)
 aRefObject.setObject(modelAPI_ResultConstruction(aResult))
-aConstraint.execute()
+aRadius.setValue(RADIUS)
 aSession.finishOperation()
 assert (aRadius.isInitialized())
 assert (aRefObject.isInitialized())
@@ -119,19 +104,21 @@ aRefObject = aConstraint.refattr("ConstraintEntityA")
 aResult = aSketchCircle.lastResult()
 assert (aResult is not None)
 aRefObject.setObject(modelAPI_ResultConstruction(aResult))
-aConstraint.execute()
+aRadius.setValue(RADIUS)
 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
+# 1. Check that constraints does not change values
 # 2. Move one point of the arc
 # 3. Check that second point is moved also
 #=========================================================================
-assert (math.fabs(distancePointPoint(anArcCentr, anArcStartPoint) - RADIUS) < 1.e-10)
-assert (math.fabs(distancePointPoint(anArcCentr, anArcEndPoint) - RADIUS) < 1.e-10)
+distCS = model.distancePointPoint(anArcCentr, anArcStartPoint)
+distCE = model.distancePointPoint(anArcCentr, anArcEndPoint)
+assert (math.fabs(distCS - RADIUS) < 1.e-10)
+assert (math.fabs(distCE - RADIUS) < 1.e-10)
 anArcPrevEndPointX = anArcEndPoint.x()
 anArcPrevEndPointY = anArcEndPoint.y()
 # Move one point of the arc
@@ -140,8 +127,10 @@ anArcStartPoint.setValue(0, 60)
 aSession.finishOperation()
 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)
+distCS = model.distancePointPoint(anArcCentr, anArcStartPoint)
+distCE = model.distancePointPoint(anArcCentr, anArcEndPoint)
+assert (math.fabs(distCS - RADIUS) < 1.e-10)
+assert (math.fabs(distCE - RADIUS) < 1.e-10)
 assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # 4. Move the centr or the point of the arc
@@ -149,13 +138,13 @@ assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 assert (anCircleCentr.x() == -25)
 assert (anCircleCentr.y() == -25)
-assert (aCircleRadius.value() == 25)
+assert (aCircleRadius.value() == RADIUS)
 aSession.startOperation()
 anCircleCentr.setValue(100., 100.)
 aSession.finishOperation()
 assert (anCircleCentr.x() == 100)
 assert (anCircleCentr.y() == 100)
-assert (aCircleRadius.value() == 25)
+assert (aCircleRadius.value() == RADIUS)
 assert (model.dof(aSketchFeature) == 6)
 #=========================================================================
 # End of test
index 7b37ce0f3184fc5b258f5b77f22f7d13b5dc2f6c..a7ea5c64e85a58f73c80f088a8516518e01987f7 100644 (file)
@@ -20,14 +20,6 @@ from salome.shaper import model
 
 __updated__ = "2015-03-17"
 
-def distancePointPoint(thePoint1, thePoint2):
-    """
-    subroutine to calculate distance between two points
-    result of calculated distance is has 10**-5 precision
-    """
-    aDist = math.sqrt((thePoint1.x()-thePoint2.x())**2 + (thePoint1.y()-thePoint2.y())**2)
-    return round(aDist, 5)
-
 def distancePointLine(point, line):
     """
     subroutine to calculate distance between point and line
@@ -50,12 +42,12 @@ def checkArcLineTangency(theArc, theLine):
     subroutine to check that the line is tangent to arc/circle
     """
     if (theArc.getKind() == "SketchCircle"):
-        aCenter = geomDataAPI_Point2D(theArc.attribute("CircleCenter"))
-        aRadius = theArc.real("CircleRadius").value()
+        aCenter = geomDataAPI_Point2D(theArc.attribute("circle_center"))
+        aRadius = theArc.real("circle_radius").value()
     else:
-        aCenter = geomDataAPI_Point2D(theArc.attribute("ArcCenter"))
-        aStartPnt = geomDataAPI_Point2D(theArc.attribute("ArcStartPoint"))
-        aRadius = distancePointPoint(aStartPnt, aCenter)
+        aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
+        aStartPnt = geomDataAPI_Point2D(theArc.attribute("start_point"))
+        aRadius = model.distancePointPoint(aStartPnt, aCenter)
     aDist = distancePointLine(aCenter, theLine)
     assert math.fabs(aDist - aRadius) < 2.e-5, "aDist = {0}, aRadius = {1}".format(aDist, aRadius)
 
@@ -68,15 +60,15 @@ def checkArcArcTangency(theArc1, theArc2):
     aRadii = []
     for anArc in anArcs:
         if (anArc.getKind() == "SketchCircle"):
-            aCenter = geomDataAPI_Point2D(anArc.attribute("CircleCenter"))
-            aRadius = anArc.real("CircleRadius").value()
+            aCenter = geomDataAPI_Point2D(anArc.attribute("circle_center"))
+            aRadius = anArc.real("circle_radius").value()
         else:
-            aCenter = geomDataAPI_Point2D(anArc.attribute("ArcCenter"))
-            aStartPnt = geomDataAPI_Point2D(anArc.attribute("ArcStartPoint"))
-            aRadius = distancePointPoint(aStartPnt, aCenter)
+            aCenter = geomDataAPI_Point2D(anArc.attribute("center_point"))
+            aStartPnt = geomDataAPI_Point2D(anArc.attribute("start_point"))
+            aRadius = model.distancePointPoint(aStartPnt, aCenter)
         aCenters.append(aCenter)
         aRadii.append(aRadius)
-    aDist = distancePointPoint(aCenters[0], aCenters[1])
+    aDist = model.distancePointPoint(aCenters[0], aCenters[1])
     aRSum = aRadii[0] + aRadii[1]
     aRDiff = math.fabs(aRadii[0] - aRadii[1])
     assert math.fabs(aDist - aRSum) < 2.e-5 or math.fabs(aDist - aRDiff) < 2.e-5, "aDist = {0}, aRSum = {1}, aRDiff = {2}".format(aDist, aRSum, aRDiff)
@@ -105,11 +97,11 @@ aSession.finishOperation()
 # Arc
 aSession.startOperation()
 aSketchArc1 = aSketchFeature.addFeature("SketchArc")
-anArcCentr = geomDataAPI_Point2D(aSketchArc1.attribute("ArcCenter"))
+anArcCentr = geomDataAPI_Point2D(aSketchArc1.attribute("center_point"))
 anArcCentr.setValue(10., 10.)
-anArcStartPoint = geomDataAPI_Point2D(aSketchArc1.attribute("ArcStartPoint"))
+anArcStartPoint = geomDataAPI_Point2D(aSketchArc1.attribute("start_point"))
 anArcStartPoint.setValue(0., 50.)
-anArcEndPoint = geomDataAPI_Point2D(aSketchArc1.attribute("ArcEndPoint"))
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc1.attribute("end_point"))
 anArcEndPoint.setValue(50., 0.)
 aSession.finishOperation()
 # Line 1
@@ -192,26 +184,28 @@ assert (model.dof(aSketchFeature) == 7)
 # Arc 1
 aSession.startOperation()
 aSketchArc1 = aSketchFeature.addFeature("SketchArc")
-anArc1Centr = geomDataAPI_Point2D(aSketchArc1.attribute("ArcCenter"))
+anArc1Centr = geomDataAPI_Point2D(aSketchArc1.attribute("center_point"))
 anArc1Centr.setValue(10., 10.)
-anArc1StartPoint = geomDataAPI_Point2D(aSketchArc1.attribute("ArcStartPoint"))
+anArc1StartPoint = geomDataAPI_Point2D(aSketchArc1.attribute("start_point"))
 anArc1StartPoint.setValue(50., 0.)
-anArc1EndPoint = geomDataAPI_Point2D(aSketchArc1.attribute("ArcEndPoint"))
+anArc1EndPoint = geomDataAPI_Point2D(aSketchArc1.attribute("end_point"))
 anArc1EndPoint.setValue(0., 50.)
 aSession.finishOperation()
 # Arc 2
 aSession.startOperation()
-aSketchArc2 = aSketchFeature.addFeature("SketchArc")
-aSketchArc2.string("ArcType").setValue("ThreePoints")
-anArc2Centr = geomDataAPI_Point2D(aSketchArc2.attribute("ArcCenter"))
-anArc2StartPoint = geomDataAPI_Point2D(aSketchArc2.attribute("ArcStartPoint"))
+aSketchArc2 = aSketchFeature.addFeature("SketchMacroArc")
+aSketchArc2.string("arc_type").setValue("by_three_points")
+anArc2StartPoint = geomDataAPI_Point2D(aSketchArc2.attribute("start_point_2"))
 anArc2StartPoint.setValue(0., 50.)
-anArc2EndPoint = geomDataAPI_Point2D(aSketchArc2.attribute("ArcEndPoint"))
+anArc2EndPoint = geomDataAPI_Point2D(aSketchArc2.attribute("end_point_2"))
 anArc2EndPoint.setValue(-50., 0.)
-anArc2PassedPoint = geomDataAPI_Point2D(aSketchArc2.attribute("ArcPassedPoint"))
+anArc2PassedPoint = geomDataAPI_Point2D(aSketchArc2.attribute("passed_point"))
 anArc2PassedPoint.setValue(-40., 40.)
 aSession.finishOperation()
 assert (model.dof(aSketchFeature) == 17)
+aSketchArc2 = model.lastSubFeature(aSketchFeature, "SketchArc")
+anArc2Centr = geomDataAPI_Point2D(aSketchArc2.attribute("center_point"))
+anArc2StartPoint = geomDataAPI_Point2D(aSketchArc2.attribute("start_point"))
 #=========================================================================
 # Link points of arcs by the coincidence constraint
 #=========================================================================
@@ -269,11 +263,11 @@ assert (model.dof(aSketchFeature) == 14)
 # 3.2  tangency between non-connected arcs
 aSession.startOperation()
 aSketchArc3 = aSketchFeature.addFeature("SketchArc")
-anArc3Centr = geomDataAPI_Point2D(aSketchArc3.attribute("ArcCenter"))
+anArc3Centr = geomDataAPI_Point2D(aSketchArc3.attribute("center_point"))
 anArc3Centr.setValue(100., -10.)
-anArc3StartPoint = geomDataAPI_Point2D(aSketchArc3.attribute("ArcStartPoint"))
+anArc3StartPoint = geomDataAPI_Point2D(aSketchArc3.attribute("start_point"))
 anArc3StartPoint.setValue(70., -10.)
-anArc3EndPoint = geomDataAPI_Point2D(aSketchArc3.attribute("ArcEndPoint"))
+anArc3EndPoint = geomDataAPI_Point2D(aSketchArc3.attribute("end_point"))
 anArc3EndPoint.setValue(100., 20.)
 aSession.finishOperation()
 assert (model.dof(aSketchFeature) == 19)
@@ -295,8 +289,8 @@ assert (model.dof(aSketchFeature) == 14)
 # 3.3  tangency between arc and circle
 aSession.startOperation()
 aCircle1 = aSketchFeature.addFeature("SketchCircle")
-aCircleCenter = geomDataAPI_Point2D(aCircle1.attribute("CircleCenter"))
-aCircleRadius = aCircle1.real("CircleRadius")
+aCircleCenter = geomDataAPI_Point2D(aCircle1.attribute("circle_center"))
+aCircleRadius = aCircle1.real("circle_radius")
 aCircleCenter.setValue(150., 100.)
 aCircleRadius.setValue(50.)
 aSession.finishOperation()
@@ -313,8 +307,8 @@ assert (model.dof(aSketchFeature) == 16)
 # 3.4  tangency between two circles
 aSession.startOperation()
 aCircle2 = aSketchFeature.addFeature("SketchCircle")
-aCircleCenter = geomDataAPI_Point2D(aCircle2.attribute("CircleCenter"))
-aCircleRadius = aCircle2.real("CircleRadius")
+aCircleCenter = geomDataAPI_Point2D(aCircle2.attribute("circle_center"))
+aCircleRadius = aCircle2.real("circle_radius")
 aCircleCenter.setValue(120., 70.)
 aCircleRadius.setValue(20.)
 aSession.finishOperation()
@@ -332,13 +326,14 @@ assert (model.dof(aSketchFeature) == 18)
 # TEST 4. Creating of tangency arc by the option of the SketchArc feature
 #=========================================================================
 aSession.startOperation()
-aSketchArc3 = aSketchFeature.addFeature("SketchArc")
-aSketchArc3.string("ArcType").setValue("Tangent")
-anArc3Start = aSketchArc3.refattr("ArcTangentPoint")
+aSketchArc3 = aSketchFeature.addFeature("SketchMacroArc")
+aSketchArc3.string("arc_type").setValue("by_tangent_edge")
+anArc3Start = aSketchArc3.refattr("tangent_point")
 anArc3Start.setAttr(anArc1StartPoint)
-anArc3EndPoint = geomDataAPI_Point2D(aSketchArc3.attribute("ArcEndPoint"))
+anArc3EndPoint = geomDataAPI_Point2D(aSketchArc3.attribute("end_point_3"))
 anArc3EndPoint.setValue(anArc1StartPoint.x()-5, anArc1StartPoint.y()-30)
 aSession.finishOperation()
+aSketchArc3 = model.lastSubFeature(aSketchFeature, "SketchArc")
 checkArcArcTangency(aSketchArc1, aSketchArc3)
 # freeze radius of tangent arc
 aSession.startOperation()
@@ -364,8 +359,8 @@ aLineEnd = geomDataAPI_Point2D(aLine.attribute("EndPoint"))
 aLineStart.setValue(100., 100.)
 aLineEnd.setValue(200., 200.)
 aCircle = aSketchFeature.addFeature("SketchCircle")
-aCircleCenter = geomDataAPI_Point2D(aCircle.attribute("CircleCenter"))
-aCircleRadius = aCircle.real("CircleRadius")
+aCircleCenter = geomDataAPI_Point2D(aCircle.attribute("circle_center"))
+aCircleRadius = aCircle.real("circle_radius")
 aCircleCenter.setValue(150., 100.)
 aCircleRadius.setValue(20.)
 aSession.finishOperation()
diff --git a/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py b/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py
new file mode 100644 (file)
index 0000000..2fb4d47
--- /dev/null
@@ -0,0 +1,129 @@
+"""
+    TestCreateArc.py
+
+    static const std::string MY_SKETCH_ARC_ID("SketchArc");
+    static const std::string MY_CENTER_ID = "center_point";
+    static const std::string MY_START_ID = "start_point";
+    static const std::string MY_END_ID = "end_point";
+    data()->addAttribute(SketchPlugin_Arc::CENTER_ID(), GeomDataAPI_Point2D::typeId());
+    data()->addAttribute(SketchPlugin_Arc::START_ID(),  GeomDataAPI_Point2D::typeId());
+    data()->addAttribute(SketchPlugin_Arc::END_ID(),    GeomDataAPI_Point2D::typeId());
+"""
+
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+from GeomDataAPI import *
+from ModelAPI import *
+import math
+from salome.shaper import model
+
+__updated__ = "2017-03-28"
+
+TOLERANCE = 1.e-7
+
+#=========================================================================
+# Auxiliary functions
+#=========================================================================
+
+def verifyLastArc(theSketch, theCenter, theStart, theEnd):
+    """
+    subroutine to verify position of last arc in the sketch
+    """
+    aLastArc = model.lastSubFeature(theSketch, "SketchArc")
+    aCenterPnt = geomDataAPI_Point2D(aLastArc.attribute("center_point"))
+    aStartPnt = geomDataAPI_Point2D(aLastArc.attribute("start_point"))
+    aEndPnt = geomDataAPI_Point2D(aLastArc.attribute("end_point"))
+    if len(theCenter):
+        verifyPointCoordinates(aCenterPnt, theCenter[0], theCenter[1])
+    if len(theStart):
+        verifyPointCoordinates(aStartPnt, theStart[0], theStart[1])
+    if len(theEnd):
+        verifyPointCoordinates(aEndPnt, theEnd[0], theEnd[1])
+    aRadius = aLastArc.real("radius")
+    aDistCS = model.distancePointPoint(aCenterPnt, aStartPnt)
+    aDistCE = model.distancePointPoint(aCenterPnt, aEndPnt)
+    assert math.fabs(aDistCS - aDistCE) < TOLERANCE, "Wrong arc: center-start distance {}, center-end distance {}".format(aDistCS, aDistCE)
+    assert math.fabs(aRadius.value() -aDistCS) < TOLERANCE, "Wrong radius {0}, expected {1}".format(aRadius.value(), aDistCS)
+
+def verifyPointCoordinates(thePoint, theX, theY):
+    assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.id(), thePoint.x(), thePoint.y(), theX, theY)
+
+
+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()
+
+#=========================================================================
+# Test 1. Create an arc by center, start and end points
+#=========================================================================
+aCenter = [10., 10.]
+aStart  = [0., 50.]
+aEnd    = [50., 0.]
+aSession.startOperation()
+aSketchArc = aSketchFeature.addFeature("SketchArc")
+assert (aSketchArc.getKind() == "SketchArc")
+anArcCenter = geomDataAPI_Point2D(aSketchArc.attribute("center_point"))
+assert (not anArcCenter.isInitialized())
+anArcCenter.setValue(aCenter[0], aCenter[1])
+anArcStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("start_point"))
+assert (not anArcStartPoint.isInitialized())
+anArcStartPoint.setValue(aStart[0], aStart[1])
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc.attribute("end_point"))
+assert (not anArcEndPoint.isInitialized())
+anArcEndPoint.setValue(aEnd[0], aEnd[1])
+aSession.finishOperation()
+verifyLastArc(aSketchFeature, aCenter, aStart, aEnd)
+# Move center
+aCenter = [15., 20.]
+aSession.startOperation()
+anArcCenter.setValue(aCenter[0], aCenter[1])
+aSession.finishOperation()
+verifyLastArc(aSketchFeature, aCenter, [], [])
+# Move start point
+deltaX, deltaY = 5., 2.
+aStart = [anArcStartPoint.x() + deltaX, anArcStartPoint.y() + deltaY]
+aSession.startOperation()
+anArcStartPoint.setValue(aStart[0], aStart[1])
+aSession.finishOperation()
+verifyLastArc(aSketchFeature, [], aStart, [])
+# Move end point
+aEnd = [anArcEndPoint.x() - deltaX, anArcEndPoint.y() - deltaY]
+aSession.startOperation()
+anArcEndPoint.setValue(aEnd[0], aEnd[1])
+aSession.finishOperation()
+verifyLastArc(aSketchFeature, [], [], aEnd)
+# Check that changing the radius does not affect arc
+aSession.startOperation()
+anArcRadius = aSketchArc.real("radius")
+aPrevRadius = anArcRadius.value();
+anArcRadius.setValue(aPrevRadius + 10.)
+aSession.finishOperation()
+assert (math.fabs(anArcRadius.value - aPrevRadius) < TOLERANCE)
+verifyLastArc(aSketchFeature, [], [], [])
+# Check that changing the angle does not affect arc
+aSession.startOperation()
+anArcAngle = aSketchArc.real("angle")
+aPrevAngle = anArcAngle.value()
+anArcAngle.setValue(aPrevAngle + 10.)
+aSession.finishOperation()
+assert (math.fabs(anArcAngle.value - aPrevAngle) < TOLERANCE)
+verifyLastArc(aSketchFeature, [], [], [])
+
+#=========================================================================
+# End of test
+#=========================================================================
+
+assert(model.checkPythonDump())
index 272399734498cbdd49028efbd215d291af79bed4..bb691dfcbd0fc4cf07ea0c533a5f4df7ca4bf27b 100644 (file)
@@ -22,28 +22,18 @@ __updated__ = "2017-03-22"
 #=========================================================================
 TOLERANCE = 1.e-7
 
-def getLastCircle(theSketch):
-    """
-    obtains last feature from the sketch and generates error if the feature is not a circle
-    """
-    expectedKind = "SketchCircle"
-    for anIndex in range(theSketch.numberOfSubs() - 1, -1, -1):
-        aSub = theSketch.subFeature(anIndex)
-        if (aSub.getKind() == expectedKind):
-            return aSub
-
 def verifyLastCircle(theSketch, theX, theY, theR):
     """
     subroutine to verify position of last circle in the sketch
     """
-    aLastCircle = getLastCircle(theSketch)
+    aLastCircle = model.lastSubFeature(theSketch, "SketchCircle")
     aCenter = geomDataAPI_Point2D(aLastCircle.attribute("circle_center"))
     verifyPointCoordinates(aCenter, theX, theY)
     aRadius = aLastCircle.real("circle_radius")
     assert aRadius.value() == theR, "Wrong radius {0}, expected {1}".format(aRadius.value(), theR)
 
 def verifyPointCoordinates(thePoint, theX, theY):
-    assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.attributeType(), thePoint.x(), thePoint.y(), theX, theY)
+    assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.id(), thePoint.x(), thePoint.y(), theX, theY)
 
 def verifyPointOnLine(thePoint, theLine):
     aDistance = distancePointLine(thePoint, theLine)
@@ -52,16 +42,13 @@ def verifyPointOnLine(thePoint, theLine):
 def verifyTangentCircles(theCircle1, theCircle2):
     aCenter1 = geomDataAPI_Point2D(theCircle1.attribute("circle_center"))
     aCenter2 = geomDataAPI_Point2D(theCircle2.attribute("circle_center"))
-    aDistCC = distancePointPoint(aCenter1, aCenter2)
+    aDistCC = model.distancePointPoint(aCenter1, aCenter2)
     aRadius1 = theCircle1.real("circle_radius").value()
     aRadius2 = theCircle2.real("circle_radius").value()
     aRSum = aRadius1 + aRadius2
     aRDiff = math.fabs(aRadius1 - aRadius2)
     assert math.fabs(aRSum - aDistCC) < TOLERANCE or math.fabs(aRDiff - aDistCC) < TOLERANCE, "Circles do not tangent"
 
-def distancePointPoint(thePoint1, thePoint2):
-    return thePoint1.pnt().distance(thePoint2.pnt())
-
 def distancePointLine(thePoint, theLine):
     aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint")).pnt().xy()
     aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint")).pnt().xy()
@@ -137,7 +124,7 @@ assert (not aCircleType.isInitialized())
 aCircleType.setValue("circle_type_by_center_and_passed_points")
 aCircleCenter.setValue(-25., -25)
 aCirclePassed.setValue(0., -25.)
-aRadius = distancePointPoint(aCircleCenter, aCirclePassed)
+aRadius = model.distancePointPoint(aCircleCenter, aCirclePassed)
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 2)
 verifyLastCircle(aSketchFeature, -25., -25., aRadius)
@@ -146,7 +133,7 @@ verifyLastCircle(aSketchFeature, -25., -25., aRadius)
 # Test 3. Create a circle as a macro-feature by center and passed point coincident to other points
 #=========================================================================
 # get previous circle
-aPrevCircle = getLastCircle(aSketchFeature)
+aPrevCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")
 aPrevCenter = geomDataAPI_Point2D(aPrevCircle.attribute("circle_center"))
 # create additional point
 aPointCoodinates = [0., 0.]
@@ -172,7 +159,7 @@ aCenterRef.setObject(aPoint.lastResult())
 aCenter.setValue(aPointCoord.pnt())
 aPassedRef.setAttr(aPrevCenter)
 aPassed.setValue(aPrevCenter.pnt())
-aRadius = distancePointPoint(aPrevCenter, aPointCoord)
+aRadius = model.distancePointPoint(aPrevCenter, aPointCoord)
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 6)
 verifyPointCoordinates(aPointCoord, aPointCoodinates[0], aPointCoodinates[1])
@@ -183,7 +170,7 @@ model.testNbSubFeatures(aSketch, "SketchConstraintCoincidence", 2)
 # Test 4. Create a circle as a macro-feature by center on a line and passed point on another circle
 #=========================================================================
 # get previous circle
-aPrevCircle = getLastCircle(aSketchFeature)
+aPrevCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")
 aPrevCenter = geomDataAPI_Point2D(aPrevCircle.attribute("circle_center"))
 aPrevCenterXY = [aPrevCenter.x(), aPrevCenter.y()]
 aPrevRadius = aPrevCircle.real("circle_radius").value()
@@ -212,7 +199,7 @@ anExpectedCenter = [(aLineStart[0] + aLineEnd[0]) * 0.5, (aLineStart[1] + aLineE
 aCenter.setValue(anExpectedCenter[0], anExpectedCenter[1])
 aPassedRef.setObject(aPrevCircle.lastResult())
 aPassed.setValue(aPrevCenter.x() + aPrevRadius, aPrevCenter.y())
-aRadius = distancePointPoint(aCenter, aPassed)
+aRadius = model.distancePointPoint(aCenter, aPassed)
 aSession.finishOperation()
 assert (aSketchFeature.numberOfSubs() == 10)
 # check connected features do not change their positions
@@ -221,7 +208,7 @@ assert(aPrevCircle.real("circle_radius").value() == aPrevRadius)
 verifyPointCoordinates(aStartPnt, aLineStart[0], aLineStart[1])
 verifyPointCoordinates(aEndPnt, aLineEnd[0], aLineEnd[1])
 # verify newly created circle
-aCircle = getLastCircle(aSketchFeature)
+aCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")
 aCenter = geomDataAPI_Point2D(aCircle.attribute("circle_center"))
 verifyPointCoordinates(aCenter, anExpectedCenter[0], anExpectedCenter[1])
 verifyPointOnLine(aCenter, aLine)
index 060127a349bc5bee8766e27a70013de1d3425388..ce9a24d4a3da5a80fa6beda46f51d14d4d81d732 100644 (file)
@@ -22,21 +22,11 @@ __updated__ = "2017-03-22"
 #=========================================================================
 TOLERANCE = 1.e-7
 
-def getLastCircle(theSketch):
-    """
-    obtains last feature from the sketch and generates error if the feature is not a circle
-    """
-    expectedKind = "SketchCircle"
-    for anIndex in range(theSketch.numberOfSubs() - 1, -1, -1):
-        aSub = theSketch.subFeature(anIndex)
-        if (aSub.getKind() == expectedKind):
-            return aSub
-
 def verifyLastCircle(theSketch, theX, theY, theR):
     """
     subroutine to verify position of last circle in the sketch
     """
-    aLastCircle = getLastCircle(theSketch)
+    aLastCircle = model.lastSubFeature(theSketch, "SketchCircle")
     aCenter = geomDataAPI_Point2D(aLastCircle.attribute("circle_center"))
     verifyPointCoordinates(aCenter, theX, theY)
     aRadius = aLastCircle.real("circle_radius")
@@ -47,14 +37,14 @@ def verifyPointCoordinates(thePoint, theX, theY):
 
 def verifyPointOnCircle(thePoint, theCircle):
     aCircleCenter = geomDataAPI_Point2D(theCircle.attribute("circle_center"))
-    aDistCP = distancePointPoint(aCircleCenter, thePoint)
+    aDistCP = model.distancePointPoint(aCircleCenter, thePoint)
     aCircleRadius = theCircle.real("circle_radius").value()
     assert math.fabs(aDistCP - aCircleRadius) < TOLERANCE, "Point is not on circle, distance: {0}, radius of circle: {1}".format(aDistCP, aCircleRadius)
 
 def verifyTangentCircles(theCircle1, theCircle2):
     aCenter1 = geomDataAPI_Point2D(theCircle1.attribute("circle_center"))
     aCenter2 = geomDataAPI_Point2D(theCircle2.attribute("circle_center"))
-    aDistCC = distancePointPoint(aCenter1, aCenter2)
+    aDistCC = model.distancePointPoint(aCenter1, aCenter2)
     aRadius1 = theCircle1.real("circle_radius").value()
     aRadius2 = theCircle2.real("circle_radius").value()
     verifyTangentCircular(aDistCC, aRadius1, aRadius2)
@@ -63,9 +53,9 @@ def verifyTangentCircleArc(theCircle, theArc):
     aCircleCenter = geomDataAPI_Point2D(theCircle.attribute("circle_center"))
     anArcCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
     anArcStart = geomDataAPI_Point2D(theArc.attribute("start_point"))
-    aDistCC = distancePointPoint(aCircleCenter, anArcCenter)
+    aDistCC = model.distancePointPoint(aCircleCenter, anArcCenter)
     aCircleRadius = theCircle.real("circle_radius").value()
-    anArcRadius = distancePointPoint(anArcCenter, anArcStart)
+    anArcRadius = model.distancePointPoint(anArcCenter, anArcStart)
     verifyTangentCircular(aDistCC, aCircleRadius, anArcRadius)
 
 def verifyTangentCircular(theDistBetweenCenters, theRadius1, theRadius2):
@@ -79,9 +69,6 @@ def verifyTangentCircleLine(theCircle, theLine):
     aDistCL = distancePointLine(aCenter, theLine)
     assert math.fabs(aDistCL - aRadius) < TOLERANCE, "Circle and line are not tangent"
 
-def distancePointPoint(thePoint1, thePoint2):
-    return thePoint1.pnt().distance(thePoint2.pnt())
-
 def distancePointLine(thePoint, theLine):
     aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint")).pnt().xy()
     aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint")).pnt().xy()
@@ -140,7 +127,7 @@ verifyLastCircle(aSketchFeature, expectedCenter[0], expectedCenter[1], expectedR
 # Test 2. Create a circle by three points coincident to other points
 #=========================================================================
 # get previous circle
-aPrevCircle = getLastCircle(aSketchFeature)
+aPrevCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")
 aPrevCenter = geomDataAPI_Point2D(aPrevCircle.attribute("circle_center"))
 aPrevCenterXY = [aPrevCenter.x(), aPrevCenter.y()]
 aPrevCircleRadius = aPrevCircle.real("circle_radius").value()
@@ -183,7 +170,7 @@ verifyPointCoordinates(aPrevCenter, aPrevCenterXY[0], aPrevCenterXY[1])
 verifyPointCoordinates(aPointCoord, aPointCoodinates[0], aPointCoodinates[1])
 verifyPointCoordinates(aStartPnt, aLineStart[0], aLineStart[1])
 # check newly created circle passes through the points
-aCircle = getLastCircle(aSketchFeature)
+aCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")
 verifyPointOnCircle(aPrevCenter, aCircle)
 verifyPointOnCircle(aPointCoord, aCircle)
 verifyPointOnCircle(aStartPnt, aCircle)
@@ -236,7 +223,7 @@ verifyPointCoordinates(anArcCenterPnt, anArcCenter[0], anArcCenter[1])
 verifyPointCoordinates(anArcStartPnt, anArcStart[0], anArcStart[1])
 verifyPointCoordinates(anArcEndPnt, anArcEnd[0], anArcEnd[1])
 # check newly created circle passes through the points
-aCircle = getLastCircle(aSketchFeature)
+aCircle = model.lastSubFeature(aSketchFeature, "SketchCircle")
 verifyTangentCircles(aCircle, aPrevCircle)
 verifyTangentCircleArc(aCircle, anArc)
 verifyTangentCircleLine(aCircle, aLine)
index 52daff262dbdae4ee654dd088d7db8b6156885c3..4a78584aa365d924d9175727f43f545253614445 100644 (file)
@@ -49,21 +49,11 @@ def assertNotInitializedByThreePoints(theMacroCircle):
     assert (not aSecondPointRef.isInitialized())
     assert (not aThirdPointRef.isInitialized())
 
-def getLastCircle(theSketch):
-    """
-    obtains last feature from the sketch and generates error if the feature is not a circle
-    """
-    expectedKind = "SketchCircle"
-    for anIndex in range(theSketch.numberOfSubs() - 1, -1, -1):
-        aSub = theSketch.subFeature(anIndex)
-        if (aSub.getKind() == expectedKind):
-            return aSub
-
 def verifyLastCircle(theSketch, theX, theY, theR):
     """
     subroutine to verify position of last circle in the sketch
     """
-    aLastCircle = getLastCircle(theSketch)
+    aLastCircle = model.lastSubFeature(theSketch, "SketchCircle")
     aCenter = geomDataAPI_Point2D(aLastCircle.attribute("circle_center"))
     verifyPointCoordinates(aCenter, theX, theY)
     aRadius = aLastCircle.real("circle_radius")
@@ -72,9 +62,6 @@ def verifyLastCircle(theSketch, theX, theY, theR):
 def verifyPointCoordinates(thePoint, theX, theY):
     assert thePoint.x() == theX and thePoint.y() == theY, "Wrong '{0}' point ({1}, {2}), expected ({3}, {4})".format(thePoint.attributeType(), thePoint.x(), thePoint.y(), theX, theY)
 
-def distancePointPoint(thePoint1, thePoint2):
-    return thePoint1.pnt().distance(thePoint2.pnt())
-
 
 #=========================================================================
 # Start of test
@@ -182,7 +169,7 @@ aPassedPointRef.setAttr(aLineEnd)
 aPassedPoint.setValue(aLineEnd.pnt())
 aSession.finishOperation()
 
-aRadius = distancePointPoint(aLineStart, aLineEnd)
+aRadius = model.distancePointPoint(aLineStart, aLineEnd)
 NB_FEATURES_EXPECTED = 4 # line, circle and two coincidences
 assert (aSketchFeature.numberOfSubs() == NB_FEATURES_EXPECTED), "Number of features in sketch {}, expected {}".format(aSketchFeature.numberOfSubs(), NB_FEATURES_EXPECTED)
 verifyLastCircle(aSketchFeature, aLineStart.x(), aLineStart.y(), aRadius)
index 59f353cb8f1e6c792f0216a3aa6ce315a2980190..a52ce5a5cc37af35de8cbc48f4a854411d880105 100644 (file)
@@ -75,9 +75,9 @@ def createSketch2(theSketch):
     allFeatures.append(aSketchLine)
     # Arc
     aSketchArc = theSketch.addFeature("SketchArc")
-    aStartPoint2 = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint"))
-    aEndPoint2   = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
-    aCenterPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
+    aStartPoint2 = geomDataAPI_Point2D(aSketchArc.attribute("start_point"))
+    aEndPoint2   = geomDataAPI_Point2D(aSketchArc.attribute("end_point"))
+    aCenterPoint = geomDataAPI_Point2D(aSketchArc.attribute("center_point"))
     aCenterPoint.setValue(20., 10.)
     aStartPoint2.setValue(10., 10.)
     aEndPoint2.setValue(20., 0.)
@@ -104,15 +104,15 @@ def checkSmoothness(theSketch):
             checkArcLineSmoothness(aConnectedFeatures[1], aConnectedFeatures[0])
 
 def checkArcLineSmoothness(theArc, theLine):
-    aCenter = geomDataAPI_Point2D(theArc.attribute("ArcCenter"))
+    aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
     aDistance = distancePointLine(aCenter, theLine)
     aRadius = arcRadius(theArc)
     assert(math.fabs(aRadius - aDistance) < TOLERANCE)
 
 def checkArcArcSmoothness(theArc1, theArc2):
-    aCenter1 = geomDataAPI_Point2D(theArc1.attribute("ArcCenter"))
-    aCenter2 = geomDataAPI_Point2D(theArc2.attribute("ArcCenter"))
-    aDistance = distancePointPoint(aCenter1, aCenter2)
+    aCenter1 = geomDataAPI_Point2D(theArc1.attribute("center_point"))
+    aCenter2 = geomDataAPI_Point2D(theArc2.attribute("center_point"))
+    aDistance = model.distancePointPoint(aCenter1, aCenter2)
     aRadius1 = arcRadius(theArc1)
     aRadius2 = arcRadius(theArc2)
     aRadSum = aRadius1 + aRadius2
@@ -138,17 +138,14 @@ def connectedFeatures(theCoincidence):
     return [aFeatureA, aFeatureB]
 
 def arcRadius(theArc):
-    aCenter = geomDataAPI_Point2D(theArc.attribute("ArcCenter"))
-    aStart = geomDataAPI_Point2D(theArc.attribute("ArcStartPoint"))
-    return distancePointPoint(aCenter, aStart)
-
-def distancePointPoint(thePoint1, thePoint2):
-    return math.hypot(thePoint1.x() - thePoint2.x(), thePoint1.y() - thePoint2.y())
+    aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
+    aStart = geomDataAPI_Point2D(theArc.attribute("start_point"))
+    return model.distancePointPoint(aCenter, aStart)
 
 def distancePointLine(thePoint, theLine):
     aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint"))
     aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint"))
-    aLength = distancePointPoint(aLineStart, aLineEnd)
+    aLength = model.distancePointPoint(aLineStart, aLineEnd)
 
     aDir1x, aDir1y = aLineEnd.x() - aLineStart.x(), aLineEnd.y() - aLineStart.y()
     aDir2x, aDir2y = thePoint.x() - aLineStart.x(), thePoint.y() - aLineStart.y()
index 15b101e444e24833e6a0a23ef2e2c0e2b66c006b..9653c3cf006837da06f346f863ca51e4382e6800 100644 (file)
@@ -14,15 +14,15 @@ from salome.shaper import model
 __updated__ = "2017-03-06"
 
 def isArcLineSmooth(theArc, theLine, theTolerance):
-  aCenter = geomDataAPI_Point2D(theArc.attribute("ArcCenter"))
+  aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
   aDistance = distancePointLine(aCenter, theLine)
   aRadius = arcRadius(theArc)
   return math.fabs(aRadius - aDistance) < theTolerance
 
 def isArcArcSmooth(theArc1, theArc2, theTolerance):
-  aCenter1 = geomDataAPI_Point2D(theArc1.attribute("ArcCenter"))
-  aCenter2 = geomDataAPI_Point2D(theArc2.attribute("ArcCenter"))
-  aDistance = distancePointPoint(aCenter1, aCenter2)
+  aCenter1 = geomDataAPI_Point2D(theArc1.attribute("center_point"))
+  aCenter2 = geomDataAPI_Point2D(theArc2.attribute("center_point"))
+  aDistance = model.distancePointPoint(aCenter1, aCenter2)
   aRadius1 = arcRadius(theArc1)
   aRadius2 = arcRadius(theArc2)
   aRadSum = aRadius1 + aRadius2
@@ -30,17 +30,14 @@ def isArcArcSmooth(theArc1, theArc2, theTolerance):
   return math.fabs(aDistance - aRadSum) < theTolerance or math.fabs(aDistance - aRadDiff) < theTolerance
 
 def arcRadius(theArc):
-  aCenter = geomDataAPI_Point2D(theArc.attribute("ArcCenter"))
-  aStart = geomDataAPI_Point2D(theArc.attribute("ArcStartPoint"))
-  return distancePointPoint(aCenter, aStart)
-
-def distancePointPoint(thePoint1, thePoint2):
-  return math.hypot(thePoint1.x() - thePoint2.x(), thePoint1.y() - thePoint2.y())
+  aCenter = geomDataAPI_Point2D(theArc.attribute("center_point"))
+  aStart = geomDataAPI_Point2D(theArc.attribute("start_point"))
+  return model.distancePointPoint(aCenter, aStart)
 
 def distancePointLine(thePoint, theLine):
   aLineStart = geomDataAPI_Point2D(theLine.attribute("StartPoint"))
   aLineEnd = geomDataAPI_Point2D(theLine.attribute("EndPoint"))
-  aLength = distancePointPoint(aLineStart, aLineEnd)
+  aLength = model.distancePointPoint(aLineStart, aLineEnd)
   aDir1x, aDir1y = aLineEnd.x() - aLineStart.x(), aLineEnd.y() - aLineStart.y()
   aDir2x, aDir2y = thePoint.x() - aLineStart.x(), thePoint.y() - aLineStart.y()
   aCross = aDir1x * aDir2y - aDir1y * aDir2x
diff --git a/src/SketchPlugin/Test/TestMirror.py b/src/SketchPlugin/Test/TestMirror.py
new file mode 100644 (file)
index 0000000..306d02d
--- /dev/null
@@ -0,0 +1,215 @@
+"""
+    TestConstraintMirror.py
+    Unit test of SketchPlugin_ConstraintMirror class
+
+    SketchPlugin_ConstraintMirror
+        static const std::string MY_CONSTRAINT_MIRROR_ID("SketchConstraintMirror");
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefListAttr::typeId());
+        data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefListAttr::typeId());
+
+"""
+from GeomDataAPI import *
+from ModelAPI import *
+import math
+from salome.shaper import model
+
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+
+__updated__ = "2015-03-17"
+
+#=========================================================================
+# Auxiliary functions
+#=========================================================================
+def normalize(theDir):
+    aLen = math.hypot(theDir[0], theDir[1])
+    if aLen < 1.e-10:
+        aLen = 1.0
+    return [theDir[0] / aLen, theDir[1] / aLen]
+
+def checkMirror(theListInit, theListMirr, theMirrorLine):
+    TOL = 6.e-5
+    aListSize = theListInit.size()
+
+    aLineStartPoint = geomDataAPI_Point2D(theMirrorLine.attribute("StartPoint"))
+    aLineEndPoint = geomDataAPI_Point2D(theMirrorLine.attribute("EndPoint"))
+    aLineDir = [aLineEndPoint.x() - aLineStartPoint.x(), aLineEndPoint.y() - aLineStartPoint.y()]
+    aLineDir = normalize(aLineDir)
+
+    for ind in range(0, aListSize):
+        aFeatureB = ModelAPI_Feature.feature(theListInit.object(ind))
+        aFeatureC = ModelAPI_Feature.feature(theListMirr.object(ind))
+        assert(aFeatureB is not None)
+        assert(aFeatureC is not None)
+        assert(aFeatureB.getKind() == aFeatureC.getKind())
+
+        anAttributes = []
+        if (aFeatureB.getKind() == "SketchLine"):
+            anAttributes = ['StartPoint', 'EndPoint']
+        elif (aFeatureB.getKind() == "SketchArc"):
+            anAttributes = ['center_point', 'start_point', 'end_point']
+
+        for key in anAttributes:
+            aPointB = geomDataAPI_Point2D(aFeatureB.attribute(key))
+            aPointC = geomDataAPI_Point2D(aFeatureC.attribute(key))
+            aDir = [aPointC.x() - aPointB.x(), aPointC.y() - aPointB.y()]
+            aDir = normalize(aDir)
+            aDot = aLineDir[0] * aDir[0] + aLineDir[1] * aDir[1]
+            assert math.fabs(aDot) < TOL, "aDot = {0}".format(aDot)
+            aDir[0] = aLineEndPoint.x() - 0.5 * (aPointB.x() + aPointC.x())
+            aDir[1] = aLineEndPoint.y() - 0.5 * (aPointB.y() + aPointC.y())
+            aCross = aLineDir[0] * aDir[1] - aLineDir[1] * aDir[0]
+            assert math.fabs(aCross) < TOL, "aCross = {0}".format(aCross)
+
+
+#=========================================================================
+# Start of test
+#=========================================================================
+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()
+#=========================================================================
+# Creation of an arc and two lines
+#=========================================================================
+# Arc
+aSession.startOperation()
+aSketchArc1 = aSketchFeature.addFeature("SketchArc")
+anArcCentr = geomDataAPI_Point2D(aSketchArc1.attribute("center_point"))
+anArcCentr.setValue(10., 10.)
+anArcStartPoint = geomDataAPI_Point2D(aSketchArc1.attribute("start_point"))
+anArcStartPoint.setValue(0., 50.)
+anArcEndPoint = geomDataAPI_Point2D(aSketchArc1.attribute("end_point"))
+anArcEndPoint.setValue(50., 0.)
+aSession.finishOperation()
+# Line 1
+aSession.startOperation()
+aSketchLine1 = aSketchFeature.addFeature("SketchLine")
+aLine1StartPoint = geomDataAPI_Point2D(aSketchLine1.attribute("StartPoint"))
+aLine1EndPoint = geomDataAPI_Point2D(aSketchLine1.attribute("EndPoint"))
+aLine1StartPoint.setValue(0., 50.)
+aLine1EndPoint.setValue(0., 100.)
+aSession.finishOperation()
+# Line 2
+aSession.startOperation()
+aSketchLine2 = aSketchFeature.addFeature("SketchLine")
+aLine2StartPoint = geomDataAPI_Point2D(aSketchLine2.attribute("StartPoint"))
+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
+#=========================================================================
+aSession.startOperation()
+aConstraint = aSketchFeature.addFeature("SketchConstraintCoincidence")
+reflistA = aConstraint.refattr("ConstraintEntityA")
+reflistB = aConstraint.refattr("ConstraintEntityB")
+reflistA.setAttr(anArcStartPoint)
+reflistB.setAttr(aLine1StartPoint)
+aConstraint.execute()
+aSession.finishOperation()
+aSession.startOperation()
+aConstraint = aSketchFeature.addFeature("SketchConstraintCoincidence")
+reflistA = aConstraint.refattr("ConstraintEntityA")
+reflistB = aConstraint.refattr("ConstraintEntityB")
+reflistA.setAttr(anArcEndPoint)
+reflistB.setAttr(aLine2StartPoint)
+aConstraint.execute()
+aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 9)
+#=========================================================================
+# Add tangency constraint and check correctness
+#=========================================================================
+aSession.startOperation()
+aTangency = aSketchFeature.addFeature("SketchConstraintTangent")
+aRefObjectA = aTangency.refattr("ConstraintEntityA")
+aRefObjectB = aTangency.refattr("ConstraintEntityB")
+anObjectA = modelAPI_ResultConstruction(aSketchArc1.lastResult())
+anObjectB = modelAPI_ResultConstruction(aSketchLine1.lastResult())
+assert (anObjectA is not None)
+assert (anObjectB is not None)
+aRefObjectA.setObject(anObjectA)
+aRefObjectB.setObject(anObjectB)
+aTangency.execute()
+aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 8)
+#=========================================================================
+# Create mirror line
+#=========================================================================
+aSession.startOperation()
+aMirrorLine = aSketchFeature.addFeature("SketchLine")
+aLineStartPoint = geomDataAPI_Point2D(aMirrorLine.attribute("StartPoint"))
+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
+#=========================================================================
+aSession.startOperation()
+aMirror = aSketchFeature.addFeature("SketchConstraintMirror")
+aRefObjectA = aMirror.refattr("ConstraintEntityA")
+aRefObjectA.setObject(modelAPI_ResultConstruction(aMirrorLine.firstResult()))
+aRefListInitial = aMirror.reflist("ConstraintMirrorList")
+aRefListInitial.append(aSketchLine1.lastResult())
+aRefListInitial.append(aSketchArc1.lastResult())
+aRefListInitial.append(aSketchLine2.lastResult())
+aMirror.execute()
+aSession.finishOperation()
+assert (model.dof(aSketchFeature) == 12)
+#=========================================================================
+# Verify the simmetricity of all mirrored objects
+#=========================================================================
+aRefListB = aMirror.reflist("ConstraintEntityB")
+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
+#=========================================================================
+aSession.startOperation()
+aRefListInitial.remove(aSketchLine2.lastResult())
+aSession.finishOperation()
+assert (aRefListB.size() == 2)
+assert (aRefListC.size() == 2)
+checkMirror(aRefListB, aRefListC, aMirrorLine)
+assert (model.dof(aSketchFeature) == 12)
+
+#=========================================================================
+# Clear list of mirrored features
+#=========================================================================
+aSession.startOperation()
+aRefListInitial.clear()
+assert (aRefListB.size() == 0)
+assert (aRefListC.size() == 0)
+# add arc once again
+aRefListInitial.append(aSketchArc1.lastResult())
+aSession.finishOperation()
+assert (aRefListB.size() == 1)
+assert (aRefListC.size() == 1)
+checkMirror(aRefListB, aRefListC, aMirrorLine)
+assert (model.dof(aSketchFeature) == 12)
+#=========================================================================
+# End of test
+#=========================================================================
+
+assert(model.checkPythonDump())
index 7328e497cc6774babc28be4f4a09bc5523f781c5..6a6d192016a8800c65f0ad7b16dd20edcac401be 100644 (file)
@@ -26,9 +26,9 @@ def createSketch(theSketch):
     allFeatures = []
     # Create arc
     aSketchArc = theSketch.addFeature("SketchArc")
-    aCenter     = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
-    aStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint"))
-    aEndPoint   = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
+    aCenter     = geomDataAPI_Point2D(aSketchArc.attribute("center_point"))
+    aStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("start_point"))
+    aEndPoint   = geomDataAPI_Point2D(aSketchArc.attribute("end_point"))
     aCenter.setValue(5., 5.)
     aStartPoint.setValue(10., 5.)
     aEndPoint.setValue(5., 10.)
@@ -69,9 +69,9 @@ def checkRotation(theObjects, theNbObjects, theCenterX, theCenterY, theAngle):
             anAttributes.append('StartPoint')
             anAttributes.append('EndPoint')
         elif (feat.getKind() == "SketchArc"):
-            anAttributes.append('ArcCenter')
-            anAttributes.append('ArcStartPoint')
-            anAttributes.append('ArcEndPoint')
+            anAttributes.append('center_point')
+            anAttributes.append('start_point')
+            anAttributes.append('end_point')
             
         for attr in anAttributes:
             aPoint1 = geomDataAPI_Point2D(feat.attribute(attr))
index 80eb90ed108f2315aa34c739d78c5802e4ee3ed1..639fd4e30a2a69cce9da2856b84ff45146156a57 100644 (file)
@@ -25,9 +25,9 @@ def createSketch(theSketch):
     allFeatures = []
     # Create arc
     aSketchArc = theSketch.addFeature("SketchArc")
-    aCenter     = geomDataAPI_Point2D(aSketchArc.attribute("ArcCenter"))
-    aStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("ArcStartPoint"))
-    aEndPoint   = geomDataAPI_Point2D(aSketchArc.attribute("ArcEndPoint"))
+    aCenter     = geomDataAPI_Point2D(aSketchArc.attribute("center_point"))
+    aStartPoint = geomDataAPI_Point2D(aSketchArc.attribute("start_point"))
+    aEndPoint   = geomDataAPI_Point2D(aSketchArc.attribute("end_point"))
     aCenter.setValue(5., 5.)
     aStartPoint.setValue(10., 5.)
     aEndPoint.setValue(5., 10.)
@@ -66,9 +66,9 @@ def checkTranslation(theObjects, theNbObjects, theDeltaX, theDeltaY):
             anAttributes.append('StartPoint')
             anAttributes.append('EndPoint')
         elif (feat.getKind() == "SketchArc"):
-            anAttributes.append('ArcCenter')
-            anAttributes.append('ArcStartPoint')
-            anAttributes.append('ArcEndPoint')
+            anAttributes.append('center_point')
+            anAttributes.append('start_point')
+            anAttributes.append('end_point')
             
         for attr in anAttributes:
              aPoint1 = geomDataAPI_Point2D(feat.attribute(attr))
index 9477cdc741d0b609308b00ebd5cc70032369e669..9183aacb578ce9eae0cd405429668c04f1bf18d8 100644 (file)
@@ -43,15 +43,15 @@ aLineStart.setValue(10., 10.)
 aLineEnd.setValue(40., 30.)
 
 aCircle = aSketchFeature.addFeature("SketchCircle")
-aCircleCenter = geomDataAPI_Point2D(aCircle.attribute("CircleCenter"))
-aCircleRadius = aCircle.real("CircleRadius")
+aCircleCenter = geomDataAPI_Point2D(aCircle.attribute("circle_center"))
+aCircleRadius = aCircle.real("circle_radius")
 aCircleCenter.setValue(-25., -25)
 aCircleRadius.setValue(25.)
 
 anArc = aSketchFeature.addFeature("SketchArc")
-anArcCenter = geomDataAPI_Point2D(anArc.attribute("ArcCenter"))
-anArcStart = geomDataAPI_Point2D(anArc.attribute("ArcStartPoint"))
-anArcEnd = geomDataAPI_Point2D(anArc.attribute("ArcEndPoint"))
+anArcCenter = geomDataAPI_Point2D(anArc.attribute("center_point"))
+anArcStart = geomDataAPI_Point2D(anArc.attribute("start_point"))
+anArcEnd = geomDataAPI_Point2D(anArc.attribute("end_point"))
 anArcCenter.setValue(10., 10.)
 anArcStart.setValue(50., 0.)
 anArcEnd.setValue(0., 50.)
@@ -100,16 +100,16 @@ assert(math.fabs(aProjLineEnd.y() - aLineEnd.y()) < 1.e-10)
 
 aProjCircle = ModelAPI_Feature.feature(aCircleProjector.refattr("ProjectedFeature").object())
 assert(aProjCircle)
-aProjCircleCenter = geomDataAPI_Point2D(aProjCircle.attribute("CircleCenter"))
-aProjCircleRadius = aProjCircle.real("CircleRadius")
+aProjCircleCenter = geomDataAPI_Point2D(aProjCircle.attribute("circle_center"))
+aProjCircleRadius = aProjCircle.real("circle_radius")
 assert(math.fabs(aProjCircleCenter.x() - aCircleCenter.x()) < 1.e-10)
 assert(math.fabs(aProjCircleCenter.y() - aCircleCenter.y()) < 1.e-10)
 assert(math.fabs(aProjCircleRadius.value() - aCircleRadius.value()) < 1.e-10)
 
 aProjArc = ModelAPI_Feature.feature(anArcProjector.refattr("ProjectedFeature").object())
-aProjArcCenter = geomDataAPI_Point2D(aProjArc.attribute("ArcCenter"))
-aProjArcStart = geomDataAPI_Point2D(aProjArc.attribute("ArcStartPoint"))
-aProjArcEnd = geomDataAPI_Point2D(aProjArc.attribute("ArcEndPoint"))
+aProjArcCenter = geomDataAPI_Point2D(aProjArc.attribute("center_point"))
+aProjArcStart = geomDataAPI_Point2D(aProjArc.attribute("start_point"))
+aProjArcEnd = geomDataAPI_Point2D(aProjArc.attribute("end_point"))
 assert(math.fabs(aProjArcCenter.x() - anArcCenter.x()) < 1.e-10)
 assert(math.fabs(aProjArcCenter.y() - anArcCenter.y()) < 1.e-10)
 assert(math.fabs(aProjArcStart.x() - anArcStart.x()) < 1.e-10)