fbxsdk/utils/fbxrenamingstrategy.h Source File
 
 
 
fbxsdk/utils/fbxrenamingstrategy.h
Go to the documentation of this file.
00001 /****************************************************************************************
00002  
00003    Copyright (C) 2013 Autodesk, Inc.
00004    All rights reserved.
00005  
00006    Use of this software is subject to the terms of the Autodesk license agreement
00007    provided at the time of installation or download, or which otherwise accompanies
00008    this software in either electronic or hard copy form.
00009  
00010 ****************************************************************************************/
00011 
00013 #ifndef _FBXSDK_UTILS_RENAMINGSTRATEGY_H_
00014 #define _FBXSDK_UTILS_RENAMINGSTRATEGY_H_
00015 
00016 #include <fbxsdk/fbxsdk_def.h>
00017 
00018 #include <fbxsdk/core/base/fbxcharptrset.h>
00019 #include <fbxsdk/utils/fbxnamehandler.h>
00020 
00021 #include <fbxsdk/fbxsdk_nsbegin.h>
00022 
00023 class FbxScene;
00024 class FbxNode;
00025 
00034 class FBXSDK_DLL FbxRenamingStrategyInterface
00035 {
00036 public:
00038     FbxRenamingStrategyInterface();
00039 
00041     virtual ~FbxRenamingStrategyInterface ();
00042 
00044     virtual void Clear() = 0;
00045 
00050     virtual bool Rename(FbxNameHandler& pName) = 0;
00051 
00055     virtual FbxRenamingStrategyInterface* Clone() = 0;
00056 };
00057 
00064 class FBXSDK_DLL FbxRenamingStrategyNumber : public FbxRenamingStrategyInterface
00065 {
00066 public:
00068     FbxRenamingStrategyNumber();
00069 
00071     virtual ~FbxRenamingStrategyNumber ();
00072 
00074     virtual void Clear();
00075 
00080     virtual bool Rename(FbxNameHandler& pName);
00081 
00085     virtual FbxRenamingStrategyInterface* Clone();
00086 
00087 /*****************************************************************************************************************************
00088 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
00089 *****************************************************************************************************************************/
00090 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00091 private:
00092     struct NameCell
00093     {
00094         NameCell(const char* pName) :
00095             mName(pName),
00096             mInstanceCount(0)
00097         {
00098         }
00099             
00100         FbxString mName;
00101         int mInstanceCount;
00102     };
00103 
00104     FbxArray<NameCell*> mNameArray;
00105 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
00106 };
00107 
00114 class FBXSDK_DLL FbxRenamingStrategy : public FbxRenamingStrategyInterface
00115 {
00116 public:
00121     enum EDirection
00122     {
00123         eToFBX,
00124         eFromFBX
00125     };
00126 
00131     FbxRenamingStrategy(EDirection pMod, bool pOnCreationRun = false);
00132 
00134     virtual ~FbxRenamingStrategy();
00135     
00140     virtual bool Rename(FbxNameHandler& pName);
00141 
00143     virtual void Clear();
00144     
00148     virtual FbxRenamingStrategyInterface* Clone();
00149 
00155     enum EClashType
00156     {
00157         eNameClashAuto,
00158         eNameClashType1,
00159         eNameClashType2
00160     };
00161 
00165     void SetClashSoverType(EClashType pType);
00166 
00171     static char* NoPrefixName (const char* pName);
00172 
00177     static char* NoPrefixName (FbxString& pName);
00178 
00182     virtual char* GetNameSpace() { return mNameSpace.Buffer(); } 
00183 
00187     virtual void SetInNameSpaceSymbol(FbxString pNameSpaceSymbol){mInNameSpaceSymbol = pNameSpaceSymbol;}
00188     
00192     virtual void SetOutNameSpaceSymbol(FbxString pNameSpaceSymbol){mOutNameSpaceSymbol = pNameSpaceSymbol;}    
00193 
00197     virtual void SetCaseSensibility(bool pIsCaseSensitive){mCaseSensitive = pIsCaseSensitive ;}
00198 
00202     virtual void SetReplaceNonAlphaNum(bool pReplaceNonAlphaNum){mReplaceNonAlphaNum = pReplaceNonAlphaNum;}
00203 
00207     virtual void SetFirstNotNum(bool pFirstNotNum){mFirstNotNum = pFirstNotNum;}
00208 
00214     virtual bool RenameUnparentNameSpace(FbxNode* pNode, bool pIsRoot = false);
00215 
00220     virtual bool RemoveImportNameSpaceClash(FbxNode* pNode);
00221 
00226     virtual void GetParentsNameSpaceList(FbxNode* pNode, FbxArray<FbxString*> &pNameSpaceList);
00227 
00233     virtual bool PropagateNameSpaceChange(FbxNode* pNode, FbxString OldNS, FbxString NewNS);
00234 
00235 /*****************************************************************************************************************************
00236 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
00237 *****************************************************************************************************************************/
00238 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00239 protected:
00240     virtual bool RenameToFBX(FbxNameHandler& pName);
00241     virtual bool RenameFromFBX(FbxNameHandler& pName);
00242     virtual FbxString& ReplaceNonAlphaNum(FbxString& pName,  const char* pReplace, bool pIgnoreNameSpace);
00243 
00244     EDirection mMode;
00245     EClashType mType;
00246 
00247     struct NameCell
00248     {
00249         NameCell(const char* pName) :
00250             mName(pName),
00251             mInstanceCount(0)
00252         {
00253         }
00254             
00255         FbxString mName;
00256         int mInstanceCount;        
00257     };
00258 
00259     FbxCharPtrSet               mStringNameArray;
00260     FbxArray<NameCell*> mExistingNsList;
00261     bool                                mOnCreationRun;
00262     bool                                mCaseSensitive;
00263     bool                                mReplaceNonAlphaNum;
00264     bool                                mFirstNotNum;
00265     FbxString                   mNameSpace;
00266     FbxString                   mInNameSpaceSymbol; //symbol identifying a name space
00267     FbxString                   mOutNameSpaceSymbol; 
00268 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
00269 };
00270 
00284 class FBXSDK_DLL FbxSceneRenamer
00285 {
00286 public:
00290     FbxSceneRenamer(FbxScene* pScene) {mScene = pScene;};
00291 
00293     virtual ~FbxSceneRenamer(){};
00294 
00315     enum ERenamingMode
00316     { 
00317         eNone,
00318         eMAYA_TO_FBX5,
00319         eMAYA_TO_FBX_MB75,
00320         eMAYA_TO_FBX_MB70,
00321         eFBXMB75_TO_FBXMB70,
00322         eFBX_TO_FBX,
00323         eMAYA_TO_FBX,
00324         eFBX_TO_MAYA,
00325         eLW_TO_FBX,
00326         eFBX_TO_LW,
00327         eXSI_TO_FBX,
00328         eFBX_TO_XSI,
00329         eMAX_TO_FBX,
00330         eFBX_TO_MAX,
00331         eMB_TO_FBX,
00332         eFBX_TO_MB,
00333         eDAE_TO_FBX,
00334         eFBX_TO_DAE
00335     };
00336 
00340     void RenameFor(ERenamingMode pMode);
00341 
00342 /*****************************************************************************************************************************
00343 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
00344 *****************************************************************************************************************************/
00345 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00346 private:
00347     void ResolveNameClashing(    bool pFromFbx, bool pIgnoreNS, bool pIsCaseSensitive,
00348                                 bool pReplaceNonAlphaNum, bool pFirstNotNum,
00349                                 FbxString pInNameSpaceSymbol, FbxString pOutNameSpaceSymbol,
00350                                 bool pNoUnparentNS/*for MB < 7.5*/, bool pRemoveNameSpaceClash);
00351 
00352     FbxRenamingStrategyInterface* mNodeRenamingStrategy;
00353     FbxScene* mScene;
00354 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
00355 };
00356 
00357 #include <fbxsdk/fbxsdk_nsend.h>
00358 
00359 #endif /* _FBXSDK_UTILS_RENAMINGSTRATEGY_H_ */
00360