Salome HOME
29470 - Point cloud on a face
[modules/geom.git] / test / test_point_cloud_on_face.py
1 # Point Cloud on Face\r
2 \r
3 import math\r
4 import salome\r
5 salome.salome_init_without_session()\r
6 import GEOM\r
7 from salome.geom import geomBuilder\r
8 geompy = geomBuilder.New()\r
9 \r
10 # create spherical face\r
11 Sphere = geompy.MakeSphereR(10, "Sphere")\r
12 [Face] = geompy.ExtractShapes(Sphere, geompy.ShapeType["FACE"], True, "Sphere_face")\r
13 \r
14 # make a cloud of 100 points on the spherical face\r
15 try:\r
16     CompoundOfVertices = geompy.MakeVertexInsideFace(Face, 100, "CompoundOfVertices")\r
17 except Exception as err:\r
18     print(err)\r
19     # this test should not fail in case of "Improper OCCT version"\r
20     assert("Improper OCCT version" in str(err))\r
21 else:\r
22     # check result\r
23     assert(geompy.NumberOfSubShapes(CompoundOfVertices, geompy.ShapeType["VERTEX"]) == 100)\r
24 \r
25 # test point cloud on a "Horse saddle"\r
26 OX = geompy.MakeVectorDXDYDZ(1, 0, 0, 'OX')\r
27 OY = geompy.MakeVectorDXDYDZ(0, 1, 0, 'OY')\r
28 [Edge_1,Edge_2,Edge_3] = geompy.ExtractShapes(Sphere, geompy.ShapeType["EDGE"], True, "Edge")\r
29 Rotation_1 = geompy.MakeRotation(Edge_3, OX, 90*math.pi/180.0, 'Rotation_1')\r
30 Rotation_2 = geompy.MakeRotation(Rotation_1, OY, 180*math.pi/180.0, 'Rotation_2')\r
31 Translation_1 = geompy.MakeTranslation(Rotation_2, 200, 0, 0, 'Translation_1')\r
32 Translation_2 = geompy.MakeTranslation(Edge_3, 100, 100, 0, 'Translation_2')\r
33 Translation_3 = geompy.MakeTranslation(Translation_2, 0, -200, 0, 'Translation_3')\r
34 Filling_1 = geompy.MakeFilling([Translation_2, Edge_3, Translation_3])\r
35 geompy.addToStudy(Filling_1, 'Filling_1')\r
36 \r
37 try:\r
38     PointCloudOnFilling = geompy.MakeVertexInsideFace(Filling_1, 30, "PointCloudOnFilling")\r
39 except Exception as err:\r
40     print(err)\r
41     # this test should not fail in case of "Improper OCCT version"\r
42     assert("Improper OCCT version" in str(err))\r
43 else:\r
44     assert(geompy.NumberOfSubShapes(PointCloudOnFilling, geompy.ShapeType["VERTEX"]) == 30)\r