Skip to content

Solution to functions that tries modifying immutable arguments passed by reference #167

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

Open
GabrielJMS opened this issue Apr 8, 2025 · 3 comments

Comments

@GabrielJMS
Copy link

Hello,

Have you found any solution for handling functions that return values via output parameters passed by reference, especially when those parameters are of immutable types?

This becomes a problem with important functions like BRep_Tool::CurveOnSurface. In such cases, the function modifies the arguments passed by reference (e.g., to return the first and last parameters of the Geom2d_Curve), but when these are immutable types in the binding language, we can’t retrieve the modified values.

This effectively blocks access to important return data.

Some relevant references:

pybind11 FAQ – Limitations involving reference arguments

pyOCCT developer notes – Reference arguments

Would appreciate any guidance or workarounds!

Thanks in advance.

@adam-urbanczyk
Copy link
Member

The solution is to add workaround method in the binding manually or via rules. What is your use case (not CQ I presume) case and why is this function so important?

@GabrielJMS
Copy link
Author

Hello @adam-urbanczyk , thank you for your quick response.

In some data science workflows involving BRep geometry, we need to work directly in the parametric (UV) domain of surfaces to perform calculations on faces. For instance, we often need to construct 2D edges and wires that represent the boundaries of a face in this parametric space.

To do this, it's essential to retrieve the associated pcurve and its parameter range. This also applies to vertices—sometimes we need to extract their (u, v) coordinates on a given surface to carry out specific operations.

Since this information is already available within the BRep data structures, it would be ideal to access it directly using functions like BRep_Tool::CurveOnSurface, rather than having to recompute or approximate it manually.

Thanks again for your support!

@GabrielJMS
Copy link
Author

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

No branches or pull requests

2 participants