[vtkusers] Using vtkMarchingCubes3D with vtkContourWidget

Jonathan Morra jonmorra at gmail.com
Mon Nov 15 14:08:53 EST 2010


So I've found out some more info.  It would appear that I am in fact
ordering the points in each cell correctly.  The following code will output
a part of the total points in order.  However, if I uncomment the outer for
loop and change strippedData.GetCell(0) to strippedData.GetCell(i) the
points are again out of order (like my last message).  It would appear that
the cells of stripped data have an order that is not 0, 1, 2,...

Does anyone know if this is correct, or if I'm on the right track?

        vtkStripper stripper = new vtkStripper();
        stripper.SetInput(unorderedData);
        stripper.Update();
        vtkPolyData strippedData = stripper.GetOutput();

        vtkPoints points = new vtkPoints();
        // Here, we're trying to mimic the suggestion given here
        //
http://vtk.1045678.n5.nabble.com/question-about-vtkContourWidget-vtkContourRepresentation-td1255118.html#a3247766

        //for (int i=0; i<strippedData.GetNumberOfCells(); i++) {
            vtkCell cell = strippedData.GetCell(0);
            for (int j=0; j<cell.GetPoints().GetNumberOfPoints()-1; j++) {
                points.InsertNextPoint(cell.GetPoints().GetPoint(j));
            }
        //}
        return points;

On Thu, Nov 11, 2010 at 12:24 PM, Jonathan Morra <jonmorra at gmail.com> wrote:

> So after struggling with this for a while, I've come up with the following
> code, which kinda does the job.
>
>     public vtkPoints reorderPoints(vtkPolyData unorderedData) {
>         vtkStripper stripper = new vtkStripper();
>         stripper.SetInput(unorderedData);
>         stripper.Update();
>         vtkPolyData strippedData = stripper.GetOutput();
>
>         vtkPoints points = new vtkPoints();
>         // Here, we're trying to mimic the suggestion given here
>         //
> http://vtk.1045678.n5.nabble.com/question-about-vtkContourWidget-vtkContourRepresentation-td1255118.html#a3247766
>         for (int i=0; i<strippedData.GetNumberOfCells(); i++) {
>             vtkCell cell = strippedData.GetCell(i);
>             for (int j=0; j<cell.GetPoints().GetNumberOfPoints()-1; j++) {
>                 points.InsertNextPoint(cell.GetPoints().GetPoint(j));
>             }
>         }
>         return points;
>     }
> The points that are returned are in "better" order than having not run this
> method, but it's still not the correct order.  It turns out that I cannot
> upgrade to the newest version of VTK because we're using GDCM which isn't
> yet integrated into the newest version of VTK, so I'm stuck with 5.6 for
> now.  However, I did do a test on the head of GIT and I tried to use
> Karthik's code suggested above, but I still couldn't get that working.  I
> attempted to follow internally what vtkCellArray.GetNextCell() was doing,
> and that's how I came up with the above function.
>
> Can someone tell me why the above function isn't returning the vtkPoints in
> the correct order for vtkContourWidget?
>
> Thanks
>
> On Sat, Nov 6, 2010 at 10:12 PM, Karthik Krishnan <
> karthik.krishnan at kitware.com> wrote:
>
>> Ah.. yes.. This method was added on May 19, 2010. Perhaps you are
>> using a version of VTK prior to that.
>>
>> Please see :
>>
>> http://vtk.org/gitweb?p=VTK.git;a=commitdiff;h=068a064cea7ba0fc7a4c4f9d2f7dfed6eb093674
>>
>> Update your VTK.
>>
>>
>> On Sat, Nov 6, 2010 at 10:54 PM, Jonathan Morra <jonmorra at gmail.com>
>> wrote:
>> > I couldn't find GetNextCell() at all in Java. I'm currently using
>> version
>> > 5.6. Do you have any other suggestions?
>> >
>> > On Nov 6, 2010 9:05 AM, "Karthik Krishnan" <
>> karthik.krishnan at kitware.com>
>> > wrote:
>> >
>> > Jonathan:
>> >
>> > Use the other signature of the method GetNextCell. [ int
>> > GetNextCell(vtkIdList *pts) ]That should be wrapped...
>> >
>> > The code to re-order the points based on the connectivity information
>> > would be written in java as :
>> >
>> >  vtkIdList idlist = new vtkIdList();
>> >  unorderedPolyData.GetLines().GetNextCell(idlist);
>> >  npts = idlist.GetNumberOfIds();
>> >  for ( int i = 0;  i < ( npts-1 );  i ++)
>> >    {
>> >    points.InsertPoint(i,
>> unorderedPolyData.GetPoints().GetPoint(pts[i]));
>> >    }
>> >
>> > --
>> > karthik
>> >
>> > On Wed, Nov 3, 2010 at 7:29 AM, Jonathan Morra <jonmorra at gmail.com>
>> wrote:
>> >> I have a 3D vtkPolyDat...
>> >
>> >> _______________________________________________
>> >> Powered by www.kitware.com
>> >>
>> >> Visit other Kitwa...
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101115/b1017893/attachment.htm>


More information about the vtkusers mailing list