Exemplo n.º 1
0
    def render(self):
        """ Plots the surface and the control points grid """
        if not self._plots:
            return

        # Start plotting of the surface and the control points grid
        fig = plt.figure(figsize=self._config.figure_size,
                         dpi=self._config.figure_dpi)
        ax = Axes3D(fig)

        legend_proxy = []
        legend_names = []

        # Start plotting
        for plot in self._plots:
            # Plot control points
            if plot['type'] == 'ctrlpts' and self._config.display_ctrlpts:
                pts = np.array(
                    utils.make_quad(plot['ptsarr'], plot['size'][1],
                                    plot['size'][0]))
                cp_z = pts[:, 2] + self._ctrlpts_offset
                ax.plot(pts[:, 0],
                        pts[:, 1],
                        cp_z,
                        color=plot['color'],
                        linestyle='-.',
                        marker='o')
                plot1_proxy = mpl.lines.Line2D([0], [0],
                                               linestyle='-.',
                                               color=plot['color'],
                                               marker='o')
                legend_proxy.append(plot1_proxy)
                legend_names.append(plot['name'])

            # Plot evaluated points
            if plot['type'] == 'evalpts':
                pts = np.array(plot['ptsarr'])
                ax.scatter(pts[:, 0],
                           pts[:, 1],
                           pts[:, 2],
                           color=plot['color'],
                           s=50,
                           depthshade=True)
                plot2_proxy = mpl.lines.Line2D([0], [0],
                                               linestyle='none',
                                               color=plot['color'],
                                               marker='o')
                legend_proxy.append(plot2_proxy)
                legend_names.append(plot['name'])

        # Add legend to 3D plot, @ref: https://stackoverflow.com/a/20505720
        if self._config.display_legend:
            ax.legend(legend_proxy, legend_names, numpoints=1)

        # Remove axes
        if not self._config.display_axes:
            plt.axis('off')

        # Display the 3D plot
        plt.show()
Exemplo n.º 2
0
    def render(self):
        """ Plots the surface and the control points grid """
        if not self._plots:
            return

        # Start plotting of the surface and the control points grid
        fig = plt.figure(figsize=self._figure_size, dpi=self._figure_dpi)
        ax = Axes3D(fig)

        legend_proxy = []
        legend_names = []

        # Start plotting
        for plot in self._plots:
            if plot['type'] == 1:
                if self._plot_ctrlpts:
                    pts = np.array(
                        utils.make_quad(plot['ptsarr'], plot['size'][1],
                                        plot['size'][0]))
                    cp_z = pts[:, 2] + self._ctrlpts_offset
                    ax.plot(pts[:, 0],
                            pts[:, 1],
                            cp_z,
                            color=plot['color'],
                            linestyle='-.',
                            marker='o')
                    plot1_proxy = mpl.lines.Line2D([0], [0],
                                                   linestyle='-.',
                                                   color=plot['color'],
                                                   marker='o')
                    legend_proxy.append(plot1_proxy)
                    legend_names.append(plot['name'])
            else:
                pts = np.array(plot['ptsarr'])
                ax.plot_trisurf(pts[:, 0],
                                pts[:, 1],
                                pts[:, 2],
                                color=plot['color'])
                plot2_proxy = mpl.lines.Line2D([0], [0],
                                               linestyle='none',
                                               color=plot['color'],
                                               marker='^')
                legend_proxy.append(plot2_proxy)
                legend_names.append(plot['name'])

        # Add legend to 3D plot, @ref: https://stackoverflow.com/a/20505720
        if self._plot_legend:
            ax.legend(legend_proxy, legend_names, numpoints=1)

        # Display the 3D plot
        plt.show()