FBX SDK Reference Guide: kfbxrenamingstrategy.h Source File
Go to the documentation of this file.
00001 
00003 #ifndef _FBXSDK_RENAMING_STRATEGY_H_
00004 #define _FBXSDK_RENAMING_STRATEGY_H_
00005 
00006 /**************************************************************************************
00007 
00008  Copyright © 2001 - 2008 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 <kaydaradef.h>
00041 #ifndef KFBX_DLL 
00042     #define KFBX_DLL K_DLLIMPORT
00043 #endif
00044 
00045 #include <klib/kstring.h>
00046 #include <klib/kstringlist.h>
00047 #include <klib/krenamingstrategy.h>
00048 #include <klib/kcharptrset.h>
00049 
00050 #ifndef MB_FBXSDK
00051 #include <kbaselib_nsuse.h>
00052 #endif
00053 
00054 #include <fbxfilesdk_nsbegin.h>
00055 class KFbxNode;
00056 class KFbxTexture;
00057 class KFbxVideo;
00058 class KFbxScene;
00059 class KFbxNodeAttribute;
00060 
00061 
00069 class KFBX_DLL KFbxRenamingStrategy : public KRenamingStrategy
00070 {
00071 public:
00072 
00078     enum EMode
00079     {
00080         eTO_FBX,
00081         eFROM_FBX,
00082         eMODE_COUNT
00083     };
00084 
00090     enum EClashType
00091     {
00092         eNAMECLASH_AUTO,
00093         eNAMECLASH_TYPE1,
00094         eNAMECLASH_TYPE2
00095     };
00096 
00097 
00099     KFbxRenamingStrategy(EMode pMod, bool pOnCreationRun = false);
00100 
00102     virtual ~KFbxRenamingStrategy ();
00103 
00105     void SetClashSoverType(EClashType pType);
00106     
00111     virtual bool Rename(KName& pName);
00112 
00114     virtual void Clear();
00115     
00120     virtual KRenamingStrategy* Clone();
00121 
00126     static char* NoPrefixName (char const* pName);
00127     static char* NoPrefixName (KString& pName);
00128 
00132     virtual char* GetNameSpace() { return mNameSpace.Buffer(); } 
00133 
00137     virtual void SetInNameSpaceSymbol(KString pNameSpaceSymbol){mInNameSpaceSymbol = pNameSpaceSymbol;}
00138     
00142     virtual void SetOutNameSpaceSymbol(KString pNameSpaceSymbol){mOutNameSpaceSymbol = pNameSpaceSymbol;}
00143     
00147     virtual void SetCaseSensibility(bool pIsCaseSensitive){mCaseSensitive = pIsCaseSensitive ;}
00148 
00152     virtual void SetReplaceNonAlphaNum(bool pReplaceNonAlphaNum){mReplaceNonAlphaNum = pReplaceNonAlphaNum;}
00153 
00157     virtual void SetFirstNotNum(bool pFirstNotNum){mFirstNotNum = pFirstNotNum;}
00158 
00164     virtual bool RenameUnparentNameSpace(KFbxNode* pNode, bool pIsRoot = false);
00165 
00170     virtual bool RemoveImportNameSpaceClash(KFbxNode* pNode);
00171 
00172 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00173 
00174     virtual void GetParentsNameSpaceList(KFbxNode* pNode, KArrayTemplate<KString*> &pNameSpaceList);
00175     virtual bool PropagateNameSpaceChange(KFbxNode* pNode, KString OldNS, KString NewNS);
00176 
00177 protected:
00178 
00179     virtual bool RenameToFBX(KName& pName);
00180     virtual bool RenameFromFBX(KName& pName);
00181     virtual KString& ReplaceNonAlphaNum(KString& pName, char* pReplace, bool pIgnoreNameSpace);
00182 
00183     EMode mMode;
00184     EClashType mType;
00185 
00186     struct NameCell
00187     {
00188         NameCell(char const* pName) :
00189             mName(pName),
00190             mInstanceCount(0)
00191         {
00192         }
00193             
00194         KString mName;
00195         int mInstanceCount;     
00196     };
00197 
00198 
00199     KCharPtrSet                 mStringNameArray;
00200     KArrayTemplate<NameCell*>   mExistingNsList;
00201     bool                        mOnCreationRun;
00202     bool                        mCaseSensitive;
00203     bool                        mReplaceNonAlphaNum;
00204     bool                        mFirstNotNum;
00205     KString                     mNameSpace;
00206     KString                     mInNameSpaceSymbol; //symbol identifying a name space
00207     KString                     mOutNameSpaceSymbol; 
00208 
00209 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 
00210 
00211 };
00212 
00221 class KFBX_DLL KFbxSceneRenamer
00222 {
00223 
00224 public:
00225 
00229     KFbxSceneRenamer(KFbxScene* pScene){mScene = pScene;};
00230 
00234     virtual ~KFbxSceneRenamer(){};
00235 
00256     enum ERenamingMode
00257     { 
00258         eNONE,
00259         eMAYA_TO_FBX5,
00260         eMAYA_TO_FBX_MB75,
00261         eMAYA_TO_FBX_MB70,
00262         eFBXMB75_TO_FBXMB70,
00263         eFBX_TO_FBX,
00264         eMAYA_TO_FBX,
00265         eFBX_TO_MAYA,
00266         eLW_TO_FBX,
00267         eFBX_TO_LW,
00268         eXSI_TO_FBX,
00269         eFBX_TO_XSI,
00270         eMAX_TO_FBX,
00271         eFBX_TO_MAX,
00272         eMB_TO_FBX,
00273         eFBX_TO_MB,
00274         eDAE_TO_FBX,
00275         eFBX_TO_DAE
00276     };
00277 
00278     void RenameFor(ERenamingMode pMode);
00279 
00292     void ResolveNameClashing(   bool pFromFbx, bool pIgnoreNS, bool pIsCaseSensitive,
00293                                 bool pReplaceNonAlphaNum, bool pFirstNotNum,
00294                                 KString pInNameSpaceSymbol, KString pOutNameSpaceSymbol,
00295                                 bool pNoUnparentNS/*for MB < 7.5*/, bool pRemoveNameSpaceClash);
00296 private:
00297 
00298     KRenamingStrategy* mNodeRenamingStrategy;
00299     KFbxScene* mScene;
00300 };
00301 
00302 
00303 #include <fbxfilesdk_nsend.h>
00304 
00305 #endif // #define _FBXSDK_RENAMING_STRATEGY_H_
00306