Updated VRML exporter and fixed some VRML related bugs
This commit is contained in:
parent
65821328d2
commit
d3771d53ef
|
@ -131,13 +131,13 @@ class SGCOORDINDEX;
|
||||||
aOwnedList.push_back( (aType*)aNode ); \
|
aOwnedList.push_back( (aType*)aNode ); \
|
||||||
aNode->SetParent( this, false ); \
|
aNode->SetParent( this, false ); \
|
||||||
} else { \
|
} else { \
|
||||||
if( NULL == aNode->GetParent() ) { \
|
/*if( NULL == aNode->GetParent() ) { \
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; \
|
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; \
|
||||||
std::cerr << " * [BUG] object '" << aNode->GetName(); \
|
std::cerr << " * [BUG] object '" << aNode->GetName(); \
|
||||||
std::cerr << "' has no parent\n"; \
|
std::cerr << "' has no parent\n"; \
|
||||||
std::cerr << " * [INFO] possible copy assignment or copy constructor bug\n"; \
|
std::cerr << " * [INFO] possible copy assignment or copy constructor bug\n"; \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} */ \
|
||||||
aRefList.push_back( (aType*)aNode ); \
|
aRefList.push_back( (aType*)aNode ); \
|
||||||
aNode->addNodeRef( this ); \
|
aNode->addNodeRef( this ); \
|
||||||
} \
|
} \
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -340,8 +340,8 @@ static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >*
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
do {
|
do {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
std::cerr << " * [INFO] cannot create an outline";
|
ostr << " * [INFO] cannot create an outline";
|
||||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
#endif
|
#endif
|
||||||
|
@ -354,8 +354,8 @@ static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >*
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
do {
|
do {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
std::cerr << " * [INFO] invalid contour: no vertices";
|
ostr << " * [INFO] invalid contour: no vertices";
|
||||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
#endif
|
#endif
|
||||||
|
@ -376,8 +376,8 @@ static bool getOutlineModel( VRML_LAYER& model, const std::list< IDF_OUTLINE* >*
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
do {
|
do {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
std::cerr << " * [BUG] cannot add segment";
|
ostr << " * [BUG] cannot add segment";
|
||||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
#endif
|
#endif
|
||||||
|
@ -410,8 +410,8 @@ static bool addSegment( VRML_LAYER& model, IDF_SEGMENT* seg, int icont, int iseg
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
do {
|
do {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
std::cerr << " * [INFO] adding a circle to an existing vertex list";
|
ostr << " * [INFO] adding a circle to an existing vertex list";
|
||||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
#endif
|
#endif
|
||||||
|
@ -454,8 +454,8 @@ static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, do
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
do {
|
do {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
std::cerr << " * [INFO] no vertex data";
|
ostr << " * [INFO] no vertex data";
|
||||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
#endif
|
#endif
|
||||||
|
@ -468,8 +468,8 @@ static SCENEGRAPH* vrmlToSG( VRML_LAYER& vpcb, int idxColor, SGNODE* aParent, do
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
do {
|
do {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
std::cerr << " * [BUG] index lists are not a multiple of 3 (not a triangle list)";
|
ostr << " * [BUG] index lists are not a multiple of 3 (not a triangle list)";
|
||||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
#endif
|
#endif
|
||||||
|
@ -574,8 +574,8 @@ static SCENEGRAPH* addOutline( IDF3_COMP_OUTLINE* outline, int idxColor, SGNODE*
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
do {
|
do {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
std::cerr << " * [INFO] no valid outline data";
|
ostr << " * [INFO] no valid outline data";
|
||||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
#endif
|
#endif
|
||||||
|
@ -614,11 +614,11 @@ static SCENEGRAPH* loadIDFOutline( const wxString& aFileName )
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
do {
|
do {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
std::cerr << " * [INFO] Failed to read IDF data:\n";
|
ostr << " * [INFO] Failed to read IDF data:\n";
|
||||||
std::cerr << brd.GetError() << "\n\n";
|
ostr << brd.GetError() << "\n\n";
|
||||||
std::cerr << " * [INFO] no outline for file '";
|
ostr << " * [INFO] no outline for file '";
|
||||||
std::cerr << aFileName << "'";
|
ostr << aFileName << "'";
|
||||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
#endif
|
#endif
|
||||||
|
@ -643,10 +643,10 @@ static SCENEGRAPH* loadIDFBoard( const wxString& aFileName )
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
do {
|
do {
|
||||||
std::ostringstream ostr;
|
std::ostringstream ostr;
|
||||||
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
|
||||||
std::cerr << " * [INFO] Failed to read IDF file:\n";
|
ostr << " * [INFO] Failed to read IDF file:\n";
|
||||||
std::cerr << brd.GetError() << "\n\n";
|
ostr << brd.GetError() << "\n\n";
|
||||||
std::cerr << " * [INFO] IDF file '" << aFileName.ToUTF8() << "'";
|
ostr << " * [INFO] IDF file '" << aFileName.ToUTF8() << "'";
|
||||||
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
wxLogTrace( MASK_IDF, "%s\n", ostr.str().c_str() );
|
||||||
} while( 0 );
|
} while( 0 );
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -468,7 +468,7 @@ bool VRML_LAYER::AppendCircle( double aXpos, double aYpos,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// adds a circle the existing list; if 'hole' is true the contour is
|
// adds a circle to the existing list; if 'hole' is true the contour is
|
||||||
// a hole. Returns true if OK.
|
// a hole. Returns true if OK.
|
||||||
bool VRML_LAYER::AddCircle( double aXpos, double aYpos, double aRadius,
|
bool VRML_LAYER::AddCircle( double aXpos, double aYpos, double aRadius,
|
||||||
bool aHoleFlag, bool aPlatedHole )
|
bool aHoleFlag, bool aPlatedHole )
|
||||||
|
@ -1826,8 +1826,8 @@ bool VRML_LAYER::Get3DTriangles( std::vector< double >& aVertexList,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
aVertexList.push_back( vp->x );
|
aVertexList.push_back( vp->x + offsetX );
|
||||||
aVertexList.push_back( vp->y );
|
aVertexList.push_back( vp->y + offsetY );
|
||||||
aVertexList.push_back( aTopZ );
|
aVertexList.push_back( aTopZ );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1836,8 +1836,8 @@ bool VRML_LAYER::Get3DTriangles( std::vector< double >& aVertexList,
|
||||||
{
|
{
|
||||||
vp = getVertexByIndex( ordmap[i], pholes );
|
vp = getVertexByIndex( ordmap[i], pholes );
|
||||||
|
|
||||||
aVertexList.push_back( vp->x );
|
aVertexList.push_back( vp->x + offsetX );
|
||||||
aVertexList.push_back( vp->y );
|
aVertexList.push_back( vp->y + offsetY );
|
||||||
aVertexList.push_back( aBotZ );
|
aVertexList.push_back( aBotZ );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1961,3 +1961,77 @@ bool VRML_LAYER::Get3DTriangles( std::vector< double >& aVertexList,
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool VRML_LAYER::Get2DTriangles( std::vector< double >& aVertexList,
|
||||||
|
std::vector< int > &aIndexPlane, double aHeight, bool aTopPlane )
|
||||||
|
{
|
||||||
|
aVertexList.clear();
|
||||||
|
aIndexPlane.clear();
|
||||||
|
|
||||||
|
if( ordmap.size() < 3 || outline.empty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
VERTEX_3D* vp = getVertexByIndex( ordmap[0], pholes );
|
||||||
|
|
||||||
|
if( !vp )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
size_t i;
|
||||||
|
size_t vsize = ordmap.size();
|
||||||
|
|
||||||
|
// vertices
|
||||||
|
for( i = 0; i < vsize; ++i )
|
||||||
|
{
|
||||||
|
vp = getVertexByIndex( ordmap[i], pholes );
|
||||||
|
|
||||||
|
if( !vp )
|
||||||
|
{
|
||||||
|
aVertexList.clear();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
aVertexList.push_back( vp->x + offsetX );
|
||||||
|
aVertexList.push_back( vp->y + offsetY );
|
||||||
|
aVertexList.push_back( aHeight );
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the index lists .. it is difficult to estimate the list size
|
||||||
|
// a priori so instead we use a vector to help
|
||||||
|
|
||||||
|
if( triplets.empty() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// go through the triplet list and write out the indices based on order
|
||||||
|
std::list< TRIPLET_3D >::const_iterator tbeg = triplets.begin();
|
||||||
|
std::list< TRIPLET_3D >::const_iterator tend = triplets.end();
|
||||||
|
|
||||||
|
std::vector< int > aIndexBot;
|
||||||
|
|
||||||
|
if( aTopPlane )
|
||||||
|
{
|
||||||
|
while( tbeg != tend )
|
||||||
|
{
|
||||||
|
// top vertices
|
||||||
|
aIndexPlane.push_back( (int) tbeg->i1 );
|
||||||
|
aIndexPlane.push_back( (int) tbeg->i2 );
|
||||||
|
aIndexPlane.push_back( (int) tbeg->i3 );
|
||||||
|
|
||||||
|
++tbeg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while( tbeg != tend )
|
||||||
|
{
|
||||||
|
// bottom vertices
|
||||||
|
aIndexPlane.push_back( (int) ( tbeg->i2 ) );
|
||||||
|
aIndexPlane.push_back( (int) ( tbeg->i1 ) );
|
||||||
|
aIndexPlane.push_back( (int) ( tbeg->i3 ) );
|
||||||
|
|
||||||
|
++tbeg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -460,7 +460,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Function Get3DTriangles
|
* Function Get3DTriangles
|
||||||
* Allocates and populates the 3D vertex and index lists with
|
* Allocates and populates the 3D vertex and index lists with
|
||||||
* triangular vertices which may be used for rendering.
|
* triangular vertices which may be used for rendering a volume
|
||||||
*
|
*
|
||||||
* @param aVertexList will store the vertices
|
* @param aVertexList will store the vertices
|
||||||
* @param aIndexPlane will store the indices for the top + bottom planes
|
* @param aIndexPlane will store the indices for the top + bottom planes
|
||||||
|
@ -472,6 +472,19 @@ public:
|
||||||
std::vector< int > &aIndexPlane, std::vector< int > &aIndexSide,
|
std::vector< int > &aIndexPlane, std::vector< int > &aIndexSide,
|
||||||
double aTopZ, double aBotZ );
|
double aTopZ, double aBotZ );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function Get2DTriangles
|
||||||
|
* Allocates and populates the 3D vertex and index lists with
|
||||||
|
* triangular vertices which may be used for rendering a plane
|
||||||
|
*
|
||||||
|
* @param aVertexList will store the vertices
|
||||||
|
* @param aIndexPlane will store the indices for the plane
|
||||||
|
* @param aHeight is the plane of the model
|
||||||
|
* @param aTopPlane is true if the plane is a top plane (false = reverse indices)
|
||||||
|
*/
|
||||||
|
bool Get2DTriangles( std::vector< double >& aVertexList,
|
||||||
|
std::vector< int > &aIndexPlane, double aHeight, bool aTopPlane );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // VRML_LAYER_H
|
#endif // VRML_LAYER_H
|
||||||
|
|
Loading…
Reference in New Issue