kfbxrenamingstrategy.h

Go to the documentation of this file.
00001 
00003 #ifndef FBXFILESDK_KFBXPLUGINS_KFBXRENAMINGSTRATEGY_H
00004 #define FBXFILESDK_KFBXPLUGINS_KFBXRENAMINGSTRATEGY_H
00005 
00006 /**************************************************************************************
00007 
00008  Copyright (C) 2001 - 2010 Autodesk, Inc. and/or its licensors.
00009  All Rights Reserved.
00010 
00011  The coded instructions, statements, computer programs, and/or related material 
00012  (collectively the "Data") in these files contain unpublished information 
00013  proprietary to Autodesk, Inc. and/or its licensors, which is protected by 
00014  Canada and United States of America federal copyright law and by international 
00015  treaties. 
00016  
00017  The Data may not be disclosed or distributed to third parties, in whole or in
00018  part, without the prior written consent of Autodesk, Inc. ("Autodesk").
00019 
00020  THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
00021  ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
00022  WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING
00023  BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, 
00024  NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. 
00025  WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION
00026  OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. 
00027  
00028  IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
00029  OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES
00030  OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER
00031  SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE
00032  OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND),
00033  HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED
00034  FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE,
00035  ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE,
00036  WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS
00037  OR DAMAGE. 
00038 
00039 **************************************************************************************/
00040 #include <fbxfilesdk/fbxfilesdk_def.h>
00041 
00042 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00043 #include <fbxfilesdk/components/kbaselib/klib/kstringlist.h>
00044 #include <fbxfilesdk/components/kbaselib/klib/krenamingstrategy.h>
00045 #include <fbxfilesdk/components/kbaselib/klib/kcharptrset.h>
00046 
00047 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00048 
00049 class KFbxNode;
00050 class KFbxTexture;
00051 class KFbxVideo;
00052 class KFbxScene;
00053 class KFbxNodeAttribute;
00054 
00061 class KFBX_DLL KFbxRenamingStrategy : public KRenamingStrategy
00062 {
00063 public:
00069     enum EMode
00070     {
00071         eTO_FBX,
00072         eFROM_FBX,
00073         eMODE_COUNT
00074     };
00075 
00080     KFbxRenamingStrategy(EMode pMod, bool pOnCreationRun = false);
00081 
00083     virtual ~KFbxRenamingStrategy();
00084     
00089     virtual bool Rename(KName& pName);
00090 
00092     virtual void Clear();
00093     
00097     virtual KRenamingStrategy* Clone();
00098 
00100     //
00101     //  WARNING!
00102     //
00103     //  Anything beyond these lines may not be documented accurately and is
00104     //  subject to change without notice.
00105     //
00107 
00108 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00109 
00115     enum EClashType
00116     {
00117         eNAMECLASH_AUTO,
00118         eNAMECLASH_TYPE1,
00119         eNAMECLASH_TYPE2
00120     };
00121 
00125     void SetClashSoverType(EClashType pType);
00126 
00131     static char* NoPrefixName (char const* pName);
00132 
00137     static char* NoPrefixName (KString& pName);
00138 
00142     virtual char* GetNameSpace() { return mNameSpace.Buffer(); } 
00143 
00147     virtual void SetInNameSpaceSymbol(KString pNameSpaceSymbol){mInNameSpaceSymbol = pNameSpaceSymbol;}
00148     
00152     virtual void SetOutNameSpaceSymbol(KString pNameSpaceSymbol){mOutNameSpaceSymbol = pNameSpaceSymbol;}    
00153 
00157     virtual void SetCaseSensibility(bool pIsCaseSensitive){mCaseSensitive = pIsCaseSensitive ;}
00158 
00162     virtual void SetReplaceNonAlphaNum(bool pReplaceNonAlphaNum){mReplaceNonAlphaNum = pReplaceNonAlphaNum;}
00163 
00167     virtual void SetFirstNotNum(bool pFirstNotNum){mFirstNotNum = pFirstNotNum;}
00168 
00174     virtual bool RenameUnparentNameSpace(KFbxNode* pNode, bool pIsRoot = false);
00175 
00180     virtual bool RemoveImportNameSpaceClash(KFbxNode* pNode);
00181 
00182     virtual void GetParentsNameSpaceList(KFbxNode* pNode, KArrayTemplate<KString*> &pNameSpaceList);
00183     virtual bool PropagateNameSpaceChange(KFbxNode* pNode, KString OldNS, KString NewNS);
00184 
00185 protected:
00186 
00187     virtual bool RenameToFBX(KName& pName);
00188     virtual bool RenameFromFBX(KName& pName);
00189     virtual KString& ReplaceNonAlphaNum(KString& pName,    char* pReplace, bool pIgnoreNameSpace);
00190 
00191     EMode mMode;
00192     EClashType mType;
00193 
00194     struct NameCell
00195     {
00196         NameCell(char const* pName) :
00197             mName(pName),
00198             mInstanceCount(0)
00199         {
00200         }
00201             
00202         KString mName;
00203         int mInstanceCount;        
00204     };
00205 
00206 
00207     KCharPtrSet                    mStringNameArray;
00208     KArrayTemplate<NameCell*>    mExistingNsList;
00209     bool                        mOnCreationRun;
00210     bool                        mCaseSensitive;
00211     bool                        mReplaceNonAlphaNum;
00212     bool                        mFirstNotNum;
00213     KString                        mNameSpace;
00214     KString                        mInNameSpaceSymbol; //symbol identifying a name space
00215     KString                        mOutNameSpaceSymbol; 
00216 
00217 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
00218 };
00219 
00233 class KFBX_DLL KFbxSceneRenamer
00234 {
00235 public:
00239     KFbxSceneRenamer(KFbxScene* pScene) {mScene = pScene;};
00240 
00242     virtual ~KFbxSceneRenamer(){};
00243 
00264     enum ERenamingMode
00265     { 
00266         eNONE,
00267         eMAYA_TO_FBX5,
00268         eMAYA_TO_FBX_MB75,
00269         eMAYA_TO_FBX_MB70,
00270         eFBXMB75_TO_FBXMB70,
00271         eFBX_TO_FBX,
00272         eMAYA_TO_FBX,
00273         eFBX_TO_MAYA,
00274         eLW_TO_FBX,
00275         eFBX_TO_LW,
00276         eXSI_TO_FBX,
00277         eFBX_TO_XSI,
00278         eMAX_TO_FBX,
00279         eFBX_TO_MAX,
00280         eMB_TO_FBX,
00281         eFBX_TO_MB,
00282         eDAE_TO_FBX,
00283         eFBX_TO_DAE
00284     };
00285 
00289     void RenameFor(ERenamingMode pMode);
00290 
00292 //
00293 //  WARNING!
00294 //
00295 //  Anything beyond these lines may not be documented accurately and is
00296 //  subject to change without notice.
00297 //
00299 
00300 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00301 
00302 private:
00303     
00316     void ResolveNameClashing(    bool pFromFbx, bool pIgnoreNS, bool pIsCaseSensitive,
00317                                 bool pReplaceNonAlphaNum, bool pFirstNotNum,
00318                                 KString pInNameSpaceSymbol, KString pOutNameSpaceSymbol,
00319                                 bool pNoUnparentNS/*for MB < 7.5*/, bool pRemoveNameSpaceClash);
00320 
00321     KRenamingStrategy* mNodeRenamingStrategy;
00322     KFbxScene* mScene;
00323 
00324 #endif // DOXYGEN_SHOULD_SKIP_THIS
00325 };
00326 
00327 
00328 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00329 
00330 #endif // FBXFILESDK_KFBXPLUGINS_KFBXRENAMINGSTRATEGY_H
00331