[vtkusers] Help with allocating memory ++

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Mon Jul 8 05:52:56 EDT 2002


hi,

Please avoid HTML emails.  They are hard to read and reply to.

>>>>> "TK" == Trond Kristiansen <polar_trond at hotmail.com> writes:

[snip]
    TK> <P>coastlineX=string.atof(XY[0])*1000</P>
    TK> <P>coastlineY=string.atof(XY[1])*1000</P>
    TK> <P>coastlineZ=0.1</P> <P>if (55000 &lt; coastlineY &lt; 61000)
    TK> and (5000 &lt; coastlineX &lt; 11000):</P>
    TK> <P>pointID=point.InsertNextPoint(coastlineX,coastlineY,coastlineZ)</P>
    TK> <P>cell.InsertNextCell(pointID)</P> <P></P> <P>coastXY =
    TK> coast.readline()</P> <P>XY = string.split(coastXY)</P> <P></P>
    TK> <P>coast.close()</P> <P>poly.SetPoints(point)</P>
[...]

I'm not sure that the cell.InsertNextCell(pointID) is correct.  From
the docs:

  // Description:
  // Create cells by specifying count, and then adding points one at a time
  // using method InsertCellPoint(). If you don't know the count initially,
  // use the method UpdateCellCount() to complete the cell. Return the cell
  // id of the cell.
  vtkIdType InsertNextCell(int npts);

So when you call cell.InsertNextCell(pointID) you are saying you want
a cell with pointID number of points.  Which is not what you want.
The approach I usually take is to do:

ids = vtkIdList()
ids.Reset() # reset the ids to contain no connectivity.
ids.InsertNextId(pointID)
# etc.
cell.InsertNextCell(ids)

This way you can insert cells with different number/type of
connectivity.


cheers,
prabhu



More information about the vtkusers mailing list