BRepOffsetAPI_ThruSections reverses direction of (half of) wires

Hi, 

I'm having some issues creating a 'ThruSections' Loft.

I created 40 wires representing crossections of a donut-like shape, 

using a translation and rotation on an initial wire, the wires are placed properly,

but when I build the shape using BRepOffsetAPI_ThruSections, the wires seem to reverse direction once they cross the xz-plane (after the 20th wire), see:

http://www.jvanderspek.com/pub/profile_flip.png

the code is as follows:

pnts = []
pnts.append( gp_Pnt( w2, 0, 0) )
pnts.append( gp_Pnt( w2 - b, 0, h2) )
pnts.append( gp_Pnt( w2, 0, h) )
pnts.append( gp_Pnt( -w2, 0, h) )
pnts.append( gp_Pnt(-w2 + b, 0, h2) )
pnts.append( gp_Pnt( -w2, 0, 0) )

segs = []
segs.append( GC_MakeArcOfCircle(pnts[ 0 ], pnts[ 1 ], pnts[ 2 ]) )
segs.append( GC_MakeSegment(pnts[ 2 ], pnts[ 3 ]) )
segs.append( GC_MakeArcOfCircle(pnts[ 3 ], pnts[ 4 ], pnts[ 5 ]) )
segs.append( GC_MakeSegment(pnts[ 5 ], pnts[ 0 ]) )

wire = BRepBuilderAPI_MakeWire()
for i in range( 0, len( segs ) ):
    edge = BRepBuilderAPI_MakeEdge( segs[ i ].Value() )
    wire.Add( edge.Edge() )

wires = []
for i in range( 0, n ):
    trn = gp_Trsf()
    trn.SetTranslation( gp_Vec( w, 0, 0 ) )
    wt = BRepBuilderAPI_Transform( wire.Wire(), trn )
    trn = gp_Trsf()
    trn.SetRotation( gp_Ax1( gp_Pnt( 0, 0, 0 ), gp_Dir( 0, 0, 1 ) ), ( i / n ) * 2 * math.pi )
    wires.append( BRepBuilderAPI_Transform( wt.Shape(), trn ) )

loft = BRepOffsetAPI_ThruSections( False, False )
loft.SetSmoothing( False )
loft.SetContinuity( GeomAbs_G2 )

for i in range( 0, len( wires ) ):
    loft.AddWire( topods.Wire( wires[ i ].Shape() ) )

 

could anyone shed some light as to what's happening here ?

 

thanks,

 

Jonathan

 

 

 

Attachments: 
Timo Roth's picture

I think, the algorithm by default tries to avoid twisting of the resulting shape by modifying the wires. Unfortunately, this procedure often fails. If the input wires are correct and have the same number of edges you can switch off this option by loft.CheckCompatibility(False).

jonathan van der spek's picture

Thank you ! that worked. For the record, I worked around it using

BRepBuilderAPI_Transform( wire.Wire(), trn, True )

giving True for the Copy=Standard_False argument.

which also resulted in a proper shape.