add the ability to analyze a mesh without fitting it
This commit is contained in:
parent
f67bc4c9d7
commit
44bd8f3b0a
37
src/main.cc
37
src/main.cc
@ -61,21 +61,39 @@ vtkAlgorithm *readerFromFileName(const char *fileName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void usage(char **argv) {
|
||||||
|
std::cerr << "Usage: " << argv[0] << " analyze|fit tetmesh polydata [radiusScale relaxationIterCount]" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
if (!(argc == 3 || argc == 5)) {
|
if (argc < 4) {
|
||||||
std::cerr << "Usage: " << argv[0] << " tetmesh polydata [radiusScale relaxationIterCount]" << std::endl;
|
usage(argv);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
bool fit = false;
|
||||||
|
if (std::string(argv[1]) == "fit") {
|
||||||
|
fit = true;
|
||||||
|
} else if (std::string(argv[1]) != "analyze") {
|
||||||
|
usage(argv);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
if ((fit && argc > 6) || (!fit && argc != 4)) {
|
||||||
|
usage(argv);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
double radiusScale = 2.;
|
double radiusScale = 2.;
|
||||||
int iterCount = 1;
|
int iterCount = 1;
|
||||||
if(argc > 3) {
|
if(argc > 4) {
|
||||||
radiusScale = std::stod(argv[3]);
|
radiusScale = std::stod(argv[3]);
|
||||||
|
}
|
||||||
|
if (argc > 5) {
|
||||||
iterCount = std::stoi(argv[4]);
|
iterCount = std::stoi(argv[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto tetMeshReader = readerFromFileName(argv[1]);
|
auto tetMeshReader = readerFromFileName(argv[2]);
|
||||||
auto polyMeshReader = readerFromFileName(argv[2]);
|
auto polyMeshReader = readerFromFileName(argv[3]);
|
||||||
|
|
||||||
vtkNew<RemoveExternalCellsFilter> removeExternalCellsFilter;
|
vtkNew<RemoveExternalCellsFilter> removeExternalCellsFilter;
|
||||||
removeExternalCellsFilter->SetInputConnection(0,
|
removeExternalCellsFilter->SetInputConnection(0,
|
||||||
@ -97,8 +115,13 @@ int main(int argc, char **argv) {
|
|||||||
relaxationFilter->SetInputConnection(project->GetOutputPort());
|
relaxationFilter->SetInputConnection(project->GetOutputPort());
|
||||||
|
|
||||||
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
||||||
|
if (fit) {
|
||||||
dihedralAnglesFilter->SetInputConnection(
|
dihedralAnglesFilter->SetInputConnection(
|
||||||
relaxationFilter->GetOutputPort());
|
relaxationFilter->GetOutputPort());
|
||||||
|
} else {
|
||||||
|
dihedralAnglesFilter->SetInputConnection(
|
||||||
|
tetMeshReader->GetOutputPort());
|
||||||
|
}
|
||||||
|
|
||||||
vtkNew<vtkGeometryFilter> geometryFilter;
|
vtkNew<vtkGeometryFilter> geometryFilter;
|
||||||
geometryFilter->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
geometryFilter->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
||||||
@ -107,11 +130,15 @@ int main(int argc, char **argv) {
|
|||||||
maxDistanceFilter->SetInputConnection(0, geometryFilter->GetOutputPort());
|
maxDistanceFilter->SetInputConnection(0, geometryFilter->GetOutputPort());
|
||||||
maxDistanceFilter->SetInputConnection(1, polyMeshReader->GetOutputPort());
|
maxDistanceFilter->SetInputConnection(1, polyMeshReader->GetOutputPort());
|
||||||
|
|
||||||
|
if (fit) {
|
||||||
vtkNew<vtkXMLUnstructuredGridWriter> writer;
|
vtkNew<vtkXMLUnstructuredGridWriter> writer;
|
||||||
writer->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
writer->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
||||||
writer->SetDataModeToAscii();
|
writer->SetDataModeToAscii();
|
||||||
writer->SetFileName("out.vtu");
|
writer->SetFileName("out.vtu");
|
||||||
writer->Write();
|
writer->Write();
|
||||||
|
} else {
|
||||||
|
dihedralAnglesFilter->Update();
|
||||||
|
}
|
||||||
|
|
||||||
maxDistanceFilter->Update();
|
maxDistanceFilter->Update();
|
||||||
std::cerr << "Max distance: " << maxDistanceFilter->GetMaxDist() << "\n"
|
std::cerr << "Max distance: " << maxDistanceFilter->GetMaxDist() << "\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user