Skip to content
Snippets Groups Projects
Commit e1400f72 authored by Johannes Junggeburth's avatar Johannes Junggeburth :dog2: Committed by Johannes Junggeburth
Browse files

Minor clean up of the cut volume action. Use PVLinks and make intrusive

parent a674bdf8
Branches
Tags
1 merge request!393Minor clean up of the cut volume action. Use PVLinks and make intrusive
Pipeline #9904853 passed
......@@ -63,16 +63,16 @@ class GeoCutVolAction : public GeoVolumeAction
virtual void handleVPhysVol (const GeoVPhysVol* vPV);
// Get the cutoff result
GeoPhysVol* getPV();
GeoFullPhysVol* getFPV();
GeoIntrusivePtr<GeoPhysVol> getPV();
GeoIntrusivePtr<GeoFullPhysVol> getFPV();
private:
GeoVPhysVol* m_physVol{nullptr};
PVLink m_physVol{nullptr};
const GeoShape& m_shape;
const GeoTrf::Transform3D& m_transform;
std::stack<GeoVPhysVol*> m_copyStack;
std::stack<PVLink> m_copyStack;
};
#endif
......@@ -27,7 +27,7 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV)
unsigned int pathLen = this->getState()->getPath()->getLength();
// Get Logical Volume details
const GeoLogVol* lvOriginal = vPV->getLogVol();
GeoIntrusivePtr<const GeoLogVol> lvOriginal = vPV->getLogVol();
const std::string& lvNameOriginal = lvOriginal->getName();
const GeoMaterial* lvMatOriginal = lvOriginal->getMaterial();
const GeoShape* lvShapeOriginal = lvOriginal->getShape();
......@@ -35,13 +35,13 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV)
if(pathLen==0) {
// We are at the first PV. Create the resulting PV
const GeoShape& cutShape = lvShapeOriginal->subtract(m_shape << m_transform);
GeoLogVol* lvNew = new GeoLogVol(lvNameOriginal,&cutShape,lvMatOriginal);
GeoIntrusivePtr<GeoLogVol> lvNew = make_intrusive<GeoLogVol>(lvNameOriginal,&cutShape,lvMatOriginal);
if(dynamic_cast<const GeoFullPhysVol*>(vPV)) {
m_physVol = new GeoFullPhysVol(lvNew);
m_physVol = make_intrusive<GeoFullPhysVol>(lvNew);
}
else {
m_physVol = new GeoPhysVol(lvNew);
m_physVol = make_intrusive<GeoPhysVol>(lvNew);
}
// Save the new PV in the copy stack
......@@ -57,17 +57,17 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV)
// Construct new PV
const GeoShape& cutShape = lvShapeOriginal->subtract(m_shape << cutTransform);
GeoLogVol* lvNew = new GeoLogVol(lvNameOriginal,&cutShape,lvMatOriginal);
GeoPhysVol* pvNew = new GeoPhysVol(lvNew);
GeoIntrusivePtr<GeoLogVol> lvNew = make_intrusive<GeoLogVol>(lvNameOriginal,&cutShape,lvMatOriginal);
PVLink pvNew = make_intrusive<GeoPhysVol>(lvNew);
// Get its characteristics (name, id, transform to parent)
std::string pvName = getState()->getName();
if(!pvName.empty()) copyParent->add(new GeoNameTag(pvName));
if(!pvName.empty()) copyParent->add(make_intrusive<GeoNameTag>(pvName));
const Query<int> pvId = getState()->getId();
if(pvId.isValid()) copyParent->add(new GeoIdentifierTag(pvId));
if(pvId.isValid()) copyParent->add(make_intrusive<GeoIdentifierTag>(pvId));
copyParent->add(new GeoTransform(getState()->getTransform()));
copyParent->add(make_intrusive<GeoTransform>(getState()->getTransform()));
copyParent->add(pvNew);
// Save new PV in the copy stack
......@@ -75,13 +75,11 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV)
}
}
GeoPhysVol* GeoCutVolAction::getPV()
{
return dynamic_cast<GeoPhysVol*>(m_physVol);
GeoIntrusivePtr<GeoPhysVol> GeoCutVolAction::getPV() {
return dynamic_pointer_cast<GeoPhysVol>(m_physVol);
}
GeoFullPhysVol* GeoCutVolAction::getFPV()
{
return dynamic_cast<GeoFullPhysVol*>(m_physVol);
GeoIntrusivePtr<GeoFullPhysVol> GeoCutVolAction::getFPV() {
return dynamic_pointer_cast<GeoFullPhysVol>(m_physVol);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment