126 lines
4.2 KiB
C++
126 lines
4.2 KiB
C++
#include "angles_filter.h"
|
|
#include "aspect_ratio_filter.h"
|
|
#include "dihedral_angles_filter.h"
|
|
#include "external_points_filter.h"
|
|
|
|
#include <vtkCellData.h>
|
|
#include <vtkUnstructuredGrid.h>
|
|
#include <vtkCamera.h>
|
|
#include <vtkNamedColors.h>
|
|
#include <vtkVolumeProperty.h>
|
|
#include <vtkRenderWindow.h>
|
|
#include <vtkRenderWindowInteractor.h>
|
|
#include <vtkRenderer.h>
|
|
#include <vtkVolumeMapper.h>
|
|
#include <vtkVolume.h>
|
|
#include <vtkOpenGLProjectedTetrahedraMapper.h>
|
|
#include <vtkUnstructuredGridReader.h>
|
|
#include <vtkUnstructuredGridWriter.h>
|
|
#include <vtkPiecewiseFunction.h>
|
|
|
|
#include <array>
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
if (argc != 2) {
|
|
std::cerr << "Usage: " << argv[0] << " FILE.vtk" << std::endl;
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
/* Reader */
|
|
vtkNew<vtkUnstructuredGridReader> reader;
|
|
reader->SetFileName(argv[1]);
|
|
|
|
|
|
/* Angles filter */
|
|
vtkNew<AnglesFilter> anglesFilter;
|
|
anglesFilter->SetInputConnection(reader->GetOutputPort());
|
|
|
|
/* Display angles in console. */
|
|
// anglesFilter->Update();
|
|
// vtkUnstructuredGrid *grid = anglesFilter->GetOutput();
|
|
// auto *angles = grid->GetCellData()->GetArray("angles");
|
|
// for (ssize_t i = 0; i < angles->GetNumberOfTuples(); i++) {
|
|
// std::cerr << "cell " << i << ": ";
|
|
// for (ssize_t j = 0; j < angles->GetNumberOfComponents(); j++) {
|
|
// std::cerr << angles->GetTuple(i)[j] << ", ";
|
|
// }
|
|
// std::cerr << "\b\b \n";
|
|
// }
|
|
|
|
/* Aspect ratio */
|
|
vtkNew<AspectRatioFilter> aspectRatioFilter;
|
|
aspectRatioFilter->SetInputConnection(anglesFilter->GetOutputPort());
|
|
|
|
/* Display aspect ratios in console. */
|
|
// aspectRatioFilter->Update();
|
|
// grid = aspectRatioFilter->GetOutput();
|
|
// auto *aspectRatios = grid->GetCellData()->GetArray("aspect_ratio");
|
|
// for (ssize_t i = 0; i < aspectRatios->GetNumberOfTuples(); i++) {
|
|
// std::cerr << "cell " << i << ": "
|
|
// << aspectRatios->GetTuple1(i) << "\n";
|
|
// }
|
|
|
|
/* Dihedral angles filter */
|
|
vtkNew<DihedralAnglesFilter> dihedralAnglesFilter;
|
|
dihedralAnglesFilter->SetInputConnection(aspectRatioFilter->GetOutputPort());
|
|
|
|
/* Display dihedral angles in console. */
|
|
// dihedralAnglesFilter->Update();
|
|
// grid = dihedralAnglesFilter->GetOutput();
|
|
// auto dihedralAngles = grid->GetCellData()->GetArray("dihedral_angles");
|
|
// for (vtkIdType i = 0; i < grid->GetNumberOfCells(); i++) {
|
|
// std::cerr << "dihedral angles ";
|
|
// for (vtkIdType j = 0; j < 6; j++) {
|
|
// std::cerr << dihedralAngles->GetTuple(i)[j] << ", ";
|
|
// }
|
|
// std::cerr << "\b\b\n";
|
|
// }
|
|
|
|
/* External faces filter. */
|
|
// vtkNew<vtkmExternalFaces> externalFacesFilter;
|
|
// externalFacesFilter->DebugOn();
|
|
// externalFacesFilter->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
|
|
|
/* External points filter. */
|
|
vtkNew<ExternalPointsFilter> externalPointsFilter;
|
|
externalPointsFilter->SetInputConnection(dihedralAnglesFilter->GetOutputPort());
|
|
|
|
vtkNew<vtkUnstructuredGridWriter> writer;
|
|
writer->SetInputConnection(externalPointsFilter->GetOutputPort());
|
|
writer->SetFileTypeToASCII();
|
|
writer->SetFileName("out.vtk");
|
|
writer->Write();
|
|
|
|
// /* Volume rendering properties */
|
|
// vtkNew<vtkOpenGLProjectedTetrahedraMapper> volumeMapper;
|
|
// volumeMapper->SetInputConnection(externalPointsFilter->GetOutputPort());
|
|
// vtkNew<vtkVolume> volume;
|
|
// volume->SetMapper(volumeMapper);
|
|
// vtkNew<vtkPiecewiseFunction> transferFunction;
|
|
// transferFunction->AddPoint(-1, 0);
|
|
// transferFunction->AddPoint(1, 1);
|
|
// volume->GetProperty()->SetScalarOpacity(transferFunction);
|
|
// volume->GetProperty()->SetColor(transferFunction);
|
|
|
|
// /* Renderer */
|
|
// vtkNew<vtkNamedColors> colors;
|
|
// std::array<unsigned char, 4> bkg{{26, 51, 102, 255}};
|
|
// colors->SetColor("BkgColor", bkg.data());
|
|
// vtkNew<vtkRenderer> renderer;
|
|
// renderer->AddVolume(volume);
|
|
// renderer->SetBackground(colors->GetColor3d("BkgColor").GetData());
|
|
// renderer->ResetCamera();
|
|
// renderer->GetActiveCamera()->Zoom(1.5);
|
|
// vtkNew<vtkRenderWindow> renderWindow;
|
|
// renderWindow->SetSize(300, 300);
|
|
// renderWindow->AddRenderer(renderer);
|
|
// renderWindow->SetWindowName("PFE");
|
|
// vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
|
|
// renderWindowInteractor->SetRenderWindow(renderWindow);
|
|
// renderWindow->Render();
|
|
// renderWindowInteractor->Start();
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|