.. 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 Click :ref:`here ` 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:: default 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-36 .. code-block:: default [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 37-38 Create a point cloud from the X, Y and Z arrays with further intensity information. .. GENERATED FROM PYTHON SOURCE LINES 38-40 .. code-block:: default cloud1 = pointCloud.fromXYZI(X, Y, Z, I) .. GENERATED FROM PYTHON SOURCE LINES 41-42 Create a point cloud from the topography image with further colour information. .. GENERATED FROM PYTHON SOURCE LINES 42-44 .. code-block:: default cloud2 = pointCloud.fromTopography(topography, color=C) .. GENERATED FROM PYTHON SOURCE LINES 45-46 Create a point cloud from the X, Y and Z arrays with further colour information. .. GENERATED FROM PYTHON SOURCE LINES 46-48 .. code-block:: default cloud3 = pointCloud.fromXYZRGBA(X, Y, Z, C) .. GENERATED FROM PYTHON SOURCE LINES 49-50 Create a point cloud from the X, Y and Z arrays with the Z-values as intensity information. .. GENERATED FROM PYTHON SOURCE LINES 50-52 .. code-block:: default cloud4 = pointCloud.fromXYZI(X, Y, Z - 0.1, Z) .. GENERATED FROM PYTHON SOURCE LINES 53-55 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 55-70 .. code-block:: default 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 71-72 Create polygonal mesh structure from cloud3 and polygons. .. GENERATED FROM PYTHON SOURCE LINES 72-74 .. code-block:: default mesh = polygonMesh.fromCloudAndPolygons(cloud3, polygons) .. GENERATED FROM PYTHON SOURCE LINES 75-78 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 78-80 .. code-block:: default mesh2 = polygonMesh.fromOrganizedCloud(cloud2) .. GENERATED FROM PYTHON SOURCE LINES 81-82 Create GUI (3D Viewer) .. GENERATED FROM PYTHON SOURCE LINES 82-98 .. code-block:: default 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.783 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-python :download:`Download Python source code: demo_cloudViewer.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_cloudViewer.ipynb `