JTImporter.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //
  2. #include "JT/JTImporter.h"
  3. #include <assimp/StreamReader.h>
  4. #include <cstddef>
  5. namespace Assimp::JT {
  6. enum class SegmentType {
  7. Invalid = -1, //< Predefined class: Invalid
  8. LOGICAL_SCENE_GRAPH,//< Predefined class: Logical_Scene_Graph
  9. JT_BREP,//< Predefined class: JT_BRep
  10. PMI_DATA, //<Predefined class: PMI_Data
  11. META_DATA, //< Predefined class: Meta_Data
  12. SHAPE, //< Predefined class: Shape
  13. SHAPE_LOD0, //< Predefined class: Shape_LOD0
  14. SHAPE_LOD1, //< Predefined class: Logical_Scene_Graph
  15. SHAPE_LOD2, //< Predefined class: Shape_LOD2
  16. SHAPE_LOD3, //< Predefined class: Shape_LOD3
  17. SHAPE_LOD4, //< Predefined class: Shape_LOD4
  18. SHAPE_LOD5, //< Predefined class: Shape_LOD5
  19. SHAPE_LOD6, //< Predefined class: Shape_LOD6
  20. SHAPE_LOD7, //< Predefined class: Shape_LOD7
  21. SHAPE_LOD8, //< Predefined class: Shape_LOD8
  22. SHAPE_LOD9, ///< Predefined class: Shape_LOD9
  23. XT_BREP, //< Predefined class: XT_BRep
  24. Count //< Number of segment types
  25. };
  26. struct Guid {
  27. uint32_t Data0{};
  28. uint32_t Data1{};
  29. uint32_t Data2{}
  30. uint32_t Data3{};
  31. };
  32. struct Version {
  33. constexpr static size_t VersionSize = 80;
  34. uint8_t Version[VersionSize]{};
  35. int32_t Empty{0};
  36. uint64_t TOCOffset{0};
  37. }
  38. struct SegmentHeader {
  39. Guid SegmentGuid{};
  40. SegmentType Type{SegmentType::Invalid};
  41. };
  42. namespace {
  43. void readVersion(StreamReaderLE& reader, Version& version) {
  44. reader.ReadBytes(version.Version, Version::VersionSize);
  45. version.Empty = reader.Read<int32_t>();
  46. version.TOCOffset = reader.Read<uint64_t>();
  47. }
  48. } // Anonymous namespace
  49. JTImporter::JTImporter() : BaseImporter() {
  50. }
  51. JTImporter::~JTImporter() {
  52. }
  53. bool JTImporter::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
  54. }
  55. void JTImporter::setupProperties(const Importer* pImp) {
  56. }
  57. void InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler) {
  58. auto stream = std::shared_ptr<IOStream>(pIOHandler->Open(pFile, "rb"));
  59. if (!stream) {
  60. throw DeadlyImportError("Failed to open JT file " + pFile + " for reading.");
  61. }
  62. StreamReaderLE reader(stream);
  63. Version version;
  64. readVersion(reader, version);
  65. }
  66. } // Namespace Assimp