MCPcopy Create free account
hub / github.com/apple/ml-pointersect / __init__

Method __init__

pointersect/inference/structures.py:3243–3270  ·  view source on GitHub ↗
(
            self,
            mesh: T.Union[o3d.geometry.TriangleMesh, str],
            scale: T.Optional[float] = 1.,
            center_w: T.Optional[T.List[float]] = (0., 0., 0.),
            preprocess_mesh: bool = True,
    )

Source from the content-addressed store, hash-verified

3241
3242class Mesh:
3243 def __init__(
3244 self,
3245 mesh: T.Union[o3d.geometry.TriangleMesh, str],
3246 scale: T.Optional[float] = 1.,
3247 center_w: T.Optional[T.List[float]] = (0., 0., 0.),
3248 preprocess_mesh: bool = True,
3249 ):
3250 if isinstance(mesh, str):
3251 # load mesh
3252 mesh: o3d.geometry.TriangleMesh = o3d.io.read_triangle_mesh(
3253 mesh, enable_post_processing=True)
3254
3255 # preprocess mesh (clean uv, shift to center, rescale to [-scale, scale])
3256 mesh = mesh_utils.preprocess_mesh(
3257 mesh=mesh,
3258 scale=scale,
3259 center_w=center_w,
3260 clean=preprocess_mesh
3261 )
3262
3263 self.scale = np.max(mesh.get_axis_aligned_bounding_box().get_half_extent())
3264 self.center_w = mesh.get_axis_aligned_bounding_box().get_center()
3265 self.mesh = mesh
3266
3267 # for ray tracing
3268 mesh_t = o3d.t.geometry.TriangleMesh.from_legacy(self.mesh)
3269 self.scene = o3d.t.geometry.RaycastingScene()
3270 self.scene.add_triangles(mesh_t)
3271
3272 def replace_texture(self, texture_imgs: T.List[np.ndarray]):
3273 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected