コード例 #1
0
    def plotNURBSSurfaces(self,
                          left_pts,
                          right_pts,
                          corsequences,
                          lsagsequences,
                          rsagsequences,
                          degree=3,
                          visualization_type=-1):
        left_surface = self.createNURBSSurface(pts=left_pts,
                                               corsequences=corsequences,
                                               sagsequences=lsagsequences)
        right_surface = self.createNURBSSurface(pts=right_pts,
                                                corsequences=corsequences,
                                                sagsequences=rsagsequences)

        # Create a MultiSurface
        surfaces = Multi.MultiSurface()
        surfaces.add(left_surface)
        surfaces.add(right_surface)

        # Set visualization component
        if visualization_type == 0:
            surfaces.delta = 0.01
            vis_comp = VisMPL.VisSurfScatter()
        elif visualization_type == 1:
            vis_comp = VisMPL.VisSurface()
        elif visualization_type == 2:
            vis_comp = VisMPL.VisSurfWireframe()
        else:
            vis_comp = VisMPL.VisSurfTriangle()
        surfaces.vis = vis_comp

        # Render the surface
        surfaces.render()
コード例 #2
0

# duck3.nurbs

# Process control points and weights
d3_ctrlpts = exchange.import_txt("duck3.ctrlpts", separator=" ")

# Create a NURBS surface
duck3 = NURBS.Surface()
duck3.order_u = 4
duck3.order_v = 4
duck3.ctrlpts_size_u = 6
duck3.ctrlpts_size_v = 6
duck3.ctrlpts = d3_ctrlpts
duck3.knotvector_u = [0, 0, 0, 0, 0.333333, 0.666667, 1, 1, 1, 1]
duck3.knotvector_v = [0, 0, 0, 0, 0.333333, 0.666667, 1, 1, 1, 1]

# Plotting
ducky = Multi.MultiSurface()
ducky.add_list([duck1, duck2, duck3])
vis_config = VisMPL.VisConfig(ctrlpts=False, legend=False)

# Use Matplotlib's colormaps to color the duck
from matplotlib import cm

ducky.vis = VisMPL.VisSurfTriangle(vis_config)
ducky.sample_size = 50
ducky.render(colormap=[cm.Wistia, cm.copper, cm.copper])

pass
コード例 #3
0
    def plotBsplineSurfaces(self,
                            left_pts,
                            right_pts,
                            corsequences,
                            lsagsequences,
                            rsagsequences,
                            degree=3,
                            visualization_type=-1):
        """ Create B-spline surface

        Parameters
        ----------
        left_pts: list
            List of tuples with 3D points that represents the left diaphragmatic surface

        right_pts: list
            List of tuples with 3D points that represents the right diaphragmatic surface

        corsequences: list
            List of int with the coronal sequences available

        lsagsequences: list
            List of int with the sagittal sequences available from the left lung

        rsagsequences: list
            List of int with the sagittal sequences available from the right lung

        degree: int
            B-spline surface's Degree (Default = 2)

        visualization_type: int
            -1: (Default) Wireframe plot for the control points and triangulated plot for the surface points
            0: Wireframe plot for the control points and scatter plot for the surface points
            1: Triangular mesh plot for the surface and wireframe plot for the control points grid
            2: Scatter plot for the control points and wireframe for the surface points
        """
        left_surface = self.createBsplineSurface(pts=left_pts,
                                                 corsequences=corsequences,
                                                 sagsequences=lsagsequences)
        right_surface = self.createBsplineSurface(pts=right_pts,
                                                  corsequences=corsequences,
                                                  sagsequences=rsagsequences)

        # Create a MultiSurface
        surfaces = Multi.MultiSurface()
        surfaces.add(left_surface)
        surfaces.add(right_surface)

        # Set visualization component
        if visualization_type == 0:
            surfaces.delta = 0.01
            vis_comp = VisMPL.VisSurfScatter()
        elif visualization_type == 1:
            vis_comp = VisMPL.VisSurface()
        elif visualization_type == 2:
            vis_comp = VisMPL.VisSurfWireframe()
        else:
            vis_comp = VisMPL.VisSurfTriangle()
        surfaces.vis = vis_comp

        # Render the surface
        surfaces.render()
コード例 #4
0
duck2.knotvector_v = [0, 0, 0, 0, 0.179541, 0.317924, 0.485586, 0.507528, 0.709398, 0.813231, 1, 1, 1, 1]


# duck3.nurbs

# Process control points and weights
d3_ctrlpts = exchange.import_txt("duck3.ctrlpts", separator=" ")

# Create a NURBS surface
duck3 = NURBS.Surface()
duck3.order_u = 4
duck3.order_v = 4
duck3.ctrlpts_size_u = 6
duck3.ctrlpts_size_v = 6
duck3.ctrlpts = d3_ctrlpts
duck3.knotvector_u = [0, 0, 0, 0, 0.333333, 0.666667, 1, 1, 1, 1]
duck3.knotvector_v = [0, 0, 0, 0, 0.333333, 0.666667, 1, 1, 1, 1]

# Plotting
ducky = Multi.MultiSurface(duck1, duck2, duck3)
vis_config = VisMPL.VisConfig(ctrlpts=False, legend=False)

# Use Matplotlib's colormaps to color the duck
from matplotlib import cm

ducky.vis = VisMPL.VisSurfTriangle(vis_config)
ducky.sample_size = 50
ducky.render(colormap=[cm.Wistia, cm.copper, cm.copper])

pass