02_user_tutorials:06_complex_objects:01_pointcloud:01_pointcloud-io
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| 02_user_tutorials:06_complex_objects:01_pointcloud:01_pointcloud-io [2025/01/24 16:22] – removed - external edit (Unknown date) 127.0.0.1 | 02_user_tutorials:06_complex_objects:01_pointcloud:01_pointcloud-io [2025/02/19 15:51] (current) – ↷ Links adapted because of a move operation gaetan | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== I/O Point Cloud ====== | ||
| + | |||
| + | The import formats both for files and object representation in GroIMP presented in this tutorial are mostly coming from the plugin [[https:// | ||
| + | |||
| + | GroIMP support two ways of defining a point cloud object: | ||
| + | - As an array: the points coordinates are stored in the array, and the object is considered as one node in the project graph. | ||
| + | - As a graph: each point is built in a node of the project graph. This representation enables links between nodes and possible meshes imported (e.g. ply files can support point, line and faces). | ||
| + | |||
| + | |||
| + | Other point cloud tutorials: | ||
| + | * [[02_user_tutorials: | ||
| + | * [[02_user_tutorials: | ||
| + | |||
| + | ===== Import ===== | ||
| + | |||
| + | The easiest way to add a Point cloud object in GroIMP is by importing them through the menu bar. See [[02_user_tutorials: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | It is however also possible to import a file from the RGG code in a Java block: | ||
| + | |||
| + | <code java> | ||
| + | importNodeFromFile( "/ | ||
| + | |||
| + | </ | ||
| + | |||
| + | The file at the given path will be loaded with the filter associated with the given mimetype from GroIMP. The node created is automatically added to the scene under the root node of the project graph. | ||
| + | Additionally the node can only be loaded, meaning it is not added to the graph but provided as a variable. | ||
| + | <code java> | ||
| + | Node x = loadNodeFromFile( "/ | ||
| + | </ | ||
| + | |||
| + | Both ways loading and importing can also work with input streams instead of file paths. | ||
| + | |||
| + | The MimeTypes used for Point cloud import in GroIMP are : | ||
| + | * " | ||
| + | * " | ||
| + | * " | ||
| + | * " | ||
| + | |||
| + | ==== As array ==== | ||
| + | |||
| + | It is the most common approach to consider point clouds as it is the most memory efficient one. However, from an array, the XL queries and graph operations are not possible on the points of the point cloud. More over, a point cloud stored as an array can only contains " | ||
| + | |||
| + | To import a point cloud as array you can use the GUI (make sure to select the correct mimetype - one that includes to //array// point cloud): | ||
| + | |||
| + | {{: | ||
| + | |||
| + | The two current available format are xyz and ply. Even if PLY enables to include " | ||
| + | The file could also have been imported with the RGG method (using a mimetype that contains //array//): | ||
| + | |||
| + | <code java> | ||
| + | importNodeFromFile( "/ | ||
| + | </ | ||
| + | |||
| + | In both case, the point cloud is imported behind a single graph Node linked to the root (an // | ||
| + | |||
| + | The point cloud' | ||
| + | |||
| + | <code java> | ||
| + | [pc: | ||
| + | [pc: | ||
| + | </ | ||
| + | |||
| + | The first command will print the //Cloud// (de.grogra.pointcloud.groimp.Cloud object), which is the class holding the knowledge of the Points. The second command will print a float array containing the coordinate of all the points. | ||
| + | ==== As Graph ==== | ||
| + | |||
| + | Point clouds can also be imported as Graph that follow the structure: | ||
| + | * **CloudGraph**: | ||
| + | * **Intermediate nodes**: these nodes are used to balance the //Points// of the point cloud to the point cloud node. | ||
| + | * **PointCloudLeaf**: | ||
| + | * LeafPointImpl: | ||
| + | * LeafLineImpl: | ||
| + | * LeafMeshImpl: | ||
| + | |||
| + | To import a point cloud file into groimp you can use the GUI, or the RGG command, (making sure the mimetype selected include //to graph pointcloud// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | <code java> | ||
| + | importNodeFromFile( "/ | ||
| + | </ | ||
| + | |||
| + | The given example import a XYZ file, which only contains Points. So the graph created is of the structure: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | If you import a PLY file that include both vertices and Faces (and/or Lines), GroIMP will create two (or three) point cloud nodes, one per type of object to import from the PLY file. | ||
| + | Each of these point cloud nodes are added under a // | ||
| + | |||
| + | {{: | ||
| + | |||
| + | This very simple example of a PLY file with 3 vertices and one face show that the face is imported as a LeafMeshImpl (which extends MeshNode - the default mesh node of GroIMP). The LeafMesh is linked to the points that defines it by // | ||
| + | |||
| + | Similarly to the point cloud as array, the cloud nodes can be accessed with RGG commands: | ||
| + | |||
| + | <code java> | ||
| + | [pc: | ||
| + | [pc: | ||
| + | </ | ||
| + | |||
| + | As the point cloud //Points// are part of the GroIMP project graph, the //Points// are accessible through XL queries for both execution and rewriting: | ||
| + | |||
| + | <code java> | ||
| + | import de.grogra.pointcloud.objects.PointCloudLeaf | ||
| + | [p: | ||
| + | // the next query replace each point by a new point with the same coordinate | ||
| + | [p: | ||
| + | </ | ||
| + | |||
| + | By creating a GroIMP module that extends LeafMeshImpl and define methods to process intercepted light, the point clouds of LeafMesh can easily be intercepting light at the //Point// level. | ||
| + | |||
| + | ===== Export ===== | ||
| + | |||
| + | As they are part of the GroIMP 3d scene, the point cloud object are included in the standards 3d scene exports. | ||
| + | |||
| + | Point cloud can additionally be exported as point clouds of the two same format as the import: XYZ and PLY. | ||
| + | The XYZ export only export //Points// that contains exactly 3 coordinates (the meshes and lines are ignored). | ||
| + | |||
| + | The PLY format export all //Points//, including meshes and lines. Meshes and Lines are using the existing LeafPoint if they exists and they are linked by Refinement edges. Otherwise they create new point on the fly for the export. | ||
| + | |||
| + | The point cloud export can be accessed from the GUI under //3d view> view> export... > pointclouds// | ||
| + | |||
| + | {{: | ||
| + | |||
| + | There are three possible export commands: | ||
| + | * Export all in one: All the point clouds in the scene are exported into one file. The user needs to select one file in the GUI prompt. This method export the **Global coordinates of the Points**. | ||
| + | * One per file: Each point cloud is exported to a separate file. For each point cloud a new prompt from the GUI will is required. This method export the **Local coordinates of the Points**. | ||
| + | * Selected: Export the selected point clouds (can be several). Each point cloud prompt a GUI file selection. This method export the **Local coordinates of the Points**. | ||
