Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:24:50

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file orange/orangeinp/ObjectIO.json.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <nlohmann/json.hpp>
0011 
0012 #include "orange/transform/VariantTransform.hh"
0013 
0014 #include "CsgTypes.hh"
0015 
0016 namespace celeritas
0017 {
0018 namespace orangeinp
0019 {
0020 //---------------------------------------------------------------------------//
0021 class ObjectInterface;
0022 
0023 template<OperatorToken Op>
0024 class JoinObjects;
0025 class NegatedObject;
0026 class PolyCone;
0027 class PolyPrism;
0028 class ShapeBase;
0029 class SolidBase;
0030 class Transformed;
0031 
0032 class PolySegments;
0033 class SolidEnclosedAngle;
0034 class SolidZSlab;
0035 
0036 class IntersectRegionInterface;
0037 class Box;
0038 class Cone;
0039 class Cylinder;
0040 class Ellipsoid;
0041 class EllipticalCylinder;
0042 class EllipticalCone;
0043 class GenPrism;
0044 class InfSlab;
0045 class InfWedge;
0046 class Parallelepiped;
0047 class Prism;
0048 class Sphere;
0049 class Involute;
0050 
0051 //---------------------------------------------------------------------------//
0052 
0053 // Dump an object to a string
0054 std::string to_string(ObjectInterface const&);
0055 
0056 // Write objects to JSON
0057 template<OperatorToken Op>
0058 void to_json(nlohmann::json& j, JoinObjects<Op> const&);
0059 void to_json(nlohmann::json& j, NegatedObject const&);
0060 void to_json(nlohmann::json& j, PolyCone const&);
0061 void to_json(nlohmann::json& j, PolyPrism const&);
0062 void to_json(nlohmann::json& j, ShapeBase const&);
0063 void to_json(nlohmann::json& j, SolidBase const&);
0064 void to_json(nlohmann::json& j, Transformed const&);
0065 
0066 // Write helper classes to JSON
0067 void to_json(nlohmann::json& j, PolySegments const&);
0068 void to_json(nlohmann::json& j, SolidEnclosedAngle const&);
0069 void to_json(nlohmann::json& j, SolidZSlab const&);
0070 
0071 // Write intersect regions to JSON
0072 void to_json(nlohmann::json& j, IntersectRegionInterface const& cr);
0073 void to_json(nlohmann::json& j, Box const& cr);
0074 void to_json(nlohmann::json& j, Cone const& cr);
0075 void to_json(nlohmann::json& j, Cylinder const& cr);
0076 void to_json(nlohmann::json& j, Ellipsoid const& cr);
0077 void to_json(nlohmann::json& j, EllipticalCylinder const& cr);
0078 void to_json(nlohmann::json& j, EllipticalCone const& cr);
0079 void to_json(nlohmann::json& j, GenPrism const& cr);
0080 void to_json(nlohmann::json& j, InfSlab const& cr);
0081 void to_json(nlohmann::json& j, InfWedge const& cr);
0082 void to_json(nlohmann::json& j, Parallelepiped const& cr);
0083 void to_json(nlohmann::json& j, Prism const& cr);
0084 void to_json(nlohmann::json& j, Sphere const& cr);
0085 void to_json(nlohmann::json& j, Involute const& cr);
0086 
0087 //---------------------------------------------------------------------------//
0088 }  // namespace orangeinp
0089 }  // namespace celeritas
0090 
0091 namespace nlohmann
0092 {
0093 //---------------------------------------------------------------------------//
0094 // Support serialization of shared pointers to ORANGE objects
0095 using CelerSPObjConst
0096     = std::shared_ptr<celeritas::orangeinp::ObjectInterface const>;
0097 using CelerVarTransform = celeritas::VariantTransform;
0098 
0099 template<>
0100 struct adl_serializer<CelerSPObjConst>
0101 {
0102     static void to_json(json& j, CelerSPObjConst const& oi);
0103 };
0104 
0105 template<>
0106 struct adl_serializer<CelerVarTransform>
0107 {
0108     static void to_json(json& j, CelerVarTransform const& vt);
0109 };
0110 
0111 //---------------------------------------------------------------------------//
0112 }  // namespace nlohmann