当前位置: 首页>>代码示例>>Python>>正文


Python vtk.vtkPolyDataNormals函数代码示例

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


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

示例1: OnExportSurface

    def OnExportSurface(self, pubsub_evt):
        filename, filetype = pubsub_evt.data
        if (filetype == const.FILETYPE_STL) or\
           (filetype == const.FILETYPE_VTP) or\
           (filetype == const.FILETYPE_PLY) or\
           (filetype == const.FILETYPE_STL_ASCII):

            # First we identify all surfaces that are selected
            # (if any)
            proj = prj.Project()
            polydata_list = []

            for index in proj.surface_dict:
                surface = proj.surface_dict[index]
                if surface.is_shown:
                    polydata_list.append(surface.polydata)

            if len(polydata_list) == 0:
                utl.debug("oops - no polydata")
                return
            elif len(polydata_list) == 1:
                polydata = polydata_list[0]
            else:
                polydata = pu.Merge(polydata_list)

            # Having a polydata that represents all surfaces
            # selected, we write it, according to filetype
            if filetype == const.FILETYPE_STL:
                writer = vtk.vtkSTLWriter()
                writer.SetFileTypeToBinary()
            elif filetype == const.FILETYPE_STL_ASCII:
                writer = vtk.vtkSTLWriter()
                writer.SetFileTypeToASCII()
            elif filetype == const.FILETYPE_VTP:
                writer = vtk.vtkXMLPolyDataWriter()
            #elif filetype == const.FILETYPE_IV:
            #    writer = vtk.vtkIVWriter()
            elif filetype == const.FILETYPE_PLY:
                writer = vtk.vtkPLYWriter()
                writer.SetFileTypeToASCII()
                writer.SetColorModeToOff()
                #writer.SetDataByteOrderToLittleEndian()
                #writer.SetColorModeToUniformCellColor()
                #writer.SetColor(255, 0, 0)

            if filetype in (const.FILETYPE_STL, const.FILETYPE_PLY):
                # Invert normals
                normals = vtk.vtkPolyDataNormals()
                normals.SetInputData(polydata)
                normals.SetFeatureAngle(80)
                normals.AutoOrientNormalsOn()
                #  normals.GetOutput().ReleaseDataFlagOn()
                normals.UpdateInformation()
                normals.Update()
                polydata = normals.GetOutput()

            filename = filename.encode(wx.GetDefaultPyEncoding())
            writer.SetFileName(filename)
            writer.SetInputData(polydata)
            writer.Write()
开发者ID:151706061,项目名称:invesalius3,代码行数:60,代码来源:surface.py

示例2: __init__

    def __init__(self, mesh):
        assert mesh != None
        
        self._mesh = mesh
        self._batch = None
        self._color = (0.0, 1.0, 0.0, 1.0)
        
        #smooth_loop = vtk.vtkLoopSubdivisionFilter()
        #smooth_loop.SetNumberOfSubdivisions(3)
        #smooth_loop.SetInput(cleanPolyData.GetOutput())
        #self.mesh = smooth_loop.GetOutput()

        normals = vtk.vtkPolyDataNormals()
        normals.SetInput(self._mesh)
        normals.ComputeCellNormalsOn()
        output = normals.GetOutput()
        output.Update();
        cellData = output.GetCellData();
        self._normals = cellData.GetNormals();

        self._caster = vtk.vtkOBBTree()
        #set the 'mesh' as the caster's dataset
        self._caster.SetDataSet(self._mesh)
        #build a caster locator
        self._caster.BuildLocator()
开发者ID:joshalbrecht,项目名称:shinyshell,代码行数:25,代码来源:mesh.py

示例3: _initialize

    def _initialize (self):
        debug ("In TensorGlyphs::_initialize ()")

        self.sphere.SetThetaResolution (8)
        self.sphere.SetPhiResolution (8)

        self.glyphs.SetInput (self.data_out)
        self.glyphs.SetSource (self.sphere.GetOutput())
        self.glyphs.SetScaleFactor (1.0)
        self.glyphs.ClampScalingOn ()
        self.glyphs.SetMaxScaleFactor (5.0)

        self.normals = vtk.vtkPolyDataNormals ()
        self.normals.SetInput (self.glyphs.GetOutput ())
        
        self.mapper.SetInput (self.normals.GetOutput ())
        self.actor.SetMapper (self.mapper)

        self.actor.GetProperty ().SetLineWidth (2)
        self.actor.GetProperty ().BackfaceCullingOff ()
        # self.actor.GetProperty ().FrontfaceCullingOff ()

        self.actor.GetProperty ().SetColor (*Common.config.fg_color)
        self.center = self.data_out.GetCenter ()
        self.renwin.add_actors (self.actor)
        # used for the pipeline browser
        self.pipe_objs = self.actor
开发者ID:sldion,项目名称:DNACC,代码行数:27,代码来源:TensorGlyphs.py

示例4: AddPolyData

    def AddPolyData(self, polyData, colorMap=None):
        """
        colorMap should be a vtkScalarsToColors (or derived class) object
        """
        if colorMap is None:
            colorMap = VTKViewer.GetDefaultColorMap(polyData.GetScalarRange())
        polyDataMapper = vtk.vtkPolyDataMapper()
        polyDataMapper.SetLookupTable(colorMap)

        if polyData.GetPointData().GetNormals() is None:
            polyDataNormals = vtk.vtkPolyDataNormals()
            try:
                polyDataNormals.SetInputData(polyData)
            except:
                polyDataNormals.SetInput(polyData)
            polyDataNormals.SetFeatureAngle(90.0)
            polyDataMapper.SetInputConnection(
                polyDataNormals.GetOutputPort())
        else:
            try:
                polyDataMapper.SetInputData(polyData)
            except:
                polyDataMapper.SetInput(polyData)
        actor = vtk.vtkActor()
        actor.GetProperty().SetPointSize(3)
        actor.SetMapper(polyDataMapper)
        self.renderer.AddActor(actor)
开发者ID:ccraddock,项目名称:mindboggle,代码行数:27,代码来源:vtkviewer.py

示例5: get_isosurface

    def get_isosurface(self, iso_value=500):

        if not self.flag_read:
            sys.stderr.write('No Image Loaded!\n')
            return

        contour = vtk.vtkContourFilter()
        normals = vtk.vtkPolyDataNormals()
        stripper = vtk.vtkStripper()
        mapper = vtk.vtkPolyDataMapper()

        contour.SetInputData(self.reader)
        contour.SetValue(0, iso_value)

        normals.SetInputConnection(contour.GetOutputPort())
        normals.SetFeatureAngle(60.0)
        normals.ReleaseDataFlagOn()

        stripper.SetInputConnection(normals.GetOutputPort())
        stripper.ReleaseDataFlagOn()

        mapper.SetInputConnection(stripper.GetOutputPort())
        mapper.SetScalarVisibility(False)

        actor = vtk.vtkActor()
        actor.SetMapper(mapper)

        # Default colour, should be changed.
        actor.GetProperty().SetDiffuseColor(
            [247.0 / 255.0, 150.0 / 255.0, 155.0 / 255.0])  # Look like red
        actor.GetProperty().SetSpecular(0.3)
        actor.GetProperty().SetSpecularPower(20)

        return actor
开发者ID:quentan,项目名称:Work_Test_4,代码行数:34,代码来源:medical_object.py

示例6: __init__

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

示例7: MouseMove

    def MouseMove(self, data):
        print("Load Cache %s" % data )
        print ("Iren data")
        #print iren
        #addcube
        #print ren
        print ren.GetViewPoint()
        print ren.GetDisplayPoint()
        print ren.WorldToView()
        print ren.ComputeVisiblePropBounds()
        ysize = renWin.GetSize()[1]
        c.SetValue(0,ysize)
        c.Update()
        normals = vtk.vtkPolyDataNormals()
        normals.SetInputData(c.GetOutput())
        normals.SetFeatureAngle(25) #?
        normals.Update()

        normals.SetFeatureAngle(45) #?
        normals.Update()
        mapper2 = vtk.vtkPolyDataMapper()
        mapper2.SetInputData(normals.GetOutput())
        mapper2.ScalarVisibilityOn()
        mapper2.SetScalarRange(-.5,1)
        mapper2.SetScalarModeToUsePointFieldData()
        mapper2.ColorByArrayComponent("Velocity", 0)
        actor2 = vtk.vtkActor()
        actor2.SetMapper(mapper2)
        ren.AddActor(actor2)
开发者ID:sshamilton,项目名称:vtkscripts,代码行数:29,代码来源:tviewer.py

示例8: Contours

 def Contours(self, num, opacity=0.2):
     contour = vtk.vtkMarchingContourFilter()
     contour.SetInput(self.vtkgrid)
     r = max(abs(self.vmin), abs(self.vmax))
     if num % 2 == 0 or self.vmin * self.vmax >= 0:
         contour.GenerateValues(
             num, (self.vmin + r / num, self.vmax - r / num))
     elif num == 1:
         contour.SetValue(0, 0)
     else:
         r = r - r / num
         contour.GenerateValues(num, -r, r)
     contour.ComputeScalarsOn()
     contour.UseScalarTreeOn()
     contour.Update()
     normals = vtk.vtkPolyDataNormals()
     normals.SetInput(contour.GetOutput())
     mapper = vtk.vtkPolyDataMapper()
     mapper.SetInput(normals.GetOutput())
     mapper.SetLookupTable(self.lut)
     mapper.SetScalarRange(self.vmin, self.vmax)
     actor = vtk.vtkActor()
     actor.SetMapper(mapper)
     actor.GetProperty().SetOpacity(opacity)
     actor.GetProperty().SetLineWidth(3)
     return actor
开发者ID:siudej,项目名称:Steklov-eigenvalues,代码行数:26,代码来源:viper3d.py

示例9: __init__

    def __init__(self, reader):
        self.reader = reader
        sg = self.src_glyph = vtk.vtkSphereSource()
        sg.SetRadius(0.5)
        sg.SetCenter(0.5, 0.0, 0.0)
        g = self.glyph = vtk.vtkTensorGlyph()        
        g.SetInputConnection(self.reader.GetOutputPort())
        g.SetSource(self.src_glyph.GetOutput())
        g.SetScaleFactor(0.25)
        
        # The normals are needed to generate the right colors and if
        # not used some of the glyphs are black.        
        self.normals = vtk.vtkPolyDataNormals()
        self.normals.SetInputConnection(g.GetOutputPort())
        self.map = vtk.vtkPolyDataMapper()
        self.map.SetInputConnection(self.normals.GetOutputPort())        
        self.act = vtk.vtkActor()
        self.act.SetMapper(self.map)

        # An outline.
        self.of = vtk.vtkOutlineFilter()
        self.of.SetInputConnection(self.reader.GetOutputPort())
        self.out_map = vtk.vtkPolyDataMapper()
        self.out_map.SetInputConnection(self.of.GetOutputPort())
        self.out_act = vtk.vtkActor()
        self.out_act.SetMapper(self.out_map)        
开发者ID:Armand0s,项目名称:homemade_vtk,代码行数:26,代码来源:TestTensorGlyph.py

示例10: vertex_normal

def vertex_normal(dataset):
    "Returns the vertex normal of each point in a dataset."
    if not dataset:
        raise RuntimeError("Need a dataset to compute vertex_normal")

    ds = dataset.NewInstance()
    ds.UnRegister(None)
    ds.CopyStructure(dataset.VTKObject)

    filter = vtk.vtkPolyDataNormals()
    filter.SetInputData(ds)
    filter.ComputeCellNormalsOff()
    filter.ComputePointNormalsOn()

    filter.SetFeatureAngle(180)
    filter.SplittingOff()
    filter.ConsistencyOff()
    filter.AutoOrientNormalsOff()
    filter.FlipNormalsOff()
    filter.NonManifoldTraversalOff()
    filter.Update()

    varray = filter.GetOutput().GetPointData().GetNormals()
    ans = dsa.vtkDataArrayToVTKArray(varray, dataset)

    # The association information has been lost over the vtk filter
    # we must reconstruct it otherwise lower pipeline will be broken.
    ans.Association = dsa.ArrayAssociation.POINT

    return ans
开发者ID:RCBiczok,项目名称:VTK,代码行数:30,代码来源:internal_algorithms.py

示例11: polyNorm

def polyNorm(ren,obj):
    #@c Add vtkPolyDataNormals to the vtkPolyData viewing pipeline.
    #@note there is no proc to perform the reverse operation (i.e. remove
    #@note the normals).  This is because the caller can presumably just
    #@note turn off normal-based properties via the actor's vtkProperty.
    #@a ren: renderer
    #@a obj: object name
    if isinstance(obj,list):
        tag = "%s_%s" % (ren[0],obj[0])
        objName = obj[0]
    elif isinstance(obj,str):
        tag = "%s_%s" % (ren[0],obj)
        objName = obj
    else:
        raise ValueError("Argument type unsupported.")
    nrm = [None]*2
    
    try:
        Map = getattr(vis,"p_map_"+tag)
    except:
        raise ValueError(objName + " not currently being displayed in " + ren[0])
        
    act = getattr(vis,"p_act_"+tag)
    nrm[0] = "p_nrm_" + tag
    
    nrm[1] = vtk.vtkPolyDataNormals()
    nrm[1].SetInputDataObject(Map[1].GetInput())
    Map[1].SetInputDataObject(nrm[1].GetOutput())
    nrm[1].Update()
    
    setattr(vis,Map[0], Map)
    setattr(vis,act[0],act)
    setattr(vis,nrm[0],nrm)
    return act
开发者ID:osmsc,项目名称:SimVascular,代码行数:34,代码来源:poly.py

示例12: AddPolyData

    def AddPolyData(self, polyData, colorMap=None):
        """
        colorMap should be a vtkScalarsToColors (or derived class) object
        """
        if colorMap is None:
            colorMap = VTKViewer.GetDefaultColorMap(polyData.GetScalarRange())
        polyDataMapper = vtk.vtkPolyDataMapper()
        polyDataMapper.SetLookupTable(colorMap)

        if polyData.GetPointData().GetNormals() is None:
            polyDataNormals = vtk.vtkPolyDataNormals()

            # Migrate to VTK6:
            # http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Replacement_of_SetInput
            # Old: polyDataNormals.SetInput(polyData)
            polyDataNormals.SetInputData(polyData)

            polyDataNormals.SetFeatureAngle(90.0)
            polyDataMapper.SetInputConnection(polyDataNormals.GetOutputPort())
        else:
            # Migrate to VTK6:
            # http://www.vtk.org/Wiki/VTK/VTK_6_Migration/Replacement_of_SetInput
            # Old: polyDataMapper.SetInput(polyData)
            polyDataMapper.SetInputData(polyData)

        actor = vtk.vtkActor()
        actor.GetProperty().SetPointSize(3)
        actor.SetMapper(polyDataMapper)
        self.renderer.AddActor(actor)
开发者ID:akeshavan,项目名称:mindboggle,代码行数:29,代码来源:vtkviewer.py

示例13: create_actors_for_skin_and_bone

def create_actors_for_skin_and_bone(reader):
    actors_list = []
    for contour_val, color, opacity in SKIN_BONE_LIST:
	contour = vtk.vtkContourFilter()
	contour.SetInput(reader.GetOutput())
	contour.SetNumberOfContours(1)
	contour.SetValue(contour_val[0], contour_val[1])

	normals = vtk.vtkPolyDataNormals()
	normals.SetInput(contour.GetOutput())
	normals.SetFeatureAngle(60)
	normals.ConsistencyOff()
	normals.SplittingOff()

	mapper = vtk.vtkPolyDataMapper()
	mapper.SetInput(normals.GetOutput())
	mapper.ScalarVisibilityOff()

	actor = vtk.vtkActor()
	actor.SetMapper(mapper)
	actor.GetProperty().SetColor(color)
        actor.GetProperty().SetOpacity(opacity)
	actor.RotateX(-90)
        actors_list.append(actor)
    return actors_list
开发者ID:arun04ceg,项目名称:3D-spatial-data,代码行数:25,代码来源:iso_surfacing.py

示例14: __init__

    def __init__(self, grid, vtkish_polydata=None, angle=15):

        vtkPolyDataPipeline.__init__(self, vtkish_polydata)

        # Make sure grid argument is correct type
        assert isinstance(grid, vtkVolumeGrid)
        self.grid = grid

        # Split polys with intersection angles greater than angle
        vtk_dnorm = vtkPolyDataNormals()
        vtk_dnorm.SetFeatureAngle(angle)
        vtk_dnorm.SplittingOn()
        vtk_dnorm.ComputeCellNormalsOff()
        vtk_dnorm.ComputePointNormalsOff()
        self.append(vtk_dnorm)

        relax = self.grid.get_relaxation_factor()

        if relax is not None:
            print 'relax=',relax
            #vtk_subdiv = vtkButterflySubdivisionFilter()
            vtk_subdiv = vtkLinearSubdivisionFilter()
            self.append(vtk_subdiv)
    
            # Smooth out some of the sharp points.
            vtk_smooth = vtkSmoothPolyDataFilter()
            vtk_smooth.SetRelaxationFactor(relax)
            self.append(vtk_smooth)
开发者ID:JConwayAWT,项目名称:PGSS14CC,代码行数:28,代码来源:pipeline.py

示例15: Execute

    def Execute(self):

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

        if self.ReferenceSurface == None:
            self.PrintError('Error: No ReferenceSurface.')

        if self.SignedDistanceArrayName != '':
            normalsFilter = vtk.vtkPolyDataNormals()
            normalsFilter.SetInputData(self.ReferenceSurface)
            normalsFilter.AutoOrientNormalsOn()
            normalsFilter.SetFlipNormals(self.FlipNormals)
            normalsFilter.Update()
            self.ReferenceSurface.GetPointData().SetNormals(normalsFilter.GetOutput().GetPointData().GetNormals())

        if self.DistanceArrayName != '' or self.DistanceVectorsArrayName != '' or self.SignedDistanceArrayName != '':
            self.PrintLog('Computing distance.')
            surfaceDistance = vtkvmtk.vtkvmtkSurfaceDistance()
            surfaceDistance.SetInputData(self.Surface)
            surfaceDistance.SetReferenceSurface(self.ReferenceSurface)
            if self.DistanceArrayName != '':
                surfaceDistance.SetDistanceArrayName(self.DistanceArrayName)
            if self.DistanceVectorsArrayName != '':
                surfaceDistance.SetDistanceVectorsArrayName(self.DistanceVectorsArrayName)
            if self.SignedDistanceArrayName != '':
                surfaceDistance.SetSignedDistanceArrayName(self.SignedDistanceArrayName)
            surfaceDistance.Update()
            self.Surface = surfaceDistance.GetOutput()
开发者ID:samsmu,项目名称:vmtk,代码行数:29,代码来源:vmtksurfacedistance.py


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