improve dihedral angles filter

This commit is contained in:
papush! 2022-03-10 16:49:49 +01:00
parent f8e26b4890
commit e789941169
2 changed files with 17 additions and 5 deletions

View File

@ -24,11 +24,18 @@ vtkTypeBool DihedralAnglesFilter::RequestData(
output->GetPointData()->PassData(input->GetPointData());
vtkCellData *cellData = output->GetCellData();
cellData->PassData(input->GetCellData());
vtkNew<vtkDoubleArray> dihedralAnglesArray;
dihedralAnglesArray->SetName("dihedral_angles");
dihedralAnglesArray->SetNumberOfComponents(6);
dihedralAnglesArray->SetNumberOfTuples(input->GetNumberOfCells());
double *dihedralAnglesBase = dihedralAnglesArray->GetPointer(0);
vtkNew<vtkDoubleArray> minDihedralAngleArray;
minDihedralAngleArray->SetName("min_dihedral_angle");
minDihedralAngleArray->SetNumberOfTuples(input->GetNumberOfCells());
double *minDihedralAngleBase = minDihedralAngleArray->GetPointer(0);
size_t i = 0;
vtkCellIterator *it = input->NewCellIterator();
for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextCell()) {
@ -52,8 +59,13 @@ vtkTypeBool DihedralAnglesFilter::RequestData(
dihedralAnglesBase[i+4] = vtkMath::AngleBetweenVectors(nbdc, nadc);
dihedralAnglesBase[i+5] = vtkMath::AngleBetweenVectors(nbdc, nabd);
minDihedralAngleBase[i / 6] =
*std::min_element(dihedralAnglesBase + i,
dihedralAnglesBase + i + 6);
i += 6;
}
cellData->AddArray((vtkAbstractArray *) dihedralAnglesArray);
cellData->AddArray((vtkAbstractArray *) minDihedralAngleArray);
return true;
}

View File

@ -65,12 +65,9 @@ int main(int argc, char **argv) {
auto tetMeshReader = readerFromFileName(argv[1]);
auto polyMeshReader = readerFromFileName(argv[2]);
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
dihedralAnglesFilter->SetInputConnection(tetMeshReader->GetOutputPort());
vtkNew<RemoveExternalCellsFilter> removeExternalCellsFilter;
removeExternalCellsFilter->SetInputConnection(0,
dihedralAnglesFilter->GetOutputPort());
tetMeshReader->GetOutputPort());
removeExternalCellsFilter->SetInputConnection(1,
polyMeshReader->GetOutputPort());
@ -82,8 +79,11 @@ int main(int argc, char **argv) {
project->SetInputConnection(0, surfacePointsFilter->GetOutputPort());
project->SetInputConnection(1, polyMeshReader->GetOutputPort());
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
dihedralAnglesFilter->SetInputConnection(project->GetOutputPort());
vtkNew<vtkXMLUnstructuredGridWriter> writer;
writer->SetInputConnection(project->GetOutputPort());
writer->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
writer->SetDataModeToAscii();
writer->SetFileName("out.vtu");
writer->Write();