Logo ROOT   6.14/05
Reference Guide
TPoints3D.cxx
Go to the documentation of this file.
1 // @(#)root/table:$Id$
2 // Author: Valery Fine(fine@mail.cern.ch) 24/04/99
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "Riostream.h"
13 
14 #include "TROOT.h"
15 #include "TClass.h"
16 #include "TPoints3D.h"
17 #include "TPointsArray3D.h"
18 
19 //______________________________________________________________________________
20 //
21 // TPoints3D is an abstract class of the array of 3-dimensional points.
22 // It has 4 different constructors.
23 //
24 // This class has no implemenatation for Paint, Draw, and SavePrimitive methods
25 //
26 // First one, without any parameters TPoints3D(), we call 'default
27 // constructor' and it's used in a case that just an initialisation is
28 // needed (i.e. pointer declaration).
29 //
30 // Example:
31 // TPoints3D *pl1 = new TPoints3D;
32 //
33 //
34 // Second one is 'normal constructor' with, usually, one parameter
35 // n (number of points), and it just allocates a space for the points.
36 //
37 // Example:
38 // TPoints3D pl1(150);
39 //
40 //
41 // Third one allocates a space for the points, and also makes
42 // initialisation from the given array.
43 //
44 // Example:
45 // TPoints3D pl1(150, pointerToAnArray);
46 //
47 //
48 // Fourth one is, almost, similar to the constructor above, except
49 // initialisation is provided with three independent arrays (array of
50 // x coordinates, y coordinates and z coordinates).
51 //
52 // Example:
53 // TPoints3D pl1(150, xArray, yArray, zArray);
54 //
55 
57 
58 ////////////////////////////////////////////////////////////////////////////////
59 /// 3-D PolyLine default constructor.
60 
62 {
63  DoOwner(kFALSE);
64  fPoints = points;
65  if (!fPoints) {
66  fPoints = new TPointsArray3D;
67  DoOwner();
68  }
69 }
70 
71 ////////////////////////////////////////////////////////////////////////////////
72 /// 3-D PolyLine normal constructor without initialisation.
73 /// If n < 0 the default size (2 points) is set.
74 
76 {
77  DoOwner();
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// 3-D Point3D normal constructor.
82 /// If n < 0 the default size (2 points) is set.
83 
85 {
86  DoOwner();
87 }
88 
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 /// 3-D PolyLine normal constructor.
92 /// If n < 0 the default size (2 points) is set.
93 
95  : fPoints(new TPointsArray3D(n,x,y,z,option))
96 {
97  DoOwner();
98 }
99 
100 
101 ////////////////////////////////////////////////////////////////////////////////
102 /// 3-D PolyLine default destructor.
103 
105 {
106  Delete();
107 }
108 ////////////////////////////////////////////////////////////////////////////////
109 ///to be documented
110 
112 {
113  ((TPoints3D&)point).Copy(*this);
114 }
115 ////////////////////////////////////////////////////////////////////////////////
116 /// Copy this TPoints3D to another.
117 
118 void TPoints3D::Copy(TObject &obj) const
119 {
120  TPoints3DABC::Copy(obj);
121  TPoints3D &thatObject = (TPoints3D&)obj;
122  thatObject.Delete();
123  if (thatObject.IsOwner()) {
124  thatObject.fPoints = new TPoints3D(GetN(),GetP(),GetOption());
125  (thatObject.fPoints)->SetLastPosition(GetLastPosition());
126  }
127  else
128  thatObject.fPoints = fPoints;
129 }
130 
131 ////////////////////////////////////////////////////////////////////////////////
132 /// Delete only own object.
133 
135 {
136  if (fPoints && IsOwner()) delete fPoints;
137  fPoints = 0;
138 }
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 ///to be documented
142 
144 {
145  if (done) SetBit(kIsOwner);
146  else ResetBit(kIsOwner);
147  return IsOwner();
148 }
149 
150 ////////////////////////////////////////////////////////////////////////////////
151 /// Execute action corresponding to one event.
152 
154 {
155  if (fPoints)
156  fPoints->ExecuteEvent(event,px,py);
157 }
158 
159 ////////////////////////////////////////////////////////////////////////////////
160 /// List this 3-D polyline with its attributes.
161 
162 void TPoints3D::ls(Option_t *option) const
163 {
165  std::cout << IsA()->GetName() << " N=" <<GetN()<<" Option="<<option<<std::endl;
166 // IsOwner()?"Owner":"Not owner" << std::endl;
167 }
168 
169 ////////////////////////////////////////////////////////////////////////////////
170 /// Dump this 3-D polyline with its attributes.
171 
172 void TPoints3D::Print(Option_t *option) const
173 {
174  std::cout <<" " << IsA()->GetName() <<" Printing N=" <<GetN()<<" Option="<<option<<std::endl;
175 // IsOwner()?"Owner":"Not owner" << std::endl;
176 }
177 
virtual void Delete()
Delete only own object.
Definition: TPoints3D.cxx:134
virtual Option_t * GetOption() const
Definition: TPoints3D.h:83
virtual Int_t GetLastPosition() const
Definition: TPoints3D.h:74
TPoints3DABC * fPoints
Definition: TPoints3D.h:33
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
Abstract class to define Arrays of 3D points.
Definition: TPoints3DABC.h:25
virtual void Copy(TObject &points) const
Copy this TPoints3D to another.
Definition: TPoints3D.cxx:118
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
Double_t x[n]
Definition: legend1.C:17
virtual void Copy(TObject &object) const
Copy this to obj.
Definition: TObject.cxx:61
virtual void ls(Option_t *option="") const
List this 3-D polyline with its attributes.
Definition: TPoints3D.cxx:162
virtual Int_t SetLastPosition(Int_t idx)
Definition: TPoints3D.h:84
point * points
Definition: X3DBuffer.c:20
virtual Float_t * GetP() const
GetP() returns the pointer to the float point array of points if available The number of the availabl...
Definition: TPoints3D.h:76
Bool_t DoOwner(Bool_t done=kTRUE)
to be documented
Definition: TPoints3D.cxx:143
virtual void Delete(Option_t *)
Delete this object.
Definition: TPoints3D.h:72
TPoints3D(TPoints3DABC *points=0)
3-D PolyLine default constructor.
Definition: TPoints3D.cxx:61
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2832
const Bool_t kFALSE
Definition: RtypesCore.h:88
Bool_t IsOwner() const
Definition: TPoints3D.h:35
#define ClassImp(name)
Definition: Rtypes.h:359
virtual Int_t GetN() const
GetN() returns the number of allocated cells if any.
Definition: TPoints3D.h:75
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition: TObject.cxx:311
Double_t y[n]
Definition: legend1.C:17
virtual void Print(Option_t *option="") const
Dump this 3-D polyline with its attributes.
Definition: TPoints3D.cxx:172
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
virtual ~TPoints3D()
3-D PolyLine default destructor.
Definition: TPoints3D.cxx:104
void ResetBit(UInt_t f)
Definition: TObject.h:171
const Int_t n
Definition: legend1.C:16
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to one event.
Definition: TPoints3D.cxx:153