[vtkusers] problem updating polydata data attributes

Andrea del Pilar Rueda Olarte asderina at gmail.com
Sun Sep 24 19:58:10 EDT 2006


Hello Dominik,

Thanks for your suggestion, but it doesn't work.

Maybe if I put some code parts you can help me...

//********** begin code part **********//
// mapping is the function to use with the vtkProgrammableFilter
// pointf is the vtkProgrammableFilter instance

void mapping (void * p) {
    vtkPolyData *input = pointf->GetPolyDataInput();
    vtkPoints *newpts = vtkPoints::New();
    double *gcurv = new double[1];

    // compute curvatures
    vtkCurvatures *curv = vtkCurvatures::New();
    curv->SetInput(input);
    curv->SetCurvatureTypeToGaussian();
    curv->Update();

    // array to store the curvature values
    vtkDoubleArray *dacurv = vtkDoubleArray::New();
    dacurv->SetNumberOfComponents(1);

    // iter stores the amount of iterations
    for (k=0; k<iter; k++) {

        //obtain the surface curvatures
        curv->Update();
        dacurv->DeepCopy(curv->GetOutput()->GetPointData()->GetScalars());

        for (i=0; i<nop; i++) {
            //get the point with id i, and store it in x
            input->GetPoint(i, x);
            cout<<"x_"<<i<<"=["<<x[0]<<","<<x[1]<<","<<x[2]<<"]"<<endl;
            //get the curvature
            dacurv->GetTuple(i, gcurv);
            cout<<"kappa_"<<i<<"="<<gcurv[0]<<endl;

            //update the point position
            x[0] = x[0] + gcurv[0];
            x[1] = x[1] + gcurv[0];
            x[2] = x[2] + gcurv[0];

            // store the new point in the array
            if (k==0) {
                newpts->InsertPoint(i, x[0], x[1], x[2]);
            } else {
                newpts->SetPoint(i, x[0], x[1], x[2]);
            }
        }

        // set the new points in the polydata
        input->SetPoints(newpts);
        curv->Update();
    }

    // set, finally, the resulting polydata
    pointf->GetPolyDataOutput()->CopyStructure(input);
    pointf->GetPolyDataOutput()->SetPoints(newpts);
    newpts->Delete();
}
//********** end code part **********//

When I execute the code with two iterations, and compare the point positions
and the curvature values in both iterations, the point positions has change,
but the curvatures remains the same.

Thanks for your help.

Andrea Rueda


On 9/21/06, Dominik Szczerba <domi at vision.ee.ethz.ch> wrote:
>
> call Update() from your vtkCurvature instance.
> DS
>
> Andrea del Pilar Rueda Olarte wrote:
> > Hello,
> >
> > I'm working in a program to deform 3D surfaces, but I have a little
> > problem with the data attributes associated to the polydata.
> >
> > I use a vtkProgrammableFilter to modify the position of the mesh points,
> > and I use a loop to iterate and update the point's position every time.
> > The new position depends basically of the surface curvature in that
> > point, and to obtain the curvature values I use the class vtkCurvatures.
> > I get the curvature of the initial surface, but after the first
> > iteration, in the sucessive modifications of the surface, the curvature
> > values remains the same. I think I need to call some method to force the
> > update of the curvature values associated to the polydata, but I don't
> > know what to do with this.
> >
> > Thanks for your help.
> >
> > Andrea Rueda
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > 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
>
> --
> Dominik Szczerba, Ph.D.
> Computer Vision Lab CH-8092 Zurich
> http://www.vision.ee.ethz.ch/~domi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060924/c05d9bf2/attachment.htm>


More information about the vtkusers mailing list