Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-12-04 11:02:25

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/orangeinp/IntersectRegion.hh"
0013 #include "orange/transform/VariantTransform.hh"
0014 
0015 #include "CsgTypes.hh"
0016 
0017 namespace celeritas
0018 {
0019 namespace orangeinp
0020 {
0021 //---------------------------------------------------------------------------//
0022 class ObjectInterface;
0023 
0024 template<OperatorToken Op>
0025 class JoinObjects;
0026 class NegatedObject;
0027 class PolyCone;
0028 class RevolvedPolygon;
0029 class ShapeBase;
0030 class SolidBase;
0031 class StackedExtrudedPolygon;
0032 class Transformed;
0033 class Truncated;
0034 
0035 class PolySegments;
0036 class EnclosedAzi;
0037 class EnclosedPolar;
0038 
0039 class IntersectRegionInterface;
0040 class Box;
0041 class Cone;
0042 class CutCylinder;
0043 class Cylinder;
0044 class Ellipsoid;
0045 class EllipticalCone;
0046 class EllipticalCylinder;
0047 class ExtrudedPolygon;
0048 class GenPrism;
0049 class InfPlane;
0050 class InfAziWedge;
0051 class InfPolarWedge;
0052 class Involute;
0053 class Paraboloid;
0054 class Parallelepiped;
0055 class Prism;
0056 class Sphere;
0057 class Tet;
0058 class Torus;
0059 
0060 //---------------------------------------------------------------------------//
0061 
0062 // Dump an object to a string
0063 std::string to_string(ObjectInterface const&);
0064 
0065 // Write objects to JSON
0066 template<OperatorToken Op>
0067 void to_json(nlohmann::json& j, JoinObjects<Op> const&);
0068 void to_json(nlohmann::json& j, NegatedObject const&);
0069 void to_json(nlohmann::json& j, PolyCone const&);
0070 void to_json(nlohmann::json& j, RevolvedPolygon const&);
0071 void to_json(nlohmann::json& j, ShapeBase const&);
0072 void to_json(nlohmann::json& j, SolidBase const&);
0073 void to_json(nlohmann::json& j, StackedExtrudedPolygon const&);
0074 void to_json(nlohmann::json& j, Transformed const&);
0075 void to_json(nlohmann::json& j, Truncated const& tr);
0076 
0077 // Write helper classes to JSON
0078 void to_json(nlohmann::json& j, PolySegments const&);
0079 void to_json(nlohmann::json& j, EnclosedAzi const&);
0080 void to_json(nlohmann::json& j, EnclosedPolar const&);
0081 
0082 // Write intersect regions to JSON
0083 void to_json(nlohmann::json& j, IntersectRegionInterface const&);
0084 void to_json(nlohmann::json& j, Box const&);
0085 void to_json(nlohmann::json& j, Cone const&);
0086 void to_json(nlohmann::json& j, CutCylinder const&);
0087 void to_json(nlohmann::json& j, Cylinder const&);
0088 void to_json(nlohmann::json& j, Ellipsoid const&);
0089 void to_json(nlohmann::json& j, EllipticalCone const&);
0090 void to_json(nlohmann::json& j, EllipticalCylinder const&);
0091 void to_json(nlohmann::json& j, ExtrudedPolygon const&);
0092 void to_json(nlohmann::json& j, GenPrism const&);
0093 void to_json(nlohmann::json& j, Hyperboloid const&);
0094 void to_json(nlohmann::json& j, InfPlane const& a);
0095 void to_json(nlohmann::json& j, InfAziWedge const&);
0096 void to_json(nlohmann::json& j, InfPolarWedge const&);
0097 void to_json(nlohmann::json& j, Involute const&);
0098 void to_json(nlohmann::json& j, Paraboloid const&);
0099 void to_json(nlohmann::json& j, Parallelepiped const&);
0100 void to_json(nlohmann::json& j, Prism const&);
0101 void to_json(nlohmann::json& j, Sphere const&);
0102 void to_json(nlohmann::json& j, Tet const&);
0103 void to_json(nlohmann::json& j, Torus const&);
0104 
0105 //---------------------------------------------------------------------------//
0106 }  // namespace orangeinp
0107 }  // namespace celeritas
0108 
0109 namespace nlohmann
0110 {
0111 //---------------------------------------------------------------------------//
0112 // Support serialization of shared pointers to ORANGE objects
0113 using CelerSPObjConst
0114     = std::shared_ptr<celeritas::orangeinp::ObjectInterface const>;
0115 using CelerVarTransform = celeritas::VariantTransform;
0116 
0117 template<>
0118 struct adl_serializer<CelerSPObjConst>
0119 {
0120     static void to_json(json& j, CelerSPObjConst const& oi);
0121 };
0122 
0123 template<>
0124 struct adl_serializer<CelerVarTransform>
0125 {
0126     static void to_json(json& j, CelerVarTransform const& vt);
0127 };
0128 
0129 //---------------------------------------------------------------------------//
0130 }  // namespace nlohmann