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
e6ff13a8
Commit
e6ff13a8
authored
May 26, 2020
by
Dennis Gläser
Browse files
[python][occ] register boolean operations
parent
ad29f1e1
Changes
1
Hide whitespace changes
Inline
Side-by-side
frackit/python/occutilities/breputilities.hh
View file @
e6ff13a8
...
...
@@ -139,6 +139,40 @@ namespace OCCUtilities {
Box
<
ctype
>
getBoundingBox
(
const
ShapeWrapper
&
wrappedShape
)
{
return
Frackit
::
OCCUtilities
::
getBoundingBox
(
wrappedShape
.
get
());
}
template
<
class
ShapeWrapper1
,
class
ShapeWrapper2
,
class
ctype
>
ShapeWrapper
cut
(
const
ShapeWrapper1
&
wrappedShape1
,
const
ShapeWrapper2
&
wrappedShape2
,
ctype
eps
)
{
return
Frackit
::
OCCUtilities
::
cut
(
wrappedShape1
.
get
(),
wrappedShape2
.
get
(),
eps
);
}
template
<
class
ShapeWrapper1
,
class
ShapeWrapper2
,
class
ctype
>
ShapeWrapper
intersect
(
const
ShapeWrapper1
&
wrappedShape1
,
const
ShapeWrapper2
&
wrappedShape2
,
ctype
eps
)
{
return
Frackit
::
OCCUtilities
::
intersect
(
wrappedShape1
.
get
(),
wrappedShape2
.
get
(),
eps
);
}
template
<
class
Wrapper
,
class
ctype
>
ShapeWrapper
fragment
(
const
std
::
vector
<
Wrapper
>&
wrappedShapes
,
ctype
eps
)
{
std
::
vector
<
typename
Wrapper
::
Shape
>
shapes
;
shapes
.
reserve
(
wrappedShapes
.
size
());
for
(
const
auto
&
s
:
wrappedShapes
)
shapes
.
push_back
(
s
.
get
());
return
Frackit
::
OCCUtilities
::
fragment
(
shapes
,
eps
);
}
template
<
class
Wrapper
,
class
ctype
>
ShapeWrapper
fuse
(
const
std
::
vector
<
Wrapper
>&
wrappedShapes
,
ctype
eps
)
{
std
::
vector
<
typename
Wrapper
::
Shape
>
shapes
;
shapes
.
reserve
(
wrappedShapes
.
size
());
for
(
const
auto
&
s
:
wrappedShapes
)
shapes
.
push_back
(
s
.
get
());
return
Frackit
::
OCCUtilities
::
fuse
(
shapes
,
eps
);
}
ShapeWrapper
readShape
(
const
std
::
string
&
fileName
)
{
return
ShapeWrapper
(
Frackit
::
OCCUtilities
::
readShape
(
fileName
));
}
...
...
@@ -243,6 +277,31 @@ void registerBRepUtilities(pybind11::module& module)
module
.
def
(
"getBoundingBox"
,
&
OCCUtilities
::
getBoundingBox
<
SolidWrapper
,
ctype
>
,
"returns the bounding box of a wrapped solid shape"
);
module
.
def
(
"getBoundingBox"
,
&
OCCUtilities
::
getBoundingBox
<
CompoundWrapper
,
ctype
>
,
"returns the bounding box of a wrapped compound shape"
);
// register boolean operations (TODO: register for all combinations of wrappers?)
using
namespace
py
::
literals
;
module
.
def
(
"cut"
,
&
OCCUtilities
::
cut
<
ShapeWrapper
,
ShapeWrapper
,
ctype
>
,
"object"
_a
,
"tool"
_a
,
"tolerance"
_a
,
"cuts the tool from the object"
);
using
namespace
py
::
literals
;
module
.
def
(
"intersect"
,
&
OCCUtilities
::
intersect
<
ShapeWrapper
,
ShapeWrapper
,
ctype
>
,
"object1"
_a
,
"object2"
_a
,
"tolerance"
_a
,
"returns the common part (intersection) between the two given shapes"
);
using
namespace
py
::
literals
;
module
.
def
(
"fragment"
,
&
OCCUtilities
::
fragment
<
ShapeWrapper
,
ctype
>
,
"objects"
_a
,
"tolerance"
_a
,
"returns the fragments after intersection of the all given shapes"
);
using
namespace
py
::
literals
;
module
.
def
(
"fuse"
,
&
OCCUtilities
::
fuse
<
ShapeWrapper
,
ctype
>
,
"objects"
_a
,
"tolerance"
_a
,
"fuse all given shapes into a single one"
);
// register write function for wrapped shapes
module
.
def
(
"write"
,
&
OCCUtilities
::
write
<
ShapeWrapper
>
,
"writes a wrapped shape to a BRep file"
);
module
.
def
(
"write"
,
&
OCCUtilities
::
write
<
VertexWrapper
>
,
"writes a wrapped vertex shape to a BRep file"
);
...
...
Write
Preview
Supports
Markdown
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