diff --git a/src/Cxx.md b/src/Cxx.md index d5d7c18b72e3fbfd46faef389b854a1e2f69a133..051285ca157b16ff50cd722a788d3da3d200b13d 100644 --- a/src/Cxx.md +++ b/src/Cxx.md @@ -563,7 +563,8 @@ This section includes vtkImageData vtkStructuredGrid and vtkRectilinearGrid. [Delaunay2D](/Cxx/Filtering/Delaunay2D) | vtkDelaunay2D | Perform a 2D Delaunay triangulation on a point set. [DetermineActorType](/Cxx/Utilities/DetermineActorType) | vtkActor vtkActorCollection |Determine the type of an actor. [DiscretizableColorTransferFunction](/Cxx/Utilities/DiscretizableColorTransferFunction) | vtkDiscretizableColorTransferFunction |Discretizable Color Transfer Function. -[FileOutputWindow](/Cxx/Utilities/FileOutputWindow) | vtkFileOutputWindow | Write errors to a log file instead of the screen. +[ExtractFaces](/Cxx/Utilities/ExtractFaces) | vtkCellIterator | Extract faces from vtkUnstructuredGrid. +[FileOutputWindow](/Cxx/Utilities/FileOutputWindow) | vtkFileOutputWindow | Write errors to a log file instead of the screen. [FilenameFunctions](/Cxx/Utilities/FilenameFunctions) | vtkDirectory vtksys/SystemTools | Do things like get the file extension, strip the file extension, etc. [FilterSelfProgress](/Cxx/Developers/FilterSelfProgress) | |Monitor a filters progress. [FrameRate](/Cxx/Utilities/FrameRate) | | Get the frame rate of the rendering. diff --git a/src/Cxx/Utilities/CMakeLists.txt b/src/Cxx/Utilities/CMakeLists.txt index 0a40a5613aa03ea87c840fa4c0ddb8c41f202b3c..e5303d4558328ae20473b31ec449daab91d54655 100644 --- a/src/Cxx/Utilities/CMakeLists.txt +++ b/src/Cxx/Utilities/CMakeLists.txt @@ -34,6 +34,7 @@ if (BUILD_TESTING) # Testing set(KIT Utilities) set(NEEDS_ARGS + ExtractFaces SaveSceneToFieldData SaveSceneToFile ViewportBorders @@ -42,6 +43,9 @@ set(NEEDS_ARGS set(DATA ${WikiExamples_SOURCE_DIR}/src/Testing/Data) set(TEMP ${WikiExamples_BINARY_DIR}/Testing/Temporary) +add_test(${KIT}-ExtractFaces ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KIT}CxxTests + TestExtractFaces ${DATA}/Hexahedron.vtu ${DATA}/QuadraticPyramid.vtu ${DATA}/QuadraticTetra.vtu ${DATA}/QuadraticWedge.vtu ${DATA}/Tetra.vtu ${DATA}/TriQuadraticHexahedron.vtu ${DATA}/Triangle.vtu ${DATA}/Wedge.vtu) + add_test(${KIT}-SaveSceneToFile ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KIT}CxxTests TestSaveSceneToFile ${DATA}/Armadillo.ply ${TEMP}/Armadillo.txt) diff --git a/src/Cxx/Utilities/ExtractFaces.cxx b/src/Cxx/Utilities/ExtractFaces.cxx new file mode 100644 index 0000000000000000000000000000000000000000..a5d745c0555d29efaa88203089fded6d8036f995 --- /dev/null +++ b/src/Cxx/Utilities/ExtractFaces.cxx @@ -0,0 +1,47 @@ +#include <vtkSmartPointer.h> +#include <vtkCellIterator.h> +#include <vtkGenericDataSet.h> +#include <vtkGenericCell.h> +#include <vtkXMLGenericDataObjectReader.h> +#include <vtkPointSet.h> +#include <vtkCellTypes.h> + +#include <map> + +int main (int argc, char *argv[]) +{ + std::map<std::string, int> cellMap; + + for (int arg = 1; arg < argc; ++arg) + { + vtkSmartPointer<vtkXMLGenericDataObjectReader> reader = + vtkSmartPointer<vtkXMLGenericDataObjectReader>::New(); + reader->SetFileName(argv[arg]); + reader->Update(); + + vtkPointSet *pointSet = vtkPointSet::SafeDownCast(reader->GetOutput()); + vtkCellIterator *it = pointSet->NewCellIterator(); + for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextCell()) + { + vtkSmartPointer<vtkGenericCell> cell = + vtkSmartPointer<vtkGenericCell>::New(); + it->GetCell(cell); + std::string cellName = vtkCellTypes::GetClassNameFromTypeId(cell->GetCellType()); + if (cellMap.count(cellName) == 0) + { + int numFaces = cell->GetNumberOfFaces(); + std::cout << "Type: " << cellName + << " has " << cell->GetNumberOfFaces() << " faces" << std::endl; + } + cellMap[cellName]++; + } +} + std::map <std::string, int>::iterator itm = cellMap.begin(); + + for (itm = cellMap.begin(); itm != cellMap.end(); ++itm) + { + std::cout << itm->first << " occurs " << itm->second << " times" << std::endl; + } + + return EXIT_SUCCESS; +}