mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 02:03:12 +02:00
Performance optimisations for hatching.
This commit is contained in:
parent
bccf365380
commit
845cdb1b25
@ -596,7 +596,39 @@ void EDA_SHAPE::UpdateHatching() const
|
||||
[&]( const std::vector<SEG>& hatchLines )
|
||||
{
|
||||
for( const SEG& seg : hatchLines )
|
||||
TransformOvalToPolygon( m_hatching, seg.A, seg.B, lineWidth, ARC_LOW_DEF, ERROR_INSIDE );
|
||||
{
|
||||
// This is essentially TransformOvalToPolygon(), but without the rounded ends, which
|
||||
// in our case are nothing but a performance sink.
|
||||
|
||||
VECTOR2I endp = seg.B - seg.A;
|
||||
VECTOR2I startp = seg.A;
|
||||
|
||||
// normalize the position in order to have endp.x >= 0
|
||||
// it makes calculations more easy to understand
|
||||
if( endp.x < 0 )
|
||||
{
|
||||
endp = seg.A - seg.B;
|
||||
startp = seg.B;
|
||||
}
|
||||
|
||||
EDA_ANGLE delta_angle( endp );
|
||||
int seg_len = endp.EuclideanNorm();
|
||||
int halfwidth = lineWidth / 2;
|
||||
|
||||
// Build the polygon (a horizontal rectangle).
|
||||
SHAPE_POLY_SET polyshape;
|
||||
polyshape.NewOutline();
|
||||
polyshape.Append( -halfwidth, halfwidth );
|
||||
polyshape.Append( -halfwidth, -halfwidth );
|
||||
polyshape.Append( halfwidth + seg_len, -halfwidth );
|
||||
polyshape.Append( halfwidth + seg_len, halfwidth );
|
||||
|
||||
// Rotate and move the polygon to its right location
|
||||
polyshape.Rotate( -delta_angle );
|
||||
polyshape.Move( startp );
|
||||
|
||||
m_hatching.Append( polyshape);
|
||||
}
|
||||
};
|
||||
|
||||
switch( m_shape )
|
||||
|
@ -191,6 +191,7 @@ public:
|
||||
{
|
||||
POLYGON_POINT_EDIT_BEHAVIOR::UpdateItem( aEditedPoint, aPoints, aCommit, aUpdatedItems );
|
||||
m_shape.SetHatchingDirty();
|
||||
m_shape.UpdateHatching();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -368,8 +368,11 @@ void PCB_SHAPE::UpdateHatching() const
|
||||
RECURSE_MODE::RECURSE );
|
||||
}
|
||||
|
||||
m_hatching.BooleanSubtract( holes );
|
||||
m_hatching.Fracture();
|
||||
if( !holes.IsEmpty() )
|
||||
{
|
||||
m_hatching.BooleanSubtract( holes );
|
||||
m_hatching.Fracture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user