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
No related branches found
No related tags found
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 ...@@ -63,16 +63,16 @@ class GeoCutVolAction : public GeoVolumeAction
virtual void handleVPhysVol (const GeoVPhysVol* vPV); virtual void handleVPhysVol (const GeoVPhysVol* vPV);
// Get the cutoff result // Get the cutoff result
GeoPhysVol* getPV(); GeoIntrusivePtr<GeoPhysVol> getPV();
GeoFullPhysVol* getFPV(); GeoIntrusivePtr<GeoFullPhysVol> getFPV();
private: private:
GeoVPhysVol* m_physVol{nullptr}; PVLink m_physVol{nullptr};
const GeoShape& m_shape; const GeoShape& m_shape;
const GeoTrf::Transform3D& m_transform; const GeoTrf::Transform3D& m_transform;
std::stack<GeoVPhysVol*> m_copyStack; std::stack<PVLink> m_copyStack;
}; };
#endif #endif
...@@ -27,7 +27,7 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV) ...@@ -27,7 +27,7 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV)
unsigned int pathLen = this->getState()->getPath()->getLength(); unsigned int pathLen = this->getState()->getPath()->getLength();
// Get Logical Volume details // Get Logical Volume details
const GeoLogVol* lvOriginal = vPV->getLogVol(); GeoIntrusivePtr<const GeoLogVol> lvOriginal = vPV->getLogVol();
const std::string& lvNameOriginal = lvOriginal->getName(); const std::string& lvNameOriginal = lvOriginal->getName();
const GeoMaterial* lvMatOriginal = lvOriginal->getMaterial(); const GeoMaterial* lvMatOriginal = lvOriginal->getMaterial();
const GeoShape* lvShapeOriginal = lvOriginal->getShape(); const GeoShape* lvShapeOriginal = lvOriginal->getShape();
...@@ -35,13 +35,13 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV) ...@@ -35,13 +35,13 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV)
if(pathLen==0) { if(pathLen==0) {
// We are at the first PV. Create the resulting PV // We are at the first PV. Create the resulting PV
const GeoShape& cutShape = lvShapeOriginal->subtract(m_shape << m_transform); 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)) { if(dynamic_cast<const GeoFullPhysVol*>(vPV)) {
m_physVol = new GeoFullPhysVol(lvNew); m_physVol = make_intrusive<GeoFullPhysVol>(lvNew);
} }
else { else {
m_physVol = new GeoPhysVol(lvNew); m_physVol = make_intrusive<GeoPhysVol>(lvNew);
} }
// Save the new PV in the copy stack // Save the new PV in the copy stack
...@@ -57,17 +57,17 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV) ...@@ -57,17 +57,17 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV)
// Construct new PV // Construct new PV
const GeoShape& cutShape = lvShapeOriginal->subtract(m_shape << cutTransform); const GeoShape& cutShape = lvShapeOriginal->subtract(m_shape << cutTransform);
GeoLogVol* lvNew = new GeoLogVol(lvNameOriginal,&cutShape,lvMatOriginal); GeoIntrusivePtr<GeoLogVol> lvNew = make_intrusive<GeoLogVol>(lvNameOriginal,&cutShape,lvMatOriginal);
GeoPhysVol* pvNew = new GeoPhysVol(lvNew); PVLink pvNew = make_intrusive<GeoPhysVol>(lvNew);
// Get its characteristics (name, id, transform to parent) // Get its characteristics (name, id, transform to parent)
std::string pvName = getState()->getName(); 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(); 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); copyParent->add(pvNew);
// Save new PV in the copy stack // Save new PV in the copy stack
...@@ -75,13 +75,11 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV) ...@@ -75,13 +75,11 @@ void GeoCutVolAction::handleVPhysVol(const GeoVPhysVol *vPV)
} }
} }
GeoPhysVol* GeoCutVolAction::getPV() GeoIntrusivePtr<GeoPhysVol> GeoCutVolAction::getPV() {
{ return dynamic_pointer_cast<GeoPhysVol>(m_physVol);
return dynamic_cast<GeoPhysVol*>(m_physVol);
} }
GeoFullPhysVol* GeoCutVolAction::getFPV() GeoIntrusivePtr<GeoFullPhysVol> GeoCutVolAction::getFPV() {
{ return dynamic_pointer_cast<GeoFullPhysVol>(m_physVol);
return dynamic_cast<GeoFullPhysVol*>(m_physVol);
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment