scenic.core.utils
Assorted utility functions.
Summary of Module Members
Functions
|
|
|
|
|
|
Decorator for making a method with no arguments cache its result |
|
Decorator for making a method cache its result on a per-object basis. |
|
|
|
Attempt to repair a mesh, returning a proper 2-manifold. |
|
Attempt to merge mesh bodies, raising a |
Classes
Dictionary which is the identity map by default. |
Member Details
- cached_method(oldMethod)[source]
Decorator for making a method cache its result on a per-object basis.
Like
functools.lru_cache(maxsize=None)
except using a separate cache for each object, with the cache automatically deallocated when the object is garbage collected.
- unifyMesh(mesh, verbose=False)[source]
Attempt to merge mesh bodies, raising a
ValueError
if something fails.Should only be used with meshes that are volumes.
If a mesh is composed of multiple bodies, the following process is applied: 1. Split mesh into volumes and holes. 2. From each volume, subtract each hole that is fully contained. 3. Union all the resulting volumes.
- repairMesh(mesh, pitch=0.015625, verbose=True)[source]
Attempt to repair a mesh, returning a proper 2-manifold.
Repair is attempted via several steps, each sacrificing more accuracy but with a higher chance of returning a proper volumetric mesh.
Repair is first attempted with easy fixes, like merging vertices and fixing winding. These will usually not deteriorate the quality of the mesh.
Repair is then attempted by voxelizing the mesh, filling it, and then running marching cubes on the mesh. This approach is somewhat accurate but always produces solid objects. (This is to be expected since non watertight hollow objects aren’t well defined).
Repair is finally attempted by using the convex hull, which is unlikely to be accurate but is guaranteed to result in a volume.
NOTE: For planar meshes, this function will throw an error.
- Parameters:
mesh – The input mesh to be repaired.
pitch – The target pitch to be used when attempting to repair the mesh via voxelization. A lower pitch uses smaller voxels, and thus a closer approximation, but can require significant additional processsing time. The actual pitch used may be larger if needed to get a manifold mesh.
verbose – Whether or not to print warnings describing attempts to repair the mesh.