LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
GeoObjCollection.cxx
Go to the documentation of this file.
1 #ifndef BASICTOOL_GEOOBJCOLLECTION_CXX
2 #define BASICTOOL_GEOOBJCOLLECTION_CXX
3 
4 #include "GeoObjCollection.h"
5 
6 namespace geoalgo {
7 
9  {}
10 
12  {
13  _pt_v.clear();
14  _box_v.clear();
15  _seg_v.clear();
16  _trj_v.clear();
17  _lin_v.clear();
18  _cone_v.clear();
19  //_sphere_v.clear();
20  _pt_col.clear();
21  _box_col.clear();
22  _seg_col.clear();
23  _trj_col.clear();
24  _lin_col.clear();
25  _cone_col.clear();
26  _sphere_col.clear();
27  _labels.clear();
28  }
29 
30  void GeoObjCollection::_AddLabel_(const Point_t& pt, std::string label)
31  {
32  auto const iter = _labels.find(pt);
33  if(iter==_labels.end())
34 
35  _labels.insert(std::make_pair(pt,Form("%s\n",label.c_str())));
36 
37  else {
38 
39  label = Form("%s%s\n",(*iter).second.c_str(),label.c_str());
40 
41  _labels[pt] = label;
42  }
43  }
44 
45  void GeoObjCollection::Add(const Point_t& pt, std::string name, std::string c)
46  {
47  if(name.empty()) name = Form("Pt (%zu)",_pt_v.size());
48  _AddLabel_(pt,name);
49  _pt_v.push_back(pt);
50  _pt_col.push_back(c);
51  }
52 
53  void GeoObjCollection::Add(const AABox_t& box, std::string name, std::string c)
54  {
55  if(name.empty()) name = Form("AABox (%zu)",_box_v.size());
56  _AddLabel_(box.Min() + (box.Max() - box.Min())/2.,name);
57  _box_v.push_back(box);
58  _box_col.push_back(c);
59  }
60 
61  void GeoObjCollection::Add(const LineSegment_t& seg, std::string name, std::string c)
62  {
63  if(name.empty()) name = Form("LSeg (%zu)",_seg_v.size());
64  _AddLabel_(seg.End(),name);
65  _seg_v.push_back(seg);
66  _seg_col.push_back(c);
67  }
68 
69 
70  void GeoObjCollection::Add(const HalfLine_t& lin, std::string name, std::string c)
71  {
72  if(name.empty()) name = Form("Line (%zu)",_lin_v.size());
73  _AddLabel_(lin.Start()+lin.Start()*10,name);
74  _lin_v.push_back(lin);
75  _lin_col.push_back(c);
76  }
77 
78  void GeoObjCollection::Add(const Trajectory_t& trj, std::string name, std::string c)
79  {
80  if(trj.size()<2)
81  throw GeoAlgoException("Trajectory size cannot be smaller than 2!");
82  if(name.empty()) name = Form("Trj (%zu)",_trj_v.size());
83  _AddLabel_(trj.back(),name);
84  _trj_v.push_back(trj);
85  _trj_col.push_back(c);
86 
87  return;
88  }
89 
90  void GeoObjCollection::Add(const Cone_t& cone, std::string name, std::string c)
91  {
92  if(name.empty()) name = Form("Cone (%zu)",_cone_v.size());
93  _AddLabel_(cone.Start()+cone.Dir()*cone.Length(),name);
94  _cone_v.push_back(cone);
95  _cone_col.push_back(c);
96  }
97 
98 
99  void GeoObjCollection::Add(const Sphere_t& sphere, std::string name, std::string c)
100  {
101  if(name.empty()) name = Form("Sphere (%zu)",_sphere_v.size());
102  _AddLabel_(sphere.Center(),name);
103  _sphere_v.push_back(sphere);
104  _sphere_col.push_back(c);
105  }
106 
107 }
108 
109 #endif
void _AddLabel_(const Point_t &pt, std::string label)
const Point_t & Start() const
Start getter.
Definition: GeoHalfLine.cxx:27
const std::string label
std::vector< std::string > _cone_col
Representation of a simple 3D line segment Defines a finite 3D straight line by having the start and ...
GeoObjCollection()
Default constructor.
Representation of a 3D rectangular box which sides are aligned w/ coordinate axis. A representation of an Axis-Aligned-Boundary-Box, a simple & 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): .
Definition: GeoAABox.h:34
void Add(const Point_t &pt, std::string label="", std::string c="")
double Length() const
Length getter.
Definition: GeoCone.cxx:46
const Point_t & Min() const
Minimum point getter.
Definition: GeoAABox.cxx:27
std::vector< geoalgo::LineSegment_t > _seg_v
std::vector< geoalgo::HalfLine_t > _lin_v
Representation of a 3D semi-infinite line. Defines a 3D cone with the following properties: Start po...
Definition: GeoCone.h:27
std::vector< std::string > _box_col
std::vector< geoalgo::Trajectory_t > _trj_v
const Point_t & End() const
End getter.
TMarker * pt
Definition: egs.C:25
std::vector< geoalgo::Sphere > _sphere_v
const Vector_t & Dir() const
Direction getter.
Definition: GeoHalfLine.cxx:29
const Point_t & Center() const
Center getter.
Definition: GeoSphere.cxx:344
std::vector< geoalgo::Cone_t > _cone_v
std::vector< geoalgo::Point_t > _pt_v
Representation of a 3D semi-infinite line. Defines a semi-infinite 3D line by having a start point (P...
Definition: GeoHalfLine.h:26
std::vector< std::string > _trj_col
const Point_t & Max() const
Maximum point getter.
Definition: GeoAABox.cxx:28
std::vector< std::string > _lin_col
std::vector< geoalgo::AABox_t > _box_v
std::vector< std::string > _pt_col
std::vector< std::string > _sphere_col
std::vector< std::string > _seg_col
std::map< geoalgo::Point_t, std::string > _labels
Class def header for a class GeoObjCollection.