TPoints3D.cxx

Go to the documentation of this file.
00001 // @(#)root/table:$Id: TPoints3D.cxx 21414 2007-12-17 14:15:59Z brun $
00002 // Author: Valery Fine(fine@mail.cern.ch)   24/04/99
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "Riostream.h"
00013 
00014 #include "TROOT.h"
00015 #include "TClass.h"
00016 #include "TPoints3D.h"
00017 #include "TPointsArray3D.h"
00018 
00019 //______________________________________________________________________________
00020 //
00021 // TPoints3D is an abstract class of the array of 3-dimensional points.
00022 // It has 4 different constructors.
00023 //
00024 // This class has no implemenatation for Paint, Draw, and SavePrimitive methods
00025 //
00026 //   First one, without any parameters TPoints3D(), we call 'default
00027 // constructor' and it's used in a case that just an initialisation is
00028 // needed (i.e. pointer declaration).
00029 //
00030 //       Example:
00031 //                 TPoints3D *pl1 = new TPoints3D;
00032 //
00033 //
00034 //   Second one is 'normal constructor' with, usually, one parameter
00035 // n (number of points), and it just allocates a space for the points.
00036 //
00037 //       Example:
00038 //                 TPoints3D pl1(150);
00039 //
00040 //
00041 //   Third one allocates a space for the points, and also makes
00042 // initialisation from the given array.
00043 //
00044 //       Example:
00045 //                 TPoints3D pl1(150, pointerToAnArray);
00046 //
00047 //
00048 //   Fourth one is, almost, similar to the constructor above, except
00049 // initialisation is provided with three independent arrays (array of
00050 // x coordinates, y coordinates and z coordinates).
00051 //
00052 //       Example:
00053 //                 TPoints3D pl1(150, xArray, yArray, zArray);
00054 //
00055 
00056 ClassImp(TPoints3D)
00057 
00058 //______________________________________________________________________________
00059 TPoints3D::TPoints3D(TPoints3DABC *points) : fPoints(points)
00060 {
00061 //*-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine default constructor*-*-*-*-*-*-*-*-*-*-*
00062 //*-*                      ================================
00063    DoOwner(kFALSE);
00064    fPoints = points;
00065    if (!fPoints) {
00066       fPoints = new TPointsArray3D;
00067       DoOwner();
00068    }
00069 }
00070 
00071 //______________________________________________________________________________
00072 TPoints3D::TPoints3D(Int_t n, Option_t *option) : fPoints( new TPointsArray3D(n,option))
00073 {
00074 //*-*-*-*-*-*3-D PolyLine normal constructor without initialisation*-*-*-*-*-*-*
00075 //*-*        ======================================================
00076 //*-*  If n < 0 the default size (2 points) is set
00077 //*-*
00078    DoOwner();
00079 }
00080 
00081 //______________________________________________________________________________
00082 TPoints3D::TPoints3D(Int_t n, Float_t *p, Option_t *option) : fPoints(new TPointsArray3D(n,p,option))
00083 {
00084 //*-*-*-*-*-*-*-*-*-*-*-*-*3-D Point3D normal constructor*-*-*-*-*-*-*-*-*-*-*-*
00085 //*-*                      ===============================
00086 //*-*  If n < 0 the default size (2 points) is set
00087 //*-*
00088    DoOwner();
00089 }
00090 
00091 
00092 //______________________________________________________________________________
00093 TPoints3D::TPoints3D(Int_t n, Float_t *x, Float_t *y, Float_t *z, Option_t *option)
00094                        : fPoints(new TPointsArray3D(n,x,y,z,option))
00095 {
00096 //*-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine normal constructor*-*-*-*-*-*-*-*-*-*-*-*
00097 //*-*                      ===============================
00098 //*-*  If n < 0 the default size (2 points) is set
00099 //*-*
00100    DoOwner();
00101 }
00102 
00103 
00104 //______________________________________________________________________________
00105 TPoints3D::~TPoints3D()
00106 {
00107 //*-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine default destructor*-*-*-*-*-*-*-*-*-*-*-*
00108 //*-*                      ===============================
00109    Delete();
00110 }
00111 //______________________________________________________________________________
00112 TPoints3D::TPoints3D(const TPoints3D &point) : TPoints3DABC(point)
00113 {
00114    //to be documented
00115    ((TPoints3D&)point).Copy(*this);
00116 }
00117 //______________________________________________________________________________
00118 void TPoints3D::Copy(TObject &obj) const
00119 {
00120 //*-*-*-*-*-*-*-*-*-*-*-*-*Copy this TPoints3D to another *-*-*-*-*-*-*-*-*-*-*-*
00121 //*-*                      ==============================
00122 
00123    TPoints3DABC::Copy(obj);
00124    TPoints3D &thatObject = (TPoints3D&)obj;
00125    thatObject.Delete();
00126    if (thatObject.IsOwner()) {
00127       thatObject.fPoints =  new TPoints3D(GetN(),GetP(),GetOption());
00128       (thatObject.fPoints)->SetLastPosition(GetLastPosition());
00129    }
00130    else
00131       thatObject.fPoints = fPoints;
00132 }
00133 
00134 //______________________________________________________________________________
00135 void TPoints3D::Delete()
00136 {
00137    // Delete only own object
00138    if (fPoints && IsOwner()) delete fPoints;
00139    fPoints = 0;
00140 }
00141 
00142 //______________________________________________________________________________
00143 Bool_t TPoints3D::DoOwner(Bool_t done)
00144 {
00145    //to be documented
00146    if (done) SetBit(kIsOwner);
00147    else ResetBit(kIsOwner);
00148    return IsOwner();
00149 }
00150 
00151 //______________________________________________________________________________
00152 void TPoints3D::ExecuteEvent(Int_t event, Int_t px, Int_t py)
00153 {
00154 //*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*-*-*
00155 //*-*                =========================================
00156    if (fPoints)
00157       fPoints->ExecuteEvent(event,px,py);
00158 }
00159 
00160 //______________________________________________________________________________
00161 void TPoints3D::ls(Option_t *option) const
00162 {
00163 //*-*-*-*-*-*-*-*-*-*List this 3-D polyline with its attributes*-*-*-*-*-*-*
00164 //*-*                ==========================================
00165 
00166    TROOT::IndentLevel();
00167    cout << IsA()->GetName() << " N=" <<GetN()<<" Option="<<option<<endl;
00168 //   IsOwner()?"Owner":"Not owner" << endl;
00169 }
00170 
00171 //______________________________________________________________________________
00172 void TPoints3D::Print(Option_t *option) const
00173 {
00174 //*-*-*-*-*-*-*-*-*-*Dump this 3-D polyline with its attributes*-*-*-*-*-*-*-*-*
00175 //*-*                ==========================================
00176    cout <<"   " << IsA()->GetName() <<" Printing N=" <<GetN()<<" Option="<<option<<endl;
00177 //   IsOwner()?"Owner":"Not owner" << endl;
00178 }
00179 

Generated on Tue Jul 5 14:45:06 2011 for ROOT_528-00b_version by  doxygen 1.5.1