Cognite Data Fusion has a concept of "objects" in point clouds, represented by one or more bounding volumes for each object. The objects are backed by the CDF Annotations API. Reveal supports styling individual objects within a point cloud.
In this context, a stylable object is represented by a volume in space. Styling an object results in all points that lie within the corresponding volume to attain the assigned style.
Stylable objects must be supplied separately from the model itself. Upon adding a new point cloud model to the viewer, Reveal will automatically fetch data describing the point cloud objects from CDF's Annotations API, if any are available. To get the number of fetched stylable objects, use the property
model is a
After the model and associated stylable objects are loaded, you may list the objects using
model.traverseStylableObjects. This method traverses all objects as instances of
PointCloudObjectMetadata, containing the following fields:
|The ID of the CDF annotation that this stylable object corresponds to.
|The ID of the CDF asset associated with the annotation, if any.
|The bounding box of the stylable object in Reveal space.
To visualize all bounding boxes associated with the stylable objects:
Point cloud objects can be styled with a
PointCloudAppearance object, containing the following attributes:
|Override color. If all components equal to zero, the override is unused.
|When false, stylable object will be invisible. Default value is
To assign a style to one or more stylable objects, you must first create an instance of the abstract class
PointCloudObjectCollection. Currently, the only implementation of this class provided by Reveal is
AnnotationIdPointCloudObjectCollection, which is initialized with a list of annotation IDs corresponding to stylable objects. To see all available annotation IDs associated with the model, you may use the method
To color all stylable objects green:
After assigning style to an object collection, you may use the property
model.styledCollections to get a list of all object collections and their assigned styles registered on the model.
It is also possible to set a default appearance for the point cloud using the
model.setDefaultPointCloudAppearance. The following example makes all annotated objects visible, while hiding everything else:
Like in CAD styling, stylable objects that are part of multiple styled object collections will attain the appearance of the object set whose first style assignment was last.
Unassigning styled object collections
To reset style of an object collection, use
model.unassignStyledObjectCollection with the previously styled
PointCloudObjectCollection as argument. To reset all styled objects use
Reset all styled object collections
To reset all styled object collections, use the method
This example removes all style on stylable object collections and makes sure the rest of the point cloud is visible.
Point cloud shapes
Currently, the only supported shapes that constitute point cloud objects are cylinders and boxes. The specification for how this data is stored, can be found in the API documentation for Retrieve Annotation under Responses -> 200 Successful retrieval ->
Note that Reveal will visualize the shapes with a somewhat larger size than how they are stored, as to make sure that all points that lie on the surface of the objects also are included as parts of it.