Fit Primitives#
Key: fitPrimitives
This operation attempts to fit transformed primitive shapes (sphere, cylinder, cone, or
cube) to selected meshes. If a mesh can be fit within tolerance it is replaced with the best-fitting
transformed primitive. fitSphere, fitCylinder, fitCone, and fitCube (all default
true) select which primitive types are attempted, in any combination.
Tolerances and units#
Fitting is governed by two relative tolerances, so they are independent of metersPerUnit and
scene scale:
vertexTolerance(default0.01) is the allowed RMS distance between mesh and primitive surface, relative to the mesh size. Lower it to accept only close fits, raise it to fit more loosely.volumeTolerance(default0.01) is the allowed relative difference in enclosed volume.
A mesh is replaced only when it passes both. gpuFaceCountThreshold selects the GPU path above a face
count (0 keeps everything on CPU).
Footguns#
ignoreNonConstPrimvars and ignoreSubsets (both default true) are permissive: when true a
mesh with varying primvars or geom subsets can still be replaced (losing that data). Set them false
to refuse fitting meshes that carry such data. generateMeshes (default false) emits a tessellated
mesh approximation instead of a true gprim; leave it false to get actual Sphere/Cylinder/etc.
prims, which are lighter.
Recommended pipelines#
Run before deduplicateGeometry so the resulting primitives can be instanced, and after a cleanup pass
on noisy meshes. A common chain is meshCleanup -> fitPrimitives -> deduplicateGeometry.
Starting configurations#
Default fit (all primitive types):
[{"operation": "fitPrimitives", "vertexTolerance": 0.01, "volumeTolerance": 0.01}]
Strict fit, true gprims only, refuse meshes with subsets/varying primvars:
[{"operation": "fitPrimitives", "vertexTolerance": 0.005, "ignoreSubsets": false, "ignoreNonConstPrimvars": false}]
Arguments#
Meshes to fit#
Optional list of prim paths to consider
Name:
pathsType:
[string]Default Value:
[]
GPU face count threshold#
For meshes with at least this many faces, use GPU algorithm. A value of zero forces CPU.
Name:
gpuFaceCountThresholdType:
intDefault Value:
0Min Value:
0.0
Show fitting parameters#
Tolerances and filters used to determine quality of fit.
Name:
showFittingParametersType:
boolDefault Value:
True
Vertex error tolerance#
Relative tolerance of RMS distance from fit vertices to primitive surface.
Name:
vertexToleranceType:
floatDefault Value:
0.01Min Value:
0.0
Volume error tolerance#
Relative tolerance of volume between faces and the fitting primitive.
Name:
volumeToleranceType:
floatDefault Value:
0.01Min Value:
0.0
Ignore non-const primvars#
If set, a mesh with non-constant primvars is allowed to be fit. If replaced by a primitive, any non-constant primvars will be lost.
Name:
ignoreNonConstPrimvarsType:
boolDefault Value:
True
Ignore subsets#
If set, a mesh with subsets is allowed to be fit. If replaced by a primitive, any subsets will be lost.
Name:
ignoreSubsetsType:
boolDefault Value:
True
Allow negative volume#
If set, a mesh with negative volume (inward-pointing normals) is allowed to be fit.
Name:
allowNegativeVolumeType:
boolDefault Value:
True
Allow missing endcaps#
If set, a cylinder, cone, or box mesh without endcaps is allowed to be fit.
Name:
allowMissingEndcapsType:
boolDefault Value:
True
Fit sphere#
Attempt to fit a transformed sphere to selected meshes
Name:
fitSphereType:
boolDefault Value:
True
Fit cylinder#
Attempt to fit a transformed cylinder to selected meshes
Name:
fitCylinderType:
boolDefault Value:
True
Fit cone#
Attempt to fit a transformed cone to selected meshes
Name:
fitConeType:
boolDefault Value:
True
Fit cube#
Attempt to fit a transformed cube to selected meshes
Name:
fitCubeType:
boolDefault Value:
True
Generate meshes#
If set, a mesh will be generated instead of a primitive shape.
Name:
generateMeshesType:
boolDefault Value:
False
Sphere longitude divisions#
The number of longitudinal divisions in which to divide spheres. Must be at least 3.
Name:
sphereLongitudeDivisionsType:
intDefault Value:
32Min Value:
3.0
Sphere latitude divisions#
The number of latitudinal divisions in which to divide spheres. Must be at least 2.
Name:
sphereLatitudeDivisionsType:
intDefault Value:
16Min Value:
2.0
Cylinder wall divisions#
The number of divisions to make around the cylinder wall. Must be at least 3.
Name:
cylinderWallDivisionsType:
intDefault Value:
32Min Value:
3.0
Cylinder length divisions#
The number of end-to-end divisions to make along the cylinder. Must be positive.
Name:
cylinderLatitudeDivisionsType:
intDefault Value:
1Min Value:
1.0
Generate cylinder endcaps#
Whether or not to add endcaps to generated cylinder meshes.
Name:
cylinderEndcapsType:
boolDefault Value:
True
Cone side divisions#
The number of divisions to make around the side of the cone. Must be at least 3.
Name:
coneSideDivisionsType:
intDefault Value:
64Min Value:
3.0
Cone length divisions#
The number of divisions to make along the length of the cone. Must be positive.
Name:
coneLengthDivisionsType:
intDefault Value:
3Min Value:
1.0
Generate cone bases#
Whether or not to add a base to generated cone meshes.
Name:
coneBasesType:
boolDefault Value:
True