EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicStlMediaGroup.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicStlMediaGroup.h
1 //
2 // AYK (ayk@bnl.gov), 2014/01/08; revamped in Oct'2017;
3 //
4 // EicRoot CAD manipulation routines; facets/vertices/etc with a given medium type;
5 //
6 
7 #include <TGeoMedium.h>
8 
9 #include <EicStlFacetEdge.h>
10 #include <EicStlFacetAssembly.h>
11 
12 #ifndef _EIC_STL_MEDIA_GROUP_
13 #define _EIC_STL_MEDIA_GROUP_
14 
15 typedef std::map <const EicStlKey*, EicStlFacetEdge*, bool(*)(const EicStlKey*, const EicStlKey*)> eEntry;
16 typedef std::map <const EicStlKey*, EicStlFacet*, bool(*)(const EicStlKey*, const EicStlKey*)> fEntry;
17 // Edge chains are not necessarily unique -> multimap;
18 //typedef std::multimap<const EicStlKey*, EicStlFacetEdgeChain*, bool(*)(const EicStlKey*, const EicStlKey*)> cEntry;
19 
21  public:
24 
25  const vEntry *vertices( void ) const { return mVertices; };
26  const eEntry *edges( void ) const { return mEdges; };
27  const fEntry *facets( void ) const { return mFacets; };
28  const std::vector<EicStlAssembly*> &assemblies( void ) const { return mAssemblies; };
29 
30  void AddVertex(EicStlVertex *vertex) { (*mVertices)[vertex->key()] = vertex; };
31 
32  int SplitIntoAssemblies(double tolerance = 0.0, bool easy = false);
33 
34  std::multimap<double, EicStlVertex*> xCoord, yCoord, zCoord;
35  std::vector<EicStlFacet*> mFbuffer;
36 
37  private:
38 
41 
43 
45 
46  std::vector<EicStlAssembly*> mAssemblies;
47 
48  //cEntry *chains; //!
49 
51  void AddVertexToCurrentGroup(std::vector<std::vector<EicStlVertex*> > &ngroups,
52  EicStlVertex *vtx);
53  void CalculateFacets( void );
54  void AllocateEdges( void );
55 
56  // As long as every edge has even number of owner facets the model is Ok up
57  // to the facet orientation; once every edge has equal number of facets, which
58  // want to own it in direct and reversed orientation, we are all happy; if in
59  // addition to this each edge is owned by only two facets, the model does not
60  // require more sophisticated facet orientation checks;
62 
66  void CoupleFacetToAssembly(EicStlFacet *facet, bool flip);
67 };
68 
69 // The idea in having std::pair<unsigned, const TGeoMedium*> instead of just
70 // 'const TGeoMedium*' as a key is to possibly benefit from having multiple
71 // "solid - endsolid" clauses in input STL file (when user clearly knows that
72 // certain fraction of a file belong to different solid volume assemblies; this
73 // would for sure make sense if one merge several ASCII STL files into one;
74 typedef std::map<std::pair<unsigned, const TGeoMedium*>, EicStlMediaGroup> gEntry;
75 
76 #endif