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

Python vtk.vtkSampleFunction函数代码示例

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

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



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

示例1: SampleFunction

 def SampleFunction(self, currentElement):
     sampFunc = vtk.vtkSampleFunction()
     # Datatype(s) I need for input:  Algorithm
     AlgorithmElement = ''
     for childElement in currentElement.getchildren():
         if childElement.tag in vtkTypes['Algorithm']:
             AlgorithmElement = childElement
     if AlgorithmElement != '':
         dataset = self.namesToFunctions[AlgorithmElement.tag](AlgorithmElement)
         self.logger.debug('  .. <SampleFunction> trying to SetImplicitFunction.')
         try:
             sampFunc.SetImplicitFunction(dataset)
         except:
             self.logger.error('  .. <SampleFunction> failed to SetImplicitFunction.')
     if 'SetSampleDimensions' in currentElement.keys():
         self.logger.debug('  .. <SampleFunction> trying to SetSampleDimensions')
         try:
             sampFunc.SetSampleDimensions( str2ints(currentElement.get('SetSampleDimensions')) )
         except:
             self.logger.error('  .. <SampleFunction> failed to SetSampleDimensions')
     if 'SetModelBounds' in currentElement.keys():
         self.logger.debug('  .. <SampleFunction> trying to SetModelBounds')
         try:
             sampFunc.SetModelBounds( str2floats(currentElement.get('SetModelBounds')) )
         except:
             self.logger.error('  .. <SampleFunction> failed to SetModelBounds')
     sampFunc.ComputeNormalsOff()
     return sampFunc
开发者ID:mfassler,项目名称:jaivis,代码行数:28,代码来源:xmlReader.py


示例2: __init__

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


示例3: BuildPolyBallSurface

 def BuildPolyBallSurface(self):
     #Build a surface for displaying the polyball
     if self.PolyBall == None:
         return
     
     #Sample the polyball
     sampler = vtk.vtkSampleFunction()
     sampler.SetImplicitFunction(self.PolyBall)
     
     #Set the bounds to be slightly larger than those of the mesh
     meshBounds = self.Mesh.GetBounds()
     meshCenter = self.Mesh.GetCenter()
     polyBallBounds = [0, 0, 0, 0, 0, 0]
     for i in range(0,3):
         length = 1.2*(meshBounds[2*i+1] - meshCenter[i])
         polyBallBounds[2*i] = meshCenter[i] - length
         polyBallBounds[2*i+1] = meshCenter[i] + length
     
     sampler.SetModelBounds(polyBallBounds)
     sampler.SetSampleDimensions(self.PolyBallResolution)
     sampler.ComputeNormalsOff()
     sampler.Update()
     
     #Extract the isosurface at 0
     contour = vtk.vtkContourFilter()
     contour.SetInput(sampler.GetOutput())
     contour.SetValue(0,0.)
     contour.Update()
     
     #Set the new model as the mapper input
     self.PolyBallActor.GetMapper().SetInput(contour.GetOutput())
开发者ID:ValentinaRossi,项目名称:vmtk,代码行数:31,代码来源:vmtkmeshclipcenterlines.py


示例4: visQuadFunc

def visQuadFunc():
    """ vtk sample scene with iso contours """

    # VTK supports implicit functions of the form f(x,y,z)=constant. These
    # functions can represent things spheres, cones, etc. Here we use a
    # general form for a quadric to create an elliptical data field.
    quadric = vtk.vtkQuadric()
    quadric.SetCoefficients(.5, 1, .2, 0, .1, 0, 0, .2, 0, 0)

    # vtkSampleFunction samples an implicit function over the x-y-z range
    # specified (here it defaults to -1,1 in the x,y,z directions).
    sample = vtk.vtkSampleFunction()
    sample.SetSampleDimensions(30, 30, 30)
    sample.SetImplicitFunction(quadric)

    # Create five surfaces F(x,y,z) = constant between range specified. The
    # GenerateValues() method creates n isocontour values between the range
    # specified.
    contours = vtk.vtkContourFilter()
    contours.SetInputConnection(sample.GetOutputPort())
    contours.GenerateValues(8, 0.0, 1.2)

    contMapper = vtk.vtkPolyDataMapper()
    contMapper.SetInputConnection(contours.GetOutputPort())
    contMapper.SetScalarRange(0.0, 1.2)

    contActor = vtk.vtkActor()
    contActor.SetMapper(contMapper)

    # We'll put a simple outline around the data.
    outline = vtk.vtkOutlineFilter()
    outline.SetInputConnection(sample.GetOutputPort())

    outlineMapper = vtk.vtkPolyDataMapper()
    outlineMapper.SetInputConnection(outline.GetOutputPort())

    outlineActor = vtk.vtkActor()
    outlineActor.SetMapper(outlineMapper)
    outlineActor.GetProperty().SetColor(1, 0.5, 0)

    # extract data from the volume
    extract = vtk.vtkExtractVOI()
    extract.SetInputConnection(sample.GetOutputPort())
    extract.SetVOI(0, 29, 0, 29, 15, 15)
    extract.SetSampleRate(1, 2, 3)

    contours2 = vtk.vtkContourFilter()
    contours2.SetInputConnection(extract.GetOutputPort())
    contours2.GenerateValues(8, 0.0, 1.2)

    contMapper2 = vtk.vtkPolyDataMapper()
    contMapper2.SetInputConnection(contours2.GetOutputPort())
    contMapper2.SetScalarRange(0.0, 1.2)

    contActor2 = vtk.vtkActor()
    contActor2.SetMapper(contMapper2)

    return contActor, contActor2, outlineActor, contours, contours2
开发者ID:alexlib,项目名称:PyDataNYC2015,代码行数:58,代码来源:scenes.py


示例5: __init__

    def __init__(self, parent):
        QVTKRenderWindowInteractor.__init__(self, parent)

        self.renderer = vtk.vtkRenderer()
        self.GetRenderWindow().AddRenderer(self.renderer)
        
        interactor = vtk.vtkInteractorStyleSwitch()
        self._Iren.SetInteractorStyle(interactor)
                
        self.surface = None

        # Remainng calls set up axes.
        tprop = vtk.vtkTextProperty()
        tprop.SetColor(1,1,1)

        # Create a faint outline to go with the axes.
        self.outline = vtk.vtkOutlineFilter()

        # Initially set up with a box as input.  This will be changed
        # to a plot once the user clicks something.
        self.box = vtk.vtkBox()
        self.box.SetBounds(0,10,0,10,0,10)
        sample = vtk.vtkSampleFunction()
        sample.SetImplicitFunction(self.box)
        sample.SetSampleDimensions(2,2,2)
        sample.SetModelBounds(0,10,0,10,0,5)
        sample.ComputeNormalsOff()

        self.outline.SetInputConnection(sample.GetOutputPort())
        mapOutline = vtk.vtkPolyDataMapper()
        mapOutline.SetInputConnection(self.outline.GetOutputPort())
        self.outlineActor = vtk.vtkActor()
        self.outlineActor.SetMapper(mapOutline)
        self.outlineActor.GetProperty().SetColor(1,1,1)
        self.outlineActor.GetProperty().SetOpacity(.25)
        self.renderer.AddActor(self.outlineActor)

        self.axes = vtk.vtkCubeAxesActor2D()
        self.axes.SetCamera(self.renderer.GetActiveCamera())
        self.axes.SetFlyModeToOuterEdges()

        self.axes.SetLabelFormat("%6.4g")
        self.axes.SetFontFactor(0.8)
        self.axes.SetAxisTitleTextProperty(tprop)
        self.axes.SetAxisLabelTextProperty(tprop)
        self.axes.SetXLabel("MPI Rank")
        self.axes.SetYLabel("Progress")
        self.axes.SetZLabel("Effort")
        self.axes.SetInput(sample.GetOutput())
        self.renderer.AddViewProp(self.axes)

        # Keep original camera around in case it gets changed
        self.originalCamera = self.renderer.GetActiveCamera()

        self.renderer.GetActiveCamera().Pitch(90)     # Want effort to be vertical
        self.renderer.GetActiveCamera().OrthogonalizeViewUp()
        self.renderer.ResetCamera()
        self.renderer.GetActiveCamera().Elevation(15)  # Be slightly above the data
开发者ID:cmcantalupo,项目名称:libra,代码行数:58,代码来源:vtkutils.py


示例6: __init__

    def __init__(self, parent = None):
        super(VTKFrame, self).__init__(parent)

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        vl = QtGui.QVBoxLayout(self)
        vl.addWidget(self.vtkWidget)
        vl.setContentsMargins(0, 0, 0, 0)
 
        self.ren = vtk.vtkRenderer()
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
 
        # Create cylinder
        cylinder = vtk.vtkCylinder()
        cylinder.SetCenter(0, 0, 0)
        cylinder.SetRadius(1.0)
        
        # Create plane
        plane = vtk.vtkPlane()
        plane.SetOrigin(0, 0, 0)
        plane.SetNormal(0, -1, 0)

        # Cut the cylinder
        cuted_cylinder = vtk.vtkImplicitBoolean()
        cuted_cylinder.SetOperationTypeToIntersection()
        #cuted_cylinder.SetOperationTypeToUnion()
        cuted_cylinder.AddFunction(cylinder)
        cuted_cylinder.AddFunction(plane)

        # Sample 
        sample = vtk.vtkSampleFunction()
        sample.SetImplicitFunction(cuted_cylinder)
        sample.SetModelBounds(-1.5 , 1.5 , -1.5 , 1.5 , -1.5 , 1.5)
        sample.SetSampleDimensions(60, 60, 60)
        sample.SetComputeNormals(0)

        #
        surface = vtk.vtkContourFilter()
        #surface.SetInput(sample.GetOutput())
        surface.SetInputConnection(sample.GetOutputPort())
 
        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        #mapper.SetInput(surface.GetOutput())
        mapper.SetInputConnection(surface.GetOutputPort())
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
 
        self.ren.AddActor(actor)
        self.ren.ResetCamera()

        self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:54,代码来源:implicitfunction.py


示例7: __init__

    def __init__(self, parent = None):
        super(VTKFrame, self).__init__(parent)

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        vl = QtGui.QVBoxLayout(self)
        vl.addWidget(self.vtkWidget)
        vl.setContentsMargins(0, 0, 0, 0)
 
        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(0.1, 0.2, 0.4)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
 
        sphere1 = vtk.vtkSphere()
        sphere1.SetCenter(0.9, 0, 0)
        sphere2 = vtk.vtkSphere()
        sphere2.SetCenter(-0.9, 0, 0)

        implicitBoolean = vtk.vtkImplicitBoolean()
        implicitBoolean.AddFunction(sphere1)
        implicitBoolean.AddFunction(sphere2)
        implicitBoolean.SetOperationTypeToUnion()
        #implicitBoolean.SetOperationTypeToIntersection()

        # Sample the function
        sample = vtk.vtkSampleFunction()
        sample.SetSampleDimensions(50, 50, 50)
        sample.SetImplicitFunction(implicitBoolean)
        sample.SetModelBounds(-3, 3, -3, 3, -3, 3)

        # Create the 0 isosurface
        contours = vtk.vtkContourFilter()
        contours.SetInputConnection(sample.GetOutputPort())
        contours.GenerateValues(1, 1, 1)
 
        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(contours.GetOutputPort())
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
 
        self.ren.AddActor(actor)
        self.ren.ResetCamera()

        self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:47,代码来源:implicitboolean.py


示例8: drawPlane

  def drawPlane(self, m, V_norm):
    scene = slicer.mrmlScene

    #create a plane to cut,here it cuts in the XZ direction (xz normal=(1,0,0);XY =(0,0,1),YZ =(0,1,0)
    planex=vtk.vtkPlane()
    planex.SetOrigin(m[0],m[1],m[2])
    planex.SetNormal(V_norm[0],V_norm[1],V_norm[2])

    renderer = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow().GetRenderers().GetFirstRenderer()
    viewSize = renderer.ComputeVisiblePropBounds()
    #viewSize = (-50.0, 50.0, -50.0, 50.0, -50.0, 50.0)


    planexSample = vtk.vtkSampleFunction()
    planexSample.SetImplicitFunction(planex)
    planexSample.SetModelBounds(viewSize)
    #planexSample.SetSampleDimensions(200,200,200)
    planexSample.ComputeNormalsOff()
    plane1 = vtk.vtkContourFilter()
    plane1.SetInputConnection(planexSample.GetOutputPort())


    # Create model Plane A node
    planeA = slicer.vtkMRMLModelNode()
    planeA.SetScene(scene)
    planeA.SetName("X-Y Plane")
    planeA.SetAndObservePolyData(plane1.GetOutput())

    # Create display model Plane A node
    planeAModelDisplay = slicer.vtkMRMLModelDisplayNode()
    planeAModelDisplay.SetColor(0.145,0.77,0.596)
    
    planeAModelDisplay.BackfaceCullingOff()
    planeAModelDisplay.SetScene(scene)
    scene.AddNode(planeAModelDisplay)
    planeA.SetAndObserveDisplayNodeID(planeAModelDisplay.GetID())

    #Add to scene
    planeAModelDisplay.SetInputPolyDataConnection(plane1.GetOutputPort())
    scene.AddNode(planeA)

    # adjust center of 3d view to plane
    layoutManager = slicer.app.layoutManager()
    threeDWidget = layoutManager.threeDWidget(0)
    threeDView = threeDWidget.threeDView()
    threeDView.resetFocalPoint()
开发者ID:RocioLO,项目名称:SoundGuidance,代码行数:46,代码来源:SoundGuidance.py


示例9: opImplement

    def opImplement(self):
         
        
        sample_implicit = vtk.vtkSampleFunction();
        #sample_implicit.CappingOn();
        sample_implicit.ComputeNormalsOn();
        #sample_implicit.SetCapValue(.05);
        from math import ceil;
        from random import randint;

        x_len = self.bbox.x_max  - self.bbox.x_min ;
        y_len = self.bbox.y_max -self.bbox.y_min ;
        z_len = self.bbox.z_max -self.bbox.z_min ;
        x_res = int(ceil(x_len/self.resoulation[0]));
        y_res = int(ceil(y_len/self.resoulation[1]));
        z_res = int(ceil(z_len/self.resoulation[2]));
        
        import time;
        threshold = 1.5;
        #Main slower....
        #sample_implicit.SetSampleDimensions(x_res,y_res,z_res);
        sample_implicit.SetSampleDimensions(int(VOLUME_SETP),int(VOLUME_SETP),int(VOLUME_SETP));
        #sample_implicit.SetSampleDimensions(100,100,100);
        sample_implicit.SetImplicitFunction(self.data);
        sample_implicit.SetOutputScalarTypeToUnsignedChar();
        sample_implicit.SetModelBounds(self.bbox.x_min * threshold,self.bbox.x_max * threshold,self.bbox.y_min * threshold,self.bbox.y_max * threshold,self.bbox.z_min * threshold,self.bbox.z_max * threshold);
        sample_implicit.Update();
        sampled_result = sample_implicit.GetOutput();

        #Difference between Marching cubes and contour filter?????
        structed_point2Poly = vtk.vtkMarchingCubes();
        #structed_point2Poly = vtk.vtkContourFilter();
        structed_point2Poly.SetInputData(sampled_result);
        structed_point2Poly.ComputeScalarsOff();
        structed_point2Poly.ComputeNormalsOff();
        structed_point2Poly.ComputeGradientsOff();
        structed_point2Poly.GenerateValues(1,1,1);
        #structed_point2Poly.SetValue(0,int(IMAGEIN+1)); #threshold
        structed_point2Poly.SetValue(0,int((IMAGEIN+IMAGEOUT)/2.0)); #threshold
        structed_point2Poly.Update();
                
        result = structed_point2Poly.GetOutput();
        return result;
开发者ID:avontd2868,项目名称:OU_Final_Year,代码行数:43,代码来源:vtkOperations.py


示例10: __init__

    def __init__(self, parent = None):
        super(VTKFrame, self).__init__(parent)

        self.vtkWidget = QVTKRenderWindowInteractor(self)
        vl = QtGui.QVBoxLayout(self)
        vl.addWidget(self.vtkWidget)
        vl.setContentsMargins(0, 0, 0, 0)
 
        self.ren = vtk.vtkRenderer()
        self.ren.SetBackground(0.1, 0.2, 0.4)
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()
 
        # Create the quadric function definition
        quadric = vtk.vtkQuadric()
        quadric.SetCoefficients(0.5, 1, 0.2, 0, 0.1, 0, 0, 0.2, 0, 0)
        #quadric.SetCoefficients(0.5, 0, 0.2, 0, 0, 0, 0, 0, 0, -0.1)

        # Sample the quadric function
        sample = vtk.vtkSampleFunction()
        sample.SetSampleDimensions(50, 50, 50)
        sample.SetImplicitFunction(quadric)
        sample.SetModelBounds(-1, 1, -1, 1, -1, 1)

        contourFilter = vtk.vtkContourFilter()
        contourFilter.SetInputConnection(sample.GetOutputPort())
        #contourFilter.GenerateValues(1, 1, 1)
        contourFilter.Update()
 
        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(contourFilter.GetOutputPort())
 
        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)
 
        self.ren.AddActor(actor)
        self.ren.ResetCamera()

        self._initialized = False
开发者ID:dbzhang800,项目名称:VTKDemoForPyQt,代码行数:41,代码来源:quadraticsuface.py


示例11: Execute

    def Execute(self):

        if self.Seeds == None:
            self.PrintError('Error: No input seeds.')

        rbf = vtkvmtk.vtkvmtkRBFInterpolation()
        rbf.SetSource(self.Seeds)
        if self.RBFType == "thinplatespline":
            rbf.SetRBFTypeToThinPlateSpline()
        elif self.RBFType == "biharmonic":
            rbf.SetRBFTypeToBiharmonic()
        elif self.RBFType == "triharmonic":
            rbf.SetRBFTypeToTriharmonic()
        rbf.ComputeCoefficients()

        if self.Image:
            origin = self.Image.GetOrigin()
            spacing = self.Image.GetSpacing()
            extent = self.Image.GetExtent()
            dimensions = self.Image.GetDimensions()
            modelBounds = [0.0,0.0,0.0,0.0,0.0,0.0]
            modelBounds[0] = origin[0] + spacing[0]*extent[0]
            modelBounds[1] = origin[0] + spacing[0]*extent[1]
            modelBounds[2] = origin[1] + spacing[1]*extent[2]
            modelBounds[3] = origin[1] + spacing[1]*extent[3]
            modelBounds[4] = origin[2] + spacing[2]*extent[4]
            modelBounds[5] = origin[2] + spacing[2]*extent[5]
        else:
            dimensions = self.Dimensions
            modelBounds = self.Bounds
        
        sampleFunction = vtk.vtkSampleFunction()
        sampleFunction.SetImplicitFunction(rbf)
        sampleFunction.SetOutputScalarTypeToDouble()
        sampleFunction.SetSampleDimensions(dimensions)
        sampleFunction.SetModelBounds(modelBounds)
        sampleFunction.CappingOff()
        sampleFunction.ComputeNormalsOff()
        sampleFunction.Update()
        
        self.Image = sampleFunction.GetOutput() 
开发者ID:vmtk,项目名称:vmtk,代码行数:41,代码来源:vmtkrbfinterpolation.py


示例12: create_renderer

def create_renderer():
    """
    vtk renderer with a sample scene
    """
    quadric = vtk.vtkQuadric()
    quadric.SetCoefficients(.5, 1, .2, 0, .1, 0, 0, .2, 0, 0)

    sample = vtk.vtkSampleFunction()
    sample.SetSampleDimensions(50, 50, 50)
    sample.SetImplicitFunction(quadric)

    contours = vtk.vtkContourFilter()
    contours.SetInputConnection(sample.GetOutputPort())
    contours.GenerateValues(5, 0.0, 1.2)

    contour_mapper = vtk.vtkPolyDataMapper()
    contour_mapper.SetInputConnection(contours.GetOutputPort())
    contour_mapper.SetScalarRange(0.0, 1.2)

    contour_actor = vtk.vtkActor()
    contour_actor.SetMapper(contour_mapper)

    outline = vtk.vtkOutlineFilter()
    outline.SetInputConnection(sample.GetOutputPort())

    outline_mapper = vtk.vtkPolyDataMapper()
    outline_mapper.SetInputConnection(outline.GetOutputPort())

    outline_actor = vtk.vtkActor()
    outline_actor.SetMapper(outline_mapper)
    outline_actor.GetProperty().SetColor(0, 0, 0)

    renderer = vtk.vtkRenderer()
    renderer.AddActor(contour_actor)
    renderer.AddActor(outline_actor)
    renderer.SetBackground(.75, .75, .75)

    return renderer
开发者ID:alexlib,项目名称:PyDataNYC2015,代码行数:38,代码来源:scenes.py


示例13: Ellipsoid

def Ellipsoid(center, color, U):
    # create the quadric function definition
    a0 = U[0][0]
    a1 = U[1][1]
    a2 = U[2][2]
    a3 = 2*U[0][1]
    a4 = 2*U[1][2]
    a5 = 2*U[0][2]
    quadric = vtk.vtkQuadric()
    quadric.SetCoefficients(a0,a1,a2,a3,a4,a5,0,0,0,-1.5282)
    # F(x,y,z) = a0*x^2 + a1*y^2 + a2*z^2 + a3*x*y + a4*y*z + a5*x*z + a6*x + a7*y + a8*z + a9
 
    # sample the quadric function
    sample = vtk.vtkSampleFunction()
    sample.SetSampleDimensions(36,36,36)
    sample.SetImplicitFunction(quadric)
    sample.SetModelBounds(-2, 2, -2, 2, -2, 2)
 
    #create the 0 isosurface
    contours = vtk.vtkContourFilter()
    contours.SetInput(sample.GetOutput())
    contours.GenerateValues(1,1,1)

    transform = vtk.vtkTransform()
    transform.Translate(center)
 
    # map the contours to graphical primitives
    contourMapper = vtk.vtkPolyDataMapper()
    contourMapper.SetInput(contours.GetOutput())
    contourMapper.ScalarVisibilityOff()
 
    # create an actor for the contours
    contourActor = vtk.vtkActor()
    contourActor.SetMapper(contourMapper)
    contourActor.GetProperty().SetColor(color) # (R,G,B)
    contourActor.SetUserTransform(transform)
    return contourActor
开发者ID:pombredanne,项目名称:tdl,代码行数:37,代码来源:pisurf_structure_viewer.py


示例14: __init__

    def __init__(self, module_manager):
        ModuleBase.__init__(self, module_manager)

        # setup config
        self._config.sampleDimensions = (64, 64, 64)
        self._config.modelBounds = (-1, 1, -1, 1, -1, 1)
        # we init normals to off, they EAT memory (3 elements per point!)
        self._config.computeNormals = False

        # and then our scripted config
        configList = [
            ('Sample dimensions: ', 'sampleDimensions', 'tuple:int,3',
             'text', 'The dimensions of the output volume.'),
            ('Model bounds: ', 'modelBounds', 'tuple:float,6', 'text',
             'Region in world space over which the sampling is performed.'),
            ('Compute normals: ', 'computeNormals', 'base:bool', 'checkbox',
             'Must normals also be calculated and stored.')]

        
        # now create the necessary VTK modules
        self._sampleFunction = vtk.vtkSampleFunction()
        # this is more than good enough.
        self._sampleFunction.SetOutputScalarTypeToFloat()
        # setup progress for the processObject
        module_utils.setup_vtk_object_progress(self, self._sampleFunction,
                                           "Sampling implicit function.")
        

        self._example_input = None

        # mixin ctor
        ScriptedConfigModuleMixin.__init__(
            self, configList,
            {'Module (self)' : self,
             'vtkSampleFunction' : self._sampleFunction})

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


示例15:

#!/usr/bin/env python
import vtk

# Test vtkExtractCells
# Control test size
#res = 200
res = 50

# Test cell extraction
#
# Quadric definition
quadric = vtk.vtkQuadric()
quadric.SetCoefficients([.5,1,.2,0,.1,0,0,.2,0,0])
sample = vtk.vtkSampleFunction()
sample.SetSampleDimensions(res,res,res)
sample.SetImplicitFunction(quadric)
sample.ComputeNormalsOff()
sample.Update()

# Now extract the cells: use badly formed range
extract = vtk.vtkExtractCells()
extract.SetInputConnection(sample.GetOutputPort())
extract.AddCellRange(0,sample.GetOutput().GetNumberOfCells())

extrMapper = vtk.vtkDataSetMapper()
extrMapper.SetInputConnection(extract.GetOutputPort())
extrMapper.ScalarVisibilityOff()

extrActor = vtk.vtkActor()
extrActor.SetMapper(extrMapper)
extrActor.GetProperty().SetColor(.8,.4,.4)
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:31,代码来源:TestExtractCells.py


示例16:

# tree.
sph = vtk.vtkSphereSource()
sph.SetPhiResolution(6)
sph.SetThetaResolution(12)
sph.SetRadius(1)

# Three dataset types will be defined in the following: image data,
# structured grid, and unstructured grid. This sampling of datasets tests the
# three execution paths currently in the sphere tree.

# Create a synthetic image data: sample a sphere across a volume
sphere = vtk.vtkSphere()
sphere.SetCenter(0.0,0.0,0.0)
sphere.SetRadius(0.25)

image = vtk.vtkSampleFunction()
image.SetImplicitFunction(sphere)
image.SetModelBounds(-0.5,0.5, -0.5,0.5, -0.5,0.5)
image.SetSampleDimensions(res,res,res)
image.Update()

# Handy dandy filter converts image data to structured grid
sgrid = vtk.vtkImageDataToPointSet()
sgrid.SetInputConnection(image.GetOutputPort())
sgrid.Update()

# Convert the image data to unstructured grid
extractionSphere = vtk.vtkSphere()
extractionSphere.SetRadius(100)
extractionSphere.SetCenter(0,0,0)
开发者ID:ElsevierSoftwareX,项目名称:SOFTX-D-15-00004,代码行数:30,代码来源:TestSphereTreeFilter2.py


示例17:

    mapper_axes_coor = vtk.vtkPolyDataMapper()
    mapper_axes_coor.SetInputConnection(axes_coor.GetOutputPort())
    actor_axes_coor = vtk.vtkActor()
    actor_axes_coor.SetMapper(mapper_axes_coor)
    renderer_1.AddActor(actor_axes_coor)
    renderer_2.AddActor(actor_axes_coor)

    iren.Initialize()
    iren.Start()

# ===========================================================================
# Left view: Quadric defined with vtkQuadric
quadric_1 = vtk.vtkQuadric()
quadric_1.SetCoefficients(coef)

sample_1 = vtk.vtkSampleFunction()
sample_1.SetImplicitFunction(quadric_1)
sample_1.ComputeNormalsOff()

contour_1 = vtk.vtkContourFilter()
contour_1.SetInputConnection(sample_1.GetOutputPort())
contour_1.SetValue(0, contour_value)

# ===========================================================================
# Right view: Quadric defined with meshgrid
range_x = [-1, 1]
range_y = [-1, 1]
range_z = [-1, 1]
step = 0.05
offset = 0.1
step_x = np.arange(range_x[0] - offset, range_x[1] + offset, step)
开发者ID:quentan,项目名称:Test_ImageData,代码行数:31,代码来源:TestImageData.py


示例18:

# vtkCompositeDataSet

# Control test size
res = 50
#res = 250
serialProcessing = 0
mergePoints = 1
interpolateAttr = 0
computeNormals = 0
computeScalarRange = 0

#
# Quadric definition
quadricL = vtk.vtkQuadric()
quadricL.SetCoefficients([.5,1,.2,0,.1,0,0,.2,0,0])
sampleL = vtk.vtkSampleFunction()
sampleL.SetModelBounds(-1,0, -1,1, -1,1)
sampleL.SetSampleDimensions(int(res/2),res,res)
sampleL.SetImplicitFunction(quadricL)
sampleL.ComputeNormalsOn()
sampleL.Update()

#
# Quadric definition
quadricR = vtk.vtkQuadric()
quadricR.SetCoefficients([.5,1,.2,0,.1,0,0,.2,0,0])
sampleR = vtk.vtkSampleFunction()
sampleR.SetModelBounds(0,1, -1,1, -1,1)
sampleR.SetSampleDimensions(int(res/2),res,res)
sampleR.SetImplicitFunction(quadricR)
sampleR.ComputeNormalsOn()
开发者ID:Kitware,项目名称:VTK,代码行数:31,代码来源:TestContour3DLinearGridCompositeInput.py


示例19: makeModels

    def makeModels(self):
        """
        make vtk model
        """

        # Here we create two ellipsoidal implicit functions and boolean them
        # together to form a "cross" shaped implicit function.
        quadric = vtk.vtkQuadric()
        quadric.SetCoefficients(.5, 1, .2, 0, .1, 0, 0, .2, 0, 0)

        sample = vtk.vtkSampleFunction()
        sample.SetSampleDimensions(50, 50, 50)
        sample.SetImplicitFunction(quadric)
        sample.ComputeNormalsOff()

        trans = vtk.vtkTransform()
        trans.Scale(1, .5, .333)
        sphere = vtk.vtkSphere()
        sphere.SetRadius(self.radius)
        sphere.SetTransform(trans)

        trans2 = vtk.vtkTransform()
        trans2.Scale(.25, .5, 1.0)
        sphere2 = vtk.vtkSphere()
        sphere2.SetRadius(self.radius)
        sphere2.SetTransform(trans2)

        self.sphere_geom_1 = sphere
        self.sphere_geom_2 = sphere2

        union = vtk.vtkImplicitBoolean()
        union.AddFunction(sphere)
        union.AddFunction(sphere2)
        union.SetOperationType(0)

        # Here is where it gets interesting. The implicit function is used to
        # extract those cells completely inside the function. They are then
        # shrunk to helpr show what was extracted.
        extract = vtk.vtkExtractGeometry()
        extract.SetInputConnection(sample.GetOutputPort())
        extract.SetImplicitFunction(union)
        shrink = vtk.vtkShrinkFilter()
        shrink.SetInputConnection(extract.GetOutputPort())
        shrink.SetShrinkFactor(self.shrink_factor)
        dataMapper = vtk.vtkDataSetMapper()
        dataMapper.SetInputConnection(shrink.GetOutputPort())

        self.shrink_geom = shrink

        # data actor
        self.data_actor = vtk.vtkActor()
        self.data_actor.SetMapper(dataMapper)

        # The outline gives context to the original data.
        outline = vtk.vtkOutlineFilter()
        outline.SetInputConnection(sample.GetOutputPort())
        outlineMapper = vtk.vtkPolyDataMapper()
        outlineMapper.SetInputConnection(outline.GetOutputPort())

        # outline actor
        self.outline_actor = vtk.vtkActor()
        self.outline_actor.SetMapper(outlineMapper)
        outlineProp = self.outline_actor.GetProperty()
        outlineProp.SetColor(0, 0, 0)
开发者ID:alexlib,项目名称:PyDataNYC2015,代码行数:64,代码来源:extract_model.py


示例20:

iceCream.SetRadius(0.5)
bite = vtk.vtkSphere()
bite.SetCenter(1.5,0,0.5)
bite.SetRadius(0.25)
# combine primitives to build ice-cream cone
theCone = vtk.vtkImplicitBoolean()
theCone.SetOperationTypeToIntersection()
theCone.AddFunction(cone)
theCone.AddFunction(vertPlane)
theCone.AddFunction(basePlane)
theCream = vtk.vtkImplicitBoolean()
theCream.SetOperationTypeToDifference()
theCream.AddFunction(iceCream)
theCream.AddFunction(bite)
# iso-surface to create geometry
theConeSample = vtk.vtkSampleFunction()
theConeSample.SetImplicitFunction(theCone)
theConeSample.SetModelBounds(-1,1.5,-1.25,1.25,-1.25,1.25)
theConeSample.SetSampleDimensions(60,60,60)
theConeSample.ComputeNormalsOff()
theConeSurface = vtk.vtkMarchingContourFilter()
theConeSurface.SetInputConnection(theConeSample.GetOutputPort())
theConeSurface.SetValue(0,0.0)
coneMapper = vtk.vtkPolyDataMapper()
coneMapper.SetInputConnection(theConeSurface.GetOutputPort())
coneMapper.ScalarVisibilityOff()
coneActor = vtk.vtkActor()
coneActor.SetMapper(coneMapper)
coneActor.GetProperty().SetColor(chocolate)
# iso-surface to create geometry
theCreamSample = vtk.vtkSampleFunction()
开发者ID:151706061,项目名称:VTK,代码行数:31,代码来源:iceCream.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python vtk.vtkScalarBarActor函数代码示例发布时间:2022-05-26
下一篇:
Python vtk.vtkSTLWriter函数代码示例发布时间: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