Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tools
frackit
Commits
e177065e
Commit
e177065e
authored
Apr 19, 2020
by
Dennis Gläser
Browse files
[python] add wrappers for geometry classes
parent
059a20f4
Changes
20
Hide whitespace changes
Inline
Side-by-side
frackit/python/CMakeLists.txt
View file @
e177065e
add_subdirectory
(
common
)
add_subdirectory
(
geometry
)
add_subdirectory
(
precision
)
frackit/python/geometry/CMakeLists.txt
0 → 100644
View file @
e177065e
install
(
FILES
point.hh
vector.hh
DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/frackit/python/geometry
)
frackit/python/geometry/box.hh
0 → 100644
View file @
e177065e
// -*- 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_GEOMETRY_BOX_HH
#define FRACKIT_PYTHON_GEOMETRY_BOX_HH
#include
<pybind11/pybind11.h>
#include
<frackit/geometry/geometry.hh>
#include
<frackit/geometry/box.hh>
namespace
Frackit
::
Python
{
namespace
py
=
pybind11
;
template
<
class
ctype
>
void
registerBox
(
py
::
module
&
module
)
{
using
namespace
py
::
literals
;
using
Box
=
Box
<
ctype
>
;
using
Point
=
typename
Box
::
Point
;
// define constructors
py
::
class_
<
Box
,
Geometry
>
cls
(
module
,
"Box"
);
cls
.
def
(
py
::
init
<
ctype
,
ctype
,
ctype
,
ctype
,
ctype
,
ctype
>
(),
"xmin"
_a
,
"ymin"
_a
,
"zmin"
_a
,
"xmax"
_a
,
"ymax"
_a
,
"zmax"
_a
);
cls
.
def
(
py
::
init
<
const
Point
&
,
Point
>
(),
"firstCorner"
_a
,
"secondCorner"
_a
);
// getter functions
cls
.
def
(
"name"
,
&
Box
::
name
,
"name of the geometry class"
);
cls
.
def
(
"volume"
,
&
Box
::
volume
,
"returns the volume of the box"
);
cls
.
def
(
"xMin"
,
&
Box
::
xMin
,
"returns the minimum x-coordinate of the box"
);
cls
.
def
(
"yMin"
,
&
Box
::
yMin
,
"returns the minimum y-coordinate of the box"
);
cls
.
def
(
"zMin"
,
&
Box
::
zMin
,
"returns the minimum z-coordinate of the box"
);
cls
.
def
(
"xMax"
,
&
Box
::
xMax
,
"returns the maximum x-coordinate of the box"
);
cls
.
def
(
"yMax"
,
&
Box
::
yMax
,
"returns the maximum y-coordinate of the box"
);
cls
.
def
(
"zMax"
,
&
Box
::
zMax
,
"returns the maximum z-coordinate of the box"
);
cls
.
def_static
(
"numCorners"
,
&
Box
::
numCorners
,
"returns the number of corners of the box"
);
cls
.
def
(
"corner"
,
&
Box
::
corner
,
"cornerIdx"
_a
,
"returns the corner with the provided index"
);
cls
.
def_static
(
"numEdges"
,
&
Box
::
numEdges
,
"returns the number of edges of the box"
);
cls
.
def
(
"edge"
,
&
Box
::
edge
,
"edgeIdx"
_a
,
"returns the edge with the provided index"
);
cls
.
def_static
(
"numFaces"
,
&
Box
::
numFaces
,
"returns the number of faces of the box"
);
cls
.
def
(
"face"
,
&
Box
::
face
,
"faceIdx"
_a
,
"returns the face with the provided index"
);
// contains queries
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&>
(
&
Box
::
contains
,
py
::
const_
),
"point"
_a
,
"returns true if the given point is within the box (default tolerance)"
);
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&
,
ctype
>
(
&
Box
::
contains
,
py
::
const_
),
"point"
_a
,
"eps"
_a
,
"returns true if the given point is within the box (given tolerance)"
);
}
}
// end namespace Frackit::Python
#endif
frackit/python/geometry/circle.hh
0 → 100644
View file @
e177065e
// -*- 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_GEOMETRY_CIRCLE_HH
#define FRACKIT_PYTHON_GEOMETRY_CIRCLE_HH
#include
<string>
#include
<pybind11/pybind11.h>
#include
<frackit/geometry/geometry.hh>
#include
<frackit/geometry/ellipticalgeometry.hh>
#include
<frackit/geometry/circle.hh>
namespace
Frackit
::
Python
{
namespace
py
=
pybind11
;
namespace
Detail
{
template
<
class
ctype
,
int
worldDim
>
void
registerCircle
(
py
::
module
&
module
)
{
using
Circle
=
Circle
<
ctype
,
worldDim
>
;
using
EllipticalGeometry
=
EllipticalGeometry
<
ctype
,
worldDim
>
;
std
::
string
className
(
"Circle_"
+
std
::
to_string
(
worldDim
));
py
::
class_
<
Circle
,
Geometry
,
EllipticalGeometry
>
cls
(
module
,
className
.
c_str
());
// define constructors
using
namespace
py
::
literals
;
using
Point
=
typename
Circle
::
Point
;
using
Direction
=
typename
Circle
::
Direction
;
cls
.
def
(
py
::
init
<
const
Point
&
,
const
Direction
&
,
ctype
>
(),
"center"
_a
,
"normal"
_a
,
"radius"
_a
);
cls
.
def
(
"name"
,
&
Circle
::
name
,
"name of the geometry class"
);
cls
.
def
(
"radius"
,
&
Circle
::
radius
,
"returns the radius of the circle"
);
cls
.
def
(
"base1"
,
&
Circle
::
base1
,
"returns the first unit basis vector"
);
cls
.
def
(
"base2"
,
&
Circle
::
base2
,
"returns the second unit basis vector"
);
// contains queries
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&>
(
&
Circle
::
contains
,
py
::
const_
),
"point"
_a
,
"returns true if the given point is on the circle (default tolerance)"
);
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&
,
ctype
>
(
&
Circle
::
contains
,
py
::
const_
),
"point"
_a
,
"eps"
_a
,
"returns true if the given point is on the circle (given tolerance)"
);
// get a point from local coordinate or angle
cls
.
def
(
"getPoint"
,
&
Circle
::
getPoint
,
"localCoordinate"
_a
,
"return the point on the circle for the given local coordinate (0.0 <= localCoordinate <= 1)"
);
cls
.
def
(
"getPointFromAngle"
,
&
Circle
::
getPointFromAngle
,
"angle"
_a
,
"return the point on the circle for the given angle w.r.t. the circle-local coordinate system (angle >= 0.0)"
);
}
}
// end namespace detail
template
<
class
ctype
>
void
registerCircle
(
py
::
module
&
module
)
{
Detail
::
registerCircle
<
ctype
,
3
>
(
module
);
}
}
// end namespace Frackit::Python
#endif
frackit/python/geometry/cylinder.hh
0 → 100644
View file @
e177065e
// -*- 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_GEOMETRY_CYLINDER_HH
#define FRACKIT_PYTHON_GEOMETRY_CYLINDER_HH
#include
<string>
#include
<pybind11/pybind11.h>
#include
<frackit/geometry/geometry.hh>
#include
<frackit/geometry/cylinder.hh>
namespace
Frackit
::
Python
{
namespace
py
=
pybind11
;
template
<
class
ctype
>
void
registerCylinder
(
py
::
module
&
module
)
{
using
namespace
py
::
literals
;
using
Cylinder
=
Cylinder
<
ctype
>
;
using
Circle
=
typename
Cylinder
::
Circle
;
using
Disk
=
typename
Cylinder
::
Disk
;
using
Point
=
typename
Cylinder
::
Point
;
// register class and define constructorss
py
::
class_
<
Cylinder
,
Geometry
>
cls
(
module
,
"Cylinder"
);
cls
.
def
(
py
::
init
<
ctype
,
ctype
>
(),
"radius"
_a
,
"height"
_a
);
cls
.
def
(
py
::
init
<
const
Circle
&
,
ctype
>
(),
"bottomCircle"
_a
,
"height"
_a
);
cls
.
def
(
py
::
init
<
const
Disk
&
,
ctype
>
(),
"bottom"
_a
,
"height"
_a
);
// 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"
);
cls
.
def
(
"direction"
,
&
Cylinder
::
direction
,
"direction of the cylinder axis"
);
cls
.
def
(
"topFace"
,
&
Cylinder
::
topFace
,
"returns the upper face"
);
cls
.
def
(
"bottomFace"
,
&
Cylinder
::
bottomFace
,
"returns the lower face"
);
cls
.
def
(
"lateralFace"
,
&
Cylinder
::
lateralFace
,
"returns the lateral cylinder surface"
);
cls
.
def
(
"centerSegment"
,
&
Cylinder
::
centerSegment
,
"returns the segment describing the cylinder axis"
);
cls
.
def
(
"height"
,
&
Cylinder
::
height
,
"returns the height of the cylinder"
);
cls
.
def
(
"radius"
,
&
Cylinder
::
radius
,
"returns the radius of the cylinder"
);
cls
.
def
(
"volume"
,
&
Cylinder
::
volume
,
"returns the volume of the cylinder"
);
// contains queries
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&>
(
&
Cylinder
::
contains
,
py
::
const_
),
"point"
_a
,
"returns true if the given point is within the cylinder (default tolerance)"
);
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&
,
ctype
>
(
&
Cylinder
::
contains
,
py
::
const_
),
"point"
_a
,
"eps"
_a
,
"returns true if the given point is within the cylinder (given tolerance)"
);
}
}
// end namespace Frackit::Python
#endif
frackit/python/geometry/cylindersurface.hh
0 → 100644
View file @
e177065e
// -*- 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_GEOMETRY_CYLINDER_SURFACE_HH
#define FRACKIT_PYTHON_GEOMETRY_CYLINDER_SURFACE_HH
#include
<pybind11/pybind11.h>
#include
<frackit/geometry/geometry.hh>
#include
<frackit/geometry/cylindersurface.hh>
namespace
Frackit
::
Python
{
namespace
py
=
pybind11
;
template
<
class
ctype
>
void
registerCylinderSurface
(
py
::
module
&
module
)
{
using
namespace
py
::
literals
;
using
CylinderSurface
=
CylinderSurface
<
ctype
>
;
using
Circle
=
typename
CylinderSurface
::
Circle
;
using
Point
=
typename
CylinderSurface
::
Point
;
// register class and define constructors
py
::
class_
<
CylinderSurface
,
Geometry
>
cls
(
module
,
"CylinderSurface"
);
cls
.
def
(
py
::
init
<
ctype
,
ctype
>
(),
"radius"
_a
,
"height"
_a
);
cls
.
def
(
py
::
init
<
const
Circle
&
,
ctype
>
(),
"bottomCircle"
_a
,
"height"
_a
);
// 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"
);
cls
.
def
(
"direction"
,
&
CylinderSurface
::
direction
,
"direction of the cylinder axis"
);
cls
.
def
(
"upperBoundingCircle"
,
&
CylinderSurface
::
upperBoundingCircle
,
"returns the upper bounding circle of the cylinder surface"
);
cls
.
def
(
"lowerBoundingCircle"
,
&
CylinderSurface
::
lowerBoundingCircle
,
"returns the lower bounding circle of the cylinder surface"
);
cls
.
def
(
"cylinder"
,
&
CylinderSurface
::
cylinder
,
"returns the cylinder this is the lateral surface of"
);
cls
.
def
(
"centerSegment"
,
&
CylinderSurface
::
centerSegment
,
"returns the segment describing the cylinder axis"
);
cls
.
def
(
"getTangentPlane"
,
&
CylinderSurface
::
getTangentPlane
,
"point"
_a
,
"returns the tangent plane in the provided point p"
);
cls
.
def
(
"height"
,
&
CylinderSurface
::
height
,
"returns the height of the the cylinder surface"
);
cls
.
def
(
"radius"
,
&
CylinderSurface
::
radius
,
"returns the raidus of the cylinder surface"
);
cls
.
def
(
"area"
,
&
CylinderSurface
::
area
,
"returns the area of the cylinder surface"
);
// contains queries
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&>
(
&
CylinderSurface
::
contains
,
py
::
const_
),
"point"
_a
,
"returns true if the given point is on the cylinder surface (default tolerance)"
);
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&
,
ctype
>
(
&
CylinderSurface
::
contains
,
py
::
const_
),
"point"
_a
,
"eps"
_a
,
"returns true if the given point is on the cylinder surface (given tolerance)"
);
}
}
// end namespace Frackit::Python
#endif
frackit/python/geometry/direction.hh
0 → 100644
View file @
e177065e
// -*- 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_GEOMETRY_DIRECTION_HH
#define FRACKIT_PYTHON_GEOMETRY_DIRECTION_HH
#include
<string>
#include
<pybind11/pybind11.h>
#include
<frackit/geometry/geometry.hh>
#include
<frackit/geometry/direction.hh>
namespace
Frackit
::
Python
{
namespace
py
=
pybind11
;
namespace
Detail
{
template
<
class
ctype
,
int
worldDim
>
void
registerDirection
(
py
::
module
&
module
)
{
using
namespace
py
::
literals
;
using
Direction
=
Direction
<
ctype
,
worldDim
>
;
using
Vector
=
typename
Direction
::
Vector
;
// register class and define constructors
std
::
string
className
(
"Direction_"
+
std
::
to_string
(
worldDim
));
py
::
class_
<
Direction
,
Geometry
>
cls
(
module
,
className
.
c_str
());
cls
.
def
(
py
::
init
<>
());
cls
.
def
(
py
::
init
<
const
Vector
&>
(),
"vector"
_a
);
// member functions
cls
.
def
(
"name"
,
&
Direction
::
name
,
"name of the geometry class"
);
cls
.
def
(
"invert"
,
&
Direction
::
invert
,
"inverts the direction"
);
// returns a vector in this direction with provided length
cls
.
def
(
py
::
self
*
ctype
());
// define retrieval functions for the coordinates
cls
.
def
(
"x"
,
&
Direction
::
x
,
"x-coordinate of the direction"
);
if
constexpr
(
worldDim
>
1
)
cls
.
def
(
"y"
,
&
Direction
::
y
,
"y-coordinate of the direction"
);
if
constexpr
(
worldDim
>
2
)
cls
.
def
(
"z"
,
&
Direction
::
z
,
"z-coordinate of the direction"
);
}
}
// end namespace detail
template
<
class
ctype
>
void
registerDirection
(
py
::
module
&
module
)
{
Detail
::
registerDirection
<
ctype
,
1
>
(
module
);
Detail
::
registerDirection
<
ctype
,
2
>
(
module
);
Detail
::
registerDirection
<
ctype
,
3
>
(
module
);
}
}
// end namespace Frackit::Python
#endif
frackit/python/geometry/disk.hh
0 → 100644
View file @
e177065e
// -*- 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_GEOMETRY_DISK_HH
#define FRACKIT_PYTHON_GEOMETRY_DISK_HH
#include
<pybind11/pybind11.h>
#include
<frackit/geometry/geometry.hh>
#include
<frackit/geometry/ellipticalgeometry.hh>
#include
<frackit/geometry/disk.hh>
namespace
Frackit
::
Python
{
namespace
py
=
pybind11
;
template
<
class
ctype
>
void
registerDisk
(
py
::
module
&
module
)
{
using
namespace
py
::
literals
;
using
Disk
=
Disk
<
ctype
>
;
using
Point
=
typename
Disk
::
Point
;
using
Ellipse
=
typename
Disk
::
Ellipse
;
using
EllipticalGeometry
=
EllipticalGeometry
<
ctype
,
3
>
;
// register class and define constructor
py
::
class_
<
Disk
,
Geometry
,
EllipticalGeometry
>
cls
(
module
,
"Disk"
);
cls
.
def
(
py
::
init
<
const
Ellipse
&>
(),
"ellipse"
_a
);
// member functions
cls
.
def
(
"name"
,
&
Disk
::
name
,
"name of the geometry"
);
cls
.
def
(
"area"
,
&
Disk
::
area
,
"area of the disk"
);
cls
.
def
(
"boundingEllipse"
,
&
Disk
::
boundingEllipse
,
"returns the ellipse that describes the disk boundary"
);
// contains queries
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&
,
bool
>
(
&
Disk
::
contains
,
py
::
const_
),
"point"
_a
,
"checkIfOnEllipse"
_a
=
true
,
"returns true if the given point is on the disk (default tolerance)"
);
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&
,
ctype
,
bool
>
(
&
Disk
::
contains
,
py
::
const_
),
"point"
_a
,
"eps"
_a
,
"checkIfOnEllipse"
_a
=
true
,
"returns true if the given point is on the disk (given tolerance)"
);
// get a point from local coordinate or angle
cls
.
def
(
"getPoint"
,
&
Disk
::
getPoint
,
"angularFraction"
_a
,
"radialFraction"
_a
,
"return the point on the ellipse arc for the given angular and radial fractions (0.0 <= angular/radial fraction <= 1)"
);
}
}
// end namespace Frackit::Python
#endif
frackit/python/geometry/ellipse.hh
0 → 100644
View file @
e177065e
// -*- 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_GEOMETRY_ELLIPSE_HH
#define FRACKIT_PYTHON_GEOMETRY_ELLIPSE_HH
#include
<string>
#include
<pybind11/pybind11.h>
#include
<frackit/geometry/geometry.hh>
#include
<frackit/geometry/ellipticalgeometry.hh>
#include
<frackit/geometry/ellipse.hh>
namespace
Frackit
::
Python
{
namespace
py
=
pybind11
;
namespace
Detail
{
template
<
class
ctype
,
int
worldDim
>
void
registerEllipse
(
py
::
module
&
module
)
{
using
namespace
py
::
literals
;
using
Ellipse
=
Ellipse
<
ctype
,
worldDim
>
;
using
EllipticalGeometry
=
EllipticalGeometry
<
ctype
,
worldDim
>
;
using
Point
=
typename
Ellipse
::
Point
;
using
Direction
=
typename
Ellipse
::
Direction
;
// register class and define constructor
std
::
string
className
(
"Ellipse_"
+
std
::
to_string
(
worldDim
));
py
::
class_
<
Ellipse
,
Geometry
,
EllipticalGeometry
>
cls
(
module
,
className
.
c_str
());
cls
.
def
(
py
::
init
<
const
Point
&
,
const
Direction
&
,
const
Direction
&
,
ctype
,
ctype
>
(),
"center"
_a
,
"majorAxis"
_a
,
"minorAxis"
_a
,
"majorAxisLength"
_a
,
"minorAxisLength"
_a
);
// member functions
cls
.
def
(
"name"
,
&
Ellipse
::
name
,
"name of the geometry"
);
// contains queries
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&
,
bool
>
(
&
Ellipse
::
contains
,
py
::
const_
),
"point"
_a
,
"checkIfOnPlane"
_a
=
true
,
"returns true if the given point is on the ellipse (default tolerance)"
);
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&
,
ctype
,
bool
>
(
&
Ellipse
::
contains
,
py
::
const_
),
"point"
_a
,
"eps"
_a
,
"checkIfOnPlane"
_a
=
true
,
"returns true if the given point is on the ellipse (given tolerance)"
);
// get a point from local coordinate or angle
cls
.
def
(
"getPoint"
,
&
Ellipse
::
getPoint
,
"localCoordinate"
_a
,
"return the point on the ellipse for the given local coordinate (0.0 <= localCoordinate <= 1)"
);
cls
.
def
(
"getPointFromAngle"
,
&
Ellipse
::
getPointFromAngle
,
"angle"
_a
,
"return the point on the ellipse for the given angle w.r.t. the ellipse-local coordinate system (angle >= 0.0)"
);
cls
.
def
(
"getParam"
,
&
Ellipse
::
getParam
,
"point"
_a
,
"checkIfOnEllipse"
_a
=
true
,
"returns the local coordinate of the given point on the ellipse"
);
cls
.
def
(
"getAngle"
,
&
Ellipse
::
getAngle
,
"point"
_a
,
"checkIfOnEllipse"
_a
=
true
,
"returns the angle w.r.t. the ellipse-local coordinate system of the given point"
);
}
}
// end namespace detail
template
<
class
ctype
>
void
registerEllipse
(
py
::
module
&
module
)
{
Detail
::
registerEllipse
<
ctype
,
3
>
(
module
);
}
}
// end namespace Frackit::Python
#endif
frackit/python/geometry/ellipsearc.hh
0 → 100644
View file @
e177065e
// -*- 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_GEOMETRY_ELLIPSEARC_HH
#define FRACKIT_PYTHON_GEOMETRY_ELLIPSEARC_HH
#include
<string>
#include
<pybind11/pybind11.h>
#include
<frackit/geometry/ellipsearc.hh>
namespace
Frackit
::
Python
{
namespace
py
=
pybind11
;
namespace
Detail
{
template
<
class
ctype
,
int
worldDim
>
void
registerEllipseArc
(
py
::
module
&
module
)
{
using
namespace
py
::
literals
;
using
EllipseArc
=
EllipseArc
<
ctype
,
worldDim
>
;
using
Ellipse
=
typename
EllipseArc
::
Ellipse
;
using
Point
=
typename
Ellipse
::
Point
;
// register class and define constructor
std
::
string
className
(
"EllipseArc_"
+
std
::
to_string
(
worldDim
));
py
::
class_
<
EllipseArc
,
Ellipse
>
cls
(
module
,
className
.
c_str
());
cls
.
def
(
py
::
init
<
const
Ellipse
&
,
const
Point
&
,
const
Point
&>
(),
"supportingEllipse"
_a
,
"source"
_a
,
"target"
_a
);
// member functions
cls
.
def
(
"name"
,
&
EllipseArc
::
name
,
"name of the geometry"
);
cls
.
def
(
"source"
,
&
EllipseArc
::
source
,
"source point of the arc"
);
cls
.
def
(
"target"
,
&
EllipseArc
::
target
,
"target point of the arc"
);
cls
.
def
(
"supportingEllipse"
,
&
EllipseArc
::
supportingEllipse
,
"returns the supporting ellipse"
);
cls
.
def
(
"isFullEllipse"
,
&
EllipseArc
::
isFullEllipse
,
"returns true if the arc describes a full ellipse"
);
// angles of source/target points
cls
.
def
(
"sourceAngleOnEllipse"
,
&
EllipseArc
::
sourceAngleOnEllipse
,
"returns the angle of the source point w.r.t. to the ellipse-local coordinate system"
);
cls
.
def
(
"targetAngleOnEllipse"
,
&
EllipseArc
::
targetAngleOnEllipse
,
"returns the angle of the target point w.r.t. to the ellipse-local coordinate system"
);
// contains queries
cls
.
def
(
"contains"
,
py
::
overload_cast
<
const
Point
&
,
bool
>
(
&
EllipseArc
::
contains
,
py
::
const_
),
"point"
_a
,
"checkIfOnEllipse"
_a
=
true
,