STEP export: add short segments as circles.

Because OCC can't connect two arcs together sometimes.
This commit is contained in:
Alex Shvartzkop 2023-08-29 23:58:21 +03:00
parent 156288bfcf
commit f8dac43325
1 changed files with 29 additions and 21 deletions

View File

@ -599,33 +599,41 @@ bool STEP_PCB_MODEL::MakeShapeAsThickSegment( TopoDS_Shape& aShape,
{
TopoDS_Edge edge;
if( short_seg )
{
Handle( Geom_Circle ) circle = GC_MakeCircle( coords3D[1], // arc1 start point
coords3D[2], // arc1 mid point
coords3D[5] // arc2 mid point
);
if( !short_seg ) // Do not export a too short segment
edge = BRepBuilderAPI_MakeEdge( circle );
wire.Add( edge );
}
else
{
edge = BRepBuilderAPI_MakeEdge( coords3D[0], coords3D[1] );
wire.Add( edge );
}
Handle(Geom_TrimmedCurve) arcOfCircle = GC_MakeArcOfCircle( coords3D[1], // start point
coords3D[2], // aux point
Handle( Geom_TrimmedCurve ) arcOfCircle =
GC_MakeArcOfCircle( coords3D[1], // start point
coords3D[2], // mid point
coords3D[3] // end point
);
edge = BRepBuilderAPI_MakeEdge( arcOfCircle );
wire.Add( edge );
if( !short_seg ) // Do not export a too short segment
{
edge = BRepBuilderAPI_MakeEdge( coords3D[3], coords3D[4] );
wire.Add( edge );
}
Handle(Geom_TrimmedCurve) arcOfCircle2 = GC_MakeArcOfCircle( coords3D[4], // start point
coords3D[5], // aux point
Handle( Geom_TrimmedCurve ) arcOfCircle2 =
GC_MakeArcOfCircle( coords3D[4], // start point
coords3D[5], // mid point
coords3D[0] // end point
);
edge = BRepBuilderAPI_MakeEdge( arcOfCircle2 );
wire.Add( edge );
}
}
catch( const Standard_Failure& e )
{
ReportMessage( wxString::Format( wxT( "build shape segment: OCC exception: %s\n" ),
@ -638,7 +646,8 @@ bool STEP_PCB_MODEL::MakeShapeAsThickSegment( TopoDS_Shape& aShape,
try
{
face = BRepBuilderAPI_MakeFace( wire );
gp_Pln plane( coords3D[0], gp::DZ() );
face = BRepBuilderAPI_MakeFace( plane, wire );
}
catch( const Standard_Failure& e )
{
@ -787,8 +796,7 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector<TopoDS_Shape>& aShapes, const SHAPE
if( lastPt != currentArc.GetP0() )
addSegment( lastPt, currentArc.GetP0() );
addArc( currentArc );
if( addArc( currentArc ) )
lastPt = currentArc.GetP1();
}
else if( !isArc )