EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicStlVertex.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicStlVertex.h
1 //
2 // AYK (ayk@bnl.gov), 2014/01/08; revamped in Oct'2017;
3 //
4 // EicRoot CAD manipulation routines; 3D vertex class;
5 //
6 
7 #include <math.h>
8 
9 #include <map>
10 #include <set>
11 #include <vector>
12 
13 #include <cstdio>
14 
15 #include <EicStlKey.h>
16 
17 class EicStlFacet;
18 
19 #ifndef _EIC_STL_VERTEX_
20 #define _EIC_STL_VERTEX_
21 
23 class EicStlVertex {
24  public:
28  EicStlVertex(const double coord[3]): mMerged(false), mMergedVertex(NULL) {
29  mKey = new EicStlKey(3, coord);
30 
31  mDistanceToOrigin = sqrt(coord[0]*coord[0]+coord[1]*coord[1]+coord[2]*coord[2]);
32  };
35  ~EicStlVertex() { if (mKey) delete mKey; };
36 
37  // Access methods;
38  const EicStlKey *key() const { return mKey;};
39  double DistanceToOrigin( void ) const { return mDistanceToOrigin; };
40  void SetMergedFlag( void ) { mMerged = true; };
41  void SetMergedVertex(EicStlVertex *vertex) { mMergedVertex = vertex; };
42  bool IsMerged( void ) const { return mMerged; };
43  EicStlVertex *GetMergedVertex( void ) const { return mMergedVertex; };
44 
45  void AddFacet(EicStlFacet *facet) { mFacets.insert(facet); };
46  std::set<EicStlFacet*> &facets( void ) { return mFacets; };
47 
48  // This is trivial indeed; prefer to avoid using 'friends' though;
50  mDegenerateNeighbors1D[vertex]++;
51  };
52  const std::map<EicStlVertex*, unsigned> &DegenerateNeighbors1D( void ) {
53  return mDegenerateNeighbors1D;
54  };
56  mDegenerateNeighbors3D.push_back(vertex);
57  };
58  const std::vector<EicStlVertex*> &DegenerateNeighbors3D( void ) {
60  };
61 
62  private:
64  EicStlKey *mKey;
65 
66  // Vertex distance to (0,0,0);
68 
69  // Facets joining in this vertex;
70  std::set<EicStlFacet*> mFacets;
71 
72  // This stuff is used to cure STL file in case few neighbor vertices are
73  // artificially displaced within tolerances from each other;
74  bool mMerged;
76  std::map<EicStlVertex*, unsigned> mDegenerateNeighbors1D;
77  std::vector<EicStlVertex*> mDegenerateNeighbors3D;
78 
81  public:
82  void Print() const {
83  printf("%16.8f %16.8f %16.8f\n",
84  mKey->GetData()[0], mKey->GetData()[1], mKey->GetData()[2]);
85  };
86 };
87 
88 typedef std::map<const EicStlKey*, EicStlVertex*, bool(*)(const EicStlKey*, const EicStlKey*)> vEntry;
89 
90 // Yes, prefer to have this call as a standalone function;
91 EicStlKey *GetVertexArrayKey(const vEntry *vertices);
92 
93 #endif