MCPcopy Create free account
hub / github.com/Simple-Robotics/Simple / loadMesh

Function loadMesh

sandbox/viz_utils.py:238–273  ·  view source on GitHub ↗
(mesh)

Source from the content-addressed store, hash-verified

236
237
238def loadMesh(mesh):
239 if isinstance(mesh, (hppfcl.Convex, hppfcl.BVHModelBase)):
240 if isinstance(mesh, hppfcl.BVHModelBase):
241 num_vertices = mesh.num_vertices
242 num_tris = mesh.num_tris
243
244 call_triangles = mesh.tri_indices
245 call_vertices = mesh.vertices
246
247 elif isinstance(mesh, hppfcl.Convex):
248 num_vertices = mesh.num_points
249 num_tris = mesh.num_polygons
250
251 call_triangles = mesh.polygons
252 call_vertices = mesh.points
253
254 faces = np.empty((num_tris, 3), dtype=int)
255 for k in range(num_tris):
256 tri = call_triangles(k)
257 faces[k] = [tri[i] for i in range(3)]
258
259 vertices = call_vertices()
260
261 vertices = vertices.astype(np.float32)
262
263 if num_tris > 0:
264 mesh = mg.TriangularMeshGeometry(vertices, faces)
265 else:
266 mesh = mg.Points(
267 mg.PointsGeometry(
268 vertices.T, color=np.repeat(np.ones((3, 1)), num_vertices, axis=1)
269 ),
270 mg.PointsMaterial(size=0.002),
271 )
272
273 return mesh
274
275
276def createCapsule(length, radius, radial_resolution=30, cap_resolution=10):

Callers 1

load_primitiveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected