From 101d3e5334f023119aa62efd4ca0ae5a31ad5a50 Mon Sep 17 00:00:00 2001 From: azv Date: Tue, 28 Mar 2017 10:52:50 +0300 Subject: [PATCH] Adjust test cases according to redesigned Arc and Circle features --- src/CollectionPlugin/Test/TestGroup.py | 4 +- .../Test/TestAxisCreation.py | 4 +- src/FeaturesPlugin/Test/TestBoolean.py | 4 +- .../Test/TestBooleanCompSolids.py | 4 +- src/FeaturesPlugin/Test/TestBooleanSmash.py | 4 +- .../Test/TestCompositeFeaturesOnCompSolids.py | 12 +- src/FeaturesPlugin/Test/TestExtrusion.py | 4 +- src/FeaturesPlugin/Test/TestExtrusionCut.py | 8 +- src/FeaturesPlugin/Test/TestExtrusionFuse.py | 8 +- src/FeaturesPlugin/Test/TestIntersection.py | 8 +- src/FeaturesPlugin/Test/TestMultiBoolean.py | 4 +- src/FeaturesPlugin/Test/TestPartition.py | 4 +- src/FeaturesPlugin/Test/TestPipe.py | 15 +- .../Test/TestRemoveSubShapes.py | 8 +- src/FeaturesPlugin/Test/TestRevolution.py | 4 +- src/FeaturesPlugin/Test/TestRevolutionCut.py | 8 +- src/FeaturesPlugin/Test/TestRevolutionFuse.py | 8 +- src/FeaturesPlugin/Test/TestRotation.py | 4 +- src/FeaturesPlugin/Test/TestSerialBoolean.py | 4 +- src/FeaturesPlugin/Test/TestTranslation.py | 4 +- src/FeaturesPlugin/Test/TestUnion.py | 8 +- src/ModelAPI/Test/Test1512.py | 8 +- .../Test/TestParameterChangeValue.py | 4 +- .../Test/TestParameterCreation.py | 4 +- .../Test/TestParameterRename.py | 4 +- src/PythonAPI/Test/TestSketcherAddMirror.py | 4 +- src/PythonAPI/Test/TestSketcherSetTangent.py | 4 +- src/PythonAPI/model/sketcher/__init__.py | 2 +- src/PythonAPI/model/sketcher/tools.py | 21 ++- src/SketchPlugin/CMakeLists.txt | 7 +- src/SketchPlugin/SketchPlugin_Arc.cpp | 11 +- src/SketchPlugin/SketchPlugin_msg_en.ts | 18 +-- src/SketchPlugin/Test/TestArcBehavior.py | 26 ++-- .../Test/TestConstraintCoincidence.py | 18 +-- .../Test/TestConstraintDistance.py | 19 +-- src/SketchPlugin/Test/TestConstraintEqual.py | 24 ++-- src/SketchPlugin/Test/TestConstraintRadius.py | 49 +++---- .../Test/TestConstraintTangent.py | 83 ++++++----- .../Test/TestCreateArcByCenterStartEnd.py | 129 ++++++++++++++++++ .../Test/TestCreateCircleByCenterAndPassed.py | 31 ++--- .../Test/TestCreateCircleByThreePoints.py | 29 ++-- .../Test/TestCreateCircleChangeType.py | 17 +-- src/SketchPlugin/Test/TestFillet.py | 25 ++-- .../Test/TestFilletInteracting.py | 19 ++- ...{TestConstraintMirror.py => TestMirror.py} | 16 +-- src/SketchPlugin/Test/TestMultiRotation.py | 12 +- src/SketchPlugin/Test/TestMultiTranslation.py | 12 +- src/SketchPlugin/Test/TestProjection.py | 20 +-- 48 files changed, 418 insertions(+), 329 deletions(-) create mode 100644 src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py rename src/SketchPlugin/Test/{TestConstraintMirror.py => TestMirror.py} (96%) diff --git a/src/CollectionPlugin/Test/TestGroup.py b/src/CollectionPlugin/Test/TestGroup.py index 4c21a570a..a5e078821 100644 --- a/src/CollectionPlugin/Test/TestGroup.py +++ b/src/CollectionPlugin/Test/TestGroup.py @@ -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() diff --git a/src/ConstructionPlugin/Test/TestAxisCreation.py b/src/ConstructionPlugin/Test/TestAxisCreation.py index f9ef91118..0db452f9c 100644 --- a/src/ConstructionPlugin/Test/TestAxisCreation.py +++ b/src/ConstructionPlugin/Test/TestAxisCreation.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestBoolean.py b/src/FeaturesPlugin/Test/TestBoolean.py index 968263eaa..0d3426549 100644 --- a/src/FeaturesPlugin/Test/TestBoolean.py +++ b/src/FeaturesPlugin/Test/TestBoolean.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestBooleanCompSolids.py b/src/FeaturesPlugin/Test/TestBooleanCompSolids.py index 414498fb4..d4c5864f6 100644 --- a/src/FeaturesPlugin/Test/TestBooleanCompSolids.py +++ b/src/FeaturesPlugin/Test/TestBooleanCompSolids.py @@ -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) diff --git a/src/FeaturesPlugin/Test/TestBooleanSmash.py b/src/FeaturesPlugin/Test/TestBooleanSmash.py index 02d0606c7..9570b1cd8 100644 --- a/src/FeaturesPlugin/Test/TestBooleanSmash.py +++ b/src/FeaturesPlugin/Test/TestBooleanSmash.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestCompositeFeaturesOnCompSolids.py b/src/FeaturesPlugin/Test/TestCompositeFeaturesOnCompSolids.py index fceb782ff..ef74d8391 100644 --- a/src/FeaturesPlugin/Test/TestCompositeFeaturesOnCompSolids.py +++ b/src/FeaturesPlugin/Test/TestCompositeFeaturesOnCompSolids.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestExtrusion.py b/src/FeaturesPlugin/Test/TestExtrusion.py index 527dafeac..efe7f293c 100644 --- a/src/FeaturesPlugin/Test/TestExtrusion.py +++ b/src/FeaturesPlugin/Test/TestExtrusion.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestExtrusionCut.py b/src/FeaturesPlugin/Test/TestExtrusionCut.py index e461c50e1..1d62b41c9 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionCut.py +++ b/src/FeaturesPlugin/Test/TestExtrusionCut.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestExtrusionFuse.py b/src/FeaturesPlugin/Test/TestExtrusionFuse.py index 12693b837..c05adb3e9 100644 --- a/src/FeaturesPlugin/Test/TestExtrusionFuse.py +++ b/src/FeaturesPlugin/Test/TestExtrusionFuse.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestIntersection.py b/src/FeaturesPlugin/Test/TestIntersection.py index d1c0043a6..1bcd0a6be 100644 --- a/src/FeaturesPlugin/Test/TestIntersection.py +++ b/src/FeaturesPlugin/Test/TestIntersection.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestMultiBoolean.py b/src/FeaturesPlugin/Test/TestMultiBoolean.py index aa36d8628..a7ea2cabd 100644 --- a/src/FeaturesPlugin/Test/TestMultiBoolean.py +++ b/src/FeaturesPlugin/Test/TestMultiBoolean.py @@ -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) diff --git a/src/FeaturesPlugin/Test/TestPartition.py b/src/FeaturesPlugin/Test/TestPartition.py index 127209b2a..b21298a33 100644 --- a/src/FeaturesPlugin/Test/TestPartition.py +++ b/src/FeaturesPlugin/Test/TestPartition.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestPipe.py b/src/FeaturesPlugin/Test/TestPipe.py index 21ba065e1..b6d59e23e 100644 --- a/src/FeaturesPlugin/Test/TestPipe.py +++ b/src/FeaturesPlugin/Test/TestPipe.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestRemoveSubShapes.py b/src/FeaturesPlugin/Test/TestRemoveSubShapes.py index 6227d4580..4d36094ff 100644 --- a/src/FeaturesPlugin/Test/TestRemoveSubShapes.py +++ b/src/FeaturesPlugin/Test/TestRemoveSubShapes.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestRevolution.py b/src/FeaturesPlugin/Test/TestRevolution.py index 28aba7762..306f1803e 100644 --- a/src/FeaturesPlugin/Test/TestRevolution.py +++ b/src/FeaturesPlugin/Test/TestRevolution.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestRevolutionCut.py b/src/FeaturesPlugin/Test/TestRevolutionCut.py index c9b10c8fe..c2d337e26 100644 --- a/src/FeaturesPlugin/Test/TestRevolutionCut.py +++ b/src/FeaturesPlugin/Test/TestRevolutionCut.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestRevolutionFuse.py b/src/FeaturesPlugin/Test/TestRevolutionFuse.py index 863d2a6d0..1512f87f3 100644 --- a/src/FeaturesPlugin/Test/TestRevolutionFuse.py +++ b/src/FeaturesPlugin/Test/TestRevolutionFuse.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestRotation.py b/src/FeaturesPlugin/Test/TestRotation.py index 175b08fdf..c33308acb 100644 --- a/src/FeaturesPlugin/Test/TestRotation.py +++ b/src/FeaturesPlugin/Test/TestRotation.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestSerialBoolean.py b/src/FeaturesPlugin/Test/TestSerialBoolean.py index 7adf33624..2fef110c0 100644 --- a/src/FeaturesPlugin/Test/TestSerialBoolean.py +++ b/src/FeaturesPlugin/Test/TestSerialBoolean.py @@ -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) diff --git a/src/FeaturesPlugin/Test/TestTranslation.py b/src/FeaturesPlugin/Test/TestTranslation.py index f6d95033d..d981d535f 100644 --- a/src/FeaturesPlugin/Test/TestTranslation.py +++ b/src/FeaturesPlugin/Test/TestTranslation.py @@ -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() diff --git a/src/FeaturesPlugin/Test/TestUnion.py b/src/FeaturesPlugin/Test/TestUnion.py index 2b6f931ac..3ccfd563b 100644 --- a/src/FeaturesPlugin/Test/TestUnion.py +++ b/src/FeaturesPlugin/Test/TestUnion.py @@ -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() diff --git a/src/ModelAPI/Test/Test1512.py b/src/ModelAPI/Test/Test1512.py index 21fce85e8..bce23fd6a 100755 --- a/src/ModelAPI/Test/Test1512.py +++ b/src/ModelAPI/Test/Test1512.py @@ -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() #========================================================================= diff --git a/src/ParametersPlugin/Test/TestParameterChangeValue.py b/src/ParametersPlugin/Test/TestParameterChangeValue.py index 3d6d9e230..2eca3f077 100644 --- a/src/ParametersPlugin/Test/TestParameterChangeValue.py +++ b/src/ParametersPlugin/Test/TestParameterChangeValue.py @@ -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() diff --git a/src/ParametersPlugin/Test/TestParameterCreation.py b/src/ParametersPlugin/Test/TestParameterCreation.py index ad85bdf51..69574c10a 100644 --- a/src/ParametersPlugin/Test/TestParameterCreation.py +++ b/src/ParametersPlugin/Test/TestParameterCreation.py @@ -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() diff --git a/src/ParametersPlugin/Test/TestParameterRename.py b/src/ParametersPlugin/Test/TestParameterRename.py index 414133829..0f2f90174 100644 --- a/src/ParametersPlugin/Test/TestParameterRename.py +++ b/src/ParametersPlugin/Test/TestParameterRename.py @@ -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() diff --git a/src/PythonAPI/Test/TestSketcherAddMirror.py b/src/PythonAPI/Test/TestSketcherAddMirror.py index 032bff237..65d7e3dc8 100644 --- a/src/PythonAPI/Test/TestSketcherAddMirror.py +++ b/src/PythonAPI/Test/TestSketcherAddMirror.py @@ -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))) diff --git a/src/PythonAPI/Test/TestSketcherSetTangent.py b/src/PythonAPI/Test/TestSketcherSetTangent.py index b2464370d..d92d6433c 100644 --- a/src/PythonAPI/Test/TestSketcherSetTangent.py +++ b/src/PythonAPI/Test/TestSketcherSetTangent.py @@ -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): diff --git a/src/PythonAPI/model/sketcher/__init__.py b/src/PythonAPI/model/sketcher/__init__.py index 994ecc6f1..b015b4278 100644 --- a/src/PythonAPI/model/sketcher/__init__.py +++ b/src/PythonAPI/model/sketcher/__init__.py @@ -2,4 +2,4 @@ """ from SketchAPI import addSketch -from tools import addPolyline, addPolygon, dof +from tools import * diff --git a/src/PythonAPI/model/sketcher/tools.py b/src/PythonAPI/model/sketcher/tools.py index 3603f2006..0a17f6aea 100644 --- a/src/PythonAPI/model/sketcher/tools.py +++ b/src/PythonAPI/model/sketcher/tools.py @@ -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 diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 84349b45b..8ac8414ee 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -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 diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index 9ebf16eb3..1890400ce 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -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); diff --git a/src/SketchPlugin/SketchPlugin_msg_en.ts b/src/SketchPlugin/SketchPlugin_msg_en.ts index 994eba6d5..f4f41f841 100755 --- a/src/SketchPlugin/SketchPlugin_msg_en.ts +++ b/src/SketchPlugin/SketchPlugin_msg_en.ts @@ -82,7 +82,7 @@ SketchMacroCircle:Model_FeatureValidator - Attribute "CircleCenter" is not initialized. + Attribute "circle_center" is not initialized. A center point is not selected @@ -110,7 +110,7 @@ SketchMacroCircle:CircleCenter - Attribute "CircleCenter" is locked by modification value in the viewer. + Attribute "circle_center" is locked by modification value in the viewer. Select a center point @@ -138,7 +138,7 @@ SketchMacroCircle:CircleRadius - Attribute "CircleRadius" is locked by modification value in the viewer. + Attribute "circle_radius" is locked by modification value in the viewer. Select a radius distance @@ -159,7 +159,7 @@ SketchMacroCircle:Model_FeatureValidator - Attribute "CircleRadius" is not initialized. + Attribute "circle_radius" is not initialized. Set the circle radius @@ -636,14 +636,14 @@ SketchArc:ArcCenter - Attribute "ArcCenter" is locked by modification value in the viewer. + Attribute "center_point" is locked by modification value in the viewer. Select a center point SketchArc:ArcCenter - Attribute "ArcCenter" is not initialized. + Attribute "center_point" is not initialized. Center point is not defined @@ -720,21 +720,21 @@ SketchArc:Model_FeatureValidator - Attribute "ArcCenter" is not initialized. + Attribute "center_point" is not initialized. Select an arc center SketchArc:Model_FeatureValidator:ArcStartPoint - Attribute "ArcStartPoint" is not initialized. + Attribute "start_point" is not initialized. Select an arc start point SketchArc:Model_FeatureValidator - Attribute "ArcEndPoint" is not initialized. + Attribute "end_point" is not initialized. Select an arc end point diff --git a/src/SketchPlugin/Test/TestArcBehavior.py b/src/SketchPlugin/Test/TestArcBehavior.py index 24014cae2..b0e31d729 100644 --- a/src/SketchPlugin/Test/TestArcBehavior.py +++ b/src/SketchPlugin/Test/TestArcBehavior.py @@ -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 #========================================================================= diff --git a/src/SketchPlugin/Test/TestConstraintCoincidence.py b/src/SketchPlugin/Test/TestConstraintCoincidence.py index 0ee20f691..893242aa9 100644 --- a/src/SketchPlugin/Test/TestConstraintCoincidence.py +++ b/src/SketchPlugin/Test/TestConstraintCoincidence.py @@ -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() diff --git a/src/SketchPlugin/Test/TestConstraintDistance.py b/src/SketchPlugin/Test/TestConstraintDistance.py index 2c8b5c6a0..47a67e6ec 100644 --- a/src/SketchPlugin/Test/TestConstraintDistance.py +++ b/src/SketchPlugin/Test/TestConstraintDistance.py @@ -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 diff --git a/src/SketchPlugin/Test/TestConstraintEqual.py b/src/SketchPlugin/Test/TestConstraintEqual.py index 49bf17658..5c518e99a 100644 --- a/src/SketchPlugin/Test/TestConstraintEqual.py +++ b/src/SketchPlugin/Test/TestConstraintEqual.py @@ -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/TestConstraintRadius.py b/src/SketchPlugin/Test/TestConstraintRadius.py index 9ba906752..f11cf74c9 100644 --- a/src/SketchPlugin/Test/TestConstraintRadius.py +++ b/src/SketchPlugin/Test/TestConstraintRadius.py @@ -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 diff --git a/src/SketchPlugin/Test/TestConstraintTangent.py b/src/SketchPlugin/Test/TestConstraintTangent.py index 7b37ce0f3..a7ea5c64e 100644 --- a/src/SketchPlugin/Test/TestConstraintTangent.py +++ b/src/SketchPlugin/Test/TestConstraintTangent.py @@ -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 index 000000000..2fb4d4711 --- /dev/null +++ b/src/SketchPlugin/Test/TestCreateArcByCenterStartEnd.py @@ -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()) diff --git a/src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py b/src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py index 272399734..bb691dfcb 100644 --- a/src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py +++ b/src/SketchPlugin/Test/TestCreateCircleByCenterAndPassed.py @@ -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) diff --git a/src/SketchPlugin/Test/TestCreateCircleByThreePoints.py b/src/SketchPlugin/Test/TestCreateCircleByThreePoints.py index 060127a34..ce9a24d4a 100644 --- a/src/SketchPlugin/Test/TestCreateCircleByThreePoints.py +++ b/src/SketchPlugin/Test/TestCreateCircleByThreePoints.py @@ -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) diff --git a/src/SketchPlugin/Test/TestCreateCircleChangeType.py b/src/SketchPlugin/Test/TestCreateCircleChangeType.py index 52daff262..4a78584aa 100644 --- a/src/SketchPlugin/Test/TestCreateCircleChangeType.py +++ b/src/SketchPlugin/Test/TestCreateCircleChangeType.py @@ -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) diff --git a/src/SketchPlugin/Test/TestFillet.py b/src/SketchPlugin/Test/TestFillet.py index 59f353cb8..a52ce5a5c 100644 --- a/src/SketchPlugin/Test/TestFillet.py +++ b/src/SketchPlugin/Test/TestFillet.py @@ -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() diff --git a/src/SketchPlugin/Test/TestFilletInteracting.py b/src/SketchPlugin/Test/TestFilletInteracting.py index 15b101e44..9653c3cf0 100644 --- a/src/SketchPlugin/Test/TestFilletInteracting.py +++ b/src/SketchPlugin/Test/TestFilletInteracting.py @@ -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/TestConstraintMirror.py b/src/SketchPlugin/Test/TestMirror.py similarity index 96% rename from src/SketchPlugin/Test/TestConstraintMirror.py rename to src/SketchPlugin/Test/TestMirror.py index 78fe2fbdc..306d02d45 100644 --- a/src/SketchPlugin/Test/TestConstraintMirror.py +++ b/src/SketchPlugin/Test/TestMirror.py @@ -1,7 +1,7 @@ """ 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()); @@ -32,7 +32,7 @@ def normalize(theDir): 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()] @@ -44,13 +44,13 @@ def checkMirror(theListInit, theListMirr, theMirrorLine): 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'] - + anAttributes = ['center_point', 'start_point', 'end_point'] + for key in anAttributes: aPointB = geomDataAPI_Point2D(aFeatureB.attribute(key)) aPointC = geomDataAPI_Point2D(aFeatureC.attribute(key)) @@ -88,11 +88,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 diff --git a/src/SketchPlugin/Test/TestMultiRotation.py b/src/SketchPlugin/Test/TestMultiRotation.py index 7328e497c..6a6d19201 100644 --- a/src/SketchPlugin/Test/TestMultiRotation.py +++ b/src/SketchPlugin/Test/TestMultiRotation.py @@ -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)) diff --git a/src/SketchPlugin/Test/TestMultiTranslation.py b/src/SketchPlugin/Test/TestMultiTranslation.py index 80eb90ed1..639fd4e30 100644 --- a/src/SketchPlugin/Test/TestMultiTranslation.py +++ b/src/SketchPlugin/Test/TestMultiTranslation.py @@ -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)) diff --git a/src/SketchPlugin/Test/TestProjection.py b/src/SketchPlugin/Test/TestProjection.py index 9477cdc74..9183aacb5 100644 --- a/src/SketchPlugin/Test/TestProjection.py +++ b/src/SketchPlugin/Test/TestProjection.py @@ -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) -- 2.30.2