00001 #include "otsdaq-core/MonicelliInterface/MonicelliGeometryConverter.h"
00002 #include "otsdaq-core/MonicelliInterface/MonicelliFileReader.h"
00003 #include "otsdaq-core/MonicelliInterface/Visual3DGeometry.h"
00004
00005 #include "otsdaq-core/MonicelliInterface/Geometry.h"
00006 #include "otsdaq-core/MonicelliInterface/Detector.h"
00007
00008 using namespace ots;
00009
00010
00011
00012 MonicelliGeometryConverter::MonicelliGeometryConverter(void)
00013 {}
00014
00015
00016 MonicelliGeometryConverter::~MonicelliGeometryConverter(void)
00017 {}
00018
00019
00020 void MonicelliGeometryConverter::loadGeometry(std::string fileName)
00021 {
00022 theVisual3DGeometry_.reset();
00023 if(!theReader_.openGeoFile(fileName))
00024 return;
00025
00026 theMonicelliGeometry_ = theReader_.getGeometryPointer() ;
00027
00028 convertGeometry();
00029 theReader_.closeGeoFile();
00030 }
00031
00032
00033 const Visual3DGeometry& MonicelliGeometryConverter::getGeometry(void) const
00034 {
00035 return theVisual3DGeometry_;
00036 }
00037
00038
00039 void MonicelliGeometryConverter::convertGeometry(void)
00040 {
00041 for(monicelli::Geometry::iterator it=theMonicelliGeometry_->begin(); it!=theMonicelliGeometry_->end(); it++)
00042 {
00043 Visual3DShape tmpShape;
00044 Point tmpPoint;
00045 tmpPoint.x = 0;
00046 tmpPoint.y = 0;
00047 tmpPoint.z = 0;
00048 it->second->fromLocalToGlobal(&tmpPoint.x,&tmpPoint.y,&tmpPoint.z);
00049 tmpShape.corners.push_back(tmpPoint*10);
00050 tmpPoint.x = it->second->getDetectorLengthX();
00051 tmpPoint.y = 0;
00052 tmpPoint.z = 0;
00053 it->second->fromLocalToGlobal(&tmpPoint.x,&tmpPoint.y,&tmpPoint.z);
00054 tmpShape.corners.push_back(tmpPoint*10);
00055 tmpPoint.x = it->second->getDetectorLengthX();
00056 tmpPoint.y = it->second->getDetectorLengthY();
00057 tmpPoint.z = 0;
00058 it->second->fromLocalToGlobal(&tmpPoint.x,&tmpPoint.y,&tmpPoint.z);
00059 tmpShape.corners.push_back(tmpPoint*10);
00060 tmpPoint.x = 0;
00061 tmpPoint.y = it->second->getDetectorLengthY();
00062 tmpPoint.z = 0;
00063 it->second->fromLocalToGlobal(&tmpPoint.x,&tmpPoint.y,&tmpPoint.z);
00064 tmpShape.corners.push_back(tmpPoint*10);
00065 tmpShape.numberOfRows = it->second->getNumberOfRows();
00066 tmpShape.numberOfColumns = it->second->getNumberOfCols();
00067 theVisual3DGeometry_.addShape(tmpShape);
00068 }
00069
00070 }