ROOT logo
// @(#)root/table:$Id: TPoints3D.cxx 21414 2007-12-17 14:15:59Z brun $
// Author: Valery Fine(fine@mail.cern.ch)   24/04/99

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#include "Riostream.h"

#include "TROOT.h"
#include "TClass.h"
#include "TPoints3D.h"
#include "TPointsArray3D.h"

//______________________________________________________________________________
//
// TPoints3D is an abstract class of the array of 3-dimensional points.
// It has 4 different constructors.
//
// This class has no implemenatation for Paint, Draw, and SavePrimitive methods
//
//   First one, without any parameters TPoints3D(), we call 'default
// constructor' and it's used in a case that just an initialisation is
// needed (i.e. pointer declaration).
//
//       Example:
//                 TPoints3D *pl1 = new TPoints3D;
//
//
//   Second one is 'normal constructor' with, usually, one parameter
// n (number of points), and it just allocates a space for the points.
//
//       Example:
//                 TPoints3D pl1(150);
//
//
//   Third one allocates a space for the points, and also makes
// initialisation from the given array.
//
//       Example:
//                 TPoints3D pl1(150, pointerToAnArray);
//
//
//   Fourth one is, almost, similar to the constructor above, except
// initialisation is provided with three independent arrays (array of
// x coordinates, y coordinates and z coordinates).
//
//       Example:
//                 TPoints3D pl1(150, xArray, yArray, zArray);
//

ClassImp(TPoints3D)

//______________________________________________________________________________
TPoints3D::TPoints3D(TPoints3DABC *points) : fPoints(points)
{
//*-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine default constructor*-*-*-*-*-*-*-*-*-*-*
//*-*                      ================================
   DoOwner(kFALSE);
   fPoints = points;
   if (!fPoints) {
      fPoints = new TPointsArray3D;
      DoOwner();
   }
}

//______________________________________________________________________________
TPoints3D::TPoints3D(Int_t n, Option_t *option) : fPoints( new TPointsArray3D(n,option))
{
//*-*-*-*-*-*3-D PolyLine normal constructor without initialisation*-*-*-*-*-*-*
//*-*        ======================================================
//*-*  If n < 0 the default size (2 points) is set
//*-*
   DoOwner();
}

//______________________________________________________________________________
TPoints3D::TPoints3D(Int_t n, Float_t *p, Option_t *option) : fPoints(new TPointsArray3D(n,p,option))
{
//*-*-*-*-*-*-*-*-*-*-*-*-*3-D Point3D normal constructor*-*-*-*-*-*-*-*-*-*-*-*
//*-*                      ===============================
//*-*  If n < 0 the default size (2 points) is set
//*-*
   DoOwner();
}


//______________________________________________________________________________
TPoints3D::TPoints3D(Int_t n, Float_t *x, Float_t *y, Float_t *z, Option_t *option)
                       : fPoints(new TPointsArray3D(n,x,y,z,option))
{
//*-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine normal constructor*-*-*-*-*-*-*-*-*-*-*-*
//*-*                      ===============================
//*-*  If n < 0 the default size (2 points) is set
//*-*
   DoOwner();
}


//______________________________________________________________________________
TPoints3D::~TPoints3D()
{
//*-*-*-*-*-*-*-*-*-*-*-*-*3-D PolyLine default destructor*-*-*-*-*-*-*-*-*-*-*-*
//*-*                      ===============================
   Delete();
}
//______________________________________________________________________________
TPoints3D::TPoints3D(const TPoints3D &point) : TPoints3DABC(point)
{
   //to be documented
   ((TPoints3D&)point).Copy(*this);
}
//______________________________________________________________________________
void TPoints3D::Copy(TObject &obj) const
{
//*-*-*-*-*-*-*-*-*-*-*-*-*Copy this TPoints3D to another *-*-*-*-*-*-*-*-*-*-*-*
//*-*                      ==============================

   TPoints3DABC::Copy(obj);
   TPoints3D &thatObject = (TPoints3D&)obj;
   thatObject.Delete();
   if (thatObject.IsOwner()) {
      thatObject.fPoints =  new TPoints3D(GetN(),GetP(),GetOption());
      (thatObject.fPoints)->SetLastPosition(GetLastPosition());
   }
   else
      thatObject.fPoints = fPoints;
}

//______________________________________________________________________________
void TPoints3D::Delete()
{
   // Delete only own object
   if (fPoints && IsOwner()) delete fPoints;
   fPoints = 0;
}

//______________________________________________________________________________
Bool_t TPoints3D::DoOwner(Bool_t done)
{
   //to be documented
   if (done) SetBit(kIsOwner);
   else ResetBit(kIsOwner);
   return IsOwner();
}

//______________________________________________________________________________
void TPoints3D::ExecuteEvent(Int_t event, Int_t px, Int_t py)
{
//*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*-*-*
//*-*                =========================================
   if (fPoints)
      fPoints->ExecuteEvent(event,px,py);
}

//______________________________________________________________________________
void TPoints3D::ls(Option_t *option) const
{
//*-*-*-*-*-*-*-*-*-*List this 3-D polyline with its attributes*-*-*-*-*-*-*
//*-*                ==========================================

   TROOT::IndentLevel();
   cout << IsA()->GetName() << " N=" <<GetN()<<" Option="<<option<<endl;
//   IsOwner()?"Owner":"Not owner" << endl;
}

//______________________________________________________________________________
void TPoints3D::Print(Option_t *option) const
{
//*-*-*-*-*-*-*-*-*-*Dump this 3-D polyline with its attributes*-*-*-*-*-*-*-*-*
//*-*                ==========================================
   cout <<"   " << IsA()->GetName() <<" Printing N=" <<GetN()<<" Option="<<option<<endl;
//   IsOwner()?"Owner":"Not owner" << endl;
}

 TPoints3D.cxx:1
 TPoints3D.cxx:2
 TPoints3D.cxx:3
 TPoints3D.cxx:4
 TPoints3D.cxx:5
 TPoints3D.cxx:6
 TPoints3D.cxx:7
 TPoints3D.cxx:8
 TPoints3D.cxx:9
 TPoints3D.cxx:10
 TPoints3D.cxx:11
 TPoints3D.cxx:12
 TPoints3D.cxx:13
 TPoints3D.cxx:14
 TPoints3D.cxx:15
 TPoints3D.cxx:16
 TPoints3D.cxx:17
 TPoints3D.cxx:18
 TPoints3D.cxx:19
 TPoints3D.cxx:20
 TPoints3D.cxx:21
 TPoints3D.cxx:22
 TPoints3D.cxx:23
 TPoints3D.cxx:24
 TPoints3D.cxx:25
 TPoints3D.cxx:26
 TPoints3D.cxx:27
 TPoints3D.cxx:28
 TPoints3D.cxx:29
 TPoints3D.cxx:30
 TPoints3D.cxx:31
 TPoints3D.cxx:32
 TPoints3D.cxx:33
 TPoints3D.cxx:34
 TPoints3D.cxx:35
 TPoints3D.cxx:36
 TPoints3D.cxx:37
 TPoints3D.cxx:38
 TPoints3D.cxx:39
 TPoints3D.cxx:40
 TPoints3D.cxx:41
 TPoints3D.cxx:42
 TPoints3D.cxx:43
 TPoints3D.cxx:44
 TPoints3D.cxx:45
 TPoints3D.cxx:46
 TPoints3D.cxx:47
 TPoints3D.cxx:48
 TPoints3D.cxx:49
 TPoints3D.cxx:50
 TPoints3D.cxx:51
 TPoints3D.cxx:52
 TPoints3D.cxx:53
 TPoints3D.cxx:54
 TPoints3D.cxx:55
 TPoints3D.cxx:56
 TPoints3D.cxx:57
 TPoints3D.cxx:58
 TPoints3D.cxx:59
 TPoints3D.cxx:60
 TPoints3D.cxx:61
 TPoints3D.cxx:62
 TPoints3D.cxx:63
 TPoints3D.cxx:64
 TPoints3D.cxx:65
 TPoints3D.cxx:66
 TPoints3D.cxx:67
 TPoints3D.cxx:68
 TPoints3D.cxx:69
 TPoints3D.cxx:70
 TPoints3D.cxx:71
 TPoints3D.cxx:72
 TPoints3D.cxx:73
 TPoints3D.cxx:74
 TPoints3D.cxx:75
 TPoints3D.cxx:76
 TPoints3D.cxx:77
 TPoints3D.cxx:78
 TPoints3D.cxx:79
 TPoints3D.cxx:80
 TPoints3D.cxx:81
 TPoints3D.cxx:82
 TPoints3D.cxx:83
 TPoints3D.cxx:84
 TPoints3D.cxx:85
 TPoints3D.cxx:86
 TPoints3D.cxx:87
 TPoints3D.cxx:88
 TPoints3D.cxx:89
 TPoints3D.cxx:90
 TPoints3D.cxx:91
 TPoints3D.cxx:92
 TPoints3D.cxx:93
 TPoints3D.cxx:94
 TPoints3D.cxx:95
 TPoints3D.cxx:96
 TPoints3D.cxx:97
 TPoints3D.cxx:98
 TPoints3D.cxx:99
 TPoints3D.cxx:100
 TPoints3D.cxx:101
 TPoints3D.cxx:102
 TPoints3D.cxx:103
 TPoints3D.cxx:104
 TPoints3D.cxx:105
 TPoints3D.cxx:106
 TPoints3D.cxx:107
 TPoints3D.cxx:108
 TPoints3D.cxx:109
 TPoints3D.cxx:110
 TPoints3D.cxx:111
 TPoints3D.cxx:112
 TPoints3D.cxx:113
 TPoints3D.cxx:114
 TPoints3D.cxx:115
 TPoints3D.cxx:116
 TPoints3D.cxx:117
 TPoints3D.cxx:118
 TPoints3D.cxx:119
 TPoints3D.cxx:120
 TPoints3D.cxx:121
 TPoints3D.cxx:122
 TPoints3D.cxx:123
 TPoints3D.cxx:124
 TPoints3D.cxx:125
 TPoints3D.cxx:126
 TPoints3D.cxx:127
 TPoints3D.cxx:128
 TPoints3D.cxx:129
 TPoints3D.cxx:130
 TPoints3D.cxx:131
 TPoints3D.cxx:132
 TPoints3D.cxx:133
 TPoints3D.cxx:134
 TPoints3D.cxx:135
 TPoints3D.cxx:136
 TPoints3D.cxx:137
 TPoints3D.cxx:138
 TPoints3D.cxx:139
 TPoints3D.cxx:140
 TPoints3D.cxx:141
 TPoints3D.cxx:142
 TPoints3D.cxx:143
 TPoints3D.cxx:144
 TPoints3D.cxx:145
 TPoints3D.cxx:146
 TPoints3D.cxx:147
 TPoints3D.cxx:148
 TPoints3D.cxx:149
 TPoints3D.cxx:150
 TPoints3D.cxx:151
 TPoints3D.cxx:152
 TPoints3D.cxx:153
 TPoints3D.cxx:154
 TPoints3D.cxx:155
 TPoints3D.cxx:156
 TPoints3D.cxx:157
 TPoints3D.cxx:158
 TPoints3D.cxx:159
 TPoints3D.cxx:160
 TPoints3D.cxx:161
 TPoints3D.cxx:162
 TPoints3D.cxx:163
 TPoints3D.cxx:164
 TPoints3D.cxx:165
 TPoints3D.cxx:166
 TPoints3D.cxx:167
 TPoints3D.cxx:168
 TPoints3D.cxx:169
 TPoints3D.cxx:170
 TPoints3D.cxx:171
 TPoints3D.cxx:172
 TPoints3D.cxx:173
 TPoints3D.cxx:174
 TPoints3D.cxx:175
 TPoints3D.cxx:176
 TPoints3D.cxx:177
 TPoints3D.cxx:178
 TPoints3D.cxx:179