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

wip: script vérification de maillage

parent 6152c936
No related branches found
No related tags found
No related merge requests found
build/
.vscode/
obj/
\ No newline at end of file
......@@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 11)
find_package(TTKVTK REQUIRED)
add_executable(projet-stage main.cpp)
add_executable(projet-stage main.cpp isTriangulate.cpp)
target_link_libraries(projet-stage
PUBLIC
......
#include <vtkTriangleFilter.h>
#include "isTriangulate.h"
// Fonction pour construire une triangulation valide à partir d'un vtkPolyData contenant des quadrilatères
vtkSmartPointer<vtkPolyData> triangulate::buildValidTriangulation(vtkSmartPointer<vtkPolyData> polyData)
{
vtkSmartPointer<vtkPolyData> triPolyData = vtkSmartPointer<vtkPolyData>::New();
// Si le maillage en entrée est composé de quadrilatères, on construit une triangulation valide
if (polyData->GetMaxCellSize() > 3)
{
std::cout << "maillage composé de quads";
// On utilise un filtre vtkQuadToTriangle pour convertir les quadrilatères en triangles
vtkSmartPointer<vtkTriangleFilter> quadToTri = vtkSmartPointer<vtkTriangleFilter>::New();
quadToTri->SetInputData(polyData);
quadToTri->Update();
triPolyData = quadToTri->GetOutput();
}
else if (polyData->GetMaxCellSize() == 3) // Si le maillage en entrée est déjà triangulé, on renvoie le vtkPolyData d'origine
{
triPolyData = polyData;
}
else
{
std::cout << "Ce maillage n'est pas géré par ce programme, sont acceptés les maillages triangulés et quadrilatérisés";
}
// On ajoute un filtre vtkTriangleFilter pour garantir que la sortie est bien un maillage triangulé
vtkSmartPointer<vtkTriangleFilter> triangleFilter = vtkSmartPointer<vtkTriangleFilter>::New();
triangleFilter->SetInputData(triPolyData);
triangleFilter->Update();
return triangleFilter->GetOutput();
}
\ No newline at end of file
#ifndef IS_TRIANGULATE_H // Vérification d'inclusion multiple
#define IS_TRIANGULATE_H
namespace triangulate
{
vtkSmartPointer<vtkPolyData> buildValidTriangulation(vtkSmartPointer<vtkPolyData> polyData); // Prototype de la fonction
}
#endif // Fin de vérification d'inclusion multiple
......@@ -32,13 +32,16 @@
#include <vtkExtractSurface.h>
#include <ttkGeometrySmoother.h>
#include <vtkDataSetSurfaceFilter.h>
#include <ttkUtils.h>
#include <vtkThresholdPoints.h>
#include <vtkAppendPolyData.h>
#include <vtkSortDataArray.h>
int main(int argc, char* argv[]) {
#include "isTriangulate.h"
int main(int argc, char *argv[])
{
if (argc != 2)
{
std::cout << "Required arguments: Filename(.obj)" << std::endl;
......@@ -57,7 +60,8 @@ int main(int argc, char* argv[]) {
vtkNew<vtkOBJReader> reader;
reader->SetFileName(filename.c_str());
reader->Update();
source = reader->GetOutput();
source = triangulate::buildValidTriangulation(reader->GetOutput());
}
else
{
......@@ -78,7 +82,6 @@ int main(int argc, char* argv[]) {
minCurvaturesFilter->Update();
auto k2 = minCurvaturesFilter->GetOutput();
// Shape Index computation
k1->GetPointData()->SetActiveScalars("Maximum_Curvature");
auto k1Array = k1->GetPointData()->GetAbstractArray("Maximum_Curvature");
......@@ -158,7 +161,6 @@ int main(int argc, char* argv[]) {
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());
......@@ -185,7 +187,6 @@ int main(int argc, char* argv[]) {
// tube->SetNumberOfSides(1);
tube->Update();
// Save the graph nodes with IcospheresFromPoints
vtkNew<vtkXMLPolyDataWriter> writerNodes{};
writerNodes->SetFileName("ReebGraphNodes.vtp");
......@@ -223,7 +224,5 @@ int main(int argc, char* argv[]) {
segWriter->SetFileName("outputColor.vtp");
segWriter->Write();*/
return EXIT_SUCCESS;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment