Loading 3d-viewer/3d_mesh_model.cpp +8 −15 Original line number Original line Diff line number Diff line Loading @@ -68,13 +68,6 @@ S3D_MESH::S3D_MESH() S3D_MESH::~S3D_MESH() S3D_MESH::~S3D_MESH() { { for( unsigned int idx = 0; idx < childs.size(); idx++ ) { if( childs[idx] ) { delete childs[idx]; } } } } Loading 3d-viewer/3d_mesh_model.h +10 −3 Original line number Original line Diff line number Diff line Loading @@ -30,6 +30,8 @@ #ifndef __3D_MESH_MODEL_H__ #ifndef __3D_MESH_MODEL_H__ #define __3D_MESH_MODEL_H__ #define __3D_MESH_MODEL_H__ #include <memory> #include <boost/shared_ptr.hpp> #include <vector> #include <vector> #define GLM_FORCE_RADIANS #define GLM_FORCE_RADIANS #include <gal/opengl/glm/glm.hpp> #include <gal/opengl/glm/glm.hpp> Loading @@ -37,9 +39,14 @@ #include "3d_material.h" #include "3d_material.h" #include "CBBox.h" #include "CBBox.h" class S3D_MESH; class S3D_MESH; /** A smart pointer to an S3D_MESH object */ typedef boost::shared_ptr<S3D_MESH> S3D_MESH_PTR; /** A container of smar S3D_MESH object pointers */ typedef std::vector<S3D_MESH_PTR> S3D_MESH_PTRS; class S3D_MESH class S3D_MESH { { public: public: Loading @@ -60,7 +67,7 @@ public: std::vector< S3D_VERTEX > m_PerFaceNormalsNormalized; std::vector< S3D_VERTEX > m_PerFaceNormalsNormalized; std::vector< S3D_VERTEX > m_PerVertexNormalsNormalized; std::vector< S3D_VERTEX > m_PerVertexNormalsNormalized; std::vector< int > m_MaterialIndex; std::vector< int > m_MaterialIndex; std::vector< S3D_MESH * > childs; S3D_MESH_PTRS childs; S3D_VERTEX m_translation; S3D_VERTEX m_translation; glm::vec4 m_rotation; glm::vec4 m_rotation; Loading 3d-viewer/modelparsers.h +9 −8 Original line number Original line Diff line number Diff line Loading @@ -30,6 +30,7 @@ #define MODELPARSERS_H #define MODELPARSERS_H #include <map> #include <map> #include <memory> #include <vector> #include <vector> #include <wx/string.h> #include <wx/string.h> #include <3d_mesh_model.h> #include <3d_mesh_model.h> Loading Loading @@ -75,7 +76,7 @@ public: return false; return false; }; }; std::vector< S3D_MESH* > childs; S3D_MESH_PTRS childs; private: private: S3D_MASTER* master; S3D_MASTER* master; Loading Loading @@ -127,7 +128,7 @@ public: private: private: wxString m_Filename; wxString m_Filename; S3D_MESH* m_model; S3D_MESH_PTR m_model; std::vector< wxString > vrml_materials; std::vector< wxString > vrml_materials; std::vector< wxString > vrml_points; std::vector< wxString > vrml_points; Loading @@ -143,7 +144,7 @@ private: typedef std::map< std::string, std::vector< glm::vec3 > > VRML2_COORDINATE_MAP; typedef std::map< std::string, std::vector< glm::vec3 > > VRML2_COORDINATE_MAP; typedef std::map< std::string, S3D_MESH* > VRML2_DEF_GROUP_MAP; typedef std::map< std::string, S3D_MESH_PTR > VRML2_DEF_GROUP_MAP; /** /** * class VRML2_MODEL_PARSER * class VRML2_MODEL_PARSER Loading @@ -164,7 +165,7 @@ public: * @param aTransformationModel a model with translation, rotation and scale to apply to default root * @param aTransformationModel a model with translation, rotation and scale to apply to default root * @return bool - true if finnished with success * @return bool - true if finnished with success */ */ bool Load( const wxString& aFilename, S3D_MESH *aTransformationModel ); bool Load( const wxString& aFilename, S3D_MESH_PTR aTransformationModel ); /** /** * Return string representing VRML2 file in vrml2 format * Return string representing VRML2 file in vrml2 format Loading @@ -174,7 +175,7 @@ public: wxString VRML2_representation(); wxString VRML2_representation(); private: private: int loadFileModel( S3D_MESH *transformationModel ); int loadFileModel( S3D_MESH_PTR transformationModel ); int read_Transform(); int read_Transform(); int read_DEF(); int read_DEF(); int read_DEF_Coordinate(); int read_DEF_Coordinate(); Loading Loading @@ -211,7 +212,7 @@ private: bool m_normalPerVertex; bool m_normalPerVertex; bool colorPerVertex; bool colorPerVertex; S3D_MESH* m_model; ///< It stores the current model that the parsing is adding data S3D_MESH_PTR m_model; ///< It stores the current model that the parsing is adding data FILE* m_file; FILE* m_file; wxFileName m_Filename; wxFileName m_Filename; VRML2_COORDINATE_MAP m_defCoordinateMap; VRML2_COORDINATE_MAP m_defCoordinateMap; Loading Loading @@ -266,7 +267,7 @@ private: bool m_normalPerVertex; bool m_normalPerVertex; bool colorPerVertex; bool colorPerVertex; S3D_MESH* m_model; S3D_MESH_PTR m_model; FILE* m_file; FILE* m_file; wxString m_Filename; wxString m_Filename; S3D_MODEL_PARSER* m_ModelParser; S3D_MODEL_PARSER* m_ModelParser; Loading 3d-viewer/vrml_v1_modelparser.cpp +6 −6 Original line number Original line Diff line number Diff line Loading @@ -51,7 +51,7 @@ VRML1_MODEL_PARSER::VRML1_MODEL_PARSER( S3D_MODEL_PARSER* aModelParser ) { { m_ModelParser = aModelParser; m_ModelParser = aModelParser; m_Master = m_ModelParser->GetMaster(); m_Master = m_ModelParser->GetMaster(); m_model = NULL; m_model.reset(); m_file = NULL; m_file = NULL; m_normalPerVertex = true; m_normalPerVertex = true; colorPerVertex = true; colorPerVertex = true; Loading Loading @@ -88,7 +88,7 @@ bool VRML1_MODEL_PARSER::Load( const wxString& aFilename ) if( strcmp( text, "Separator" ) == 0 ) if( strcmp( text, "Separator" ) == 0 ) { { m_model = new S3D_MESH(); m_model.reset( new S3D_MESH() ); m_ModelParser->childs.push_back( m_model ); m_ModelParser->childs.push_back( m_model ); read_separator(); read_separator(); } } Loading Loading @@ -122,18 +122,18 @@ int VRML1_MODEL_PARSER::read_separator() } } else if( strcmp( text, "Separator" ) == 0 ) else if( strcmp( text, "Separator" ) == 0 ) { { S3D_MESH* parent = m_model; S3D_MESH_PTR parent( m_model.get() ); S3D_MESH* new_mesh_model = new S3D_MESH(); S3D_MESH_PTR new_mesh_model( new S3D_MESH() ); m_model->childs.push_back( new_mesh_model ); m_model->childs.push_back( new_mesh_model ); m_model = new_mesh_model; m_model.reset( new_mesh_model.get() ); // recursive // recursive read_separator(); read_separator(); m_model = parent; m_model.reset( parent.get() ); } } else if( ( *text != '}' ) ) else if( ( *text != '}' ) ) { { Loading 3d-viewer/vrml_v2_modelparser.cpp +39 −39 Original line number Original line Diff line number Diff line Loading @@ -54,7 +54,7 @@ VRML2_MODEL_PARSER::VRML2_MODEL_PARSER( S3D_MODEL_PARSER* aModelParser ) { { m_ModelParser = aModelParser; m_ModelParser = aModelParser; m_Master = m_ModelParser->GetMaster(); m_Master = m_ModelParser->GetMaster(); m_model = NULL; m_model.reset(); m_file = NULL; m_file = NULL; m_normalPerVertex = true; m_normalPerVertex = true; colorPerVertex = true; colorPerVertex = true; Loading Loading @@ -98,7 +98,7 @@ bool VRML2_MODEL_PARSER::Load( const wxString& aFilename ) // Switch the locale to standard C (needed to print floating point numbers) // Switch the locale to standard C (needed to print floating point numbers) LOCALE_IO toggle; LOCALE_IO toggle; loadFileModel( NULL ); loadFileModel( S3D_MESH_PTR() ); fclose( m_file ); fclose( m_file ); Loading @@ -107,7 +107,7 @@ bool VRML2_MODEL_PARSER::Load( const wxString& aFilename ) } } bool VRML2_MODEL_PARSER::Load( const wxString& aFilename, S3D_MESH *aTransformationModel ) bool VRML2_MODEL_PARSER::Load( const wxString& aFilename, S3D_MESH_PTR aTransformationModel ) { { if( aTransformationModel ) if( aTransformationModel ) { { Loading Loading @@ -141,7 +141,7 @@ bool VRML2_MODEL_PARSER::Load( const wxString& aFilename, S3D_MESH *aTransformat } } int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH_PTR aTransformationModel ) { { char text[BUFLINE_SIZE]; char text[BUFLINE_SIZE]; Loading @@ -156,9 +156,9 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) if( strcmp( text, "Transform" ) == 0 ) if( strcmp( text, "Transform" ) == 0 ) { { m_model = new S3D_MESH(); m_model.reset( new S3D_MESH() ); S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr( m_model ); if( read_Transform() == 0 ) if( read_Transform() == 0 ) { { Loading @@ -167,12 +167,12 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); } } else else { { if( aTransformationModel ) if( aTransformationModel.get() != NULL ) { { m_model->m_translation = aTransformationModel->m_translation; m_model->m_translation = aTransformationModel->m_translation; m_model->m_rotation = aTransformationModel->m_rotation; m_model->m_rotation = aTransformationModel->m_rotation; Loading @@ -187,14 +187,14 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) } } else else { { delete m_model; m_model.reset(); } } } } else if( strcmp( text, "DEF" ) == 0 ) else if( strcmp( text, "DEF" ) == 0 ) { { m_model = new S3D_MESH(); m_model.reset( new S3D_MESH() ); S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr( m_model ); if( read_DEF() == 0 ) if( read_DEF() == 0 ) { { Loading @@ -203,12 +203,12 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); } } else else { { if( aTransformationModel ) if( aTransformationModel.get() != NULL ) { { m_model->m_translation = aTransformationModel->m_translation; m_model->m_translation = aTransformationModel->m_translation; m_model->m_rotation = aTransformationModel->m_rotation; m_model->m_rotation = aTransformationModel->m_rotation; Loading @@ -223,14 +223,14 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) } } else else { { delete m_model; m_model.reset(); } } } } else if( strcmp( text, "Shape" ) == 0 ) else if( strcmp( text, "Shape" ) == 0 ) { { m_model = new S3D_MESH(); m_model.reset( new S3D_MESH() ); S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr = m_model; if( read_Shape() == 0 ) if( read_Shape() == 0 ) { { Loading @@ -239,12 +239,12 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); } } else else { { if( aTransformationModel ) if( aTransformationModel.get() != NULL ) { { m_model->m_translation = aTransformationModel->m_translation; m_model->m_translation = aTransformationModel->m_translation; m_model->m_rotation = aTransformationModel->m_rotation; m_model->m_rotation = aTransformationModel->m_rotation; Loading @@ -261,7 +261,7 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) } } else else { { delete m_model; m_model.reset(); } } } } } } Loading @@ -279,7 +279,7 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) for( VRML2_DEF_GROUP_MAP::iterator groupIt = m_defGroupMap.begin(); groupIt!=m_defGroupMap.end(); ++groupIt ) for( VRML2_DEF_GROUP_MAP::iterator groupIt = m_defGroupMap.begin(); groupIt!=m_defGroupMap.end(); ++groupIt ) { { wxString groupName = groupIt->first; wxString groupName = groupIt->first; S3D_MESH* ptrModel = groupIt->second; S3D_MESH_PTR ptrModel( groupIt->second ); if( ((ptrModel->m_Point.size() == 0) || (ptrModel->m_CoordIndex.size() == 0)) && if( ((ptrModel->m_Point.size() == 0) || (ptrModel->m_CoordIndex.size() == 0)) && Loading Loading @@ -326,9 +326,9 @@ int VRML2_MODEL_PARSER::read_Transform() if( strcmp( text, "Transform" ) == 0 ) if( strcmp( text, "Transform" ) == 0 ) { { m_model = new S3D_MESH(); m_model.reset( new S3D_MESH() ); S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr( m_model ); if( read_Transform() == 0 ) if( read_Transform() == 0 ) { { Loading @@ -337,7 +337,7 @@ int VRML2_MODEL_PARSER::read_Transform() if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: skipping model with no points or childs" ) ); } } else else Loading @@ -352,7 +352,7 @@ int VRML2_MODEL_PARSER::read_Transform() } } else else { { delete m_model; m_model.reset(); } } } } else if( strcmp( text, "translation" ) == 0 ) else if( strcmp( text, "translation" ) == 0 ) Loading Loading @@ -463,14 +463,14 @@ int VRML2_MODEL_PARSER::read_Transform() else if( strcmp( text, "Shape" ) == 0 ) else if( strcmp( text, "Shape" ) == 0 ) { { // Save the pointer // Save the pointer S3D_MESH* parent = m_model; S3D_MESH_PTR parent( m_model ); S3D_MESH* new_mesh_model = new S3D_MESH(); S3D_MESH_PTR new_mesh_model( new S3D_MESH() ); // Assign the current pointer // Assign the current pointer m_model = new_mesh_model; m_model = new_mesh_model; S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr = m_model; if( read_Shape() == 0 ) if( read_Shape() == 0 ) { { Loading @@ -481,7 +481,7 @@ int VRML2_MODEL_PARSER::read_Transform() if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: Shape, skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: Shape, skipping model with no points or childs" ) ); } } else else Loading @@ -496,14 +496,14 @@ int VRML2_MODEL_PARSER::read_Transform() } } else else { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: Shape, discard child." ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: Shape, discard child." ) ); } } } } else else { { delete m_model; m_model.reset(); } } m_model = parent; m_model = parent; Loading Loading @@ -540,7 +540,7 @@ int VRML2_MODEL_PARSER::read_Transform() return -1; return -1; } } S3D_MESH* ptrModel = groupIt->second; S3D_MESH_PTR ptrModel( groupIt->second ); if( ((ptrModel->m_Point.size() == 0) || (ptrModel->m_CoordIndex.size() == 0)) && if( ((ptrModel->m_Point.size() == 0) || (ptrModel->m_CoordIndex.size() == 0)) && (ptrModel->childs.size() == 0) ) (ptrModel->childs.size() == 0) ) Loading Loading @@ -778,14 +778,14 @@ int VRML2_MODEL_PARSER::read_DEF() wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "Shape" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "Shape" ) ); // Save the pointer // Save the pointer S3D_MESH* parent = m_model; S3D_MESH_PTR parent = m_model; S3D_MESH* new_mesh_model = new S3D_MESH(); S3D_MESH_PTR new_mesh_model( new S3D_MESH() ); // Assign the current pointer // Assign the current pointer m_model = new_mesh_model; m_model = new_mesh_model; S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr = m_model; if( read_Shape() == 0 ) if( read_Shape() == 0 ) { { Loading @@ -794,7 +794,7 @@ int VRML2_MODEL_PARSER::read_DEF() if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_DEF: Shape, skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_DEF: Shape, skipping model with no points or childs" ) ); } } else else Loading @@ -809,7 +809,7 @@ int VRML2_MODEL_PARSER::read_DEF() } } else else { { delete m_model; m_model.reset(); } } m_model = parent; m_model = parent; Loading @@ -824,9 +824,9 @@ int VRML2_MODEL_PARSER::read_DEF() wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "Group %s" ), tagName ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "Group %s" ), tagName ); // Save the pointer // Save the pointer S3D_MESH* parent = m_model; S3D_MESH_PTR parent = m_model; S3D_MESH* new_mesh_model = new S3D_MESH(); S3D_MESH_PTR new_mesh_model( new S3D_MESH() ); // Assign the current pointer // Assign the current pointer m_model = new_mesh_model; m_model = new_mesh_model; Loading @@ -848,7 +848,7 @@ int VRML2_MODEL_PARSER::read_DEF() } } else else { { delete m_model; m_model.reset(); } } // Restore current model pointer // Restore current model pointer Loading Loading
3d-viewer/3d_mesh_model.cpp +8 −15 Original line number Original line Diff line number Diff line Loading @@ -68,13 +68,6 @@ S3D_MESH::S3D_MESH() S3D_MESH::~S3D_MESH() S3D_MESH::~S3D_MESH() { { for( unsigned int idx = 0; idx < childs.size(); idx++ ) { if( childs[idx] ) { delete childs[idx]; } } } } Loading
3d-viewer/3d_mesh_model.h +10 −3 Original line number Original line Diff line number Diff line Loading @@ -30,6 +30,8 @@ #ifndef __3D_MESH_MODEL_H__ #ifndef __3D_MESH_MODEL_H__ #define __3D_MESH_MODEL_H__ #define __3D_MESH_MODEL_H__ #include <memory> #include <boost/shared_ptr.hpp> #include <vector> #include <vector> #define GLM_FORCE_RADIANS #define GLM_FORCE_RADIANS #include <gal/opengl/glm/glm.hpp> #include <gal/opengl/glm/glm.hpp> Loading @@ -37,9 +39,14 @@ #include "3d_material.h" #include "3d_material.h" #include "CBBox.h" #include "CBBox.h" class S3D_MESH; class S3D_MESH; /** A smart pointer to an S3D_MESH object */ typedef boost::shared_ptr<S3D_MESH> S3D_MESH_PTR; /** A container of smar S3D_MESH object pointers */ typedef std::vector<S3D_MESH_PTR> S3D_MESH_PTRS; class S3D_MESH class S3D_MESH { { public: public: Loading @@ -60,7 +67,7 @@ public: std::vector< S3D_VERTEX > m_PerFaceNormalsNormalized; std::vector< S3D_VERTEX > m_PerFaceNormalsNormalized; std::vector< S3D_VERTEX > m_PerVertexNormalsNormalized; std::vector< S3D_VERTEX > m_PerVertexNormalsNormalized; std::vector< int > m_MaterialIndex; std::vector< int > m_MaterialIndex; std::vector< S3D_MESH * > childs; S3D_MESH_PTRS childs; S3D_VERTEX m_translation; S3D_VERTEX m_translation; glm::vec4 m_rotation; glm::vec4 m_rotation; Loading
3d-viewer/modelparsers.h +9 −8 Original line number Original line Diff line number Diff line Loading @@ -30,6 +30,7 @@ #define MODELPARSERS_H #define MODELPARSERS_H #include <map> #include <map> #include <memory> #include <vector> #include <vector> #include <wx/string.h> #include <wx/string.h> #include <3d_mesh_model.h> #include <3d_mesh_model.h> Loading Loading @@ -75,7 +76,7 @@ public: return false; return false; }; }; std::vector< S3D_MESH* > childs; S3D_MESH_PTRS childs; private: private: S3D_MASTER* master; S3D_MASTER* master; Loading Loading @@ -127,7 +128,7 @@ public: private: private: wxString m_Filename; wxString m_Filename; S3D_MESH* m_model; S3D_MESH_PTR m_model; std::vector< wxString > vrml_materials; std::vector< wxString > vrml_materials; std::vector< wxString > vrml_points; std::vector< wxString > vrml_points; Loading @@ -143,7 +144,7 @@ private: typedef std::map< std::string, std::vector< glm::vec3 > > VRML2_COORDINATE_MAP; typedef std::map< std::string, std::vector< glm::vec3 > > VRML2_COORDINATE_MAP; typedef std::map< std::string, S3D_MESH* > VRML2_DEF_GROUP_MAP; typedef std::map< std::string, S3D_MESH_PTR > VRML2_DEF_GROUP_MAP; /** /** * class VRML2_MODEL_PARSER * class VRML2_MODEL_PARSER Loading @@ -164,7 +165,7 @@ public: * @param aTransformationModel a model with translation, rotation and scale to apply to default root * @param aTransformationModel a model with translation, rotation and scale to apply to default root * @return bool - true if finnished with success * @return bool - true if finnished with success */ */ bool Load( const wxString& aFilename, S3D_MESH *aTransformationModel ); bool Load( const wxString& aFilename, S3D_MESH_PTR aTransformationModel ); /** /** * Return string representing VRML2 file in vrml2 format * Return string representing VRML2 file in vrml2 format Loading @@ -174,7 +175,7 @@ public: wxString VRML2_representation(); wxString VRML2_representation(); private: private: int loadFileModel( S3D_MESH *transformationModel ); int loadFileModel( S3D_MESH_PTR transformationModel ); int read_Transform(); int read_Transform(); int read_DEF(); int read_DEF(); int read_DEF_Coordinate(); int read_DEF_Coordinate(); Loading Loading @@ -211,7 +212,7 @@ private: bool m_normalPerVertex; bool m_normalPerVertex; bool colorPerVertex; bool colorPerVertex; S3D_MESH* m_model; ///< It stores the current model that the parsing is adding data S3D_MESH_PTR m_model; ///< It stores the current model that the parsing is adding data FILE* m_file; FILE* m_file; wxFileName m_Filename; wxFileName m_Filename; VRML2_COORDINATE_MAP m_defCoordinateMap; VRML2_COORDINATE_MAP m_defCoordinateMap; Loading Loading @@ -266,7 +267,7 @@ private: bool m_normalPerVertex; bool m_normalPerVertex; bool colorPerVertex; bool colorPerVertex; S3D_MESH* m_model; S3D_MESH_PTR m_model; FILE* m_file; FILE* m_file; wxString m_Filename; wxString m_Filename; S3D_MODEL_PARSER* m_ModelParser; S3D_MODEL_PARSER* m_ModelParser; Loading
3d-viewer/vrml_v1_modelparser.cpp +6 −6 Original line number Original line Diff line number Diff line Loading @@ -51,7 +51,7 @@ VRML1_MODEL_PARSER::VRML1_MODEL_PARSER( S3D_MODEL_PARSER* aModelParser ) { { m_ModelParser = aModelParser; m_ModelParser = aModelParser; m_Master = m_ModelParser->GetMaster(); m_Master = m_ModelParser->GetMaster(); m_model = NULL; m_model.reset(); m_file = NULL; m_file = NULL; m_normalPerVertex = true; m_normalPerVertex = true; colorPerVertex = true; colorPerVertex = true; Loading Loading @@ -88,7 +88,7 @@ bool VRML1_MODEL_PARSER::Load( const wxString& aFilename ) if( strcmp( text, "Separator" ) == 0 ) if( strcmp( text, "Separator" ) == 0 ) { { m_model = new S3D_MESH(); m_model.reset( new S3D_MESH() ); m_ModelParser->childs.push_back( m_model ); m_ModelParser->childs.push_back( m_model ); read_separator(); read_separator(); } } Loading Loading @@ -122,18 +122,18 @@ int VRML1_MODEL_PARSER::read_separator() } } else if( strcmp( text, "Separator" ) == 0 ) else if( strcmp( text, "Separator" ) == 0 ) { { S3D_MESH* parent = m_model; S3D_MESH_PTR parent( m_model.get() ); S3D_MESH* new_mesh_model = new S3D_MESH(); S3D_MESH_PTR new_mesh_model( new S3D_MESH() ); m_model->childs.push_back( new_mesh_model ); m_model->childs.push_back( new_mesh_model ); m_model = new_mesh_model; m_model.reset( new_mesh_model.get() ); // recursive // recursive read_separator(); read_separator(); m_model = parent; m_model.reset( parent.get() ); } } else if( ( *text != '}' ) ) else if( ( *text != '}' ) ) { { Loading
3d-viewer/vrml_v2_modelparser.cpp +39 −39 Original line number Original line Diff line number Diff line Loading @@ -54,7 +54,7 @@ VRML2_MODEL_PARSER::VRML2_MODEL_PARSER( S3D_MODEL_PARSER* aModelParser ) { { m_ModelParser = aModelParser; m_ModelParser = aModelParser; m_Master = m_ModelParser->GetMaster(); m_Master = m_ModelParser->GetMaster(); m_model = NULL; m_model.reset(); m_file = NULL; m_file = NULL; m_normalPerVertex = true; m_normalPerVertex = true; colorPerVertex = true; colorPerVertex = true; Loading Loading @@ -98,7 +98,7 @@ bool VRML2_MODEL_PARSER::Load( const wxString& aFilename ) // Switch the locale to standard C (needed to print floating point numbers) // Switch the locale to standard C (needed to print floating point numbers) LOCALE_IO toggle; LOCALE_IO toggle; loadFileModel( NULL ); loadFileModel( S3D_MESH_PTR() ); fclose( m_file ); fclose( m_file ); Loading @@ -107,7 +107,7 @@ bool VRML2_MODEL_PARSER::Load( const wxString& aFilename ) } } bool VRML2_MODEL_PARSER::Load( const wxString& aFilename, S3D_MESH *aTransformationModel ) bool VRML2_MODEL_PARSER::Load( const wxString& aFilename, S3D_MESH_PTR aTransformationModel ) { { if( aTransformationModel ) if( aTransformationModel ) { { Loading Loading @@ -141,7 +141,7 @@ bool VRML2_MODEL_PARSER::Load( const wxString& aFilename, S3D_MESH *aTransformat } } int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH_PTR aTransformationModel ) { { char text[BUFLINE_SIZE]; char text[BUFLINE_SIZE]; Loading @@ -156,9 +156,9 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) if( strcmp( text, "Transform" ) == 0 ) if( strcmp( text, "Transform" ) == 0 ) { { m_model = new S3D_MESH(); m_model.reset( new S3D_MESH() ); S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr( m_model ); if( read_Transform() == 0 ) if( read_Transform() == 0 ) { { Loading @@ -167,12 +167,12 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); } } else else { { if( aTransformationModel ) if( aTransformationModel.get() != NULL ) { { m_model->m_translation = aTransformationModel->m_translation; m_model->m_translation = aTransformationModel->m_translation; m_model->m_rotation = aTransformationModel->m_rotation; m_model->m_rotation = aTransformationModel->m_rotation; Loading @@ -187,14 +187,14 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) } } else else { { delete m_model; m_model.reset(); } } } } else if( strcmp( text, "DEF" ) == 0 ) else if( strcmp( text, "DEF" ) == 0 ) { { m_model = new S3D_MESH(); m_model.reset( new S3D_MESH() ); S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr( m_model ); if( read_DEF() == 0 ) if( read_DEF() == 0 ) { { Loading @@ -203,12 +203,12 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); } } else else { { if( aTransformationModel ) if( aTransformationModel.get() != NULL ) { { m_model->m_translation = aTransformationModel->m_translation; m_model->m_translation = aTransformationModel->m_translation; m_model->m_rotation = aTransformationModel->m_rotation; m_model->m_rotation = aTransformationModel->m_rotation; Loading @@ -223,14 +223,14 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) } } else else { { delete m_model; m_model.reset(); } } } } else if( strcmp( text, "Shape" ) == 0 ) else if( strcmp( text, "Shape" ) == 0 ) { { m_model = new S3D_MESH(); m_model.reset( new S3D_MESH() ); S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr = m_model; if( read_Shape() == 0 ) if( read_Shape() == 0 ) { { Loading @@ -239,12 +239,12 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "loadFileModel: skipping model with no points or childs" ) ); } } else else { { if( aTransformationModel ) if( aTransformationModel.get() != NULL ) { { m_model->m_translation = aTransformationModel->m_translation; m_model->m_translation = aTransformationModel->m_translation; m_model->m_rotation = aTransformationModel->m_rotation; m_model->m_rotation = aTransformationModel->m_rotation; Loading @@ -261,7 +261,7 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) } } else else { { delete m_model; m_model.reset(); } } } } } } Loading @@ -279,7 +279,7 @@ int VRML2_MODEL_PARSER::loadFileModel( S3D_MESH *aTransformationModel ) for( VRML2_DEF_GROUP_MAP::iterator groupIt = m_defGroupMap.begin(); groupIt!=m_defGroupMap.end(); ++groupIt ) for( VRML2_DEF_GROUP_MAP::iterator groupIt = m_defGroupMap.begin(); groupIt!=m_defGroupMap.end(); ++groupIt ) { { wxString groupName = groupIt->first; wxString groupName = groupIt->first; S3D_MESH* ptrModel = groupIt->second; S3D_MESH_PTR ptrModel( groupIt->second ); if( ((ptrModel->m_Point.size() == 0) || (ptrModel->m_CoordIndex.size() == 0)) && if( ((ptrModel->m_Point.size() == 0) || (ptrModel->m_CoordIndex.size() == 0)) && Loading Loading @@ -326,9 +326,9 @@ int VRML2_MODEL_PARSER::read_Transform() if( strcmp( text, "Transform" ) == 0 ) if( strcmp( text, "Transform" ) == 0 ) { { m_model = new S3D_MESH(); m_model.reset( new S3D_MESH() ); S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr( m_model ); if( read_Transform() == 0 ) if( read_Transform() == 0 ) { { Loading @@ -337,7 +337,7 @@ int VRML2_MODEL_PARSER::read_Transform() if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: skipping model with no points or childs" ) ); } } else else Loading @@ -352,7 +352,7 @@ int VRML2_MODEL_PARSER::read_Transform() } } else else { { delete m_model; m_model.reset(); } } } } else if( strcmp( text, "translation" ) == 0 ) else if( strcmp( text, "translation" ) == 0 ) Loading Loading @@ -463,14 +463,14 @@ int VRML2_MODEL_PARSER::read_Transform() else if( strcmp( text, "Shape" ) == 0 ) else if( strcmp( text, "Shape" ) == 0 ) { { // Save the pointer // Save the pointer S3D_MESH* parent = m_model; S3D_MESH_PTR parent( m_model ); S3D_MESH* new_mesh_model = new S3D_MESH(); S3D_MESH_PTR new_mesh_model( new S3D_MESH() ); // Assign the current pointer // Assign the current pointer m_model = new_mesh_model; m_model = new_mesh_model; S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr = m_model; if( read_Shape() == 0 ) if( read_Shape() == 0 ) { { Loading @@ -481,7 +481,7 @@ int VRML2_MODEL_PARSER::read_Transform() if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: Shape, skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: Shape, skipping model with no points or childs" ) ); } } else else Loading @@ -496,14 +496,14 @@ int VRML2_MODEL_PARSER::read_Transform() } } else else { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: Shape, discard child." ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_Transform: Shape, discard child." ) ); } } } } else else { { delete m_model; m_model.reset(); } } m_model = parent; m_model = parent; Loading Loading @@ -540,7 +540,7 @@ int VRML2_MODEL_PARSER::read_Transform() return -1; return -1; } } S3D_MESH* ptrModel = groupIt->second; S3D_MESH_PTR ptrModel( groupIt->second ); if( ((ptrModel->m_Point.size() == 0) || (ptrModel->m_CoordIndex.size() == 0)) && if( ((ptrModel->m_Point.size() == 0) || (ptrModel->m_CoordIndex.size() == 0)) && (ptrModel->childs.size() == 0) ) (ptrModel->childs.size() == 0) ) Loading Loading @@ -778,14 +778,14 @@ int VRML2_MODEL_PARSER::read_DEF() wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "Shape" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "Shape" ) ); // Save the pointer // Save the pointer S3D_MESH* parent = m_model; S3D_MESH_PTR parent = m_model; S3D_MESH* new_mesh_model = new S3D_MESH(); S3D_MESH_PTR new_mesh_model( new S3D_MESH() ); // Assign the current pointer // Assign the current pointer m_model = new_mesh_model; m_model = new_mesh_model; S3D_MESH* save_ptr = m_model; S3D_MESH_PTR save_ptr = m_model; if( read_Shape() == 0 ) if( read_Shape() == 0 ) { { Loading @@ -794,7 +794,7 @@ int VRML2_MODEL_PARSER::read_DEF() if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && if( ((m_model->m_Point.size() == 0) || (m_model->m_CoordIndex.size() == 0)) && (m_model->childs.size() == 0) ) (m_model->childs.size() == 0) ) { { delete m_model; m_model.reset(); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_DEF: Shape, skipping model with no points or childs" ) ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "read_DEF: Shape, skipping model with no points or childs" ) ); } } else else Loading @@ -809,7 +809,7 @@ int VRML2_MODEL_PARSER::read_DEF() } } else else { { delete m_model; m_model.reset(); } } m_model = parent; m_model = parent; Loading @@ -824,9 +824,9 @@ int VRML2_MODEL_PARSER::read_DEF() wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "Group %s" ), tagName ); wxLogTrace( traceVrmlV2Parser, m_debugSpacer + wxT( "Group %s" ), tagName ); // Save the pointer // Save the pointer S3D_MESH* parent = m_model; S3D_MESH_PTR parent = m_model; S3D_MESH* new_mesh_model = new S3D_MESH(); S3D_MESH_PTR new_mesh_model( new S3D_MESH() ); // Assign the current pointer // Assign the current pointer m_model = new_mesh_model; m_model = new_mesh_model; Loading @@ -848,7 +848,7 @@ int VRML2_MODEL_PARSER::read_DEF() } } else else { { delete m_model; m_model.reset(); } } // Restore current model pointer // Restore current model pointer Loading