Teresa,<div><br></div><div>I didn't try to run this, so there may be more issues than just this one, but you are duplicating points not sharing them. Try the changes I marked below.</div><div><br></div><div>- Wes<br><br>
<div class="gmail_quote">On Tue, Oct 27, 2009 at 10:46 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 all.<br>
<br>
I would like to extract the boundary cells of an unstructured grid, that 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 share one face. When I check if a cell of the grid has neighbors, the code prompts a message box. Unfortunately, when I run it, I never get the 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(); </blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> v2->GetPointIds()->SetId(0, 8);<br> v2->GetPointIds()->SetId(1, 9);<br>
v2->GetPointIds()->SetId(2, 10);<br>
v2->GetPointIds()->SetId(3, 11);<br></blockquote><div> </div> v2->GetPointIds()->SetId(0, 4);<br> v2->GetPointIds()->SetId(1, 5);<br> v2->GetPointIds()->SetId(2, 6);<br> v2->GetPointIds()->SetId(3, 7);<br>
<div> </div><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, cellNeighbors);<br>
if ( cellNeighbors->GetNumberOfIds() > 0 )<br>
{<br>
MessageBox(NULL, "Cell has neighbors!", 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 <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>
</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>
</div>