-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add BVH-based navigation functions to TGeoTessellated #21045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
7acc8cf
dc87a3d
98d5515
ebd09b6
d45f1e4
fcf7b4e
6b18c88
30199d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,18 +60,29 @@ class TGeoTessellated : public TGeoBBox { | |
| using Vertex_t = Tessellated::Vertex_t; | ||
|
|
||
| private: | ||
| int fNfacets = 0; // Number of facets | ||
| int fNvert = 0; // Number of vertices | ||
| int fNseg = 0; // Number of segments | ||
| bool fDefined = false; //! Shape fully defined | ||
| bool fClosedBody = false; // The faces are making a closed body | ||
| std::vector<Vertex_t> fVertices; // List of vertices | ||
| std::vector<TGeoFacet> fFacets; // List of facets | ||
| int fNfacets = 0; // Number of facets | ||
| int fNvert = 0; // Number of vertices | ||
| int fNseg = 0; // Number of segments | ||
| bool fDefined = false; //! Shape fully defined | ||
| bool fClosedBody = false; // The faces are making a closed body | ||
|
|
||
| // for now separate vectors but might be better to group per face | ||
| std::vector<Vertex_t> fVertices; // List of vertices | ||
| std::vector<TGeoFacet> fFacets; // List of facets | ||
| std::vector<Vertex_t> fOutwardNormals; //! Vector of outward-facing normals | ||
|
|
||
| std::multimap<long, int> fVerticesMap; //! Temporary map used to deduplicate vertices | ||
| bool fIsClosed = false; //! to know if shape still needs closure/initialization | ||
| std::vector<unsigned char> fBVHData; // Serialized BVH data for persistence | ||
| void *fBVH = nullptr; //! BVH acceleration structure for safety and navigation | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The destructor of the class should delete fBVH
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we put the real type, can we also use a |
||
|
|
||
| TGeoTessellated(const TGeoTessellated &) = delete; | ||
| TGeoTessellated &operator=(const TGeoTessellated &) = delete; | ||
|
|
||
| // bvh helper functions | ||
| void BuildBVH(); | ||
| void CalculateNormals(); | ||
|
|
||
| public: | ||
| // constructors | ||
| TGeoTessellated() {} | ||
|
|
@@ -130,7 +141,28 @@ class TGeoTessellated : public TGeoBBox { | |
| /// Reader from .obj format | ||
| static TGeoTessellated *ImportFromObjFormat(const char *objfile, bool check = false, bool verbose = false); | ||
|
|
||
| ClassDefOverride(TGeoTessellated, 1) // tessellated shape class | ||
| // navigation functions used by TGeoNavigator (attention: only the iact == 3 cases implemented for now) | ||
| 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; | ||
| bool Contains(const Double_t *point) const override; | ||
| Double_t Safety(const Double_t *point, Bool_t in = kTRUE) const override; | ||
| void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) const override; | ||
|
|
||
| // these are trivial implementations, just for debugging | ||
| Double_t DistFromInside_Loop(const Double_t *point, const Double_t *dir) const; | ||
| Double_t DistFromOutside_Loop(const Double_t *point, const Double_t *dir) const; | ||
| bool Contains_Loop(const Double_t *point) const; | ||
|
Comment on lines
+154
to
+156
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since these are for testing purposes only, leaving them in the public interface may not be the best choice. The alternative could be to move these to a test utility, where we can add also some regression tests in future. What about |
||
|
|
||
| Double_t Capacity() const override; | ||
|
|
||
| private: | ||
| // a safety kernel used in multiple implementations | ||
| template <bool closest_facet = false> | ||
| Double_t SafetyKernel(const Double_t *point, bool in, int *closest_facet_id = nullptr) const; | ||
|
|
||
| ClassDefOverride(TGeoTessellated, 2) // tessellated shape class | ||
| }; | ||
|
|
||
| #endif | ||
Uh oh!
There was an error while loading. Please reload this page.