def plot_boreholes(self, notebook=False, background=False, **kwargs): """ Uses the previously calculated borehole tubes in self._get_polygon_data() when a borehole dictionary is available This will generate a pyvista object that can be visualized with .show() Args: notebook: If using in notebook to show inline background: Returns: Pyvista object with all the boreholes """ self._get_polygon_data() if background: try: p = pv.BackgroundPlotter(**kwargs) except pv.QtDeprecationError: from pyvistaqt import BackgroundPlotter p = BackgroundPlotter(**kwargs) else: p = pv.Plotter(notebook=notebook, **kwargs) for i in range(len(self.borehole_tube)): cmap = self.colors_bh[i] p.add_mesh(self.borehole_tube[i], cmap=[cmap[j] for j in range(len(cmap)-1)], smooth_shading=False) # for i in range(len(self.faults_bh)): # for plotting the faults # TODO: Messing with the colors when faults if len(self.faults_bh) > 0: point = pv.PolyData(self.faults_bh) p.add_mesh(point, render_points_as_spheres=True, point_size=self._radius_borehole) # p.add_mesh(point, cmap = self.faults_color_bh[i], # render_points_as_spheres=True, point_size=self._radius_borehole) extent = numpy.copy(self._model_extent) # extent[-1] = numpy.ceil(self.modelspace_arucos.box_z.max()/100)*100 p.show_bounds(bounds=extent) p.show_grid() p.set_scale(zscale=self._ve) # self.vtk = pn.panel(p.ren_win, sizing_mode='stretch_width', orientation_widget=True) # self.vtk = pn.Row(pn.Column(pan, pan.construct_colorbars()), pn.pane.Str(type(p.ren_win), width=500)) return p
def show_processing(self, mesh): if not mesh: print(f"Can't render mesh of type {type(mesh)}") return None new_data = self.normalizer.mono_run_pipeline(mesh) history = new_data["history"] num_of_operations = len(history) plt = BackgroundPlotter(shape=(2, num_of_operations // 2)) elements = history plt.show_axes_all() for idx in range(num_of_operations): plt.subplot(int(idx / 3), idx % 3) if elements[idx]["op"] == "Center": plt.add_mesh(pv.Cube().extract_all_edges()) curr_mesh = pv.PolyData(elements[idx]["data"]["vertices"], elements[idx]["data"]["faces"]) plt.add_mesh(curr_mesh, color='w', show_edges=True) plt.reset_camera() plt.view_isometric() plt.add_text(elements[idx]["op"] + "\nVertices: " + str(len(curr_mesh.points)) + "\nFaces: " + str(curr_mesh.n_faces)) plt.show_grid()