13 #include "Riostream.h"
16 #include "TVolumePosition.h"
21 #include "TVirtualPad.h"
22 #include "TGeometry.h"
23 #include "TRotMatrix.h"
25 #include "X3DBuffer.h"
27 #include "TTablePadView3D.h"
62 : fMatrix(0),fNode(node),fId(0)
64 SetMatrixOwner(kFALSE);
65 fX[0] = x; fX[1] =y; fX[2] = z;
67 static Int_t counter = 0;
69 if(!(counter%1000))std::cout<<
"TVolumePosition count="<<counter<<
" name="<<node->GetName()<<std::endl;
71 if (!gGeometry)
new TGeometry;
72 if (matrixname && strlen(matrixname)) fMatrix = gGeometry->GetRotMatrix(matrixname);
88 : fMatrix(matrix),fNode(node),fId(0)
90 SetMatrixOwner(kFALSE);
91 if (!gGeometry)
new TGeometry;
92 fX[0] = x; fX[1] = y; fX[2] = z;
100 SetMatrixOwner(kFALSE);
102 UInt_t curPositionId = 0;
103 TRotMatrix *curMatrix = 0;
105 curNode = curPosition->GetNode();
106 curPositionId = curPosition->GetId();
107 curMatrix = (TRotMatrix *) curPosition->GetMatrix();
109 TRotMatrix *oldMatrix = 0;
110 fX[0] = 0; fX[1] = 0; fX[2] = 0;
111 Double_t oldTranslation[] = { 0, 0, 0 };
113 oldMatrix = (TRotMatrix *) oldPosition->GetMatrix();
114 oldTranslation[0] = oldPosition->GetX();
115 oldTranslation[1] = oldPosition->GetY();
116 oldTranslation[2] = oldPosition->GetZ();
122 Double_t newMatrix[9];
124 if(oldMatrix && curMatrix && curPosition) {
125 TGeometry::UpdateTempMatrix(oldTranslation,oldMatrix->GetMatrix(),
126 curPosition->GetX(),curPosition->GetY(),curPosition->GetZ(),
127 curMatrix->GetMatrix(),
129 Int_t num = gGeometry->GetListOfMatrices()->GetSize();
131 snprintf(anum,100,
"%d",num+1);
132 fMatrix =
new TRotMatrix(anum,
"NodeView",newMatrix);
133 SetMatrixOwner(kTRUE);
136 fX[0] = oldTranslation[0] + curPosition->GetX();
137 fX[1] = oldTranslation[1] + curPosition->GetY();
138 fX[2] = oldTranslation[2] + curPosition->GetZ();
148 , fMatrix(((
TVolumePosition &)pos).GetMatrix()),fNode(pos.GetNode()),fId(pos.GetId())
151 for (
int i=0;i<3;i++) fX[i] = pos.GetX(i);
156 SetMatrixOwner(pos.IsMatrixOwner());
174 TShape *shape = GetNode()->GetShape();
175 b->Add(GetNode(),shape?shape->GetName():GetNode()->GetName());
198 if (node) node->
Draw(option);
213 gPad->SetCursor(kHand);
221 return GetNode()?GetNode()->GetName():IsA()->GetName();
230 if (!GetNode())
return 0;
231 static char info[64];
232 snprintf(info,64,
"%s/%s, shape=%s/%s",GetNode()->
GetName(),GetNode()->
GetTitle(),GetNode()->GetShape()->
GetName(),GetNode()->GetShape()->ClassName());
242 TCL::vzero(&error[1],4);
243 error[0] = localError[0]; error[2] = localError[1]; error[5] = localError[2];
253 TCL::vzero(&error[1],4);
254 error[0] = localError[0]; error[2] = localError[1]; error[5] = localError[2];
264 const TRotMatrix *rm = GetMatrix();
266 if (rm && ( m = ((TRotMatrix *)rm)->GetMatrix()) )
267 res =
TCL::trasat(m,(Double_t *)localCorr,masterCorr,3,3);
269 res = TCL::ucopy(localCorr,masterCorr,6);
279 const TRotMatrix *rm = GetMatrix();
281 if (rm && (m = ((TRotMatrix *)rm)->GetMatrix()) ) {
282 double corLocal[6], corGlobal[6];
283 TCL::ucopy(localCorr,corLocal,6);
285 res = TCL::ucopy(corGlobal,masterCorr,6);
287 res = TCL::ucopy(localCorr,masterCorr,6);
296 TCL::vzero(&error[1],4);
297 error[0] = masterError[0]; error[2] = masterError[1]; error[5] = masterError[2];
306 TCL::vzero(&error[1],4);
307 error[0] = masterError[0]; error[2] = masterError[1]; error[5] = masterError[2];
316 TRotMatrix *rm = (TRotMatrix *) GetMatrix();
318 if (rm && ( m = rm->GetMatrix()) )
319 res =
TCL::tratsa(m,(Double_t *)localCorr,masterCorr,3,3);
321 res = TCL::ucopy(localCorr,masterCorr,6);
331 TRotMatrix *rm = (TRotMatrix *) GetMatrix();
333 if (rm && (m = rm->GetMatrix()) ) {
334 double corLocal[6], corGlobal[6];
335 TCL::ucopy(localCorr,corLocal,6);
337 res = TCL::ucopy(corGlobal,masterCorr,6);
340 res = TCL::ucopy(localCorr,masterCorr,6);
354 Double_t *matrix = 0;
356 if (!fMatrix || fMatrix ==
TVolume::GetIdentity() || !(matrix = ((TRotMatrix *)fMatrix)->GetMatrix()) ) {
358 for (
int i =0; i < nPoints; i++,local += 3, master += 3) TCL::vadd(local,fX,master,3);
361 for (
int i =0; i < nPoints; i++, local += 3, master += 3) {
362 TCL::mxmpy2(matrix,local,master,3,3,1);
363 TCL::vadd(master,fX,master,3);
379 Double_t *matrix = 0;
381 if (!fMatrix || fMatrix ==
TVolume::GetIdentity() || !(matrix = ((TRotMatrix *)fMatrix)->GetMatrix()) )
384 for (
int i =0; i < nPoints; i++,local += 3, master += 3) TCL::vadd(local,fX,master,3);
387 for (
int i =0; i < nPoints; i++, local += 3, master += 3) {
388 Double_t dlocal[3]; Double_t dmaster[3];
389 TCL::ucopy(local,dlocal,3);
390 TCL::mxmpy2(matrix,dlocal,dmaster,3,3,1);
391 TCL::vadd(dmaster,fX,dmaster,3);
392 TCL::ucopy(dmaster,master,3);
407 Double_t *matrix = 0;
409 if (!fMatrix || fMatrix ==
TVolume::GetIdentity() || !(matrix = ((TRotMatrix *)fMatrix)->GetMatrix()) ){
411 for (
int i =0; i < nPoints; i++,master += 3, local += 3) TCL::vsub(master,fX,local,3);
414 for (
int i =0; i < nPoints; i++, master += 3, local += 3) {
416 TCL::vsub(master,fX,dlocal,3);
417 TCL::mxmpy(matrix,dlocal,local,3,3,1);
433 Double_t *matrix = 0;
435 if (!fMatrix || fMatrix ==
TVolume::GetIdentity() || !(matrix = ((TRotMatrix *)fMatrix)->GetMatrix()) ){
437 for (
int i =0; i < nPoints; i++,master += 3, local += 3) TCL::vsub(master,fX,local,3);
440 for (
int i =0; i < nPoints; i++, master += 3, local += 3) {
441 Double_t dmaster[3]; Double_t dlocal[3];
442 TCL::ucopy(master,dmaster,3);
443 TCL::vsub(dmaster,fX,dmaster,3);
444 TCL::mxmpy(matrix,dmaster,dlocal,3,3,1);
445 TCL::ucopy(dlocal,local,3);
455 Error(
"Paint",
"Position can not be painted");
463 std::cout << *
this << std::endl;
491 out <<
"TVolumePosition *CreatePosition() { " << std::endl;
492 out <<
" TVolumePosition *myPosition = 0; " << std::endl;
497 myPosition =
new TVolumePosition(
TVolume *node,Double_t x, Double_t y, Double_t z,
const char *matrixname)
498 : fNode(node),fX(x),fY(y),fZ(z),fMatrix(0)
501 out <<
" return myPosition; " << std::endl;
502 out <<
"} " << std::endl;
512 if (thisNode) thisNode->SetLineAttributes();
519 if (matrix != fMatrix) {
531 if (gGeometry->GeomLevel() && fMatrix) {
532 gGeometry->UpdateTempMatrix(fX[0],fX[1],fX[2]
533 ,((TRotMatrix *)fMatrix)->GetMatrix()
534 ,fMatrix->IsReflection());
536 view3D->UpdatePosition(fX[0],fX[1],fX[2],((TRotMatrix *)fMatrix));
559 curNode = curPosition.GetNode();
561 const TRotMatrix *oldMatrix = 0;
562 Double_t oldTranslation[] = { 0, 0, 0 };
563 oldMatrix = GetMatrix();
564 oldTranslation[0] = GetX();
565 oldTranslation[1] = GetY();
566 oldTranslation[2] = GetZ();
569 const TRotMatrix *curMatrix = curPosition.GetMatrix();
572 Double_t newTranslation[3];
573 Double_t newMatrix[9];
575 TGeometry::UpdateTempMatrix(oldTranslation,((TRotMatrix *)oldMatrix)->GetMatrix()
576 ,curPosition.GetX(),curPosition.GetY(),curPosition.GetZ(),
577 ((TRotMatrix *)curMatrix)->GetMatrix()
578 ,newTranslation,newMatrix);
579 Int_t num = gGeometry->GetListOfMatrices()->GetSize();
581 snprintf(anum,100,
"%d",num+1);
584 ,newTranslation[0],newTranslation[1],newTranslation[2]
585 ,
new TRotMatrix(anum,
"NodeView",newMatrix));
586 SetMatrixOwner(kTRUE);
588 newTranslation[0] = oldTranslation[0] + curPosition.GetX();
589 newTranslation[1] = oldTranslation[1] + curPosition.GetY();
590 newTranslation[2] = oldTranslation[2] + curPosition.GetZ();
591 Reset(curNode,newTranslation[0],newTranslation[1],newTranslation[2]);
602 if (xyz) memcpy(fX,xyz,
sizeof(fX));
603 else memset(fX,0,
sizeof(fX));
609 void TVolumePosition::Streamer(TBuffer &R__b)
611 TRotMatrix *save = fMatrix;
612 if (R__b.IsReading()) {
614 R__b.ReadClassBuffer(TVolumePosition::Class(),
this);
615 if (!fMatrix) fMatrix = save;
618 R__b.WriteClassBuffer(TVolumePosition::Class(),
this);
625 std::ostream& operator<<(std::ostream& s,
const TVolumePosition &target)
628 if (target.GetNode()) s << target.GetNode()->GetName() << std::endl;
629 else s <<
"NILL" << std::endl;
630 s << Form(
" Position: x=%10.5f : y=%10.5f : z=%10.5f\n", target.GetX(), target.GetY(), target.GetZ());
631 TRotMatrix *rot = (TRotMatrix *) target.GetMatrix();
633 s << rot->IsA()->GetName() <<
"\t" << rot->GetName() <<
"\t" << rot->GetTitle() << std::endl;
634 Double_t *matrix = rot->GetMatrix();
637 for (Int_t j=0;j<3;j++) s << Form(
"%10.5f:", *matrix++);
virtual void Browse(TBrowser *b)
to be documented
virtual void Draw(Option_t *depth="3")
Draw Referenced node with current parameters.
virtual Double_t * Cormx2Master(const Double_t *localCorr, Double_t *masterCorr) const
to be documented
virtual Float_t * Errmx2Master(const Float_t *localError, Float_t *masterError) const
to be documented
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual void Draw(Option_t *depth="3")
virtual const char * GetTitle() const
forward the GetObjectInfo call to the decorated object
virtual void SetVisibility(ENodeSEEN vis=TVolume::kBothVisible)
virtual void SetXYZ(Double_t *xyz=0)
to be documented
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
to be documented
virtual Double_t * Local2Master(const Double_t *local, Double_t *master, Int_t nPoints=1) const
virtual ~TVolumePosition()
to be documented
static TRotMatrix * GetIdentity()
Return a pointer the "identity" matrix.
virtual void SetVisibility(Int_t vis=1)
to be documented
virtual Double_t * Cormx2Local(const Double_t *masterCorr, Double_t *localCorr) const
to be documented
virtual char * GetObjectInfo(Int_t px, Int_t py) const
to be documented
virtual void SetLineAttributes()
to be documented
virtual void SetMatrix(TRotMatrix *matrix=0)
to be documented
TVolumePosition(TVolume *node=0, Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0)
virtual void UpdatePosition(Option_t *option="")
to be documented
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual TVolumePosition * Reset(TVolume *node=0, Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0)
virtual Double_t * Master2Local(const Double_t *master, Double_t *local, Int_t nPoints=1) const
static float * trasat(const float *a, const float *s, float *r, int m, int n)
virtual Float_t * Errmx2Local(const Float_t *masterError, Float_t *localError) const
to be documented
virtual void Print(Option_t *option="") const
to be documented
static float * tratsa(const float *a, const float *s, float *r, int m, int n)
virtual void Paint(Option_t *option="")
Paint Referenced node with current parameters.
virtual const Char_t * GetName() const
return VolumePosition name