[vtkusers] error in using vtkCellLocator::IntersectWithLine

xujf xujf at sjtu.edu.cn
Tue Apr 6 21:02:47 EDT 2004


----- Original Message -----
From: Mathieu Malaterre <mathieu.malaterre at kitware.com>
To: xujf at sjtu.edu.cn
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] error in using vtkCellLocator::IntersectWithLine

xujf wrote:
>>xujf wrote:
>>
>>>Hi,vtkusers:
>>>   I get an isosurface using vtkImageMarchingCubes,and I get a line using >vtklinesource.
>>>I want to get the point of intersection of the isosurface and the line.In order to get
>>>the point of intersection,I use vtkCellLocator::IntersectWithLine.But error is found:
>>>AttributeError:IntersectWithLine.
>>>
>>>this is my programe:(written in python)
>>>
>>>import sys,os 
>>>from paths import *
>>>from vtkMINCReader import *
>>>
>>>reader=vtkMINCReader()
>>>reader.SetFileName("E:/picture/brain.mnc")
>>>
>>>filter=vtkImageMarchingCubes()
>>>filter.SetInput(reader.GetOutput())
>>>filter.SetValue(0,1200)
>>>
>>>tolerance=100.0
> 
> 
>>xujf,
> 
> 
>>Just after tolerance add:
>>
>>filter.Update()
>>print filter.GetOutput().GetNumberOfCells()
>>
>>If it is equal to zero you won\\\\\'t be able to go any furhter.
> 
> 
>>Mathieu
> 
> 
> Hi,Mathieu:
>    Thanks very much for your help.
>    I add these two sentences in my programe: 
> filter.Update()
> print filter.GetOutput().GetNumberOfCells()
> 
> the result is 1839638.it is not zero.
> still the sentence in my programe"returnState=myCellLocator.IntersectWithLine(center,point,tolerance,t,intersectionPoint,parametricCoords,subCellID,cellID)"
> has an error:
> AttributeError :IntersectWithLine
> 

Xujf,

	I am sorry, could you please resend me your sample python code ? I
delete your mail and the archive is not able to parse your mails:

	http://vtk.org/pipermail/vtkusers/2004-April/023464.html


Mathieu

Hi,Mathieu:
   Thanks very much.
this is my code:
import sys,os 
from paths import *
from vtkMINCReader import *

reader=vtkMINCReader()
reader.SetFileName("E:/data/sbrain.mnc")

filter=vtkImageMarchingCubes()
filter.SetInput(reader.GetOutput())
filter.SetValue(0,1200)

mapper=vtkPolyDataMapper()
mapper.SetInput(filter.GetOutput())
mapper.ScalarVisibilityOff()

actor=vtkActor()
pro=vtkProperty()
pro.SetColor(1,0,0)
actor.SetMapper(mapper)

myCellLocator=vtkCellLocator()
myCellLocator.SetDataSet(filter.GetOutput())

center=actor.GetCenter()

point=[]
point.append(200.0)
point.append(200.0)
point.append(200.0)

tolerance=100.0
filter.Update()
print filter.GetOutput().GetNumberOfCells()
returnState=myCellLocator.IntersectWithLine   ###???????(center,point,tolerance,t,intersectionPoint,parametricCoords,subCellID,cellID)
print intersectionPoint

ren = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren)
iren = vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
ren.AddActor(actor)

iren.Initialize()
renWin.Render()
iren.Start()

Best Regards!
xujf 


More information about the vtkusers mailing list