Logo ROOT   6.10/09
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 ///*-* ================================
61 
63 {
64  DoOwner(kFALSE);
65  fPoints = points;
66  if (!fPoints) {
67  fPoints = new TPointsArray3D;
68  DoOwner();
69  }
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 ///*-*-*-*-*-*3-D PolyLine normal constructor without initialisation*-*-*-*-*-*-*
74 ///*-* ======================================================
75 ///*-* If n < 0 the default size (2 points) is set
76 ///*-*
77 
78 TPoints3D::TPoints3D(Int_t n, Option_t *option) : fPoints( new TPointsArray3D(n,option))
79 {
80  DoOwner();
81 }
82 
83 ////////////////////////////////////////////////////////////////////////////////
84 ///*-*-*-*-*-*-*-*-*-*-*-*-*3-D Point3D normal constructor*-*-*-*-*-*-*-*-*-*-*-*
85 ///*-* ===============================
86 ///*-* If n < 0 the default size (2 points) is set
87 ///*-*
88 
90 {
91  DoOwner();
92 }
93 
94 
95 ////////////////////////////////////////////////////////////////////////////////
96 ///*-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine normal constructor*-*-*-*-*-*-*-*-*-*-*-*
97 ///*-* ===============================
98 ///*-* If n < 0 the default size (2 points) is set
99 ///*-*
100 
102  : fPoints(new TPointsArray3D(n,x,y,z,option))
103 {
104  DoOwner();
105 }
106 
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 ///*-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine default destructor*-*-*-*-*-*-*-*-*-*-*-*
110 ///*-* ===============================
111 
113 {
114  Delete();
115 }
116 ////////////////////////////////////////////////////////////////////////////////
117 ///to be documented
118 
120 {
121  ((TPoints3D&)point).Copy(*this);
122 }
123 ////////////////////////////////////////////////////////////////////////////////
124 ///*-*-*-*-*-*-*-*-*-*-*-*-*Copy this TPoints3D to another *-*-*-*-*-*-*-*-*-*-*-*
125 ///*-* ==============================
126 
127 void TPoints3D::Copy(TObject &obj) const
128 {
129  TPoints3DABC::Copy(obj);
130  TPoints3D &thatObject = (TPoints3D&)obj;
131  thatObject.Delete();
132  if (thatObject.IsOwner()) {
133  thatObject.fPoints = new TPoints3D(GetN(),GetP(),GetOption());
134  (thatObject.fPoints)->SetLastPosition(GetLastPosition());
135  }
136  else
137  thatObject.fPoints = fPoints;
138 }
139 
140 ////////////////////////////////////////////////////////////////////////////////
141 /// Delete only own object
142 
144 {
145  if (fPoints && IsOwner()) delete fPoints;
146  fPoints = 0;
147 }
148 
149 ////////////////////////////////////////////////////////////////////////////////
150 ///to be documented
151 
153 {
154  if (done) SetBit(kIsOwner);
155  else ResetBit(kIsOwner);
156  return IsOwner();
157 }
158 
159 ////////////////////////////////////////////////////////////////////////////////
160 ///*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*-*-*
161 ///*-* =========================================
162 
164 {
165  if (fPoints)
166  fPoints->ExecuteEvent(event,px,py);
167 }
168 
169 ////////////////////////////////////////////////////////////////////////////////
170 ///*-*-*-*-*-*-*-*-*-*List this 3-D polyline with its attributes*-*-*-*-*-*-*
171 ///*-* ==========================================
172 
173 void TPoints3D::ls(Option_t *option) const
174 {
176  std::cout << IsA()->GetName() << " N=" <<GetN()<<" Option="<<option<<std::endl;
177 // IsOwner()?"Owner":"Not owner" << std::endl;
178 }
179 
180 ////////////////////////////////////////////////////////////////////////////////
181 ///*-*-*-*-*-*-*-*-*-*Dump this 3-D polyline with its attributes*-*-*-*-*-*-*-*-*
182 ///*-* ==========================================
183 
184 void TPoints3D::Print(Option_t *option) const
185 {
186  std::cout <<" " << IsA()->GetName() <<" Printing N=" <<GetN()<<" Option="<<option<<std::endl;
187 // IsOwner()?"Owner":"Not owner" << std::endl;
188 }
189 
virtual void Delete()
Delete only own object.
Definition: TPoints3D.cxx:143
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 Bool_t DoOwner(Bool_t done=kTRUE)
Set / Reset the ownerships and returns the previous status of the ownerships.
Definition: TObjectSet.cxx:85
virtual void Copy(TObject &points) const
*-*-*-*-*-*-*-*-*-*-*-*-*Copy this TPoints3D to another *-*-*-*-*-*-*-*-*-*-*-* *-* =================...
Definition: TPoints3D.cxx:127
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:687
Double_t x[n]
Definition: legend1.C:17
virtual void Copy(TObject &object) const
Copy this to obj.
Definition: TObject.cxx:60
virtual void ls(Option_t *option="") const
-*-*-*-*-*-*-*-*-*List this 3-D polyline with its attributes-*-*-*-*-*-* *-* ========================...
Definition: TPoints3D.cxx:173
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:152
virtual void Delete(Option_t *)
Delete this object.
Definition: TPoints3D.h:72
TPoints3D(TPoints3DABC *points=0)
-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine default constructor-*-*-*-*-*-*-*-*-*-* *-* ====================...
Definition: TPoints3D.cxx:62
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition: TROOT.cxx:2632
const Bool_t kFALSE
Definition: RtypesCore.h:92
Bool_t IsOwner() const
Definition: TPoints3D.h:35
#define ClassImp(name)
Definition: Rtypes.h:336
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:318
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:184
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:112
void ResetBit(UInt_t f)
Definition: TObject.h:158
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:163