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
This commit is contained in:
Alex Shvartzkop 2024-05-18 22:46:07 +03:00
parent 11586863cf
commit 5b1c84b5dd
1 changed files with 9 additions and 9 deletions

View File

@ -694,13 +694,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() )
@ -826,8 +819,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 )
{
@ -895,6 +894,7 @@ bool STEP_PCB_MODEL::MakeShapes( std::vector<TopoDS_Shape>& aShapes, const SHAPE
else
{
wxASSERT( false );
return false;
}
}