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
ad29f1e1
Commit
ad29f1e1
authored
May 26, 2020
by
Dennis Gläser
Browse files
[python][shapewrappers] add constructor from other wrappers
parent
73ccd2b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
frackit/python/occutilities/brepwrapper.hh
View file @
ad29f1e1
...
...
@@ -51,6 +51,24 @@ private:
Shape
shape_
;
};
// Wrapper class around TopoDS_Shape is constructible from other wrappers
template
<
>
class
BRepWrapper
<
TopoDS_Shape
>
{
public:
//! export underlying shape type
using
Shape
=
TopoDS_Shape
;
template
<
class
S
>
BRepWrapper
(
const
BRepWrapper
<
S
>&
wrapper
)
:
shape_
(
wrapper
.
get
())
{}
BRepWrapper
(
const
Shape
&
shape
)
:
shape_
(
shape
)
{}
BRepWrapper
(
Shape
&&
shape
)
:
shape_
(
std
::
move
(
shape
))
{}
const
Shape
&
get
()
const
{
return
shape_
;
}
std
::
string
name
()
const
{
return
geometryName
(
get
())
+
"_Wrapper"
;
}
private:
Shape
shape_
;
};
// Wrapper around TopoDS_Compound
template
<
>
class
BRepWrapper
<
TopoDS_Compound
>
...
...
frackit/python/occutilities/brepwrappers.hh
View file @
ad29f1e1
...
...
@@ -19,6 +19,7 @@
#ifndef FRACKIT_PYTHON_OCC_BREP_WRAPPERS_HH
#define FRACKIT_PYTHON_OCC_BREP_WRAPPERS_HH
#include <type_traits>
#include <pybind11/pybind11.h>
#include "brepwrapper.hh"
...
...
@@ -34,6 +35,20 @@ namespace Detail {
using
Wrapper
=
OCCUtilities
::
BRepWrapper
<
Shape
>
;
pybind11
::
class_
<
Wrapper
>
cls
(
module
,
className
.
c_str
());
cls
.
def
(
"name"
,
&
Wrapper
::
name
,
"return the name of the wrapper"
);
// add constructor from other shape wrappers
if
constexpr
(
std
::
is_same_v
<
Shape
,
TopoDS_Shape
>
)
{
namespace
py
=
pybind11
;
cls
.
def
(
py
::
init
<
OCCUtilities
::
ShapeWrapper
>
(),
"construction from another brep wrapper"
);
cls
.
def
(
py
::
init
<
OCCUtilities
::
VertexWrapper
>
(),
"construction from another brep wrapper"
);
cls
.
def
(
py
::
init
<
OCCUtilities
::
EdgeWrapper
>
(),
"construction from another brep wrapper"
);
cls
.
def
(
py
::
init
<
OCCUtilities
::
WireWrapper
>
(),
"construction from another brep wrapper"
);
cls
.
def
(
py
::
init
<
OCCUtilities
::
FaceWrapper
>
(),
"construction from another brep wrapper"
);
cls
.
def
(
py
::
init
<
OCCUtilities
::
ShellWrapper
>
(),
"construction from another brep wrapper"
);
cls
.
def
(
py
::
init
<
OCCUtilities
::
SolidWrapper
>
(),
"construction from another brep wrapper"
);
cls
.
def
(
py
::
init
<
OCCUtilities
::
CompoundWrapper
>
(),
"construction from another brep wrapper"
);
}
}
void
registerCompoundWrapper
(
pybind11
::
module
&
module
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment