(self, **kwargs)
Plots the curve and the control points polygon.
Plots the curve and the control points polygon.
Plots the curve and the control points polygon .
def render(self, **kwargs):
        """ Plots the curve and the control points polygon. """
        # Calling parent function
        super(VisCurve3D, self).render(**kwargs)

        # Initialize a list to store VTK actors
        vtk_actors = []

        # Start plotting
        for plot in self._plots:
            # Plot control points
            if plot['type'] == 'ctrlpts' and self.vconf.display_ctrlpts:
                # Points as spheres
                pts = np.array(plot['ptsarr'], dtype=np.float)
                # Handle 2-dimensional data
                if pts.shape[1] == 2:
                    pts = np.c_[pts, np.zeros(pts.shape[0], dtype=np.float)]
                vtkpts = numpy_to_vtk(pts, deep=False, array_type=VTK_FLOAT)
                vtkpts.SetName(plot['name'])
                actor1 = vtkh.create_actor_pts(pts=vtkpts, color=vtkh.create_color(plot['color']),
                                               name=plot['name'], idx=plot['idx'])
                vtk_actors.append(actor1)
                # Lines
                actor2 = vtkh.create_actor_polygon(pts=vtkpts, color=vtkh.create_color(plot['color']),
                                                   name=plot['name'], index=plot['idx'], size=self.vconf.line_width)
                vtk_actors.append(actor2)

            # Plot evaluated points
            if plot['type'] == 'evalpts' and self.vconf.display_evalpts:
                pts = np.array(plot['ptsarr'], dtype=np.float)
                # Handle 2-dimensional data
                if pts.shape[1] == 2:
                    pts = np.c_[pts, np.zeros(pts.shape[0], dtype=np.float)]
                vtkpts = numpy_to_vtk(pts, deep=False, array_type=VTK_FLOAT)
                vtkpts.SetName(plot['name'])
                actor1 = vtkh.create_actor_polygon(pts=vtkpts, color=vtkh.create_color(plot['color']),
                                                   name=plot['name'], index=plot['idx'], size=self.vconf.line_width * 2)
                vtk_actors.append(actor1)

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

        fig_filename = self.vconf.figure_image_filename if fig_filename is None else fig_filename

        # Render actors
        vtkh.create_render_window(
            vtk_actors,
            dict(KeyPressEvent=(self.vconf.keypress_callback, 1.0)),
            figure_size=self.vconf.figure_size,
            display_plot=fig_display,
            image_filename=fig_filename
        )
def render ( self , * * kwargs ) : # Calling parent function super ( VisCurve3D , self ) . render ( * * kwargs ) # Initialize a list to store VTK actors vtk_actors = [ ] # Start plotting for plot in self . _plots : # Plot control points if plot [ 'type' ] == 'ctrlpts' and self . vconf . display_ctrlpts : # Points as spheres pts = np . array ( plot [ 'ptsarr' ] , dtype = np . float ) # Handle 2-dimensional data if pts . shape [ 1 ] == 2 : pts = np . c_ [ pts , np . zeros ( pts . shape [ 0 ] , dtype = np . float ) ] vtkpts = numpy_to_vtk ( pts , deep = False , array_type = VTK_FLOAT ) vtkpts . SetName ( plot [ 'name' ] ) actor1 = vtkh . create_actor_pts ( pts = vtkpts , color = vtkh . create_color ( plot [ 'color' ] ) , name = plot [ 'name' ] , idx = plot [ 'idx' ] ) vtk_actors . append ( actor1 ) # Lines actor2 = vtkh . create_actor_polygon ( pts = vtkpts , color = vtkh . create_color ( plot [ 'color' ] ) , name = plot [ 'name' ] , index = plot [ 'idx' ] , size = self . vconf . line_width ) vtk_actors . append ( actor2 ) # Plot evaluated points if plot [ 'type' ] == 'evalpts' and self . vconf . display_evalpts : pts = np . array ( plot [ 'ptsarr' ] , dtype = np . float ) # Handle 2-dimensional data if pts . shape [ 1 ] == 2 : pts = np . c_ [ pts , np . zeros ( pts . shape [ 0 ] , dtype = np . float ) ] vtkpts = numpy_to_vtk ( pts , deep = False , array_type = VTK_FLOAT ) vtkpts . SetName ( plot [ 'name' ] ) actor1 = vtkh . create_actor_polygon ( pts = vtkpts , color = vtkh . create_color ( plot [ 'color' ] ) , name = plot [ 'name' ] , index = plot [ 'idx' ] , size = self . vconf . line_width * 2 ) vtk_actors . append ( actor1 ) # Process keyword arguments fig_filename = kwargs . get ( 'fig_save_as' , None ) fig_display = kwargs . get ( 'display_plot' , True ) fig_filename = self . vconf . figure_image_filename if fig_filename is None else fig_filename # Render actors vtkh . create_render_window ( vtk_actors , dict ( KeyPressEvent = ( self . vconf . keypress_callback , 1.0 ) ) , figure_size = self . vconf . figure_size , display_plot = fig_display , image_filename = fig_filename )