diff --git a/FileIO/CMakeLists.txt b/FileIO/CMakeLists.txt index f3a8f9454feb2b0bbc5171d1ee30e91eab216a5d..9b5ea377b5d7c0eb1c58d1c0d16a9459cf99b009 100644 --- a/FileIO/CMakeLists.txt +++ b/FileIO/CMakeLists.txt @@ -24,7 +24,8 @@ SET( SOURCES GET_SOURCE_FILES(SOURCES_LEGACY Legacy) GET_SOURCE_FILES(SOURCES_GMSHIO GmshIO) GET_SOURCE_FILES(SOURCES_RAPID_XML RapidXmlIO) -SET ( SOURCES ${SOURCES} ${SOURCES_LEGACY} ${SOURCES_GMSHIO} ${SOURCES_RAPID_XML}) +GET_SOURCE_FILES(SOURCES_VTK VtkIO) +SET ( SOURCES ${SOURCES} ${SOURCES_LEGACY} ${SOURCES_GMSHIO} ${SOURCES_RAPID_XML} ${SOURCES_VTK}) GET_SOURCE_FILES(SOURCES_BASE_XML XmlIO) SET (SOURCES ${SOURCES} ${SOURCES_BASE_XML}) @@ -55,6 +56,10 @@ TARGET_LINK_LIBRARIES (FileIO shp ) +IF(TARGET CatalystRescan) + ADD_DEPENDENCIES(FileIO CatalystRescan) +ENDIF() + FILE(GLOB XSD_FILES . *.xsd) IF(APPLE) INSTALL(FILES ${XSD_FILES} DESTINATION ${CMAKE_BINARY_DIR}/_CPack_Packages/OSX/DragNDrop/${CPACK_PACKAGE_FILE_NAME}/DataExplorer.app/Contents/MacOS) diff --git a/FileIO/VtkIO/VtuInterface.cpp b/FileIO/VtkIO/VtuInterface.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4a71dbeae4b1132a9016498168a3d681d33cd864 --- /dev/null +++ b/FileIO/VtkIO/VtuInterface.cpp @@ -0,0 +1,43 @@ +/** + * \file + * \author Lars Bilke + * \date 2014-09-25 + * \brief Implementation of the BoostVtuInterface class. + * + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + */ + +#include "VtuInterface.h" + +#include "Mesh.h" + +#include <vtkXMLUnstructuredGridReader.h> +#include <vtkSmartPointer.h> + +namespace FileIO +{ + +VtuInterface::VtuInterface() : + _mesh(nullptr), _use_compressor(false) +{ +} + +VtuInterface::~VtuInterface() +{} + +MeshLib::Mesh* VtuInterface::readVTUFile(const std::string &file_name) +{ + vtkSmartPointer<vtkXMLUnstructuredGridReader> reader = + vtkXMLUnstructuredGridReader::New(); + + reader->SetFileName(file_name.c_str()); + reader->Update(); + + return nullptr; +} + +} diff --git a/FileIO/VtkIO/VtuInterface.h b/FileIO/VtkIO/VtuInterface.h new file mode 100644 index 0000000000000000000000000000000000000000..91ec860a32e23364b71a73a10d48a088b51d8884 --- /dev/null +++ b/FileIO/VtkIO/VtuInterface.h @@ -0,0 +1,53 @@ +/** + * \file + * \author Lars Bilke + * \date 2014-09-25 + * \brief Implementation of the VtuInterface class. + * + * \copyright + * Copyright (c) 2012-2014, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#ifndef BOOSTVTUINTERFACE_H_ +#define BOOSTVTUINTERFACE_H_ + +#include "Writer.h" + +#include <string> + +namespace MeshLib { + class Mesh; +} + +namespace FileIO +{ + +/** + * \brief Reads and writes VtkXMLUnstructuredGrid-files (vtu) to and from OGS data structures. + */ +class VtuInterface : public Writer +{ +public: + VtuInterface(); + ~VtuInterface(); + + /// Read an unstructured grid from a VTU file + static MeshLib::Mesh* readVTUFile(const std::string &file_name); + + /// Decide if the mesh data should be written compressed (default is false). + void setCompressData(bool flag=true) { _use_compressor = flag; }; + +private: + bool write(); + + MeshLib::Mesh* _mesh; + bool _use_compressor; +}; + +} + +#endif /* BOOSTVTUINTERFACE_H_ */