[vtkusers] help

John Biddiscombe jbiddiscombe at skippingmouse.co.uk
Sat Sep 22 06:25:53 EDT 2001


At the end of the execute you've done
this->SetOutput(stuff).
This is generally not good because any filter which does
this->SetInput(Knittedfabric->GetOutput());
is going to lose its input.

Because you've got filters embedded in your own filter you want
>     this->SetOutput(profileTubes->GetOutput());

replaced with
profileTubes->Update();
this->GetOutput()->CopyStructure(profileTubes->GetOutput());
if there are field arrays inside the profiletube that you want you must also
vtkPolydata *output = this->GetOutput();
output->CopyStructure(profileTubes->GetOutput());
output->GetPointData()->PassData(profileTubes->GetOutput()->GetPointData());
output->GetCellData()->PassData(profileTubes->GetOutput()->GetCellData());
though you most likely won't need both. Either point or cell data

NB. There may be other bugs, but I just looked at the code and spotted 
this, I haven't double checked

JB




At 04:56 22/09/2001, ghzhao wrote:
>I write a class vtkKnittedFabricSource, but it does not work.
>When I move the Execut() method outside just like the CSpline.tcl demo, it 
>works. Why?
>
>void vtkKnittedFabricSource::Execute()
>{
>   float pi= 3.141592654;
>   int i, numPts;
>   float x, y, z, s;
>   vtkPoints *newPoints;
>   vtkCellArray *newPolys;
>   vtkTubeFilter *profileTubes;
>   vtkPolyData *profileData = vtkPolyData::New();
>   vtkPolyData *polyData = vtkPolyData::New();
>
>//
>// Set things up; allocate memory
>//
>
>   numPts = this->ThetaResolution;
>   newPoints = vtkPoints::New();
>   newPoints->Allocate(numPts);
>   newPolys = vtkCellArray::New();
>   newPolys->InsertNextCell(numPts);
>//
>// Generate points and lines
>//
>   for(i=0; i<numPts; i++)
>   {
>   s=1.0*i/numPts;
>      x = this->Shape*s*s*s-1.5*this->Shape*s*s+(this->Width+this->Shape)*s/2;
>      y = 0.5*(this->Height+this->Overlap)*(1-cos(pi*s));
>      z = 0.5*(this->Thickness-2*this->Radius)*(1-cos(2*pi*s));
>      newPoints->InsertPoint(i, x, y, z);
>      newPolys->InsertCellPoint(i);
>   }
>
>
>   profileData->SetPoints( newPoints);
>   profileData->SetLines( newPolys);
>
>   profileTubes =vtkTubeFilter::New();
>   profileTubes->SetNumberOfSides(this->PhiResolution);
>   profileTubes->SetInput( profileData);
>   profileTubes->SetRadius( this->Radius);
>
>//
>// Update ourselves and release memory
>//
>     this->SetOutput(profileTubes->GetOutput());
>//  newPoints->Delete();
>//  newPolys->Delete();
>//  profileTubes->Delete();
>}
>
>
>




More information about the vtkusers mailing list