ROOT logo
// $Id: HTriMesh.h 2548 2011-10-10 07:03:57Z matevz $

// Copyright (C) 1999-2008, Matevz Tadel. All rights reserved.
// This file is part of GLED, released under GNU General Public License version 2.
// For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/.

#ifndef Var1_HTriMesh_H
#define Var1_HTriMesh_H

#include <Glasses/TriMesh.h>

class HTriMesh : public TriMesh
{
  MAC_RNR_FRIENDS(HTriMesh);

private:
  void _init();

public:

  struct HNode;
  //typedef vector<HNode>            vHNode_t;
  //typedef vector<HNode>::iterator  vHNode_i;
  typedef vector<HNode*>           vpHNode_t;
  typedef vector<HNode*>::iterator vpHNode_i;

  struct HLevel;
  typedef vector<HLevel>           vHLevel_t;
  typedef vector<HLevel>::iterator vHLevel_i;

  struct HNode
  {
    HPointF fHighestV;
    Int_t   fHighestVT;

    // Triangle representing this node in h-mesh
    Int_t   fT;           // = -1 for root of list

    // Child indexes
    Int_t   fFirstChildT; // = 0 for root, < 0 for leaf node
    Int_t   fNChildT;     // == 4 ? (or some other const stuff)
                          // hmh, this is 20 for initial state

    // Child nodes; empty for leaf nodes
    vpHNode_t fSubNodes;

    HNode() {}
    HNode(Int_t s, Int_t fc, Int_t nc) { Init(s, fc, nc); }

    ~HNode()
    {
      for (vpHNode_i i = fSubNodes.begin(); i != fSubNodes.end(); ++i) delete *i;
    }

    void Init(Int_t s, Int_t fc, Int_t nc)
    {
      fHighestV.Zero();
      fHighestVT = -1;
      fT = s;
      fFirstChildT = fc;
      fNChildT = nc;
    }

    Int_t FirstT() const { return fFirstChildT; }
    Int_t LastT()  const { return fFirstChildT + fNChildT - 1; }
  };

  struct HLevel
  {
    Int_t     fLevel;
    Int_t     fFirstT;
    Int_t     fNT;

    vpHNode_t fNodes;

    // Opcode model ...

    HLevel() {}
    HLevel(Int_t l, Int_t ft, Int_t nt, Int_t nn) { Init(l, ft, nt, nn); }

    void Init(Int_t l, Int_t ft, Int_t nt, Int_t nn)
    {
      fLevel = l; fFirstT = ft; fNT = nt;
      vpHNode_t v;
      v.reserve(nn);
      fNodes.swap(v);
    }

    Int_t FirstT() const { return fFirstT; }
    Int_t LastT()  const { return fFirstT + fNT - 1; }
  };

  struct TringTvorSubdivider
  {
#ifndef __CINT__
    TringTvor        &fTvor;
    TriMesh::hEdge_t  fEdgeMap;
#endif
    Int_t         fCurV;
    Int_t         fCurT;
    Int_t         fCurLevel;

    TringTvorSubdivider(TringTvor& t) : fTvor(t) {}

    void  BeginSubdivision(Int_t n_hierarhical, Int_t n_leaf);
    Int_t SubdivideEdge(Int_t v0, Int_t v1);
    Int_t SubdivideTriangle(Int_t t);
    void  EndSubdivision();
  };

protected:
  HNode         mRootNode; //!
  vHLevel_t     mLevels;   //! X{R}
  Int_t         mMaxLevel; //! X{G}

  void subdivide_hierarhical(TringTvorSubdivider& tts);
  void subdivide_leaf       (TringTvorSubdivider& tts, Int_t n_leaf);

  void subdivide_leaf_rec(TringTvorSubdivider& tts, Int_t v0, Int_t v1, Int_t v2, Int_t depth);

public:
  HTriMesh(const Text_t* n="HTriMesh", const Text_t* t=0);
  virtual ~HTriMesh();

  void PrintLevels() const; //! X{E} 7 MButt()

  void Subdivide(Int_t n_hierarhical, Int_t n_leaf);

#include "HTriMesh.h7"
  ClassDef(HTriMesh, 1);
}; // endclass HTriMesh

#endif
 HTriMesh.h:1
 HTriMesh.h:2
 HTriMesh.h:3
 HTriMesh.h:4
 HTriMesh.h:5
 HTriMesh.h:6
 HTriMesh.h:7
 HTriMesh.h:8
 HTriMesh.h:9
 HTriMesh.h:10
 HTriMesh.h:11
 HTriMesh.h:12
 HTriMesh.h:13
 HTriMesh.h:14
 HTriMesh.h:15
 HTriMesh.h:16
 HTriMesh.h:17
 HTriMesh.h:18
 HTriMesh.h:19
 HTriMesh.h:20
 HTriMesh.h:21
 HTriMesh.h:22
 HTriMesh.h:23
 HTriMesh.h:24
 HTriMesh.h:25
 HTriMesh.h:26
 HTriMesh.h:27
 HTriMesh.h:28
 HTriMesh.h:29
 HTriMesh.h:30
 HTriMesh.h:31
 HTriMesh.h:32
 HTriMesh.h:33
 HTriMesh.h:34
 HTriMesh.h:35
 HTriMesh.h:36
 HTriMesh.h:37
 HTriMesh.h:38
 HTriMesh.h:39
 HTriMesh.h:40
 HTriMesh.h:41
 HTriMesh.h:42
 HTriMesh.h:43
 HTriMesh.h:44
 HTriMesh.h:45
 HTriMesh.h:46
 HTriMesh.h:47
 HTriMesh.h:48
 HTriMesh.h:49
 HTriMesh.h:50
 HTriMesh.h:51
 HTriMesh.h:52
 HTriMesh.h:53
 HTriMesh.h:54
 HTriMesh.h:55
 HTriMesh.h:56
 HTriMesh.h:57
 HTriMesh.h:58
 HTriMesh.h:59
 HTriMesh.h:60
 HTriMesh.h:61
 HTriMesh.h:62
 HTriMesh.h:63
 HTriMesh.h:64
 HTriMesh.h:65
 HTriMesh.h:66
 HTriMesh.h:67
 HTriMesh.h:68
 HTriMesh.h:69
 HTriMesh.h:70
 HTriMesh.h:71
 HTriMesh.h:72
 HTriMesh.h:73
 HTriMesh.h:74
 HTriMesh.h:75
 HTriMesh.h:76
 HTriMesh.h:77
 HTriMesh.h:78
 HTriMesh.h:79
 HTriMesh.h:80
 HTriMesh.h:81
 HTriMesh.h:82
 HTriMesh.h:83
 HTriMesh.h:84
 HTriMesh.h:85
 HTriMesh.h:86
 HTriMesh.h:87
 HTriMesh.h:88
 HTriMesh.h:89
 HTriMesh.h:90
 HTriMesh.h:91
 HTriMesh.h:92
 HTriMesh.h:93
 HTriMesh.h:94
 HTriMesh.h:95
 HTriMesh.h:96
 HTriMesh.h:97
 HTriMesh.h:98
 HTriMesh.h:99
 HTriMesh.h:100
 HTriMesh.h:101
 HTriMesh.h:102
 HTriMesh.h:103
 HTriMesh.h:104
 HTriMesh.h:105
 HTriMesh.h:106
 HTriMesh.h:107
 HTriMesh.h:108
 HTriMesh.h:109
 HTriMesh.h:110
 HTriMesh.h:111
 HTriMesh.h:112
 HTriMesh.h:113
 HTriMesh.h:114
 HTriMesh.h:115
 HTriMesh.h:116
 HTriMesh.h:117
 HTriMesh.h:118
 HTriMesh.h:119
 HTriMesh.h:120
 HTriMesh.h:121
 HTriMesh.h:122
 HTriMesh.h:123
 HTriMesh.h:124
 HTriMesh.h:125
 HTriMesh.h:126
 HTriMesh.h:127
 HTriMesh.h:128
 HTriMesh.h:129
 HTriMesh.h:130
 HTriMesh.h:131
 HTriMesh.h:132
 HTriMesh.h:133