| 6 | from ..meshio import form_mesh |
| 7 | |
| 8 | class Inflator(object): |
| 9 | def __init__(self, wire_network): |
| 10 | self.logger = logging.getLogger(__name__) |
| 11 | self.wire_network = wire_network |
| 12 | |
| 13 | # Geometry correction. |
| 14 | self.rel_geometry_correction = None |
| 15 | self.abs_geometry_correction = None |
| 16 | self.geometry_correction_cap = None |
| 17 | self.geometry_spread = None |
| 18 | self.geometry_correction_lookup = None |
| 19 | |
| 20 | # Wire profile |
| 21 | self.profile = None |
| 22 | |
| 23 | # Post-subdivision |
| 24 | self.subdivide_order = 1 |
| 25 | self.subdivide_method="simple" |
| 26 | |
| 27 | def set_geometry_correction(self, |
| 28 | rel_geometry_correction=None, |
| 29 | abs_geometry_correction=None, |
| 30 | geometry_correction_cap=None, |
| 31 | geometry_spread=None, |
| 32 | geometry_correction_lookup=None): |
| 33 | self.rel_geometry_correction = rel_geometry_correction |
| 34 | self.abs_geometry_correction = abs_geometry_correction |
| 35 | self.geometry_correction_cap = geometry_correction_cap |
| 36 | self.geometry_spread = geometry_spread |
| 37 | self.geometry_correction_lookup = geometry_correction_lookup |
| 38 | |
| 39 | def set_profile(self, N): |
| 40 | """ Set the cross section shape of each wire to N-gon. |
| 41 | """ |
| 42 | if self.wire_network.dim != 3: |
| 43 | raise NotImplementedError("Wire profile only works in 3D.") |
| 44 | self.profile = PyMesh.WireProfile.create_isotropic(N) |
| 45 | |
| 46 | def set_refinement(self, order=1, method="loop"): |
| 47 | """ Refine the output mesh using subdivision. |
| 48 | |
| 49 | Arguments: |
| 50 | order: how many times to subdivide. |
| 51 | mehtod: which subdivision scheme to use. |
| 52 | Options are ``loop`` and ``simple``. |
| 53 | """ |
| 54 | if not isinstance(order, int) or order < 0: |
| 55 | raise RuntimeError("Invalid subdivision order: {}".format(order)) |
| 56 | if method not in ("loop", "simple"): |
| 57 | raise NotImplementedError( |
| 58 | "Unsupport subdivision method: {}".format(method)) |
| 59 | |
| 60 | self.subdivide_order = order |
| 61 | self.subdivide_method = method |
| 62 | |
| 63 | def inflate(self, thickness, per_vertex_thickness=True, |
| 64 | allow_self_intersection=False): |
| 65 | wires = self.wire_network.raw_wires |
no outgoing calls