add the ability to analyze a mesh without fitting it
This commit is contained in:
parent
f67bc4c9d7
commit
44bd8f3b0a
51
src/main.cc
51
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;
|
||||||
dihedralAnglesFilter->SetInputConnection(
|
if (fit) {
|
||||||
relaxationFilter->GetOutputPort());
|
dihedralAnglesFilter->SetInputConnection(
|
||||||
|
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());
|
||||||
|
|
||||||
vtkNew<vtkXMLUnstructuredGridWriter> writer;
|
if (fit) {
|
||||||
writer->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
vtkNew<vtkXMLUnstructuredGridWriter> writer;
|
||||||
writer->SetDataModeToAscii();
|
writer->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
||||||
writer->SetFileName("out.vtu");
|
writer->SetDataModeToAscii();
|
||||||
writer->Write();
|
writer->SetFileName("out.vtu");
|
||||||
|
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