NodeMap_s.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #pragma once
  2. #include "ThirdPartyHeadersBegin.h"
  3. #include <fstream>
  4. #include <vector>
  5. #include <boost/make_shared.hpp>
  6. #include <boost/shared_ptr.hpp>
  7. #include "ThirdPartyHeadersEnd.h"
  8. #include "MASTER.h"
  9. #include "GLOBAL.h"
  10. #include "basicTypes.h"
  11. #include "fileio.h"
  12. struct ___2730
  13. {
  14. typedef boost::shared_ptr<___2730> Ptr;
  15. static Ptr makePtr(int32_t nodesPerCell, int64_t cellCount, int64_t maxNodeValue);
  16. static OffsetDataType_e getRawItemTypeForMaxNodeValue(int64_t maxNodeValue);
  17. int32_t ___2500;
  18. int64_t ___2392;
  19. int64_t m_maxNodeValue;
  20. ___2730(int32_t nodesPerCell, int64_t cellCount, int64_t maxNodeValue) : ___2500(nodesPerCell), ___2392(cellCount), m_maxNodeValue(maxNodeValue) {}
  21. virtual ~___2730() {}
  22. OffsetDataType_e getRawItemType() const { return getRawItemTypeForMaxNodeValue(m_maxNodeValue); }
  23. virtual int64_t storedValueCount() const = 0;
  24. virtual void appendValue(int64_t ___4314) = 0;
  25. virtual void ___3504(int64_t ___2865, int64_t ___4314) = 0;
  26. virtual int64_t ___4314(int64_t ___2865) const = 0;
  27. virtual void *getRawPtr() = 0;
  28. virtual void writeToFile(tecplot::___3933::FileWriterInterface &outputFile, bool ___4480) const = 0;
  29. virtual uint64_t sizeInFile(bool ___4480) const = 0;
  30. static Ptr makePtr(tecplot::___3933::___1399 &inputFile, bool readASCII);
  31. protected:
  32. virtual void readValuesFromFile(tecplot::___3933::___1399 &inputFile, bool readASCII) = 0;
  33. };
  34. template <typename T>
  35. class TypedNodeMap : public ___2730
  36. {
  37. public:
  38. TypedNodeMap(int32_t nodesPerCell, int64_t cellCount, int64_t maxNodeValue);
  39. virtual int64_t storedValueCount() const;
  40. virtual void appendValue(int64_t ___4314);
  41. virtual void ___3504(int64_t ___2865, int64_t ___4314);
  42. virtual int64_t ___4314(int64_t ___2865) const;
  43. virtual void *getRawPtr();
  44. virtual void writeToFile(tecplot::___3933::FileWriterInterface &outputFile, bool ___4480) const;
  45. virtual uint64_t sizeInFile(bool ___4480) const;
  46. protected:
  47. virtual void readValuesFromFile(tecplot::___3933::___1399 &inputFile, bool readASCII);
  48. private:
  49. std::vector<T> m_nodes;
  50. };
  51. template <typename T>
  52. TypedNodeMap<T>::TypedNodeMap(int32_t nodesPerCell, int64_t cellCount, int64_t maxNodeValue) : ___2730(nodesPerCell, cellCount, maxNodeValue) { REQUIRE(maxNodeValue < static_cast<int64_t>(std::numeric_limits<T>::max())); }
  53. template <typename T>
  54. int64_t TypedNodeMap<T>::storedValueCount() const { return static_cast<int64_t>(m_nodes.size()); }
  55. template <typename T>
  56. void TypedNodeMap<T>::appendValue(int64_t ___4314)
  57. {
  58. REQUIRE(___4314 < std::numeric_limits<T>::max());
  59. if (m_nodes.empty())
  60. m_nodes.reserve(___2500 * ___2392);
  61. m_nodes.push_back(static_cast<T>(___4314));
  62. }
  63. template <typename T>
  64. void TypedNodeMap<T>::___3504(int64_t ___2865, int64_t ___4314)
  65. {
  66. REQUIRE(___4314 < std::numeric_limits<T>::max());
  67. if (m_nodes.empty() || m_nodes.size() <= (size_t)___2865)
  68. m_nodes.resize(___2865 + 1);
  69. m_nodes[___2865] = static_cast<T>(___4314);
  70. }
  71. template <typename T>
  72. int64_t TypedNodeMap<T>::___4314(int64_t ___2865) const
  73. {
  74. REQUIRE(0 <= ___2865 && ___2865 < static_cast<int64_t>(m_nodes.size()));
  75. return m_nodes[___2865];
  76. }
  77. template <typename T>
  78. void *TypedNodeMap<T>::getRawPtr()
  79. {
  80. if (m_nodes.empty())
  81. m_nodes.assign(___2500 * ___2392, 0);
  82. return &m_nodes[0];
  83. }
  84. inline OffsetDataType_e ___2730::getRawItemTypeForMaxNodeValue(int64_t maxNodeValue)
  85. {
  86. if (maxNodeValue < std::numeric_limits<int32_t>::max())
  87. return OffsetDataType_32Bit;
  88. else
  89. return OffsetDataType_64Bit;
  90. }
  91. inline ___2730::Ptr ___2730::makePtr(int32_t nodesPerCell, int64_t cellCount, int64_t maxNodeValue)
  92. {
  93. if (getRawItemTypeForMaxNodeValue(maxNodeValue) == OffsetDataType_32Bit)
  94. return boost::make_shared<TypedNodeMap<int32_t>>(nodesPerCell, cellCount, maxNodeValue);
  95. else
  96. return boost::make_shared<TypedNodeMap<int64_t>>(nodesPerCell, cellCount, maxNodeValue);
  97. }
  98. template <typename T>
  99. void TypedNodeMap<T>::writeToFile(tecplot::___3933::FileWriterInterface &outputFile, bool ___4480) const
  100. {
  101. tecplot::tecioszl::writeScalar(outputFile, ___2500, ___4480);
  102. tecplot::tecioszl::writeScalar(outputFile, ___2392, ___4480);
  103. tecplot::tecioszl::writeScalar(outputFile, m_maxNodeValue, ___4480);
  104. tecplot::tecioszl::writeVector(outputFile, m_nodes, ___4480);
  105. }
  106. template <typename T>
  107. uint64_t TypedNodeMap<T>::sizeInFile(bool ___4480) const { return tecplot::tecioszl::scalarSizeInFile(___2500, ___4480) + tecplot::tecioszl::scalarSizeInFile(___2392, ___4480) + tecplot::tecioszl::scalarSizeInFile(m_maxNodeValue, ___4480) + tecplot::tecioszl::vectorSizeInFile(m_nodes, ___4480); }
  108. template <typename T>
  109. void TypedNodeMap<T>::readValuesFromFile(tecplot::___3933::___1399 &inputFile, bool readASCII) { tecplot::tecioszl::readVector(inputFile, m_nodes, readASCII); }
  110. inline ___2730::Ptr ___2730::makePtr(tecplot::___3933::___1399 &inputFile, bool readASCII)
  111. {
  112. int32_t nodesPerCell;
  113. int64_t cellCount;
  114. int64_t maxNodeValue;
  115. tecplot::tecioszl::readScalar(inputFile, nodesPerCell, readASCII);
  116. tecplot::tecioszl::readScalar(inputFile, cellCount, readASCII);
  117. tecplot::tecioszl::readScalar(inputFile, maxNodeValue, readASCII);
  118. Ptr ___3358 = makePtr(nodesPerCell, cellCount, maxNodeValue);
  119. ___3358->readValuesFromFile(inputFile, readASCII);
  120. return ___3358;
  121. }