Teresa,<div><br></div><div>I didn&#39;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">&lt;<a href="mailto:dce06003@fe.up.pt">dce06003@fe.up.pt</a>&gt;</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-&gt;Allocate(2, 2);<br>
<br>
        vtkPoints* vPts = vtkPoints::New();<br>
        vPts-&gt;SetNumberOfPoints(16);<br>
        vPts-&gt;InsertPoint( 0, 0, 0, 0);<br>
        vPts-&gt;InsertPoint( 1, 1, 0, 0);<br>
        vPts-&gt;InsertPoint( 2, 0, 1, 0);<br>
        vPts-&gt;InsertPoint( 3, 1, 1, 0);<br>
        vPts-&gt;InsertPoint( 4, 0, 0, 1);<br>
        vPts-&gt;InsertPoint( 5, 1, 0, 1);<br>
        vPts-&gt;InsertPoint( 6, 0, 1, 1);<br>
        vPts-&gt;InsertPoint( 7, 1, 1, 1);<br>
<br>
        vtkVoxel* vl = vtkVoxel::New();<br>
        vl-&gt;GetPointIds()-&gt;SetId(0, 0);<br>
        vl-&gt;GetPointIds()-&gt;SetId(1, 1);<br>
        vl-&gt;GetPointIds()-&gt;SetId(2, 2);<br>
        vl-&gt;GetPointIds()-&gt;SetId(3, 3);<br>
        vl-&gt;GetPointIds()-&gt;SetId(4, 4);<br>
        vl-&gt;GetPointIds()-&gt;SetId(5, 5);<br>
        vl-&gt;GetPointIds()-&gt;SetId(6, 6);<br>
        vl-&gt;GetPointIds()-&gt;SetId(7, 7);<br>
<br>
        aVoxelGrid-&gt;InsertNextCell(VTK_VOXEL, vl-&gt;GetPointIds());<br>
<br>
        vPts-&gt;InsertPoint( 8, 0, 0, 1);<br>
        vPts-&gt;InsertPoint( 9, 1, 0, 1);<br>
        vPts-&gt;InsertPoint( 10, 0, 1, 1);<br>
        vPts-&gt;InsertPoint( 11, 1, 1, 1);<br>
        vPts-&gt;InsertPoint( 12, 0, 0, 2);<br>
        vPts-&gt;InsertPoint( 13, 1, 0, 2);<br>
        vPts-&gt;InsertPoint( 14, 0, 1, 2);<br>
        vPts-&gt;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-&gt;GetPointIds()-&gt;SetId(0, 8);<br>       v2-&gt;GetPointIds()-&gt;SetId(1, 9);<br>

        v2-&gt;GetPointIds()-&gt;SetId(2, 10);<br>
        v2-&gt;GetPointIds()-&gt;SetId(3, 11);<br></blockquote><div> </div>       v2-&gt;GetPointIds()-&gt;SetId(0, 4);<br>       v2-&gt;GetPointIds()-&gt;SetId(1, 5);<br>       v2-&gt;GetPointIds()-&gt;SetId(2, 6);<br>       v2-&gt;GetPointIds()-&gt;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-&gt;GetPointIds()-&gt;SetId(4, 12);<br>
        v2-&gt;GetPointIds()-&gt;SetId(5, 13);<br>
        v2-&gt;GetPointIds()-&gt;SetId(6, 14);<br>
        v2-&gt;GetPointIds()-&gt;SetId(7, 15);<br>
<br>
        aVoxelGrid-&gt;InsertNextCell(VTK_VOXEL, v2-&gt;GetPointIds());<br>
        aVoxelGrid-&gt;SetPoints(vPts);<br>
        aVoxelGrid-&gt;Update();<br>
<br>
        vtkGenericCell* cell = vtkGenericCell::New();<br>
        for( int i = 0; i &lt; aVoxelGrid-&gt;GetNumberOfCells(); i++ )<br>
        {<br>
                aVoxelGrid-&gt;GetCell( i, cell );<br>
                vtkIdList* cellNeighbors = vtkIdList::New();<br>
                int numFaces = cell-&gt;GetNumberOfFaces();<br>
                for ( int j = 0; j &lt; numFaces; j++ )<br>
                {<br>
                        vtkCell* face = cell-&gt;GetFace( j );<br>
                        aVoxelGrid-&gt;GetCellNeighbors( i, face-&gt;PointIds, cellNeighbors);<br>
                        if ( cellNeighbors-&gt;GetNumberOfIds() &gt; 0 )<br>
                        {<br>
                                MessageBox(NULL, &quot;Cell has neighbors!&quot;, 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>