Biomechanical Joint Model
 Author: Anderson Maciel

comexml.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2002 by Anderson Maciel                                 *
00003  *   andi.maciel@gmail.com                                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  **************************************************************************/
00020 
00022 //
00023 //  PROJECT.....: CO-ME
00024 //  RESPONSIBLE.: 
00025 //
00026 //  FILE........: comexml.h
00027 //  DESCRIPTION.: Contain the COME_Xml class declarations.
00028 //
00029 //  AUTHOR......: Anderson Maciel
00030 //  DATE........: September/10/2002
00031 //  DESCRIPTION.: Class and new methods declaration.
00032 //
00034 
00035 #ifndef __COME_XML_H
00036 #define __COME_XML_H
00037 
00038 #include        <general/come.h>
00039 #include        <bio/comematerial.h>
00040 #include        <bio/comepatient.h>
00041 #include        <bio/comebiostructure.h>
00042 #include        <physics/comeforce.h>
00043 
00044 #include        <xercesc/util/XercesDefs.hpp>
00045 #include        <xercesc/util/PlatformUtils.hpp>
00046 #include        <xercesc/sax/SAXException.hpp>
00047 #include        <xercesc/sax/SAXParseException.hpp>
00048 #include        <xercesc/parsers/XercesDOMParser.hpp>
00049 #include        <xercesc/dom/DOM.hpp>
00050 
00051 using namespace XERCES_CPP_NAMESPACE;
00052 
00053 #ifndef __COME_SIMULATOR_H      
00054 class COME_Simulator;
00055 #endif
00056 
00057 #define ROOT_PARTS "ilium|lunate|laburum"
00058 #define HIP_PARTS "femur|femoralcap|iliofemoral|ischiofemoral|pubofemoral|teres|transverse|capsular"
00059 
00060 class COME_Xml : public COME {
00061 
00062         private:
00063                 vector<COME_Material*>* materials;
00064                 DOMElement      *root;
00065                 COME_Simulator  *simulatorXml;
00066 
00067                 COME_Dof        **auxVec; 
00068                 int             iIndDofAux; 
00069 
00070         protected:              
00071                 COME_BioStructure *     loadMoleculeOrgan( DOMNode *node );             
00072                 void                    loadMaterials( DOMNodeList *node );             
00073 
00074                 void    saveMoleculeOrgan( DOMDocument *doc, DOMElement *jointNode, COME_Patient patient );
00075                 void    saveMaterials( DOMDocument *doc, DOMElement *patientNode, COME_Patient patient );
00076 
00077                 COME_Joint*                     loadJoint( DOMNode *node, COME_Joint *parent, list<COME_BioStructure*> &patientOrganList );
00078                 COME_Dof*                       loadDofs( DOMNodeList *list );
00079                 vector<COME_BioStructure*>      loadShapes( DOMNodeList *list );
00080                 void                            loadModifiers( DOMNodeList *joints );
00081 
00082         public:
00083                 COME_Xml();
00084                 COME_Xml( vector<COME_Material*>* existentMaterials );
00085                 ~COME_Xml();
00086                 
00087                 vector<COME_Material*>* getAllMaterials();
00088 
00089                 void    loadSceneFile( string file_name, list<COME_Patient*> &patientL, COME_Simulator *simulator, COME_Scenario *parentScene );
00090                 void    loadMaterialsFile( string file_name, list<COME_Patient*> &patientL, COME_Simulator *simulator, COME_Scenario *parentScene );
00091                 COME_BioStructure* loadOrganFile( string file_name, list<COME_Patient*> &patientL, COME_Simulator *simulator, COME_Scenario *parentScene );
00092                 
00093                 int     saveSceneFile( string file_name, const list<COME_Patient*> &patientL, COME_Simulator *simulator );
00094                 void    saveSurface( COME_Mesh *mesh, string f_name );
00095                 int     saveAnimationFile( string file_name, const list<COME_Patient*> &patientL, COME_Simulator *simulator);
00096                 void    saveOrgansAnimation( DOMDocument *doc, DOMElement *organsNode, COME_Patient *patient );
00097                 void    saveJointsAnimation( DOMDocument *doc, DOMElement *jointsNode, COME_Joint *currJoint );
00098 
00099                 int             loadIntegrationFile( string fileName, list<COME_Patient*> &patientL, COME_Simulator *simulator, COME_Scenario *parentScene );
00100                 void    loadMaterialsFromOrganFile( string fileName );
00101                 int             exportIntegrationFile( string file_name, const list<COME_Patient*> &patientL, COME_Simulator *simulator);
00102                 void    saveJointOrgans( DOMDocument *doc, DOMElement *jointNode, COME_Joint *jointThis );
00103 };
00104 
00105 
00106 #include <xercesc/sax/ErrorHandler.hpp>
00107 
00108 //class SAXParseException;
00109 
00110 
00111 // ---------------------------------------------------------------------------
00112 //  Simple error handler deriviative to install on parser
00113 // ---------------------------------------------------------------------------
00114 class DOMCountErrorHandler : public ErrorHandler
00115 {
00116 public:
00117     // -----------------------------------------------------------------------
00118     //  Constructors and Destructor
00119     // -----------------------------------------------------------------------
00120     DOMCountErrorHandler();
00121     ~DOMCountErrorHandler();
00122 
00123 
00124     // -----------------------------------------------------------------------
00125     //  Getter methods
00126     // -----------------------------------------------------------------------
00127     bool getSawErrors() const;
00128 
00129 
00130     // -----------------------------------------------------------------------
00131     //  Implementation of the SAX ErrorHandler interface
00132     // -----------------------------------------------------------------------
00133     void warning(const SAXParseException& e);
00134     void error(const SAXParseException& e);
00135     void fatalError(const SAXParseException& e);
00136     void resetErrors();
00137 
00138 
00139 private :
00140     // -----------------------------------------------------------------------
00141     //  Unimplemented constructors and operators
00142     // -----------------------------------------------------------------------
00143     DOMCountErrorHandler(const DOMCountErrorHandler&);
00144     void operator=(const DOMCountErrorHandler&);
00145 
00146 
00147     // -----------------------------------------------------------------------
00148     //  Private data members
00149     //
00150     //  fSawErrors
00151     //      This is set if we get any errors, and is queryable via a getter
00152     //      method. Its used by the main code to suppress output if there are
00153     //      errors.
00154     // -----------------------------------------------------------------------
00155     bool    fSawErrors;
00156 };
00157 
00158 
00159 // ---------------------------------------------------------------------------
00160 //  This is a simple class that lets us do easy (though not terribly efficient)
00161 //  trancoding of XMLCh data to local code page for display.
00162 // ---------------------------------------------------------------------------
00163 class StrX
00164 {
00165 public :
00166     // -----------------------------------------------------------------------
00167     //  Constructors and Destructor
00168     // -----------------------------------------------------------------------
00169     StrX(const XMLCh* const toTranscode)
00170     {
00171         // Call the private transcoding method
00172         fLocalForm = XMLString::transcode(toTranscode);
00173     }//DOM
00174 
00175     ~StrX()
00176     {
00177         delete [] fLocalForm;
00178     }
00179 
00180 
00181     // -----------------------------------------------------------------------
00182     //  Getter methods
00183     // -----------------------------------------------------------------------
00184     const char* localForm() const
00185     {
00186         return fLocalForm;
00187     }
00188 
00189 private :
00190     // -----------------------------------------------------------------------
00191     //  Private data members
00192     //
00193     //  fLocalForm
00194     //      This is the local code page form of the string.
00195     // -----------------------------------------------------------------------
00196     char*   fLocalForm;
00197 };
00198 
00199 
00200 
00201 #endif

Generated on Thu Dec 1 10:13:37 2005 for COME - Biomechanical Joint Model by  doxygen 1.4.5