Ensure consistent use of mm within SG models and that SG models write VRML files using 0.1 inch units

This commit is contained in:
Cirilo Bernardo 2016-01-18 08:35:29 +11:00
parent 9aeaf4a71b
commit ef62a5f153
3 changed files with 31 additions and 1 deletions

View File

@ -223,10 +223,14 @@ bool SGCOORDS::WriteVRML( std::ofstream& aFile, bool aReuseFlag )
std::string tmp;
size_t n = coords.size();
bool nline = false;
SGPOINT pt;
for( size_t i = 0; i < n; )
{
S3D::FormatPoint( tmp, coords[i] );
pt = coords[i];
// ensure VRML output has 1U = 0.1 inch as per legacy kicad expectations
pt.x /= 2.54;
S3D::FormatPoint( tmp, pt );
aFile << tmp ;
++i;

View File

@ -163,6 +163,19 @@ bool WRL1COORDS::Read( WRLPROC& proc, WRL1BASE* aTopNode )
return false;
}
// assuming legacy kicad expectation of 1U = 0.1 inch,
// convert to mm to meet the expectations of the SG structure
std::vector< WRLVEC3F >::iterator sP = points.begin();
std::vector< WRLVEC3F >::iterator eP = points.end();
while( sP != eP )
{
sP->x *= 2.54;
sP->y *= 2.54;
sP->z *= 2.54;
++sP;
}
if( proc.Peek() == '}' )
{
proc.Pop();

View File

@ -173,6 +173,19 @@ bool WRL2COORDS::Read( WRLPROC& proc, WRL2BASE* aTopNode )
return false;
}
// assuming legacy kicad expectation of 1U = 0.1 inch,
// convert to mm to meet the expectations of the SG structure
std::vector< WRLVEC3F >::iterator sP = points.begin();
std::vector< WRLVEC3F >::iterator eP = points.end();
while( sP != eP )
{
sP->x *= 2.54;
sP->y *= 2.54;
sP->z *= 2.54;
++sP;
}
if( proc.Peek() == '}' )
{
proc.Pop();