ROOT logo
// $Id: Glass_SKEL.cxx 2089 2008-11-23 20:31:03Z 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/.

#include "MonopodialTree.h"
#include "MonopodialTree.c7"
#include "TMath.h"

// MonopodialTree

//______________________________________________________________________________
//
//

ClassImp(MonopodialTree);

void MonopodialTree::_init()
{}

MonopodialTree::MonopodialTree(const Text_t* n, const Text_t* t) :
ParametricSystem(n, t),
mTrunkContraction(0.9),
mLateralContraction(0.6),
mTrunkAngle(45),
mLateralAngle(45),
mStartLength(1),
mStartWidth(0.1)
{
  _init();
  mStart = "A";
}

MonopodialTree::~MonopodialTree()
{}

void
MonopodialTree::InitialiseExpression()
{
  assert(mExpression.empty());
  mExpression.push_back(TwoParam('A', mStartLength, mStartWidth));
}

void
MonopodialTree::SetStartWidth(float x)
{
  mStartWidth = x;
  mStampReqTring = Stamp(FID());
}

void
MonopodialTree::SetStartLength(float x)
{
  mStartLength = x;
  mStampReqTring = Stamp(FID());
}

void
MonopodialTree::ExpandRule(const Text_t* rule, TwoParam& parent, ParametricSystem::Segments_t& newExp )
{
  const static float widthDecrease = TMath::Sqrt(0.5f);
  static float divergenceAngle = 137;
  
  bool firstStep = true;
  
  for (size_t k = 0; k < strlen(rule); ++k)
  {
    newExp.push_back(TwoParam(rule[k], parent.mParam1, parent.mParam2));  
    
    TwoParam& s = newExp.back();
    if (s.mType == ']')
      firstStep = false;
    
    if (s.mType == '&' || s.mType == '^')
    {
      s.mParam1 = mTrunkAngle;
    }
    else if (s.mType == '+' || s.mType == '-')
    {
      s.mParam1 = mLateralAngle;
    }
    else if (s.mType == '\\' || s.mType == '/')
    {
      s.mParam1 = divergenceAngle;
    }
    else if (s.mType == 'A' || s.mType == 'B' || s.mType == 'C')
    {
      float contraction = (firstStep) ? mLateralContraction : mTrunkContraction ;
      //   printf("contractin %f \n", contraction);
      s.mParam1 *= contraction;
      s.mParam2 *= widthDecrease;
    }
  }
}

 MonopodialTree.cxx:1
 MonopodialTree.cxx:2
 MonopodialTree.cxx:3
 MonopodialTree.cxx:4
 MonopodialTree.cxx:5
 MonopodialTree.cxx:6
 MonopodialTree.cxx:7
 MonopodialTree.cxx:8
 MonopodialTree.cxx:9
 MonopodialTree.cxx:10
 MonopodialTree.cxx:11
 MonopodialTree.cxx:12
 MonopodialTree.cxx:13
 MonopodialTree.cxx:14
 MonopodialTree.cxx:15
 MonopodialTree.cxx:16
 MonopodialTree.cxx:17
 MonopodialTree.cxx:18
 MonopodialTree.cxx:19
 MonopodialTree.cxx:20
 MonopodialTree.cxx:21
 MonopodialTree.cxx:22
 MonopodialTree.cxx:23
 MonopodialTree.cxx:24
 MonopodialTree.cxx:25
 MonopodialTree.cxx:26
 MonopodialTree.cxx:27
 MonopodialTree.cxx:28
 MonopodialTree.cxx:29
 MonopodialTree.cxx:30
 MonopodialTree.cxx:31
 MonopodialTree.cxx:32
 MonopodialTree.cxx:33
 MonopodialTree.cxx:34
 MonopodialTree.cxx:35
 MonopodialTree.cxx:36
 MonopodialTree.cxx:37
 MonopodialTree.cxx:38
 MonopodialTree.cxx:39
 MonopodialTree.cxx:40
 MonopodialTree.cxx:41
 MonopodialTree.cxx:42
 MonopodialTree.cxx:43
 MonopodialTree.cxx:44
 MonopodialTree.cxx:45
 MonopodialTree.cxx:46
 MonopodialTree.cxx:47
 MonopodialTree.cxx:48
 MonopodialTree.cxx:49
 MonopodialTree.cxx:50
 MonopodialTree.cxx:51
 MonopodialTree.cxx:52
 MonopodialTree.cxx:53
 MonopodialTree.cxx:54
 MonopodialTree.cxx:55
 MonopodialTree.cxx:56
 MonopodialTree.cxx:57
 MonopodialTree.cxx:58
 MonopodialTree.cxx:59
 MonopodialTree.cxx:60
 MonopodialTree.cxx:61
 MonopodialTree.cxx:62
 MonopodialTree.cxx:63
 MonopodialTree.cxx:64
 MonopodialTree.cxx:65
 MonopodialTree.cxx:66
 MonopodialTree.cxx:67
 MonopodialTree.cxx:68
 MonopodialTree.cxx:69
 MonopodialTree.cxx:70
 MonopodialTree.cxx:71
 MonopodialTree.cxx:72
 MonopodialTree.cxx:73
 MonopodialTree.cxx:74
 MonopodialTree.cxx:75
 MonopodialTree.cxx:76
 MonopodialTree.cxx:77
 MonopodialTree.cxx:78
 MonopodialTree.cxx:79
 MonopodialTree.cxx:80
 MonopodialTree.cxx:81
 MonopodialTree.cxx:82
 MonopodialTree.cxx:83
 MonopodialTree.cxx:84
 MonopodialTree.cxx:85
 MonopodialTree.cxx:86
 MonopodialTree.cxx:87
 MonopodialTree.cxx:88
 MonopodialTree.cxx:89
 MonopodialTree.cxx:90
 MonopodialTree.cxx:91
 MonopodialTree.cxx:92
 MonopodialTree.cxx:93
 MonopodialTree.cxx:94
 MonopodialTree.cxx:95
 MonopodialTree.cxx:96