Adding triangulation viewing to AC

This adds a helper routine to visualize the quality of our
triangulation.  It also renames an excessively long variable name for
the arc editor
This commit is contained in:
Seth Hillbrand 2020-08-12 06:16:57 -07:00
parent eae739d98e
commit ab58b67842
4 changed files with 51 additions and 11 deletions

View File

@ -108,6 +108,11 @@ static const wxChar DrawArcAccuracy[] = wxT( "DrawArcAccuracy" );
*/
static const wxChar DrawArcCenterStartEndMaxAngle[] = wxT( "DrawArcCenterStartEndMaxAngle" );
/**
* When true, GAL will stroke the triangulations (only used in OpenGL) with a visible color
*/
static const wxChar StrokeTriangulation[] = wxT( "StrokeTriangulation" );
} // namespace KEYS
@ -185,11 +190,12 @@ ADVANCED_CFG::ADVANCED_CFG()
// Init defaults - this is done in case the config doesn't exist,
// then the values will remain as set here.
m_realTimeConnectivity = true;
m_coroutineStackSize = AC_STACK::default_stack;
m_ShowRouterDebugGraphics = false;
m_drawArcAccuracy = 10.0;
m_drawArcCenterStartEndMaxAngle = 50.0;
m_realTimeConnectivity = true;
m_coroutineStackSize = AC_STACK::default_stack;
m_ShowRouterDebugGraphics = false;
m_drawArcAccuracy = 10.0;
m_drawArcCenterMaxAngle = 50.0;
m_DrawTriangulationOutlines = false;
loadFromConfigFile();
}
@ -239,11 +245,14 @@ void ADVANCED_CFG::loadSettings( wxConfigBase& aCfg )
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::CompactFileSave,
&m_CompactSave, false ) );
configParams.push_back( new PARAM_CFG_DOUBLE(
true, AC_KEYS::DrawArcAccuracy, &m_drawArcAccuracy, 10.0, 0.0, 100000.0 ) );
configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::DrawArcAccuracy,
&m_drawArcAccuracy, 10.0, 0.0, 100000.0 ) );
configParams.push_back( new PARAM_CFG_DOUBLE( true, AC_KEYS::DrawArcCenterStartEndMaxAngle,
&m_drawArcCenterStartEndMaxAngle, 50.0, 0.0, 100000.0 ) );
&m_drawArcCenterMaxAngle, 50.0, 0.0, 100000.0 ) );
configParams.push_back( new PARAM_CFG_BOOL( true, AC_KEYS::StrokeTriangulation,
&m_DrawTriangulationOutlines, false ) );
wxConfigLoadSetups( &aCfg, configParams );

View File

@ -34,6 +34,7 @@
#include <gl_utils.h>
#include <advanced_config.h>
#include <gal/opengl/opengl_gal.h>
#include <gal/opengl/utils.h>
#include <gal/definitions.h>
@ -1043,6 +1044,32 @@ void OPENGL_GAL::drawTriangulatedPolyset( const SHAPE_POLY_SET& aPolySet )
}
}
}
if( ADVANCED_CFG::GetCfg().m_DrawTriangulationOutlines )
{
auto oldStrokeColor = strokeColor;
double oldLayerDepth = layerDepth;
SetLayerDepth( layerDepth - 1 );
SetStrokeColor( COLOR4D( 0.0, 1.0, 0.2, 1.0 ) );
for( unsigned int j = 0; j < aPolySet.TriangulatedPolyCount(); ++j )
{
auto triPoly = aPolySet.TriangulatedPolygon( j );
for( size_t i = 0; i < triPoly->GetTriangleCount(); i++ )
{
VECTOR2I a, b, c;
triPoly->GetTriangle( i, a, b, c );
DrawLine( a, b );
DrawLine( b, c );
DrawLine( c, a );
}
}
SetStrokeColor( oldStrokeColor );
SetLayerDepth( oldLayerDepth );
}
}

View File

@ -77,10 +77,10 @@ public:
/**
* For drawsegments - arcs.
* When drawing an arc, the angle ( center - start ) - ( start - end )
* When drawing an arc, the angle ( center - start ) - ( start - end )
* can be limited to avoid extremely high radii.
*/
double m_drawArcCenterStartEndMaxAngle;
double m_drawArcCenterMaxAngle;
/**
* Extra fill clearance for zone fills
@ -108,6 +108,10 @@ public:
*/
bool m_CompactSave;
/**
* When true, strokes the triangulations with visible color
*/
bool m_DrawTriangulationOutlines;
private:
ADVANCED_CFG();

View File

@ -732,7 +732,7 @@ void POINT_EDITOR::updateItem() const
// This is just to limit the radius, so nothing overflows later when drawing.
if( abs( v2.y / ( R - v2.x ) )
> ADVANCED_CFG::GetCfg().m_drawArcCenterStartEndMaxAngle )
> ADVANCED_CFG::GetCfg().m_drawArcCenterMaxAngle )
{
arcValid = false;
}