• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python vtk.vtkClipPolyData函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vtk.vtkClipPolyData函数的典型用法代码示例。如果您正苦于以下问题:Python vtkClipPolyData函数的具体用法?Python vtkClipPolyData怎么用?Python vtkClipPolyData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了vtkClipPolyData函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: clipSurfacesForCutLVMesh

def clipSurfacesForCutLVMesh(
        endo,
        epi,
        height,
        verbose=1):

    myVTK.myPrint(verbose, "*** clipSurfacesForCutLVMesh ***")

    plane = vtk.vtkPlane()
    plane.SetNormal(0,0,-1)
    plane.SetOrigin(0,0,height)

    clip = vtk.vtkClipPolyData()
    clip.SetClipFunction(plane)
    clip.SetInputData(endo)
    clip.Update()
    clipped_endo = clip.GetOutput(0)

    clip = vtk.vtkClipPolyData()
    clip.SetClipFunction(plane)
    clip.SetInputData(epi)
    clip.Update()
    clipped_epi = clip.GetOutput(0)

    return (clipped_endo,
            clipped_epi)
开发者ID:gacevedobolton,项目名称:myVTKPythonLibrary,代码行数:26,代码来源:clipSurfacesForCutLVMesh.py


示例2: clipSurfacesForFullLVMesh

def clipSurfacesForFullLVMesh(endo, epi, verbose=1):

    myVTK.myPrint(verbose, "*** clipSurfacesForFullLVMesh ***")

    endo_implicit_distance = vtk.vtkImplicitPolyDataDistance()
    endo_implicit_distance.SetInput(endo)

    epi_implicit_distance = vtk.vtkImplicitPolyDataDistance()
    epi_implicit_distance.SetInput(epi)

    epi_clip = vtk.vtkClipPolyData()
    epi_clip.SetInputData(epi)
    epi_clip.SetClipFunction(endo_implicit_distance)
    epi_clip.GenerateClippedOutputOn()
    epi_clip.Update()
    clipped_epi = epi_clip.GetOutput(0)
    clipped_valve = epi_clip.GetOutput(1)

    endo_clip = vtk.vtkClipPolyData()
    endo_clip.SetInputData(endo)
    endo_clip.SetClipFunction(epi_implicit_distance)
    endo_clip.InsideOutOn()
    endo_clip.Update()
    clipped_endo = endo_clip.GetOutput(0)

    return (clipped_endo, clipped_epi, clipped_valve)
开发者ID:gacevedobolton,项目名称:myVTKPythonLibrary,代码行数:26,代码来源:clipSurfacesForFullLVMesh.py


示例3: clipSurfacesForFullBiVMesh

def clipSurfacesForFullBiVMesh(
        pdata_endLV,
        pdata_endRV,
        pdata_epi,
        verbose=1):

    myVTK.myPrint(verbose, "*** clipSurfacesForFullBiVMesh ***")

    pdata_endLV_implicit_distance = vtk.vtkImplicitPolyDataDistance()
    pdata_endLV_implicit_distance.SetInput(pdata_endLV)

    pdata_endRV_implicit_distance = vtk.vtkImplicitPolyDataDistance()
    pdata_endRV_implicit_distance.SetInput(pdata_endRV)

    pdata_epi_implicit_distance = vtk.vtkImplicitPolyDataDistance()
    pdata_epi_implicit_distance.SetInput(pdata_epi)

    pdata_endLV_clip = vtk.vtkClipPolyData()
    pdata_endLV_clip.SetInputData(pdata_endLV)
    pdata_endLV_clip.SetClipFunction(pdata_epi_implicit_distance)
    pdata_endLV_clip.InsideOutOn()
    pdata_endLV_clip.Update()
    clipped_pdata_endLV = pdata_endLV_clip.GetOutput(0)

    pdata_endRV_clip = vtk.vtkClipPolyData()
    pdata_endRV_clip.SetInputData(pdata_endRV)
    pdata_endRV_clip.SetClipFunction(pdata_epi_implicit_distance)
    pdata_endRV_clip.InsideOutOn()
    pdata_endRV_clip.Update()
    clipped_pdata_endRV = pdata_endRV_clip.GetOutput(0)

    pdata_epi_clip = vtk.vtkClipPolyData()
    pdata_epi_clip.SetInputData(pdata_epi)
    pdata_epi_clip.SetClipFunction(pdata_endLV_implicit_distance)
    pdata_epi_clip.GenerateClippedOutputOn()
    pdata_epi_clip.Update()
    clipped_pdata_epi = pdata_epi_clip.GetOutput(0)
    clipped_valM = pdata_epi_clip.GetOutput(1)

    pdata_epi_clip = vtk.vtkClipPolyData()
    pdata_epi_clip.SetInputData(clipped_pdata_epi)
    pdata_epi_clip.SetClipFunction(pdata_endRV_implicit_distance)
    pdata_epi_clip.GenerateClippedOutputOn()
    pdata_epi_clip.Update()
    clipped_pdata_epi = pdata_epi_clip.GetOutput(0)
    clipped_valP = pdata_epi_clip.GetOutput(1)

    return (clipped_pdata_endLV,
            clipped_pdata_endRV,
            clipped_pdata_epi,
            clipped_valM,
            clipped_valP)
开发者ID:gacevedobolton,项目名称:myVTKPythonLibrary,代码行数:52,代码来源:clipSurfacesForFullBiVMesh.py


示例4: __init__

 def __init__(self, module_manager):
     SimpleVTKClassModuleBase.__init__(
         self, module_manager,
         vtk.vtkClipPolyData(), 'Processing.',
         ('vtkPolyData',), ('vtkPolyData', 'vtkPolyData'),
         replaceDoc=True,
         inputFunctions=None, outputFunctions=None)
开发者ID:fvpolpeta,项目名称:devide,代码行数:7,代码来源:vtkClipPolyData.py


示例5: openSurfaceAtPoint

    def openSurfaceAtPoint(self, polyData, seed):
        '''
        Returns a new surface with an opening at the given seed.
        '''

        someradius = 1.0

        pointLocator = vtk.vtkPointLocator()
        pointLocator.SetDataSet(polyData)
        pointLocator.BuildLocator()

        # find the closest point next to the seed on the surface
        # id = pointLocator.FindClosestPoint(int(seed[0]),int(seed[1]),int(seed[2]))
        id = pointLocator.FindClosestPoint(seed)

        # the seed is now guaranteed on the surface
        seed = polyData.GetPoint(id)

        sphere = vtk.vtkSphere()
        sphere.SetCenter(seed[0], seed[1], seed[2])
        sphere.SetRadius(someradius)

        clip = vtk.vtkClipPolyData()
        clip.SetInputData(polyData)
        clip.SetClipFunction(sphere)
        clip.Update()

        outPolyData = vtk.vtkPolyData()
        outPolyData.DeepCopy(clip.GetOutput())

        return outPolyData
开发者ID:vmtk,项目名称:SlicerExtension-VMTK,代码行数:31,代码来源:CenterlineComputation.py


示例6: _Clip

    def _Clip(self, pd):
        # The plane implicit function will be >0 for all the points in the positive side
        # of the plane (i.e. x s.t. n.(x-o)>0, where n is the plane normal and o is the 
        # plane origin).
        plane = vtkPlane()
        plane.SetOrigin(self.Iolet.Centre.x, self.Iolet.Centre.y, self.Iolet.Centre.z)
        plane.SetNormal(self.Iolet.Normal.x, self.Iolet.Normal.y, self.Iolet.Normal.z)
        
        # The sphere implicit function will be >0 for all the points outside the sphere.
        sphere = vtkSphere()
        sphere.SetCenter(self.Iolet.Centre.x, self.Iolet.Centre.y, self.Iolet.Centre.z)
        sphere.SetRadius(self.Iolet.Radius)
        
        # The VTK_INTERSECTION operator takes the maximum value of all the registered 
        # implicit functions. This will result in the function evaluating to >0 for all 
        # the points outside the sphere plus those inside the sphere in the positive 
        # side of the plane.
        clippingFunction = vtkImplicitBoolean()
        clippingFunction.AddFunction(plane)
        clippingFunction.AddFunction(sphere)
        clippingFunction.SetOperationTypeToIntersection() 
        
        clipper = vtkClipPolyData()
        clipper.SetInput(pd)
        clipper.SetClipFunction(clippingFunction)

        # Filter to get part closest to seed point
        connectedRegionGetter = vtkPolyDataConnectivityFilter()
        connectedRegionGetter.SetExtractionModeToClosestPointRegion()
        connectedRegionGetter.SetClosestPoint(*self.SeedPoint)
        connectedRegionGetter.SetInputConnection(clipper.GetOutputPort())
        connectedRegionGetter.Update()
        return connectedRegionGetter.GetOutput()
开发者ID:jenshnielsen,项目名称:hemelb,代码行数:33,代码来源:OutputGeneration.py


示例7: SphereDrill

    def SphereDrill(self, m_holelist, m_holeRadius, m_quiet=False):
        """
        Drill sphere at locations specified by m_holelist.

        :param m_holelist:      [list]  A list of coordinates where holes are to be drilled
        :param m_holeRadius:    [float] The radius of the hole to drill
        :param m_quiet:         [bool]
        :return:
        """
        m_totalNumOfHoles = len(m_holelist)
        if not m_quiet:
            t = time.time()
            print "Drilling"

        for i in xrange(m_totalNumOfHoles):
            m_sphere = vtk.vtkSphere()
            m_sphere.SetCenter(m_holelist[i])
            m_sphere.SetRadius(m_holeRadius)

            clipper = vtk.vtkClipPolyData()
            clipper.SetInputData(self._data)
            clipper.SetClipFunction(m_sphere)
            clipper.Update()

            clipped = clipper.GetOutput()
            self._data.DeepCopy(clipped)

            if not m_quiet:
                print "\t%s/%s -- %.2f %%" % (i + 1, m_totalNumOfHoles, (i + 1) * 100 / float(m_totalNumOfHoles))
        if not m_quiet:
            print "Finished: Totaltime used = %.2f s" % (time.time() - t)
        pass
开发者ID:teracamo,项目名称:vtkSemiUniformGridding,代码行数:32,代码来源:PolyDataHandler.py


示例8: cut_brain_hemi

def cut_brain_hemi(hemi_elec_data, hemi_poly_data):
    depth_elec_data = hemi_elec_data[(hemi_elec_data.eType == 'D') | (hemi_elec_data.eType == 'd')]
    print depth_elec_data
    print

    x_coords = np.array([avg_surf.x_snap for avg_surf in depth_elec_data.avgSurf], dtype=np.float)
    y_coords = np.array([avg_surf.y_snap for avg_surf in depth_elec_data.avgSurf], dtype=np.float)
    z_coords = np.array([avg_surf.z_snap for avg_surf in depth_elec_data.avgSurf], dtype=np.float)

    x_min, x_max = np.min(x_coords), np.max(x_coords)
    y_min, y_max = np.min(y_coords), np.max(y_coords)
    z_min, z_max = np.min(z_coords), np.max(z_coords)

    clipPlane = vtk.vtkPlane()
    clipPlane.SetNormal(0.0, 0.0, 1.0)
    # clipPlane.SetOrigin(0, 0, np.max(z_coords))
    # clipPlane.SetOrigin(np.max(x_coords), np.max(y_coords), np.max(z_coords))

    clipPlane.SetOrigin(0, 0, -500)

    clipper = vtk.vtkClipPolyData()
    clipper.SetInputData(hemi_poly_data)
    clipper.SetClipFunction(clipPlane)

    return clipper
开发者ID:maciekswat,项目名称:ram_plots,代码行数:25,代码来源:brain_plot_utils.py


示例9: Execute

    def Execute(self):

        if self.Surface == None:
            self.PrintError('Error: no Surface.')

        if self.WidgetType == "box":
            self.ClipFunction = vtk.vtkPlanes()
        elif self.WidgetType == "sphere":
            self.ClipFunction = vtk.vtkSphere()

        self.Clipper = vtk.vtkClipPolyData()
        self.Clipper.SetInput(self.Surface)
        self.Clipper.SetClipFunction(self.ClipFunction)
        self.Clipper.GenerateClippedOutputOn()
        self.Clipper.InsideOutOn()
        
        if not self.vmtkRenderer:
            self.vmtkRenderer = vmtkrenderer.vmtkRenderer()
            self.vmtkRenderer.Initialize()
            self.OwnRenderer = 1

        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInput(self.Surface)
        mapper.ScalarVisibilityOff()
        self.Actor = vtk.vtkActor()
        self.Actor.SetMapper(mapper)
        self.vmtkRenderer.Renderer.AddActor(self.Actor)

        if self.WidgetType == "box":
            self.ClipWidget = vtk.vtkBoxWidget()
            self.ClipWidget.GetFaceProperty().SetColor(0.6,0.6,0.2)
            self.ClipWidget.GetFaceProperty().SetOpacity(0.25)
        elif self.WidgetType == "sphere":
            self.ClipWidget = vtk.vtkSphereWidget()
            self.ClipWidget.GetSphereProperty().SetColor(0.6,0.6,0.2)
            self.ClipWidget.GetSphereProperty().SetOpacity(0.25)
            self.ClipWidget.GetSelectedSphereProperty().SetColor(0.6,0.0,0.0)
            self.ClipWidget.GetSelectedSphereProperty().SetOpacity(0.75)
            self.ClipWidget.SetRepresentationToSurface()
            self.ClipWidget.SetPhiResolution(20)
            self.ClipWidget.SetThetaResolution(20)

        self.ClipWidget.SetInteractor(self.vmtkRenderer.RenderWindowInteractor)
        self.Display()

        self.Transform = vtk.vtkTransform()
        self.ClipWidget.GetTransform(self.Transform)

        if self.OwnRenderer:
            self.vmtkRenderer.Deallocate()

        if self.CleanOutput == 1:
            cleaner = vtk.vtkCleanPolyData()
            cleaner.SetInput(self.Surface)
            cleaner.Update()
            self.Surface = cleaner.GetOutput()

        if self.Surface.GetSource():
            self.Surface.GetSource().UnRegisterAllOutputs()
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:59,代码来源:vmtksurfaceclipper.py


示例10: Clipper

def Clipper(src, dx, dy, dz):
    '''
    Clip a vtkPolyData source.
    A cube is made whose size corresponds the the bounds of the source.
    Then each side is shrunk by the appropriate dx, dy or dz. After
    this operation the source is clipped by the cube.
    :param: src - the vtkPolyData source
    :param: dx - the amount to clip in the x-direction
    :param: dy - the amount to clip in the y-direction
    :param: dz - the amount to clip in the z-direction
    :return: vtkPolyData.
    '''
    bounds = [0,0,0,0,0,0]
    src.GetBounds(bounds)

    plane1 = vtk.vtkPlane()
    plane1.SetOrigin(bounds[0] + dx, 0, 0)
    plane1.SetNormal(1, 0, 0)

    plane2 = vtk.vtkPlane()
    plane2.SetOrigin(bounds[1] - dx, 0, 0)
    plane2.SetNormal(-1, 0, 0)

    plane3 = vtk.vtkPlane()
    plane3.SetOrigin(0, bounds[2] + dy, 0)
    plane3.SetNormal(0, 1, 0)

    plane4 = vtk.vtkPlane()
    plane4.SetOrigin(0, bounds[3] - dy, 0)
    plane4.SetNormal(0, -1, 0)

    plane5 = vtk.vtkPlane()
    plane5.SetOrigin(0, 0, bounds[4] + dz)
    plane5.SetNormal(0, 0, 1)

    plane6 = vtk.vtkPlane()
    plane6.SetOrigin(0, 0, bounds[5] - dz)
    plane6.SetNormal(0, 0, -1)

    clipFunction = vtk.vtkImplicitBoolean()
    clipFunction.SetOperationTypeToUnion()
    clipFunction.AddFunction(plane1)
    clipFunction.AddFunction(plane2)
    clipFunction.AddFunction(plane3)
    clipFunction.AddFunction(plane4)
    clipFunction.AddFunction(plane5)
    clipFunction.AddFunction(plane6)

    # Clip it.
    clipper =vtk.vtkClipPolyData()
    clipper.SetClipFunction(clipFunction)
    clipper.SetInputData(src)
    clipper.GenerateClipScalarsOff()
    clipper.GenerateClippedOutputOff()
    #clipper.GenerateClippedOutputOn()
    clipper.Update()
    return clipper.GetOutput()
开发者ID:dlrdave,项目名称:VTKWikiExamples,代码行数:57,代码来源:CurvatureBandsWithGlyphs.py


示例11: __init__

    def __init__(self, parent=None, id=-1,
                 pos=wx.DefaultPosition,
                 title="3D Density"):
        VizFrame.__init__(self, parent, id, pos, title)
        self.widget = wxVTKRenderWindowInteractor(self,-1)
        style = vtk.vtkInteractorStyleTrackballCamera()
        self.widget.SetInteractorStyle(style)

        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(0.1, 0.1, 0.7)
        self.widget.GetRenderWindow().AddRenderer(self.ren)


        self.data = None
        self.colors = None
        
        # layout the frame
        self.box = wx.BoxSizer(wx.HORIZONTAL)
        self.leftPanel = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(self.box)
        self.box.Add(self.leftPanel,0, wx.EXPAND)
        self.box.Add(self.widget,1,wx.EXPAND)
        self.Layout()

        self.MenuBar = wx.MenuBar()
        self.FileMenu = wx.Menu()
        self.GateMenu = wx.Menu()
        self.MenuBar.Append(self.FileMenu, "File")
        self.MenuBar.Append(self.GateMenu, "Gating")
        self.SetMenuBar(self.MenuBar)
        export = self.FileMenu.Append(-1, "Export graphics")
        self.Bind(wx.EVT_MENU, self.OnExport, export)
        self.colorGate = self.GateMenu.Append(-1, "Gate on visible colors only")
        self.Bind(wx.EVT_MENU, self.GateByColor, self.colorGate)
        self.colorGate.Enable(False)
        gate = self.GateMenu.Append(-1, "Capture gated events")
        self.boxAddMenuItem = self.GateMenu.Append(-1, "Add box gate")
        self.GateMenu.AppendSeparator()
        self.boxes = []
        self.Bind(wx.EVT_MENU, self.OnBox, self.boxAddMenuItem)
        
        self.Bind(wx.EVT_MENU, self.Gate, gate)

        self.selectActor = vtk.vtkLODActor()
        self.planes = {} #vtk.vtkPlanes()
        self.clipper = vtk.vtkClipPolyData()
        
        self.boxCount = 1
        self.boxIds = {}

        self.Show()
        self.SendSizeEvent()
开发者ID:cliburn,项目名称:flow,代码行数:52,代码来源:Main.py


示例12: planeclip

def planeclip(polydata, point, normal, insideout=True):
    """Clip polydata with a plane defined by point and normal. Change clipping
    direction with 'insideout' argument."""
    clipplane = vtk.vtkPlane()
    clipplane.SetOrigin(point)
    clipplane.SetNormal(normal)
    clipper = vtk.vtkClipPolyData()
    clipper.SetInput(polydata)
    clipper.SetClipFunction(clipplane)
    if insideout:
        clipper.InsideOutOn()
    clipper.Update()
    return clipper.GetOutput()
开发者ID:ajgeers,项目名称:utils,代码行数:13,代码来源:vtklib.py


示例13: _createTube

 def _createTube(self):
     logging.debug("In MultiSliceContour::createTube()")
     
     points = vtk.vtkPoints()
     for point in self._originalPoints:
         points.InsertNextPoint(point)
                
     self._parametricSpline = vtk.vtkParametricSpline()
     self._parametricSpline.SetPoints(points)
     
     self._parametricFuntionSource = vtk.vtkParametricFunctionSource()
     self._parametricFuntionSource.SetParametricFunction(self._parametricSpline)
     self._parametricFuntionSource.SetUResolution(100)
     
     self._tubeFilter = vtk.vtkTubeFilter()
     self._tubeFilter.SetNumberOfSides(10)
     self._tubeFilter.SetRadius(self._radius)
     self._tubeFilter.SetInputConnection(self._parametricFuntionSource.GetOutputPort())
     
     self._tubeActor = []
     self._cubes = []
     i = 0
     for cutter in self._cutters:
         cutter.SetInputConnection(self._tubeFilter.GetOutputPort())
         cutter.Update()
         
         cube = vtk.vtkBox()
         #TODO change imagebounds to planesourceRange
         cube.SetBounds(self._scene.slice[i].getBounds())
         clip = vtk.vtkClipPolyData()
         clip.SetClipFunction(cube)
         clip.SetInputConnection(cutter.GetOutputPort())
         clip.InsideOutOn()
         clip.Update()          
         self._cubes.append(cube)
         
         tubeMapper=vtk.vtkPolyDataMapper()
         tubeMapper.ScalarVisibilityOff()
         tubeMapper.SetInputConnection(clip.GetOutputPort())
         tubeMapper.GlobalImmediateModeRenderingOn()
         
         tubeActor = vtk.vtkActor()
         tubeActor.SetMapper(tubeMapper)
         tubeActor.GetProperty().LightingOff()
         tubeActor.GetProperty().SetColor(self.lineColor)
         tubeActor.SetUserTransform(self._scene.slice[i].resliceTransform.GetInverse())
         
         
         self._tubeActor.append(tubeActor)
         self._scene.renderer.AddActor(tubeActor)
         i = i+1                
开发者ID:aevum,项目名称:moonstone,代码行数:51,代码来源:multislicecontour.py


示例14: planeclip

def planeclip(surface, point, normal, insideout=1):
    clipplane = vtk.vtkPlane()
    clipplane.SetOrigin(point)
    clipplane.SetNormal(normal)
    clipper = vtk.vtkClipPolyData()
    clipper.SetInputData(surface)
    clipper.SetClipFunction(clipplane)

    if insideout == 1:
        clipper.InsideOutOn()
    else:
        clipper.InsideOutOff()
    clipper.Update()
    return clipper.GetOutput()
开发者ID:catactg,项目名称:SUM,代码行数:14,代码来源:basefunctions.py


示例15: doClip1

def doClip1(data,value,normal,axis=0):
    # We have the actor, do clipping
    clpf = vtk.vtkPlane()
    if axis == 0:
      clpf.SetOrigin(value,0,0)
      clpf.SetNormal(normal,0,0)
    else:
      clpf.SetOrigin(0,value,0)
      clpf.SetNormal(0,normal,0)
    clp = vtk.vtkClipPolyData()
    clp.SetClipFunction(clpf)
    clp.SetInputData(data)
    clp.Update()
    return clp.GetOutput()
开发者ID:charlesdoutriaux,项目名称:uvcdat-devel,代码行数:14,代码来源:vcs2vtk.py


示例16: __init__

    def __init__(self, module_manager):
        # initialise our base class
        ModuleBase.__init__(self, module_manager)


        self._clipPolyData = vtk.vtkClipPolyData()
        module_utils.setup_vtk_object_progress(self, self._clipPolyData,
                                           'Calculating normals')

        NoConfigModuleMixin.__init__(
            self,
            {'vtkClipPolyData' : self._clipPolyData})

        self.sync_module_logic_with_config()
开发者ID:fvpolpeta,项目名称:devide,代码行数:14,代码来源:clipPolyData.py


示例17: getClippedPDataUsingField

def getClippedPDataUsingField(pdata_mesh, array_name, threshold_value, verbose=0):

    mypy.my_print(verbose, "*** getClippedPDataUsingField ***")

    pdata_mesh.GetPointData().SetActiveScalars(array_name)
    clip_poly_data = vtk.vtkClipPolyData()
    if vtk.vtkVersion.GetVTKMajorVersion() >= 6:
        clip_poly_data.SetInputData(pdata_mesh)
    else:
        clip_poly_data.SetInput(pdata_mesh)
    clip_poly_data.SetValue(threshold_value)
    clip_poly_data.GenerateClippedOutputOn()
    clip_poly_data.Update()

    return clip_poly_data.GetOutput(0), clip_poly_data.GetOutput(1)
开发者ID:mgenet,项目名称:myVTKPythonLibrary,代码行数:15,代码来源:getClippedPDataUsingField.py


示例18: update_pipeline

    def update_pipeline(self):

        if self.isoActor is not None:
            self.renderer.RemoveActor(self.isoActor)

        
        
        pipe = self.marchingCubes


        if self.useConnect:
            self.connect.SetInput( pipe.GetOutput())
            pipe = self.connect

        if self.useDecimate:
            self.deci.SetInput( pipe.GetOutput())
            pipe = self.deci

        if 0:
            plane = vtk.vtkPlane()
            clipper = vtk.vtkClipPolyData()
            polyData = pipe.GetOutput()

            clipper.SetInput(polyData)
            clipper.SetClipFunction(plane)
            clipper.InsideOutOff()
            pipe = clipper

            def callback(pw, event):
                pw.GetPlane(plane)
                self.interactor.Render()
            self.planeWidget = vtk.vtkImplicitPlaneWidget()
            self.planeWidget.SetInteractor(self.interactor)
            self.planeWidget.On()
            self.planeWidget.SetPlaceFactor(1.0)
            self.planeWidget.SetInput(polyData)
            self.planeWidget.PlaceWidget()
            self.planeWidget.AddObserver("InteractionEvent", callback)
        
        
        self.isoMapper = vtk.vtkPolyDataMapper()
        self.isoMapper.SetInput(pipe.GetOutput())
        self.isoMapper.ScalarVisibilityOff()

        self.isoActor = vtk.vtkActor()
        self.isoActor.SetMapper(self.isoMapper)
        self.renderer.AddActor(self.isoActor)
        self.update_properties()
开发者ID:alexsavio,项目名称:nidoodles,代码行数:48,代码来源:surf_params.py


示例19: cutter

 def cutter(self):
     maxLayers = 0
     for model in self.modelDict.values():
         if len(model.layerValues) > maxLayers:
             maxLayers = len(model.layerValues)
             
     for model in self.modelDict.values():
         i = self.currentIndex
         if i < 0:
             i = 0
             self.currentIndex = -1
         elif i > len(model.layerValues) - 1:
             i = len(model.layerValues) - 1 # The last layer
             if len(model.layerValues) > maxLayers:
                 self.currentIndex = maxLayers
             
         for actor in [model._actor, model._slice_actor, model._support_actor, model._base_actor]:
             if actor is not None:
                 actor.GetProperty().SetOpacity(0)
                 
         for polydata in [model._slice_vtkpolydata, model._support_vtkpolydata, model._base_vtkpolydata]:
             if polydata is not None:
                 plane = vtk.vtkPlane() 
                 plane.SetOrigin(0, 0, model.layerValues[i] -0.005) # some errors if path height is 0.005
                 plane.SetNormal(0, 0, 1)
                 window = vtk.vtkImplicitWindowFunction()
                 window.SetImplicitFunction(plane)
                 try:
                     pathHeight = float(self.toolDict[str(model._modelMaterial)].pathHeight)
                 except:
                     pathHeight = model.pathHeight # error fix in gcode import
                 window.SetWindowRange(0, pathHeight)
                 clipper = vtk.vtkClipPolyData()
                 clipper.AddInput(polydata) 
                 clipper.SetClipFunction(window)
                 clipper.GenerateClippedOutputOn()
                 if self.tubeOn:
                     try:
                         clipActor = self.tubeView(clipper, float(self.toolDict[str(model._modelMaterial)].pathWidth))
                     except:
                         clipActor = self.tubeView(clipper, pathHeight) # error fix in gcode import
                 else:
                     clipMapper = vtk.vtkPolyDataMapper()
                     clipMapper.SetInputConnection(clipper.GetOutputPort())
                     clipActor = vtk.vtkActor()
                     clipActor.SetMapper(clipMapper)
                 self.ren.AddActor(clipActor)
                 self.newActors.append(clipActor)
开发者ID:GVallicrosa,项目名称:FabQtV2,代码行数:48,代码来源:vtkCustom.py


示例20: preprocess_mesh

def preprocess_mesh(mesh, num_patches=10):
    """
    This function...

    :param mesh:
    :param num_patches:
    :return:
    """

    # run patching
    for i in range(num_patches):
        mesh = patch(mesh)

    edges2 = vtk.vtkFeatureEdges()
    edges2.SetInputData(mesh)
    edges2.FeatureEdgesOff()
    edges2.NonManifoldEdgesOn()
    edges2.ManifoldEdgesOff()
    edges2.BoundaryEdgesOn()
    edges2.Update()
    edgesPd = edges2.GetOutput()
    print(
        "{0} cells and {1} points".format(
            edgesPd.GetNumberOfCells(), edgesPd.GetNumberOfPoints()
        )
    )

    toDelete = vtk.vtkFloatArray()
    toDelete.SetNumberOfComponents(1)
    toDelete.SetNumberOfValues(mesh.GetNumberOfPoints())

    for i in range(mesh.GetNumberOfPoints()):
        toDelete.SetValue(i, 0)

    for i in range(edgesPd.GetNumberOfPoints()):
        edgePnt = edgesPd.GetPoint(i)
        meshVertId = mesh.FindPoint(edgePnt)
        toDelete.SetValue(meshVertId, 1)

    mesh.GetPointData().SetScalars(toDelete)

    clipper = vtk.vtkClipPolyData()
    clipper.SetValue(0.5)
    clipper.SetInputData(mesh)
    clipper.InsideOutOn()
    clipper.Update()

    return clipper.GetOutput()
开发者ID:BRAINSia,项目名称:BRAINSTools,代码行数:48,代码来源:mesh2mask.py



注:本文中的vtk.vtkClipPolyData函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkCollection函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkCleanPolyData函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap