Commit 7f648995 authored by jean-pierre charras's avatar jean-pierre charras

specctra_export.cpp: fix a bug in my export function to 3D viewer which...

specctra_export.cpp: fix a bug in my export function to 3D viewer which generates bad shapes for holes generated by outlines
inside the main board outlines.
specctra_export.cpp: always approximate arcs in outlines by 36 segm for 360 degrees,
even for arc angle which differs from 90 degrees.
90 degrees is the default when creating an arc, but the arc value can be edited and have any value between 0 and 360 degrees.
Previously, 9 segments were used regardless the arc angle.
parent 8580d87e
......@@ -489,24 +489,24 @@ void EDA_3D_CANVAS::InitGL()
m_ZTop = 10.0;
glDisable( GL_CULL_FACE ); // show back faces
glEnable( GL_DEPTH_TEST ); // Enable z-buferring
glEnable( GL_ALPHA_TEST );
glEnable( GL_LINE_SMOOTH );
glEnable(GL_POLYGON_SMOOTH);
glEnable( GL_COLOR_MATERIAL );
glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE );
/* speedups */
// speedups
glEnable( GL_DITHER );
glShadeModel( GL_SMOOTH );
glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_DONT_CARE );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST ); // can be GL_FASTEST
glHint( GL_POLYGON_SMOOTH_HINT, GL_NICEST );
/* blend */
// Initialize alpha blending function.
glEnable( GL_BLEND );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
}
glShadeModel( GL_FLAT );
}
// set viewing projection
......
......@@ -229,7 +229,8 @@ void EDA_3D_CANVAS::BuildBoard3DView()
allLayerHoles, &msg ) )
{
msg << wxT("\n\n") <<
_("Unable to calculate the board outlines, will use the outlines boundary box");
_("Unable to calculate the board outlines.\n"
"Therefore use the board boundary box.");
wxMessageBox( msg );
}
......
......@@ -882,6 +882,7 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
{
TYPE_COLLECTOR items;
unsigned prox; // a proximity BIU metric, not an accurate distance
const int STEPS = 36; // for a segmentation of an arc of 360 degrees
// Get all the DRAWSEGMENTS and module graphics into 'items',
// then keep only those on layer == EDGE_N.
......@@ -945,17 +946,19 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
// an arc with a series of short lines and put those
// line segments into the !same! PATH.
{
const int STEPS = 9; // in an arc of 90 degrees
wxPoint start = graphic->GetArcStart();
wxPoint center = graphic->GetCenter();
double angle = -graphic->GetAngle();
int steps = STEPS * fabs(angle) /3600.0;
if( steps == 0 )
steps = 1;
wxPoint pt;
for( int step = 1; step<=STEPS; ++step )
for( int step = 1; step<=steps; ++step )
{
double rotation = ( angle * step ) / STEPS;
double rotation = ( angle * step ) / steps;
pt = start;
......@@ -1053,12 +1056,14 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
// an arc with a series of short lines and put those
// line segments into the !same! PATH.
{
const int STEPS = 9; // in an arc of 90 degrees
wxPoint start = graphic->GetArcStart();
wxPoint end = graphic->GetArcEnd();
wxPoint center = graphic->GetCenter();
double angle = -graphic->GetAngle();
int steps = STEPS * fabs(angle) /3600.0;
if( steps == 0 )
steps = 1;
if( !close_enough( prevPt, start, prox ) )
{
......@@ -1070,9 +1075,9 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
wxPoint nextPt;
for( int step = 1; step<=STEPS; ++step )
for( int step = 1; step<=steps; ++step )
{
double rotation = ( angle * step ) / STEPS;
double rotation = ( angle * step ) / steps;
nextPt = start;
......@@ -1169,12 +1174,14 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
// an arc with a series of short lines and put those
// line segments into the !same! PATH.
{
const int STEPS = 9; // in an arc of 90 degrees
wxPoint start = graphic->GetArcStart();
wxPoint end = graphic->GetArcEnd();
wxPoint center = graphic->GetCenter();
double angle = -graphic->GetAngle();
int steps = STEPS * fabs(angle) /3600.0;
if( steps == 0 )
steps = 1;
if( !close_enough( prevPt, start, prox ) )
{
......@@ -1186,9 +1193,9 @@ void SPECCTRA_DB::fillBOUNDARY( BOARD* aBoard, BOUNDARY* boundary ) throw( IO_ER
wxPoint nextPt;
for( int step = 1; step<=STEPS; ++step )
for( int step = 1; step<=steps; ++step )
{
double rotation = ( angle * step ) / STEPS;
double rotation = ( angle * step ) / steps;
nextPt = start;
......@@ -1300,7 +1307,7 @@ bool SPECCTRA_DB::GetBoardPolygonOutlines( BOARD* aBoard,
KEEPOUT& keepout = *i;
PATH* poly_hole = (PATH*)keepout.shape;
POINTS& plist = poly_hole->GetPoints();
for( unsigned ii = 0; ii < plist.size(); ii+=2 )
for( unsigned ii = 0; ii < plist.size(); ii++ )
{
corner.x = plist[ii].x * specctra2UIfactor;
corner.y = - plist[ii].y * specctra2UIfactor;
......
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