<div>Look at:</div><div><br></div><div><a href="http://www.vtk.org/doc/nightly/html/classvtkMergePoints.html#3cd8b8f48693148a6b5546c237aab78f">http://www.vtk.org/doc/nightly/html/classvtkMergePoints.html</a></div><div><br>
</div><div>You can insert your points into a merge points class which will determine if the point is a duplicate and return the correct point id. At the end, you can do:</div><div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">aVoxelGrid->SetPoints(vMergePts->GetPoints());</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">- Wes</span></font></div>
<br><div class="gmail_quote">On Tue, Oct 27, 2009 at 11:16 AM, Teresa Azevedo <span dir="ltr"><<a href="mailto:dce06003@fe.up.pt">dce06003@fe.up.pt</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi, Wes. Thank you so much for your quick answer!<br>
<br>
If I try your changes, I runs ok: I get two messages.<br>
But my problem is: I have a set of voxels (with different sizes), from which I build my grid. That is, I do not know which voxels share the same face points.<br>
Is there a way to check, on the point list, if a certain point is already there?<br><font color="#888888">
<br>
Teresa</font><div><div></div><div class="h5"><br>
<br>
Quoting Wes Turner <<a href="mailto:wes.turner@kitware.com" target="_blank">wes.turner@kitware.com</a>>:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Teresa,<br>
<br>
I didn't try to run this, so there may be more issues than just this one,<br>
but you are duplicating points not sharing them. Try the changes I marked<br>
below.<br>
<br>
- Wes<br>
<br>
On Tue, Oct 27, 2009 at 10:46 AM, Teresa Azevedo <<a href="mailto:dce06003@fe.up.pt" target="_blank">dce06003@fe.up.pt</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all.<br>
<br>
I would like to extract the boundary cells of an unstructured grid, that<br>
is, those who have at least one face with no neighbors.<br>
Here is a test code, that builds an unstructured grid, with two voxels that<br>
share one face. When I check if a cell of the grid has neighbors, the code<br>
prompts a message box. Unfortunately, when I run it, I never get the<br>
message.<br>
Can someone tell me what I am doing wrong?<br>
<br>
vtkUnstructuredGrid* aVoxelGrid = vtkUnstructuredGrid::New();<br>
aVoxelGrid->Allocate(2, 2);<br>
<br>
vtkPoints* vPts = vtkPoints::New();<br>
vPts->SetNumberOfPoints(16);<br>
vPts->InsertPoint( 0, 0, 0, 0);<br>
vPts->InsertPoint( 1, 1, 0, 0);<br>
vPts->InsertPoint( 2, 0, 1, 0);<br>
vPts->InsertPoint( 3, 1, 1, 0);<br>
vPts->InsertPoint( 4, 0, 0, 1);<br>
vPts->InsertPoint( 5, 1, 0, 1);<br>
vPts->InsertPoint( 6, 0, 1, 1);<br>
vPts->InsertPoint( 7, 1, 1, 1);<br>
<br>
vtkVoxel* vl = vtkVoxel::New();<br>
vl->GetPointIds()->SetId(0, 0);<br>
vl->GetPointIds()->SetId(1, 1);<br>
vl->GetPointIds()->SetId(2, 2);<br>
vl->GetPointIds()->SetId(3, 3);<br>
vl->GetPointIds()->SetId(4, 4);<br>
vl->GetPointIds()->SetId(5, 5);<br>
vl->GetPointIds()->SetId(6, 6);<br>
vl->GetPointIds()->SetId(7, 7);<br>
<br>
aVoxelGrid->InsertNextCell(VTK_VOXEL, vl->GetPointIds());<br>
<br>
vPts->InsertPoint( 8, 0, 0, 1);<br>
vPts->InsertPoint( 9, 1, 0, 1);<br>
vPts->InsertPoint( 10, 0, 1, 1);<br>
vPts->InsertPoint( 11, 1, 1, 1);<br>
vPts->InsertPoint( 12, 0, 0, 2);<br>
vPts->InsertPoint( 13, 1, 0, 2);<br>
vPts->InsertPoint( 14, 0, 1, 2);<br>
vPts->InsertPoint( 15, 1, 1, 2);<br>
<br>
vtkVoxel* v2 = vtkVoxel::New();<br>
</blockquote>
<br>
v2->GetPointIds()->SetId(0, 8);<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
v2->GetPointIds()->SetId(1, 9);<br>
v2->GetPointIds()->SetId(2, 10);<br>
v2->GetPointIds()->SetId(3, 11);<br>
<br>
</blockquote>
<br>
v2->GetPointIds()->SetId(0, 4);<br>
v2->GetPointIds()->SetId(1, 5);<br>
v2->GetPointIds()->SetId(2, 6);<br>
v2->GetPointIds()->SetId(3, 7);<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
v2->GetPointIds()->SetId(4, 12);<br>
v2->GetPointIds()->SetId(5, 13);<br>
v2->GetPointIds()->SetId(6, 14);<br>
v2->GetPointIds()->SetId(7, 15);<br>
<br>
aVoxelGrid->InsertNextCell(VTK_VOXEL, v2->GetPointIds());<br>
aVoxelGrid->SetPoints(vPts);<br>
aVoxelGrid->Update();<br>
<br>
vtkGenericCell* cell = vtkGenericCell::New();<br>
for( int i = 0; i < aVoxelGrid->GetNumberOfCells(); i++ )<br>
{<br>
aVoxelGrid->GetCell( i, cell );<br>
vtkIdList* cellNeighbors = vtkIdList::New();<br>
int numFaces = cell->GetNumberOfFaces();<br>
for ( int j = 0; j < numFaces; j++ )<br>
{<br>
vtkCell* face = cell->GetFace( j );<br>
aVoxelGrid->GetCellNeighbors( i, face->PointIds,<br>
cellNeighbors);<br>
if ( cellNeighbors->GetNumberOfIds() > 0 )<br>
{<br>
MessageBox(NULL, "Cell has neighbors!",<br>
NULL, MB_OK);<br>
}<br>
}<br>
}<br>
<br>
<br>
Thank you all.<br>
Teresa<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at:<br>
<a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br>
</blockquote>
<br>
<br>
<br>
--<br>
Wesley D. Turner, Ph.D.<br>
Kitware, Inc.<br>
Technical Leader<br>
28 Corporate Drive<br>
Clifton Park, NY 12065-8662<br>
Phone: 518-881-4920<br>
<br>
</blockquote>
<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Wesley D. Turner, Ph.D.<br>Kitware, Inc.<br>Technical Leader<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-881-4920<br>