fbxsdk/utils/fbxrenamingstrategy.h Source File

fbxrenamingstrategy.h
Go to the documentation of this file.
1 /****************************************************************************************
2 
3  Copyright (C) 2015 Autodesk, Inc.
4  All rights reserved.
5 
6  Use of this software is subject to the terms of the Autodesk license agreement
7  provided at the time of installation or download, or which otherwise accompanies
8  this software in either electronic or hard copy form.
9 
10 ****************************************************************************************/
11 
13 #ifndef _FBXSDK_UTILS_RENAMINGSTRATEGY_H_
14 #define _FBXSDK_UTILS_RENAMINGSTRATEGY_H_
15 
16 #include <fbxsdk/fbxsdk_def.h>
17 
20 
21 #include <fbxsdk/fbxsdk_nsbegin.h>
22 
23 class FbxScene;
24 class FbxNode;
25 
35 {
36 public:
39 
41  virtual ~FbxRenamingStrategyInterface ();
42 
44  virtual void Clear() = 0;
45 
50  virtual bool Rename(FbxNameHandler& pName) = 0;
51 
55  virtual FbxRenamingStrategyInterface* Clone() = 0;
56 };
57 
65 {
66 public:
69 
71  virtual ~FbxRenamingStrategyNumber ();
72 
74  virtual void Clear();
75 
80  virtual bool Rename(FbxNameHandler& pName);
81 
86 
87 /*****************************************************************************************************************************
88 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
89 *****************************************************************************************************************************/
90 #ifndef DOXYGEN_SHOULD_SKIP_THIS
91 private:
92  struct NameCell
93  {
94  NameCell(const char* pName) :
95  mName(pName),
96  mInstanceCount(0)
97  {
98  }
99 
100  FbxString mName;
101  int mInstanceCount;
102  };
103 
104  FbxArray<NameCell*> mNameArray;
105 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
106 };
107 
115 {
116 public:
122  {
124  eFromFBX
125  };
126 
131  FbxRenamingStrategy(EDirection pMod, bool pOnCreationRun = false);
132 
134  virtual ~FbxRenamingStrategy();
135 
140  virtual bool Rename(FbxNameHandler& pName);
141 
143  virtual void Clear();
144 
149 
156  {
159  eNameClashType2
160  };
161 
165  void SetClashSoverType(EClashType pType);
166 
171  static char* NoPrefixName (const char* pName);
172 
177  static char* NoPrefixName (FbxString& pName);
178 
182  virtual char* GetNameSpace() { return mNameSpace.Buffer(); }
183 
187  virtual void SetInNameSpaceSymbol(FbxString pNameSpaceSymbol){mInNameSpaceSymbol = pNameSpaceSymbol;}
188 
192  virtual void SetOutNameSpaceSymbol(FbxString pNameSpaceSymbol){mOutNameSpaceSymbol = pNameSpaceSymbol;}
193 
197  virtual void SetCaseSensibility(bool pIsCaseSensitive){mCaseSensitive = pIsCaseSensitive ;}
198 
202  virtual void SetReplaceNonAlphaNum(bool pReplaceNonAlphaNum){mReplaceNonAlphaNum = pReplaceNonAlphaNum;}
203 
207  virtual void SetFirstNotNum(bool pFirstNotNum){mFirstNotNum = pFirstNotNum;}
208 
214  virtual bool RenameUnparentNameSpace(FbxNode* pNode, bool pIsRoot = false);
215 
220  virtual bool RemoveImportNameSpaceClash(FbxNode* pNode);
221 
226  virtual void GetParentsNameSpaceList(FbxNode* pNode, FbxArray<FbxString*> &pNameSpaceList);
227 
233  virtual bool PropagateNameSpaceChange(FbxNode* pNode, FbxString OldNS, FbxString NewNS);
234 
235 /*****************************************************************************************************************************
236 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
237 *****************************************************************************************************************************/
238 #ifndef DOXYGEN_SHOULD_SKIP_THIS
239 protected:
240  virtual bool RenameToFBX(FbxNameHandler& pName);
241  virtual bool RenameFromFBX(FbxNameHandler& pName);
242  virtual FbxString& ReplaceNonAlphaNum(FbxString& pName, const char* pReplace, bool pIgnoreNameSpace);
243 
244  EDirection mMode;
245  EClashType mType;
246 
247  struct NameCell
248  {
249  NameCell(const char* pName) :
250  mName(pName),
251  mInstanceCount(0)
252  {
253  }
254 
255  FbxString mName;
256  int mInstanceCount;
257  };
258 
259  FbxCharPtrSet mStringNameArray;
260  FbxArray<NameCell*> mExistingNsList;
261  bool mOnCreationRun;
262  bool mCaseSensitive;
263  bool mReplaceNonAlphaNum;
264  bool mFirstNotNum;
265  FbxString mNameSpace;
266  FbxString mInNameSpaceSymbol; //symbol identifying a name space
267  FbxString mOutNameSpaceSymbol;
268 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
269 };
270 
285 {
286 public:
290  FbxSceneRenamer(FbxScene* pScene) {mScene = pScene;};
291 
293  virtual ~FbxSceneRenamer(){};
294 
316  {
334  eFBX_TO_DAE
335  };
336 
340  void RenameFor(ERenamingMode pMode);
341 
342 /*****************************************************************************************************************************
343 ** WARNING! Anything beyond these lines is for internal use, may not be documented and is subject to change without notice! **
344 *****************************************************************************************************************************/
345 #ifndef DOXYGEN_SHOULD_SKIP_THIS
346 private:
347  void ResolveNameClashing( bool pFromFbx, bool pIgnoreNS, bool pIsCaseSensitive,
348  bool pReplaceNonAlphaNum, bool pFirstNotNum,
349  FbxString pInNameSpaceSymbol, FbxString pOutNameSpaceSymbol,
350  bool pNoUnparentNS/*for MB < 7.5*/, bool pRemoveNameSpaceClash);
351 
352  FbxRenamingStrategyInterface* mNodeRenamingStrategy;
353  FbxScene* mScene;
354 #endif /* !DOXYGEN_SHOULD_SKIP_THIS *****************************************************************************************/
355 };
356 
357 #include <fbxsdk/fbxsdk_nsend.h>
358 
359 #endif /* _FBXSDK_UTILS_RENAMINGSTRATEGY_H_ */
360 
FbxSceneRenamer(FbxScene *pScene)
Constructor.
FBX SDK environment definition.
Utility class to manipulate strings.
Definition: fbxstring.h:66
EDirection
The mode describing the convention direction, from FBX format or to FBX format.
virtual char * GetNameSpace()
Get the namespace of the last renamed object.
Implements a renaming strategy that resolves name clashes by adding number postfixes.
virtual void SetInNameSpaceSymbol(FbxString pNameSpaceSymbol)
Sets the current scene namespace symbol.
virtual void SetOutNameSpaceSymbol(FbxString pNameSpaceSymbol)
Sets the wanted scene namespace symbol.
This base class is an abstract implementation of a renaming strategy for avoiding name clashes...
virtual void SetReplaceNonAlphaNum(bool pReplaceNonAlphaNum)
Sets the flag for character acceptance during renaming.
virtual void SetCaseSensibility(bool pIsCaseSensitive)
Sets case sensitivity for name clashing.
Represents an element in the scene graph.
Definition: fbxnode.h:72
This class contains the description of a 3D scene.
Definition: fbxscene.h:61
This class contains the data structure support for char pointer set.
Definition: fbxcharptrset.h:22
virtual FbxRenamingStrategyInterface * Clone()=0
Create a dynamic renaming strategy instance of the same type as the child class.
The FbxRenamingStrategy object can be set to rename all the objects in a scene.
#define FBXSDK_DLL
Definition: fbxarch.h:173
A name is a case-sensitive string ID of a property, a node, a node attribute, a texture, etc.
The FbxSceneRenamer provides a way to easily rename objects in a scene without using the FbxRenamingS...
virtual void SetFirstNotNum(bool pFirstNotNum)
Sets the flag for first character acceptance during renaming.
virtual bool Rename(FbxNameHandler &pName)=0
Rename a name if necessary to avoid name-clash issues.
virtual void Clear()=0
Resets internal state regarding assigned names.
Class for array of basic elements such as pointers and basic types.
Definition: fbxarray.h:23
virtual ~FbxSceneRenamer()
Destructor.
ERenamingMode
The Mode describing from which format to which format.