-
-
Notifications
You must be signed in to change notification settings - Fork 677
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
Proposal on how to pass clipping planes info #3774
Conversation
BTW @aothms another superminor topic, but I accidentally found it when messing around for this PR. In |
Hm, that's indeed strange, we have something like that here https://github.com/IfcOpenShell/IfcOpenShell/blame/v0.7.0/src/blenderbim/blenderbim/bim/import_ifc.py#L1875-L1879 but it's based on blender's mathutils. I also remember discussing with @Moult that that function isn't entirely correctly implemented, because it can't do mirroring. There is the Axis3 attribute, which is ignored. I really don't remember what happened with this discussion though and why the result is a missing reference in python :( |
Even less ignored data would be a 4-component plane equation |
Awesome! but yeah, I wouldn't save those 2 floats from |
Hey this is a great change, just been delaying merging it since I haven't had the time to check for usages in BBIM and would like to ensure that this doesn't break things in BBIM |
Sure! No problem. Nice that you don't find anything very off at first glance. I just added a strict validation flag similar to transactions, as discussed here. |
Hey just an update this PR looks at a few things. Some I agree with some I don't which is why I'm not just pressing "merge". Here's a breakdown:
|
Thanks for the follow up, Dion.
As a side note, I'm making these proposals because I can get immediate benefit from them when using the library, so it just makes sense for me. What's for sure is that this is not intended to put any pressure on the current super dev team (i.e. @Andrej730) on rebuilding my PRs. Let me quote this from the first message two months ago:
Maybe I could have been on that call also =) |
Whoops I missed those two lines. This makes a lot more sense now.
Yes, I'm sorry, the call was actually meant to discuss different topics but we drifted off-topic and ended up chatting about this. We'll stick to text Github from now on. |
Co-Authored-By: Carlos Villagrasa <carvillasil@gmail.com>
Merged the clippings planes parts to the main branch. Tried not to modify usecases themselves much, the only changes were to make them use |
Great @Andrej730 ! Do we want to support Python 3.9 and lower on ifcopenshell-python? I used PEP 604 notation for annotations because it feels cleaner and thought it was sensible to require Python 3.10 in a rapidly evolving library as of today, but maybe Dion and Thomas prefer to type |
Sure, let's fix it. |
Co-Authored-By: Carlos Villagrasa <carvillasil@gmail.com>
Hi @Moult , this is linked to question 4 from here, and some little fights I'm having with the current API, which make me interested in improving it. Let's see if you like the angle of this PR, or maybe you'd go in another direction.
It consists of a very simple idea to begin with: to just pass a location and a normal vector in order to generate a clipping plane, instead of a whole matrix in which X and Y vectors are going to be ignored.
However, I also feel like passing a simple dict, without any definition and/or validation is what was making things difficult in the first place. So in order to address that, I defined a
TypedDict
during an initial attempt. Nonetheless, withoutNotRequired
andUnpack
from Python 3.11, it's quite unusable. Furthermore, some factory method can be added to validate the dict, but that kind of defeats the purpose of its simplicity to begin with. So to me, this was screaming dataclass. Consequently, I defined aClippingInfo
dataclass and placed it underutil.representation
.Another thing, I really miss are type hints. They really help to quickly understand the code, and with which args should the API method be called. In addition, the same issue described above happens with the Usecase classes, specially their arguments. I've tried to think of why the
settings
dict was being used, but couldn't figure it out. So I tried a dataclass instead (for thegeometry.add_wall_representation
case), expecting maybe to find the reason, but it just works. Curious to learn the underlying reason if I've missed it.So with the dataclass also in the Usecase, default values can be super easily defined. I've also added some manual validation methods, which don't cover everything, but do cover 100% of their scope. Meaning that they issue a warning if any data has an unexpected format and is going to be ignored. I feel this is super important in general, since as it is now, invalid arguments are ignored silently, making the user have a harder time chasing issues. At the same time, it's not a Pydantic BaseModel validating everything and adding significant overhead, the overhead of a slotted dataclass is negligible. And as it is in this proposal, the dev chooses what to validate (namely, correct keys of dicts or correct classes of entity_instances).
In case this is acceptable, it can be extended to
add_profile_representation
,add_slab_representation
and their respective calls from BlenderBIM, using a dict with "location" and "normal", instead of with "matrix". And of course, the conversion of the Usecase could be extended to the whole API. Is there any interference with Sphinx, maybe?When you have availability, let me know what you think of this, and if there's any drawback concerning dataclasses or type hints I haven't seen. We can screenshare if needed.