EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicCadWizardSphere.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicCadWizardSphere.cxx
1 
2 #include <gp_Sphere.hxx>
3 
4 #include <BRepPrimAPI_MakeSphere.hxx>
5 
6 #include <TGeoMatrix.h>
7 #include <TGeoSphere.h>
8 
9 #include <EicCadWizardSphere.h>
10 
11 // =======================================================================================
12 
14 {
15  // Just need exactly this sphere, please;
16  mSphere = new gp_Sphere(sphere);
17  mSolid = new TopoDS_Shape(BRepPrimAPI_MakeSphere(sphere.Location(), sphere.Radius()).Solid());
18 } // EicCadWizardSphere::EicCadWizardSphere()
19 
20 // ---------------------------------------------------------------------------------------
21 
23 {
24  // Check object type first;
25  const EicCadWizardSphere *other = dynamic_cast<const EicCadWizardSphere*>(cut);
26  if (!other) return false;
27 
28  // FIXME: llow for some tolerance later, please! (?);
29  const gp_Sphere *spl = mSphere, *spr = other->mSphere;
30 
31  if (fabs(spl->Radius() - spr->Radius()) > _SPATIAL_TOLERANCE_) return false;
32 
33  {
34  double dc = sqrt(SQR(spl->Location().X() - spr->Location().X()) +
35  SQR(spl->Location().Y() - spr->Location().Y()) +
36  SQR(spl->Location().Z() - spr->Location().Z()));
37 
38  if (dc > _SPATIAL_TOLERANCE_) return false;
39  }
40 
41  return true;
42 } // EicCadWizardSphere::IsEqual()
43 
44 // ---------------------------------------------------------------------------------------
45 
46 TGeoCombiTrans *EicCadWizardSphere::BuildRootVolume(const char *vname, const char *tname)
47 {
48  new TGeoSphere(vname, 0.0, mSphere->Radius());
49 
50  return new TGeoCombiTrans(tname, mSphere->Location().X(),
51  mSphere->Location().Y(),
52  mSphere->Location().Z(), 0);
53 
54  //printf("SP (%s) x0[]: %f %f %f, r = %f\n", facets[fc].first ? "-" : "*",
55  // sphere->Location().X(),
56  // sphere->Location().Y(), sphere->Location().Z(), sphere->Radius());
57 } // EicCadWizardSphere::BuildRootVolume()
58 
59 // =======================================================================================