- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am implementing my own custom point cloud engine because Revit's internal point cloud engine does not provide the entire list of points in point cloud. A sample code in the Revit SDK gave me a lot of questions and opportunity of learning Revit APIs.
My engine works somehow, but the point cloud appears as if it is broken at distant zoom levels.
While I was trying to figure out what is wrong,
I found the following statement in the Revit API docs:
[http://www.revitapidocs.com/2016/d5e8d1d7-9375-ce6b-ff4f-6d4764c92736.htm]
IPointCloudAccess
"An instance of this class will be requested by Revit when drawing the point cloud in the view. For performance reasons, when rendering every frame Revit asks the engine to fetch the necessary points split into multiple batches. The number of batches requested depends on the view: the smaller the projection of the cloud bounding box on the screen the fewer batches Revit requests. Revit assumes that each batch contains points uniformly distributed over the visible part of the cloud ("visible" as defined by the filter). Thus, the points supplied by the engine should not be geometrically distinct (e.g. divided into multiple independent volumes, because at distant zoom levels Revit will only request a few batches and only part of the cloud will be displayed."
Revit fetches point clouds from custom point cloud engines using an iterator class inherited by IPointSetIterator.
After the engines are registered to the Revit's PointCloudEngineRegistry class, Revit calls ReadPoints methods of the target point clouds' IPointSetIterator class instance.
I think that the "batch" means the invocation of IPointSetIterator.ReadPoints method.
The description means that the number of batches decreases as the zoom level goes distant, thus the fewer batches fetch the fewer points.
I check my point cloud engine and it turns out that it did not care at all.
However, do you think that it is more reasonable that each batch fetches the smaller (and fixed) amount of points with the same number of batches, instead of decreasing the number of batches?
The following source code is the declaration of IPointSetIterator which is used as an interface of point cloud access iterator of custom point cloud engines (metadata):
using System;
namespace Autodesk.Revit.DB.PointClouds
{
public interface IPointSetIterator
{
...
//
// Summary:
// Implement this method to fill the provided buffer with points up to the number
// of maximum points for which the buffer was allocated.
//
// Parameters:
// buffer:
// Memory buffer into which the points should be written. The buffer was allocated
// by Revit and it is guaranteed to be valid for the duration of the call.
//
// bufferSize:
// The maximum number of CloudPoint objects that may be copied into the buffer.
//
// Returns:
// The actual number of CloudPoint objects placed in the buffer (can be less than
// the length of the buffer). If there are no more points available, return 0.
int ReadPoints( IntPtr buffer, int bufferSize );
}
}
Revit calls the ReadPoints methods iteratively until the exact amount of points that Revit requires.
The bufferSize parameter is not fixed. Revit keep changing the size of buffer through the successive calls.
The number of calls is also not fixed. Revit tries calling the methods, changing the size of buffer.
I tested my own add-in that handles 544,285 points of point cloud.
At first, the batches requires 262,144 points, which means the bufferSize was set to 262144.
Note that the number 262,144 is not half of 544,285.
That makes me assume that the number is not decided as a result of calculation related to the total number of points in the point cloud.
After some of the points are provided, the size is set to 209,254, and 186,387 after that, and so on.
When I try again, the size becomes another random number. I am not sure it is random, but to me, it looks like random.
I don't know what is going on except for the fact that it is decreasing.
There is no description about how Revit decides the sizes of those buffers.
The engines cannot presume how many batches will eventually occur, so they cannot decide how many points they should provide to make the distribution of the points uniform. In order to make each batch contains the points uniformly distributed, the engines have to know how many batches will be executed, and how many points each batch requires, so that the engine can prepare the points (for example, they can filter out uniformly distributed portion of their points).
Solved! Go to Solution.