Ensure partially triangulated polys are not valid

Moves rule area triangulation outside of layer iterator and keeps the
triangulation_valid flag false until the triangulation has been
completed.

Fixes https://gitlab.com/kicad/code/kicad/issues/7032
This commit is contained in:
Seth Hillbrand 2021-01-29 16:32:48 -08:00
parent af3789571e
commit 73886aecb1
2 changed files with 23 additions and 23 deletions

View File

@ -2141,7 +2141,7 @@ void SHAPE_POLY_SET::CacheTriangulation( bool aPartition )
}
m_triangulatedPolys.clear();
m_triangulationValid = true;
m_triangulationValid = false;
while( tmpSet.OutlineCount() > 0 )
{

View File

@ -963,7 +963,7 @@ std::unique_ptr<PNS::VIA> PNS_KICAD_IFACE_BASE::syncVia( VIA* aVia )
bool PNS_KICAD_IFACE_BASE::syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_SET* aBoardOutline )
{
SHAPE_POLY_SET poly;
SHAPE_POLY_SET* poly;
if( !aZone->GetIsRuleArea() && aZone->GetZoneName().IsEmpty() )
return false;
@ -979,15 +979,10 @@ bool PNS_KICAD_IFACE_BASE::syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_
LSET layers = aZone->GetLayerSet();
EDA_UNITS units = EDA_UNITS::MILLIMETRES; // TODO: get real units
for( int layer = F_Cu; layer <= B_Cu; layer++ )
{
if( ! layers[ layer ] )
continue;
poly = aZone->Outline();
poly->CacheTriangulation( false );
aZone->BuildSmoothedPoly( poly, ToLAYER_ID( layer ), aBoardOutline );
poly.CacheTriangulation();
if( !poly.IsTriangulationUpToDate() )
if( !poly->IsTriangulationUpToDate() )
{
KIDIALOG dlg( nullptr, wxString::Format( _( "%s is malformed." ),
aZone->GetSelectMenuText( units ) ),
@ -1002,9 +997,14 @@ bool PNS_KICAD_IFACE_BASE::syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_
return false;
}
for( int outline = 0; outline < poly.OutlineCount(); outline++ )
for( int layer = F_Cu; layer <= B_Cu; layer++ )
{
const SHAPE_POLY_SET::TRIANGULATED_POLYGON* tri = poly.TriangulatedPolygon( outline );
if( !layers[ layer ] )
continue;
for( int outline = 0; outline < poly->OutlineCount(); outline++ )
{
const SHAPE_POLY_SET::TRIANGULATED_POLYGON* tri = poly->TriangulatedPolygon( outline );
for( size_t i = 0; i < tri->GetTriangleCount(); i++)
{