Commit 8d3ac4b2 by Dennis Gläser

### [python][geometry] register dimensionality fields

parent 263272e3
 ... ... @@ -20,8 +20,10 @@ #define FRACKIT_PYTHON_GEOMETRY_BOX_HH #include #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -40,6 +42,9 @@ void registerBox(py::module& module) "xmin"_a, "ymin"_a, "zmin"_a, "xmax"_a, "ymax"_a, "zmax"_a); cls.def(py::init(), "firstCorner"_a, "secondCorner"_a); // dimensionality properties registerDimensionProperties(cls); // getter functions cls.def("name", &Box::name, "name of the geometry class"); cls.def("volume", &Box::volume, "returns the volume of the box"); ... ...
 ... ... @@ -22,9 +22,11 @@ #include #include #include #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -40,6 +42,9 @@ namespace Detail { std::string className("Circle_" + std::to_string(worldDim)); py::class_ cls(module, className.c_str()); // dimensionality properties registerDimensionProperties(cls); // define constructors using namespace py::literals; using Point = typename Circle::Point; ... ...
 ... ... @@ -24,6 +24,7 @@ #include #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -44,8 +45,12 @@ void registerCylinder(py::module& module) cls.def(py::init(), "bottomCircle"_a, "height"_a); cls.def(py::init(), "bottom"_a, "height"_a); // dimensionality properties registerDimensionProperties(cls); // getter functions cls.def("name", &Cylinder::name, "name of the geometry class"); cls.def("base1", &Cylinder::base1, "first basis vector orthogonal to center line"); cls.def("base2", &Cylinder::base2, "second basis vector orthogonal to center line"); cls.def("base3", &Cylinder::base3, "basis vector parallel to center line"); ... ...
 ... ... @@ -20,8 +20,10 @@ #define FRACKIT_PYTHON_GEOMETRY_CYLINDER_SURFACE_HH #include #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -40,8 +42,12 @@ void registerCylinderSurface(py::module& module) cls.def(py::init(), "radius"_a, "height"_a); cls.def(py::init(), "bottomCircle"_a, "height"_a); // dimensionality properties registerDimensionProperties(cls); // getter functions cls.def("name", &CylinderSurface::name, "name of the geometry class"); cls.def("base1", &CylinderSurface::base1, "first basis vector orthogonal to center line"); cls.def("base2", &CylinderSurface::base2, "second basis vector orthogonal to center line"); cls.def("base3", &CylinderSurface::base3, "basis vector parallel to center line"); ... ...
 ... ... @@ -24,6 +24,7 @@ #include #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -44,6 +45,9 @@ namespace Detail { cls.def(py::init<>()); cls.def(py::init(), "vector"_a); // dimensionality properties registerDimensionProperties(cls); // member functions cls.def("name", &Direction::name, "name of the geometry class"); cls.def("invert", &Direction::invert, "inverts the direction"); ... ...
 ... ... @@ -24,6 +24,7 @@ #include #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -42,6 +43,9 @@ void registerDisk(py::module& module) py::class_ cls(module, "Disk"); cls.def(py::init(), "ellipse"_a); // dimensionality properties registerDimensionProperties(cls); // member functions cls.def("name", &Disk::name, "name of the geometry"); cls.def("area", &Disk::area, "area of the disk"); ... ...
 ... ... @@ -22,9 +22,11 @@ #include #include #include #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -47,6 +49,9 @@ namespace Detail { cls.def(py::init(), "center"_a, "majorAxis"_a, "minorAxis"_a, "majorAxisLength"_a, "minorAxisLength"_a); // dimensionality properties registerDimensionProperties(cls); // member functions cls.def("name", &Ellipse::name, "name of the geometry"); ... ...
 ... ... @@ -23,6 +23,7 @@ #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -44,6 +45,9 @@ namespace Detail { cls.def(py::init(), "supportingEllipse"_a, "source"_a, "target"_a); // dimensionality properties registerDimensionProperties(cls); // member functions cls.def("name", &EllipseArc::name, "name of the geometry"); cls.def("source", &EllipseArc::source, "source point of the arc"); ... ...
 ... ... @@ -25,6 +25,7 @@ #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -45,6 +46,9 @@ namespace Detail { py::class_ cls(module, className.c_str()); cls.def(py::init(), "supportPoint"_a, "direction"_a); // dimensionality properties registerDimensionProperties(cls); // member functions cls.def("name", &Line::name, "name of the geometry"); cls.def("direction", &Line::direction, "direction of the line"); ... ...
 ... ... @@ -25,6 +25,7 @@ #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -51,6 +52,9 @@ namespace Detail { cls.def(py::init(), "supportPoint"_a, "base1"_a, "base2"_a, "normal"_a); // dimensionality properties registerDimensionProperties(cls); // getter functions cls.def("name", &Plane::name, "name of the geometry"); cls.def("normal", &Plane::normal, "normal direction"); ... ...
 ... ... @@ -28,6 +28,7 @@ #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -48,6 +49,9 @@ namespace Detail { std::string className("PointBase_" + std::to_string(worldDim)); py::class_ cls(module, className.c_str()); // dimensionality properties registerDimensionProperties(cls); // member function cls.def("name", &Base::name, "name of the geometry class"); ... ... @@ -59,11 +63,9 @@ namespace Detail { // equality checks using namespace py::literals; cls.def("isEqual", py::overload_cast(&Base::isEqual, py::const_), cls.def("isEqual", py::overload_cast(&Base::isEqual, py::const_), "p"_a, "equality check with default tolerance"); cls.def("isEqual", py::overload_cast(&Base::isEqual, py::const_), cls.def("isEqual", py::overload_cast(&Base::isEqual, py::const_), "p"_a, "b"_a, "equality check with default tolerance"); } ... ...
 ... ... @@ -25,6 +25,7 @@ #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -45,6 +46,9 @@ namespace Detail { cls.def(py::init(), "p1"_a, "p2"_a, "p3"_a, "p4"_a); // dimensionality properties registerDimensionProperties(cls); // member functions cls.def("name", &Quad::name, "name of the geometry"); cls.def("area", &Quad::area, "area of the quadrilateral"); ... ...
 // -*- 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 . * *****************************************************************************/ #ifndef FRACKIT_PYTHON_GEOMETRY_REGISTER_DIMENSION_PROPERTIES_HH #define FRACKIT_PYTHON_GEOMETRY_REGISTER_DIMENSION_PROPERTIES_HH #include namespace Frackit::Python { namespace py = pybind11; template void registerDimensionProperties(py::class_& cls) { cls.def_property_readonly_static("myDimension", [] (py::object /*self*/) { return Geometry::myDimension(); }, "dimension of the geometry"); cls.def_property_readonly_static("worldDimension", [] (py::object /*self*/) { return Geometry::worldDimension(); }, "space dimension"); } } // end namespace Frackit::Python #endif
 ... ... @@ -25,6 +25,7 @@ #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -44,6 +45,9 @@ namespace Detail { py::class_ cls(module, className.c_str()); cls.def(py::init(), "source"_a, "target"_a); // dimensionality properties registerDimensionProperties(cls); // member functions cls.def("name", &Segment::name, "name of the geometry"); cls.def("source", &Segment::source, "source point of the segment"); ... ...
 ... ... @@ -25,6 +25,7 @@ #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -44,6 +45,9 @@ namespace Detail { py::class_ cls(module, className.c_str()); cls.def(py::init(), "p1"_a, "p2"_a, "p3"_a); // dimensionality properties registerDimensionProperties(cls); // member functions cls.def("name", &Triangle::name, "name of the geometry"); cls.def("area", &Triangle::area, "area of the triangle"); ... ...
 ... ... @@ -29,6 +29,7 @@ #include #include #include #include "registerdimensionproperties.hh" namespace Frackit::Python { ... ... @@ -44,6 +45,9 @@ namespace Detail { std::string className("VectorBase_" + std::to_string(Base::worldDimension())); py::class_ cls(module, className.c_str()); // dimensionality properties registerDimensionProperties(cls); cls.def("name", &Base::name, "name of the geometry class"); cls.def("squaredLength", &Base::squaredLength, "squared length of the vector"); cls.def("length", &Base::length, "length of the vector"); ... ... @@ -104,10 +108,8 @@ namespace Detail { // define retrieval functions for the coordinates cls.def("x", &Vector::x, "x-coordinate of the vector"); if constexpr (worldDim > 1) cls.def("y", &Vector::y, "y-coordinate of the vector"); if constexpr (worldDim > 2) cls.def("z", &Vector::z, "z-coordinate of the vector"); if constexpr (worldDim > 1) cls.def("y", &Vector::y, "y-coordinate of the vector"); if constexpr (worldDim > 2) cls.def("z", &Vector::z, "z-coordinate of the vector"); } } // end namespace detail ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!