3D Human Airway Tree
Program generuje ludzkie drzewo oskrzelowe
TreeBranchProducer.h
Idź do dokumentacji tego pliku.
1 /*
2  <one line to give the program's name and a brief idea of what it does.>
3  Copyright (C) 2011 Kacper Pluta <kacperp@wsinf.edu.pl>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19 
20 
21 #ifndef TREEBRANCHPRODUCER_H
22 #define TREEBRANCHPRODUCER_H
23 
24 #include <list>
25 #include "Branch.h"
26 #include <vtkPlane.h>
27 
28 #include <boost/bind.hpp>
29 #include <boost/thread.hpp>
30 #include <vtkClipPolyData.h>
31 #include <vtkAppendPolyData.h>
32 #include "CollisionDetection.h"
33 #include "SpaceDivision.h"
34 #include <vtkCleanPolyData.h>
35 
37 {
38 private:
39  bool flag;
40  boost::thread_group t_group;
41  boost::mutex mutex;
42  bool threads;
43  int rate;
44  double normal[3];
45  double angle[2];
46  double diameter[2];
47  double length[2];
48  float minFlowRatio;
49  double volumeTmp[2];
50  float Distance2Length;
51  float r,rl,rr;
52  vtkPolyData *ChildRegions[4];
53  CollisionDetector *detector;
54  SpaceDivision *divisorOfSpace;
55  vtkCleanPolyData *polyCleaner;
56  vtkClipPolyData *clipper;
57  vtkAppendPolyData *appendPoly;
58  boost::shared_ptr<Branch> Patella;
59  vtkPlane *cutPlane;
60  std::list<boost::shared_ptr<Branch> > &BranchList;
61  boost::shared_ptr<Branch> root;
62 
63  void SplitRegion(boost::shared_ptr< Branch > branch);
64  void ComputeCutPlane(boost::shared_ptr<Branch>, float degrees = 90.0);
65  void SetBranchingAngle();
66  void SetFlowRatio();
67  inline void SetPatella(double len = 0.001)
68  {
69  Patella.reset();
70  Patella = Branch::New(root->GetRadius(),len, root->GetTransform(),2,TWIST_OFF);
71  }
72  inline void SetPatella(double len, double diameter)
73  {
74  Patella.reset();
75  Patella = Branch::New(diameter/2.0,len, root->GetTransform(),2,TWIST_OFF);
76  }
77  void SetChildDiameters();
78  void SetChildLength();
79  double ComputeCenterOfVolume(double step, float precision, vtkPolyData *region, double branchLenght);
80  void TranslateNewBranches(boost::shared_ptr<Branch>, boost::shared_ptr<Branch>);
81  void Generate(boost::shared_ptr<Branch>);
82  void GoToNextRecursion(boost::shared_ptr<Branch>, boost::shared_ptr<Branch>);
91 
92  void RemovePunkRegions();
93  void Rule4a();
94  int Rule6a();
95  void Rule7a();
96 public:
97  void Start();
98  TreeBranchProducer(std::list<boost::shared_ptr<Branch> > &p_list, boost::shared_ptr<Branch> p_masterRoot, int p_rate, bool p_threads = false);
100 };
101 
102 #endif // TREEBRANCHPRODUCER_H