viz_output_event.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2019 by
  4. * The Salk Institute for Biological Studies and
  5. * Pittsburgh Supercomputing Center, Carnegie Mellon University
  6. *
  7. * Use of this source code is governed by an MIT-style
  8. * license that can be found in the LICENSE file or at
  9. * https://opensource.org/licenses/MIT.
  10. *
  11. ******************************************************************************/
  12. #ifndef SRC4_VIZ_OUTPUT_EVENT_H_
  13. #define SRC4_VIZ_OUTPUT_EVENT_H_
  14. #include "base_event.h"
  15. #include "mcell_structs_shared.h"
  16. namespace MCell {
  17. class Partition;
  18. class Molecule;
  19. /**
  20. * Dumps world state either in a textual or cellblender format.
  21. */
  22. class VizOutputEvent: public BaseEvent {
  23. public:
  24. VizOutputEvent(World* world_)
  25. : BaseEvent(EVENT_TYPE_INDEX_VIZ_OUTPUT),
  26. viz_mode(NO_VIZ_MODE),
  27. visualize_all_species(false),
  28. world(world_) {
  29. }
  30. virtual ~VizOutputEvent() {}
  31. void step() override;
  32. void dump(const std::string ind = "") const override;
  33. void to_data_model(Json::Value& mcell_node) const override;
  34. // DiffuseReactEvent must execute only up to this event
  35. bool is_barrier() const override { return true; }
  36. bool should_visualize_all_species() const;
  37. static std::string iterations_to_string(const uint64_t current_iterations, const uint64_t total_iterations);
  38. viz_mode_t viz_mode;
  39. std::string file_prefix_name;
  40. bool visualize_all_species;
  41. uint_set<species_id_t> species_ids_to_visualize;
  42. World* world;
  43. private:
  44. void compute_where_and_norm(
  45. const Partition& p, const Molecule& m,
  46. Vec3& where, Vec3& norm
  47. );
  48. FILE* create_and_open_output_file_name();
  49. void output_ascii_molecules();
  50. void output_cellblender_molecules();
  51. };
  52. } // namespace mcell
  53. #endif // SRC4_VIZ_OUTPUT_EVENT_H_