EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicCadWizard.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicCadWizard.h
1 
2 #include <TObject.h>
3 #include <TString.h>
4 
5 #include <EicCadWizardPlane.h>
6 #include <EicCadWizardCylinder.h>
7 #include <EicCadWizardCone.h>
8 #include <EicCadWizardSphere.h>
9 #include <EicCadWizardTorus.h>
10 
11 #ifndef _EIC_CAD_WIZARD_
12 #define _EIC_CAD_WIZARD_
13 
14 class gp_Pnt;
15 
16 class TopoDS_Face;
17 class STEPControl_Reader;
18 class EicOpenCascadeShape;
19 
21  public:
23  mForcedStlSolidCreation(false)/*, mForcedGhostSolidCreation(false)*/ {
24  if (material) mMaterial = TString(material);
25  };
27 
28  void AllowBooleanSolidCreation(bool what = true) { mBooleanSolidCreationAllowed = what; };
29  void ForceStlSolidCreation(bool what = true) { mForcedStlSolidCreation = what; };
30  //void ForceGhostSolidCreation(bool what = true) { mForcedGhostSolidCreation = what; };
31 
32  void SetStlQualityCoefficient(double cff) { mStlQualityCoefficient = cff; };
33  double GetStlQualityCoefficient( void ) const { return mStlQualityCoefficient; };
34 
35  //void SetMaterial(const char *material) { if (material) mMaterial = TString(material); }
36  TString mMaterial;
37 
38 #if _CHECK_
39  // If unset, the default OCC value of 0.001 (see StlAPI_Writer::StlAPI_Writer()) will
40  // be used both in EicCadFile::DumpAsStlSolid() and EicCompositeShape::LocalFillBuffer3D();
41  // NB: prefer to assign this value of 0.01 right in the constructor in order not to
42  // depend on possible changes in OCC codes in future releases;
43 #endif
45 
46  bool mBooleanSolidCreationAllowed;//, mStlSolidCreationAllowed;
47  bool mForcedStlSolidCreation;//, mForcedGhostSolidCreation;
48 
49  private:
50 
52 };
53 
54 class EicCadWizardFile: public TObject {
55  public:
56  EicCadWizardFile(const char *fname = 0, const char *material = 0): mFileName(fname) {
58  };
59  ~EicCadWizardFile() { if (mConfig) delete mConfig; };
60 
61  const TString &GetFileName( void ) const { return mFileName; };
62 
63  TString mFileName;
64 
66  // Sorry, I like short C-style names too;
67  EicCadWizardFileConfig *config( void ) { return mConfig; };
68 
70 
71  private:
72 
74 };
75 
76 class EicCadWizard: public TObject {
77  public:
78  EicCadWizard(): /*: mBoundarySphereCenter(NULL), mBoundarySphereRadius(0.0)*/ mCreateEicCompositeShape(true) {};
80 
81  EicCadWizardFile *AddSourceFile(const char *fname, const char *material);
82  //void AddSourceDirectory(const char *dname);
83 
84  int ConvertSourceFilesToRoot( void );
85 
86  std::vector<EicCadWizardFile*> mSourceFiles;
87 
88  //enum FaceType {FaceTypeAny, FaceTypeFlat, FaceTypeCurved};
89 
90  //gp_Pnt *mBoundarySphereCenter; //!
91  //double mBoundarySphereRadius; //!
92 
93  int AccountRootFile(const TString &fname);
94  void AddRootDirectory(const char *dname);
95  int AssembleRootFiles(const char *dirname = 0, const char *detname = "DUMMY");
96 
97  std::vector<TString> mRootFiles;
98 
99  int SplitAndRescaleSourceFile(const TString &fname);//const char *fname);//const char *fname);
100 
102 
103  private:
105 
106  int ConvertSourceFileToRoot(const TString &fname, EicCadWizardFileConfig *config,
107  const std::vector<std::pair<EicCadWizardCut*,bool> > *tried_cuts);
109  const std::vector<std::pair<EicCadWizardCut*,bool> > *tried_cuts);
111  const std::vector<std::pair<EicCadWizardCut*,bool> > *tried_cuts);
112  int StraightforwardSplit(const STEPControl_Reader &cReader, const char *bname);
113  int FaceGuidedSplit(const STEPControl_Reader &cReader, const char *bname,
114  EicCadWizardFileConfig *config, const std::vector<std::pair<EicCadWizardCut*,bool> > *tried_cuts);
115  int FlatSurfaceSplit(const STEPControl_Reader &cReader, const char *bname,
116  EicCadWizardFileConfig *config, const std::vector<std::pair<EicCadWizardCut*,bool> > *tried_cuts);
117 
118  Bool_t IsElementaryFace(const TopoDS_Face &face) const;
119  Bool_t IsKnownFace(const TopoDS_Face &face) const;
120 
121  //Bool_t SplitSolidByInfiniteFace(const TopoDS_Shape &solid, const TopoDS_Face &face,
122  // EicOpenCascadeShape &cuttingShape,
123  // std::vector<TopoDS_Shape> &commonSolids,
124  // std::vector<TopoDS_Shape> &cutSolids);
125  EicCadWizardCut *GetCut(const TopoDS_Face &face, const gp_Pnt *bcenter, double bradius);
126  int CreateStlSolidRootFile(const TopoDS_Shape &solid, const char *bname, EicCadWizardFileConfig *config);
127  int CreateGhostSolidRootFile(const TopoDS_Shape &solid, const char *bname, EicCadWizardFileConfig *config);
128  //int CreateBooleanSolidRootFile(const TopoDS_Shape &solid,
129  // std::vector< std::pair<unsigned, EicOpenCascadeShape> > &facets,
130  // const char *bname);
131  int CreateBooleanSolidRootFile(const TopoDS_Shape &solid, const gp_Pnt *bcenter, double bradius,
132  const std::vector<std::pair<EicCadWizardCut*,bool> > *cuts,
133  const char *bname, EicCadWizardFileConfig *config);
134 
136 };
137 
138 #endif