STEP export: fix a Bnd_BoundSortBox usage bug.

This commit is contained in:
Alex Shvartzkop 2023-11-21 14:21:12 +03:00
parent 58b9d68084
commit 5de55b8c4a
1 changed files with 12 additions and 3 deletions

View File

@ -905,13 +905,21 @@ bool STEP_PCB_MODEL::CreatePCB( SHAPE_POLY_SET& aOutline, VECTOR2D aOrigin )
}
}
Bnd_Box brdBndBox;
for( const TopoDS_Shape& brdShape : m_board_outlines )
BRepBndLib::Add( brdShape, brdBndBox );
// subtract cutouts (if any)
if( m_cutouts.size() )
{
ReportMessage( wxString::Format( wxT( "Build board cutouts and holes (%d hole(s)).\n" ),
(int) m_cutouts.size() ) );
Bnd_BoundSortBox bsb;
// We need to encompass every location we'll need to test in the global bbox,
// otherwise Bnd_BoundSortBox doesn't work near the boundaries.
Bnd_Box brdWithHolesBndBox = brdBndBox;
Bnd_BoundSortBox bsbHoles;
Handle( Bnd_HArray1OfBox ) holeBoxSet = new Bnd_HArray1OfBox( 0, m_cutouts.size() - 1 );
@ -919,10 +927,11 @@ bool STEP_PCB_MODEL::CreatePCB( SHAPE_POLY_SET& aOutline, VECTOR2D aOrigin )
{
Bnd_Box bbox;
BRepBndLib::Add( m_cutouts[i], bbox );
brdWithHolesBndBox.Add( bbox );
( *holeBoxSet )[i] = bbox;
}
bsb.Initialize( holeBoxSet );
bsbHoles.Initialize( brdWithHolesBndBox, holeBoxSet );
auto subtractShapes = [&]( const wxString& aWhat, std::vector<TopoDS_Shape>& aShapesList )
{
@ -933,7 +942,7 @@ bool STEP_PCB_MODEL::CreatePCB( SHAPE_POLY_SET& aOutline, VECTOR2D aOrigin )
Bnd_Box shapeBbox;
BRepBndLib::Add( shape, shapeBbox );
const TColStd_ListOfInteger& indices = bsb.Compare( shapeBbox );
const TColStd_ListOfInteger& indices = bsbHoles.Compare( shapeBbox );
TopTools_ListOfShape holelist;