Commit afc5d131 authored by jean-pierre charras's avatar jean-pierre charras

Apply a workaround in 3D_draw.cpp to avoid crash in boost::polygon (try to fix Bug #1322804)

This workaround was already used (bzr 4301, in file plot_board_layers.cpp) also to avoid similar crashes (uses 18 segments instead of 16 to approximate a circle by segments).
Minor code cleanup in dialog_plot.
parent 3802629a
...@@ -240,7 +240,12 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -240,7 +240,12 @@ void EDA_3D_CANVAS::BuildBoard3DView()
bool realistic_mode = g_Parm_3D_Visu.IsRealisticMode(); bool realistic_mode = g_Parm_3D_Visu.IsRealisticMode();
// Number of segments to convert a circle to polygon // Number of segments to convert a circle to polygon
const int segcountforcircle = 16; // Boost polygon (at least v 1.54, v1.55 and previous) in very rare cases crashes
// when using 16 segments to approximate a circle.
// So using 18 segments is a workaround to try to avoid these crashes
// ( We already used this trick in plot_board_layers.cpp,
// see PlotSolderMaskLayer() )
const int segcountforcircle = 18;
double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle * 2) ); double correctionFactor = 1.0 / cos( M_PI / (segcountforcircle * 2) );
const int segcountLowQuality = 12; // segments to draw a circle with low quality const int segcountLowQuality = 12; // segments to draw a circle with low quality
// to reduce time calculations // to reduce time calculations
...@@ -355,9 +360,11 @@ void EDA_3D_CANVAS::BuildBoard3DView() ...@@ -355,9 +360,11 @@ void EDA_3D_CANVAS::BuildBoard3DView()
LAYER_NUM zonelayer = zone->GetLayer(); LAYER_NUM zonelayer = zone->GetLayer();
if( zonelayer == layer ) if( zonelayer == layer )
{
zone->TransformSolidAreasShapesToPolygonSet( zone->TransformSolidAreasShapesToPolygonSet(
hightQualityMode ? bufferPolys : bufferZonesPolys, hightQualityMode ? bufferPolys : bufferZonesPolys,
segcountLowQuality, correctionFactorLQ ); segcountLowQuality, correctionFactorLQ );
}
} }
} }
......
...@@ -46,8 +46,6 @@ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) : ...@@ -46,8 +46,6 @@ DIALOG_PLOT::DIALOG_PLOT( PCB_EDIT_FRAME* aParent ) :
m_plotOpts( aParent->GetPlotSettings() ) m_plotOpts( aParent->GetPlotSettings() )
{ {
m_config = Kiface().KifaceSettings(); m_config = Kiface().KifaceSettings();
m_brdSettings = m_board->GetDesignSettings();
Init_Dialog(); Init_Dialog();
GetSizer()->Fit( this ); GetSizer()->Fit( this );
...@@ -101,9 +99,9 @@ void DIALOG_PLOT::Init_Dialog() ...@@ -101,9 +99,9 @@ void DIALOG_PLOT::Init_Dialog()
break; break;
} }
msg = StringFromValue( g_UserUnit, m_brdSettings.m_SolderMaskMargin, true ); msg = StringFromValue( g_UserUnit, m_board->GetDesignSettings().m_SolderMaskMargin, true );
m_SolderMaskMarginCurrValue->SetLabel( msg ); m_SolderMaskMarginCurrValue->SetLabel( msg );
msg = StringFromValue( g_UserUnit, m_brdSettings.m_SolderMaskMinWidth, true ); msg = StringFromValue( g_UserUnit, m_board->GetDesignSettings().m_SolderMaskMinWidth, true );
m_SolderMaskMinWidthCurrValue->SetLabel( msg ); m_SolderMaskMinWidthCurrValue->SetLabel( msg );
// Set units and value for HPGL pen size (this param in in mils). // Set units and value for HPGL pen size (this param in in mils).
......
...@@ -41,8 +41,7 @@ public: ...@@ -41,8 +41,7 @@ public:
private: private:
PCB_EDIT_FRAME* m_parent; PCB_EDIT_FRAME* m_parent;
BOARD* m_board; BOARD* m_board;
BOARD_DESIGN_SETTINGS m_brdSettings; wxConfigBase* m_config;
wxConfigBase* m_config;
std::vector<LAYER_NUM> m_layerList; // List to hold CheckListBox layer numbers std::vector<LAYER_NUM> m_layerList; // List to hold CheckListBox layer numbers
double m_XScaleAdjust; // X scale factor adjust to compensate double m_XScaleAdjust; // X scale factor adjust to compensate
// plotter X scaling error // plotter X scaling error
......
...@@ -1222,7 +1222,7 @@ int CPolyLine::HitTestForCorner( const wxPoint& aPos, int aDistMax ) const ...@@ -1222,7 +1222,7 @@ int CPolyLine::HitTestForCorner( const wxPoint& aPos, int aDistMax ) const
* Copy the contours to a KI_POLYGON_WITH_HOLES * Copy the contours to a KI_POLYGON_WITH_HOLES
* The first contour is the main outline, others are holes * The first contour is the main outline, others are holes
*/ */
void CPOLYGONS_LIST::ExportTo( KI_POLYGON_WITH_HOLES& aPolygoneWithHole ) void CPOLYGONS_LIST::ExportTo( KI_POLYGON_WITH_HOLES& aPolygoneWithHole ) const
{ {
unsigned corners_count = m_cornersList.size(); unsigned corners_count = m_cornersList.size();
...@@ -1273,7 +1273,7 @@ void CPOLYGONS_LIST::ExportTo( KI_POLYGON_WITH_HOLES& aPolygoneWithHole ) ...@@ -1273,7 +1273,7 @@ void CPOLYGONS_LIST::ExportTo( KI_POLYGON_WITH_HOLES& aPolygoneWithHole )
* Each contour is copied into a KI_POLYGON, and each KI_POLYGON * Each contour is copied into a KI_POLYGON, and each KI_POLYGON
* is append to aPolygons * is append to aPolygons
*/ */
void CPOLYGONS_LIST::ExportTo( KI_POLYGON_SET& aPolygons ) void CPOLYGONS_LIST::ExportTo( KI_POLYGON_SET& aPolygons ) const
{ {
std::vector<KI_POLY_POINT> cornerslist; std::vector<KI_POLY_POINT> cornerslist;
unsigned corners_count = GetCornersCount(); unsigned corners_count = GetCornersCount();
......
...@@ -164,7 +164,7 @@ public: ...@@ -164,7 +164,7 @@ public:
* Copy all contours to a KI_POLYGON_SET * Copy all contours to a KI_POLYGON_SET
* @param aPolygons = the KI_POLYGON_WITH_HOLES to populate * @param aPolygons = the KI_POLYGON_WITH_HOLES to populate
*/ */
void ExportTo( KI_POLYGON_SET& aPolygons ); void ExportTo( KI_POLYGON_SET& aPolygons ) const;
/** /**
* Function ExportTo * Function ExportTo
...@@ -172,7 +172,7 @@ public: ...@@ -172,7 +172,7 @@ public:
* The first contour is the main outline, others are holes * The first contour is the main outline, others are holes
* @param aPolygoneWithHole = the KI_POLYGON_WITH_HOLES to populate * @param aPolygoneWithHole = the KI_POLYGON_WITH_HOLES to populate
*/ */
void ExportTo( KI_POLYGON_WITH_HOLES& aPolygoneWithHole ); void ExportTo( KI_POLYGON_WITH_HOLES& aPolygoneWithHole ) const;
/** /**
* Function ImportFrom * Function ImportFrom
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment