|
Easy3D 3.0.0
|
Attaching per-point attributes (here, colors) to a PointCloud using named properties.
Overview
Building on Tutorial_101_PointCloud, this console tutorial shows how to store extra data alongside each point. We synthesize the same 10 x 10 grid of points, give every point a random color, then read back both the coordinates and the colors and print them. No viewer is opened; the goal is to understand Easy3D's property system, which underpins almost all geometry processing in the library.
The technique
A property (a.k.a. a property map) is a parallel array: one value per mesh element, addressed by the element's handle. Rather than a struct-of-fields per point, Easy3D keeps each attribute in its own contiguous array, so adding or removing an attribute never disturbs the others and iteration stays cache-friendly. Properties are identified by a unique string name. By convention a prefix says which element type the property lives on: "v:" for vertices, "e:" for edges, "f:" for faces (the prefix is optional but recommended). The coordinates themselves are just a built-in vertex property named "v:point", so a position is accessed exactly like any other attribute. Creating a property whose name is already in use triggers a warning, which is why every property must be given a distinct name.
Easy3D API
Running it
Console-only. It first prints "point cloud has 100 points", then one line per point giving its index, xyz coordinates, and random color, e.g. "index: 0, xyz: ..., color: ...". The cloud is heap-allocated here and explicitly deleted at the end to release its memory.