(self, **kwargs)
Plots the surface and the control points grid.
Plots the surface and the control points grid.
Plots the surface and the control points grid .
def render(self, **kwargs):
        """ Plots the surface and the control points grid. """
        # Calling parent function
        super(VisSurface, self).render(**kwargs)

        # Initialize variables
        plot_data = []

        for plot in self._plots:
            # Plot control points
            if plot['type'] == 'ctrlpts' and self.vconf.display_ctrlpts:
                pts = np.array(plot['ptsarr'], dtype=self.vconf.dtype)
                pts[:, 2] += self._ctrlpts_offset
                figure = graph_objs.Scatter3d(
                    x=pts[:, 0],
                    y=pts[:, 1],
                    z=pts[:, 2],
                    name=plot['name'],
                    mode='markers',
                    marker=dict(
                        color=plot['color'],
                        size=self.vconf.line_width * 2,
                    )
                )
                plot_data.append(figure)

            # Plot evaluated points
            if plot['type'] == 'evalpts' and self.vconf.display_evalpts:
                vertices = plot['ptsarr'][0]
                triangles = plot['ptsarr'][1]
                pts = [v.data for v in vertices]
                tri = [t.data for t in triangles]
                pts = np.array(pts, dtype=self.vconf.dtype)
                tri = np.array(tri, dtype=self.vconf.dtype)
                figure = graph_objs.Mesh3d(
                    x=pts[:, 0],
                    y=pts[:, 1],
                    z=pts[:, 2],
                    name=plot['name'],
                    i=tri[:, 0],
                    j=tri[:, 1],
                    k=tri[:, 2],
                    color=plot['color'],
                    opacity=0.75,
                )
                plot_data.append(figure)

            # Plot bounding box
            if plot['type'] == 'bbox' and self.vconf.display_bbox:
                pts = np.array(plot['ptsarr'], dtype=self.vconf.dtype)
                figure = graph_objs.Scatter3d(
                    x=pts[:, 0],
                    y=pts[:, 1],
                    z=pts[:, 2],
                    name=plot['name'],
                    mode='lines',
                    line=dict(
                        color=plot['color'],
                        width=self.vconf.line_width,
                        dash='dashdot',
                    ),
                )
                plot_data.append(figure)

            # Plot trim curves
            if self.vconf.display_trims:
                if plot['type'] == 'trimcurve':
                    pts = np.array(plot['ptsarr'], dtype=self.vconf.dtype)
                    figure = graph_objs.Scatter3d(
                        x=pts[:, 0],
                        y=pts[:, 1],
                        z=pts[:, 2],
                        name=plot['name'],
                        mode='markers',
                        marker=dict(
                            color=plot['color'],
                            size=self.vconf.trim_size * 2,
                        ),
                    )
                    plot_data.append(figure)

            # Plot extras
            if plot['type'] == 'extras':
                pts = np.array(plot['ptsarr'], dtype=self.vconf.dtype)
                figure = graph_objs.Scatter3d(
                    x=pts[:, 0],
                    y=pts[:, 1],
                    z=pts[:, 2],
                    name=plot['name'],
                    mode='markers',
                    marker=dict(
                        color=plot['color'][0],
                        size=plot['color'][1],
                        line=dict(
                            width=self.vconf.line_width
                        )
                    )
                )
                plot_data.append(figure)

        plot_layout = dict(
            width=self.vconf.figure_size[0],
            height=self.vconf.figure_size[1],
            autosize=False,
            showlegend=self.vconf.display_legend,
            scene=dict(
                xaxis=dict(
                    showgrid=self.vconf.display_axes,
                    showline=self.vconf.display_axes,
                    zeroline=self.vconf.display_axes,
                    showticklabels=self.vconf.display_axes,
                    title='',
                ),
                yaxis=dict(
                    showgrid=self.vconf.display_axes,
                    showline=self.vconf.display_axes,
                    zeroline=self.vconf.display_axes,
                    showticklabels=self.vconf.display_axes,
                    title='',
                ),
                zaxis=dict(
                    showgrid=self.vconf.display_axes,
                    showline=self.vconf.display_axes,
                    zeroline=self.vconf.display_axes,
                    showticklabels=self.vconf.display_axes,
                    title='',
                ),
            ),
        )

        # Set aspect ratio
        if self.vconf.axes_equal:
            plot_layout['scene']['aspectmode'] = 'data'

        # Generate the figure
        fig = graph_objs.Figure(data=plot_data, layout=plot_layout)

        # Process keyword arguments
        fig_filename = kwargs.get('fig_save_as', None)
        fig_display = kwargs.get('display_plot', True)

        # Display the plot
        if self.vconf.in_notebook() or self.vconf.use_renderer:
            fig.show()
        elif fig_display:
            fig.write_html(file=self.vconf.figure_image_filename if fig_filename is None else fig_filename)
        else:
            fig.write_image(file=self.vconf.figure_image_filename if fig_filename is None else fig_filename)
def render ( self , * * kwargs ) : # Calling parent function super ( VisSurface , self ) . render ( * * kwargs ) # Initialize variables plot_data = [ ] for plot in self . _plots : # Plot control points if plot [ 'type' ] == 'ctrlpts' and self . vconf . display_ctrlpts : pts = np . array ( plot [ 'ptsarr' ] , dtype = self . vconf . dtype ) pts [ : , 2 ] += self . _ctrlpts_offset figure = graph_objs . Scatter3d ( x = pts [ : , 0 ] , y = pts [ : , 1 ] , z = pts [ : , 2 ] , name = plot [ 'name' ] , mode = 'markers' , marker = dict ( color = plot [ 'color' ] , size = self . vconf . line_width * 2 , ) ) plot_data . append ( figure ) # Plot evaluated points if plot [ 'type' ] == 'evalpts' and self . vconf . display_evalpts : vertices = plot [ 'ptsarr' ] [ 0 ] triangles = plot [ 'ptsarr' ] [ 1 ] pts = [ v . data for v in vertices ] tri = [ t . data for t in triangles ] pts = np . array ( pts , dtype = self . vconf . dtype ) tri = np . array ( tri , dtype = self . vconf . dtype ) figure = graph_objs . Mesh3d ( x = pts [ : , 0 ] , y = pts [ : , 1 ] , z = pts [ : , 2 ] , name = plot [ 'name' ] , i = tri [ : , 0 ] , j = tri [ : , 1 ] , k = tri [ : , 2 ] , color = plot [ 'color' ] , opacity = 0.75 , ) plot_data . append ( figure ) # Plot bounding box if plot [ 'type' ] == 'bbox' and self . vconf . display_bbox : pts = np . array ( plot [ 'ptsarr' ] , dtype = self . vconf . dtype ) figure = graph_objs . Scatter3d ( x = pts [ : , 0 ] , y = pts [ : , 1 ] , z = pts [ : , 2 ] , name = plot [ 'name' ] , mode = 'lines' , line = dict ( color = plot [ 'color' ] , width = self . vconf . line_width , dash = 'dashdot' , ) , ) plot_data . append ( figure ) # Plot trim curves if self . vconf . display_trims : if plot [ 'type' ] == 'trimcurve' : pts = np . array ( plot [ 'ptsarr' ] , dtype = self . vconf . dtype ) figure = graph_objs . Scatter3d ( x = pts [ : , 0 ] , y = pts [ : , 1 ] , z = pts [ : , 2 ] , name = plot [ 'name' ] , mode = 'markers' , marker = dict ( color = plot [ 'color' ] , size = self . vconf . trim_size * 2 , ) , ) plot_data . append ( figure ) # Plot extras if plot [ 'type' ] == 'extras' : pts = np . array ( plot [ 'ptsarr' ] , dtype = self . vconf . dtype ) figure = graph_objs . Scatter3d ( x = pts [ : , 0 ] , y = pts [ : , 1 ] , z = pts [ : , 2 ] , name = plot [ 'name' ] , mode = 'markers' , marker = dict ( color = plot [ 'color' ] [ 0 ] , size = plot [ 'color' ] [ 1 ] , line = dict ( width = self . vconf . line_width ) ) ) plot_data . append ( figure ) plot_layout = dict ( width = self . vconf . figure_size [ 0 ] , height = self . vconf . figure_size [ 1 ] , autosize = False , showlegend = self . vconf . display_legend , scene = dict ( xaxis = dict ( showgrid = self . vconf . display_axes , showline = self . vconf . display_axes , zeroline = self . vconf . display_axes , showticklabels = self . vconf . display_axes , title = '' , ) , yaxis = dict ( showgrid = self . vconf . display_axes , showline = self . vconf . display_axes , zeroline = self . vconf . display_axes , showticklabels = self . vconf . display_axes , title = '' , ) , zaxis = dict ( showgrid = self . vconf . display_axes , showline = self . vconf . display_axes , zeroline = self . vconf . display_axes , showticklabels = self . vconf . display_axes , title = '' , ) , ) , ) # Set aspect ratio if self . vconf . axes_equal : plot_layout [ 'scene' ] [ 'aspectmode' ] = 'data' # Generate the figure fig = graph_objs . Figure ( data = plot_data , layout = plot_layout ) # Process keyword arguments fig_filename = kwargs . get ( 'fig_save_as' , None ) fig_display = kwargs . get ( 'display_plot' , True ) # Display the plot if self . vconf . in_notebook ( ) or self . vconf . use_renderer : fig . show ( ) elif fig_display : fig . write_html ( file = self . vconf . figure_image_filename if fig_filename is None else fig_filename ) else : fig . write_image ( file = self . vconf . figure_image_filename if fig_filename is None else fig_filename )