[vtkusers] ActiViz C# | Get Cells of a Polydata | Get Points of every cell in PolyData

David Gobbi david.gobbi at gmail.com
Wed Jan 15 14:01:15 EST 2014


To get the number of points in a cell, call idlist.GetNumberOfIds()
after you call GetNextCell(idlist).

On Wed, Jan 15, 2014 at 11:46 AM, Matias Montroull <matimontg at gmail.com> wrote:
> Wow, your code works like a charm. I only had to delete the definition
> "double" below each double array variable declaration.
>
> Now, last question, I have a count of 1279226 Cells.. pa, pb and pc are 3
> Points in that Cell or how is it? How many points a cell has?
>
>
> On Wed, Jan 15, 2014 at 2:49 PM, David Gobbi <david.gobbi at gmail.com> wrote:
>>
>> I think you are just missing this final piece inside your loop:
>>
>>   {
>>
>>     ...
>>     double[] pa = new double[3];
>>     double pa = polys.GetPoint(a);
>>     double[] pb = new double[3];
>>     double pb = polys.GetPoint(b);
>>     double[] pc = new double[3];
>>     double pc = polys.GetPoint(c);
>>   }
>>
>> The details of the syntax are just guesswork on my part, because I've
>> never used C# or Activiz.
>>
>>   David
>>
>> On Wed, Jan 15, 2014 at 9:45 AM, Matias Montroull <matimontg at gmail.com>
>> wrote:
>> > Hi,
>> >
>> > I'm trying to get the Cells out of a PolyData. So far I've done this:
>> >
>> >               vtkCellArray Cellarray = new vtkCellArray();
>> >               Cellarray = polys.GetPolys(); //where polys is a
>> > vtkpolydata
>> > instance
>> >               int numcells = Cellarray.GetNumberOfCells(); //I get the
>> > number of cells, I want to iterate through each cell..
>> >
>> > I've done this:
>> >               vtkIdList idlist = new vtkIdList();
>> >
>> >               Cellarray.InitTraversal();
>> >
>> >               for (int j = 0; j < polys.GetNumberOfPolys(); j++)
>> >               {
>> >                   Cellarray.GetNextCell(idlist);
>> >
>> >                   double a = idlist.GetId(0);
>> >                   double b = idlist.GetId(1);
>> >                   double c = idlist.GetId(2);
>> >               }
>> > but I don't get the points in the cell, what I'm doing wrong?
>
>


More information about the vtkusers mailing list