FBX SDK Reference Guide: kfbxrenamingstrategy.h Source File
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 © 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 <fbxfilesdk/components/kbaselib/kaydaradef_h.h>
00041 #include <fbxfilesdk/components/kbaselib/klib/kstring.h>
00042 #include <fbxfilesdk/components/kbaselib/klib/kstringlist.h>
00043 #include <fbxfilesdk/components/kbaselib/klib/krenamingstrategy.h>
00044 #include <fbxfilesdk/components/kbaselib/klib/kcharptrset.h>
00045 
00046 #include <fbxfilesdk/fbxfilesdk_nsbegin.h>
00047 class KFbxNode;
00048 class KFbxTexture;
00049 class KFbxVideo;
00050 class KFbxScene;
00051 class KFbxNodeAttribute;
00052 
00053 
00061 class KFBX_DLL KFbxRenamingStrategy : public KRenamingStrategy
00062 {
00063 public:
00064 
00070     enum EMode
00071     {
00072         eTO_FBX,
00073         eFROM_FBX,
00074         eMODE_COUNT
00075     };
00076 
00082     enum EClashType
00083     {
00084         eNAMECLASH_AUTO,
00085         eNAMECLASH_TYPE1,
00086         eNAMECLASH_TYPE2
00087     };
00088 
00089 
00094     KFbxRenamingStrategy(EMode pMod, bool pOnCreationRun = false);
00095 
00097     virtual ~KFbxRenamingStrategy ();
00098 
00102     void SetClashSoverType(EClashType pType);
00103     
00108     virtual bool Rename(KName& pName);
00109 
00111     virtual void Clear();
00112     
00117     virtual KRenamingStrategy* Clone();
00118 
00123     static char* NoPrefixName (char const* pName);
00124     static char* NoPrefixName (KString& pName);
00125 
00129     virtual char* GetNameSpace() { return mNameSpace.Buffer(); } 
00130 
00134     virtual void SetInNameSpaceSymbol(KString pNameSpaceSymbol){mInNameSpaceSymbol = pNameSpaceSymbol;}
00135     
00139     virtual void SetOutNameSpaceSymbol(KString pNameSpaceSymbol){mOutNameSpaceSymbol = pNameSpaceSymbol;}
00140     
00144     virtual void SetCaseSensibility(bool pIsCaseSensitive){mCaseSensitive = pIsCaseSensitive ;}
00145 
00149     virtual void SetReplaceNonAlphaNum(bool pReplaceNonAlphaNum){mReplaceNonAlphaNum = pReplaceNonAlphaNum;}
00150 
00154     virtual void SetFirstNotNum(bool pFirstNotNum){mFirstNotNum = pFirstNotNum;}
00155 
00161     virtual bool RenameUnparentNameSpace(KFbxNode* pNode, bool pIsRoot = false);
00162 
00167     virtual bool RemoveImportNameSpaceClash(KFbxNode* pNode);
00168 
00169 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00170 
00171     virtual void GetParentsNameSpaceList(KFbxNode* pNode, KArrayTemplate<KString*> &pNameSpaceList);
00172     virtual bool PropagateNameSpaceChange(KFbxNode* pNode, KString OldNS, KString NewNS);
00173 
00174 protected:
00175 
00176     virtual bool RenameToFBX(KName& pName);
00177     virtual bool RenameFromFBX(KName& pName);
00178     virtual KString& ReplaceNonAlphaNum(KString& pName, char* pReplace, bool pIgnoreNameSpace);
00179 
00180     EMode mMode;
00181     EClashType mType;
00182 
00183     struct NameCell
00184     {
00185         NameCell(char const* pName) :
00186             mName(pName),
00187             mInstanceCount(0)
00188         {
00189         }
00190             
00191         KString mName;
00192         int mInstanceCount;     
00193     };
00194 
00195 
00196     KCharPtrSet                 mStringNameArray;
00197     KArrayTemplate<NameCell*>   mExistingNsList;
00198     bool                        mOnCreationRun;
00199     bool                        mCaseSensitive;
00200     bool                        mReplaceNonAlphaNum;
00201     bool                        mFirstNotNum;
00202     KString                     mNameSpace;
00203     KString                     mInNameSpaceSymbol; //symbol identifying a name space
00204     KString                     mOutNameSpaceSymbol; 
00205 
00206 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 
00207 
00208 };
00209 
00218 class KFBX_DLL KFbxSceneRenamer
00219 {
00220 
00221 public:
00222 
00226     KFbxSceneRenamer(KFbxScene* pScene){mScene = pScene;};
00227 
00231     virtual ~KFbxSceneRenamer(){};
00232 
00253     enum ERenamingMode
00254     { 
00255         eNONE,
00256         eMAYA_TO_FBX5,
00257         eMAYA_TO_FBX_MB75,
00258         eMAYA_TO_FBX_MB70,
00259         eFBXMB75_TO_FBXMB70,
00260         eFBX_TO_FBX,
00261         eMAYA_TO_FBX,
00262         eFBX_TO_MAYA,
00263         eLW_TO_FBX,
00264         eFBX_TO_LW,
00265         eXSI_TO_FBX,
00266         eFBX_TO_XSI,
00267         eMAX_TO_FBX,
00268         eFBX_TO_MAX,
00269         eMB_TO_FBX,
00270         eFBX_TO_MB,
00271         eDAE_TO_FBX,
00272         eFBX_TO_DAE
00273     };
00274 
00275     void RenameFor(ERenamingMode pMode);
00276 
00289     void ResolveNameClashing(   bool pFromFbx, bool pIgnoreNS, bool pIsCaseSensitive,
00290                                 bool pReplaceNonAlphaNum, bool pFirstNotNum,
00291                                 KString pInNameSpaceSymbol, KString pOutNameSpaceSymbol,
00292                                 bool pNoUnparentNS/*for MB < 7.5*/, bool pRemoveNameSpaceClash);
00293 private:
00294 
00295     KRenamingStrategy* mNodeRenamingStrategy;
00296     KFbxScene* mScene;
00297 };
00298 
00299 
00300 #include <fbxfilesdk/fbxfilesdk_nsend.h>
00301 
00302 #endif // FBXFILESDK_KFBXPLUGINS_KFBXRENAMINGSTRATEGY_H
00303