wrml exporter: optimize circle to segment approximation.
This commit is contained in:
parent
f1c599fa4d
commit
4a53917efa
|
@ -605,6 +605,8 @@ void EXPORTER_PCB_VRML::ExportVrmlBoard()
|
|||
}
|
||||
}
|
||||
|
||||
// Max error allowed to approximate a circle by segments, in mm
|
||||
static const double err_approx_max = 0.005;
|
||||
|
||||
void EXPORTER_PCB_VRML::ExportVrmlViaHoles()
|
||||
{
|
||||
|
@ -632,7 +634,22 @@ void EXPORTER_PCB_VRML::ExportVrmlViaHoles()
|
|||
double x = via->GetStart().x * m_BoardToVrmlScale;
|
||||
double y = via->GetStart().y * m_BoardToVrmlScale;
|
||||
|
||||
m_holes.AddCircle( x, -y, hole_radius, true );
|
||||
// Set the optimal number of segments to approximate a circle.
|
||||
// SetArcParams needs a count max, and the minimal and maximal length
|
||||
// of segments
|
||||
int nsides = GetArcToSegmentCount( via->GetDrillValue(),
|
||||
Millimeter2iu( err_approx_max ), 360.0 );
|
||||
double minSegLength = M_PI * 2.0 * hole_radius / nsides;
|
||||
double maxSegLength = minSegLength*2.0;
|
||||
|
||||
m_holes.SetArcParams( nsides*2, minSegLength, maxSegLength );
|
||||
m_plated_holes.SetArcParams( nsides, minSegLength, maxSegLength );
|
||||
|
||||
m_holes.AddCircle( x, -y, hole_radius, true, true );
|
||||
m_plated_holes.AddCircle( x, -y, hole_radius, true, false );
|
||||
|
||||
m_holes.ResetArcParams();
|
||||
m_plated_holes.ResetArcParams();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -648,6 +665,14 @@ void EXPORTER_PCB_VRML::ExportVrmlPadHole( PAD* aPad )
|
|||
// Export the hole on the edge layer
|
||||
if( hole_drill > 0 )
|
||||
{
|
||||
int nsides = GetArcToSegmentCount( hole_drill,
|
||||
Millimeter2iu( err_approx_max ), 360.0 );
|
||||
double minSegLength = M_PI * hole_drill / nsides;
|
||||
double maxSegLength = minSegLength*2.0;
|
||||
|
||||
m_holes.SetArcParams( nsides*2, minSegLength, maxSegLength );
|
||||
m_plated_holes.SetArcParams( nsides, minSegLength, maxSegLength );
|
||||
|
||||
bool pth = false;
|
||||
|
||||
if( ( aPad->GetAttribute() != PAD_ATTRIB_NPTH ) )
|
||||
|
@ -688,6 +713,9 @@ void EXPORTER_PCB_VRML::ExportVrmlPadHole( PAD* aPad )
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
m_holes.ResetArcParams();
|
||||
m_plated_holes.ResetArcParams();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -169,10 +169,7 @@ static void CALLBACK vrml_tess_combine( GLdouble coords[3], VERTEX_3D* vertex_da
|
|||
|
||||
VRML_LAYER::VRML_LAYER()
|
||||
{
|
||||
// arc parameters suitable to mm measurements
|
||||
maxArcSeg = 48;
|
||||
minSegLength = 0.1;
|
||||
maxSegLength = 0.5;
|
||||
ResetArcParams();
|
||||
offsetX = 0.0;
|
||||
offsetY = 0.0;
|
||||
|
||||
|
@ -219,6 +216,15 @@ VRML_LAYER::~VRML_LAYER()
|
|||
}
|
||||
|
||||
|
||||
void VRML_LAYER::ResetArcParams()
|
||||
{
|
||||
// arc parameters suitable to mm measurements
|
||||
maxArcSeg = 48;
|
||||
minSegLength = 0.1;
|
||||
maxSegLength = 0.5;
|
||||
}
|
||||
|
||||
|
||||
void VRML_LAYER::GetArcParams( int& aMaxSeg, double& aMinLength, double& aMaxLength )
|
||||
{
|
||||
aMaxSeg = maxArcSeg;
|
||||
|
|
|
@ -179,6 +179,12 @@ public:
|
|||
*/
|
||||
bool SetArcParams( int aMaxSeg, double aMinLength, double aMaxLength );
|
||||
|
||||
/**
|
||||
* Resets the parameters used in calculating the number of vertices in an arc
|
||||
* to default values
|
||||
*/
|
||||
void ResetArcParams();
|
||||
|
||||
/**
|
||||
* Function Clear
|
||||
* erases all data except for arc parameters.
|
||||
|
|
Loading…
Reference in New Issue