For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

One cylinder trims another cylinder

Cauchy Ding's picture
Forums: 

Hi All,

In attachment there are two standard cylinders, I want to use one cylinder to trim another one, but failed. My method is firstly use BRepAlgo_Section to get intersection curves(here I got 7 intersection curves ), and I try to group some of them into a wire (the pcurve will be kept during making wire) and use BRepFeat_SplitShape to split the cylinder. I think that's typical trimming method for face trim face in OCC, but it's so hard to trim this simple case. I have used this method for a long time to do lots of trimming, but blocked by this simple case.
Currently, I have to use another stupid method to solve this, I create four planes to fill the top and bottom of the cylinder to make them as SOLID cylinder, and use Boolean Union operation to get what I want.
Why OCC doesn't provide APIs to trim face by face? How to trim the cylinder in this case?
Any suggestion is welcome, thanks in advance.

Ding

Attachments: 
Forum supervisor's picture

Hi Cauchy,
As a workaround you may create a shell from the face, then solid from the shell,
and do Boolean operations as with valid solids.
Regards

Cauchy Ding's picture

Hi Supervisor,

Thank you for your suggestion. However, I don't think it's a good and proper method to trim face by face using high level Boolean operation. Boolean has many strict pre-conditions.

Ding

Cauchy Ding's picture

Another case is a torus and a sphere.

Attachments: 
Cauchy Ding's picture

For this torus and sphere model, even the intersection has problem. It can only get one intersection edge using API BRepAlgo_Section. My OCC version is 6.3.

Forum supervisor's picture

Hi,
Probably you forgot to turn on the option to build pcurves (section algo)in the result section edges then split shape won't work because pcurves will be absent. For planes pcurves are not mandatory to be presented.
Nevertheless we will check the provided examples and will inform you soon.
Regards

Cauchy Ding's picture

Hi Supervisor,

Thank you for your so quick reply. Yes, I don't forget the pcurve. Please kindly check it again in your app. Thank you very much.
Best Regards.

Ding

Lodyzhensky's picture

Dear Cauchy Ding

Try to use the following Draw commands to trim the cylider 1 by the cylinder 2.

restore twocylinder.brep b
explode b
shape sh2 sh
add b_2 sh2
shape so2 so
add sh2 so2
bop b_1 so2
bopcommon r

Cauchy Ding's picture

Hi Forum Supervisor and Lodyzhensky,

For the second example, both intersection and trim are failed in my app. It can only get one intersection curve using two faces. And also cut the torus failed by the only one intersection edge. Would you please kindly check these? My OCC version is 6.3, hope 6.5 version fix this.
As I said before, Boolean operation is not a good solution to solve face trim by face, especially when destination face and source face can't be grouped into a proper solid shapes.

Thanks in advance.

Ding

Lodyzhensky's picture

Dear Cauchy Ding

1.
You wrote
"...I think that's typical trimming method for face trim face in OCC, but it's so hard to trim this simple case.."

Ok.
Would you so kind to formulate the rules of this "typical" method.
- What does it mean: to trim the face F1 by the face F2 ?
- What will be the result R ? Why ?

2. "...source face can't be grouped into a proper solid shapes..."
- A face(vertex, edge,...) can newer be a solid. The solid can contain a face.
- "...proper solid..." Could you clarify, please, what does it mean?

Cauchy Ding's picture

Hi Lodyzhensky,

Thank you for your reply.
Both the forum supervisor and you suggest me make two solids by the two faces directly, and use Boolean operation to trim one cylinder. Yes, I have tried this method, and it did works well for this case. The cylinder is broken into 5 piece, that's what expected. But I think we'd better have a direct way to trim a face by face.
Currently, in my app, to trim a face by face, my method is firstly do BRepAlgo_Section to get the intersected pcurves in destination faces. Then, I have to do another operations: group the neighbor pcurves into several wires(closed and open). If I have the wires, I can easily trim the destination faces into several pieces using API BRepFeat_SplitShape. In most cases, my method works well because I can group the pcurves easily and BRepFeat_SplitShape works fine. But for this two cylinders case, I can't. 7 intersection pcurves make my grouping failed. (Though BRepFeat_SplitShape also supply .Add(edge) API, but it can't treat 7 intersection curves adding).
So my first idea is "can I trim this model using Boolean operation". Firstly, I add four planes into two cylinders to stitch them as real solids, and this method works well. You and the forum supervisor suggest me directly build solid without adding any face. Yes, it did work well. But have you tried another case of the sphere and the torus (the torus doesn't contain any seamed edge) using this method. It's failed in my app. Though I can cut the torus into three pieces by the sphere using BRepFeat_SplitShape, but three sub torus has topologically error, so it can't be tessellated well in my app(occ 6.3).
"Proper Solid". Boolean has many strict conditions for the two solids: orientation, manifold property, tolerance and others. So I don't think it's a good idea to trim a face by building a solid firstly and doing Boolean operation. For this kind solid, I guess occ algorithm only treat it as a half-space shape.
Well, I don't want to accuse anything about occ. I just hope it's more robust, and more easily used.

Ding

Bearloga's picture

Hi Cauchy,
Using section, making a wire from intersection curves and splitting shape you do almost the same things that Boolean operation does.
You do not need to create two solids. BOP cut requires a solid only for the second object (tool). The first one can be a face/shell.
It is not necessary to close the tool solid by planar faces if intersection curve is fully inside the tool face without meeting with boundary. But if it is the case then I think no way exists to perform your task because it is impossible to split a face by incomplete curve.
For your info, torus contains two seam edges, and they share one vertex. In spite of seemed simplicity this geometry is very complex. I won't wonder if OCCT has some problems with it (and if it has they should be solved for sure))).

Cauchy Ding's picture

Hi Bearloga,

Thank you very much for your detailed explaination. Okay, I will take the Boolean method into my face trimming by face. In my app, if the intersection curve is not throughly crossed destination face but the tolerance is not too much large, I will try to snap the ends of the curve to the boundary or the vertex on the face. So I have to keep my raw method.
Anyway, thank you very much for you, Lodyzhensky and forum supervisor's help. I will end this post.
Best Regards.

Ding

Jane Hu's picture

Hi, Cauchy:

I've recently encountered an imprint problem for two solid cylinders. Their positions are similar as yours. Just that yours are two cylindrical surfaces. As you described, TopOpeBRep_ShapeIntersector gives me 7 curves, and I can't do a proper group using my code. Even if I manually give the curves' loop to make the cut, it still returns me with invalid surfaces.

Your post gave me ideas to use boolean operation, I tried BRepAlgoAPI_Cut and BRepAlgoAPI_Common and want to then unite the solids, taking advantage that unite operation keeps imprints. However, for those two solid cylinders, the BRepAlgoAPI_Common gives intersector.BuilderCanWork() = 1 which means "The Object is created but Nothing is Done", and it truely didn't return me any resultant shapes.

I order to determine it's not that I didn't use the correct operation, I'll need to ask you for a favor, can you describe the booleans that you used for imprint purpose? I know there're many threads on "Common operation not working" issues. That's why I am looking for other alternatives.

Thank you for your possible helps, and have a nice day!

Jane

Cauchy Ding's picture

Hi Jane,

I don't exactly know how you call Boolean APIs. Firstly you need group two faces to two solids. My solid cut codes is attached.
Hope it works for you.

Ding

Attachments: