[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vtkusers
Subject:    [vtkusers] help
From:       "ghzhao" <ghzhao () comgi ! com>
Date:       2001-09-22 3:56:26
Message-ID: 000b01c1431a$8ea7d920$0500a8c0 () comgi ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]

[Attachment #4 (text/plain)]

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();
}



[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 5.50.4616.200" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>I write a class vtkKnittedFabricSource, but it does not 
work.</FONT></DIV>
<DIV><FONT size=2>When I move the Execut() method outside just like the 
CSpline.tcl demo, it works. Why?</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>void vtkKnittedFabricSource::Execute()<BR>{<BR>&nbsp; float 
pi= 3.141592654;<BR>&nbsp; int i, numPts;<BR>&nbsp; float x, y, z, s;<BR>&nbsp; 
vtkPoints *newPoints; <BR>&nbsp; vtkCellArray *newPolys;<BR>&nbsp; vtkTubeFilter 
*profileTubes;<BR>&nbsp; vtkPolyData *profileData = 
vtkPolyData::New();<BR>&nbsp; vtkPolyData *polyData = 
vtkPolyData::New();<BR>&nbsp;<BR>//<BR>// Set things up; allocate 
memory<BR>//</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=2>&nbsp; numPts = this-&gt;ThetaResolution;<BR>&nbsp; newPoints 
= vtkPoints::New();<BR>&nbsp; newPoints-&gt;Allocate(numPts);<BR>&nbsp; newPolys 
= vtkCellArray::New();<BR>&nbsp; 
newPolys-&gt;InsertNextCell(numPts);<BR>//<BR>// Generate points and 
lines<BR>//<BR>&nbsp; for(i=0; i&lt;numPts; i++)<BR>&nbsp; {<BR>&nbsp; 
s=1.0*i/numPts;<BR>&nbsp;&nbsp;&nbsp;&nbsp; x = 
this-&gt;Shape*s*s*s-1.5*this-&gt;Shape*s*s+(this-&gt;Width+this-&gt;Shape)*s/2;<BR>&nbsp;&nbsp;&nbsp;&nbsp; \
 y = 
0.5*(this-&gt;Height+this-&gt;Overlap)*(1-cos(pi*s));<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
z = 
0.5*(this-&gt;Thickness-2*this-&gt;Radius)*(1-cos(2*pi*s));<BR>&nbsp;&nbsp;&nbsp;&nbsp; \
 newPoints-&gt;InsertPoint(i, x, y, z);<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
newPolys-&gt;InsertCellPoint(i);<BR>&nbsp; }</FONT></DIV>
<DIV>&nbsp;</DIV><FONT size=2>
<DIV><BR>&nbsp; profileData-&gt;SetPoints( newPoints);<BR>&nbsp; 
profileData-&gt;SetLines( newPolys);</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp; profileTubes =vtkTubeFilter::New();<BR>&nbsp; 
profileTubes-&gt;SetNumberOfSides(this-&gt;PhiResolution);<BR>&nbsp; 
profileTubes-&gt;SetInput( profileData);<BR>&nbsp; profileTubes-&gt;SetRadius( 
this-&gt;Radius);<BR>&nbsp; <BR>//<BR>// Update ourselves and release 
memory<BR>//<BR>&nbsp;&nbsp;&nbsp; 
this-&gt;SetOutput(profileTubes-&gt;GetOutput());<BR>//&nbsp; 
newPoints-&gt;Delete();<BR>//&nbsp; newPolys-&gt;Delete();<BR>//&nbsp; 
profileTubes-&gt;Delete();<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV></FONT>&nbsp;</DIV></BODY></HTML>


["vtkKnittedFabricSource.cxx" (application/octet-stream)]
["vtkKnittedFabricSource.h" (application/octet-stream)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic