GeoModel - GeoModelCore
GeoAlignableTransform.cxx
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "GeoModelKernel/GeoAlignableTransform.h"
6 #include "GeoModelKernel/GeoClearAbsPosAction.h"
7 #include "GeoModelKernel/GeoVAlignmentStore.h"
8 #include "GeoSelClearAbsPosAction.h"
9 #include <set>
10 
11 GeoAlignableTransform::GeoAlignableTransform (const GeoTrf::Transform3D& transform)
12  : GeoTransform(transform)
13  , m_delta (nullptr)
14 {
15 }
16 
17 GeoAlignableTransform::~GeoAlignableTransform()
18 {
19  delete m_delta;
20 }
21 
22 GeoTrf::Transform3D GeoAlignableTransform::getTransform(const GeoVAlignmentStore* store) const
23 {
24  const GeoTrf::Transform3D* delta = (store==nullptr ? m_delta : store->getDelta(this));
25  return GeoTransform::getTransform(nullptr) * (delta==nullptr ? GeoTrf::Transform3D(GeoTrf::Transform3D::Identity()) : *delta);
26 }
27 
28 void GeoAlignableTransform::setDelta (const GeoTrf::Transform3D& delta, GeoVAlignmentStore* store)
29 {
30  if(store==nullptr) {
31  if(m_delta && (m_delta->isApprox(delta))) return;
32 
33  if(m_delta) {
34  (*m_delta) = delta;
35  }
36  else {
37  m_delta = new GeoTrf::Transform3D(delta);
38  }
39 
40  std::set<GeoGraphNode*> uniqueParents;
41  for(GeoGraphNode* parent : m_parentList) {
42  if(uniqueParents.find(parent)==uniqueParents.end()) {
43  GeoSelClearAbsPosAction cc(this);
44  parent->exec(&cc);
45  uniqueParents.insert(parent);
46  }
47  }
48  } // if(store==nullptr)
49  else {
50  store->setDelta(this,delta);
51  }
52 }
53 
55 {
56  // Does not make sence to clear deltas inside Alignment Store
57  if(store!=nullptr) return;
58 
59  delete m_delta;
60  m_delta = nullptr;
61 
62  std::set<GeoGraphNode*> uniqueParents;
63  for(GeoGraphNode* parent : m_parentList) {
64  if(uniqueParents.find(parent)==uniqueParents.end()) {
65  GeoSelClearAbsPosAction cc(this);
66  parent->exec (&cc);
67  uniqueParents.insert(parent);
68  }
69  }
70 }
71 
73 {
74  m_parentList.push_back (parent);
75 }
virtual GeoTrf::Transform3D getTransform(const GeoVAlignmentStore *store=nullptr) const
Gets the total transformation.
This action class has been introduced in order to speed up GeoAlignableTransform::setDelta(), which is heavily used by alignment callbacks.
Abstract base class for GeoModel alignment stores The interface allows to store/retrieve transformati...
void clearDelta(GeoVAlignmentStore *store=nullptr)
Clears the alignment delta.
virtual GeoTrf::Transform3D getTransform(const GeoVAlignmentStore *store=nullptr) const override
Gets the total transform, including the alignment correction.
virtual void dockTo(GeoVPhysVol *parent) override
Represents Nodes that can be assembled together to make a graph. Subclasses (for now): ...
Definition: GeoGraphNode.h:28
A basic geometrical (Euclidean) transform. Can return a GeoTrf::Transform3D. Reference counted...
Definition: GeoTransform.h:22
void setDelta(const GeoTrf::Transform3D &delta, GeoVAlignmentStore *store=nullptr)
Sets an alignment delta.