bngl_utils.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2020 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 "generated/gen_geometry_utils.h"
  12. #include "bng/bng.h"
  13. #include "api/geometry_object.h"
  14. using namespace std;
  15. namespace MCell {
  16. namespace API {
  17. namespace bngl_utils {
  18. std::map<std::string, double> load_bngl_parameters(
  19. const std::string& file_name,
  20. const std::map<std::string, double>& parameter_overrides
  21. ) {
  22. BNG::BNGData bng_data;
  23. int num_errors = BNG::parse_bngl_file(file_name, bng_data, parameter_overrides);
  24. if (num_errors != 0) {
  25. throw RuntimeError("Could not parse BNGL file " + file_name + ".");
  26. }
  27. return bng_data.get_parameters();
  28. }
  29. } // namespace bngl_utils
  30. } // namespace API
  31. } // namespace MCell