X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FTest%2FTestProjection.py;h=7e24e3ed5b3916a2794bcabc919992dafb416b42;hb=d0f078983d5f74d45a6f28b3a4dfe8feadb2cdf7;hp=ee3151c430e805a7d029d7df1a85c1e3fcba54d6;hpb=d34842c50d5f335cca443c78910c16c54139c7d0;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/Test/TestProjection.py b/src/SketchPlugin/Test/TestProjection.py index ee3151c43..7e24e3ed5 100644 --- a/src/SketchPlugin/Test/TestProjection.py +++ b/src/SketchPlugin/Test/TestProjection.py @@ -1,3 +1,23 @@ +## Copyright (C) 2014-2017 CEA/DEN, EDF R&D +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library; if not, write to the Free Software +## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## +## See http:##www.salome-platform.org/ or +## email : webmaster.salome@opencascade.com +## + """ TestProjection.py Unit test of SketchPlugin_Projection class @@ -6,6 +26,8 @@ from GeomDataAPI import * from ModelAPI import * import math +from salome.shaper import model + #========================================================================= # Initialization of the test #========================================================================= @@ -41,19 +63,20 @@ 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.) aSession.finishOperation() +assert (model.dof(aSketchFeature) == 12) #========================================================================= # Create another sketch #========================================================================= @@ -72,16 +95,20 @@ aSession.finishOperation() aSession.startOperation() aLineProjector = aSketchFeature.addFeature("SketchProjection") aLineProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/Edge-SketchLine_1") +aLineProjector.boolean("IncludeToResult").setValue(False) aLineProjector.execute() aCircleProjector = aSketchFeature.addFeature("SketchProjection") aCircleProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/Edge-SketchCircle_1_2") +aCircleProjector.boolean("IncludeToResult").setValue(False) aCircleProjector.execute() anArcProjector = aSketchFeature.addFeature("SketchProjection") anArcProjector.selection("ExternalFeature").selectSubShape("EDGE", "Sketch_1/Edge-SketchArc_1_2") +anArcProjector.boolean("IncludeToResult").setValue(False) anArcProjector.execute() aSession.finishOperation() +assert (model.dof(aSketchFeature) == 0) #========================================================================= # Check projection coordinates #========================================================================= @@ -96,16 +123,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) @@ -122,9 +149,9 @@ assert(math.fabs(aProjLineStart.x() - aLineStart.x()) < 1.e-10) assert(math.fabs(aProjLineStart.y() - aLineStart.y()) < 1.e-10) assert(math.fabs(aProjLineEnd.x() - aLineEnd.x()) < 1.e-10) assert(math.fabs(aProjLineEnd.y() - aLineEnd.y()) < 1.e-10) +assert (model.dof(aSketchFeature) == 0) #========================================================================= # End of test #========================================================================= -import model assert(model.checkPythonDump())