Making pipe from Geom_Line

How to make a pipe kind of solid with specified thickness from a Geom_Line?

Volker's picture

Geom_Line is a special Geom_Curve.

// define spine shape
Handle(Geom_Curve) curve = ...
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(curve);
TopoDS_Wire spine = BRepBuilderAPI_MakeWire( edge );

// define profile shape
gp_Pnt origin;
gp_Vec normal;
curve->D1(curve->FirstParameter(), origin, normal);
gp_Dir v1 = gp::DX().IsParallel(normal, Precision::Angular()) ? gp::DY() : gp::DX();
gp_Ax2 center(origin, normal, v1);

Handle(Geom_Curve) circle = new Geom_Circle(center, coolingHole->radius());
TopoDS_Edge circleEdge = BRepBuilderAPI_MakeEdge(circle);
TopoDS_Wire circleWire = BRepBuilderAPI_MakeWire(circleEdge);
TopoDS_Face profile = BRepBuilderAPI_MakeFace(circleWire, Standard_True);

// pipe profile algong spine
BRepOffsetAPI_MakePipe makePipe(spine, profile);
makePipe.Build();
shape = makePipe.Shape();

arkoala's picture

Hi Volker,

I've seen you have fought hard with BRepOffsetAPI_MakePipe, BRepOffsetAPI_MakePipeShell and maybe with BRepOffsetAPI_ThruSections.

I start with a wire for spine in all cases, and I calculate a profile with triangle shape to drag along the spine.

Is it possible to get oriented the profile automatically along the spine curves (not a planar spine)?

My only approximation is using BRepOffsetAPI_ThruSections and calculate for each vertex a new profile well oriented, but it is very hard if I get curved edges.

I am sure MakePipe or MakePipeShell offers a simple way, but I cannot get it.
You are not using SetMode at all, so I guess you will have my same problem if the spine is not planar and with curves.

Thanks.

Volker's picture

Hi arkoala,

I got MakePipeShell work with SetMode(auxilarySpine).

TopoDS_Wire aProfile = makeWire.Wire();
BRepOffsetAPI_MakePipeShell aSweep(spine);
aSweep.SetMode(auxiliarySpine, Standard_True);
aSweep.Add (aProfile);
define transition mode to manage discontinuities on the sweep
BRepBuilderAPI_TransitionMode aTransition = BRepBuilderAPI_RoundCorner;
aSweep.SetTransitionMode (aTransition);
perform sweeping and get a result
aSweep.Build();
aSweep.MakeSolid();
TopoDS_Shape aResult;
if (aSweep.IsDone())
aResult = aSweep.Shape();

Unfortunately, for calculation of the sweeping of an rigid body seperate sweeping of the faces is of little use.
I assume that for this application I'll have to calculate characterstic curves, build an ThruSection with these (the characteristic sections may have different topology!) and fuse this solid with the initial and final position of the solid. (For an idea of solid sweeping you might look at Rossignac et.al.:Boundary of the volume swept by a free-form solid in screw motion, in: cad 39(9):745-755, 2007)

Roman Lygin's picture

Hi Harmish,

Perhaps you already got an answer from previous posts. Just a small addition then.
To get a solid you need to sweep a face along a line spine. To create a profile as a 'pipe section' you could do so by creating an external contour then offsetting it inwards or outwards. If you sweep along the line you could use extrusion BRepPrimAPI_MakePrism, not a generic sweep.

The general rule of thumb is that sweeping produces topology of level + 2 from a profile. Edge will produce face, wire -> shell, face -> solid.

Hope this helps.
Roman

---
opencascade.blogspot.com - blog on Open CASCADE

arkoala's picture

Definitely, I have to return to BRepOffsetAPI_ThruSections and do it the body semi-manually.

Volker: I got working with your code, but instead of using "aSweep.SetMode(auxiliarySpine, Standard_True);" I add two shapes at the beginning and at the end. I could do it with setmode.

It worked well only if the body was planar. Because user can define a 3D wire, function sometimes creates artifacts and my posterior boolean operation is not well done.

Roman: Offset functions are thought only for planar wires, aren't they? If the wire goes along a wall and continues for the ground, offset functions won't be able to predict what I want.

So, If I am not wrong, I have to make an offset funtion on my own, and then use ThruSections to get the body.

Thank you for your assistance.