support multiple file types and migrate the halfcow to xml
This commit is contained in:
parent
537764fce3
commit
9edb9a5385
@ -11,7 +11,8 @@ set(VTK_COMPONENTS
|
||||
VTK::IOLegacy
|
||||
VTK::IOGeometry
|
||||
VTK::IOXML
|
||||
VTK::FiltersModeling)
|
||||
VTK::FiltersModeling
|
||||
VTK::vtksys)
|
||||
set(ENABLE_VIEWER OFF CACHE BOOL "Enable the 3D viewer, depends on Qt.")
|
||||
if(ENABLE_VIEWER)
|
||||
list(APPEND VTK_COMPONENTS
|
||||
|
182173
data/TetMesh.vtk
182173
data/TetMesh.vtk
File diff suppressed because it is too large
Load Diff
@ -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
77201
data/half_cow.vtu
Normal file
File diff suppressed because it is too large
Load Diff
63
src/main.cc
63
src/main.cc
@ -1,54 +1,73 @@
|
||||
#include "angles_filter.h"
|
||||
#include "aspect_ratio_filter.h"
|
||||
#include "dihedral_angles_filter.h"
|
||||
#include "remove_external_cells_filter.h"
|
||||
#include "surface_points_filter.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 <vtkDataSetReader.h>
|
||||
#include <vtkOBJReader.h>
|
||||
#include <vtkPolyData.h>
|
||||
#include <vtkPolyDataReader.h>
|
||||
#include <vtkUnstructuredGrid.h>
|
||||
#include <vtkUnstructuredGridReader.h>
|
||||
#include <vtkXMLUnstructuredGridWriter.h>
|
||||
#include <vtkPolyData.h>
|
||||
#include <vtkCellArrayIterator.h>
|
||||
#include <vtkXMLPolyDataReader.h>
|
||||
#include <vtkOBJReader.h>
|
||||
#include <vtkXMLUnstructuredGridReader.h>
|
||||
#include <vtkXMLUnstructuredGridWriter.h>
|
||||
#include <vtksys/SystemTools.hxx>
|
||||
|
||||
#ifdef USE_VIEWER
|
||||
#include <vtkNamedColors.h>
|
||||
#include <vtkCamera.h>
|
||||
#include <vtkVolumeProperty.h>
|
||||
#include <vtkNamedColors.h>
|
||||
#include <vtkOpenGLProjectedTetrahedraMapper.h>
|
||||
#include <vtkPiecewiseFunction.h>
|
||||
#include <vtkRenderWindow.h>
|
||||
#include <vtkRenderWindowInteractor.h>
|
||||
#include <vtkRenderer.h>
|
||||
#include <vtkVolumeMapper.h>
|
||||
#include <vtkVolume.h>
|
||||
#include <vtkOpenGLProjectedTetrahedraMapper.h>
|
||||
#include <vtkPiecewiseFunction.h>
|
||||
#endif
|
||||
#include <vtkVolumeMapper.h>
|
||||
#include <vtkVolumeProperty.h>
|
||||
#endif // USE_VIEWER
|
||||
|
||||
#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) {
|
||||
if (argc != 3) {
|
||||
std::cerr << "Usage: " << argv[0] << " tetmesh polydata" << std::endl;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
vtkNew<vtkUnstructuredGridReader> tetMeshReader;
|
||||
tetMeshReader->SetFileName(argv[1]);
|
||||
auto tetMeshReader = readerFromFileName(argv[1]);
|
||||
auto polyMeshReader = readerFromFileName(argv[2]);
|
||||
|
||||
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
||||
dihedralAnglesFilter->SetInputConnection(tetMeshReader->GetOutputPort());
|
||||
|
||||
// vtkNew<vtkXMLPolyDataReader> polyMeshReader;
|
||||
// polyMeshReader->SetFileName(argv[2]);
|
||||
vtkNew<vtkOBJReader> polyMeshReader;
|
||||
polyMeshReader->SetFileName(argv[2]);
|
||||
|
||||
vtkNew<RemoveExternalCellsFilter> removeExternalCellsFilter;
|
||||
removeExternalCellsFilter->SetInputConnection(0,
|
||||
dihedralAnglesFilter->GetOutputPort());
|
||||
|
Loading…
Reference in New Issue
Block a user