Ignore:
Timestamp:
10/29/06 18:17:38 (18 years ago)
Author:
mattausch
Message:

removed memory leaks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Intersectable.h

    r1687 r1696  
    4848  BvhLeaf *mBvhLeaf; 
    4949//BvhNode *mBvhLeaf; 
    50   /// some rays piercing this intersectable 
    51   VssRayContainer mVssRays; 
    52  
     50   
    5351  /// # of references to this instance 
    5452  int mReferences; 
    5553 
    5654  ////////////////// 
    57   // note matt: delete these, they are only taking memory+ 
     55  // note matt: delete these, they are only taking memory 
    5856 
    5957 
     
    7775                }; 
    7876   
    79   Intersectable(): mMailbox(0), mReferences(0), mBvhLeaf(0) {} 
     77  Intersectable(): mMailbox(0), mReferences(0), mBvhLeaf(0), mVssRays(NULL) {} 
    8078 
    8179  virtual Intersectable::~Intersectable() {}; 
     
    114112 
    115113  virtual int GetRandomVisibleSurfacePoint(Vector3 &point, 
    116           Vector3 &normal, 
    117           const Vector3 &viewpoint, 
    118           const int maxTries) = 0; 
     114                                                                                   Vector3 &normal, 
     115                                                                                   const Vector3 &viewpoint, 
     116                                           const int maxTries) = 0; 
    119117 
    120118  virtual ostream &Describe(ostream &s) = 0; 
     
    160158  } 
    161159 
    162   /** returns normal from the face with the specified index. 
    163   PROBLEM: Does not fit to all intersectable types (e.g., spheres) 
     160  /** Returns normal from the face with the specified index. 
     161          PROBLEM: Does not fit to all intersectable types (e.g., spheres) 
    164162  */ 
    165163  virtual Vector3 GetNormal(const int idx) const { return Vector3(0, 0, 0); } 
     164 
     165  VssRayContainer *GetOrCreateRays()  
     166  {  
     167          if (!mVssRays) 
     168                mVssRays = new VssRayContainer(); 
     169          return mVssRays; 
     170  } 
     171 
     172  void DelRayRefs() 
     173  { 
     174          DEL_PTR(mVssRays); 
     175  } 
     176 
     177protected: 
     178 
     179  /// some rays piercing this intersectable 
     180  VssRayContainer *mVssRays; 
    166181}; 
    167182 
Note: See TracChangeset for help on using the changeset viewer.