.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\itom\ui\demo_cloudViewer.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_11_demos_itom_ui_demo_cloudViewer.py: Cloud viewer =============== .. GENERATED FROM PYTHON SOURCE LINES 5-22 .. code-block:: Python import numpy as np from itom import pointCloud from itom import polygonMesh from itom import ui from itom import dataObject try: from itom import pointCloud except Exception as ex: ui.msgInformation( "PointCloud missing", "your itom version is compiled without support of pointClouds", ) raise ex .. GENERATED FROM PYTHON SOURCE LINES 24-26 Create a data objects with X, Y and Z values of a topography as well as a 2.5D topography in terms of a data object. .. GENERATED FROM PYTHON SOURCE LINES 26-34 .. code-block:: Python [X, Y] = np.meshgrid(np.arange(0, 5, 0.1), np.arange(0, 5, 0.1)) Z = np.sin(X * 2) + np.cos(Y * 0.5) I = np.random.rand(*X.shape) # further intensity C = dataObject.randN([X.shape[0], X.shape[1]], "rgba32") # further color information topography = dataObject(Z).astype("float32") topography.axisScales = (0.1, 0.1) topography[0, 0] = float("nan") .. GENERATED FROM PYTHON SOURCE LINES 35-36 Create a point cloud from the X, Y and Z arrays with further intensity information. .. GENERATED FROM PYTHON SOURCE LINES 36-38 .. code-block:: Python cloud1 = pointCloud.fromXYZI(X, Y, Z, I) .. GENERATED FROM PYTHON SOURCE LINES 39-40 Create a point cloud from the topography image with further colour information. .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: Python cloud2 = pointCloud.fromTopography(topography, color=C) .. GENERATED FROM PYTHON SOURCE LINES 43-44 Create a point cloud from the X, Y and Z arrays with further colour information. .. GENERATED FROM PYTHON SOURCE LINES 44-46 .. code-block:: Python cloud3 = pointCloud.fromXYZRGBA(X, Y, Z, C) .. GENERATED FROM PYTHON SOURCE LINES 47-48 Create a point cloud from the X, Y and Z arrays with the Z-values as intensity information. .. GENERATED FROM PYTHON SOURCE LINES 48-50 .. code-block:: Python cloud4 = pointCloud.fromXYZI(X, Y, Z - 0.1, Z) .. GENERATED FROM PYTHON SOURCE LINES 51-53 Manually create triangular polygons for the whole surface the polygons are regularly distributed and each rectangle is divided into two polygons. .. GENERATED FROM PYTHON SOURCE LINES 53-68 .. code-block:: Python polygons = dataObject.zeros([2 * 49 * 49, 3], "uint16") c = 0 for row in range(0, 49): for col in range(0, 49): polygons[c, 0] = row * 50 + col polygons[c, 1] = (row + 1) * 50 + col polygons[c, 2] = row * 50 + 1 + col c += 1 for row in range(0, 49): for col in range(0, 49): polygons[c, 0] = (row + 1) * 50 + col polygons[c, 1] = (row + 1) * 50 + col + 1 polygons[c, 2] = row * 50 + col + 1 c += 1 .. GENERATED FROM PYTHON SOURCE LINES 69-70 Create polygonal mesh structure from cloud3 and polygons. .. GENERATED FROM PYTHON SOURCE LINES 70-72 .. code-block:: Python mesh = polygonMesh.fromCloudAndPolygons(cloud3, polygons) .. GENERATED FROM PYTHON SOURCE LINES 73-76 As alternative approach you can directly create the same polygonal mesh from the point cloud if you know that the point cloud is organized, hence, the points are located like in a regular grid. .. GENERATED FROM PYTHON SOURCE LINES 76-78 .. code-block:: Python mesh2 = polygonMesh.fromOrganizedCloud(cloud2) .. GENERATED FROM PYTHON SOURCE LINES 79-80 Create GUI (3D Viewer) .. GENERATED FROM PYTHON SOURCE LINES 80-94 .. code-block:: Python gui = ui("cloudViewer.ui", ui.TYPEWINDOW) # gui.plot.call("addPointCloud",cloud1,"cloud1") # gui.plot.call("addPointCloud",cloud2,"cloud2") # gui.plot.call("addPointCloud",cloud3,"cloud3") gui.plot.call( "addPointCloud", cloud4, "cloud4" ) # visualize cloud4 under the name 'cloud4' gui.plot.call( "setItemProperty", "cloud4", "PointSize", 10 ) # change the property PointSize of this point # gui.plot.call("addMesh",mesh,"mesh") gui.plot.call("addMesh", mesh2, "mesh2") # visualize the mesh2 under the name 'mesh2' gui.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.032 seconds) .. _sphx_glr_download_11_demos_itom_ui_demo_cloudViewer.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_cloudViewer.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_cloudViewer.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: demo_cloudViewer.zip `