Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:56

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