diff --git a/g3d/inc/LinkDef.h b/g3d/inc/LinkDef.h
index e10753c91674f568030d115915664d00b06da63f..657e3e816b0deb022f483ce3a25aab6ad26e424d 100644
--- a/g3d/inc/LinkDef.h
+++ b/g3d/inc/LinkDef.h
@@ -1,4 +1,4 @@
-/* @(#)root/g3d:$Name:  $:$Id: LinkDef.h,v 1.7 2004/12/06 07:22:55 brun Exp $ */
+/* @(#)root/g3d:$Name:  $:$Id: LinkDef.h,v 1.8 2006/04/07 08:43:59 brun Exp $ */
 
 /*************************************************************************
  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
@@ -37,7 +37,7 @@
 #pragma link C++ class TPGON+;
 #pragma link C++ class TPolyLine3D-;
 #pragma link C++ class TPolyMarker3D-;
-#pragma link C++ class TPointSet3D+;
+#pragma link C++ class TPointSet3D-;
 #pragma link C++ class TRotMatrix-;
 #pragma link C++ class TShape-;
 #pragma link C++ class TSPHE-;
diff --git a/g3d/inc/TPointSet3D.h b/g3d/inc/TPointSet3D.h
index 83efe0c315e1b04a7571ae2305da19215306b8e9..d5d72fbb4e117b627384550bceaffea81f295a61 100644
--- a/g3d/inc/TPointSet3D.h
+++ b/g3d/inc/TPointSet3D.h
@@ -1,4 +1,4 @@
-// @(#)root/g3d:$Name:  $:$Id: TPointSet3D.h,v 1.2 2006/04/07 09:20:43 rdm Exp $
+// @(#)root/g3d:$Name:  $:$Id: TPointSet3D.h,v 1.3 2006/08/23 14:39:40 brun Exp $
 // Author: Matevz Tadel  7/4/2006
 
 /*************************************************************************
@@ -20,32 +20,27 @@
 #include "TAttBBox.h"
 #endif
 
+#include "TRefArray.h"
+
 class TPointSet3D : public TPolyMarker3D, public TAttBBox
 {
 protected:
-   TObject** fIds;    //!User-provided point identifications
-   Int_t     fNIds;   //!Number of allocated entries for user-ids
-   Bool_t    fOwnIds; //!Flag specifying id-objects are owned by the point-set
-   Bool_t    fFakeIds;//!Flag specifying ids are not TObject*
+   Bool_t    fOwnIds; //Flag specifying id-objects are owned by the point-set
+   TRefArray fIds;    //User-provided point identifications
 
    TPointSet3D& operator=(const TPointSet3D&);
 
 public:
    TPointSet3D() :
-      TPolyMarker3D(), fIds(0), fNIds(0),
-      fOwnIds(kFALSE), fFakeIds(kFALSE) { fName = "TPointSet3D"; }
+      TPolyMarker3D(), fOwnIds(kFALSE) { fName = "TPointSet3D"; }
    TPointSet3D(Int_t n, Marker_t m=1, Option_t *opt="") :
-      TPolyMarker3D(n, m, opt), fIds(0), fNIds(0),
-      fOwnIds(kFALSE), fFakeIds(kFALSE) { fName = "TPointSet3D"; }
+      TPolyMarker3D(n, m, opt), fOwnIds(kFALSE) { fName = "TPointSet3D"; }
    TPointSet3D(Int_t n, Float_t *p, Marker_t m=1, Option_t *opt="") :
-      TPolyMarker3D(n, p, m, opt), fIds(0), fNIds(0),
-      fOwnIds(kFALSE), fFakeIds(kFALSE) { fName = "TPointSet3D"; }
+      TPolyMarker3D(n, p, m, opt), fOwnIds(kFALSE) { fName = "TPointSet3D"; }
    TPointSet3D(Int_t n, Double_t *p, Marker_t m=1, Option_t *opt="") :
-      TPolyMarker3D(n, p, m, opt), fIds(0), fNIds(0),
-      fOwnIds(kFALSE), fFakeIds(kFALSE) { fName = "TPointSet3D"; }
+      TPolyMarker3D(n, p, m, opt), fOwnIds(kFALSE) { fName = "TPointSet3D"; }
    TPointSet3D(const TPointSet3D &ps) :
-      TPolyMarker3D(ps), TAttBBox(), fIds(0), fNIds(0),
-      fOwnIds(kFALSE), fFakeIds(kFALSE) { fName = "TPointSet3D"; }
+      TPolyMarker3D(ps), TAttBBox(ps), fOwnIds(kFALSE), fIds(ps.fIds) {}
 
    virtual ~TPointSet3D();
 
@@ -53,13 +48,11 @@ public:
 
    void     SetPointId(TObject* id);
    void     SetPointId(Int_t n, TObject* id);
-   TObject* GetPointId(Int_t n) const;
+   TObject* GetPointId(Int_t n) const { return fIds.At(n); }
    void     ClearIds();
 
    Bool_t GetOwnIds() const    { return fOwnIds; }
    void   SetOwnIds(Bool_t o)  { fOwnIds = o; }
-   Bool_t GetFakeIds() const   { return fFakeIds; }
-   void   SetFakeIds(Bool_t f) { fFakeIds = f; }
 
    virtual void PointSelected(Int_t n);
 
diff --git a/g3d/src/TPointSet3D.cxx b/g3d/src/TPointSet3D.cxx
index 113ab359acb787657a860e0df55a636dc36be0e6..a719423d242b09a8e8e5303d9b631b7d6f8402d2 100644
--- a/g3d/src/TPointSet3D.cxx
+++ b/g3d/src/TPointSet3D.cxx
@@ -1,4 +1,4 @@
-// @(#)root/g3d:$Name:  $:$Id: TPointSet3D.cxx,v 1.4 2006/05/09 19:08:44 brun Exp $
+// @(#)root/g3d:$Name:  $:$Id: TPointSet3D.cxx,v 1.5 2006/08/23 14:39:40 brun Exp $
 // Author: Matevz Tadel  7/4/2006
 
 /*************************************************************************
@@ -42,6 +42,10 @@ TPointSet3D& TPointSet3D::operator=(const TPointSet3D& tp3)
    if(this!=&tp3) {
       ClearIds();
       TPolyMarker3D::operator=(tp3);
+      fOwnIds = kFALSE;
+      fIds.Expand(tp3.fIds.GetSize());
+      for (Int_t i=0; i<tp3.fIds.GetSize(); ++i)
+         fIds.AddAt(tp3.fIds.At(i), i);
    }
    return *this;
 }
@@ -85,27 +89,9 @@ void TPointSet3D::SetPointId(Int_t n, TObject* id)
    // Set id of point n.
 
    if (n >= fN) return;
-   if (fN > fNIds) {
-      TObject** idarr = new TObject* [fN];
-      if (fIds && fNIds) {
-         memcpy(idarr, fIds, fNIds*sizeof(TObject*));
-         memset(idarr+fNIds, 0, (fN-fNIds)*sizeof(TObject*));
-         delete [] fIds;
-      }
-      fIds  = idarr;
-      fNIds = fN;
-   }
-   fIds[n] = id;
-}
-
-//______________________________________________________________________________
-TObject* TPointSet3D::GetPointId(Int_t n) const
-{
-   // Get id of point n.
-   // If n is out of range 0 is returned.
-
-   if (n < 0 || n >= fNIds) return 0;
-   return fIds[n];
+   if (fN > fIds.GetSize())
+      fIds.Expand(fN);
+   fIds.AddAt(id, n);
 }
 
 //______________________________________________________________________________
@@ -113,13 +99,11 @@ void TPointSet3D::ClearIds()
 {
    // Clears the id-array. If ids are owned the TObjects are deleted.
 
-   if (fNIds <= 0) return;
    if (fOwnIds) {
-      for (Int_t i=0; i<fNIds; ++i)
-         if (fIds[i]) delete fIds[i];
+      for (Int_t i=0; i<fIds.GetSize(); ++i)
+         delete GetPointId(i);
    }
-   delete [] fIds;
-   fNIds = 0;
+   fIds.Expand(0);
 }
 
 //______________________________________________________________________________
@@ -133,9 +117,37 @@ void TPointSet3D::PointSelected(Int_t n)
    //  b) extend this class to include TExec or some other kind of callback.
 
    TObject* id = GetPointId(n);
-   Bool_t idok = (id != 0 && fFakeIds == kFALSE);
    printf("TPointSet3D::PointSelected n=%d, id=(%s*)0x%lx\n",
-          n, idok ? id->IsA()->GetName() : "void", (ULong_t)id);
-   if (idok)
+          n, id ? id->IsA()->GetName() : "void", (ULong_t)id);
+   if (id)
       id->Print();
 }
+
+//______________________________________________________________________________
+void TPointSet3D::Streamer(TBuffer &R__b)
+{
+   // Stream an object of class TPointSet3D.
+
+   if (R__b.IsReading()) {
+      TPointSet3D::Class()->ReadBuffer(R__b, this);
+      if (fOwnIds) {
+         Int_t n;
+         R__b >> n;
+         for (Int_t i=0; i<n; ++i) {
+            TObject* o = (TObject*) R__b.ReadObjectAny(TObject::Class());
+            if (gDebug > 0) printf("Read[%2d]: ", i); o->Print();
+         }
+      }
+   } else {
+      TPointSet3D::Class()->WriteBuffer(R__b, this);
+      if (fOwnIds) {
+         R__b << fIds.GetEntries();
+         TObject* o;
+         TIter next(&fIds);
+         while ((o = next())) {
+            if (gDebug > 0) printf("Writing: "); o->Print();
+            R__b.WriteObjectAny(o, TObject::Class());
+         }
+      }
+   }
+}