File: UnplacedMultiUnion.h

package info (click to toggle)
vecgeom 1.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 23,928 kB
  • sloc: cpp: 88,717; ansic: 6,894; python: 1,035; sh: 582; sql: 538; makefile: 29
file content (126 lines) | stat: -rw-r--r-- 4,311 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#ifndef VECGEOM_VOLUMES_UNPLACEDMULTIUNION_H_
#define VECGEOM_VOLUMES_UNPLACEDMULTIUNION_H_
/**
 @brief Class representing an unplaced union of multiple placed solids, possibly overlapping.
 Implemented based on the class G4MultipleUnion
 @author mihaela.gheata@cern.ch
*/

#include "VecGeom/base/Cuda.h"
#include "VecGeom/base/Global.h"
#include "VecGeom/base/AlignedBase.h"
#include "VecGeom/base/Vector3D.h"
#include "VecGeom/volumes/UnplacedVolume.h"
#include "MultiUnionStruct.h"
#include "VecGeom/volumes/kernel/MultiUnionImplementation.h"
#include "VecGeom/volumes/UnplacedVolumeImplHelper.h"

namespace vecgeom {

VECGEOM_DEVICE_DECLARE_CONV(class, UnplacedMultiUnion);
VECGEOM_DEVICE_FORWARD_DECLARE(class UnplacedMultiUnion;);

inline namespace VECGEOM_IMPL_NAMESPACE {

class UnplacedMultiUnion : public LoopUnplacedVolumeImplHelper<MultiUnionImplementation>, public AlignedBase {

protected:
  mutable MultiUnionStruct fMultiUnion; ///< Structure storing multi-union parameters

public:
  // the constructor
  VECCORE_ATT_HOST_DEVICE
  UnplacedMultiUnion() : fMultiUnion()
  {
    fGlobalConvexity = false;
    ComputeBBox();
  }

  VECCORE_ATT_HOST_DEVICE
  VECGEOM_FORCE_INLINE
  void AddNode(VUnplacedVolume const *volume, Transformation3D const &transform)
  {
    LogicalVolume *lvol = new LogicalVolume(volume);
    VPlacedVolume *pvol = lvol->Place(new Transformation3D(transform));
    fMultiUnion.AddNode(pvol);
  }

  VECCORE_ATT_HOST_DEVICE
  VECGEOM_FORCE_INLINE
  void AddNode(VPlacedVolume const *volume) { fMultiUnion.AddNode(volume); }

  VECCORE_ATT_HOST_DEVICE
  void Close() { fMultiUnion.Close(); }

  VECCORE_ATT_HOST_DEVICE
  VECGEOM_FORCE_INLINE
  VPlacedVolume const *GetNode(size_t i) const { return fMultiUnion.fVolumes[i]; }

  VECCORE_ATT_HOST_DEVICE
  MultiUnionStruct const &GetStruct() const { return fMultiUnion; }

  VECCORE_ATT_HOST_DEVICE
  bool Normal(Vector3D<Precision> const &point, Vector3D<Precision> &normal) const override;

  Precision Capacity() const override;

  Precision SurfaceArea() const override;

  VECCORE_ATT_HOST_DEVICE
  VECGEOM_FORCE_INLINE
  size_t GetNumberOfSolids() const { return fMultiUnion.fVolumes.size(); }

  VECCORE_ATT_HOST_DEVICE
  void Extent(Vector3D<Precision> &aMin, Vector3D<Precision> &aMax) const override
  {
    aMin = fMultiUnion.fMinExtent;
    aMax = fMultiUnion.fMaxExtent;
  }

  Vector3D<Precision> SamplePointOnSurface() const override;

  std::string GetEntityType() const { return "MultiUnion"; }

  VECCORE_ATT_HOST_DEVICE
  virtual void Print() const override{};

  virtual void Print(std::ostream & /*os*/) const override{};

  template <TranslationCode transCodeT, RotationCode rotCodeT>
  VECCORE_ATT_DEVICE
  static VPlacedVolume *Create(LogicalVolume const *const logical_volume, Transformation3D const *const transformation,
#ifdef VECCORE_CUDA
                               const int id,
#endif
                               VPlacedVolume *const placement = NULL);

#ifdef VECGEOM_CUDA_INTERFACE
#ifdef VECGEOM_CUDA_HYBRID2
  virtual size_t DeviceSizeOf() const override { return DevicePtr<cuda::UnplacedMultiUnion>::SizeOf(); }
  virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override;
  virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override;
#else
  virtual size_t DeviceSizeOf() const override { return 0; }
  virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu() const override { return DevicePtr<cuda::VUnplacedVolume>(); }
  virtual DevicePtr<cuda::VUnplacedVolume> CopyToGpu(DevicePtr<cuda::VUnplacedVolume> const gpu_ptr) const override
  {
    return DevicePtr<cuda::VUnplacedVolume>(gpu_ptr);
  }
#endif
#endif

private:
  VECCORE_ATT_DEVICE
  virtual VPlacedVolume *SpecializedVolume(LogicalVolume const *const volume,
                                           Transformation3D const *const transformation,
                                           const TranslationCode trans_code, const RotationCode rot_code,
#ifdef VECCORE_CUDA
                                           const int id,
#endif
                                           VPlacedVolume *const placement = NULL) const override;

}; // End class
} // End impl namespace
} // End global namespace

#endif /* VECGEOM_VOLUMES_UNPLACEDMULTIUNION_H_ */