shared_structs.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2020-2021 by
  4. * The Salk Institute for Biological Studies
  5. *
  6. * Use of this source code is governed by an MIT-style
  7. * license that can be found in the LICENSE file or at
  8. * https://opensource.org/licenses/MIT.
  9. *
  10. ******************************************************************************/
  11. #ifndef LIBMCELL_API_SHARED_STRUCTS_H_
  12. #define LIBMCELL_API_SHARED_STRUCTS_H_
  13. #include "defines.h"
  14. namespace MCell {
  15. struct VertexMoveInfo {
  16. // vertex index and partition defines the object index but
  17. // it is faster to have the object id available as well
  18. VertexMoveInfo(
  19. const partition_id_t partition_id_,
  20. const geometry_object_id_t geometry_object_id_,
  21. const vertex_index_t vertex_index_,
  22. const Vec3& displacement_)
  23. : partition_id(partition_id_),
  24. geometry_object_id(geometry_object_id_),
  25. vertex_index(vertex_index_),
  26. displacement(displacement_),
  27. vertex_walls_are_movable(true) {
  28. }
  29. // id of partition of where do the move
  30. partition_id_t partition_id;
  31. // id of the object to move
  32. geometry_object_id_t geometry_object_id;
  33. // which vertex of the object to move
  34. vertex_index_t vertex_index;
  35. // and by how much
  36. Vec3 displacement;
  37. // may be set to false in apply_vertex_moves_per_object when any of the walls to which
  38. // this vertex belongs is not movable
  39. bool vertex_walls_are_movable;
  40. };
  41. struct GeometryObjectWallUnorderedPair {
  42. GeometryObjectWallUnorderedPair(
  43. geometry_object_id_t geometry_object_id1_,
  44. wall_index_t wall_index1_,
  45. geometry_object_id_t geometry_object_id2_,
  46. wall_index_t wall_index2_) {
  47. // the pair with lower geom obj id is always the first one
  48. if (geometry_object_id1_ <= geometry_object_id2_) {
  49. geometry_object_id1 = geometry_object_id1_;
  50. wall_index1 = wall_index1_;
  51. geometry_object_id2 = geometry_object_id2_;
  52. wall_index2 = wall_index2_;
  53. }
  54. else {
  55. geometry_object_id1 = geometry_object_id2_;
  56. wall_index1 = wall_index2_;
  57. geometry_object_id2 = geometry_object_id1_;
  58. wall_index2 = wall_index1_;
  59. }
  60. }
  61. // some ordering for usage in std::set
  62. bool operator < (const GeometryObjectWallUnorderedPair& other) const {
  63. if (geometry_object_id1 != other.geometry_object_id1) {
  64. return geometry_object_id1 < other.geometry_object_id1;
  65. }
  66. else if (wall_index1 != other.wall_index1) {
  67. return wall_index1 < other.wall_index1;
  68. }
  69. else if (geometry_object_id2 != other.geometry_object_id2) {
  70. return geometry_object_id2 < other.geometry_object_id2;
  71. }
  72. else {
  73. return wall_index2 < other.wall_index2;
  74. }
  75. }
  76. geometry_object_id_t geometry_object_id1;
  77. wall_index_t wall_index1;
  78. geometry_object_id_t geometry_object_id2;
  79. wall_index_t wall_index2;
  80. };
  81. }
  82. #endif /* LIBMCELL_API_SHARED_STRUCTS_H_ */