diff --git a/CMakeLists.txt b/CMakeLists.txt index 4459f06610f2daa724c9e12b0f8fcbab60619ce0..5d9e912f2e76e0c7a58b583df326a7c5b5207545 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,6 +152,7 @@ IF(TARGET Boost) ENDIF() ADD_SUBDIRECTORY( FileIO ) ADD_SUBDIRECTORY( GeoLib ) +ADD_SUBDIRECTORY( InSituLib ) ADD_SUBDIRECTORY( MathLib ) ADD_SUBDIRECTORY( MeshLib ) ADD_SUBDIRECTORY( MeshGeoToolsLib ) diff --git a/InSituLib/CMakeLists.txt b/InSituLib/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..5a8874f6ba341059f3e8820ae4c13be3d3ddf334 --- /dev/null +++ b/InSituLib/CMakeLists.txt @@ -0,0 +1,5 @@ +#ADD_LIBRARY(InSituLib +# VtkMeshNodalCoordinatesTemplate.txx +#) + +#ADD_DEPENDENCIES(InSituLib STATIC VtkRescan) diff --git a/InSituLib/VtkMeshNodalCoordinatesTemplate.h b/InSituLib/VtkMeshNodalCoordinatesTemplate.h new file mode 100644 index 0000000000000000000000000000000000000000..cb0edd32b0572a8cc4e6b154e0f2b5e0a5df9cb4 --- /dev/null +++ b/InSituLib/VtkMeshNodalCoordinatesTemplate.h @@ -0,0 +1,38 @@ +/** + * \file + * \author Lars Bilke + * \date 2014-02-26 + * \brief Definition of the ElementStatus class. + * + * \copyright + * Copyright (c) 2013, 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 VTKMESHNODALCOORDINATES_H_ +#define VTKMESHNODALCOORDINATES_H_ + +#include <vtkMappedDataArray.h> +#include <vtkTypeTemplate.h> // For templated vtkObject API +#include <vtkObjectFactory.h> // for vtkStandardNewMacro + +template <class Scalar> +class VtkMeshNodalCoordinatesTemplate: + public vtkTypeTemplate<VtkMeshNodalCoordinatesTemplate<Scalar>, + vtkMappedDataArray<Scalar> > +{ +public: + vtkMappedDataArrayNewInstanceMacro( + VtkMeshNodalCoordinatesTemplate<Scalar>) + static VtkMeshNodalCoordinatesTemplate *New(); + virtual void PrintSelf(ostream &os, vtkIndent indent); + + void SetNodes(std::vector<MeshLib::Node*> const & nodes); +}; + +#include "VtkMeshNodalCoordinatesTemplate.txx" + +#endif // VTKMESHNODALCOORDINATES_H_ diff --git a/InSituLib/VtkMeshNodalCoordinatesTemplate.txx b/InSituLib/VtkMeshNodalCoordinatesTemplate.txx new file mode 100644 index 0000000000000000000000000000000000000000..5cfe641d26d92288604f4c76c0c993f059175154 --- /dev/null +++ b/InSituLib/VtkMeshNodalCoordinatesTemplate.txx @@ -0,0 +1,41 @@ +/** + * \file + * \author Lars Bilke + * \date 2014-02-26 + * \brief Definition of the ElementStatus class. + * + * \copyright + * Copyright (c) 2013, 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 "VtkMeshNodalCoordinatesTemplate.h" + +#include <vtkIdList.h> +#include <vtkObjectFactory.h> +#include <vtkVariant.h> +#include <vtkVariantCast.h> + +//------------------------------------------------------------------------------ +// Can't use vtkStandardNewMacro with a template. +template <class Scalar> VtkMeshNodalCoordinatesTemplate<Scalar> * +VtkMeshNodalCoordinatesTemplate<Scalar>::New() +{ + VTK_STANDARD_NEW_BODY(VtkMeshNodalCoordinatesTemplate<Scalar>) +} + +//------------------------------------------------------------------------------ +template <class Scalar> void VtkMeshNodalCoordinatesTemplate<Scalar> +::PrintSelf(ostream &os, vtkIndent indent) +{ + this->VtkMeshNodalCoordinatesTemplate<Scalar>::Superclass::PrintSelf( + os, indent); + os << indent << "Blub" << std::endl; + //os << indent << "XArray: " << this->XArray << std::endl; + //os << indent << "YArray: " << this->YArray << std::endl; + //os << indent << "ZArray: " << this->ZArray << std::endl; + //os << indent << "TempDoubleArray: " << this->TempDoubleArray << std::endl; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index c398d1ec773ac9f7cf49f8cd21fa79b5f838fe8c..f161aae06aa8076d7b3104ff8a026e42190197f3 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -16,6 +16,11 @@ IF (QT4_FOUND) APPEND_SOURCE_FILES(TEST_SOURCES FileIO) ENDIF() +IF (OGS_BUILD_GUI) + APPEND_SOURCE_FILES(TEST_SOURCES InSituLib) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/InSituLib) +ENDIF() + INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/AssemblerLib ${CMAKE_SOURCE_DIR}/BaseLib diff --git a/Tests/InSituLib/TestVtkMeshNodalCoordinatesTemplate.cpp b/Tests/InSituLib/TestVtkMeshNodalCoordinatesTemplate.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8f3254525ab5c3141b8ddd154f957943290187d4 --- /dev/null +++ b/Tests/InSituLib/TestVtkMeshNodalCoordinatesTemplate.cpp @@ -0,0 +1,32 @@ +/** + * \file + * \author Lars Bilke + * \date 2014-02-26 + * \brief Unit tests for In-Situ mesh nodes + * + * \copyright + * Copyright (c) 2013, 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 <vtkNew.h> + +#include "gtest/gtest.h" + +#include "Mesh.h" +#include "MeshGenerators/MeshGenerator.h" + +#include "VtkMeshNodalCoordinatesTemplate.h" + +TEST(InSituLibNodalCoordinates, Init) +{ + MeshLib::Mesh* mesh = MeshLib::MeshGenerator::generateRegularQuadMesh(10.0, 99); + + vtkNew<VtkMeshNodalCoordinatesTemplate<double> > nodeCoords; + nodeCoords->SetNodes(mesh->getNodes()); + nodeCoords->PrintSelf(std::cout, vtkIndent()); + + delete mesh; +}