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

feat: gère bien le cas où un obj a besoin d'être triangulé, précise si ce n'est pas possible

parent fe98a605
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 11)
find_package(TTKVTK REQUIRED)
add_executable(projet-stage main.cpp isTriangulate.cpp)
add_executable(projet-stage main.cpp triangulate.cpp)
target_link_libraries(projet-stage
PUBLIC
......
#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
/**=========================================================================
* @file main.cpp
*
* @brief This script reads mesh files and translate them in VTKPolyData.
* It calculates the main curvature of the mesh, then the shape index in
* each vertex of the mesh. Generates a Reeb's graph of shape index.
* Finally, it writes the graph in .vtp format and colors the map with
* the shape index of mesh.
*
* @authors Lucie CLERAND, Eve REGA
* Astrid BEYER
*
* @date 2023
* @version 1.0.1
*
=========================================================================**/
#include <vtkNew.h>
#include <vtkSmartPointer.h>
#include <vtkOBJReader.h>
......@@ -38,10 +55,11 @@
#include <vtkAppendPolyData.h>
#include <vtkSortDataArray.h>
#include "isTriangulate.h"
#include "triangulate.h"
int main(int argc, char *argv[])
{
vtkObject::GlobalWarningDisplayOff();
if (argc != 2)
{
std::cout << "Required arguments: Filename(.obj)" << std::endl;
......@@ -60,7 +78,6 @@ int main(int argc, char *argv[])
vtkNew<vtkOBJReader> reader;
reader->SetFileName(filename.c_str());
reader->Update();
source = triangulate::buildValidTriangulation(reader->GetOutput());
}
else
......
#include <vtkTriangleFilter.h>
#include "isTriangulate.h"
#include "triangulate.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)
// if mesh is composed of quads, builds a valid triangulation
if (polyData->GetMaxCellSize() == 4)
{
std::cout << "maillage composé de quads";
// On utilise un filtre vtkQuadToTriangle pour convertir les quadrilatères en triangles
// we're using a vtkQuadToTriangle filter to convert quads in 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
else if (polyData->GetMaxCellSize() == 3) // if mesh is already triangulated, return origin's vtkPolyData
{
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";
std::cout << "This mesh is not handled by this program, allows only triangulated and quadrilated meshes.\n";
std::cout << "Maximum cell size for this mesh: " << polyData->GetMaxCellSize() << ".\n";
exit(0);
}
// On ajoute un filtre vtkTriangleFilter pour garantir que la sortie est bien un maillage triangulé
// adding a vtkTriangleFilter to ensure that the output is a well triangulated mesh
vtkSmartPointer<vtkTriangleFilter> triangleFilter = vtkSmartPointer<vtkTriangleFilter>::New();
triangleFilter->SetInputData(triPolyData);
triangleFilter->Update();
......
/**
* @class triangulate
*
* @author Astrid BEYER
* @date 2023
* @version 1.1
*
*/
#ifndef TRIANGULATE_H
#define TRIANGULATE_H
namespace triangulate
{
/**
* @brief buildValidTriangulation : transforms, if necessary, input's polyData so it ensure it's triangulated
* @param polyData
* @returns vtkSmartPointer<vtkPolyData>
*/
vtkSmartPointer<vtkPolyData> buildValidTriangulation(vtkSmartPointer<vtkPolyData> polyData);
}
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment