-
Notifications
You must be signed in to change notification settings - Fork 39
Add Shape::transform
#213
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
base: main
Are you sure you want to change the base?
Add Shape::transform
#213
Conversation
bschwind
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for this and sorry for the super long wait!
| pub fn transform(&self, transform: &DMat4) -> Self { | ||
| let t = crate::transform::gp_trsf(transform); | ||
| // NOTE: Setting the copy argument does not seem to have an effect. | ||
| let mut res = ffi::BRepBuilderAPI_Transform_ctor(&self.inner, &t, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you pull true into a named local variable?
| let mut res = ffi::BRepBuilderAPI_Transform_ctor(&self.inner, &t, true); | |
| let copy = true; | |
| let mut res = ffi::BRepBuilderAPI_Transform_ctor(&self.inner, &t, copy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do! Sorry for taking so long. Very busy at work the past several weeks!
Summary
gp_Trsf::SetValuestransformmodule, testsgp_trsf(&DMat4) -> gp_TrsfShape::transformDescription
I needed a way to define a
Shapeonce and then duplicate that geometry throughout a model space using transform matrices, similar to "blocks" from the CAD world or "instanced rendering" from the GPU programming world.This PR exposes OCC's implementation of this capability through the
BRepBuilderAPI_Transformclass. This requires using agp_Trsfinstance as the transform matrix. There didn't seem to be a convenient way to construct these from aglamtype, so I added thetransformmodule and a simple test to ensure the construction is correct.One caveat here (that is also noted in the comments) is that the
gp_Trsfconstructor:wcomponent of any columnSo, the values of the output can be different than the input based on the orthogonality of the input.