[vtkusers] a problem on vtkContourFilter filter

scofield zhu scofieldzhu.zcg at gmail.com
Fri Sep 30 01:03:51 EDT 2011


Hi All:
      i meet a problem,  and it's urgent to me, please help me!

      the problem description:
      I want to create mask surface actor and split surface actor
using same function called__GenerateSurfaceData to create surface
data.
      But when application run at the following codes, application crashed.
              surfaceFactory.CreateSplitSurfaceActor(
self.__MaskImageData, [3, 4], (1.0, 0.0, 0.0) )
              surfaceFactory.CreateMaskSurfaceActor( self.__MaskImageData,
5, ( 0.0, 1.0, 0.0 ) )  #crash inside this call
      why this problem occur only through same calling step?

      example code is as following:


 class SurfaceActorFactory( AtamaiActorFactory ):
	def __GenerateSurfaceData(self, imageData, intensities):
        threshold = vtkImageThreshold()
        threshold.ReleaseDataFlagOn()
        threshold.SetInput( imageData )
        threshold.SetInValue( 100 )
        threshold.SetOutValue( 0 )
        minValue = int( intensities[0] )
        maxValue = int( intensities[len(intensities) - 1] )
        threshold.ThresholdBetween( minValue, maxValue )

        extractor = vtkContourFilter()
        extractor.ReleaseDataFlagOn()
        extractor.SetInput( threshold.GetOutput() )
        extractor.SetValue( 0, 100 )

		decimate = vtkDecimatePro()
		decimate.ReleaseDataFlagOn()
		decimate.SetInput( extractor.GetOutput() )
		decimate.PreserveTopologyOff()
		decimate.SplittingOn()
		decimate.BoundaryVertexDeletionOn()
		decimate.SetMaximumError( VTK_DOUBLE_MAX )
		decimate.SetTargetReduction( 0.5 )

		sincFilter = vtkWindowedSincPolyDataFilter()
		sincFilter.ReleaseDataFlagOn()
		sincFilter.SetInput( decimate.GetOutput() )
		sincFilter.BoundarySmoothingOn()
		sincFilter.FeatureEdgeSmoothingOn()
		sincFilter.NonManifoldSmoothingOn()
		sincFilter.SetFeatureAngle( 180 )

		normals = vtkPolyDataNormals()
		normals.ReleaseDataFlagOn()
		normals.SetInput( sincFilter.GetOutput() )
		normals.ComputeCellNormalsOn()
		normals.ConsistencyOn()
		normals.SplittingOn()
			
		triFilter = vtkTriangleFilter()
		triFilter.ReleaseDataFlagOn()
		triFilter.SetInput( normals.GetOutput() )
		targetPolyData = triFilter.GetOutput()
		targetPolyData.Update()
		
		del triFilter
		del normals
		del sincFilter
		del decimate
		del extractor
		del threshold
		del imageData
		return targetPolyData
		
    def CreateMaskSurfaceActor(self, maskImageData, maskIntensity, maskColor):
        if self.__MaskSurfaceActor:
            return
        maskPolyData = self.__GenerateSurfaceData( maskImageData,
[maskIntensity,], True )
        self.__MaskSurfaceActor = self.__CreateActor( maskPolyData, maskColor )
        del maskPolyData
		
	 def CreateSplitSurfaceActor(self, maskImageData, splitIntensities,
splitColor):
        if self.__SplitSurfaceActor:
            return
        splitPolyData = self.__GenerateSurfaceData( maskImageData,
splitIntensities )
        self.__SplitSurfaceActor = self.__CreateActor( splitPolyData,
splitColor )
        del splitPolyData
		
		
#implement file
	surfaceFactory.CreateSplitSurfaceActor( self.__MaskImageData, [3, 4],
(1.0, 0.0, 0.0) )
	surfaceFactory.CreateMaskSurfaceActor( self.__MaskImageData, 5, (
0.0, 1.0, 0.0 ) )	#crash inside this called function



More information about the vtkusers mailing list