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,32 +979,32 @@ 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
poly = aZone->Outline();
poly->CacheTriangulation( false );
if( !poly->IsTriangulationUpToDate() )
{
KIDIALOG dlg( nullptr, wxString::Format( _( "%s is malformed." ),
aZone->GetSelectMenuText( units ) ),
KIDIALOG::KD_WARNING );
dlg.ShowDetailedText( wxString::Format( _( "This zone cannot be handled by the track "
"layout tool.\n"
"Please verify it is not a "
"self-intersecting polygon." ) ) );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
dlg.ShowModal();
return false;
}
for( int layer = F_Cu; layer <= B_Cu; layer++ )
{
if( ! layers[ layer ] )
if( !layers[ layer ] )
continue;
aZone->BuildSmoothedPoly( poly, ToLAYER_ID( layer ), aBoardOutline );
poly.CacheTriangulation();
if( !poly.IsTriangulationUpToDate() )
for( int outline = 0; outline < poly->OutlineCount(); outline++ )
{
KIDIALOG dlg( nullptr, wxString::Format( _( "%s is malformed." ),
aZone->GetSelectMenuText( units ) ),
KIDIALOG::KD_WARNING );
dlg.ShowDetailedText( wxString::Format( _( "This zone cannot be handled by the track "
"layout tool.\n"
"Please verify it is not a "
"self-intersecting polygon." ) ) );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
dlg.ShowModal();
return false;
}
for( int outline = 0; outline < poly.OutlineCount(); outline++ )
{
const SHAPE_POLY_SET::TRIANGULATED_POLYGON* tri = poly.TriangulatedPolygon( outline );
const SHAPE_POLY_SET::TRIANGULATED_POLYGON* tri = poly->TriangulatedPolygon( outline );
for( size_t i = 0; i < tri->GetTriangleCount(); i++)
{