FBXDocumentUtil.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2012, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file FBXDocumentUtil.h
  34. * @brief FBX internal utilities used by the DOM reading code
  35. */
  36. #ifndef INCLUDED_AI_FBX_DOCUMENT_UTIL_H
  37. #define INCLUDED_AI_FBX_DOCUMENT_UTIL_H
  38. namespace Assimp {
  39. namespace FBX {
  40. namespace Util {
  41. // does not return
  42. void DOMError(const std::string& message, const Token& token);
  43. void DOMError(const std::string& message, const Element* element = NULL);
  44. // does return
  45. void DOMWarning(const std::string& message, const Token& token);
  46. void DOMWarning(const std::string& message, const Element* element = NULL);
  47. // extract required compound scope
  48. const Scope& GetRequiredScope(const Element& el);
  49. // get token at a particular index
  50. const Token& GetRequiredToken(const Element& el, unsigned int index);
  51. // wrapper around ParseTokenAsID() with DOMError handling
  52. uint64_t ParseTokenAsID(const Token& t);
  53. // wrapper around ParseTokenAsDim() with DOMError handling
  54. size_t ParseTokenAsDim(const Token& t);
  55. // wrapper around ParseTokenAsFloat() with DOMError handling
  56. float ParseTokenAsFloat(const Token& t);
  57. // wrapper around ParseTokenAsInt() with DOMError handling
  58. int ParseTokenAsInt(const Token& t);
  59. // wrapper around ParseTokenAsString() with DOMError handling
  60. std::string ParseTokenAsString(const Token& t);
  61. // extract a required element from a scope, abort if the element cannot be found
  62. const Element& GetRequiredElement(const Scope& sc, const std::string& index, const Element* element = NULL);
  63. // read an array of float3 tuples
  64. void ReadVectorDataArray(std::vector<aiVector3D>& out, const Element& el);
  65. // read an array of color4 tuples
  66. void ReadVectorDataArray(std::vector<aiColor4D>& out, const Element& el);
  67. // read an array of float2 tuples
  68. void ReadVectorDataArray(std::vector<aiVector2D>& out, const Element& el);
  69. // read an array of ints
  70. void ReadVectorDataArray(std::vector<int>& out, const Element& el);
  71. // read an array of uints
  72. void ReadVectorDataArray(std::vector<unsigned int>& out, const Element& el);
  73. // fetch a property table and the corresponding property template
  74. boost::shared_ptr<const PropertyTable> GetPropertyTable(const Document& doc,
  75. const std::string& templateName,
  76. const Element &element,
  77. const Scope& sc);
  78. } //!Util
  79. } //!FBX
  80. } //!Assimp
  81. #endif