![]() |
Project
|
#include <O2FlatCSG.h>
Inherits TGeoBBox.
Public Member Functions | |
| O2FlatCSG () | |
| O2FlatCSG (const char *name) | |
| ~O2FlatCSG () override | |
| O2FlatCSG (const O2FlatCSG &)=delete | |
| O2FlatCSG & | operator= (const O2FlatCSG &)=delete |
| 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 | 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; returns its index. | |
| int | AddCell (int first, int count, double volume) |
Append a cell over [first, first + count) of the halfspace array; returns its index. | |
| int | GetNhalfspaces () const |
| int | GetNcells () const |
| const FlatCSGHalfspace & | GetHalfspace (int index) const |
| const FlatCSGCell & | GetCell (int index) const |
| void | SetCellBBox (int cell, const double *lo, const double *hi) |
| void | GetCellBBox (int cell, double *lo, double *hi) const |
| void | CloseShape () |
| Build the sub-cell boxes and their BVH. Call once, after the last AddCell. | |
| bool | IsClosed () const |
| size_t | GetBVHMemory () const |
| Bytes held by the BVH nodes and the primitive-index permutation. | |
| int | GetNboxes () const |
| const FlatCSGBox & | GetBox (int index) const |
| int | GetActive (int index) const |
| For the tests: the box structure is the thing being proved sound, so it has to be readable. | |
| bool | CellContains (int index, const double *point) const |
True when every halfspace of cell index contains point. | |
| void | SetSplitDepth (int depth) |
Subdivision depth cap. See fSplitDepth for where the default comes from. | |
| void | SetMinBoxFraction (double fraction) |
| int | CellIntervals (int cell, const int *active, int nActive, const double *origin, const double *dir, double tlo, double thi, double *out, int maxOut) const |
| Bool_t | Contains (const Double_t *point) const override |
| 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 |
| 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 | 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, inside the faces of a solid box, else 0. | |
| void | ComputeBBox () override |
| The union of the retained sub-cell boxes, tighter than the union of the cell AABBs. | |
| Double_t | Capacity () const override |
| 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 | 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_t | Contains_Loop (const Double_t *point) const |
| Double_t | DistFromOutside_Loop (const Double_t *point, const Double_t *dir, Double_t step=TGeoShape::Big()) const |
| Double_t | DistFromInside_Loop (const Double_t *point, const Double_t *dir, Double_t step=TGeoShape::Big()) const |
| 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. | |
Static Public Member Functions | |
| static double | EvalHalfspace (const FlatCSGHalfspace &halfspace, const double *point) |
sign * f(point); the halfspace contains the point when this is <= 0. | |
| static void | HalfspaceRange (const FlatCSGHalfspace &halfspace, const double *lo, const double *hi, double &rangeLo, double &rangeHi) |
| 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. | |
| static void | ResetUnprunedRetryCounter () |
| Per-thread count of DistFromInside queries whose pruned traversal had to be redone unpruned. | |
| static long long | GetUnprunedRetryCount () |
Protected Types | |
| enum class | RayBound { kNone , kEntry , kExit } |
Protected Member Functions | |
| void | EnsureCellBBoxStorage () |
| Grow the per-cell bounding-box storage to the cell count. | |
| 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 active list. | |
| 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 the twin's glue. | |
| 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 boxes. | |
| void | SplitBox (int cell, const double *lo, const double *hi, const std::vector< int > &active, int depth, double minSize, int cubifyBudget) |
Protected Attributes | |
| std::vector< FlatCSGHalfspace > | fHalfspaces |
| the flat halfspace array | |
| std::vector< FlatCSGCell > | fCells |
| the DNF's cells, indexing into it | |
| std::vector< FlatCSGBox > | fBoxes |
The sub-cell boxes, rebuilt by CloseShape; not streamed. | |
| std::vector< int > | fActive |
| std::vector< double > | fCellLo |
| each cell's AABB low corner, 3 doubles per cell | |
| std::vector< double > | fCellHi |
| std::vector< bool > | fCellBBoxSet |
| bool | fClosed = false |
Set by a successful CloseShape; not streamed. The #pragma read rule closes every shape ROOT reads back. | |
| int | fSplitDepth = 4 |
| double | fMinBoxFraction = 0.05 |
| void * | fBVH = nullptr |
The BVH over fBoxes, rebuilt by CloseShape; not streamed. | |
A solid stored as a union of intersection cells over signed implicit halfspaces, the flat DNF of a decomposed part. Every accelerated query has a bit-identical _Loop twin over all cells and halfspaces.
Definition at line 55 of file O2FlatCSG.h.
|
strongprotected |
What the running bound prunes against: nothing, the nearest entry so far (DistFromOutside) or the far end of the interval holding t = 0 so far (DistFromInside).
| Enumerator | |
|---|---|
| kNone | |
| kEntry | |
| kExit | |
Definition at line 171 of file O2FlatCSG.h.
| o2::cad::O2FlatCSG::O2FlatCSG | ( | ) |
Definition at line 285 of file O2FlatCSG.cxx.
|
explicit |
Definition at line 287 of file O2FlatCSG.cxx.
|
override |
Definition at line 289 of file O2FlatCSG.cxx.
|
delete |
Append a cell over [first, first + count) of the halfspace array; returns its index.
Definition at line 335 of file O2FlatCSG.cxx.
| int o2::cad::O2FlatCSG::AddQuadric | ( | double | sign, |
| const double | coeff[10] | ||
| ) |
Append a quadric halfspace; returns its index. sign is +1 or -1, inside is sign*Q <= 0.
Definition at line 304 of file O2FlatCSG.cxx.
| int o2::cad::O2FlatCSG::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; returns its index.
Definition at line 316 of file O2FlatCSG.cxx.
|
override |
The sum of the cells' own volumes. The cells of a decomposition are disjoint by construction (decompose's volume guard checks it), so there is no inclusion-exclusion to do.
Definition at line 1329 of file O2FlatCSG.cxx.
| bool o2::cad::O2FlatCSG::CellContains | ( | int | index, |
| const double * | point | ||
| ) | const |
True when every halfspace of cell index contains point.
Definition at line 463 of file O2FlatCSG.cxx.
| int o2::cad::O2FlatCSG::CellIntervals | ( | int | cell, |
| const int * | active, | ||
| int | nActive, | ||
| const double * | origin, | ||
| const double * | dir, | ||
| double | tlo, | ||
| double | thi, | ||
| double * | out, | ||
| int | maxOut | ||
| ) | const |
The occupancy of cell cell along the ray within [tlo, thi], as [enter, exit] pairs in out; a null active uses every halfspace. Returns the pair count, or a negative value when maxOut is too small.
Definition at line 857 of file O2FlatCSG.cxx.
| void o2::cad::O2FlatCSG::CloseShape | ( | ) |
Build the sub-cell boxes and their BVH. Call once, after the last AddCell.
Definition at line 535 of file O2FlatCSG.cxx.
|
override |
The union of the retained sub-cell boxes, tighter than the union of the cell AABBs.
Definition at line 1415 of file O2FlatCSG.cxx.
|
override |
The normal of the halfspace nearest to equality at point, oriented along dir.
ComputeNormal – the halfspace with the smallest first-order distance |f| / |grad f| among the active list of the box holding point, which HalfspaceRange's 64-eps pad makes every halfspace that can be at equality there.
Definition at line 1340 of file O2FlatCSG.cxx.
|
override |
Definition at line 751 of file O2FlatCSG.cxx.
| Bool_t o2::cad::O2FlatCSG::Contains_Loop | ( | const Double_t * | point | ) | const |
Definition at line 664 of file O2FlatCSG.cxx.
|
override |
Definition at line 1209 of file O2FlatCSG.cxx.
| Double_t o2::cad::O2FlatCSG::DistFromInside_Loop | ( | const Double_t * | point, |
| const Double_t * | dir, | ||
| Double_t | step = TGeoShape::Big() |
||
| ) | const |
Definition at line 989 of file O2FlatCSG.cxx.
|
protected |
DistFromInsideBVH – the far end of the union's interval containing t = 0, merged across cells with the twin's glue.
Definition at line 1145 of file O2FlatCSG.cxx.
|
override |
Definition at line 1189 of file O2FlatCSG.cxx.
| Double_t o2::cad::O2FlatCSG::DistFromOutside_Loop | ( | const Double_t * | point, |
| const Double_t * | dir, | ||
| Double_t | step = TGeoShape::Big() |
||
| ) | const |
Definition at line 963 of file O2FlatCSG.cxx.
|
protected |
The accelerated DistFromOutside/DistFromInside bodies; each clips the ray to a box before using its active list.
DistFromOutsideBVH – the pieces are rejoined per cell, never across cells, as the twin's per-cell intervals.
Definition at line 1094 of file O2FlatCSG.cxx.
|
protected |
Grow the per-cell bounding-box storage to the cell count.
Definition at line 345 of file O2FlatCSG.cxx.
|
static |
sign * f(point); the halfspace contains the point when this is <= 0.
Definition at line 380 of file O2FlatCSG.cxx.
|
protected |
GatherRayPieces – each box's window is its own slab intersected with [0, step], never pooled across boxes.
Each box's own occupancy pieces along the ray within [0, step]: [enter, exit] in pairs and its cell in cells, unmerged. False when a CellIntervals call overflowed. smallestPruned reports the nearest entry the exit bound skipped, Big if it skipped nothing or if the bound is not kExit.
Definition at line 1026 of file O2FlatCSG.cxx.
For the tests: the box structure is the thing being proved sound, so it has to be readable.
Definition at line 97 of file O2FlatCSG.h.
|
inline |
Definition at line 95 of file O2FlatCSG.h.
| size_t o2::cad::O2FlatCSG::GetBVHMemory | ( | ) | const |
Bytes held by the BVH nodes and the primitive-index permutation.
Definition at line 295 of file O2FlatCSG.cxx.
|
inline |
Definition at line 78 of file O2FlatCSG.h.
The AABB SetCellBBox recorded for cell cell, for the sidecar writer. Reads back zeros for a cell whose box was never set.
Definition at line 370 of file O2FlatCSG.cxx.
|
inline |
Definition at line 77 of file O2FlatCSG.h.
|
inline |
Definition at line 94 of file O2FlatCSG.h.
|
inline |
Definition at line 76 of file O2FlatCSG.h.
|
inline |
Definition at line 75 of file O2FlatCSG.h.
|
override |
Points on the solid's own boundary, for the overlap checkers; kFALSE if fewer than npoints were found.
Contains – inside its box a box's active list is the cell, so the point must first be in the box's own bounds.
< cm either side of a point at which Contains must change
Definition at line 677 of file O2FlatCSG.cxx.
Definition at line 1184 of file O2FlatCSG.cxx.
|
static |
A rigorous enclosure [rangeLo, rangeHi] of sign * f over the box [lo, hi], padded outward. Requires lo[i] <= hi[i] and finite bounds, which CloseShape enforces; it does not check them.
Definition at line 403 of file O2FlatCSG.cxx.
|
static |
Real roots of sign * f(origin + t*dir) = 0, unsorted, at most four; returns the count.
Definition at line 774 of file O2FlatCSG.cxx.
|
inline |
Definition at line 89 of file O2FlatCSG.h.
|
static |
Per-thread count of DistFromInside queries whose pruned traversal had to be redone unpruned.
Definition at line 1179 of file O2FlatCSG.cxx.
|
override |
A lower bound on the distance to the boundary from the box structure: outside the nearest box, inside the faces of a solid box, else 0.
Safety – Safety_Loop's computation through the BVH; the pruning never drops the nearest box.
< the node box's squared distance, computed once when pushed
Definition at line 1252 of file O2FlatCSG.cxx.
| Double_t o2::cad::O2FlatCSG::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.
Safety_Loop – outside the distance to the nearest box; inside the distance to the faces of a wholly-inside box, else 0.
Definition at line 1230 of file O2FlatCSG.cxx.
The AABB of cell cell. The halfspaces alone do not bound a cell – an intersection of halfspaces can be unbounded – so the converter supplies the box the decomposition measured.
Definition at line 354 of file O2FlatCSG.cxx.
|
inline |
Stop splitting a box narrower than this fraction of the part's bounding-box diagonal. See fMinBoxFraction for where the default comes from.
Definition at line 105 of file O2FlatCSG.h.
Subdivision depth cap. See fSplitDepth for where the default comes from.
Definition at line 102 of file O2FlatCSG.h.
|
protected |
Recursively split [lo, hi] for cell, dropping the halfspaces the range bound decides and the boxes it proves outside. A split of a far-from-cubic box draws on cubifyBudget, any other on depth.
Definition at line 474 of file O2FlatCSG.cxx.
|
protected |
The boxes' active-halfspace lists, concatenated. Derived alongside fBoxes; not streamed for the same reason.
Definition at line 194 of file O2FlatCSG.h.
|
protected |
The sub-cell boxes, rebuilt by CloseShape; not streamed.
Definition at line 191 of file O2FlatCSG.h.
|
protected |
The BVH over fBoxes, rebuilt by CloseShape; not streamed.
Definition at line 208 of file O2FlatCSG.h.
|
protected |
Whether SetCellBBox was ever called for a given cell; CloseShape refuses to build a solid missing one rather than silently drop that cell – see CloseShape's implementation.
Definition at line 199 of file O2FlatCSG.h.
|
protected |
each cell's AABB high corner, 3 doubles per cell
Definition at line 196 of file O2FlatCSG.h.
|
protected |
each cell's AABB low corner, 3 doubles per cell
Definition at line 195 of file O2FlatCSG.h.
|
protected |
the DNF's cells, indexing into it
Definition at line 188 of file O2FlatCSG.h.
|
protected |
Set by a successful CloseShape; not streamed. The #pragma read rule closes every shape ROOT reads back.
Definition at line 201 of file O2FlatCSG.h.
|
protected |
the flat halfspace array
Definition at line 187 of file O2FlatCSG.h.
|
protected |
Definition at line 205 of file O2FlatCSG.h.
|
protected |
Subdivision depth cap, and the minimum box size as a fraction of the part's bounding-box diagonal, chosen for query cost on the shipped parts.
Definition at line 204 of file O2FlatCSG.h.