Skip to content
Snippets Groups Projects
Commit 4aa55443 authored by Andrea Dell'Acqua's avatar Andrea Dell'Acqua
Browse files

temporary commit to save changes

parent 988f7546
Branches
Tags
No related merge requests found
Showing
with 391 additions and 153 deletions
#ifndef Axis_H
#define Axis_H
enum Axis {PHI_axis,X_axis,Y_axis,Z_axis};
#endif
......@@ -16,7 +16,7 @@ class GeoMaterial;
class GeoLogVol;
class GeoPhysVol;
typedef std::pair<GeoLogVol*,GeoPhysVol*> GeoVolume;
typedef std::pair<GeoLogVol*,GeoPhysVol* > GeoVolume;
typedef std::map<std::string, GeoShape*, std::less<std::string> > solidStore;
......
#ifndef directionHandler_H
#define directionHandler_H
//
#include "GDMLInterface/GDMLHandler.h"
#include "GDMLInterface/GDMLController.h"
#include "GDMLInterface/Axis.h"
#include <string>
#include <iostream>
class directionHandler:public GDMLHandler {
public:
directionHandler(std::string n, GDMLController* c);
void ElementHandle();
Axis getAxis();
private:
Axis axis;
};
#endif /* end of include guard: */
#ifndef offsetHandler_H
#define offsetHandler_H
//
#include "GDMLInterface/GDMLHandler.h"
#include "GDMLInterface/GDMLController.h"
#include <string>
#include <iostream>
class offsetHandler:public GDMLHandler {
public:
offsetHandler(std::string n, GDMLController* c);
void ElementHandle();
double getOffset();
private:
double unit;
double value;
double offset;
};
#endif /* end of include guard: */
......@@ -6,7 +6,6 @@
#include <string>
class GDMLHandler;
class GeoPhysVol;
class GeoTransform;
......
#ifndef physvolHandler_H
#define physvolHandler_H
#include "GeoModelXMLParser/XercesParser.h"
#pragma once
#include "GDMLInterface/GDMLHandler.h"
#include "GDMLInterface/GDMLController.h"
#include "GDMLInterface/volumerefHandler.h"
#include "GDMLInterface/positionHandler.h"
#include "GDMLInterface/rotationHandler.h"
#include "GeoModelKernel/GeoPhysVol.h"
#include "GeoModelKernel/GeoDefinitions.h"
#include "GeoModelKernel/GeoTransform.h"
class physvolHandler:public GDMLHandler {
public:
class GDMLController;
physvolHandler(std::string n, GDMLController* c): GDMLHandler(n,c) {}
void ElementHandle() {
thePhysicalVolume=0;
name=getAttributeAsString("name");
//std::cout<<" this is physvolHandler: name "<<name<<std::endl;
#include <string>
#include <vector>
StopLoop(true);
xercesc::DOMNode *child;
//GeoTrf::TransformRT pVTransform=GeoTrf::Transform3D::Identity();
GeoTrf::Transform3D pVRotation=GeoTrf::Transform3D::Identity();
GeoTrf::Vector3D pVTranslation=GeoTrf::Vector3D(0,0,0);
class GeoPhysVol;
class GeoTransform;
for (child=XercesParser::GetCurrentElement()->getFirstChild();child!=0;child=child->getNextSibling())
{
if (child->getNodeType()==xercesc::DOMNode::ELEMENT_NODE) {
XercesParser::elementLoop(child);
XMLHandler *h=theController->XMLStore()->GetHandler(child);
if(h){
std::string nH=h->GetName();
//std::cout<<" handler name "<<nH<<std::endl;
if (nH=="volumeref") {
volumerefHandler* vH=dynamic_cast<volumerefHandler*>(h);
if (!vH) std::cout<<" something is wrong! can not retrieve volumerefHandler!!!"<<std::endl;
else thePhysicalVolume=(vH->getVolume()).second;
}
else if (nH=="positionref" || nH=="position") {
positionHandler* pH=dynamic_cast<positionHandler*>(h);
if (!pH) std::cout<<" something is wrong! can not retrieve positionHandler!!!"<<std::endl;
else {
pVTranslation=pH->getPosition().v3d;
}
}
else if (nH=="rotationref" || nH=="rotation" ) {
rotationHandler* rH=dynamic_cast<rotationHandler*>(h);
if (!rH) std::cout<<" something is wrong! can not retrieve rotationHandler!!!"<<std::endl;
else {
rotation r=rH->getRotation();
pVRotation=GeoTrf::RotateX3D(-r.rotx)*GeoTrf::RotateY3D(-r.roty)*GeoTrf::RotateZ3D(-r.rotz);
}
}
else std::cout<<" Name of the handler not defined "<<nH<<std::endl;
}
else std::cout<<"WARNING: handler not defined.. continuing"<<std::endl;
}
}
trf=new GeoTransform(GeoTrf::Translate3D(pVTranslation.x(),pVTranslation.y(),pVTranslation.z())*pVRotation);
class replicaHandler:public GDMLHandler {
public:
}
GeoPhysVol* getPhysicalVolume() {return thePhysicalVolume;}
GeoTransform* getTransform() {return trf;}
void postLoopHandling()
{
}
replicaHandler(std::string n, GDMLController* c);
void ElementHandle();
GeoPhysVol* getPhysicalVolume(int);
GeoTransform* getTransform(int);
int getNCopies();
void postLoopHandling();
private:
std::string name;
GeoPhysVol* thePhysicalVolume=0;
GeoTransform* trf=0;
int nCopies=0;
std::vector<GeoPhysVol*> thePhysicalVolumes;
std::vector<GeoTransform*> transforms;
};
#endif /* end of include guard: */
/* end of include guard: */
#ifndef replicate_axisHandler_H
#define replicate_axisHandler_H
#include "GDMLInterface/GDMLHandler.h"
#include <string>
class GDMLHandler;
class GeoPhysVol;
class GeoTransform;
class replicate_axisHandler:public GDMLHandler {
public:
replicate_axisHandler(std::string n, GDMLController* c);
void ElementHandle();
private:
};
#endif /* end of include guard: */
......@@ -3,15 +3,17 @@
#define solidsHandler_H
#include "GDMLInterface/GDMLHandler.h"
#include "GDMLInterface/GDMLController.h"
#include <string>
#include <iostream>
class GDMLController;
class solidsHandler:public GDMLHandler {
public:
solidsHandler(std::string n, GDMLController* c):GDMLHandler(n,c) {}
void ElementHandle() {;}
void postLoopHandling() {;}
solidsHandler(std::string n, GDMLController* c);
void ElementHandle();
void postLoopHandling();
};
......
#ifndef widthHandler_H
#define widthHandler_H
//
#include "GDMLInterface/GDMLHandler.h"
#include "GDMLInterface/GDMLController.h"
#include <string>
#include <iostream>
class widthHandler:public GDMLHandler {
public:
widthHandler(std::string n, GDMLController* c);
void ElementHandle();
double getWidth();
private:
double unit;
double value;
double width;
};
#endif /* end of include guard: */
......@@ -200,8 +200,6 @@ GeoVolume GDMLController::retrieveLogicalVolume(std::string name)
}
#include "GDMLInterface/defineHandler.h"
#include "GDMLInterface/boxHandler.h"
#include "GDMLInterface/tubeHandler.h"
#include "GDMLInterface/topTreeHandler.h"
#include "GDMLInterface/materialsHandler.h"
#include "GDMLInterface/solidsHandler.h"
......@@ -224,35 +222,13 @@ GeoVolume GDMLController::retrieveLogicalVolume(std::string name)
#include "GDMLInterface/setupHandler.h"
#include "GDMLInterface/worldHandler.h"
#include "GDMLInterface/physvolHandler.h"
#include "GDMLInterface/coneHandler.h"
#include "GDMLInterface/eltubeHandler.h"
#include "GDMLInterface/paraHandler.h"
#include "GDMLInterface/torusHandler.h"
#include "GDMLInterface/trdHandler.h"
#include "GDMLInterface/polyconeHandler.h"
#include "GDMLInterface/polyhedraHandler.h"
#include "GDMLInterface/zplaneHandler.h"
#include "GDMLInterface/unionHandler.h"
#include "GDMLInterface/subtractionHandler.h"
#include "GDMLInterface/intersectionHandler.h"
#include "GDMLInterface/booleanHandler.h"
#include "GDMLInterface/trapHandler.h"
#include "GDMLInterface/twistedTrapHandler.h"
#include "GDMLInterface/tessellatedHandler.h"
#include "GDMLInterface/triangularHandler.h"
#include "GDMLInterface/quadrangularHandler.h"
#include "GDMLInterface/xtruHandler.h"
#include "GDMLInterface/arb8Handler.h"
#include "GDMLInterface/sectionHandler.h"
#include "GDMLInterface/twoDimVertexHandler.h"
#include "GDMLInterface/unidentifiedShapeHandler.h"
void GDMLController::registerHandlers()
{
//std::cout << "This is GDMLController::registerHandlers()" << std::endl;
new defineHandler("define",this);
new boxHandler("box",this);
new tubeHandler("tube",this);
new topTreeHandler("gdml",this);
new materialsHandler("materials",this);
new solidsHandler("solids",this);
......@@ -280,27 +256,5 @@ void GDMLController::registerHandlers()
new physvolHandler("physvol",this);
new setupHandler("setup",this);
new worldHandler("world",this);
new coneHandler("cone",this);
new eltubeHandler("eltube",this);
new paraHandler("para",this);
new torusHandler("torus",this);
new trdHandler("trd",this);
new polyconeHandler("polycone",this);
new polyhedraHandler("polyhedra",this);
new zplaneHandler("zplane",this);
new booleanHandler("first",this);
new booleanHandler("second",this);
new unionHandler("union",this);
new subtractionHandler("subtraction",this);
new intersectionHandler("intersection",this);
new trapHandler("trap",this);
new twistedTrapHandler("twistedtrap",this);
new tessellatedHandler("tessellated",this);
new triangularHandler("triangular",this);
new quadrangularHandler("quadrangular",this);
new xtruHandler("xtru",this);
new arb8Handler("arb8",this);
new twoDimVertexHandler("twoDimVertex",this);
new sectionHandler("section",this);
new unidentifiedShapeHandler("cutTube",this);
}
#include "GDMLInterface/directionHandler.h"
#include "GDMLInterface/Axis.h"
directionHandler::directionHandler(std::string n, GDMLController* c): GDMLHandler(n,c)
{
}
void directionHandler::ElementHandle()
{
int value=0;
if ((value=getAttributeAsDouble("phi",0))) axis=PHI_axis;
else if ((value=getAttributeAsDouble("x",0))) axis=X_axis;
else if ((value=getAttributeAsDouble("y",0))) axis=Y_axis;
else if ((value=getAttributeAsDouble("z",0))) axis=Z_axis;
}
Axis directionHandler::getAxis()
{
return axis;
}
#include "GDMLInterface/offsetHandler.h"
#include "GeoModelKernel/Units.h"
offsetHandler::offsetHandler(std::string n, GDMLController* c): GDMLHandler(n,c)
{
}
void offsetHandler::ElementHandle()
{
unit=value=offset=0;
unit=getAttributeAsDouble("unit",GeoModelKernelUnits::g/GeoModelKernelUnits::mole);
value=getAttributeAsDouble("value");
offset=unit*value;
// std::cout<<" this is offsetHandler: offset= "<<offset<<std::endl;
}
double offsetHandler::getOffset()
{
return offset;
}
#include "GDMLInterface/replicaHandler.h"
#include "GDMLInterface/GDMLController.h"
#include "GDMLInterface/volumerefHandler.h"
#include "GDMLInterface/positionHandler.h"
#include "GDMLInterface/rotationHandler.h"
#include "GeoModelKernel/GeoPhysVol.h"
#include "GeoModelKernel/GeoDefinitions.h"
#include "GeoModelKernel/GeoTransform.h"
#include "GDMLInterface/replicate_axisHandler.h"
replicaHandler::replicaHandler(std::string n, GDMLController* c): GDMLHandler(n,c)
{
new replicate_axisHandler("replicate_along_axis",c);
}
void replicaHandler::ElementHandle()
{
std::cout<<"this is replicaHandler::ElementHandle() "<<std::endl;
nCopies=getAttributeAsInt("number");
}
GeoPhysVol* replicaHandler::getPhysicalVolume(int i)
{
return thePhysicalVolumes[i];
}
GeoTransform* replicaHandler::getTransform(int i)
{
return transforms[i];
}
void replicaHandler::postLoopHandling()
{
}
int replicaHandler::getNCopies()
{
return nCopies;
}
#include "GDMLInterface/replicate_axisHandler.h"
#include "GeoModelXMLParser/XercesParser.h"
#include "GDMLInterface/GDMLHandler.h"
#include "GDMLInterface/GDMLController.h"
#include "GDMLInterface/directionHandler.h"
#include "GDMLInterface/widthHandler.h"
#include "GDMLInterface/offsetHandler.h"
replicate_axisHandler::replicate_axisHandler(std::string n, GDMLController* c): GDMLHandler(n,c)
{
new widthHandler("width",c);
new offsetHandler("offset",c);
new directionHandler("direction",c);
}
void replicate_axisHandler::ElementHandle() {
//std::cout<<" this is replicate_axisHandler"<<std::endl;
StopLoop(true);
xercesc::DOMNode *child;
for (child=XercesParser::GetCurrentElement()->getFirstChild();child!=0;child=child->getNextSibling())
{
if (child->getNodeType()==xercesc::DOMNode::ELEMENT_NODE)
{
XercesParser::elementLoop(child);
XMLHandler *h=theController->XMLStore()->GetHandler(child);
if(h){
std::string nH=h->GetName();
//std::cout<<" handler name "<<nH<<std::endl;
if (nH=="direction") {
directionHandler* dH=dynamic_cast<directionHandler*>(h);
if (!dH) std::cout<<" something is wrong! can not retrieve directionHandler!!!"<<std::endl;
else ;
}
else if (nH=="width")
{
widthHandler* wH=dynamic_cast<widthHandler*>(h);
if (!wH) std::cout<<" something is wrong! can not retrieve widthHandler!!!"<<std::endl;
else
{
;
}
}
else if (nH=="offset")
{
offsetHandler* oH=dynamic_cast<offsetHandler*>(h);
if (!oH) std::cout<<" something is wrong! can not retrieve offsetHandler!!!"<<std::endl;
else
{
;
}
}
else std::cout<<" Name of the handler not defined "<<nH<<std::endl;
}
else std::cout<<"WARNING: handler not defined.. continuing"<<std::endl;
}
}
}
#include "GDMLInterface/solidsHandler.h"
#include "GDMLInterface/GDMLController.h"
// handlers being created here
#include "GDMLInterface/boxHandler.h"
#include "GDMLInterface/tubeHandler.h"
#include "GDMLInterface/coneHandler.h"
#include "GDMLInterface/eltubeHandler.h"
#include "GDMLInterface/paraHandler.h"
#include "GDMLInterface/torusHandler.h"
#include "GDMLInterface/trdHandler.h"
#include "GDMLInterface/polyconeHandler.h"
#include "GDMLInterface/polyhedraHandler.h"
#include "GDMLInterface/zplaneHandler.h"
#include "GDMLInterface/unionHandler.h"
#include "GDMLInterface/subtractionHandler.h"
#include "GDMLInterface/intersectionHandler.h"
#include "GDMLInterface/booleanHandler.h"
#include "GDMLInterface/trapHandler.h"
#include "GDMLInterface/twistedTrapHandler.h"
#include "GDMLInterface/tessellatedHandler.h"
#include "GDMLInterface/triangularHandler.h"
#include "GDMLInterface/quadrangularHandler.h"
#include "GDMLInterface/xtruHandler.h"
#include "GDMLInterface/arb8Handler.h"
#include "GDMLInterface/sectionHandler.h"
#include "GDMLInterface/twoDimVertexHandler.h"
#include "GDMLInterface/unidentifiedShapeHandler.h"
solidsHandler::solidsHandler(std::string n, GDMLController* c):GDMLHandler(n,c)
{
new boxHandler("box",c);
new tubeHandler("tube",c);
new coneHandler("cone",c);
new eltubeHandler("eltube",c);
new paraHandler("para",c);
new torusHandler("torus",c);
new trdHandler("trd",c);
new polyconeHandler("polycone",c);
new polyhedraHandler("polyhedra",c);
new zplaneHandler("zplane",c);
new booleanHandler("first",c);
new booleanHandler("second",c);
new unionHandler("union",c);
new subtractionHandler("subtraction",c);
new intersectionHandler("intersection",c);
new trapHandler("trap",c);
new twistedTrapHandler("twistedtrap",c);
new tessellatedHandler("tessellated",c);
new triangularHandler("triangular",c);
new quadrangularHandler("quadrangular",c);
new xtruHandler("xtru",c);
new arb8Handler("arb8",c);
new twoDimVertexHandler("twoDimVertex",c);
new sectionHandler("section",c);
new unidentifiedShapeHandler("cutTube",c);
}
void solidsHandler::ElementHandle()
{
}
void solidsHandler::postLoopHandling()
{
}
......@@ -2,10 +2,14 @@
#include "GeoModelXMLParser/XercesParser.h"
#include "GDMLInterface/replicaHandler.h"
#include "GeoModelKernel/GeoTransform.h"
volumeHandler::volumeHandler(std::string n, GDMLController* c): GDMLHandler(n,c)
{
new replicaHandler("replicavol",c);
}
void volumeHandler::ElementHandle()
......@@ -27,32 +31,40 @@ void volumeHandler::ElementHandle()
if (child->getNodeType()==xercesc::DOMNode::ELEMENT_NODE) {
XercesParser::elementLoop(child);
XMLHandler *h=theController->XMLStore()->GetHandler(child);
if (h){
std::string nH=h->GetName();
//std::cout<<" handler name "<<nH<<std::endl;
if (nH=="materialref") {
materialrefHandler* mH=dynamic_cast<materialrefHandler*>(h);
if (!mH) std::cout<<" something is wrong! can not retrieve materialrefHandler!!!"<<std::endl;
else material=mH->getMaterial();
}
else if (nH=="solidref") {
solidrefHandler* sH=dynamic_cast<solidrefHandler*>(h);
if (!sH) std::cout<<" something is wrong! can not retrieve solidrefHandler!!!"<<std::endl;
else shape=sH->getSolid();
}
else if (nH=="physvol") {
physvolHandler* pH=dynamic_cast<physvolHandler*>(h);
if (!pH) std::cout<<" something is wrong! can not retrieve solidrefHandler!!!"<<std::endl;
else
{
tempPhys.push_back(pH->getPhysicalVolume());
tempTransform.push_back(pH->getTransform());
}
}
else std::cout<<" handler name not defined "<<nH<<std::endl;
}
if (h){
std::string nH=h->GetName();
//std::cout<<" handler name "<<nH<<std::endl;
if (nH=="materialref") {
materialrefHandler* mH=dynamic_cast<materialrefHandler*>(h);
if (!mH) std::cout<<" something is wrong! can not retrieve materialrefHandler!!!"<<std::endl;
else material=mH->getMaterial();
}
else if (nH=="solidref") {
solidrefHandler* sH=dynamic_cast<solidrefHandler*>(h);
if (!sH) std::cout<<" something is wrong! can not retrieve solidrefHandler!!!"<<std::endl;
else shape=sH->getSolid();
}
else if (nH=="physvol") {
physvolHandler* pH=dynamic_cast<physvolHandler*>(h);
if (!pH) std::cout<<" something is wrong! can not retrieve solidrefHandler!!!"<<std::endl;
else
{
tempPhys.push_back(pH->getPhysicalVolume());
tempTransform.push_back(pH->getTransform());
}
}
else if (nH=="replicavol") {
replicaHandler* rH=dynamic_cast<replicaHandler*>(h);
if (!rH) std::cout<<" something is wrong! can not retrieve replicaHandler!!!"<<std::endl;
else
{
std::cout<<" from replicaHandler: nCopies="<<rH->getNCopies()<<std::endl;
}
}
else std::cout<<" handler name not defined "<<nH<<std::endl;
}
} //else std::cout<<"WARNING: handler not defined.. continuing"<<std::endl;
} //else std::cout<<"WARNING: handler not defined.. continuing"<<std::endl;
}
//std::cout << "Creating logical volume "<<name<<" shape "<<shape<<" mat "<<material<<std::endl;
GeoLogVol* tempLV=new GeoLogVol(name,shape,material);
......
#include "GDMLInterface/widthHandler.h"
#include "GeoModelKernel/Units.h"
widthHandler::widthHandler(std::string n, GDMLController* c): GDMLHandler(n,c)
{
}
void widthHandler::ElementHandle()
{
unit=value=width=0;
unit=getAttributeAsDouble("unit",GeoModelKernelUnits::g/GeoModelKernelUnits::mole);
value=getAttributeAsDouble("value");
width=unit*value;
// std::cout<<" this is widthHandler: width= "<<width<<std::endl;
}
double widthHandler::getWidth()
{
return width;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment