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

triangulate becomes operation, detection of open surface mesh

parent 71310059
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 triangulate.cpp vtkOFFReader.cxx)
add_executable(projet-stage main.cpp operation_mesh.cpp vtkOFFReader.cxx)
target_link_libraries(projet-stage
PUBLIC
......
......@@ -55,7 +55,7 @@
#include <vtkAppendPolyData.h>
#include <vtkSortDataArray.h>
#include "triangulate.h"
#include "operation_mesh.h"
int main(int argc, char *argv[])
{
......@@ -78,7 +78,8 @@ int main(int argc, char *argv[])
vtkNew<vtkOBJReader> reader;
reader->SetFileName(filename.c_str());
reader->Update();
source = triangulate::buildValidTriangulation(reader->GetOutput());
source = operation::buildValidTriangulation(reader->GetOutput());
vtkSmartPointer<vtkPolyData> toto = operation::closeMesh(reader->GetOutput());
}
else if (extension == ".off")
{
......@@ -93,7 +94,7 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
}
if (source->GetNumberOfCells() > 90000) // avoid segmentation fault
if (source->GetNumberOfCells() > 100000) // avoid segmentation fault
{
std::cerr << "Your mesh has too many polygones (" << source->GetNumberOfCells() << ") for this program to run properly.\n";
return EXIT_FAILURE;
......@@ -121,7 +122,7 @@ int main(int argc, char *argv[])
vtkNew<vtkDoubleArray> shapeIndex;
shapeIndex->SetName("Shape_Index");
for (vtkIdType i = 0; i < k1->GetNumberOfPoints(); ++i)
for (vtkIdType i = 0; i < k2->GetNumberOfPoints(); ++i)
{
double kmax = k1Array->GetVariantValue(i).ToDouble();
double kmin = k2Array->GetVariantValue(i).ToDouble();
......
#include <vtkTriangleFilter.h>
#include "triangulate.h"
#include "operation_mesh.h"
vtkSmartPointer<vtkPolyData> triangulate::buildValidTriangulation(vtkSmartPointer<vtkPolyData> polyData)
vtkSmartPointer<vtkPolyData> operation::buildValidTriangulation(vtkSmartPointer<vtkPolyData> polyData)
{
vtkSmartPointer<vtkPolyData> triPolyData = vtkSmartPointer<vtkPolyData>::New();
......@@ -32,3 +31,32 @@ vtkSmartPointer<vtkPolyData> triangulate::buildValidTriangulation(vtkSmartPointe
return triangleFilter->GetOutput();
}
#include <vtkSmartPointer.h>
#include <vtkPolyData.h>
#include <vtkCellArray.h>
#include <vtkIdList.h>
#include <vtkTriangle.h>
#include <vtkTetra.h>
#include <vtkCleanPolyData.h>
#include <vtkFeatureEdges.h>
vtkSmartPointer<vtkPolyData> operation::closeMesh(vtkSmartPointer<vtkPolyData> polyData)
{
// Check if the input mesh is open
vtkSmartPointer<vtkFeatureEdges> featureEdges = vtkSmartPointer<vtkFeatureEdges>::New();
featureEdges->SetInputData(polyData);
featureEdges->BoundaryEdgesOn();
featureEdges->NonManifoldEdgesOn();
featureEdges->FeatureEdgesOff();
featureEdges->Update();
vtkSmartPointer<vtkPolyData> output = featureEdges->GetOutput();
int numOpenEdges = output->GetNumberOfCells();
if (numOpenEdges != 0) {
std::cout << "There are " << numOpenEdges << " open edges.\n";
} else {
std::cout << "There are no open edges.\n";
}
}
/**
* @class triangulate
* @class operation_mesh
*
* @author Astrid BEYER
* @date 2023
* @version 1.1
* @version 1.0
*
*/
#ifndef TRIANGULATE_H
#define TRIANGULATE_H
#ifndef OPERATION_MESH_H
#define OPERATION_MESH_H
namespace triangulate
#include <vtkTriangleFilter.h>
namespace operation
{
/**
* @brief buildValidTriangulation : transforms, if necessary, input's polyData so it ensure it's triangulated
......@@ -18,6 +21,13 @@ namespace triangulate
* @returns vtkSmartPointer<vtkPolyData>
*/
vtkSmartPointer<vtkPolyData> buildValidTriangulation(vtkSmartPointer<vtkPolyData> polyData);
/**
* @brief closeMesh : close the surface of the mesh, if necessary
* @param polyData
* @returns vtkSmartPointer<vtkPolyData>
*/
vtkSmartPointer<vtkPolyData> closeMesh(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