xsi_shape.h Source File
 
 
 
xsi_shape.h
Go to the documentation of this file.
00001 //*****************************************************************************
00011 //*****************************************************************************
00012 
00013 #if (_MSC_VER > 1000) || defined(SGI_COMPILER)
00014 #pragma once
00015 #endif
00016 
00017 #ifndef __XSISHAPE_H__
00018 #define __XSISHAPE_H__
00019 
00020 #include "sicppsdk.h"
00021 #include <xsi_decl.h>
00022 
00023 namespace XSI {
00024 
00025 namespace MATH {
00026 
00027 //*****************************************************************************
00238 //*****************************************************************************
00239 class CShape
00240 {
00241 public:
00246         struct ParameterInstance
00247         {
00248                 bool operator==( const ParameterInstance& in_rOther ) const
00249                 {
00250                         return m_nInstanceIndex == in_rOther.m_nInstanceIndex;
00251                 }
00252                 ULONG m_nInstanceIndex;
00253         };
00254 
00259         struct ParameterReference
00260         {
00261                 bool operator==( const ParameterReference& in_rOther ) const
00262                 {
00263                         return m_nObjectID == in_rOther.m_nObjectID && m_bBranch == in_rOther.m_bBranch;
00264                 }
00265                 ULONG m_nObjectID;
00266                 bool m_bBranch;
00267         };
00268 
00272         CShape( XSI::siICEShapeType in_type = XSI::siICEShapePoint ) : m_type( in_type )
00273         {
00274         }
00275 
00279         CShape( const CShape& in_shape )
00280         {
00281                 *this = in_shape;
00282         }
00283 
00285         ~CShape() {}
00286 
00291         CShape& operator = ( const CShape& in_shape )
00292         {
00293                 m_type = in_shape.m_type;
00294                 switch ( m_type )
00295                 {
00296                         case XSI::siICEShapeInstance:
00297                         {
00298                                 m_description.m_shapeInstance = in_shape.m_description.m_shapeInstance;
00299                         }
00300                         break;
00301 
00302                         case XSI::siICEShapeReference:
00303                         {
00304                                 m_description.m_shapeReference = in_shape.m_description.m_shapeReference;
00305                         }
00306                         break;
00307                 };
00308                 return *this;
00309         }
00310 
00314         XSI::siICEShapeType GetType()
00315         {
00316                 return (XSI::siICEShapeType)m_type;
00317         }
00318 
00323         ULONG GetReferenceID( )
00324         {
00325                 if ( m_type == XSI::siICEShapeReference )
00326                 {
00327                         return m_description.m_shapeReference.m_nObjectID;
00328                 }
00329                 return UINT_MAX;
00330         }
00331 
00336         bool IsBranchSelected( )
00337         {
00338                 if ( m_type == XSI::siICEShapeReference )
00339                 {
00340                         return m_description.m_shapeReference.m_bBranch;
00341                 }
00342                 return false;
00343         }
00344 
00349         bool operator == (const CShape & in_shape )const
00350         {
00351                 if( m_type != in_shape.m_type )
00352                 {
00353                         return false;
00354                 }
00355 
00356                 switch( m_type )
00357                 {
00358                         case XSI::siICEShapeInstance:
00359                         {
00360                                 return m_description.m_shapeInstance == in_shape.m_description.m_shapeInstance;
00361                         }
00362                         break;
00363 
00364                         case XSI::siICEShapeReference:
00365                         {
00366                                 return m_description.m_shapeReference == in_shape.m_description.m_shapeReference;
00367                         }
00368                         break;
00369                 }
00370                 return true;
00371         }
00372         
00378         void SetAsInstance(ULONG in_instanceIndex)
00379         {
00380                 m_type = (unsigned char)XSI::siICEShapeInstance;
00381                 m_description.m_shapeInstance.m_nInstanceIndex = in_instanceIndex;
00382         }
00383 
00390         void SetAsReference(ULONG in_objectId, bool in_branch)
00391         {
00392                 m_type = (unsigned char)XSI::siICEShapeReference;
00393                 m_description.m_shapeReference.m_nObjectID = in_objectId;
00394                 m_description.m_shapeReference.m_bBranch = in_branch;
00395         }
00396 
00401         void SetAsTrivial( XSI::siICEShapeType in_trivialType ) 
00402         { 
00403                 m_type = (unsigned char)in_trivialType;  
00404         }
00405 
00409         XSI::siICEShapeType GetType() const { return (XSI::siICEShapeType)m_type;}
00410 
00412         const ParameterReference& GetReferenceDescription() const
00413         {
00414                 assert( m_type == (unsigned char)XSI::siICEShapeReference);
00415                 return m_description.m_shapeReference;
00416         }
00417         
00419         const ParameterInstance& GetInstanceDescription() const
00420         {
00421                 assert( m_type == (unsigned char)XSI::siICEShapeInstance);
00422                 return m_description.m_shapeInstance;
00423         }
00424 
00425         private:
00426         union ParameterUnion
00427         {
00428                 ParameterInstance       m_shapeInstance;
00429                 ParameterReference      m_shapeReference;
00430         };
00431 
00432         unsigned char m_type; // XSI::siICEShapeType m_type;
00433         ParameterUnion m_description;
00434 };
00435 
00436 }; // MATH
00437 }; // XSI
00438 
00439 #endif // __XSISHAPE_H__