14#ifndef ALICEO2_CADSUPPORT_O2FLATCSG_
15#define ALICEO2_CADSUPPORT_O2FLATCSG_
69 int AddQuadric(
double sign,
const double coeff[10]);
71 int AddTorus(
double sign,
const double* centre,
const double* axis,
double major,
double minor);
82 void SetCellBBox(
int cell,
const double* lo,
const double* hi);
85 void GetCellBBox(
int cell,
double* lo,
double* hi)
const;
113 double& rangeLo,
double& rangeHi);
117 const double* dir,
double* roots);
122 const double* dir,
double tlo,
double thi,
double* out,
int maxOut)
const;
125 Bool_t
Contains(
const Double_t* point)
const override;
127 Double_t
DistFromOutside(
const Double_t* point,
const Double_t* dir, Int_t iact = 1,
128 Double_t step = TGeoShape::Big(), Double_t* safe =
nullptr)
const override;
129 Double_t
DistFromInside(
const Double_t* point,
const Double_t* dir, Int_t iact = 1,
130 Double_t step = TGeoShape::Big(), Double_t* safe =
nullptr)
const override;
133 Double_t
Safety(
const Double_t* point, Bool_t in = kTRUE)
const override;
147 void ComputeNormal(
const Double_t* point,
const Double_t* dir, Double_t* norm)
const override;
155 Double_t step = TGeoShape::Big())
const;
157 Double_t step = TGeoShape::Big())
const;
159 Double_t
Safety_Loop(
const Double_t* point, Bool_t in = kTRUE)
const;
166 Double_t
DistFromOutsideBVH(
const Double_t* point,
const Double_t* dir, Double_t step)
const;
167 Double_t
DistFromInsideBVH(
const Double_t* point,
const Double_t* dir, Double_t step)
const;
178 bool GatherRayPieces(
const Double_t* point,
const Double_t* dir, Double_t step,
179 std::vector<double>& pairs, std::vector<int>&
cells,
RayBound bound,
180 double& smallestPruned)
const;
184 void SplitBox(
int cell,
const double* lo,
const double* hi,
const std::vector<int>&
active,
header::DataOrigin origin
void SplitBox(int cell, const double *lo, const double *hi, const std::vector< int > &active, int depth, double minSize, int cubifyBudget)
static long long GetUnprunedRetryCount()
std::vector< int > fActive
const FlatCSGBox & GetBox(int index) const
void * fBVH
The BVH over fBoxes, rebuilt by CloseShape; not streamed.
Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const override
int AddCell(int first, int count, double volume)
Append a cell over [first, first + count) of the halfspace array; returns its index.
Double_t DistFromOutside_Loop(const Double_t *point, const Double_t *dir, Double_t step=TGeoShape::Big()) const
std::vector< double > fCellLo
each cell's AABB low corner, 3 doubles per cell
int AddQuadric(double sign, const double coeff[10])
Append a quadric halfspace; returns its index. sign is +1 or -1, inside is sign*Q <= 0.
int CellIntervals(int cell, const int *active, int nActive, const double *origin, const double *dir, double tlo, double thi, double *out, int maxOut) const
static int HalfspaceRoots(const FlatCSGHalfspace &halfspace, const double *origin, const double *dir, double *roots)
Real roots of sign * f(origin + t*dir) = 0, unsorted, at most four; returns the count.
bool fClosed
Set by a successful CloseShape; not streamed. The #pragma read rule closes every shape ROOT reads bac...
int GetActive(int index) const
For the tests: the box structure is the thing being proved sound, so it has to be readable.
int GetNhalfspaces() const
Bool_t GetPointsOnSegments(Int_t npoints, Double_t *array) const override
Points on the solid's own boundary, for the overlap checkers; kFALSE if fewer than npoints were found...
bool GatherRayPieces(const Double_t *point, const Double_t *dir, Double_t step, std::vector< double > &pairs, std::vector< int > &cells, RayBound bound, double &smallestPruned) const
GatherRayPieces – each box's window is its own slab intersected with [0, step], never pooled across b...
void EnsureCellBBoxStorage()
Grow the per-cell bounding-box storage to the cell count.
Double_t Safety_Loop(const Double_t *point, Bool_t in=kTRUE) const
Safety's twin over all boxes: it must equal Safety and be a sound bound.
void SetSplitDepth(int depth)
Subdivision depth cap. See fSplitDepth for where the default comes from.
O2FlatCSG(const O2FlatCSG &)=delete
Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const override
Double_t DistFromInsideBVH(const Double_t *point, const Double_t *dir, Double_t step) const
DistFromInsideBVH – the far end of the union's interval containing t = 0, merged across cells with th...
std::vector< bool > fCellBBoxSet
static double EvalHalfspace(const FlatCSGHalfspace &halfspace, const double *point)
sign * f(point); the halfspace contains the point when this is <= 0.
void CloseShape()
Build the sub-cell boxes and their BVH. Call once, after the last AddCell.
Bool_t Contains_Loop(const Double_t *point) const
Double_t Safety(const Double_t *point, Bool_t in=kTRUE) const override
A lower bound on the distance to the boundary from the box structure: outside the nearest box,...
static void HalfspaceRange(const FlatCSGHalfspace &halfspace, const double *lo, const double *hi, double &rangeLo, double &rangeHi)
void ComputeBBox() override
The union of the retained sub-cell boxes, tighter than the union of the cell AABBs.
const FlatCSGCell & GetCell(int index) const
std::vector< double > fCellHi
Double_t DistFromInside_Loop(const Double_t *point, const Double_t *dir, Double_t step=TGeoShape::Big()) const
int AddTorus(double sign, const double *centre, const double *axis, double major, double minor)
Append a torus halfspace, inside sign * (sqrt((rho - major)^2 + z^2) - minor) <= 0 about unit axis; r...
void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) const override
The normal of the halfspace nearest to equality at point, oriented along dir.
Bool_t Contains(const Double_t *point) const override
void GetCellBBox(int cell, double *lo, double *hi) const
std::vector< FlatCSGCell > fCells
the DNF's cells, indexing into it
void SetMinBoxFraction(double fraction)
Double_t Capacity() const override
size_t GetBVHMemory() const
Bytes held by the BVH nodes and the primitive-index permutation.
static void ResetUnprunedRetryCounter()
Per-thread count of DistFromInside queries whose pruned traversal had to be redone unpruned.
bool CellContains(int index, const double *point) const
True when every halfspace of cell index contains point.
Double_t DistFromOutsideBVH(const Double_t *point, const Double_t *dir, Double_t step) const
The accelerated DistFromOutside/DistFromInside bodies; each clips the ray to a box before using its a...
const FlatCSGHalfspace & GetHalfspace(int index) const
std::vector< FlatCSGBox > fBoxes
The sub-cell boxes, rebuilt by CloseShape; not streamed.
std::vector< FlatCSGHalfspace > fHalfspaces
the flat halfspace array
void SetCellBBox(int cell, const double *lo, const double *hi)
O2FlatCSG & operator=(const O2FlatCSG &)=delete
GLuint const GLchar * name
GLint GLint GLsizei GLsizei GLsizei depth
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
One DNF cell: [first, first + count) of the halfspace array, intersected; volume is its own volume.
std::vector< Cell > cells