basic/geometry/ObjectBase.cpp

Go to the documentation of this file.
00001 //## begin module%36FE7BF30032.cm preserve=no
00002 //        %X% %Q% %Z% %W%
00003 //## end module%36FE7BF30032.cm
00004 
00005 //## begin module%36FE7BF30032.cp preserve=no
00006 //## end module%36FE7BF30032.cp
00007 
00008 //## Module: ObjectBase%36FE7BF30032; Pseudo Package body
00009 //## Source file: E:\mpk\code\geometry\ObjectBase.cpp
00010 
00011 //## begin module%36FE7BF30032.additionalIncludes preserve=no
00012 //## end module%36FE7BF30032.additionalIncludes
00013 
00014 //## begin module%36FE7BF30032.includes preserve=yes
00015 #include <additional/streams/mystreams.h>
00016 #include <geometry/IGS/IGS_Group.h>
00017 #include <geometry/IGS/IGS_MeshTri.h>
00018 //## end module%36FE7BF30032.includes
00019 
00020 // ObjectBase
00021 #include "geometry\ObjectBase.h"
00022 #include "geometry\IGS\IGS_Material.h"
00023 #include "OpenGL\GL_Group.h"
00024 #include "OpenGL\GL_Mesh.h"
00025 #include <stdio.h>
00026 
00027 
00028 ObjectBase::ObjectBase (FrameManager* frameManager)
00029   //## begin ObjectBase::ObjectBase%925235863.hasinit preserve=no
00030   //## end ObjectBase::ObjectBase%925235863.hasinit
00031   //## begin ObjectBase::ObjectBase%925235863.initialization preserve=yes
00032   : Entity( frameManager )
00033   //## end ObjectBase::ObjectBase%925235863.initialization
00034 {
00035   //## begin ObjectBase::ObjectBase%925235863.body preserve=yes
00036   //## end ObjectBase::ObjectBase%925235863.body
00037 }
00038 
00039 ObjectBase::ObjectBase (const ObjectBase& right)
00040   //## begin ObjectBase::ObjectBase%925420849.hasinit preserve=no
00041   //## end ObjectBase::ObjectBase%925420849.hasinit
00042   //## begin ObjectBase::ObjectBase%925420849.initialization preserve=yes
00043   : theFrame( right.theFrame ),
00044         Entity( right )
00045   //## end ObjectBase::ObjectBase%925420849.initialization
00046 {
00047   //## begin ObjectBase::ObjectBase%925420849.body preserve=yes
00048   //## end ObjectBase::ObjectBase%925420849.body
00049 }
00050 
00051 
00052 ObjectBase::~ObjectBase()
00053 {
00054   //## begin ObjectBase::~ObjectBase%.body preserve=yes
00055   //## end ObjectBase::~ObjectBase%.body
00056 }
00057 
00058 //=============================================================================
00059 // Create
00060 //
00061 // Description: creates an object out of an IGS object
00062 //=============================================================================
00063 ObjectBase* ObjectBase::Create(const IGS_Object* right )
00064 {
00065         ObjectBase* returnMe = NULL;
00066         
00067         //check if it is a group
00068         const IGS_Group* igsGroup = dynamic_cast< const IGS_Group* >( right );
00069         if( igsGroup != NULL )
00070         {
00071                 returnMe = new GL_Group( *igsGroup );
00072         }
00073 
00074         //check if it is a mesh of triangles
00075         const IGS_MeshTri* igsMeshTri = dynamic_cast< const IGS_MeshTri* >( right );
00076         if( igsMeshTri != NULL )
00077         {
00078                 returnMe = new GL_Mesh( *igsMeshTri );
00079         }
00080 
00081         //check if it is a material?
00082         const IGS_Material* igsMaterial = dynamic_cast< const IGS_Material* >( right );
00083         if( igsMaterial != NULL )
00084         {
00085                 returnMe = NULL;
00086         return NULL;
00087         }
00088 
00089         //return the MPK object
00090         assert( returnMe != NULL );
00091         return returnMe;
00092 }
00093 
00094 
00095 
00096 //## Other Operations (implementation)
00097 const Matrix4x4& ObjectBase::GetFrame () const
00098 {
00099   //## begin ObjectBase::GetFrame%923117052.body preserve=yes
00100         return theFrame ;
00101   //## end ObjectBase::GetFrame%923117052.body
00102 }
00103 
00104 void ObjectBase::SetFrame (const Matrix4x4& frame)
00105 {
00106   //## begin ObjectBase::SetFrame%923117053.body preserve=yes
00107         theFrame = frame ;
00108   //## end ObjectBase::SetFrame%923117053.body
00109 }
00110 
00111 ObjectBase* ObjectBase::Deserialize (IfstreamWithComments& is)
00112 {
00113   //## begin ObjectBase::Deserialize%945198448.body preserve=yes
00114         //read in the first line
00115         char marker[ 300 ] ;
00116         eatwhite( is ) ;
00117         is.getline( marker, 300 ) ;
00118 
00119         if( stricmp( marker, "#object_group" ) == 0 )
00120         {
00121                 GL_Group* g = new( GL_Group )( NULL ) ;
00122                 g->Deserialize( is ) ;
00123                 return g ;
00124         }
00125 
00126         if( stricmp( marker, "#mesh" ) == 0 )
00127         {
00128                 GL_Mesh* m = new( GL_Mesh )( NULL ) ;
00129                 m->Deserialize( is ) ;
00130                 return m ;
00131         }
00132         
00133 
00134         assert( false ) ;
00135         return NULL ;
00136   //## end ObjectBase::Deserialize%945198448.body
00137 }
00138 
00139 int ObjectBase::TotalPolys() const
00140 {
00141         return 0 ;
00142 }
00143 
00144 void ObjectBase::PrintDebugInfo() const
00145 {
00146     int polys = TotalPolys();
00147     ::printf( "Polys: %d\n", polys );
00148 }

Generated on Sat Apr 1 21:30:33 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO