Drawings SDK Developer Guide > Working with .dwg Files > Working with Entities > Working with Specific Entitites > Working with Point Clouds > Rendering Point Clouds
Rendering Point Clouds

There are many point cloud file formats, some of which are rather straight-forward such as text files with enumerated X, Y, Z coordinates. Rendering a set of points looks like a trivial task: polyline() call with 2 coinciding vertices is used to render each point. But point cloud files can contain millions and even billions of points produced by scanners.

To render billions of points with reasonable performance, the process can be optimized by rendering only a subset of points based on visible volume, limited points density, etc.

Two file formats of point clouds can be inserted into .dwg files:

  • .pcg
  • .isd

These files contain:

  • for each point, coordinates and optionally attributes such as color, luminance, etc.
  • index data for performance optimization.

A special point cloud engine is required to process billions of points with suitable performance.

Currently the Drawings SDK does not provide support for reading and rendering .pcg and .isd files, but provides a hook for client implementation using third-party engines and libraries.

Example

See the following folder for a sample implementation of reading and rendering .pcg files:

Drawing/Examples/ExPointCloudHost

Its performance is acceptable for 1 million points but may be not sufficient for larger models.

Loading the PointCloudHost.tx module registers implementation of OdDbPointCloudHostPE protocol extension for the OdDbPointCloudDef class.

OdDbPointCloudHostPE has only one function to implement:

  virtual OdResult load(const OdString& strPath, OdDbPointCloudItemPtr& item) = 0;

Given a valid file path (findFile() was already invoked), it returns a pointer to the class implementing the OdDbPointCloudItem interface.

Note: It can return a pointer to different implementations, for example, based on file format.

The class implementing the OdDbPointCloudItem interface can store any cached data. An instance of this class will be destroyed together with the OdDbPointCloudDef class that owns it.

Methods to be implemented in OdDbPointCloudItem inheritor are:

  virtual OdGeExtents3d extents() const = 0;
  virtual OdInt64 pointsCount() const = 0;
  virtual bool worldDrawPoints(const OdDbPointCloud* pEnt, OdGiWorldDraw* pWd) const = 0;
  virtual void viewportDrawPoints(const OdDbPointCloud* pEnt, OdGiViewportDraw* pWd) const = 0;

If the rendering implementation does not use optimization by viewport properties, worldDrawPoints() should be implemented to do the task and return True. Otherwise it should return False and viewportDrawPoints() will be called for each viewport.

Note: Drawings SDK takes care of transformations and clipping boundaries, so these methods are expected to just call polyline(), possibly with setting a point’s properties such as color.

See Also

Working with Point Clouds

Working with Point Cloud Definitions

Working with Point Cloud Entities

Inserting a Point Cloud into a Drawing

Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.