[vtkusers] Drawing an Arc

Brian C. Panneton (CONTR) brian.c.panneton.ctr at us.army.mil
Thu Jun 23 15:11:32 EDT 2011


Brian C. Panneton (CONTR) wrote:
> I have two points that are in an unstructured grid and I want to draw 
> an arc between them. What is the best way to do this? I was looking 
> into splines, but the set up seems too complicated for what I am 
> looking for. I am doing this within a reader.
>
> Thanks,
> Brian
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at 
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: 
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
Okay, I have figured out a way to do what I need. I was wondering if 
there is a faster way to do this? I must run the code hundreds of times 
per timestep and it is very slow.

ugGlyphsPts is a vtkPoints SmartPointer. ugTubesAppend is a 
vtkAppendFilter SmartPointer. I use the vtkAppendFilter to take in the 
PolyData output from the vtkParametricFunctionSource. I then use the 
output of the vtkAppendFilter as my vtkUnstructuredGrid which gets 
displayed.

[code]
                                double p0[3];
                                ugGlyphsPts->GetPoint(pids[0], p0);
                                double p1[3];
                                ugGlyphsPts->GetPoint(pids[1], p1);

                                vtkSmartPointer<vtkParametricSpline> 
pSpline =
                                    
vtkSmartPointer<vtkParametricSpline>::New();
                                pSpline->SetNumberOfPoints(3);
                                pSpline->SetPoint(0, p0[0], p0[1], 0);
                                pSpline->SetPoint(1,
                                    (p0[0]+p1[0])/2,
                                    (p0[1]+p1[1])/2,
                                    (sqrt(pow(p0[0] - p1[0], 2) +
                                          pow(p0[1] - p1[1], 2) +
                                          pow(p0[2] - p1[2], 2))/4));

                                pSpline->SetPoint(2, p1[0], p1[1], 0);

                                vtkSmartPointer<vtkParametricFunctionSource>
                                    fs = vtkSmartPointer<
                                    vtkParametricFunctionSource>::New();
                                fs->SetParametricFunction(pSpline);
                                fs->SetUResolution( 10 );
                                fs->Update();

                                ugTubesAppend->AddInput(fs->GetOutput());
[/code]


If I could reduce the steps here to make it more efficient that would be 
great! Possibly taking the vtkParametricSpline and placing it directly 
in the vtkUnstructuredGrid would save me from having to hop through 
these different filters, however I could not figure out how to do that.

Thanks,
Brian



More information about the vtkusers mailing list