Commit 5ff1d205 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Changed memory model.

parent f6277674
......@@ -20,12 +20,11 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
// of the form: (n,id1,id2,...,idn, n,id1,id2,...,idn, ...)
// where n is the number of points in the cell, and id is a zero-offset index
// into an associated point list.
//
// Advantages of this data structure are its compactness, simplicity, and easy
// interface to external data. However, it is totally inadequate for random
// access. This functionality (when necessary) is accomplished by using the
// vlCellList and vlLinkList objects to extend the definition of data
// structure.
// Advantages of this data structure are its compactness, simplicity, and
// easy interface to external data. However, it is totally inadequate for
// random access. This functionality (when necessary) is accomplished by
// using the vlCellList and vlLinkList objects to extend the definition of
// data structure.
#ifndef __vlCellArray_h
#define __vlCellArray_h
......@@ -33,7 +32,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "IntArray.hh"
#include "Cell.hh"
class vlCellArray : public vlObject
class vlCellArray : public vlRefCount
{
public:
vlCellArray() : NumberOfCells(0), Location(0) {};
......
......@@ -23,14 +23,15 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlCellList_h
#define __vlCellList_h
#include "Object.hh"
#include "RefCount.hh"
struct vlCell_s {
unsigned char type; //from CellTypes.hh
int loc; //location in associated CellArray object
};
class vlCellList : public vlObject {
class vlCellList : public vlRefCount
{
public:
vlCellList() : Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
vlCellList(const int sz, const int ext);
......
......@@ -13,7 +13,7 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME vlLinkList - object represents upward pointers from point list to cell list
// .NAME vlLinkList - object represents upward pointers from points to list of cells using each point
// .SECTION Description
// vlLinkList is a supplemental object to CellArray and CellList to allow
// access from points to cells using the points. LinkList is a collection
......@@ -24,7 +24,7 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlLinkList_h
#define __vlLinkList_h
#include "Object.hh"
#include "RefCount.hh"
class vlDataSet;
struct vlLink {
......@@ -32,7 +32,8 @@ struct vlLink {
int *cells;
};
class vlLinkList : public vlObject {
class vlLinkList : public vlRefCount
{
public:
vlLinkList():Array(NULL),Size(0),MaxId(-1),Extend(1000) {};
vlLinkList(int sz, int ext=1000);
......
......@@ -43,7 +43,7 @@ public:
// Description:
// Set list of points to insert into locator.
vlSetObjectMacro(Points,vlPoints);
vlSetRefCountedObjectMacro(Points,vlPoints);
vlGetObjectMacro(Points,vlPoints);
// Description:
......
......@@ -24,12 +24,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlNormals_h
#define __vlNormals_h
#include "Object.hh"
#include "RefCount.hh"
class vlIdList;
class vlFloatNormals;
class vlNormals : public vlObject
class vlNormals : public vlRefCount
{
public:
vlNormals() {};
......@@ -50,16 +50,16 @@ public:
virtual float *GetNormal(int i) = 0;
// Description:
// Insert vector into object. No range checking performed (fast!).
// Insert normal into object. No range checking performed (fast!).
virtual void SetNormal(int i,float n[3]) = 0;
// Description:
// Insert vector into object. Range checking performed and memory
// Insert normal into object. Range checking performed and memory
// allocated as necessary.
virtual void InsertNormal(int i, float n[3]) = 0;
// Description:
// Insert vector into next available slot. Returns point id of slot.
// Insert normal into next available slot. Returns point id of slot.
virtual int InsertNextNormal(float n[3]) = 0;
// Description:
......
......@@ -16,8 +16,8 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
// .NAME vlObject - abstract base class for visualization library
// .SECTION Description
// vlObject is the base class for many objects in the visualization
// library. vlObject provides methods for reference counting, tracking
// modification time, debugging, and printing.
// library. vlObject provides methods for tracking modification time,
// debugging, and printing.
#ifndef __vlObject_hh
#define __vlObject_hh
......@@ -35,11 +35,6 @@ public:
virtual ~vlObject();
virtual char *GetClassName() {return "vlObject";};
// reference counting
void Register(vlObject* o);
void UnRegister(vlObject* o);
int GetRefCount() {return this->RefCount;};
// debugging
void DebugOn();
void DebugOff();
......@@ -63,7 +58,6 @@ protected:
vlTimeStamp MTime; // Keep track of modification time
private:
int RefCount; // Number of uses of this object by other objects
vlPrintList PrintList;
friend ostream& operator<<(ostream& os, vlObject& o);
......
......@@ -51,7 +51,7 @@ public:
// Description:
// Specify point array to define point coordinates.
vlSetObjectMacro(Points,vlPoints);
vlSetRefCountedObjectMacro(Points,vlPoints);
vlGetObjectMacro(Points,vlPoints);
protected:
......
......@@ -23,12 +23,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlPoints_h
#define __vlPoints_h
#include "Object.hh"
#include "RefCount.hh"
class vlFloatPoints;
class vlIdList;
class vlPoints : public vlObject
class vlPoints : public vlRefCount
{
public:
vlPoints();
......
......@@ -61,22 +61,22 @@ public:
// Description:
// Set the scalar data.
vlSetObjectMacro (Scalars, vlScalars);
vlSetRefCountedObjectMacro (Scalars, vlScalars);
vlGetObjectMacro (Scalars, vlScalars);
// Description:
// Set the vector data.
vlSetObjectMacro (Vectors, vlVectors);
vlSetRefCountedObjectMacro (Vectors, vlVectors);
vlGetObjectMacro (Vectors, vlVectors);
// Description:
// Set the normal data.
vlSetObjectMacro (Normals, vlNormals);
vlSetRefCountedObjectMacro (Normals, vlNormals);
vlGetObjectMacro (Normals, vlNormals);
// Description:
// Set the texture coordinate data.
vlSetObjectMacro (TCoords, vlTCoords);
vlSetRefCountedObjectMacro (TCoords, vlTCoords);
vlGetObjectMacro (TCoords, vlTCoords);
// Description:
......
......@@ -23,12 +23,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlScalars_h
#define __vlScalars_h
#include "Object.hh"
#include "RefCount.hh"
class vlIdList;
class vlFloatScalars;
class vlScalars : public vlObject
class vlScalars : public vlRefCount
{
public:
vlScalars();
......
......@@ -13,17 +13,13 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
// .NAME SetGet Macros - standard macros for setting/getting instance
// variable values
// .NAME SetGet Macros - standard macros for setting/getting instance variables
// .SECTION Description
// The SetGet macros are used to interface to instance variables
// in a standard fashion. This includes properly treating modified time,
// registering/unregistering object use, and printing out debug
// information.
//
// Macros are available for built-in types; for character strings;
// vector arrays of built-in types size 2,3,4; and for setting
// objects (i.e., Registering objects).
// in a standard fashion. This includes properly treating modified time
// and printing out debug information.
// Macros are available for built-in types; for character strings;
// vector arrays of built-in types size 2,3,4; and for setting objects.
#ifndef __vlSetGet_hh
#define __vlSetGet_hh
......@@ -109,10 +105,28 @@ void Set##name (type _arg) \
}
//
// Set pointer to object; uses vlObject reference counting methodology.
// Creates method Set"name"() (e.g., SetPoints()).
// Set pointer to object. Creates method Set"name"() (e.g., SetPoints()).
//
#define vlSetObjectMacro(name,type) \
void Set##name (type* _arg) \
{ \
if (Debug) cerr << "In " __FILE__ << ", line " << __LINE__ << "\n" << this->GetClassName() << " (" << this << "): setting " << #name " to " << &_arg << "\n\n"; \
if (name != _arg) \
{ \
name = _arg; \
this->Modified(); \
} \
} \
void Set##name (type& _arg) \
{ \
Set##name (&_arg);\
}
//
// Set pointer to object; uses vlRefCount reference counting methodology.
// Creates method Set"name"() (e.g., SetPoints()).
//
#define vlSetRefCountedObjectMacro(name,type) \
void Set##name (type* _arg) \
{ \
if (Debug) cerr << "In " __FILE__ << ", line " << __LINE__ << "\n" << this->GetClassName() << " (" << this << "): setting " << #name " to " << &_arg << "\n\n"; \
......
......@@ -71,6 +71,8 @@ protected:
vlBitArray *PointVisibility;
};
// Description:
// Return non-zero value if specified point is visible.
inline int vlStructuredDataSet::IsPointVisible(int ptId)
{
if (!this->Blanking) return 1;
......
......@@ -25,12 +25,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlTCoords_h
#define __vlTCoords_h
#include "Object.hh"
#include "RefCount.hh"
class vlIdList;
class vlFloatTCoords;
class vlTCoords : public vlObject
class vlTCoords : public vlRefCount
{
public:
vlTCoords(int dim=2);
......
......@@ -23,12 +23,12 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlVectors_h
#define __vlVectors_h
#include "Object.hh"
#include "RefCount.hh"
class vlIdList;
class vlFloatVectors;
class vlVectors : public vlObject
class vlVectors : public vlRefCount
{
public:
vlVectors();
......
......@@ -6,8 +6,6 @@
Date: $Date$
Version: $Revision$
Description:
---------------------------------------------------------------------------
This file is part of the Visualization Library. No part of this file
or its contents may be copied, reproduced or altered in any way
without the express written consent of the authors.
......
......@@ -13,7 +13,6 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
#include <iostream.h>
#include "CellList.hh"
vlCellList::vlCellList(const int sz, const int ext)
......
......@@ -25,10 +25,6 @@ vlDataSetFilter::vlDataSetFilter()
vlDataSetFilter::~vlDataSetFilter()
{
if ( this->Input != NULL )
{
this->Input->UnRegister(this);
}
}
void vlDataSetFilter::Update()
......
......@@ -29,7 +29,7 @@ void vlNormals::GetNormals(vlIdList& ptId, vlFloatNormals& fp)
void vlNormals::PrintSelf(ostream& os, vlIndent indent)
{
vlObject::PrintSelf(os,indent);
vlRefCount::PrintSelf(os,indent);
os << indent << "Number Of Normals: " << this->GetNumberOfNormals() << "\n";
}
......@@ -26,39 +26,15 @@ ostream& operator<<(ostream& os, vlObject& o)
vlObject::vlObject()
{
this->RefCount = 0;
this->Debug = 0;
this->Modified(); // Insures modified time > than any other time
}
vlObject::~vlObject()
{
if (this->RefCount > 0)
{
vlErrorMacro(<< "Trying to delete object with non-zero refCount");
}
vlDebugMacro(<< "Destructing!");
}
// Description:
// Increase the reference count (mark as used by another object).
void vlObject::Register(vlObject* o)
{
this->RefCount++;
vlDebugMacro(<< "Registered by " << o->GetClassName() << " (" << o << ")");
}
// Description:
// Decrease the reference count (release by another object).
void vlObject::UnRegister(vlObject* o)
{
vlDebugMacro(<< "UnRegistered by " << o->GetClassName() << " (" << 0 << ")");
if (--this->RefCount <= 0) delete this;
}
// Description:
// Return the modification for this object.
unsigned long int vlObject::GetMTime()
......@@ -89,7 +65,6 @@ void vlObject::PrintSelf(ostream& os, vlIndent indent)
{
os << indent << "Debug: " << (this->Debug ? "On\n" : "Off\n");
os << indent << "Modified Time: " << this->GetMTime() << "\n";
os << indent << "Reference Count: " << this->RefCount << "\n";
}
}
......
......@@ -28,7 +28,6 @@ vlDataSet(ps)
if (this->Points) this->Points->Register(this);
this->Locator = ps.Locator;
if (this->Locator) this->Locator->Register(this);
}
void vlPointSet::Initialize()
......@@ -43,8 +42,7 @@ void vlPointSet::Initialize()
if ( this->Locator )
{
this->Locator->UnRegister(this);
this->Locator = NULL;
this->Locator->Initialize();
}
}
void vlPointSet::ComputeBounds()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment