gen_introspection.cpp 4.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 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. #include <sstream>
  12. #include "api/pybind11_stl_include.h"
  13. #include "api/python_export_utils.h"
  14. #include "gen_introspection.h"
  15. #include "api/introspection.h"
  16. #include "api/color.h"
  17. #include "api/complex.h"
  18. #include "api/geometry_object.h"
  19. #include "api/molecule.h"
  20. #include "api/wall.h"
  21. namespace MCell {
  22. namespace API {
  23. std::shared_ptr<Introspection> GenIntrospection::copy_introspection() const {
  24. std::shared_ptr<Introspection> res = std::make_shared<Introspection>(DefaultCtorArgType());
  25. return res;
  26. }
  27. std::shared_ptr<Introspection> GenIntrospection::deepcopy_introspection(py::dict) const {
  28. std::shared_ptr<Introspection> res = std::make_shared<Introspection>(DefaultCtorArgType());
  29. return res;
  30. }
  31. bool GenIntrospection::__eq__(const Introspection& other) const {
  32. return
  33. true ;
  34. }
  35. bool GenIntrospection::eq_nonarray_attributes(const Introspection& other, const bool ignore_name) const {
  36. return
  37. true ;
  38. }
  39. std::string GenIntrospection::to_str(const bool all_details, const std::string ind) const {
  40. std::stringstream ss;
  41. ss << "Introspection";
  42. return ss.str();
  43. }
  44. py::class_<Introspection> define_pybinding_Introspection(py::module& m) {
  45. return py::class_<Introspection, std::shared_ptr<Introspection>>(m, "Introspection", "Only internal. This class is used only as a base class to Model, it is not provided through API. Defines interface to introspect simulation state.")
  46. .def(
  47. py::init<
  48. >()
  49. )
  50. .def("__copy__", &Introspection::copy_introspection)
  51. .def("__deepcopy__", &Introspection::deepcopy_introspection, py::arg("memo"))
  52. .def("__str__", &Introspection::to_str, py::arg("all_details") = false, py::arg("ind") = std::string(""))
  53. .def("__eq__", &Introspection::__eq__, py::arg("other"))
  54. .def("get_molecule_ids", &Introspection::get_molecule_ids, py::arg("pattern") = nullptr, "Returns a list of ids of molecules.\nIf the arguments pattern is not set, the list of all molecule ids is returned. \nIf the argument pattern is set, the list of all molecule ids whose species match \nthe pattern is returned. \n\n- pattern: BNGL pattern to select molecules based on their species, might use compartments.\n\n")
  55. .def("get_molecule", &Introspection::get_molecule, py::arg("id"), "Returns a information on a molecule from the simulated environment, \nNone if the molecule does not exist.\n\n- id: Unique id of the molecule to be retrieved.\n\n")
  56. .def("get_species_name", &Introspection::get_species_name, py::arg("species_id"), "Returns a string representing canonical species name in the BNGL format.\n\n- species_id: Id of the species.\n\n")
  57. .def("get_vertex", &Introspection::get_vertex, py::arg("object"), py::arg("vertex_index"), "Returns coordinates of a vertex.\n- object\n- vertex_index: This is the index of the vertex in the geometry object's walls (wall_list).\n\n")
  58. .def("get_wall", &Introspection::get_wall, py::arg("object"), py::arg("wall_index"), "Returns information about a wall belonging to a given object.\n- object: Geometry object whose wall to retrieve.\n\n- wall_index: This is the index of the wall in the geometry object's walls (wall_list).\n\n")
  59. .def("get_vertex_unit_normal", &Introspection::get_vertex_unit_normal, py::arg("object"), py::arg("vertex_index"), "Returns sum of all wall normals that use this vertex converted to a unit vector of \nlength 1 um (micrometer).\nThis represents the unit vector pointing outwards from the vertex.\n\n- object: Geometry object whose vertex to retrieve.\n\n- vertex_index: This is the index of the vertex in the geometry object's vertex_list.\n\n")
  60. .def("get_wall_unit_normal", &Introspection::get_wall_unit_normal, py::arg("object"), py::arg("wall_index"), "Returns wall normal converted to a unit vector of length 1um.\n- object: Geometry object whose wall's normal to retrieve.\n\n- wall_index: This is the index of the vertex in the geometry object's walls (wall_list).\n\n")
  61. .def("get_wall_color", &Introspection::get_wall_color, py::arg("object"), py::arg("wall_index"), "Returns color of a wall.\n- object: Geometry object whose wall's color to retrieve.\n\n- wall_index: This is the index of the vertex in the geometry object's walls (wall_list).\n\n")
  62. .def("set_wall_color", &Introspection::set_wall_color, py::arg("object"), py::arg("wall_index"), py::arg("color"), "Sets color of a wall.\n- object: Geometry object whose wall's color to retrieve.\n\n- wall_index: This is the index of the vertex in the geometry object's walls (wall_list).\n\n- color: Color to be set.\n\n")
  63. .def("dump", &Introspection::dump)
  64. ;
  65. }
  66. } // namespace API
  67. } // namespace MCell