Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:40

0001 // @(#)root/eve7:$Id$
0002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT7_REvePolygonSetProjected
0013 #define ROOT7_REvePolygonSetProjected
0014 
0015 #include <ROOT/REveVector.hxx>
0016 #include <ROOT/REveShape.hxx>
0017 
0018 #include <vector>
0019 
0020 class TBuffer3D;
0021 
0022 namespace ROOT {
0023 namespace Experimental {
0024 
0025 // =========================================================================
0026 // REvePolygonSetProjected
0027 // Set of projected polygons with outline; typically produced from a TBuffer3D.
0028 // =========================================================================
0029 
0030 class REvePolygonSetProjected : public REveShape,
0031                                 public REveProjected
0032 {
0033 private:
0034    REvePolygonSetProjected(const REvePolygonSetProjected &) = delete;
0035    REvePolygonSetProjected &operator=(const REvePolygonSetProjected &) = delete;
0036 
0037 protected:
0038    struct Polygon_t {
0039       std::vector<UInt_t> fPnts; // point indices
0040 
0041       Polygon_t() = default;
0042       Polygon_t(std::vector<UInt_t> &&pnts) : fPnts(pnts){};
0043       ~Polygon_t() = default;
0044 
0045       int NPoints() const { return (UInt_t)fPnts.size(); }
0046 
0047       int FindPoint(int pi)
0048       {
0049          auto dist = std::distance(fPnts.begin(), std::find(fPnts.begin(), fPnts.end(), pi));
0050          return (dist >= (int) fPnts.size()) ? -1 : (int) dist;
0051       }
0052    };
0053 
0054    typedef std::list<Polygon_t> vpPolygon_t;
0055 
0056 private:
0057    std::unique_ptr<TBuffer3D> fBuff; // buffer of projectable object
0058 
0059    Bool_t IsFirstIdxHead(Int_t s0, Int_t s1);
0060    Float_t AddPolygon(std::list<UInt_t> &pp, std::list<Polygon_t> &p);
0061 
0062    std::vector<UInt_t> ProjectAndReducePoints();
0063    Float_t MakePolygonsFromBP(std::vector<UInt_t> &idxMap);
0064    Float_t MakePolygonsFromBS(std::vector<UInt_t> &idxMap);
0065 
0066 protected:
0067    vpPolygon_t fPols;   ///<! polygons
0068    vpPolygon_t fPolsBS; ///<! polygons build from TBuffer3D segments
0069    vpPolygon_t fPolsBP; ///<! polygons build from TBuffer3D polygons
0070 
0071    std::vector<REveVector> fPnts; ///<! reduced and projected points
0072 
0073    void SetDepthLocal(Float_t d) override;
0074 
0075    Float_t PolygonSurfaceXY(const Polygon_t &poly) const;
0076 
0077 public:
0078    REvePolygonSetProjected(const std::string &n = "REvePolygonSetProjected", const std::string &t = "");
0079    ~REvePolygonSetProjected() override;
0080 
0081    void ComputeBBox() override;
0082    // TClass* ProjectedClass() same as for REveShape
0083 
0084    void SetProjection(REveProjectionManager *mng, REveProjectable *model) override;
0085    void UpdateProjection() override;
0086    REveElement *GetProjectedAsElement() override { return this; }
0087 
0088    void ProjectBuffer3D();
0089 
0090    virtual void DumpPolys() const;
0091    void DumpBuffer3D();
0092 
0093    Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
0094    void BuildRenderData() override;
0095 };
0096 
0097 } // namespace Experimental
0098 } // namespace ROOT
0099 
0100 #endif