<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>- i tried this but it didn't change anything.</DIV>
<DIV> </DIV>
<DIV>- i have a question: do you know if my parameter <STRONG>t has to be a float between 0 and 1</STRONG>? </DIV>
<DIV> </DIV>
<DIV>When I traced spline_points, here is what I got:</DIV>
<DIV> </DIV>
<DIV><STRONG>t=0.000000, spline points:13.035959 10.105188 0.000000<BR>t=5.210526, spline points:-434367840.000000 -434367840.000000 -434367840.000000<BR>t=10.421053, spline points:-431597504.000000 -431597504.000000 -431597504.000000<BR>t=15.631579, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=20.842106, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=26.052631, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=31.263159, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=36.473682, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=41.684212, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=46.894737, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=52.105263, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=57.315788, spline points:-431602080.000000 -431602080.000000
-431602080.000000<BR>t=62.526318, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=67.736839, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=72.947365, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=78.157898, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=83.368423, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=88.578949, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=93.789474, spline points:-431602080.000000 -431602080.000000 -431602080.000000<BR>t=99.000000, spline points:-431602080.000000 -431602080.000000 -431602080.000000</STRONG> </DIV>
<DIV> </DIV>
<DIV>Maybe t could be the problem. I saw many examples: </DIV>
<DIV>- sometimes t is defined as: </DIV>
<DIV> t = ( (float)numberOfInputPoints - 1.0 ) / ( (float)numberOfOutputPoints - 1.0 ) * (float)i;</DIV>
<DIV> </DIV>
<DIV>- sometimes length of the polyline is used, such as vtkSplineFilter:</DIV>
<DIV>t=len/length as cumulative distance</DIV>
<DIV> </DIV>
<DIV>BTW, i tried to use vtkSplineFilter but i couldn't compile: undefined identifier vtkGarbageCollector in vtkAlgortihm??????????</DIV>
<DIV> </DIV>
<DIV>Please help,</DIV>
<DIV> </DIV>
<DIV>Isabelle<BR><BR><B><I>Dean Inglis <dean.inglis@camris.ca></I></B> a écrit :</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">sorry, I missed that.<BR><BR>Maybe it's because you call Reset()<BR>without setting the number of points.<BR><BR><BR>if(spline_points) spline_points->Reset(); float t = 0.0;<BR>for(int i=0; i<NUMBEROFOUTPUTPOINTS;I++)<BR> {<BR>t = ( (float)numberOfInputPoints - 1.0 ) / (<BR>(float)numberOfOutputPoints - 1.0 ) * (float)i;<BR>spline_points->SetPoint(i, splineX->Evaluate(t),<BR>splineY->Evaluate(t), splineZ->Evaluate(t));<BR><BR>float* pt = spline_points->GetPoint(i);<BR><BR><BR>If you do<BR><BR>points->Initialize();<BR>or<BR>points->Reset();<BR><BR>you must then do<BR>points->SetNumberOfPoints( npoints ); // pre-allocate memory<BR><BR>before calling<BR>points->SetPoint(i,x,y,z); // when memmory is pre-allocated (faster)<BR><BR>if you do not set the number of points, you can do<BR>points->InsertNextPoint(x,y,z); //allocate memory as required
(slower)<BR><BR><BR>Dean<BR><BR><BR><BR>Hi,<BR><BR>Thanks for your reply. But your are wrong: I set:<BR><BR>t = ( (float)numberOfInputPoints - 1.0 ) / ( (float)numberOfOutputPoints -<BR>1.0 ) * (float)i;<BR>spline_points->SetPoint(i, splineX->Evaluate(t),<BR>splineY->Evaluate(t), splineZ->Evaluate(t));<BR><BR>Is it not correct? Any other idea?<BR><BR>Isabelle<BR><BR><BR><BR><BR><BR>dean.inglis@camris.ca a écrit :<BR>you didn't define any points:<BR><BR>//Generate the polyline for the spline.<BR>spline_points = vtkPoints::New();<BR>spline_points->SetNumberOfPoints( static_cast(numberOfOutputPoints) );<BR><BR>you need to also do:<BR><BR>spline_points->SetPoint(i,somethingX,somethingY,somethingZ);<BR><BR>or,<BR><BR>double somethingXYZ[3];<BR>spline_points->SetPoint(i,somethingXYZ);<BR><BR>Dean<BR><BR><BR>><BR>Hi,<BR><BR>I am really confused about interpolating my glyph points with a spline.<BR><BR>I look a lot of examples on this and I thought having understood,
but<BR>actually, only my glyph are drawn.<BR><BR>I put a TRACE instruction to see what is computed after calling<BR>spline-.Evaluate(): i got crazy values except for the first one: not so<BR>amazing that nothing is drawn!<BR><BR>Here is what I did:<BR><BR><BR>splineX = vtkCardinalSpline::New();<BR>splineY = vtkCardinalSpline::New();<BR>splineZ = vtkCardinalSpline::New();<BR><BR>numberOfOutputPoints = 20; //Number of points on the spline<BR><BR>//Generate the polyline for the spline.<BR>spline_points = vtkPoints::New();<BR>spline_points->SetNumberOfPoints(<BR>static_cast<VTKIDTYPE>(numberOfOutputPoints) );<BR><BR>//Create the polyline.<BR>spline_lines = vtkCellArray::New();<BR>spline_lines->InsertNextCell(numberOfOutputPoints);<BR><BR>for(int i=0; i<NUMBEROFOUTPUTPOINTS;I++)<BR> spline_lines->InsertCellPoint(i);//add points one at a time<BR><BR>spline_polyData =
vtkPolyData::New();<BR>spline_polyData->SetPoints(spline_points);<BR>spline_points->Delete();<BR>spline_polyData->SetLines(spline_lines);<BR>spline_lines->Delete();<BR><BR>//Add thickness to the resulting line.<BR>tubes = vtkTubeFilter::New();<BR>tubes->SetInput(spline_polyData);<BR>tubes->SetRadius(0.075);<BR>tubes->SetNumberOfSides(6);<BR><BR>vtkPolyDataMapper* spline_mapper = vtkPolyDataMapper::New();<BR>spline_mapper->SetInput(tubes->GetOutput());<BR>tubes->Delete();<BR><BR>splines = vtkActor::New();<BR>splines->SetMapper(spline_mapper);<BR>spline_mapper->Delete();<BR><BR>splines->GetProperty()->SetColor(1.0, 0.0, 1.0);<BR><BR>And after each click:<BR>case vtkCommand::LeftButtonPressEvent:<BR>{<BR>vtkRenderWindowInteractor *interactor =<BR>reinterpret_cast<VTKRENDERWINDOWINTERACTOR *>(caller);<BR>int x = interactor->GetEventPosition()[0];<BR>int y = interactor->GetEventPosition()[1];<BR><BR>// Convert display point to world
point<BR>double world_point[4];<BR>m_Renderer->SetDisplayPoint( x, y, 0 );<BR>m_Renderer->DisplayToWorld();<BR>m_Renderer->GetWorldPoint( world_point );<BR><BR>// Store the point with no range checking or memory allocation.<BR>points->SetPoint( nodeId, world_point[0], world_point[1],<BR>world_point[2] );<BR><BR>// Create a vertex for each node. This type of cell has a single<BR>point.<BR>vtkIdType topology[1];<BR>topology[0] = nodeId;<BR>vertices->InsertNextCell( 1, topology );<BR><BR>//create new points<BR>numberOfInputPoints = points->GetNumberOfPoints();<BR><BR>if ( numberOfInputPoints >= 2 )<BR>{<BR>if(numberOfInputPoints==2)<BR>{<BR>m_Renderer->AddActor( splines );<BR>splines->Delete();<BR>}<BR><BR>splineX->RemoveAllPoints();<BR>splineY->RemoveAllPoints();<BR>splineZ->RemoveAllPoints();<BR><BR>for ( int i = 0 ; i < numberOfInputPoints; i++)<BR>{<BR>//add coordinates points to the splines.<BR>float* point =
points->GetPoint(i);<BR>splineX->AddPoint( i, point[0] );<BR>splineY->AddPoint( i, point[1] );<BR>splineZ->AddPoint( i, point[2] );<BR>}<BR><BR>if(spline_points) spline_points->Reset();<BR>float t = 0.0;<BR>for(int i=0; i<NUMBEROFOUTPUTPOINTS;I++)<BR> {<BR>t = ( (float)numberOfInputPoints - 1.0 ) / (<BR>(float)numberOfOutputPoints - 1.0 ) * (float)i;<BR>spline_points->SetPoint(i, splineX->Evaluate(t),<BR>splineY->Evaluate(t), splineZ->Evaluate(t));<BR><BR>float* pt = spline_points->GetPoint(i);<BR>TRACE("spline points:%f %f %f\n", pt[0], pt[1], pt[2]);<BR>}<BR><BR>spline_polyData->Modified();<BR>}<BR><BR>nodeId++;<BR>m_glyphActor->VisibilityOn();<BR>splines->VisibilityOn();<BR>this->Render();<BR>}<BR>break;<BR><BR>- Does someone see what is wrong? Insofar as my glyph are correcly drawn, I<BR>assume that my input points are correct. So what's wrong?<BR><BR>Please help
me,<BR><BR>Isabelle<BR>_______________________________________________<BR>This is the private VTK discussion list.<BR>Please keep messages on-topic. Check the FAQ at:<BR>http://www.vtk.org/Wiki/VTK_FAQ<BR>Follow this link to subscribe/unsubscribe:<BR>http://www.vtk.org/mailman/listinfo/vtkusers<BR><BR><BR>Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger<BR>Téléchargez le ici !<BR><BR><BR>_______________________________________________<BR>This is the private VTK discussion list. <BR>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<BR>Follow this link to subscribe/unsubscribe:<BR>http://www.vtk.org/mailman/listinfo/vtkusers<BR></BLOCKQUOTE><p>
                <hr size=1>
<b><font color=#FF0000>Appel audio GRATUIT</font> partout dans le monde</b> avec le nouveau Yahoo! Messenger<br>
<a href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.messenger.yahoo.com">Téléchargez le ici !</a>