Dear experts
Is there a way to get the pointer of a private member of a TObject, say TGraphDelaunay2D
? I want to get all triangles for debug purpose, is there a way to do that in ROOT?
Dear experts
Is there a way to get the pointer of a private member of a TObject, say TGraphDelaunay2D
? I want to get all triangles for debug purpose, is there a way to do that in ROOT?
Hi @Crisps,
while there are some hacks to do that, when looking at the TGraphDelaunay2D code, I see member functions to access the triangles and also the TGraph2D object.
TGraph2D *GetGraph2D() const {return fGraph2D;}
Double_t GetMarginBinsContent() const {return fDelaunay.ZOuterValue();}
Int_t GetNdt() const {return fDelaunay.NumberOfTriangles(); }
Double_t GetXNmin() const {return fDelaunay.XMin();}
Double_t GetXNmax() const {return fDelaunay.XMax();}
Double_t GetYNmin() const {return fDelaunay.YMin();}
Double_t GetYNmax() const {return fDelaunay.YMax();}
void SetMarginBinsContent(Double_t z=0.) { fDelaunay.SetZOuterValue(z); }
Triangles::const_iterator begin() const { return fDelaunay.begin(); }
Triangles::const_iterator end() const { return fDelaunay.end(); }
Or am I missing something?
By the way, if you see that there is information that’s useful for debugging purpose but not accessible, we appreciate if you open a GitHub issue requesting a public accessor instead of hacking around it (or even open a pull request if you want). Others who run into the same problem will thank you
Some possible temporary hacks:
protected
, derive from the class and define public accessor functions, for example (assuming the info would not be available yet):class MyTGraphDelaunay2D : public TGraphDelaunay2D {
public:
// Using base class constructors
using TGraphDelaunay2D::TGraphDelaunay2D;
TGraph2D *graph2D() { return fGraph2D; }
ROOT::Math::Delaunay2D const& delaunay() { return fDelaunay; }
};
#define private public
in a preprocessor macro before including the header file (very evil, don’t do that haha!)I hope this helps!
Cheers,
Jonas
Thank you for the very detailed answer! I know there are some methods to get the data from triangles, but my purpose is to change the triangles (specifically, delete some of them) inside the TGraph2D
or TGraphDelaunay2D
object. Can you give some suggestion how can I do it? Like shifting the address of Object pointer of TGraph2D
?
The purpose is relating to this question, I want to delete triangles that out of concave curve.
The right place to look at is Delaunay2D. See my answer to the other question
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.