|
|
|||
File indexing completed on 2026-04-17 08:35:36
0001 #ifndef VECGEOM_SURFACE_BREPHELPER_H_ 0002 #define VECGEOM_SURFACE_BREPHELPER_H_ 0003 0004 #include "VecGeom/base/Assert.h" 0005 #include <functional> 0006 #include <map> 0007 #include <VecGeom/surfaces/Model.h> 0008 #include <VecGeom/surfaces/SurfData.h> 0009 #include <VecGeom/surfaces/conv/SolidConverter.h> 0010 #include <VecGeom/surfaces/bvh/BVHsurfCreator.h> 0011 #include <VecGeom/management/Logger.h> 0012 0013 // Check if math necessary 0014 #include <VecGeom/base/Math.h> 0015 #include <VecGeom/volumes/LogicalVolume.h> 0016 #include <VecGeom/volumes/Box.h> 0017 #include <VecGeom/volumes/Trd.h> 0018 #include <VecGeom/volumes/Tube.h> 0019 #include <VecGeom/volumes/BooleanVolume.h> 0020 #include <VecGeom/management/GeoManager.h> 0021 // #include <VecGeom/management/BVHManager.h> 0022 0023 namespace vgbrep { 0024 0025 template <typename Real_t> 0026 class BrepHelper { 0027 using SurfData_t = SurfData<Real_t>; 0028 using EllipData_t = EllipData<Real_t>; 0029 using TorusData_t = TorusData<Real_t>; 0030 using Arb4Data_t = Arb4Data<Real_t>; 0031 using WindowMask_t = WindowMask<Real_t>; 0032 using RingMask_t = RingMask<Real_t>; 0033 using ZPhiMask_t = ZPhiMask<Real_t>; 0034 using TriangleMask_t = TriangleMask<Real_t>; 0035 using QuadMask_t = QuadrilateralMask<Real_t>; 0036 using CPUsurfData_t = CPUsurfData<vecgeom::Precision>; 0037 using SideDivision_t = SideDivision<Real_t>; 0038 0039 private: 0040 int fVerbose{0}; ///< verbosity level 0041 SurfData_t *fSurfData{nullptr}; ///< Surface data 0042 CPUsurfData_t &fCPUdata; ///< Transient CPU surface data used during conversion 0043 0044 public: 0045 ~BrepHelper(); 0046 0047 /// @brief Returns the singleton instance (CPU only) 0048 /// @return Singleton instance 0049 static BrepHelper &Instance(); 0050 0051 /// @brief Clear all content of the arrays 0052 void ClearData(); 0053 0054 /// @brief Top-level conversion from a closed GeoManager to the surface model 0055 /// @return Successful conversion 0056 bool Convert(); 0057 0058 /// @brief Surface data getter 0059 SurfData_t const &GetSurfData() const { return *fSurfData; } 0060 0061 /// @brief Print a summary on the numbers and sizes for the surface data 0062 void PrintSurfData(); 0063 0064 /// @brief Construction time verbosity 0065 /// @param verbose Verbosity level 0066 void SetVerbosity(int verbose) { fVerbose = verbose; } 0067 0068 // methods 0069 private: 0070 /// @brief Private ctor used by the singleton creation 0071 BrepHelper(); 0072 0073 /// @brief Computes default states for both sides of a common surface 0074 /// @param common_id Comon surface id 0075 void ComputeDefaultStates(int common_id); 0076 0077 /// @brief Computes the division helper for a cylindrical side. 0078 /// @param side Side to which the extent is computed 0079 /// @param extent_full extent of the side 0080 /// @return Index of the helper 0081 int ComputeCylinderDivision(Side &side, ZPhiMask<double> extent_full); 0082 0083 // Computes bounding extent on a side of cylindrical surface 0084 ZPhiMask<double> ComputeCylinderExtent(const Side &side); 0085 0086 /// @brief Computes the division helper for a planar side. 0087 /// @param side Side to which the extent is computed 0088 /// @param extent_full extent of the side 0089 /// @return Index of the helper 0090 int ComputePlaneDivision(Side &side, WindowMask<double> extent_full); 0091 0092 /// @brief Computes the bounding extent on a planar side. 0093 /// @param side Side to which the extent is computed 0094 WindowMask<double> ComputePlaneExtent(const Side &side); 0095 0096 /// @brief Computes division helpers for all sides 0097 void ComputeSideDivisions(); 0098 0099 /// @brief Computes the indexes of the frames traversed into from one side to another 0100 /// @param surf Common surface being checked 0101 /// @param left Is left side 0102 void ComputeTraversalFrames(int common_id, bool left); 0103 0104 /// @brief Computes the indexes of the frames traversed from a frame to the other side 0105 /// @param common_id Common surface 0106 /// @param left Side 0107 /// @param iframe Frame id 0108 void ComputeTraversalForFrame(int common_id, bool left, int iframe); 0109 0110 /// @brief Count the number of direct traversals found per CS 0111 /// @param surf Common surface 0112 /// @param nfound Number of traversals found 0113 /// @param ntotal Total number of frames on both sides 0114 void CountTraversals(const CommonSurface<Real_t> &surf, int &nfound, int &ntotal) const; 0115 0116 // /// @brief Computes extents for the sides of all common surfaces 0117 // /// @return Operation success 0118 // bool ComputeExtents(); 0119 0120 ///< This method uses the transformation T1 of the first placed surface on the left side (which always exists) 0121 ///< as transformation for the common surface, then recalculates the transformations of all placed 0122 ///< surfaces as T' = T1.Inverse() * T. If identity this will get the index 0. 0123 void ConvertTransformations(int idsurf); 0124 0125 ///< This method creates helper lists of candidate surfaces for each navigation state 0126 void CreateCandidateLists(); 0127 0128 ///< @brief Create a common surface in scene_id 0129 int CreateCommonSurface(int idglob, int volId, int scene_id, int &iframe, char &iside); 0130 0131 /// @brief Method creating all common surfaces 0132 bool CreateCommonSurfacesScenes(); 0133 0134 /// @brief Create local surfaces by convering all defined solids 0135 bool CreateLocalSurfaces(); 0136 0137 /// @brief Iterate the geometry tree and flatten surfaces at scene level 0138 /// @return Success of operation 0139 void DumpBVH(uint ivol); 0140 0141 /// @brief This function evaluates if the frames of two placed surfaces on the same side of a common surface are matching 0142 /// @param side Side containing the framed surfaces 0143 /// @param i1 Index of the first framed surface 0144 /// @param i2 Index of the second framed surface 0145 /// @return Equality 0146 bool EqualFrames(Side const &side, int i1, int i2); 0147 0148 /// @brief Iterates over all logical volumes and initializes the data needed for BVH construction and navigation 0149 void InitBVHData(); 0150 0151 /// @brief Iterates over all logical volumes and identifies convex surfaces in booleans, which can be treated as normal surfaces 0152 void FindConvexBooleanSurfaces(); 0153 0154 /// @brief Get the 2D extent of a planar frame, positioned with the transformation trans 0155 /// @param framed_surf Framed surface 0156 /// @param trans Transformation applied to the framed surface 0157 /// @return 2D window extent in the parent reference 0158 WindowMask<double> GetPlanarFrameExtent(FramedSurface<Real_t, TransformationMP<Real_t>> const &framed_surf, 0159 TransformationMP<Real_t> const &trans); 0160 0161 /// @brief Print the list of common surface candidates for a given state 0162 /// @param state Full state (not just local scene state) 0163 void PrintCandidates(vecgeom::NavigationState const &state); 0164 void PrintCandidateLists(); 0165 0166 /// @brief Print verbose info for a common surface 0167 /// @param common_id Common surface index 0168 void PrintCommonSurface(int common_id); 0169 0170 /// @brief Print verbose info for a framed surface 0171 /// @param surf Framed surface 0172 template <typename Real_i, typename Transformation_t> 0173 void PrintFramedSurface(FramedSurface<Real_i, Transformation_t> const &surf); 0174 0175 /// @brief Reserve container slots based on the number of registered volumes 0176 /// @param nvolumes Number of registered volumes 0177 void SetNvolumes(int nvolumes); 0178 0179 /// @brief Sort framed surfaces on sides, daughters first (see: FramedSurface::operator< ) 0180 /// @param common_id Common surface id for which to sort sides 0181 void SortSides(int common_id); 0182 0183 /// @brief A function to update all mask containers. 0184 /// @details Needs to be called when updating masks after creating both frames and extents. 0185 void UpdateMaskData(); 0186 0187 /// @brief The method updates the SurfData storage 0188 void UpdateSurfData(); 0189 }; 0190 0191 } // namespace vgbrep 0192 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|