-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Operator overloading for domain combinations #142
Comments
A good idea, but you'll have to dive into C++ to implement it indeed. I'd love to elevate more code to the Python level, but the problem is that the primitives' |
If I understand correctly, splitting Thinking now that |
Just give it a shot, I'll review all PRs. Best start out with one operator, like |
I'm thinking it would help with intuitive use of domains if domain combinations could also be implemented as operator overloads, e.g. support the following in
DomainBase
:|
__or__(self, obj)
pygalmesh.Union(self, obj)
Ball | Ball
&
__and__(self, obj)
pygalmesh.Intersection(self, obj)
Ball & Ball
-
__sub__(self, obj)
pygalmesh.Difference(self, obj)
Ball - Ball
+
__add__(self, obj)
pygalmesh.Translate(self, obj)
Ball + [x,y,z]
+
__radd__(self, obj)
self.__add__(obj)
[x,y,z] + Ball
*
__mul__(self, obj)
pygalmesh.Scale(self, obj)
Ball * [x,y,z]
*
__rmul__(self, obj)
self.__mul__(obj)
[x,y,z] * Ball
I'm unsure about
Rotate
(possibly@
(__matmul__
)) andStretch
(possibly%
(__mod__
) or**
(__pow__
), or just left off).I was planning to implement this as a PR but then saw that
DomainBase
and its subclasses are implemented in C++, which I'm not very familiar with. I'm also not sure if a class (e.g.DomainBase
) can have methods that return its own subclasses, which is what would be desired here.EDIT: updated with examples and to better reflect valid inputs.
The text was updated successfully, but these errors were encountered: