Commit 36e4e659 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[python] provide ctype traits compatible with brep wrappers

parent 4416a527
install(FILES
extractctype.hh
id.hh
math.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/frackit/python/common)
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
#ifndef FRACKIT_PYTHON_EXTRACT_CTYPE_HH
#define FRACKIT_PYTHON_EXTRACT_CTYPE_HH
#include <frackit/common/extractctype.hh>
#include <frackit/python/occutilities/brepwrapper.hh>
namespace Frackit::Python {
// helper struct to extract the underlying coordinate type of a
// geometry that provides compatibility with the brep wrappers
template<class Geo>
struct CoordinateTypeTraits
: public Frackit::CoordinateTypeTraits<Geo> {};
template<class S>
struct CoordinateTypeTraits<OCCUtilities::BRepWrapper<S>>
: public Frackit::CoordinateTypeTraits<S> {};
} // end namespace Frackit::Python
#endif
......@@ -21,7 +21,6 @@
#include <pybind11/pybind11.h>
#include <frackit/common/extractctype.hh>
// supported (registered) geometry types (so far)
#include <frackit/geometry/disk.hh>
......@@ -30,6 +29,7 @@
#include <frackit/geometry/box.hh>
#include <frackit/geometry/cylinder.hh>
#include <frackit/python/occutilities/brepwrapper.hh>
#include <frackit/python/common/extractctype.hh>
#include <frackit/magnitude/magnitude.hh>
#include <frackit/magnitude/containedmagnitude.hh>
......@@ -40,16 +40,9 @@ namespace py = pybind11;
namespace Detail {
// helper struct for ctype traits to achieve support for brepwrappers
template<class Geo>
struct CTypeTraits : public Frackit::CoordinateTypeTraits<Geo> {};
template<class S>
struct CTypeTraits<OCCUtilities::BRepWrapper<S>> : public Frackit::CoordinateTypeTraits<S> {};
//! overload for computation of the magnitude of the contained part of a shape wrapper
template<class Geo, class Domain>
typename CTypeTraits<Geo>::type
typename CoordinateTypeTraits<Geo>::type
computeContainedMagnitude(const Geo& geo, const Domain& domain)
{
static constexpr bool isWrapperGeo = OCCUtilities::IsBRepWrapper<Geo>::value;
......@@ -67,7 +60,7 @@ namespace Detail {
//! overload for computation of the magnitude of the contained part of a shape wrapper
template<class Geo>
typename CTypeTraits<Geo>::type
typename CoordinateTypeTraits<Geo>::type
computeMagnitude(const Geo& geo)
{
if constexpr (OCCUtilities::IsBRepWrapper<Geo>::value)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment