Salome HOME
29470 - Point cloud on a face
[modules/geom.git] / test / test_point_cloud_on_face.py
diff --git a/test/test_point_cloud_on_face.py b/test/test_point_cloud_on_face.py
new file mode 100644 (file)
index 0000000..490a83c
--- /dev/null
@@ -0,0 +1,44 @@
+# Point Cloud on Face\r
+\r
+import math\r
+import salome\r
+salome.salome_init_without_session()\r
+import GEOM\r
+from salome.geom import geomBuilder\r
+geompy = geomBuilder.New()\r
+\r
+# create spherical face\r
+Sphere = geompy.MakeSphereR(10, "Sphere")\r
+[Face] = geompy.ExtractShapes(Sphere, geompy.ShapeType["FACE"], True, "Sphere_face")\r
+\r
+# make a cloud of 100 points on the spherical face\r
+try:\r
+    CompoundOfVertices = geompy.MakeVertexInsideFace(Face, 100, "CompoundOfVertices")\r
+except Exception as err:\r
+    print(err)\r
+    # this test should not fail in case of "Improper OCCT version"\r
+    assert("Improper OCCT version" in str(err))\r
+else:\r
+    # check result\r
+    assert(geompy.NumberOfSubShapes(CompoundOfVertices, geompy.ShapeType["VERTEX"]) == 100)\r
+\r
+# test point cloud on a "Horse saddle"\r
+OX = geompy.MakeVectorDXDYDZ(1, 0, 0, 'OX')\r
+OY = geompy.MakeVectorDXDYDZ(0, 1, 0, 'OY')\r
+[Edge_1,Edge_2,Edge_3] = geompy.ExtractShapes(Sphere, geompy.ShapeType["EDGE"], True, "Edge")\r
+Rotation_1 = geompy.MakeRotation(Edge_3, OX, 90*math.pi/180.0, 'Rotation_1')\r
+Rotation_2 = geompy.MakeRotation(Rotation_1, OY, 180*math.pi/180.0, 'Rotation_2')\r
+Translation_1 = geompy.MakeTranslation(Rotation_2, 200, 0, 0, 'Translation_1')\r
+Translation_2 = geompy.MakeTranslation(Edge_3, 100, 100, 0, 'Translation_2')\r
+Translation_3 = geompy.MakeTranslation(Translation_2, 0, -200, 0, 'Translation_3')\r
+Filling_1 = geompy.MakeFilling([Translation_2, Edge_3, Translation_3])\r
+geompy.addToStudy(Filling_1, 'Filling_1')\r
+\r
+try:\r
+    PointCloudOnFilling = geompy.MakeVertexInsideFace(Filling_1, 30, "PointCloudOnFilling")\r
+except Exception as err:\r
+    print(err)\r
+    # this test should not fail in case of "Improper OCCT version"\r
+    assert("Improper OCCT version" in str(err))\r
+else:\r
+    assert(geompy.NumberOfSubShapes(PointCloudOnFilling, geompy.ShapeType["VERTEX"]) == 30)\r