[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> </DIV>
<DIV><FONT size=2>void vtkKnittedFabricSource::Execute()<BR>{<BR> float
pi= 3.141592654;<BR> int i, numPts;<BR> float x, y, z, s;<BR>
vtkPoints *newPoints; <BR> vtkCellArray *newPolys;<BR> vtkTubeFilter
*profileTubes;<BR> vtkPolyData *profileData =
vtkPolyData::New();<BR> vtkPolyData *polyData =
vtkPolyData::New();<BR> <BR>//<BR>// Set things up; allocate
memory<BR>//</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2> numPts = this->ThetaResolution;<BR> newPoints
= vtkPoints::New();<BR> newPoints->Allocate(numPts);<BR> newPolys
= vtkCellArray::New();<BR>
newPolys->InsertNextCell(numPts);<BR>//<BR>// Generate points and
lines<BR>//<BR> for(i=0; i<numPts; i++)<BR> {<BR>
s=1.0*i/numPts;<BR> x =
this->Shape*s*s*s-1.5*this->Shape*s*s+(this->Width+this->Shape)*s/2;<BR> \
y =
0.5*(this->Height+this->Overlap)*(1-cos(pi*s));<BR>
z =
0.5*(this->Thickness-2*this->Radius)*(1-cos(2*pi*s));<BR> \
newPoints->InsertPoint(i, x, y, z);<BR>
newPolys->InsertCellPoint(i);<BR> }</FONT></DIV>
<DIV> </DIV><FONT size=2>
<DIV><BR> profileData->SetPoints( newPoints);<BR>
profileData->SetLines( newPolys);</DIV>
<DIV> </DIV>
<DIV> profileTubes =vtkTubeFilter::New();<BR>
profileTubes->SetNumberOfSides(this->PhiResolution);<BR>
profileTubes->SetInput( profileData);<BR> profileTubes->SetRadius(
this->Radius);<BR> <BR>//<BR>// Update ourselves and release
memory<BR>//<BR>
this->SetOutput(profileTubes->GetOutput());<BR>//
newPoints->Delete();<BR>// newPolys->Delete();<BR>//
profileTubes->Delete();<BR>}</DIV>
<DIV> </DIV>
<DIV></FONT> </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