support multiple file types and migrate the halfcow to xml

This commit is contained in:
papush! 2022-03-08 16:28:26 +01:00
parent 537764fce3
commit 9edb9a5385
5 changed files with 77244 additions and 182216 deletions

View File

@ -11,7 +11,8 @@ set(VTK_COMPONENTS
VTK::IOLegacy VTK::IOLegacy
VTK::IOGeometry VTK::IOGeometry
VTK::IOXML VTK::IOXML
VTK::FiltersModeling) VTK::FiltersModeling
VTK::vtksys)
set(ENABLE_VIEWER OFF CACHE BOOL "Enable the 3D viewer, depends on Qt.") set(ENABLE_VIEWER OFF CACHE BOOL "Enable the 3D viewer, depends on Qt.")
if(ENABLE_VIEWER) if(ENABLE_VIEWER)
list(APPEND VTK_COMPONENTS list(APPEND VTK_COMPONENTS

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +0,0 @@
# vtk DataFile Version 3.0
vtk output
ASCII
DATASET UNSTRUCTURED_GRID
POINTS 4 float
0 0 0
1 0 0
0 1 0
0 0 1
CELLS 1 5
4 0 1 2 3
CELL_TYPES 1
10
POINT_DATA 4
SCALARS Indication float
LOOKUP_TABLE default
1
1
1
1

77201
data/half_cow.vtu Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,54 +1,73 @@
#include "angles_filter.h"
#include "aspect_ratio_filter.h"
#include "dihedral_angles_filter.h" #include "dihedral_angles_filter.h"
#include "remove_external_cells_filter.h"
#include "surface_points_filter.h" #include "surface_points_filter.h"
#include "project_surface_points_on_poly.h" #include "project_surface_points_on_poly.h"
#include "mesh_fit_filter.h"
#include "point_tris_dist.h"
#include "remove_external_cells_filter.h"
#include <vtkCellArrayIterator.h>
#include <vtkCellData.h> #include <vtkCellData.h>
#include <vtkDataSetReader.h>
#include <vtkOBJReader.h>
#include <vtkPolyData.h>
#include <vtkPolyDataReader.h>
#include <vtkUnstructuredGrid.h> #include <vtkUnstructuredGrid.h>
#include <vtkUnstructuredGridReader.h> #include <vtkUnstructuredGridReader.h>
#include <vtkXMLUnstructuredGridWriter.h>
#include <vtkPolyData.h>
#include <vtkCellArrayIterator.h>
#include <vtkXMLPolyDataReader.h> #include <vtkXMLPolyDataReader.h>
#include <vtkOBJReader.h> #include <vtkXMLUnstructuredGridReader.h>
#include <vtkXMLUnstructuredGridWriter.h>
#include <vtksys/SystemTools.hxx>
#ifdef USE_VIEWER #ifdef USE_VIEWER
#include <vtkNamedColors.h>
#include <vtkCamera.h> #include <vtkCamera.h>
#include <vtkVolumeProperty.h> #include <vtkNamedColors.h>
#include <vtkOpenGLProjectedTetrahedraMapper.h>
#include <vtkPiecewiseFunction.h>
#include <vtkRenderWindow.h> #include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h> #include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h> #include <vtkRenderer.h>
#include <vtkVolumeMapper.h>
#include <vtkVolume.h> #include <vtkVolume.h>
#include <vtkOpenGLProjectedTetrahedraMapper.h> #include <vtkVolumeMapper.h>
#include <vtkPiecewiseFunction.h> #include <vtkVolumeProperty.h>
#endif #endif // USE_VIEWER
#include <array> #include <array>
vtkSmartPointer<vtkAlgorithm> readerFromFileName(const char *fileName) {
std::string extension =
vtksys::SystemTools::GetFilenameLastExtension(fileName);
if (extension == ".vtk") {
auto reader = vtkDataSetReader::New();
reader->SetFileName(fileName);
return {reader};
} else if (extension == ".vtu") {
auto reader = vtkXMLUnstructuredGridReader::New();
reader->SetFileName(fileName);
return {reader};
} else if (extension == ".vtp") {
auto reader = vtkXMLPolyDataReader::New();
reader->SetFileName(fileName);
return {reader};
} else if (extension == ".obj") {
auto reader = vtkOBJReader::New();
reader->SetFileName(fileName);
return {reader};
}
throw std::runtime_error("Invalid file extension.");
}
int main(int argc, char **argv) { int main(int argc, char **argv) {
if (argc != 3) { if (argc != 3) {
std::cerr << "Usage: " << argv[0] << " tetmesh polydata" << std::endl; std::cerr << "Usage: " << argv[0] << " tetmesh polydata" << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
vtkNew<vtkUnstructuredGridReader> tetMeshReader; auto tetMeshReader = readerFromFileName(argv[1]);
tetMeshReader->SetFileName(argv[1]); auto polyMeshReader = readerFromFileName(argv[2]);
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter; vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
dihedralAnglesFilter->SetInputConnection(tetMeshReader->GetOutputPort()); dihedralAnglesFilter->SetInputConnection(tetMeshReader->GetOutputPort());
// vtkNew<vtkXMLPolyDataReader> polyMeshReader;
// polyMeshReader->SetFileName(argv[2]);
vtkNew<vtkOBJReader> polyMeshReader;
polyMeshReader->SetFileName(argv[2]);
vtkNew<RemoveExternalCellsFilter> removeExternalCellsFilter; vtkNew<RemoveExternalCellsFilter> removeExternalCellsFilter;
removeExternalCellsFilter->SetInputConnection(0, removeExternalCellsFilter->SetInputConnection(0,
dihedralAnglesFilter->GetOutputPort()); dihedralAnglesFilter->GetOutputPort());