00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "TPointSet3D.h"
00014 #include "TClass.h"
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 ClassImp(TPointSet3D);
00038
00039
00040 TPointSet3D::TPointSet3D(const TPointSet3D &t) :
00041 TPolyMarker3D(t), TAttBBox(t), fOwnIds(kFALSE), fIds()
00042 {
00043
00044
00045 CopyIds(t);
00046 }
00047
00048
00049 TPointSet3D::~TPointSet3D()
00050 {
00051
00052
00053 ClearIds();
00054 }
00055
00056
00057 void TPointSet3D::CopyIds(const TPointSet3D& t)
00058 {
00059
00060
00061 fOwnIds = t.fOwnIds;
00062 fIds.Expand(t.fIds.GetSize());
00063 if (fOwnIds) {
00064 for (Int_t i=0; i<t.fIds.GetSize(); ++i)
00065 fIds.AddAt(t.fIds.At(i)->Clone(), i);
00066 } else {
00067 for (Int_t i=0; i<t.fIds.GetSize(); ++i)
00068 fIds.AddAt(t.fIds.At(i), i);
00069 }
00070 }
00071
00072
00073 TPointSet3D& TPointSet3D::operator=(const TPointSet3D& t)
00074 {
00075
00076
00077 if (this != &t) {
00078 ClearIds();
00079 TPolyMarker3D::operator=(t);
00080 CopyIds(t);
00081 }
00082 return *this;
00083 }
00084
00085
00086 void TPointSet3D::ComputeBBox()
00087 {
00088
00089
00090 if (Size() > 0) {
00091 BBoxInit();
00092 Int_t n = Size();
00093 Float_t* p = fP;
00094 for (Int_t i = 0; i < n; ++i, p += 3) {
00095 BBoxCheckPoint(p);
00096 }
00097 } else {
00098 BBoxZero();
00099 }
00100 }
00101
00102 void TPointSet3D::SetPointId(TObject* id)
00103 {
00104
00105
00106
00107 SetPointId(fLastPoint, id);
00108 }
00109
00110
00111 void TPointSet3D::SetPointId(Int_t n, TObject* id)
00112 {
00113
00114
00115 if (n >= fN) return;
00116 if (fN > fIds.GetSize())
00117 fIds.Expand(fN);
00118 fIds.AddAt(id, n);
00119 }
00120
00121
00122 void TPointSet3D::ClearIds()
00123 {
00124
00125
00126 if (fOwnIds) {
00127 for (Int_t i=0; i<fIds.GetSize(); ++i)
00128 delete GetPointId(i);
00129 }
00130 fIds.Expand(0);
00131 }
00132
00133
00134 void TPointSet3D::PointSelected(Int_t n)
00135 {
00136
00137
00138
00139
00140
00141
00142
00143 TObject* id = GetPointId(n);
00144 printf("TPointSet3D::PointSelected n=%d, id=(%s*)0x%lx\n",
00145 n, id ? id->IsA()->GetName() : "void", (ULong_t)id);
00146 if (id)
00147 id->Print();
00148 }
00149
00150
00151 void TPointSet3D::Streamer(TBuffer &R__b)
00152 {
00153
00154
00155 if (R__b.IsReading()) {
00156 R__b.ReadClassBuffer(TPointSet3D::Class(), this);
00157 if (fOwnIds) {
00158 Int_t n;
00159 R__b >> n;
00160 for (Int_t i=0; i<n; ++i) {
00161 TObject* o = (TObject*) R__b.ReadObjectAny(TObject::Class());
00162 if (gDebug > 0) printf("Read[%2d]: ", i); o->Print();
00163 }
00164 }
00165 } else {
00166 R__b.WriteClassBuffer(TPointSet3D::Class(), this);
00167 if (fOwnIds) {
00168 R__b << fIds.GetEntries();
00169 TObject* o;
00170 TIter next(&fIds);
00171 while ((o = next())) {
00172 if (gDebug > 0) printf("Writing: "); o->Print();
00173 R__b.WriteObjectAny(o, TObject::Class());
00174 }
00175 }
00176 }
00177 }