All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
larcorealg/larcorealg/GeoAlgo/GeoObjCollection.cxx
Go to the documentation of this file.
3 
4 #include "TString.h" // for Form
5 
6 #include <utility>
7 
8 namespace geoalgo {
9 
11  {
12  _pt_v.clear();
13  _box_v.clear();
14  _seg_v.clear();
15  _trj_v.clear();
16  _lin_v.clear();
17  _cone_v.clear();
18  //_sphere_v.clear();
19  _pt_col.clear();
20  _box_col.clear();
21  _seg_col.clear();
22  _trj_col.clear();
23  _lin_col.clear();
24  _cone_col.clear();
25  _sphere_col.clear();
26  _labels.clear();
27  }
28 
29  void GeoObjCollection::_AddLabel_(const Point_t& pt, std::string label)
30  {
31  auto const iter = _labels.find(pt);
32  if(iter==_labels.end())
33 
34  _labels.insert(std::make_pair(pt,Form("%s\n",label.c_str())));
35 
36  else {
37 
38  label = Form("%s%s\n",(*iter).second.c_str(),label.c_str());
39 
40  _labels[pt] = label;
41  }
42  }
43 
44  void GeoObjCollection::Add(const Point_t& pt, std::string name, std::string c)
45  {
46  if(name.empty()) name = Form("Pt (%zu)",_pt_v.size());
47  _AddLabel_(pt,name);
48  _pt_v.push_back(pt);
49  _pt_col.push_back(c);
50  }
51 
52  void GeoObjCollection::Add(const AABox_t& box, std::string name, std::string c)
53  {
54  if(name.empty()) name = Form("AABox (%zu)",_box_v.size());
55  _AddLabel_(box.Min() + (box.Max() - box.Min())/2.,name);
56  _box_v.push_back(box);
57  _box_col.push_back(c);
58  }
59 
60  void GeoObjCollection::Add(const LineSegment_t& seg, std::string name, std::string c)
61  {
62  if(name.empty()) name = Form("LSeg (%zu)",_seg_v.size());
63  _AddLabel_(seg.End(),name);
64  _seg_v.push_back(seg);
65  _seg_col.push_back(c);
66  }
67 
68 
69  void GeoObjCollection::Add(const HalfLine_t& lin, std::string name, std::string c)
70  {
71  if(name.empty()) name = Form("Line (%zu)",_lin_v.size());
72  _AddLabel_(lin.Start()+lin.Start()*10,name);
73  _lin_v.push_back(lin);
74  _lin_col.push_back(c);
75  }
76 
77  void GeoObjCollection::Add(const Trajectory_t& trj, std::string name, std::string c)
78  {
79  if(trj.size()<2)
80  throw GeoAlgoException("Trajectory size cannot be smaller than 2!");
81  if(name.empty()) name = Form("Trj (%zu)",_trj_v.size());
82  _AddLabel_(trj.back(),name);
83  _trj_v.push_back(trj);
84  _trj_col.push_back(c);
85 
86  return;
87  }
88 
89  void GeoObjCollection::Add(const Cone_t& cone, std::string name, std::string c)
90  {
91  if(name.empty()) name = Form("Cone (%zu)",_cone_v.size());
92  _AddLabel_(cone.Start()+cone.Dir()*cone.Length(),name);
93  _cone_v.push_back(cone);
94  _cone_col.push_back(c);
95  }
96 
97 
98  void GeoObjCollection::Add(const Sphere_t& sphere, std::string name, std::string c)
99  {
100  if(name.empty()) name = Form("Sphere (%zu)",_sphere_v.size());
101  _AddLabel_(sphere.Center(),name);
102  _sphere_v.push_back(sphere);
103  _sphere_col.push_back(c);
104  }
105 
106 }
void _AddLabel_(const Point_t &pt, std::string label)
const Point_t & Start() const
Start getter.
Representation of a simple 3D line segment Defines a finite 3D straight line by having the start and ...
Representation of a 3D rectangular box which sides are aligned w/ coordinate axis. A representation of an Axis-Aligned-Boundary-Box, a simple &amp; popular representation of 3D boundary box for collision detection. The concept was taken from the reference, Real-Time-Collision-Detection (RTCD), and in particular Ch. 4.2 (page 77): .
void Add(const Point_t &pt, std::string label="", std::string c="")
double Length() const
Length getter.
const Point_t & Min() const
Minimum point getter.
std::map< geoalgo::Point_t, std::string > _labels
Representation of a 3D semi-infinite line. Defines a 3D cone with the following properties: Start po...
const Point_t & End() const
End getter.
const Vector_t & Dir() const
Direction getter.
const Point_t & Center() const
Center getter.
Representation of a 3D semi-infinite line. Defines a semi-infinite 3D line by having a start point (P...
const Point_t & Max() const
Maximum point getter.
then echo fcl name