[vtkusers] vtkMergePoints usage

Doug McCorkle mccdo at iastate.edu
Mon Oct 13 10:30:56 EDT 2003


I found a really good way if you don't mind getting an unsgrid back.
Here is the code snippet.

 vtkExtractUnstructuredGrid *extunsgrid =
vtkExtractUnstructuredGrid::New();
 //extunsgrid->DebugOn();
 extunsgrid->BreakOnError();
 extunsgrid->PointClippingOn();
 extunsgrid->CellClippingOff();
 extunsgrid->ExtentClippingOff();
 extunsgrid->MergingOn();
 
 int numPoints = ((vtkPointSet
*)filter->GetOutput())->GetNumberOfPoints();
 extunsgrid->SetInput( ( vtkUnstructuredGrid * ) filter->GetOutput() );
 extunsgrid->SetPointMinimum( 0 );
 extunsgrid->SetPointMaximum( numPoints );
 extunsgrid->Update();
 
 unswriter->SetFileName( "merged.vtk" );
 unswriter->SetInput( ( vtkUnstructuredGrid * ) extunsgrid->GetOutput()
);
 //unswriter->Print( cout );
 //if (!debug)
 unswriter->SetFileTypeToBinary();
 unswriter->Write();
 unswriter->Delete();

-----Original Message-----
From: Turner, Wesley D (Research) [mailto:turner at crd.ge.com] 
Sent: Thursday, October 09, 2003 11:35 AM
To: 'Doug McCorkle'; Turner, Wesley D (Research)
Cc: vtkusers at vtk.org; 'Steve Boyd'
Subject: RE: [vtkusers] vtkMergePoints usage (Steve Boyd)

I generally use Polydata so this isn't a problem for me, but
vtkGeometryFilter MAY work to convert from an unstructured grid.  In any
event, you can use the vtkCleanPolyData code to figure out how to get
rid of
duplicates.

- Wes

-----Original Message-----
From: Doug McCorkle [mailto:mccdo at iastate.edu]
Sent: Thursday, October 09, 2003 12:28 PM
To: Turner, Wesley D (Research)
Cc: vtkusers at vtk.org; 'Steve Boyd'
Subject: Re: [vtkusers] vtkMergePoints usage (Steve Boyd)


Does that also work for unstructured grids? So do you create a 
ploydataset from the unsgrid and then clean it?

On Thursday, October 9, 2003, at 09:54  AM, Turner, Wesley D (Research) 
wrote:

> Did you try vtkCleanPolyData?
>
> - Wes
>
> -----Original Message-----
> From: Doug McCorkle [mailto:mccdo at iastate.edu]
> Sent: Thursday, October 09, 2003 8:02 AM
> To: vtkusers at vtk.org
> Cc: 'Steve Boyd'
> Subject: [vtkusers] vtkMergePoints usage (Steve Boyd)
>
>
> Steve,
>      We also are having the same problems as you. I have been unable
to
> figure out how to use vtkMergePoints to accomplish this task. I have
> also been unable to figure out an alternate way to remove coincident
> points. If anyone has sample code that does this I would be interested
> in the code.
> Doug
>
> Message: 3
> Date: Wed, 08 Oct 2003 15:05:55 -0700
> From: Steve Boyd <skboyd at ucalgary.ca>
> Organization: University of Calgary
> To: vtk <vtkusers at public.kitware.com>
> Subject: [vtkusers] vtkMergePoints usage
>
> Hi,
>
> I am trying to locate duplicate points using vtkMergePoints.  I am
> successful at finding, for any given point, the closest point using
> ->FindClosestPoint(p1), but I when I try running ->IsUniquePoint(p1) I
> get a runtime error (memory).  Am I using this class incorrectly?
>
>     float p1[3];
>     p1[0] = 2.0;
>     p1[1] = 1.0;
>     p1[2] = 0.5;
>
>     vtkMergePoints *pointLocator = vtkMergePoints::New();
>       pointLocator->SetDataSet(ug);	// ug is vtkUnstructuredGrid
> data
>       pointLocator->BuildLocator();
>
>     // this line works fine
>     cout << "Closest point is at id " <<
> pointLocator->FindClosestPoint(p1) << endl;
>
>     // this line gives a runtime error (regardless if p1 is unique or
> not).
>     cout << "Is it inserted? " << pointLocator->IsInsertedPoint(p1) <<
> endl;
>
> I'm guessing that this isn't a bug, but rather my incorrect usage of 
> the
> class.  Can somebody tell me how to use it properly?
>
> Regards,
>
> Steve
>
> -- 
> Steven Boyd
>
> PhD, PEng
> Assistant Professor
> Department of Mechanical and Manufacturing Engineering
> University of Calgary
> 2500 University Drive, N.W.
> Calgary, Alberta, Canada, T2N 1N4
>
> tel. 1.403.220.4173  fax. 1.403.282.8406  skboyd at ucalgary.ca
> -------------------------------------------------------------------
>
>
>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>






More information about the vtkusers mailing list