Skip to content
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

Plane instantiation from planar Geom_BoundedSurface faces Issue #756 #764

Merged

Conversation

dalibor-frivaldsky
Copy link
Contributor

@dalibor-frivaldsky dalibor-frivaldsky commented Nov 5, 2024

This PR addresses additional problems with #756, specifically instantiating a Plane from planar faces that are not of type Geom_Plane.

Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.09%. Comparing base (82af584) to head (a797e59).
Report is 17 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #764      +/-   ##
==========================================
+ Coverage   96.05%   96.09%   +0.03%     
==========================================
  Files          25       25              
  Lines        8387     8447      +60     
==========================================
+ Hits         8056     8117      +61     
+ Misses        331      330       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gumyr
Copy link
Owner

gumyr commented Nov 6, 2024

There is no issue or description of what problem this change is attempting to fix. Please describe the problem first.

@dalibor-frivaldsky
Copy link
Contributor Author

@gumyr apologies, I assumed the link to the issue in the commit message would be sufficient for provding the context.

This addresses additional issues with loft() creating planar faces of different type than Geom_Plane (or of GeomType.Plane), as described in #756 . I've provided description of these related issues after you've closed the issue. I thought it better to reopen the closed issue, but I can open a new one if this is the prefered way.

BRep_Tool.Surface_s(arg_face.wrapped).Position().XDirection()
)
)
if isinstance(surface, Geom_BoundedSurface):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the special case of Geom_BoundedSurface handled here?

Copy link
Contributor Author

@dalibor-frivaldsky dalibor-frivaldsky Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The added test to this PR fails otherwise when trying to instantiate a Plane from the trapezoid faces created by the loft(), since the underlying kernel creates them as Geom_BSplineSurface and not Geom_Plane. Initially I thought of making the special case for Geom_BSPlineSurface specifically, but there are other surface types, like Geom_BezierSurface. These can be planar as well and it should be possible to create a Plane object from those too. The Geom_BoundedSurface is a base class of these and makes the implementation more general, that's why I opted for it.

tangent_v = gp_Vec()
surface.D1(0.5, 0.5, point, face_x_dir, tangent_v)
else:
face_x_dir = surface.Position().XDirection()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The important ability to force the x direction has been removed and needs to be returned.

Copy link
Contributor Author

@dalibor-frivaldsky dalibor-frivaldsky Nov 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that is the case, the line 2109 retains the ability to force the x direction from the argument to the Plane constructor. All the tests pass so I suppose such a regression would have been caught by them, unless I overlooked something.

@@ -2556,6 +2556,17 @@ def test_plane_init(self):
with self.assertRaises(TypeError):
Plane(Edge.make_line((0, 0), (0, 1)))

# can be instantiated from planar faces of different surface types
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests must make assertions to validate the results and not just run to completion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've extended the test to also verify properties of the two trapezoid faces, which are created as Geom_BSplineSurface by loft() and are the focus of the introduced changes.

@dalibor-frivaldsky
Copy link
Contributor Author

I've updated the Plane instantiation code to use the new is_planar property of the Face class and added missing tests.

@gumyr gumyr merged commit 5633c5f into gumyr:dev Nov 8, 2024
13 checks passed
@gumyr
Copy link
Owner

gumyr commented Nov 8, 2024

My mistake about forcing the x direction. Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants