STEP export: allow closing (and constructing) the wire with 1nm edges.

This is ok (and required) because we don't mess with BRepBuilderAPI::Precision nowadays.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18030

(cherry picked from commit 5b1c84b5dd)
This commit is contained in:
Alex Shvartzkop 2024-05-18 22:46:07 +03:00
parent aaf3142e9a
commit e00219f459
1 changed files with 9 additions and 9 deletions

View File

@ -1444,13 +1444,6 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector<TopoDS_Shape>& aShapes, const SHAPE
gp_Pnt start = toPoint( aPt0 );
gp_Pnt end = toPoint( aPt1 );
// Do not export too short segments: they create broken shape because OCC thinks
// start point and end point are at the same place
double seg_len = std::hypot( end.X() - start.X(), end.Y() - start.Y() );
if( seg_len <= m_mergeOCCMaxDist )
return false;
BRepBuilderAPI_MakeEdge mkEdge( start, end );
if( !mkEdge.IsDone() || mkEdge.Edge().IsNull() )
@ -1575,8 +1568,14 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector<TopoDS_Shape>& aShapes, const SHAPE
isFirstShape = false;
}
if( lastPt != firstPt )
addSegment( lastPt, firstPt );
if( lastPt != firstPt && !addSegment( lastPt, firstPt ) )
{
ReportMessage( wxString::Format(
wxT( "** Failed to close wire at %d, %d -> %d, %d **\n" ), lastPt.x,
lastPt.y, firstPt.x, firstPt.y ) );
return false;
}
}
catch( const Standard_Failure& e )
{
@ -1711,6 +1710,7 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector<TopoDS_Shape>& aShapes, const SHAPE
else
{
wxASSERT( false );
return false;
}
}