GhostInfo_s.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #pragma once
  2. #include "ThirdPartyHeadersBegin.h"
  3. #include <algorithm>
  4. #include <iterator>
  5. #include <sstream>
  6. #include <stdexcept>
  7. #include <vector>
  8. #include <boost/unordered_set.hpp>
  9. #include "ThirdPartyHeadersEnd.h"
  10. #include "basicTypes.h"
  11. #include "fileio.h"
  12. struct GhostInfo_s
  13. {
  14. std::vector<int64_t> m_items;
  15. std::vector<int32_t> m_neighbors;
  16. std::vector<int64_t> m_neighborItems;
  17. GhostInfo_s() {}
  18. GhostInfo_s(std::vector<int32_t> const &___2099)
  19. {
  20. throwIfDuplicateItems(___2099);
  21. std::copy(___2099.begin(), ___2099.end(), std::back_inserter(m_items));
  22. m_neighbors.assign(___2099.size(), 0);
  23. m_neighborItems.assign(___2099.size(), 0);
  24. }
  25. GhostInfo_s(std::vector<int64_t> const &___2099) : m_items(___2099)
  26. {
  27. throwIfDuplicateItems(___2099);
  28. m_neighbors.assign(___2099.size(), 0);
  29. m_neighborItems.assign(___2099.size(), 0);
  30. }
  31. GhostInfo_s(std::vector<int32_t> const &___2099, std::vector<int32_t> const &neighbors, std::vector<int32_t> const &neighborItems) : m_neighbors(neighbors)
  32. {
  33. throwIfDuplicateItems(___2099);
  34. std::copy(___2099.begin(), ___2099.end(), std::back_inserter(m_items));
  35. std::copy(neighborItems.begin(), neighborItems.end(), std::back_inserter(m_neighborItems));
  36. }
  37. GhostInfo_s(std::vector<int64_t> const &___2099, std::vector<int32_t> const &neighbors, std::vector<int64_t> const &neighborItems) : m_items(___2099), m_neighbors(neighbors), m_neighborItems(neighborItems) { throwIfDuplicateItems(___2099); }
  38. template <typename T>
  39. void throwIfDuplicateItems(std::vector<T> const &___2099)
  40. {
  41. boost::unordered_set<T> ___2100;
  42. for (size_t i = 0; i < ___2099.size(); ++i)
  43. {
  44. if (!___2100.insert(___2099[i]).second)
  45. {
  46. size_t ___2105 = 0;
  47. for (___2105 = 0; ___2105 < i; ++___2105)
  48. if (___2099[___2105] == ___2099[i])
  49. break;
  50. ___478(___2105 < i);
  51. std::ostringstream ___2892;
  52. ___2892 << "Duplicate item " << ___2099[i] << " detected at position " << i + 1 << "; duplicates item at position " << ___2105 + 1;
  53. throw std::runtime_error(___2892.str().c_str());
  54. }
  55. }
  56. }
  57. bool empty() const { return m_items.empty(); }
  58. void writeToFile(tecplot::___3933::FileWriterInterface &outputFile, bool ___4480) const
  59. {
  60. tecplot::tecioszl::writeVector(outputFile, m_items, ___4480);
  61. tecplot::tecioszl::writeVector(outputFile, m_neighbors, ___4480);
  62. tecplot::tecioszl::writeVector(outputFile, m_neighborItems, ___4480);
  63. }
  64. uint64_t sizeInFile(bool ___4480) const { return tecplot::tecioszl::vectorSizeInFile(m_items, ___4480) + tecplot::tecioszl::vectorSizeInFile(m_neighbors, ___4480) + tecplot::tecioszl::vectorSizeInFile(m_neighborItems, ___4480); }
  65. GhostInfo_s(tecplot::___3933::___1399 &inputFile, bool readASCII)
  66. {
  67. tecplot::tecioszl::readVector(inputFile, m_items, readASCII);
  68. tecplot::tecioszl::readVector(inputFile, m_neighbors, readASCII);
  69. tecplot::tecioszl::readVector(inputFile, m_neighborItems, readASCII);
  70. }
  71. };