<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#003333" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">I'm answering my own post to give more
      details. Here is a C++ example wich reproduces my heap corruption
      problem.<br>
      Thanks by advance.<br>
      <br>
      /****/<br>
      <br>
      #include "vtkPolyData.H"<br>
      #include "vtkSmartPointer.H"<br>
      #include "vtkSphereSource.H"<br>
      #include "vtkIdType.H"<br>
      #include "vtkIdList.H"<br>
      <br>
      int main(int argc, char *argv[])<br>
      {<br>
      &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkSphereSource&gt; source =
      vtkSmartPointer&lt;vtkSphereSource&gt;::New();<br>
      &nbsp;&nbsp;&nbsp; source-&gt;Update();<br>
      <br>
      &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkPolyData&gt; Mesh =
      vtkSmartPointer&lt;vtkPolyData&gt;::New();<br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;DeepCopy( source-&gt;GetOutput());<br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;BuildLinks();<br>
      <br>
      &nbsp;&nbsp;&nbsp; // cell 0 and cell 1 share the same edge composed by the
      couple of points (0, 8)<br>
      &nbsp;&nbsp;&nbsp; // we create a new point in the middle of the edge<br>
      &nbsp;&nbsp;&nbsp; // then instead of creating four new cells we update cell 0
      and cell 1 and create only two new cells<br>
      <br>
      &nbsp;&nbsp;&nbsp; vtkIdType cell0pt0, cell0pt1, cell0pt2;<br>
      &nbsp;&nbsp;&nbsp; vtkIdType cell1pt0, cell1pt1, cell1pt2;<br>
      <br>
      &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt;vtkIdList&gt; ids_list =
      vtkSmartPointer&lt;vtkIdList&gt;::New();<br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;GetCellPoints( 0, ids_list);<br>
      <br>
      &nbsp;&nbsp;&nbsp; cell0pt0 = ids_list-&gt;GetId(1);<br>
      &nbsp;&nbsp;&nbsp; cell0pt1 = ids_list-&gt;GetId(2);<br>
      &nbsp;&nbsp;&nbsp; cell0pt2 = ids_list-&gt;GetId(0);<br>
      <br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;GetCellPoints( 1, ids_list);<br>
      <br>
      &nbsp;&nbsp;&nbsp; cell1pt0 = ids_list-&gt;GetId(0);<br>
      &nbsp;&nbsp;&nbsp; cell1pt2 = ids_list-&gt;GetId(1);<br>
      &nbsp;&nbsp;&nbsp; cell1pt1 = ids_list-&gt;GetId(2);<br>
      <br>
      &nbsp;&nbsp;&nbsp; double point0[3], point1[3], newPoint[3];<br>
      <br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;GetPoints()-&gt;GetPoint( cell0pt0, point0);<br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;GetPoints()-&gt;GetPoint( cell0pt1, point1);<br>
      <br>
      &nbsp;&nbsp;&nbsp; for(int i=0; i&lt;3; i++)<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; newPoint[i] = 0.5*( point0[i]+ point1[i]);<br>
      <br>
      &nbsp;&nbsp;&nbsp; // for each cell we create two new cell from the middle of the
      edge<br>
      <br>
      &nbsp;&nbsp;&nbsp; // newPoint will be used by four cells<br>
      &nbsp;&nbsp;&nbsp; vtkIdType newId = Mesh-&gt;InsertNextLinkedPoint(newPoint,4);<br>
      <br>
      &nbsp;&nbsp;&nbsp; // we update the current cell 0 by replacing cell0pt1 with the
      new point<br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;ReplaceCellPoint( 0, cell0pt1, newId);<br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;RemoveReferenceToCell( cell0pt1, 0);<br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;AddReferenceToCell( newId, 0);<br>
      <br>
      &nbsp;&nbsp;&nbsp; // we add a new cell <br>
      &nbsp;&nbsp;&nbsp; vtkIdType tri1[3];<br>
      &nbsp;&nbsp;&nbsp; tri1[0] = cell0pt2;<br>
      &nbsp;&nbsp;&nbsp; tri1[1] = newId;<br>
      &nbsp;&nbsp;&nbsp; tri1[2] = cell0pt1;<br>
      <br>
      &nbsp;&nbsp;&nbsp; vtkIdType new_cell0 =
      Mesh-&gt;InsertNextLinkedCell(VTK_TRIANGLE,3,tri1);<br>
      <br>
      &nbsp;&nbsp;&nbsp; // we update the current cell 1 by replacing cell1pt1 with the
      new point<br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;ReplaceCellPoint( 1, cell1pt1, newId);<br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;RemoveReferenceToCell( cell1pt1, 1);<br>
      &nbsp;&nbsp;&nbsp; Mesh-&gt;AddReferenceToCell( newId, 1);<br>
      <br>
      &nbsp;&nbsp;&nbsp; // we add a new cell <br>
      &nbsp;&nbsp;&nbsp; vtkIdType tri2[3];<br>
      &nbsp;&nbsp;&nbsp; tri2[0] = cell1pt1;<br>
      &nbsp;&nbsp;&nbsp; tri2[1] = newId;<br>
      &nbsp;&nbsp;&nbsp; tri2[2] = cell1pt2;<br>
      <br>
      &nbsp;&nbsp;&nbsp; // this line throw a heap corruption alert in debug<br>
      &nbsp;&nbsp;&nbsp; vtkIdType new_cell2 =
      Mesh-&gt;InsertNextLinkedCell(VTK_TRIANGLE,3,tri2);<br>
      }<br>
      <br>
      Le 28/09/2012 11:55, NsPx a &eacute;crit&nbsp;:<br>
    </div>
    <blockquote cite="mid:506573F9.9050203@gmail.com" type="cite">
      <meta http-equiv="content-type" content="text/html;
        charset=ISO-8859-1">
      <font size="-1"><font face="Tahoma">Hi all,<br>
          <br>
          <font size="-1">Can someone explain me how vtkPolyData<font
              size="-1">::</font>InsertNextLinkedPoint</font> works ? <br>
          <br>
          I get heap corruption <font size="-1">w</font>hen trying to <font
            size="-1">split triangles by adding new points at this edge.<br>
            <br>
            <font size="-1">Thanks by adva<font size="-1">nce.</font></font><br>
          </font></font></font> </blockquote>
    <br>
  </body>
</html>