Commit 53cd19a6 authored by unknown's avatar unknown Committed by jean-pierre charras

VRML export rewritten

parent bd174ebf
......@@ -140,7 +140,6 @@ set( PCBNEW_EXPORTERS
exporters/gen_drill_report_files.cpp
exporters/gen_modules_placefile.cpp
exporters/gendrill_Excellon_writer.cpp
exporters/vrml_board.cpp
)
set( PCBNEW_AUTOROUTER_SRCS
......
......@@ -568,7 +568,7 @@ bool Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, bool aUseThou )
ok = false;
}
catch( std::exception& e )
catch( const std::exception& e )
{
wxString msg;
msg << _( "IDF Export Failed:\n" ) << FROM_UTF8( e.what() );
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -775,7 +775,7 @@ void BOARD_OUTLINE::writeOutline( std::ofstream& aBoardFile, IDF_OUTLINE* aOutli
aBoardFile << aIndex << " " << setiosflags(ios::fixed) << setprecision(5)
<< aOutline->front()->startPoint.x << " "
<< aOutline->front()->startPoint.y << " "
<< setprecision(5) << -aOutline->front()->angle << "\n";
<< setprecision(2) << -aOutline->front()->angle << "\n";
}
}
else
......@@ -799,7 +799,7 @@ void BOARD_OUTLINE::writeOutline( std::ofstream& aBoardFile, IDF_OUTLINE* aOutli
aBoardFile << aIndex << " " << setiosflags(ios::fixed) << setprecision(1)
<< (aOutline->front()->startPoint.x / IDF_THOU_TO_MM) << " "
<< (aOutline->front()->startPoint.y / IDF_THOU_TO_MM) << " "
<< setprecision(5) << -aOutline->front()->angle << "\n";
<< setprecision(2) << -aOutline->front()->angle << "\n";
}
}
......@@ -819,7 +819,7 @@ void BOARD_OUTLINE::writeOutline( std::ofstream& aBoardFile, IDF_OUTLINE* aOutli
aBoardFile << aIndex << " " << setiosflags(ios::fixed) << setprecision(5)
<< (*bo)->startPoint.x << " "
<< (*bo)->startPoint.y << " "
<< setprecision(5) << -(*bo)->angle << "\n";
<< setprecision(2) << -(*bo)->angle << "\n";
}
}
else
......@@ -835,7 +835,7 @@ void BOARD_OUTLINE::writeOutline( std::ofstream& aBoardFile, IDF_OUTLINE* aOutli
aBoardFile << aIndex << " " << setiosflags(ios::fixed) << setprecision(1)
<< ((*bo)->startPoint.x / IDF_THOU_TO_MM) << " "
<< ((*bo)->startPoint.y / IDF_THOU_TO_MM) << " "
<< setprecision(5) << -(*bo)->angle << "\n";
<< setprecision(2) << -(*bo)->angle << "\n";
}
}
......@@ -869,7 +869,7 @@ void BOARD_OUTLINE::writeOutline( std::ofstream& aBoardFile, IDF_OUTLINE* aOutli
aBoardFile << aIndex << " " << setiosflags(ios::fixed) << setprecision(5)
<< (*bo)->endPoint.x << " "
<< (*bo)->endPoint.y << " "
<< setprecision(5) << (*bo)->angle << "\n";
<< setprecision(2) << (*bo)->angle << "\n";
}
}
else
......@@ -893,7 +893,7 @@ void BOARD_OUTLINE::writeOutline( std::ofstream& aBoardFile, IDF_OUTLINE* aOutli
aBoardFile << aIndex << " " << setiosflags(ios::fixed) << setprecision(1)
<< ((*bo)->endPoint.x / IDF_THOU_TO_MM) << " "
<< ((*bo)->endPoint.y / IDF_THOU_TO_MM) << " "
<< setprecision(5) << (*bo)->angle << "\n";
<< setprecision(2) << (*bo)->angle << "\n";
}
}
......@@ -915,7 +915,7 @@ void BOARD_OUTLINE::writeOutline( std::ofstream& aBoardFile, IDF_OUTLINE* aOutli
aBoardFile << aIndex << " " << setiosflags(ios::fixed) << setprecision(5)
<< (*bo)->endPoint.x << " "
<< (*bo)->endPoint.y << " "
<< setprecision(5) << (*bo)->angle << "\n";
<< setprecision(2) << (*bo)->angle << "\n";
}
}
else
......@@ -931,7 +931,7 @@ void BOARD_OUTLINE::writeOutline( std::ofstream& aBoardFile, IDF_OUTLINE* aOutli
aBoardFile << aIndex << " " << setiosflags(ios::fixed) << setprecision(1)
<< ((*bo)->endPoint.x / IDF_THOU_TO_MM) << " "
<< ((*bo)->endPoint.y / IDF_THOU_TO_MM) << " "
<< setprecision(5) << (*bo)->angle << "\n";
<< setprecision(2) << (*bo)->angle << "\n";
}
}
......@@ -1281,7 +1281,7 @@ bool BOARD_OUTLINE::addOutline( IDF_OUTLINE* aOutline )
outlines.push_back( aOutline );
}
catch( std::exception& e )
catch( const std::exception& e )
{
errormsg = e.what();
......
......@@ -2382,7 +2382,7 @@ void IDF3_BOARD::readBoardFile( const std::string& aFileName, bool aNoSubstitute
}
}
}
catch( std::exception& e )
catch( const std::exception& e )
{
brd.exceptions ( std::ios_base::goodbit );
......@@ -2689,7 +2689,7 @@ void IDF3_BOARD::readLibFile( const std::string& aFileName )
while( lib.good() ) readLibSection( lib, state, this );
}
catch( std::exception& e )
catch( const std::exception& e )
{
lib.exceptions ( std::ios_base::goodbit );
......@@ -2773,7 +2773,7 @@ bool IDF3_BOARD::ReadFile( const wxString& aFullFileName, bool aNoSubstituteOutl
// read the board file
readBoardFile( bfname, aNoSubstituteOutlines );
}
catch( std::exception& e )
catch( const std::exception& e )
{
Clear();
errormsg = e.what();
......@@ -2821,7 +2821,7 @@ bool IDF3_BOARD::writeLibFile( const std::string& aFileName )
}
}
catch( std::exception& e )
catch( const std::exception& e )
{
lib.exceptions( std::ios_base::goodbit );
......@@ -3065,7 +3065,7 @@ void IDF3_BOARD::writeBoardFile( const std::string& aFileName )
}
}
catch( std::exception& e )
catch( const std::exception& e )
{
brd.exceptions( std::ios_base::goodbit );
......@@ -3137,7 +3137,7 @@ bool IDF3_BOARD::WriteFile( const wxString& aFullFileName, bool aUnitMM, bool aF
writeBoardFile( bfname );
}
catch( std::exception& e )
catch( const std::exception& e )
{
errormsg = e.what();
......@@ -3901,7 +3901,7 @@ IDF3_COMP_OUTLINE* IDF3_BOARD::GetComponentOutline( wxString aFullFileName )
}
} // while( true )
}
catch( std::exception& e )
catch( const std::exception& e )
{
delete cp;
......
......@@ -230,8 +230,7 @@ void VRML_LAYER::Clear( void )
contours.pop_back();
}
while( !areas.empty() )
areas.pop_back();
areas.clear();
for( i = vertices.size(); i > 0; --i )
{
......@@ -254,8 +253,7 @@ void VRML_LAYER::clearTmp( void )
ord = 0;
glcmd = 0;
while( !triplets.empty() )
triplets.pop_back();
triplets.clear();
for( i = outline.size(); i > 0; --i )
{
......@@ -263,8 +261,7 @@ void VRML_LAYER::clearTmp( void )
outline.pop_back();
}
for( i = ordmap.size(); i > 0; --i )
ordmap.pop_back();
ordmap.clear();
for( i = extra_verts.size(); i > 0; --i )
{
......@@ -274,8 +271,7 @@ void VRML_LAYER::clearTmp( void )
// note: unlike outline and extra_verts,
// vlist is not responsible for memory management
for( i = vlist.size(); i > 0; --i )
vlist.pop_back();
vlist.clear();
// go through the vertex list and reset ephemeral parameters
for( i = 0; i < vertices.size(); ++i )
......@@ -743,6 +739,7 @@ bool VRML_LAYER::Tesselate( VRML_LAYER* holes )
// open the polygon
gluTessBeginPolygon( tess, this );
// add solid outlines
pushVertices( false );
// close the polygon
......@@ -751,8 +748,10 @@ bool VRML_LAYER::Tesselate( VRML_LAYER* holes )
if( Fault )
return false;
// push the (solid) outline to the tesselator
if( !pushOutline( holes ) )
// at this point we have a solid outline; add it to the tesselator
gluTessBeginPolygon( tess, this );
if( !pushOutline( NULL ) )
return false;
// add the holes contained by this object
......@@ -772,14 +771,14 @@ bool VRML_LAYER::Tesselate( VRML_LAYER* holes )
// erase the previous outline data and vertex order
// but preserve the extra vertices
for( int i = outline.size(); i > 0; --i )
while( !outline.empty() )
{
delete outline.back();
outline.pop_back();
}
for( unsigned int i = ordmap.size(); i > 0; --i )
ordmap.pop_back();
ordmap.clear();
ord = 0;
// go through the vertex lists and reset ephemeral parameters
for( unsigned int i = 0; i < vertices.size(); ++i )
......@@ -792,14 +791,16 @@ bool VRML_LAYER::Tesselate( VRML_LAYER* holes )
extra_verts[i]->o = -1;
}
ord = 0;
// close the polygon; we now have all the data necessary for the tesselation
// close the polygon; this creates the outline points
// and the point ordering list 'ordmap'
gluTessEndPolygon( tess );
// request a tesselated surface
// repeat the last operation but request a tesselated surface
// rather than an outline; this creates the triangles list.
gluTessProperty( tess, GLU_TESS_BOUNDARY_ONLY, GL_FALSE );
gluTessBeginPolygon( tess, this );
if( !pushOutline( holes ) )
return false;
......@@ -821,8 +822,6 @@ bool VRML_LAYER::pushOutline( VRML_LAYER* holes )
return false;
}
gluTessBeginPolygon( tess, this );
std::list<std::list<int>*>::const_iterator obeg = outline.begin();
std::list<std::list<int>*>::const_iterator oend = outline.end();
......@@ -851,6 +850,7 @@ bool VRML_LAYER::pushOutline( VRML_LAYER* holes )
if( pi < 0 || (unsigned int) pi > ordmap.size() )
{
gluTessEndContour( tess );
error = "pushOutline():BUG: *outline.begin() is not a valid index to ordmap";
return false;
}
......@@ -862,6 +862,7 @@ bool VRML_LAYER::pushOutline( VRML_LAYER* holes )
if( !vp )
{
gluTessEndContour( tess );
error = "pushOutline():: BUG: ordmap[n] is not a valid index to vertices[]";
return false;
}
......@@ -1194,9 +1195,9 @@ bool VRML_LAYER::addTriplet( VERTEX_3D* p0, VERTEX_3D* p1, VERTEX_3D* p2 )
double dy0 = p1->y - p0->y;
double dy1 = p2->y - p0->y;
// this number is chosen because we shall only write 6 decimal places
// on the VRML output
double err = 0.000001;
// this number is chosen because we shall only write 9 decimal places
// at most on the VRML output
double err = 0.000000001;
// test if the triangles are degenerate (parallel sides)
......
......@@ -96,6 +96,7 @@ private:
bool fix; // when true, no more vertices may be added by the user
int idx; // vertex index (number of contained vertices)
int ord; // vertex order (number of ordered vertices)
unsigned int idxout; // outline index to first point in 3D outline
std::vector<VERTEX_3D*> vertices; // vertices of all contours
std::vector<std::list<int>*> contours; // lists of vertices for each contour
std::vector< double > areas; // area of the contours (positive if winding is CCW)
......
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