Returns a handle to a point cloud file.
Overview
int pcopenlod(string filename, string Pchannel, vector P, float min_size, int min_pts, int max_depth, ...)
This function opens a point cloud file (.pc) and queues up access to the
points contained in it. You can then iterate over the points with
pcunshaded or pciterate and add new data to the point cloud using
pcexport.
While this function is similar to pcopen, the major difference is the points that it queues up may be aggregates of entire groups of points. In other words, a single point may represent many points. This allows you to perform queries at any desired level of detail without ignoring points in the point cloud. For example, you can perform a query in which points near the query origin are queued up as usual, but points far from the origin are averaged. This can lead to dramatic performance increases because entire groups of points can be processed as if they are a single point.
As in pcopen, P specifies the query origin and Pchannel specifies the position channel. min_size, min_pts, and max_depth control the construction of a tree structure that is used to sort the points in a point cloud. The tree structure starts out as a single bounding box that encompasses all the points in a point cloud, and is recursively subdivided until certain conditions are met. Either a subdivided box is smaller than min_size, has fewer points than min_pts, or is the result of max_depth subdivisions. Sensible defaults are 0.000001 for min_size (this will depend on the scene scale), 8 for min_pts, and 10 for max_depth.
Queries are performed by descending the tree structure from the root node
until some condition is met. Conceptually, you start with a coarse
query and refine it until you decide that it is detailed enough. You use a
measure and a threshold to decide when the query has the desired level
of detail. The threshold is a fixed value while the measure is computed for
a particular subdivision box in the tree structure. The query halts when the
computed measure value for a box is greater than the threshold. Two measure
values are supported: distance and solidangle. distance mode is
provided for compatibility with pcopen and does not queue up aggregate
points. In this case, the threshold parameter is equivalent to the radius
passed to pcopen. For example, calling pcopenlod(..., measure,
distance, threshold, radius, ...) queues up points that lie within the
specified radius of the query origin.
For solidangle, the measure for a box is computed as follows:
Ai / ||Pi - P||^2,
where Ai is an aggregate area value, Pi is an aggregate position value, and
P is the query origin. Calling pcopenlod(..., measure, solidangle,
area, A, threshold, 0.001, ...) performs a solid-angle query in
which the A channel is assumed to hold area values.
Additional string parameters indicate how point values are aggregated. Each
channel can have a different aggregation mode: mean, sum, or
weighted. Calling pcopenlod(..., aggregate:P, sum) will aggregate
the values in channel P by summing them. Calling pcopenlod(...,
aggregate:A, weighted, weight, W) will aggregate the values in
channel A using a weighted mean with weights from channel W.
Example: Proximity Query
int handle = pcopenlod(texturename, "P", P, 1e-6, 8, 10, "measure", "distance", "threshold", 2.0, "aggregate:P", "mean", "aggregate:value", "sum"); Cf = 0; while (pciterate(handle)) { pcimport(handle, "value", valueSum); Cf += valueSum; } pcclose(handle);
Example: Solid-angle Query
handle = pcopenlod(texturename, "P", P, 1e-6, 8, 10, "measure", "solidangle", "area", "A", "threshold", 0.01, "aggregate:A", "sum", "aggregate:irradiance", "weighted", "weight", "A", "aggregate:P", "mean"); Cf = 0; while (pciterate(handle)) { pcimport(handle, "irradiance", irradiance); Cf += irradiance; } pcclose(handle);