improve dihedral angles filter
This commit is contained in:
parent
f8e26b4890
commit
e789941169
@ -24,11 +24,18 @@ vtkTypeBool DihedralAnglesFilter::RequestData(
|
|||||||
output->GetPointData()->PassData(input->GetPointData());
|
output->GetPointData()->PassData(input->GetPointData());
|
||||||
vtkCellData *cellData = output->GetCellData();
|
vtkCellData *cellData = output->GetCellData();
|
||||||
cellData->PassData(input->GetCellData());
|
cellData->PassData(input->GetCellData());
|
||||||
|
|
||||||
vtkNew<vtkDoubleArray> dihedralAnglesArray;
|
vtkNew<vtkDoubleArray> dihedralAnglesArray;
|
||||||
dihedralAnglesArray->SetName("dihedral_angles");
|
dihedralAnglesArray->SetName("dihedral_angles");
|
||||||
dihedralAnglesArray->SetNumberOfComponents(6);
|
dihedralAnglesArray->SetNumberOfComponents(6);
|
||||||
dihedralAnglesArray->SetNumberOfTuples(input->GetNumberOfCells());
|
dihedralAnglesArray->SetNumberOfTuples(input->GetNumberOfCells());
|
||||||
double *dihedralAnglesBase = dihedralAnglesArray->GetPointer(0);
|
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;
|
size_t i = 0;
|
||||||
vtkCellIterator *it = input->NewCellIterator();
|
vtkCellIterator *it = input->NewCellIterator();
|
||||||
for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextCell()) {
|
for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextCell()) {
|
||||||
@ -52,8 +59,13 @@ vtkTypeBool DihedralAnglesFilter::RequestData(
|
|||||||
dihedralAnglesBase[i+4] = vtkMath::AngleBetweenVectors(nbdc, nadc);
|
dihedralAnglesBase[i+4] = vtkMath::AngleBetweenVectors(nbdc, nadc);
|
||||||
dihedralAnglesBase[i+5] = vtkMath::AngleBetweenVectors(nbdc, nabd);
|
dihedralAnglesBase[i+5] = vtkMath::AngleBetweenVectors(nbdc, nabd);
|
||||||
|
|
||||||
|
minDihedralAngleBase[i / 6] =
|
||||||
|
*std::min_element(dihedralAnglesBase + i,
|
||||||
|
dihedralAnglesBase + i + 6);
|
||||||
|
|
||||||
i += 6;
|
i += 6;
|
||||||
}
|
}
|
||||||
cellData->AddArray((vtkAbstractArray *) dihedralAnglesArray);
|
cellData->AddArray((vtkAbstractArray *) dihedralAnglesArray);
|
||||||
|
cellData->AddArray((vtkAbstractArray *) minDihedralAngleArray);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
10
src/main.cc
10
src/main.cc
@ -65,12 +65,9 @@ int main(int argc, char **argv) {
|
|||||||
auto tetMeshReader = readerFromFileName(argv[1]);
|
auto tetMeshReader = readerFromFileName(argv[1]);
|
||||||
auto polyMeshReader = readerFromFileName(argv[2]);
|
auto polyMeshReader = readerFromFileName(argv[2]);
|
||||||
|
|
||||||
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
|
||||||
dihedralAnglesFilter->SetInputConnection(tetMeshReader->GetOutputPort());
|
|
||||||
|
|
||||||
vtkNew<RemoveExternalCellsFilter> removeExternalCellsFilter;
|
vtkNew<RemoveExternalCellsFilter> removeExternalCellsFilter;
|
||||||
removeExternalCellsFilter->SetInputConnection(0,
|
removeExternalCellsFilter->SetInputConnection(0,
|
||||||
dihedralAnglesFilter->GetOutputPort());
|
tetMeshReader->GetOutputPort());
|
||||||
removeExternalCellsFilter->SetInputConnection(1,
|
removeExternalCellsFilter->SetInputConnection(1,
|
||||||
polyMeshReader->GetOutputPort());
|
polyMeshReader->GetOutputPort());
|
||||||
|
|
||||||
@ -82,8 +79,11 @@ int main(int argc, char **argv) {
|
|||||||
project->SetInputConnection(0, surfacePointsFilter->GetOutputPort());
|
project->SetInputConnection(0, surfacePointsFilter->GetOutputPort());
|
||||||
project->SetInputConnection(1, polyMeshReader->GetOutputPort());
|
project->SetInputConnection(1, polyMeshReader->GetOutputPort());
|
||||||
|
|
||||||
|
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
||||||
|
dihedralAnglesFilter->SetInputConnection(project->GetOutputPort());
|
||||||
|
|
||||||
vtkNew<vtkXMLUnstructuredGridWriter> writer;
|
vtkNew<vtkXMLUnstructuredGridWriter> writer;
|
||||||
writer->SetInputConnection(project->GetOutputPort());
|
writer->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
||||||
writer->SetDataModeToAscii();
|
writer->SetDataModeToAscii();
|
||||||
writer->SetFileName("out.vtu");
|
writer->SetFileName("out.vtu");
|
||||||
writer->Write();
|
writer->Write();
|
||||||
|
Loading…
Reference in New Issue
Block a user