1+ """Example that shows how to add a scalar field
2+ as well as how to make it properly be displayed in the UI
3+ """
4+ import pycc
5+ import numpy as np
6+
7+ xs = np .arange (0.0 , 5.0 , 0.1 , pycc .PointCoordinateType )
8+ ys = np .ones (len (xs ), pycc .PointCoordinateType ) * 18.5
9+ zs = np .ones (len (xs ), pycc .PointCoordinateType ) * 17.33
10+
11+ pc = pycc .ccPointCloud (xs , ys , zs )
12+
13+ # Create and add a new scalar field
14+ idx = pc .addScalarField ("Intensity" )
15+ scalar_field = pc .getScalarField (idx )
16+
17+ # Change the values
18+ sfArray = pc .getScalarField (idx ).asArray ()
19+ num_chunk = 4
20+ chunk_size = len (xs ) // num_chunk
21+ for i in range (num_chunk ):
22+ sfArray [i * chunk_size :(i + 1 )* chunk_size ] = i
23+
24+ # Make it so the scalar field is displayed
25+ scalar_field .computeMinAndMax ()
26+ pc .setCurrentDisplayedScalarField (idx )
27+ pc .showSF (True )
28+
29+ # Optional: choose the color scale
30+ scale = pycc .ccColorScalesManager .GetDefaultScale (
31+ pycc .ccColorScalesManager .YELLOW_BROWN
32+ )
33+ scalar_field .setColorScale (scale )
34+
35+ pc .setName ("Scalar Field Example" )
36+ # Change the point size so that the cloud is more
37+ # visible by default (only needed here as the point cloud
38+ # is very small)
39+ pc .setPointSize (7 )
40+
41+ pycc .GetInstance ().addToDB (pc )
0 commit comments