X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBuildPlugin%2FTest%2FTestVertex.py;h=1e23427a92e44c942427acda8913a4b542f1242d;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=be6c50e79456c01b0f7ea9d402851c8acfc69b75;hpb=5b6031b015602aa07f5a6fc668c13ac3faf7a8a9;p=modules%2Fshaper.git diff --git a/src/BuildPlugin/Test/TestVertex.py b/src/BuildPlugin/Test/TestVertex.py index be6c50e79..1e23427a9 100644 --- a/src/BuildPlugin/Test/TestVertex.py +++ b/src/BuildPlugin/Test/TestVertex.py @@ -1,3 +1,22 @@ +# Copyright (C) 2014-2023 CEA, EDF +# +# 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 +# + # Initialization of the test from ModelAPI import * from GeomDataAPI import * @@ -8,8 +27,8 @@ import random def createPoint(theSketchFeature): aSketchPointFeature = theSketchFeature.addFeature("SketchPoint") - aPointCoordindates = geomDataAPI_Point2D(aSketchPointFeature.attribute("PointCoordindates")) - aPointCoordindates.setValue(random.uniform(0, 100), random.uniform(0, 100)) + aPointCoordinates = geomDataAPI_Point2D(aSketchPointFeature.attribute("PointCoordinates")) + aPointCoordinates.setValue(random.uniform(0, 100), random.uniform(0, 100)) return aSketchPointFeature # Get document @@ -56,5 +75,34 @@ aSession.finishOperation() # Test results assert (len(aVertexFeature.results()) == aNumOfPoints) +# Check Vertex feature correct on a whole sketch +aSession.startOperation() +aVertexFeature2 = aPart.addFeature("Vertex") +aBaseObjectsList = aVertexFeature2.selectionList("base_objects") +aBaseObjectsList.append(aSketchResult, None) +aSession.finishOperation() +assert (len(aVertexFeature2.results()) == aNumOfPoints) + +# Check Vertex feature failed on incorrect input +aSession.startOperation() +aLine = aSketchFeature.addFeature("SketchLine") +geomDataAPI_Point2D(aLine.attribute("StartPoint")).setValue(0, 0) +geomDataAPI_Point2D(aLine.attribute("EndPoint")).setValue(100, 100) +aSession.finishOperation() +aSession.startOperation() +aPart.setCurrentFeature(aVertexFeature2, False) +aSession.finishOperation() +aSession.startOperation() +aVertexFeature3 = aPart.addFeature("Vertex") +aBaseObjectsList = aVertexFeature3.selectionList("base_objects") +aBaseObjectsList.append(aSketchResult, aLine.lastResult().shape()) +aSession.finishOperation() +assert (len(aVertexFeature3.results()) == 0) + +# remove failed feature +aSession.startOperation() +aPart.removeFeature(aVertexFeature3) +aSession.finishOperation() + from salome.shaper import model assert(model.checkPythonDump())