def collect_shapes( self, loc, quality, deviation, angular_tolerance, edge_accuracy, render_edges, render_normals, progress=None, timeit=False, ): # A first rough estimate of the bounding box. # Will be too large, but is sufficient for computing the quality with Timer(timeit, self.name, "compute quality:", 2) as t: bb = bounding_box(self.shape, loc=loc, optimal=False) quality = compute_quality(bb, deviation=deviation) t.info = str(bb) normals_len = 0 if render_normals is False else quality / deviation * 5 with Timer(timeit, self.name, "tessellate: ", 2) as t: mesh = tessellate( self.shape, quality=quality, angular_tolerance=angular_tolerance, normals_len=normals_len, debug=timeit, compute_edges=render_edges, ) t.info = f"{{quality:{quality:.4f}, angular_tolerance:{angular_tolerance:.2f}}}" # After meshing the non optimal bounding box is much more exact with Timer(timeit, self.name, "bounding box: ", 2) as t: bb2 = bounding_box(self.shape, loc=loc, optimal=False) bb2.update(bb, minimize=True) t.info = str(bb2) if progress: progress.update() color = [c.web_color for c in self.color] if isinstance( self.color, tuple) else self.color.web_color return { "id": self.id, "type": "shapes", "name": self.name, "shape": mesh, "color": color, "bb": bb2.to_dict(), }
def collect_shapes( self, path, loc, deviation, angular_tolerance, edge_accuracy, render_edges, parallel=False, progress=None, timeit=False, ): self.id = f"{path}/{self.name}" bb = bounding_box(self.shape, loc=wrapped_or_None(loc)) if progress is not None: progress.update() return { "id": self.id, "type": "vertices", "name": self.name, "shape": [get_point(vertex) for vertex in self.shape], "color": self.color.web_color, "size": self.size, "bb": bb.to_dict(), }
def collect_shapes( self, loc, quality, deviation, angular_tolerance, edge_accuracy, render_edges, render_normals, progress=None, timeit=False, ): bb = bounding_box(self.shape, loc=loc) if progress: progress.update() return { "id": self.id, "type": "vertices", "name": self.name, "shape": [get_point(vertex) for vertex in self.shape], "color": self.color.web_color, "bb": bb, }
def collect_shapes( self, path, loc, deviation, angular_tolerance, edge_accuracy, render_edges, parallel=False, progress=None, timeit=False, ): self.id = f"{path}/{self.name}" with Timer(timeit, self.name, "bounding box:", 2) as t: bb = bounding_box(self.shape, loc=wrapped_or_None(loc)) quality = compute_quality(bb, deviation=deviation) deflection = quality / 100 if edge_accuracy is None else edge_accuracy t.info = str(bb) with Timer(timeit, self.name, "discretize: ", 2): edges = [] for edge in self.shape: edges.extend(discretize_edge(edge, deflection)) edges = np.asarray(edges) if progress: progress.update() color = [c.web_color for c in self.color] if isinstance( self.color, tuple) else self.color.web_color return { "id": self.id, "type": "edges", "name": self.name, "shape": edges, "color": color, "width": self.width, "bb": bb.to_dict(), }
def collect_shapes( self, loc, quality, deviation, angular_tolerance, edge_accuracy, render_edges, render_normals, progress=None, timeit=False, ): with Timer(timeit, self.name, "bounding box:", 2) as t: bb = bounding_box(self.shape, loc=loc) quality = compute_quality(bb, deviation=deviation) deflection = quality / 100 if edge_accuracy is None else edge_accuracy t.info = str(bb) with Timer(timeit, self.name, "discretize: ", 2): edges = flatten( [discretize_edge(edge, deflection) for edge in self.shape]) if progress: progress.update() color = [c.web_color for c in self.color] if isinstance( self.color, tuple) else self.color.web_color return { "id": self.id, "type": "edges", "name": self.name, "shape": edges, "color": color, "bb": bb, }
def collect_shapes( self, path, loc, deviation, angular_tolerance, edge_accuracy, render_edges, parallel=False, progress=None, timeit=False, ): self.id = f"{path}/{self.name}" # A first rough estimate of the bounding box. # Will be too large, but is sufficient for computing the quality with Timer(timeit, self.name, "compute quality:", 2) as t: bb = bounding_box(self.shape, loc=wrapped_or_None(loc), optimal=False) quality = compute_quality(bb, deviation=deviation) t.info = str(bb) with Timer(timeit, self.name, "tessellate: ", 2) as t: func = mp_tessellate if parallel else tessellate result = func( self.shape, loc_to_tq(wrapped_or_None(loc)), deviation=deviation, quality=quality, angular_tolerance=angular_tolerance, debug=timeit, compute_edges=render_edges, ) t.info = f"{{quality:{quality:.4f}, angular_tolerance:{angular_tolerance:.2f}}}" if parallel and is_apply_result(result): mesh = result bb = {} else: mesh, bb = result if progress is not None: progress.update() if isinstance(self.color, tuple): color = [c.web_color for c in self.color] # pylint: disable=not-an-iterable else: color = self.color.web_color return { "id": self.id, "type": "shapes", "name": self.name, "shape": mesh, "color": color, "renderback": self.renderback, "accuracy": quality, "bb": bb, }