<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>
vtkSmartPointer<vtkSphereSource> source =
vtkSmartPointer<vtkSphereSource>::New();<br>
source->Update();<br>
<br>
vtkSmartPointer<vtkPolyData> Mesh =
vtkSmartPointer<vtkPolyData>::New();<br>
Mesh->DeepCopy( source->GetOutput());<br>
Mesh->BuildLinks();<br>
<br>
// cell 0 and cell 1 share the same edge composed by the
couple of points (0, 8)<br>
// we create a new point in the middle of the edge<br>
// then instead of creating four new cells we update cell 0
and cell 1 and create only two new cells<br>
<br>
vtkIdType cell0pt0, cell0pt1, cell0pt2;<br>
vtkIdType cell1pt0, cell1pt1, cell1pt2;<br>
<br>
vtkSmartPointer<vtkIdList> ids_list =
vtkSmartPointer<vtkIdList>::New();<br>
Mesh->GetCellPoints( 0, ids_list);<br>
<br>
cell0pt0 = ids_list->GetId(1);<br>
cell0pt1 = ids_list->GetId(2);<br>
cell0pt2 = ids_list->GetId(0);<br>
<br>
Mesh->GetCellPoints( 1, ids_list);<br>
<br>
cell1pt0 = ids_list->GetId(0);<br>
cell1pt2 = ids_list->GetId(1);<br>
cell1pt1 = ids_list->GetId(2);<br>
<br>
double point0[3], point1[3], newPoint[3];<br>
<br>
Mesh->GetPoints()->GetPoint( cell0pt0, point0);<br>
Mesh->GetPoints()->GetPoint( cell0pt1, point1);<br>
<br>
for(int i=0; i<3; i++)<br>
newPoint[i] = 0.5*( point0[i]+ point1[i]);<br>
<br>
// for each cell we create two new cell from the middle of the
edge<br>
<br>
// newPoint will be used by four cells<br>
vtkIdType newId = Mesh->InsertNextLinkedPoint(newPoint,4);<br>
<br>
// we update the current cell 0 by replacing cell0pt1 with the
new point<br>
Mesh->ReplaceCellPoint( 0, cell0pt1, newId);<br>
Mesh->RemoveReferenceToCell( cell0pt1, 0);<br>
Mesh->AddReferenceToCell( newId, 0);<br>
<br>
// we add a new cell <br>
vtkIdType tri1[3];<br>
tri1[0] = cell0pt2;<br>
tri1[1] = newId;<br>
tri1[2] = cell0pt1;<br>
<br>
vtkIdType new_cell0 =
Mesh->InsertNextLinkedCell(VTK_TRIANGLE,3,tri1);<br>
<br>
// we update the current cell 1 by replacing cell1pt1 with the
new point<br>
Mesh->ReplaceCellPoint( 1, cell1pt1, newId);<br>
Mesh->RemoveReferenceToCell( cell1pt1, 1);<br>
Mesh->AddReferenceToCell( newId, 1);<br>
<br>
// we add a new cell <br>
vtkIdType tri2[3];<br>
tri2[0] = cell1pt1;<br>
tri2[1] = newId;<br>
tri2[2] = cell1pt2;<br>
<br>
// this line throw a heap corruption alert in debug<br>
vtkIdType new_cell2 =
Mesh->InsertNextLinkedCell(VTK_TRIANGLE,3,tri2);<br>
}<br>
<br>
Le 28/09/2012 11:55, NsPx a écrit :<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>