From c894cf352e40a0453c9d965086384267f79a61a1 Mon Sep 17 00:00:00 2001 From: Christian Grefe <Christian.Grefe@cern.ch> Date: Fri, 7 Mar 2014 18:47:39 +0000 Subject: [PATCH] DDSurfaces now builds with cmake --- DDSurfaces/CMakeLists.txt | 48 +++++++++++++++++++ DDSurfaces/include/DDSurfaces/DiskSurface.h | 10 ++-- DDSurfaces/include/DDSurfaces/ISurface.h | 10 ++-- DDSurfaces/include/DDSurfaces/Material.h | 2 +- DDSurfaces/include/DDSurfaces/Measurement.h | 2 +- .../include/DDSurfaces/StraightLineSurface.h | 10 ++-- DDSurfaces/include/DDSurfaces/Vector3D.h | 2 +- .../include/DDSurfaces/ZCylinderSurface.h | 10 ++-- .../include/DDSurfaces/ZPlanarSurface.h | 10 ++-- DDSurfaces/src/DiskSurface.cpp | 2 +- DDSurfaces/src/StraightLineSurface.cpp | 2 +- DDSurfaces/src/ZCylinderSurface.cpp | 2 +- DDSurfaces/src/ZPlanarSurface.cpp | 2 +- 13 files changed, 84 insertions(+), 28 deletions(-) create mode 100644 DDSurfaces/CMakeLists.txt diff --git a/DDSurfaces/CMakeLists.txt b/DDSurfaces/CMakeLists.txt new file mode 100644 index 000000000..967d57672 --- /dev/null +++ b/DDSurfaces/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR) + +#--------------------------- +set( PackageName DDSurfaces ) +#--------------------------- + +project(${PackageName}) + +# project version +SET( DDSurfaces_VERSION_MAJOR 0 ) +SET( DDSurfaces_VERSION_MINOR 1 ) +SET( DDSurfaces_VERSION_PATCH 0 ) + +SET( DDSurfaces_VERSION "${DDSurfaces_VERSION_MAJOR}.${DDSurfaces_VERSION_MINOR}" ) +SET( DDSurfaces_SOVERSION "${DDSurfaces_VERSION_MAJOR}.${DDSurfaces_VERSION_MINOR}" ) + +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake ) +set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) +set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin) + +IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + SET( CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR} CACHE PATH + "install prefix path - overwrite with -D CMAKE_INSTALL_PREFIX = ..." + FORCE ) + MESSAGE(STATUS "CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX} - overwrite with -D CMAKE_INSTALL_PREFIX" ) +ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) + +file(GLOB sources src/*.cpp) + +add_library(${PackageName} SHARED ${sources} ) + +SET(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -Wno-long-long") +SET_TARGET_PROPERTIES( ${PackageName} PROPERTIES VERSION ${DDSurfaces_VERSION} SOVERSION ${DDSurfaces_SOVERSION}) + +#--- install target------------------------------------- +install(DIRECTORY include/${PackageName} + DESTINATION include + PATTERN ".svn" EXCLUDE ) + +install(TARGETS ${PackageName} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib +) + +# to do: add corresponding uninstall... +#------------------------------------------------------- diff --git a/DDSurfaces/include/DDSurfaces/DiskSurface.h b/DDSurfaces/include/DDSurfaces/DiskSurface.h index 477ebd7e5..0d4afec36 100644 --- a/DDSurfaces/include/DDSurfaces/DiskSurface.h +++ b/DDSurfaces/include/DDSurfaces/DiskSurface.h @@ -12,7 +12,9 @@ namespace DDSurfaces { -class DiskBoundary; +struct DiskBoundary { + ; +}; class DiskSurface: public ISurface { public: @@ -23,13 +25,13 @@ public: virtual ~DiskSurface(); /// Checks if the given point lies within the surface - bool isInsideBoundaries(const Vector3D& point) const; + virtual bool isInsideBoundaries(const Vector3D& point) const; /// Access to the normal direction at the given point - Vector3D getNormal(const Vector3D& point) const; + virtual Vector3D getNormal(const Vector3D& point) const; /// Access to the measurement directions at the given point - Measurement measurement(const Vector3D& point) const; + virtual Measurement measurement(const Vector3D& point) const; protected: DiskBoundary m_boundary; diff --git a/DDSurfaces/include/DDSurfaces/ISurface.h b/DDSurfaces/include/DDSurfaces/ISurface.h index 7d907a6d7..f1ca8ce27 100644 --- a/DDSurfaces/include/DDSurfaces/ISurface.h +++ b/DDSurfaces/include/DDSurfaces/ISurface.h @@ -25,18 +25,18 @@ public: } /// Checks if the surface has measurement directions - bool hasMeasurement() const { + virtual bool hasMeasurement() const { return m_measurement != 0; } /// Checks if the given point lies within the surface - bool isInsideBoundaries(const Vector3D& point) const = 0; + virtual bool isInsideBoundaries(const Vector3D& point) const = 0; /// Access to the normal direction at the given point - Vector3D getNormal(const Vector3D& point) const = 0; + virtual Vector3D getNormal(const Vector3D& point) const = 0; /// Access to the measurement directions at the given point - Measurement measurement(const Vector3D& point) const = 0; + virtual Measurement measurement(const Vector3D& point) const = 0; /// Access to the material in opposite direction of the normal const Material& innerMaterial() const { @@ -65,7 +65,7 @@ public: protected: /// Constructor which can be used by derived classes - ISurface(const Material& innerMaterial=Material(), const Material& outerMaterial=Material()) : + ISurface(const Material& innerMaterial = Material(), const Material& outerMaterial = Material()) : m_innerMaterial(innerMaterial), m_outerMaterial(outerMaterial), m_measurement(0) { } diff --git a/DDSurfaces/include/DDSurfaces/Material.h b/DDSurfaces/include/DDSurfaces/Material.h index ccb00970c..69da03667 100644 --- a/DDSurfaces/include/DDSurfaces/Material.h +++ b/DDSurfaces/include/DDSurfaces/Material.h @@ -14,7 +14,7 @@ namespace DDSurfaces { class Material { public: /// Default constructor - Material(int Z=0, int A=0, double density=0., double radiationLength = 0.) : + Material(int Z = 0, int A = 0, double density = 0., double radiationLength = 0.) : m_Z(Z), m_A(A), m_density(density), m_radiationLength( radiationLength) { } diff --git a/DDSurfaces/include/DDSurfaces/Measurement.h b/DDSurfaces/include/DDSurfaces/Measurement.h index 661053461..4e010babe 100644 --- a/DDSurfaces/include/DDSurfaces/Measurement.h +++ b/DDSurfaces/include/DDSurfaces/Measurement.h @@ -16,7 +16,7 @@ namespace DDSurfaces { class Measurement { public: /// Default constructor - Measurement(const Vector3D& u, const Vector3D& v) : + Measurement(const Vector3D& u = Vector3D(), const Vector3D& v = Vector3D()) : m_u(u), m_v(v) { } diff --git a/DDSurfaces/include/DDSurfaces/StraightLineSurface.h b/DDSurfaces/include/DDSurfaces/StraightLineSurface.h index df96a5baa..48468db90 100644 --- a/DDSurfaces/include/DDSurfaces/StraightLineSurface.h +++ b/DDSurfaces/include/DDSurfaces/StraightLineSurface.h @@ -12,7 +12,9 @@ namespace DDSurfaces { -class StraightLineBoundary; +struct StraightLineBoundary { + ; +}; class StraightLineSurface: public ISurface { public: @@ -23,13 +25,13 @@ public: virtual ~StraightLineSurface(); /// Checks if the given point lies within the surface - bool isInsideBoundaries(const Vector3D& point) const; + virtual bool isInsideBoundaries(const Vector3D& point) const; /// Access to the normal direction at the given point - Vector3D getNormal(const Vector3D& point) const; + virtual Vector3D getNormal(const Vector3D& point) const; /// Access to the measurement directions at the given point - Measurement measurement(const Vector3D& point) const; + virtual Measurement measurement(const Vector3D& point) const; protected: StraightLineBoundary m_boundary; diff --git a/DDSurfaces/include/DDSurfaces/Vector3D.h b/DDSurfaces/include/DDSurfaces/Vector3D.h index 85d871e1d..3b710a815 100644 --- a/DDSurfaces/include/DDSurfaces/Vector3D.h +++ b/DDSurfaces/include/DDSurfaces/Vector3D.h @@ -14,7 +14,7 @@ namespace DDSurfaces { class Vector3D { public: /// Default constructor - Vector3D(double x=0., double y=0., double z=0.) : + Vector3D(double x = 0., double y = 0., double z = 0.) : m_x(x), m_y(y), m_z(z) { } diff --git a/DDSurfaces/include/DDSurfaces/ZCylinderSurface.h b/DDSurfaces/include/DDSurfaces/ZCylinderSurface.h index 7eb4835e5..3161f1dd6 100644 --- a/DDSurfaces/include/DDSurfaces/ZCylinderSurface.h +++ b/DDSurfaces/include/DDSurfaces/ZCylinderSurface.h @@ -12,7 +12,9 @@ namespace DDSurfaces { -class ZCylinderBoundary; +struct ZCylinderBoundary { + ; +}; class ZCylinderSurface: public ISurface { public: @@ -23,13 +25,13 @@ public: virtual ~ZCylinderSurface(); /// Checks if the given point lies within the surface - bool isInsideBoundaries(const Vector3D& point) const; + virtual bool isInsideBoundaries(const Vector3D& point) const; /// Access to the normal direction at the given point - Vector3D getNormal(const Vector3D& point) const; + virtual Vector3D getNormal(const Vector3D& point) const; /// Access to the measurement directions at the given point - Measurement measurement(const Vector3D& point) const; + virtual Measurement measurement(const Vector3D& point) const; protected: ZCylinderBoundary m_boundary; diff --git a/DDSurfaces/include/DDSurfaces/ZPlanarSurface.h b/DDSurfaces/include/DDSurfaces/ZPlanarSurface.h index 7d7a98314..d690a42c0 100644 --- a/DDSurfaces/include/DDSurfaces/ZPlanarSurface.h +++ b/DDSurfaces/include/DDSurfaces/ZPlanarSurface.h @@ -12,7 +12,9 @@ namespace DDSurfaces { -class ZPlanarBoundary; +struct ZPlanarBoundary { + ; +}; class ZPlanarSurface: public ISurface { public: @@ -23,13 +25,13 @@ public: virtual ~ZPlanarSurface(); /// Checks if the given point lies within the surface - bool isInsideBoundaries(const Vector3D& point) const; + virtual bool isInsideBoundaries(const Vector3D& point) const; /// Access to the normal direction at the given point - Vector3D getNormal(const Vector3D& point) const; + virtual Vector3D getNormal(const Vector3D& point) const; /// Access to the measurement directions at the given point - Measurement measurement(const Vector3D& point) const; + virtual Measurement measurement(const Vector3D& point) const; protected: ZPlanarBoundary m_boundary; diff --git a/DDSurfaces/src/DiskSurface.cpp b/DDSurfaces/src/DiskSurface.cpp index f342d376b..bbc249463 100644 --- a/DDSurfaces/src/DiskSurface.cpp +++ b/DDSurfaces/src/DiskSurface.cpp @@ -34,7 +34,7 @@ Vector3D DiskSurface::getNormal(const Vector3D& point) const { /// Access to the measurement directions at the given point Measurement DiskSurface::measurement(const Vector3D& point) const { // TODO - return Vector3D(); + return Measurement(); } } /* namespace DDSurfaces */ diff --git a/DDSurfaces/src/StraightLineSurface.cpp b/DDSurfaces/src/StraightLineSurface.cpp index e03fbaf04..a8eb02ff5 100644 --- a/DDSurfaces/src/StraightLineSurface.cpp +++ b/DDSurfaces/src/StraightLineSurface.cpp @@ -34,7 +34,7 @@ Vector3D StraightLineSurface::getNormal(const Vector3D& point) const { /// Access to the measurement directions at the given point Measurement StraightLineSurface::measurement(const Vector3D& point) const { // TODO - return Vector3D(); + return Measurement(); } } /* namespace DDSurfaces */ diff --git a/DDSurfaces/src/ZCylinderSurface.cpp b/DDSurfaces/src/ZCylinderSurface.cpp index 04f1c032a..6ff626bed 100644 --- a/DDSurfaces/src/ZCylinderSurface.cpp +++ b/DDSurfaces/src/ZCylinderSurface.cpp @@ -34,7 +34,7 @@ Vector3D ZCylinderSurface::getNormal(const Vector3D& point) const { /// Access to the measurement directions at the given point Measurement ZCylinderSurface::measurement(const Vector3D& point) const { // TODO - return Vector3D(); + return Measurement(); } } /* namespace DDSurfaces */ diff --git a/DDSurfaces/src/ZPlanarSurface.cpp b/DDSurfaces/src/ZPlanarSurface.cpp index 0b5a4513f..4fbe85475 100644 --- a/DDSurfaces/src/ZPlanarSurface.cpp +++ b/DDSurfaces/src/ZPlanarSurface.cpp @@ -34,7 +34,7 @@ Vector3D ZPlanarSurface::getNormal(const Vector3D& point) const { /// Access to the measurement directions at the given point Measurement ZPlanarSurface::measurement(const Vector3D& point) const { // TODO - return Vector3D(); + return Measurement(); } } /* namespace DDSurfaces */ -- GitLab