otsdaq  v2_01_00
MonicelliGeometryConverter.cpp
1 #include "otsdaq-core/MonicelliInterface/MonicelliGeometryConverter.h"
2 #include "otsdaq-core/MonicelliInterface/MonicelliFileReader.h"
3 #include "otsdaq-core/MonicelliInterface/Visual3DGeometry.h"
4 
5 #include "otsdaq-core/MonicelliInterface/Geometry.h"
6 #include "otsdaq-core/MonicelliInterface/Detector.h"
7 
8 using namespace ots;
9 
10 
11 //========================================================================================================================
12 MonicelliGeometryConverter::MonicelliGeometryConverter(void)
13 {}
14 
15 //========================================================================================================================
16 MonicelliGeometryConverter::~MonicelliGeometryConverter(void)
17 {}
18 
19 //========================================================================================================================
20 void MonicelliGeometryConverter::loadGeometry(std::string fileName)
21 {
22  theVisual3DGeometry_.reset();
23  if(!theReader_.openGeoFile(fileName))
24  return;
25 
26  theMonicelliGeometry_ = theReader_.getGeometryPointer() ;
27 
28  convertGeometry();
29  theReader_.closeGeoFile();
30 }
31 
32 //========================================================================================================================
33 const Visual3DGeometry& MonicelliGeometryConverter::getGeometry(void) const
34 {
35  return theVisual3DGeometry_;
36 }
37 
38 //========================================================================================================================
39 void MonicelliGeometryConverter::convertGeometry(void)
40 {
41  for(monicelli::Geometry::iterator it=theMonicelliGeometry_->begin(); it!=theMonicelliGeometry_->end(); it++)
42  {
43  Visual3DShape tmpShape;
44  Point tmpPoint;
45  tmpPoint.x = 0;
46  tmpPoint.y = 0;
47  tmpPoint.z = 0;
48  it->second->fromLocalToGlobal(&tmpPoint.x,&tmpPoint.y,&tmpPoint.z);
49  tmpShape.corners.push_back(tmpPoint*10);//To become um
50  tmpPoint.x = it->second->getDetectorLengthX();
51  tmpPoint.y = 0;
52  tmpPoint.z = 0;
53  it->second->fromLocalToGlobal(&tmpPoint.x,&tmpPoint.y,&tmpPoint.z);
54  tmpShape.corners.push_back(tmpPoint*10);//To become um
55  tmpPoint.x = it->second->getDetectorLengthX();
56  tmpPoint.y = it->second->getDetectorLengthY();
57  tmpPoint.z = 0;
58  it->second->fromLocalToGlobal(&tmpPoint.x,&tmpPoint.y,&tmpPoint.z);
59  tmpShape.corners.push_back(tmpPoint*10);//To become um
60  tmpPoint.x = 0;
61  tmpPoint.y = it->second->getDetectorLengthY();
62  tmpPoint.z = 0;
63  it->second->fromLocalToGlobal(&tmpPoint.x,&tmpPoint.y,&tmpPoint.z);
64  tmpShape.corners.push_back(tmpPoint*10);//To become um
65  tmpShape.numberOfRows = it->second->getNumberOfRows();
66  tmpShape.numberOfColumns = it->second->getNumberOfCols();
67  theVisual3DGeometry_.addShape(tmpShape);
68  }
69 
70 }