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
|
#include "VecGeom/volumes/Planes.h"
namespace vecgeom {
inline namespace VECGEOM_IMPL_NAMESPACE {
VECCORE_ATT_HOST_DEVICE
Planes::Planes(int size, bool convex) : fNormals(size), fDistances(size), fConvex(convex) {}
VECCORE_ATT_HOST_DEVICE
Planes::~Planes() {}
VECCORE_ATT_HOST_DEVICE
Planes &Planes::operator=(Planes const &rhs)
{
#ifndef VECCORE_CUDA_DEVICE_COMPILATION
fNormals = rhs.fNormals;
fDistances = rhs.fDistances;
#else
fNormals = SOA3D<Precision>(const_cast<Precision *>(rhs.fNormals.x()), const_cast<Precision *>(rhs.fNormals.y()),
const_cast<Precision *>(rhs.fNormals.z()), rhs.fNormals.size());
fDistances = Array<Precision>(const_cast<Precision *>(&rhs.fDistances[0]), rhs.fDistances.size());
#endif
return *this;
}
VECCORE_ATT_HOST_DEVICE
void Planes::Set(int index, Vector3D<Precision> const &normal, Vector3D<Precision> const &x0)
{
Vector3D<Precision> fixedNormal(normal);
fixedNormal.FixZeroes();
Precision inverseLength = 1. / fixedNormal.Mag();
fNormals.set(index, inverseLength * fixedNormal);
fDistances[index] = inverseLength * -fixedNormal.Dot(x0);
}
VECCORE_ATT_HOST_DEVICE
void Planes::Set(int index, Vector3D<Precision> const &normal, Precision distance)
{
fNormals.set(index, normal);
fDistances[index] = distance;
}
VECCORE_ATT_HOST_DEVICE
void Planes::FlipSign(int index)
{
fNormals.set(index, -fNormals[index]);
fDistances[index] = -fDistances[index];
}
std::ostream &operator<<(std::ostream &os, Planes const &planes)
{
for (int i = 0, iMax = planes.size(); i < iMax; ++i) {
os << "{" << planes.GetNormal(i) << ", " << planes.GetDistance(i) << "}\n";
}
return os;
}
} // namespace VECGEOM_IMPL_NAMESPACE
} // namespace vecgeom
|