[vtkusers] splines

Renaud Isabelle renauisa at yahoo.fr
Mon Sep 12 14:11:37 EDT 2005


I don't have files vtkParametricSpline and vtkPolyDataAlgorithm. 
 
- Do you know if thiese one were only added in VTK 4.4? How can I update my VTK version? And how can I know which files have been added since VTK 4.2? I tried to download these files by CVS but, as vtkSplineFilter, I got errors while compiling with vtkGarbageCollector.... 
 
Some papers talk about VTK 4.5 for august 2004: is it already downloadable?

Isabelle

Dean Inglis <dean.inglis at camris.ca> a écrit :
why don't you just use the
new vtkParametricSpline and vtkParametricFunctionSource
classes? That way you just insert a vtkPoints containing
the points to fit a spline to into a
vtkParametricSpline and then vtkParametricFunctionSource
generates the polydata for you.
Have a look at cvs vtkSplineWidget
to see how this is can be done.

Dean


-----Original Message-----
From: Renaud Isabelle [mailto:renauisa at yahoo.fr]
Sent: Monday, September 12, 2005 11:48 AM
To: Dean Inglis; vtkusers archive
Subject: RE: [vtkusers] splines


Hi,

- i tried this but it didn't change anything.

- i have a question: do you know if my parameter t has to be a float between
0 and 1?

When I traced spline_points, here is what I got:

t=0.000000, spline points:13.035959 10.105188 0.000000
t=5.210526, spline
points:-434367840.000000 -434367840.000000 -434367840.000000
t=10.421053, spline
points:-431597504.000000 -431597504.000000 -431597504.000000
t=15.631579, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=20.842106, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=26.052631, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=31.263159, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=36.473682, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=41.684212, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=46.894737, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=52.105263, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=57.315788, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=62.526318, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=67.736839, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=72.947365, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=78.157898, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=83.368423, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=88.578949, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=93.789474, spline
points:-431602080.000000 -431602080.000000 -431602080.000000
t=99.000000, spline
points:-431602080.000000 -431602080.000000 -431602080.000000

Maybe t could be the problem. I saw many examples:
- sometimes t is defined as:
t = ( (float)numberOfInputPoints - 1.0 ) / ( (float)numberOfOutputPoints -
1.0 ) * (float)i;

- sometimes length of the polyline is used, such as vtkSplineFilter:
t=len/length as cumulative distance

BTW, i tried to use vtkSplineFilter but i couldn't compile: undefined
identifier vtkGarbageCollector in vtkAlgortihm??????????

Please help,

Isabelle

Dean Inglis a écrit :
sorry, I missed that.

Maybe it's because you call Reset()
without setting the number of points.


if(spline_points) spline_points->Reset(); float t = 0.0;
for(int i=0; i {
t = ( (float)numberOfInputPoints - 1.0 ) / (
(float)numberOfOutputPoints - 1.0 ) * (float)i;
spline_points->SetPoint(i, splineX->Evaluate(t),
splineY->Evaluate(t), splineZ->Evaluate(t));

float* pt = spline_points->GetPoint(i);


If you do

points->Initialize();
or
points->Reset();

you must then do
points->SetNumberOfPoints( npoints ); // pre-allocate memory

before calling
points->SetPoint(i,x,y,z); // when memmory is pre-allocated (faster)

if you do not set the number of points, you can do
points->InsertNextPoint(x,y,z); //allocate memory as required (slower)


Dean



Hi,

Thanks for your reply. But your are wrong: I set:

t = ( (float)numberOfInputPoints - 1.0 ) / ( (float)numberOfOutputPoints -
1.0 ) * (float)i;
spline_points->SetPoint(i, splineX->Evaluate(t),
splineY->Evaluate(t), splineZ->Evaluate(t));

Is it not correct? Any other idea?

Isabelle





dean.inglis at camris.ca a écrit :
you didn't define any points:

//Generate the polyline for the spline.
spline_points = vtkPoints::New();
spline_points->SetNumberOfPoints( static_cast(numberOfOutputPoints) );

you need to also do:

spline_points->SetPoint(i,somethingX,somethingY,somethingZ);

or,

double somethingXYZ[3];
spline_points->SetPoint(i,somethingXYZ);

Dean


>
Hi,

I am really confused about interpolating my glyph points with a spline.

I look a lot of examples on this and I thought having understood, but
actually, only my glyph are drawn.

I put a TRACE instruction to see what is computed after calling
spline-.Evaluate(): i got crazy values except for the first one: not so
amazing that nothing is drawn!

Here is what I did:


splineX = vtkCardinalSpline::New();
splineY = vtkCardinalSpline::New();
splineZ = vtkCardinalSpline::New();

numberOfOutputPoints = 20; //Number of points on the spline

//Generate the polyline for the spline.
spline_points = vtkPoints::New();
spline_points->SetNumberOfPoints(
static_cast(numberOfOutputPoints) );

//Create the polyline.
spline_lines = vtkCellArray::New();
spline_lines->InsertNextCell(numberOfOutputPoints);

for(int i=0; i spline_lines->InsertCellPoint(i);//add points one at a time

spline_polyData = vtkPolyData::New();
spline_polyData->SetPoints(spline_points);
spline_points->Delete();
spline_polyData->SetLines(spline_lines);
spline_lines->Delete();

//Add thickness to the resulting line.
tubes = vtkTubeFilter::New();
tubes->SetInput(spline_polyData);
tubes->SetRadius(0.075);
tubes->SetNumberOfSides(6);

vtkPolyDataMapper* spline_mapper = vtkPolyDataMapper::New();
spline_mapper->SetInput(tubes->GetOutput());
tubes->Delete();

splines = vtkActor::New();
splines->SetMapper(spline_mapper);
spline_mapper->Delete();

splines->GetProperty()->SetColor(1.0, 0.0, 1.0);

And after each click:
case vtkCommand::LeftButtonPressEvent:
{
vtkRenderWindowInteractor *interactor =
reinterpret_cast(caller);
int x = interactor->GetEventPosition()[0];
int y = interactor->GetEventPosition()[1];

// Convert display point to world point
double world_point[4];
m_Renderer->SetDisplayPoint( x, y, 0 );
m_Renderer->DisplayToWorld();
m_Renderer->GetWorldPoint( world_point );

// Store the point with no range checking or memory allocation.
points->SetPoint( nodeId, world_point[0], world_point[1],
world_point[2] );

// Create a vertex for each node. This type of cell has a single
point.
vtkIdType topology[1];
topology[0] = nodeId;
vertices->InsertNextCell( 1, topology );

//create new points
numberOfInputPoints = points->GetNumberOfPoints();

if ( numberOfInputPoints >= 2 )
{
if(numberOfInputPoints==2)
{
m_Renderer->AddActor( splines );
splines->Delete();
}

splineX->RemoveAllPoints();
splineY->RemoveAllPoints();
splineZ->RemoveAllPoints();

for ( int i = 0 ; i < numberOfInputPoints; i++)
{
//add coordinates points to the splines.
float* point = points->GetPoint(i);
splineX->AddPoint( i, point[0] );
splineY->AddPoint( i, point[1] );
splineZ->AddPoint( i, point[2] );
}

if(spline_points) spline_points->Reset();
float t = 0.0;
for(int i=0; i {
t = ( (float)numberOfInputPoints - 1.0 ) / (
(float)numberOfOutputPoints - 1.0 ) * (float)i;
spline_points->SetPoint(i, splineX->Evaluate(t),
splineY->Evaluate(t), splineZ->Evaluate(t));

float* pt = spline_points->GetPoint(i);
TRACE("spline points:%f %f %f\n", pt[0], pt[1], pt[2]);
}

spline_polyData->Modified();
}

nodeId++;
m_glyphActor->VisibilityOn();
splines->VisibilityOn();
this->Render();
}
break;

- Does someone see what is wrong? Insofar as my glyph are correcly drawn, I
assume that my input points are correct. So what's wrong?

Please help me,

Isabelle
_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers


Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez le ici !


_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
Téléchargez le ici !



		
---------------------------------
 Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
 Téléchargez le ici !  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20050912/afa2b3a9/attachment.htm>


More information about the vtkusers mailing list