fixed bug 588882 (issue on arcs draw in 3D viewer)
This commit is contained in:
parent
c7623715e1
commit
f6a62dc739
|
@ -32,8 +32,8 @@ static void Draw3D_FilledSegmentWithHole( double startx, double starty,
|
||||||
double width, double holex,
|
double width, double holex,
|
||||||
double holey, double holeradius,
|
double holey, double holeradius,
|
||||||
double zpos );
|
double zpos );
|
||||||
static void Draw3D_ArcSegment( double startx, double starty, double endx,
|
static void Draw3D_ArcSegment( double startx, double starty, double centrex,
|
||||||
double endy, double width, double zpos );
|
double centrey, double arc_angle, double width, double zpos );
|
||||||
static void Draw3D_CircleSegment( double startx, double starty, double endx,
|
static void Draw3D_CircleSegment( double startx, double starty, double endx,
|
||||||
double endy, double width, double zpos );
|
double endy, double width, double zpos );
|
||||||
static int Get3DLayerEnable( int act_layer );
|
static int Get3DLayerEnable( int act_layer );
|
||||||
|
@ -530,7 +530,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment )
|
||||||
switch( segment->m_Shape )
|
switch( segment->m_Shape )
|
||||||
{
|
{
|
||||||
case S_ARC:
|
case S_ARC:
|
||||||
Draw3D_ArcSegment( x, -y, xf, -yf, w, zpos );
|
Draw3D_ArcSegment( x, -y, xf, -yf, (double) segment->m_Angle, w, zpos );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_CIRCLE:
|
case S_CIRCLE:
|
||||||
|
@ -552,7 +552,7 @@ void Pcb3D_GLCanvas::Draw3D_DrawSegment( DRAWSEGMENT* segment )
|
||||||
switch( segment->m_Shape )
|
switch( segment->m_Shape )
|
||||||
{
|
{
|
||||||
case S_ARC:
|
case S_ARC:
|
||||||
Draw3D_ArcSegment( x, -y, xf, -yf, w, zpos );
|
Draw3D_ArcSegment( x, -y, xf, -yf, (double) segment->m_Angle, w, zpos );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_CIRCLE:
|
case S_CIRCLE:
|
||||||
|
@ -759,7 +759,7 @@ void EDGE_MODULE::Draw3D( Pcb3D_GLCanvas* glcanvas )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case S_ARC:
|
case S_ARC:
|
||||||
Draw3D_ArcSegment( x, -y, fx, -fy, w, zpos );
|
Draw3D_ArcSegment( x, -y, fx, -fy, (double) m_Angle, w, zpos );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1196,27 +1196,42 @@ static void Draw3D_FilledSegmentWithHole( double startx, double starty,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void Draw3D_ArcSegment( double startx, double starty, double endx,
|
static void Draw3D_ArcSegment( double startx, double starty, double centrex,
|
||||||
double endy, double width, double zpos )
|
double centrey, double arc_angle, double width, double zpos )
|
||||||
{
|
{
|
||||||
int ii, slice = 36;
|
int ii;
|
||||||
double x, y, hole, rayon;
|
int slice = 36; // Number of segments to approximate a circle by segments
|
||||||
int angle;
|
double hole, rayon;
|
||||||
|
double arcStart_Angle;
|
||||||
|
|
||||||
angle = static_cast<int>( atan2( startx - endx, starty - endy ) *
|
arcStart_Angle = (atan2( startx - centrex, starty - centrey ) * 1800 / M_PI );
|
||||||
1800 / M_PI ) + 900;
|
rayon = hypot( startx - centrex, starty - centrey ) + ( width / 2);
|
||||||
rayon = hypot( startx - endx, starty - endy ) + ( width / 2);
|
|
||||||
hole = rayon - width;
|
hole = rayon - width;
|
||||||
|
|
||||||
|
// Calculate the number of segments to approximate this arc
|
||||||
|
int imax = (int) ( (double) arc_angle * slice / 3600.0 );
|
||||||
|
if( imax < 0 )
|
||||||
|
imax = -imax;
|
||||||
|
if (imax == 0 )
|
||||||
|
imax = 1;
|
||||||
|
|
||||||
|
// Adjust delta_angle to have exactly imax segments in arc_angle
|
||||||
|
// i.e. arc_angle = imax delta_agnle.
|
||||||
|
double delta_angle = (double) arc_angle / imax;
|
||||||
|
|
||||||
glBegin( GL_QUAD_STRIP );
|
glBegin( GL_QUAD_STRIP );
|
||||||
for( ii = 0; ii <= slice / 4; ii++ )
|
for( ii = 0; ii <= imax; ii++ )
|
||||||
{
|
{
|
||||||
x = hole; y = 0.0;
|
double angle = (double) ii * delta_angle;
|
||||||
RotatePoint( &x, &y, angle + ( ii * 3600 / slice ) );
|
angle += arcStart_Angle + 900;
|
||||||
glVertex3f( x + startx, y + starty, zpos );
|
double dx = hole;
|
||||||
x = rayon; y = 0.0;
|
double dy = 0.0;
|
||||||
RotatePoint( &x, &y, angle + ( ii * 3600 / slice ) );
|
RotatePoint( &dx, &dy, (int)angle );
|
||||||
glVertex3f( x + startx, y + starty, zpos );
|
glVertex3f( dx + startx, dy + starty, zpos );
|
||||||
|
dx = rayon;
|
||||||
|
dy = 0.0;
|
||||||
|
RotatePoint( &dx, &dy, (int)angle );
|
||||||
|
glVertex3f( dx + startx, dy + starty, zpos );
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
Loading…
Reference in New Issue