How to solve issues creating a rectangular tube: meshing, adding holes

Hello!

I am trying to create a tube which has rectangular profile with rounded corners. I tried two methods and both have drawbacks that I need to overcome, and am hoping somebody can point me in the right direction.

The requirements I have are:
a) Must be able to add/remove holes on the surface quickly (we can assume that the wires defining the holes already exist, but the holes themselves can "appear/disappear" when user selects them)
b) Visualization has to be good

I already have the holes definition in the parametric space of the surface (I've done this succesfully for a circular tube) (Parametric would be as if we cut the tube in one corner and unfolded it)

1) The first method was to create a wire of lines/arcs and just extrude it with BRepPrimAPI_MakePrism. This creates a good mesh for visualizing as you can see in the attached prism_method.jpg file. The problem is that I don't know how to add/remove holes on the fly with this method, and also I'm pretty sure there is no parametric space definition in this case (as far as I can tell, it is just a collection of separate faces)

2) The second method was to create a wire and convert it to a bspline (using BRepAdaptor_CompCurve and Approx_Curve3d), and extrude it using Geom_SurfaceOfLinearExtrusion. This gives me a surface that I can convert to BRepBuilderAPI_MakeFace and by keeping this object I can add/remove wires and redisplay the surface, fulfilling my first requirement. Also since profile of the tube is defined with a spline it has a parameter space which I could use to define the holes (of course, it would be much better if the parametric space was linear in the planar segments of the tube and quadratic in the corners, but being a bspline the space would be defined by its degree). The big drawback? You can see in the other attached pictures, approxcurve_method.jpg and approxcurve_method with mesh.jpg. It looks as if some angry kid smashed the tube with a hammer. I tried to improve the mesh by calling BRepMesh_IncrementalMesh with smaller/bigger deflection values, and even though it improves a little, it creates a LOT of triangles in the rounded corners and slows down the program. By looking at the mesh of the first method this seems unnecessary.

So in conclusion, what I need is the control for holes available in the second method with the visualization quality of the second method. Any ideas?

Just so you know, my first tests were done using a simple extrusion and boolean operations, but I found them to be too slow, even for one hole. And my tubes might have tens to hundreds of holes

I should also mention that in the end I intend to add an inner tube and close the sides to make this a solid tube, but for the sake of simplifying the problem I only deal with one surface in this question.

I'm also attaching the code used to create the two samples (it assumes a handle to an AISContext exists)

Thanks to anyone that might help!

Elias Cohenca

Elias Cohenca's picture

I can't seem to attach multiple files in one post so here's a pic

Elias Cohenca's picture

and another pic

Elias Cohenca's picture

last pic

Elias Cohenca's picture

Code for the first method

Elias Cohenca's picture

and code for the second method

Elias Cohenca's picture

And fix for a typo, should say:
So in conclusion, what I need is the control for holes available in the second method with the visualization quality of the FIRST method. Any ideas?

(this forum could use an Edit button. And multiple attachment support - I feel like I'm bombarding the board already :)