.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\itom\pointClouds\demo_PointCloud.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_11_demos_itom_pointClouds_demo_PointCloud.py: PointCloud ============= This demo is a very short introduction to basic point clouds and a polygon mesh, that consists of two triangles, whose corner points are given by some points of a cloud. .. GENERATED FROM PYTHON SOURCE LINES 7-15 .. code-block:: default import numpy as np from itom import pointCloud from itom import polygonMesh from itom import point .. GENERATED FROM PYTHON SOURCE LINES 17-24 Create a new, empty ``pointCloud`` of type x,y,z only. Point clouds can either be organized or unorganized. Organized point clouds have a height > 1, such that all points are organized in a 2d grid and the direct neighbours of every point are therefore defined. In unorganized point clouds, the height is always <= 1 and the size is equal to the width of the cloud. No point has any neighbourhood relationship to other points. This is usually the default. .. GENERATED FROM PYTHON SOURCE LINES 24-31 .. code-block:: default pcl = pointCloud(point.PointXYZ) print( "Initial point cloud pcl, shape (h, w): %i x %i, fields: %s, organized: %i" % (pcl.height, pcl.width, str(pcl.fields), pcl.organized) ) .. rst-class:: sphx-glr-script-out .. code-block:: none Initial point cloud pcl, shape (h, w): 0 x 0, fields: ['x', 'y', 'z'], organized: 0 .. GENERATED FROM PYTHON SOURCE LINES 32-33 Add 8 points of a unit cube. .. GENERATED FROM PYTHON SOURCE LINES 33-67 .. code-block:: default pcl.append(point(point.PointXYZ, (0, 0, 0))) pcl.append(point(point.PointXYZ, (1, 0, 0))) pcl.append(point(point.PointXYZ, (0, 1, 0))) pcl.append(point(point.PointXYZ, (1, 1, 0))) pcl.append(point(point.PointXYZ, (0, 0, 1))) pcl.append(point(point.PointXYZ, (1, 0, 1))) pcl.append(point(point.PointXYZ, (0, 1, 1))) pcl.append(point(point.PointXYZ, (1, 1, 1))) print( "Modified point cloud pcl, shape (h, w): %i x %i, fields: %s, organized: %i" % (pcl.height, pcl.width, str(pcl.fields), pcl.organized) ) for idx in range(pcl.size): print("Point %i: %s" % (idx + 1, str(pcl[idx]))) # A polygon mesh can be constructed from a point cloud, that indicates # all corner points of the mesh and a table of vertices. Every entry in the # vertices table must contain 3 (default) or 4 values and indicate the indices # to the points in the cloud that define a triangle or quadrangle of the # mesh. If the normal vector to such a triangle points towards the outside # of the object, the order of the points is given by the right-hand rule, where # the thumbs shows in the direction of the normale vector. # create an array with two triangles. The first triangle has the corner # points with the indices 0, 1 and 2 of the cloud. The 2nd triangle consists # of the corner points 0, 1 and 3. vertices = np.array([[0, 1, 2], [0, 1, 3]]) # create a mesh from the cloud and the vertices mesh = polygonMesh.fromCloudAndPolygons(pcl, vertices) print("Mesh of %i polygons" % mesh.nrOfPolygons) .. rst-class:: sphx-glr-script-out .. code-block:: none Modified point cloud pcl, shape (h, w): 1 x 8, fields: ['x', 'y', 'z'], organized: 0 Point 1: Point (XYZ=[0,0,0]) Point 2: Point (XYZ=[1,0,0]) Point 3: Point (XYZ=[0,1,0]) Point 4: Point (XYZ=[1,1,0]) Point 5: Point (XYZ=[0,0,1]) Point 6: Point (XYZ=[1,0,1]) Point 7: Point (XYZ=[0,1,1]) Point 8: Point (XYZ=[1,1,1]) Mesh of 2 polygons .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.004 seconds) .. _sphx_glr_download_11_demos_itom_pointClouds_demo_PointCloud.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_PointCloud.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_PointCloud.ipynb `