INSTALL(FILES ${XML_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
INSTALL(DIRECTORY icons/ DESTINATION ${SHAPER_INSTALL_XML_RESOURCES}/icons/Build)
-# ADD_UNIT_TESTS()
+ADD_UNIT_TESTS(TestVertex.py
+ TestEdge.py
+ TestWire.py
+ TestFace.py)
--- /dev/null
+# Initialization of the test
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+import random
+
+def createLine(theSketchFeature):
+ aSketchLineFeature = theSketchFeature.addFeature("SketchLine")
+ aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+ aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+ aSketchLineStartPoint.setValue(random.uniform(0, 100), random.uniform(0, 100))
+ aSketchLineEndPoint.setValue(random.uniform(0, 100), random.uniform(0, 100))
+
+# Get document
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+# Create a sketch
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+anOrigin.setValue(0, 0, 0)
+aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+aDirX.setValue(1, 0, 0)
+aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+aNorm.setValue(0, 0, 1)
+
+# Create lines
+aNumOfLines = 10
+for i in range(aNumOfLines):
+ createLine(aSketchFeature)
+aSession.finishOperation()
+aSketchResult = aSketchFeature.firstResult()
+aSketchShape = aSketchResult.shape()
+
+# Create edges
+aSession.startOperation()
+anEdgeFeature = aPart.addFeature("Edge")
+aBaseObjectsList = anEdgeFeature.selectionList("base_objects")
+aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
+while aShapeExplorer.more():
+ aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
+ aShapeExplorer.next()
+aSession.finishOperation()
+
+# Test results
+assert (len(anEdgeFeature.results()) == aNumOfLines)
--- /dev/null
+# Initialization of the test
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+# Get document
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+# Create a sketch
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+anOrigin.setValue(0, 0, 0)
+aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+aDirX.setValue(1, 0, 0)
+aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+aNorm.setValue(0, 0, 1)
+
+# Create lines
+aNumOfLines = 10
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(0, 0)
+aSketchLineEndPoint.setValue(0, 50)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(0, 50)
+aSketchLineEndPoint.setValue(50, 50)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(50, 50)
+aSketchLineEndPoint.setValue(50, 0)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(50, 0)
+aSketchLineEndPoint.setValue(0, 0)
+aSession.finishOperation()
+aSketchResult = aSketchFeature.firstResult()
+aSketchShape = aSketchResult.shape()
+
+# Create face
+aSession.startOperation()
+aFaceFeature = aPart.addFeature("Face")
+aBaseObjectsList = aFaceFeature.selectionList("base_objects")
+aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
+while aShapeExplorer.more():
+ aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
+ aShapeExplorer.next()
+aSession.finishOperation()
+
+# Test results
+assert (len(aFaceFeature.results()) > 0)
--- /dev/null
+# Initialization of the test
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+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))
+ return aSketchPointFeature
+
+# Get document
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+# Create a sketch
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+anOrigin.setValue(0, 0, 0)
+aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+aDirX.setValue(1, 0, 0)
+aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+aNorm.setValue(0, 0, 1)
+
+# Create points
+aNumOfPoints = 10
+aPoints = []
+for i in range(aNumOfPoints):
+ aSession.startOperation()
+ aSketchPointFeature = createPoint(aSketchFeature)
+ aSession.finishOperation()
+ aPoints.append(aSketchPointFeature.firstResult().shape())
+aSession.finishOperation()
+aSketchResult = aSketchFeature.firstResult()
+
+# Create vertices
+aSession.startOperation()
+aVertexFeature = aPart.addFeature("Vertex")
+aBaseObjectsList = aVertexFeature.selectionList("base_objects")
+
+for aPoint in aPoints:
+ aBaseObjectsList.append(aSketchResult, aPoint)
+aSession.finishOperation()
+
+# Test results
+assert (len(aVertexFeature.results()) == aNumOfPoints)
--- /dev/null
+# Initialization of the test
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+# Get document
+aSession = ModelAPI_Session.get()
+aDocument = aSession.moduleDocument()
+
+# Create a part
+aSession.startOperation()
+aPartFeature = aDocument.addFeature("Part")
+aSession.finishOperation()
+aPartResult = modelAPI_ResultPart(aPartFeature.firstResult())
+aPart = aPartResult.partDoc()
+
+# Create a sketch
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+anOrigin.setValue(0, 0, 0)
+aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+aDirX.setValue(1, 0, 0)
+aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+aNorm.setValue(0, 0, 1)
+
+# Create lines
+aNumOfLines = 10
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(0, 0)
+aSketchLineEndPoint.setValue(0, 50)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(0, 50)
+aSketchLineEndPoint.setValue(50, 50)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(50, 50)
+aSketchLineEndPoint.setValue(50, 0)
+aSketchLineFeature = aSketchFeature.addFeature("SketchLine")
+aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint"))
+aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint"))
+aSketchLineStartPoint.setValue(50, 0)
+aSketchLineEndPoint.setValue(0, 0)
+aSession.finishOperation()
+aSketchResult = aSketchFeature.firstResult()
+aSketchShape = aSketchResult.shape()
+
+# Create wire
+aSession.startOperation()
+aWireFeature = aPart.addFeature("Wire")
+aBaseObjectsList = aWireFeature.selectionList("base_objects")
+aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
+while aShapeExplorer.more():
+ aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
+ aShapeExplorer.next()
+aSession.finishOperation()
+
+# Test results
+assert (len(aWireFeature.results()) > 0)