Finding critical point in vtkPolyData. Found the GetScalarFieldCriticalIndex method, but the method always returns ERR_INCORRECT_FIELD (-3), what am I doing wrong?
vtkDoubleArray* da = dynamic_cast<vtkDoubleArray*>(pd->GetPointData()->GetArray(0));
if (da != NULL) {
for (int i = 0; i < pd->GetNumberOfPoints(); i++) {
auto p = points->GetPoint(i);
pointsNew->InsertNextPoint(p[0], p[1], p[2] + da->GetValue(i));
int type = pd->GetScalarFieldCriticalIndex(pd->FindPoint(p[0], p[1], p[2]), 0);
if (type != -3) {
printf("");
}
}
}
Java code:
vtkPolyData pd = new vtkPolyData();
vtkPoints points = new vtkPoints();
points.InsertNextPoint(0, 0, 0);
points.InsertNextPoint(5, 0, 0);
points.InsertNextPoint(5, 5, 0);
points.InsertNextPoint(0, 5, 0);
points.InsertNextPoint(2.5, 2.5, 0);
vtkDoubleArray da = new vtkDoubleArray();
da.InsertNextValue(0);
da.InsertNextValue(0);
da.InsertNextValue(0);
da.InsertNextValue(0);
da.InsertNextValue(1);
pd.SetPoints(points);
pd.GetPointData().SetScalars(da);
for (int i = 0; i < points.GetNumberOfPoints(); i++) {
System.out.println(pd.GetScalarFieldCriticalIndex(i, 0));
}
out:
-3
-3
-3
-3
-3
What am I doing wrong?
if (this->GetNumberOfPoints() != scalarField->GetSize())
{
return vtkPolyData::ERR_INCORRECT_FIELD;
}
so you could try and print the size of the array.
Apart from that, you also need to add triangle cells to form a valid manifold 2d mesh.