[vtkusers] Replacing Points in polydata mesh

Bayliss, Chris (Chicago) cbayliss at gnresound.com
Thu Apr 12 15:10:53 EDT 2012


Thanks David,

I was able to achieve the desired results with the following code.

//Convert sample vtkpolydatareader to vtk polydata
   vtkPolyData * templatemesh = cleanclipper->GetOutput();
   vtkPolyData * sample1 = cleansample1->GetOutput();
   vtkPolyData * newsample1 = vtkPolyData::New();
   newsample1->DeepCopy(templatemesh);
   sample1->Update();
   newsample1->Update();

   //Create closest point locator
   vtkPointLocator *nearpt = vtkPointLocator::New();
   nearpt->SetDataSet(sample1);
   nearpt->SetNumberOfPointsPerBucket(25);
   nearpt->BuildLocator();
   
   vtkPoints *newpts = vtkPoints::New();

 for(vtkIdType a = 0; a < templatemesh->GetNumberOfPoints(); a++)
      {
	   double templatepoint[3];
	   templatemesh->GetPoint(a,templatepoint);
       vtkIdType ptloc = nearpt->FindClosestPoint(templatepoint);
	   
	   double sample1point[3];
	   sample1->GetPoint(ptloc, sample1point);
       newpts->InsertNextPoint(sample1point); 
	   newpts->Modified();
	   
      
      }

   newsample1->SetPoints(newpts);
   newsample1->Update();

Regards,

Chris


-----Original Message-----
From: David Doria [mailto:daviddoria at gmail.com] 
Sent: Thursday, April 12, 2012 1:20 PM
To: Bayliss, Chris (Chicago)
Cc: VTK Users
Subject: Re: [vtkusers] Replacing Points in polydata mesh

On Thu, Apr 12, 2012 at 2:16 PM, Bayliss, Chris (Chicago)
<cbayliss at gnresound.com> wrote:
>
>
> I would like the surface topology to move with the new point
locations.
> From the earlier comments, it sounds like I would also have to modify
the
> polydata cells?
>
>
>
> Would the points->Modified() function, recalculate the cells with the
new
> points properly, or do I need to add some other functions to change
the cell
> points?

If you want the topology to stay the same you don't have to do
anything. Once the data set is redrawn it will do what you want. I'd
suggest trying it with a sphere source or similar so you can convince
yourself of how it works.

David

**** GN GROUP NOTICE - AUTOMATICALLY INSERTED **** 
The information in this e-mail (including attachments, if any) is
considered confidential and is intended only for the recipient(s) listed
above. Any review, use, disclosure, distribution or copying of this
e-mail is prohibited except by or on behalf of the intended recipient.
If you have received this email in error, please notify me immediately
by reply e-mail, delete this e-mail, and do not disclose its contents to
anyone. Any opinions expressed in this e-mail are those of the
individual and not necessarily the GN group. Thank you. 
******************** DISCLAIMER END ************************


**** GN GROUP NOTICE - AUTOMATICALLY INSERTED **** 
The information in this e-mail (including attachments, if any) is considered confidential and is intended only for the recipient(s) listed above. Any review, use, disclosure, distribution or copying of this e-mail is prohibited except by or on behalf of the intended recipient. If you have received this email in error, please notify me immediately by reply e-mail, delete this e-mail, and do not disclose its contents to anyone. Any opinions expressed in this e-mail are those of the individual and not necessarily the GN group. Thank you. 
******************** DISCLAIMER END ************************




More information about the vtkusers mailing list