====== Point Cloud ====== The objects and tools presented in this wiki mostly comes from the plugin [[https://gitlab.com/grogra/groimp-plugins/Pointcloud|Pointcloud]]. See [[dev-guide:plugins|here]] to see how install plugins in GroIMP. The wiki is up to date with the version 1.8 of the plugin. Tools: * [[groimp-platform:pointcloudtools | Point cloud tools]] * [[groimp-platform:pointcloudfitting | Point cloud shape fitting]] Tutorials: * [[tutorials:pointcloud-IO|Import/Export point clouds]] * [[tutorials:using-point-cloud-to-validate-model|Validating growth model on measured point cloud]] * [[tutorials:using-mesh-clouds-as-organ|Using point clouds with meshes as organs]] ===== Object design ===== In GroIMP point cloud are implemented following the design: scale 700 width Class Node Interface CollectionDisplayable { getDisplayHandler() setDisplayHandler() } Class PointCloud { setCloud() } Interface CloudContext { Cloud getCloud } Interface Cloud { setPoints(Point[]) addPoints(Point[]) getPoints() remove(Object[]) removeAll() float[] pointsToFloat() Point[] floatsToPoints(float[]) } Interface Point { float[] toFloat() } Class PointCloudD Class CloudGraph Class CloudList Class CloudArray Class ArrayPoint Class PointCloudLeaf Node <|-- PointCloud CloudContext <|.. PointCloud CloudContext <|-- Cloud CloudContext <|-- Point CollectionDisplayable <|.. PointCloudD PointCloud <|-- PointCloudD Cloud <|.. CloudGraph Cloud <|.. CloudArray CloudArray <|-- CloudList Point <|.. ArrayPoint Point <|.. PointCloudLeaf Point --* Cloud ArrayPoint --* CloudArray Cloud --o PointCloud PointCloudLeaf --* CloudGraph The main Objects are: * **PointCloud** : A **Node**, i.e. an object that can be inserted in a GroIMP graph. The PointCloud is responsible for the display of the points. In the case of **PointCloudD** the display is managed by implementing **CollectionDisplayable**. * **Cloud** : The representation of the data structure through which the point cloud data is accessed. * **Point** : The base interface that an object must implements to be part of a Cloud. In GroIMP, points are not limited to 3 dimensions. These three Objects implements **CloudContext**, meaning when any of the three is selected, you can access the **Cloud** structure handled. Most of the tools from the package //de.grogra.pointcloud.tools// are applied on Cloud, and produce Cloud objects. The GUI commands however can works with any CloudContext object. ===== GUI Visualization & Interactions ===== The PointCloud visualization in the 3d scene of GroIMP follows the classic GroIMP display scene creation (see [[groimp-platform:3d:visualization|here]] for more detail on how GroIMP build the 3d scene). As part of the GroIMP graph, the PointCloud display follow the local transformations idea. It is displayed after the transformation of each of his potential ancestor in the graph, including his own transformation. The coordinates of the Points are local as well in regards to the PointCloud node. Nodes imported from the GUI menu are added at the root of the graph, thus, PointCloud are by default not having ancestor's transformations to resolve. Because the representation of PointCloud as graph can lead to huge amount of nodes (each Point being a node), the visitation of the graph for every 3d update can be very time consuming. Thus, PointCloud display are using the graph [[groimp-platform:visit-resolution|resolution display tool]], which can keep the display in memory and block visitation of the graph. PointCloud are created with a default resolution index of 3, which can be changed in the [[:user-guide:common_panels#Attribute_Editor|attribute editor]]. The management of the display is push to a **CollectionDisplayHandler**. There are currently three implementations of the interface: * **FloatArrayHandler** : Simply handle float arrays which is the data representation of **CloudArray** and **CloudList**. It can however be used on any type of **Cloud** as they implements //pointsToFloat()//. This DisplayHandler takes a float array of length divisible by three, each point coordinates are in the array stored as: [x0, y0, z0, x1, y1, z1, ...]. * **CollectionPointHandler** : Used to handle a collection of Point that do not have 3d geometry (e.g. imp3d points). It takes a collection of Points as input (either a List or a graph). The collection is visited and each Point display data is stored in the CollectionDisplayHandler. It requires that Points have at least three dimensions and will only includes the three first dimensions as coordinate to display a point in the 3d scene. * **CollectionMeshHandler** : Similarly to the CollectionPointHandler, it visits the given collection, but it uses the 3d geometry of each Point, create a Mesh out of it, and aggregate them into the CollectionMeshHandler. The aggregated Mesh is the displayed object. DisplayHandler require to be pinged to update their data. This can be done manually through the PointCloud using the attribute editor, or automatically when some tools are applied on the PointCloud. {{ :groimp-platform:visualization2.svg |}} The picking is also managed by the PointCloud through the DisplayHandler. By default, the Points are picked on the 3d scene, but a [[3d-guide:view_manipulations#navigate_in_the_scene|navigation mode]] enables to pick the DisplayHandler. ===== Point Cloud as a graph ===== Cloud object can be represented as graph in GroIMP, where both the PointCloud and each Point objects are GroIMP Nodes. This structure enables to leverage the power of XL queries onto the point cloud data both for querying and rewriting. The main objects of a PointCloud as graph are: * **PointCloud**: the Node that is part of the project graph. * **CloudGraph** : the object that extends Cloud. It implements the methods to access/modify the Points. Because the Points of a CloudGraph are Nodes, they can also be accessed and modified through XL queries. * **IntermediateCloudNode** : intermediate nodes used to balance the load of the graph. * **PointCloudLeaf** ; the implementation of Point of the Cloud. PointCloudLeaf extends Node (or subclasses of Node), thus are part of the project graph. GroIMP struggle handling Nodes with huge number of edges. It slows down the graph visiting and the queries processing. Thus, the Cloud data is spread over several layers using IntermediateCloudNode. IntermediateCloudNode are used in order to enables the Points of a PointCloud to be rewritten with minimum modifications in the project graph. Modifications that add/remove/change edges, on Points only affect the leaves of the PointCloud graph. The PointCloudLeaf can extends imp3d objects to have a 3d geometry. The PointCloudLeaf objects are not limited to "point" as they can have any 3d implemented in GroIMP. However, within one Cloud all Points needs to extends the same Class. That class is defined on the Cloud creation and cannot be modified. To replace a Point of a specific class to another, a new Cloud is required. Three base implementation of PointCloudLeaf are available: * **LeafPointImpl** : extends imp3d Point (not to be confused with Point from pointcloud - objects from imp3d are GroIMP objects for the 3d scene see [[3d-guide:3d-manipulations#3d_objects|here]] for more details). * **LeafLineImpl** : extends imp3d Axis. * **LeafMeshImpl** : extends imp3d MeshNode. {{ :groimp-platform:cloudgraph.svg |}}