Map face attribute from mesh1 to mesh2 based on closest points. Args: mesh1 (:class:`Mesh`): Source mesh, where the attribute is defined. mesh2 (:class:`Mesh`): Target mesh, where the attribute is mapped to. attr_name (``string``): Attribute name. bvh (:class:`B
(mesh1, mesh2, attr_name, bvh=None)
| 50 | |
| 51 | |
| 52 | def map_face_attribute(mesh1, mesh2, attr_name, bvh=None): |
| 53 | """ Map face attribute from mesh1 to mesh2 based on closest points. |
| 54 | |
| 55 | Args: |
| 56 | mesh1 (:class:`Mesh`): Source mesh, where the attribute is defined. |
| 57 | mesh2 (:class:`Mesh`): Target mesh, where the attribute is mapped to. |
| 58 | attr_name (``string``): Attribute name. |
| 59 | bvh (:class:`BVH`): Pre-computed Bounded volume hierarchy if available. |
| 60 | |
| 61 | A new attribute with name ``attr_name`` is added to ``mesh2``. |
| 62 | """ |
| 63 | |
| 64 | assert(mesh1.dim == mesh2.dim) |
| 65 | assert(mesh1.has_attribute(attr_name)) |
| 66 | values = mesh1.get_face_attribute(attr_name) |
| 67 | |
| 68 | if not mesh2.has_attribute("face_centroid"): |
| 69 | mesh2.add_attribute("face_centroid") |
| 70 | query_pts = mesh2.get_face_attribute("face_centroid") |
| 71 | |
| 72 | if bvh is None: |
| 73 | bvh = BVH(dim=mesh1.dim) |
| 74 | bvh.load_mesh(mesh1) |
| 75 | dists, closest_faces, p = bvh.lookup(query_pts) |
| 76 | target_val = values[closest_faces, :] |
| 77 | |
| 78 | if not mesh2.has_attribute(attr_name): |
| 79 | mesh2.add_attribute(attr_name) |
| 80 | mesh2.set_attribute(attr_name, target_val) |
| 81 | |
| 82 | def map_corner_attribute(mesh1, mesh2, attr_name, bvh=None): |
| 83 | """ Map per-vertex per-face attribute from mesh1 to mesh2 based on closest points. |
nothing calls this directly
no test coverage detected