1 ## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 ## This library is free software; you can redistribute it and/or
4 ## modify it under the terms of the GNU Lesser General Public
5 ## License as published by the Free Software Foundation; either
6 ## version 2.1 of the License, or (at your option) any later version.
8 ## This library is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ## Lesser General Public License for more details.
13 ## You should have received a copy of the GNU Lesser General Public
14 ## License along with this library; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 ## See http:##www.salome-platform.org/ or
18 ## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 # Initialization of the test
22 from ModelAPI import *
23 from GeomDataAPI import *
24 from GeomAlgoAPI import *
29 def createPoint(theSketchFeature):
30 aSketchPointFeature = theSketchFeature.addFeature("SketchPoint")
31 aPointCoordinates = geomDataAPI_Point2D(aSketchPointFeature.attribute("PointCoordinates"))
32 aPointCoordinates.setValue(random.uniform(0, 100), random.uniform(0, 100))
33 return aSketchPointFeature
36 aSession = ModelAPI_Session.get()
37 aDocument = aSession.moduleDocument()
40 aSession.startOperation()
41 aPartFeature = aDocument.addFeature("Part")
42 aSession.finishOperation()
43 aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
44 aPart = aPartResult.partDoc()
47 aSession.startOperation()
48 aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
49 anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
50 anOrigin.setValue(0, 0, 0)
51 aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
52 aDirX.setValue(1, 0, 0)
53 aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
54 aNorm.setValue(0, 0, 1)
59 for i in range(aNumOfPoints):
60 aSession.startOperation()
61 aSketchPointFeature = createPoint(aSketchFeature)
62 aSession.finishOperation()
63 aPoints.append(aSketchPointFeature.firstResult().shape())
64 aSession.finishOperation()
65 aSketchResult = aSketchFeature.firstResult()
68 aSession.startOperation()
69 aVertexFeature = aPart.addFeature("Vertex")
70 aBaseObjectsList = aVertexFeature.selectionList("base_objects")
72 for aPoint in aPoints:
73 aBaseObjectsList.append(aSketchResult, aPoint)
74 aSession.finishOperation()
77 assert (len(aVertexFeature.results()) == aNumOfPoints)
79 from salome.shaper import model
80 assert(model.checkPythonDump())