Skip to content
Snippets Groups Projects
Commit 5fc21bee authored by Astrid Beyer's avatar Astrid Beyer
Browse files

wip: filter no err

parent ada8a302
Branches main
No related tags found
No related merge requests found
......@@ -192,81 +192,56 @@ int main(int argc, char *argv[])
*/
/** Another filter **/
double threshold = 0.9;
double threshold = 0.95;
vtkSmartPointer<vtkPoints> filteredPoints = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkDoubleArray> filteredShapeIndex = vtkSmartPointer<vtkDoubleArray>::New();
filteredShapeIndex->SetName("Filtered_Shape_Index");
for (vtkIdType i = 0; i < k2->GetNumberOfPoints(); ++i)
{
double kmax = k1Array->GetVariantValue(i).ToDouble();
double kmin = k2Array->GetVariantValue(i).ToDouble();
double si = 0.5 - (1 / M_PI) * atan((kmax + kmin) / (kmin - kmax)); // Calcul de l'indice de forme
if (si > 0 && si < 1) // Vérifiez si l'indice de forme est différent de 0 et 1
{
if (si >= threshold) // Vérifiez si l'indice de forme dépasse le seuil
{
filteredPoints->InsertNextPoint(source->GetPoint(i));
filteredShapeIndex->InsertNextValue(si);
}
}
}
// Créez un nouveau maillage à partir des points filtrés
vtkSmartPointer<vtkPolyData> filteredMesh = vtkSmartPointer<vtkPolyData>::New();
filteredMesh->SetPoints(filteredPoints);
filteredMesh->GetPointData()->AddArray(filteredShapeIndex);
for (vtkIdType i = 0; i < filteredShapeIndex->GetNumberOfTuples(); ++i)
{
double value = filteredShapeIndex->GetValue(i);
std::cout << "Shape_Index[" << i << "] = " << value << std::endl;
}
source->GetPointData()->AddArray(filteredShapeIndex);
source->GetPointData()->SetActiveScalars("Shape_Index");
// Create a vtkThresholdPoints filter for each threshold value
vtkNew<vtkThresholdPoints> threshold1;
threshold1->SetInputData(source);
threshold1->SetInputArrayComponent(1);
threshold1->ThresholdBetween(threshold, 1);
threshold1->Update();
// Create a vtkFTRGraph
vtkNew<ttkFTRGraph> graph1;
graph1->SetInputData(threshold1->GetOutput());
graph1->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Shape_Index");
graph1->Update();
// vtkNew<ttkFTRGraph> graph;
// graph->SetInputData(filteredMesh);
// graph->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Shape_Index");
// graph->Update();
// Merge the thresholded datasets together into a single polydata
vtkNew<vtkAppendPolyData> appendFilter;
appendFilter->AddInputData(threshold1->GetOutput());
appendFilter->Update();
// Compute the Reeb Graph of the input dataset
vtkNew<ttkFTRGraph> reebGraph;
// reebGraph->SetInputData(source);
// reebGraph->SetInputData(appendFilter->GetOutput()); // ttkFTRGraph for the merged polydata
// reebGraph->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Shape_Index");
reebGraph->SetInputData(source);
reebGraph->SetInputData(appendFilter->GetOutput());
reebGraph->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Shape_Index");
reebGraph->Update();
// Create Icospheres to represent nodes in the Reeb Graph
vtkNew<ttkIcospheresFromPoints> ttkIcospheresFromPoints{};
ttkIcospheresFromPoints->SetInputData(0, reebGraph->GetOutput());
ttkIcospheresFromPoints->SetRadius(0.008);
ttkIcospheresFromPoints->SetRadius(1);
ttkIcospheresFromPoints->SetNumberOfSubdivisions(1);
ttkIcospheresFromPoints->Update();
// // Filters dependencies with Tubes : applies smooth to the geometry of the Reeb Graph
// vtkNew<ttkGeometrySmoother> ttkGeometrySmoother{};
// ttkGeometrySmoother->SetInputConnection(reebGraph->GetOutputPort(1));
// ttkGeometrySmoother->Update();
// Filters dependencies with Tubes : applies smooth to the geometry of the Reeb Graph
vtkNew<ttkGeometrySmoother> ttkGeometrySmoother{};
ttkGeometrySmoother->SetInputConnection(reebGraph->GetOutputPort(1));
ttkGeometrySmoother->Update();
// vtkNew<vtkGeometryFilter> geometryFilter{};
// geometryFilter->SetInputConnection(ttkGeometrySmoother->GetOutputPort());
// geometryFilter->Update();
vtkNew<vtkGeometryFilter> geometryFilter{};
geometryFilter->SetInputConnection(ttkGeometrySmoother->GetOutputPort());
geometryFilter->Update();
// vtkNew<vtkPolyData> polyData{};
// polyData->ShallowCopy(geometryFilter->GetOutput());
vtkNew<vtkPolyData> polyData{};
polyData->ShallowCopy(geometryFilter->GetOutput());
// // Create Tubes to represent edges in the Reeb Graph
// vtkNew<vtkTubeFilter> tube{};
// tube->SetInputData(polyData); // smoothed geometry of the Reeb graph
// tube->SetRadius(0.004);
// // tube->SetNumberOfSides(1);
// tube->Update();
// Create Tubes to represent edges in the Reeb Graph
vtkNew<vtkTubeFilter> tube{};
tube->SetInputData(polyData); // smoothed geometry of the Reeb graph
tube->SetRadius(0.004);
// tube->SetNumberOfSides(1);
tube->Update();
// Save the graph nodes with IcospheresFromPoints
vtkNew<vtkXMLPolyDataWriter> writerNodes{};
......@@ -286,24 +261,5 @@ int main(int argc, char *argv[])
segWriter->SetInputConnection(reebGraph->GetOutputPort(2));
segWriter->Write();
/*
// Save the graph nodes (simple graph)
vtkNew<vtkXMLUnstructuredGridWriter> sWriter{};
sWriter->SetInputConnection(reebGraph->GetOutputPort(0));
sWriter->SetFileName("outputNodes.vtp");
sWriter->Write();
// Save the graph edges
vtkNew<vtkXMLUnstructuredGridWriter> sepWriter{};
sepWriter->SetInputConnection(reebGraph->GetOutputPort(1));
sepWriter->SetFileName("outputEdges.vtp");
sepWriter->Write();
// Save the graph coloration
vtkNew<vtkXMLPolyDataWriter> segWriter{};
segWriter->SetInputConnection(reebGraph->GetOutputPort(2));
segWriter->SetFileName("outputColor.vtp");
segWriter->Write();*/
return EXIT_SUCCESS;
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment