<DIV>
<DIV>Hi,</DIV>
<DIV> </DIV>
<DIV>I am really confused about interpolating my glyph points with a spline. </DIV>
<DIV> </DIV>
<DIV>I look a lot of examples on this and I thought having understood, but actually, only my glyph are drawn. </DIV>
<DIV> </DIV>
<DIV>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! </DIV>
<DIV> </DIV>
<DIV>Here is what I did:</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> <STRONG>splineX = vtkCardinalSpline::New();<BR> splineY = vtkCardinalSpline::New();<BR> splineZ = vtkCardinalSpline::New();<BR> <BR> numberOfOutputPoints = 20; //Number of points on the spline<BR></STRONG> <BR><STRONG> //Generate the polyline for the spline.<BR> spline_points = vtkPoints::New();<BR> spline_points->SetNumberOfPoints( static_cast<vtkIdType>(numberOfOutputPoints) );</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> //Create the polyline.<BR> spline_lines = vtkCellArray::New();<BR> spline_lines->InsertNextCell(numberOfOutputPoints);</STRONG></DIV>
<DIV><BR> <STRONG>for(int i=0; i<numberOfOutputPoints;i++)<BR> spline_lines->InsertCellPoint(i);//add points one at a time</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> spline_polyData = vtkPolyData::New();<BR> spline_polyData->SetPoints(spline_points);<BR> spline_points->Delete();<BR> spline_polyData->SetLines(spline_lines);<BR> spline_lines->Delete();</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> </STRONG>//Add thickness to the resulting line.<BR><STRONG> tubes = vtkTubeFilter::New();<BR> tubes->SetInput(spline_polyData);<BR> tubes->SetRadius(0.075);<BR> tubes->SetNumberOfSides(6);</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> vtkPolyDataMapper* spline_mapper = vtkPolyDataMapper::New();<BR> spline_mapper->SetInput(tubes->GetOutput());<BR> tubes->Delete();</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> splines = vtkActor::New();<BR> splines->SetMapper(spline_mapper);<BR> spline_mapper->Delete();</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV> <STRONG>splines->GetProperty()->SetColor(1.0, 0.0, 1.0);</STRONG></DIV>
<P><STRONG></STRONG> </P>
<P>And after each click:</P>
<DIV><STRONG>case vtkCommand::LeftButtonPressEvent:<BR> {<BR> vtkRenderWindowInteractor *interactor = reinterpret_cast<vtkRenderWindowInteractor *>(caller);<BR> int x = interactor->GetEventPosition()[0];<BR> int y = interactor->GetEventPosition()[1];</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> // 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 );</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> // Store the point with no range checking or memory allocation.<BR> points->SetPoint( nodeId, world_point[0], world_point[1], world_point[2] );</STRONG>
<DIV> </DIV>
<DIV><STRONG> // Create a vertex for each node. This type of cell has a single point.<BR> vtkIdType topology[1];<BR> topology[0] = nodeId; <BR> vertices->InsertNextCell( 1, topology ); </STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV>
<DIV><STRONG> //create new points<BR> numberOfInputPoints = points->GetNumberOfPoints();</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> if ( numberOfInputPoints >= 2 )<BR> {<BR> if(numberOfInputPoints==2) <BR> {<BR> m_Renderer->AddActor( splines );<BR> splines->Delete();<BR> }</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> splineX->RemoveAllPoints();<BR> splineY->RemoveAllPoints();<BR> splineZ->RemoveAllPoints();</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> 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> }</STRONG></DIV>
<DIV><STRONG></STRONG> </DIV>
<DIV><STRONG> if(spline_points) spline_points->Reset(); </STRONG>
<DIV><STRONG> float t = 0.0;<BR> for(int i=0; i<numberOfOutputPoints;i++)<BR> {<BR> t = ( (float)numberOfInputPoints - 1.0 ) / ( (float)numberOfOutputPoints - 1.0 ) * (float)i;<BR> spline_points->SetPoint(i, splineX->Evaluate(t), splineY->Evaluate(t), splineZ->Evaluate(t));<BR> </STRONG></DIV>
<DIV><STRONG> float* pt = spline_points->GetPoint(i);<BR> TRACE("spline points:%f %f %f\n", pt[0], pt[1], pt[2]);<BR> }</STRONG></DIV>
<DIV><STRONG> <BR> spline_polyData->Modified();</STRONG></DIV>
<DIV><STRONG>}</STRONG></DIV>
<DIV><STRONG> </STRONG></DIV>
<DIV><STRONG> nodeId++; <BR> m_glyphActor->VisibilityOn(); <BR> splines->VisibilityOn(); <BR> this->Render();<BR> } <BR> break; <BR></STRONG></DIV></DIV></DIV></DIV>
<DIV>- 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? </DIV>
<DIV> </DIV>
<DIV>Please help me,</DIV>
<DIV> </DIV>
<DIV>Isabelle</DIV></DIV><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>