Commit 12947cd1 authored by Brad King's avatar Brad King
Browse files

ENH: Three sweeping changes.

1.) vtkTypeRevisionMacro is now used in all VTK classes in place of
    vtkTypeMacro.  It invokes the original vtkTypeMacro and then adds
    a protected CollectRevisions method for future use in serialization.
    A corresponding vtkCxxRevisionMacro has been added to every .cxx file
    to implement the CollectRevisions method for each class.  This will
    allow collection of every class revision at run time.  Any new VTK class
    should use vtkTypeRevisionMacro instead of vtkTypeMacro.  The .cxx
    implementation should then have the following line:
      vtkCxxRevisionMacro(vtkFoo, "$Revision: 1.1 $");
    CVS should insert the correct revision number when the class is commited.

2.) vtkTypeMacro now also adds a typedef called "Superclass" to refer to
    the superclass of any VTK class.  All PrintSelf methods have been
    updated to call their superclass's PrintSelf like this:
      this->Superclass::PrintSelf(os,indent);
    This should reduce the number of places that refer to a superclass
    by its actual name.

3.) The standard ::New() method implementation has been replaced with a
    macro.  Instead of an explicitly written implementation to try the
    object factory and then call the new operator, VTK classes should
    instead use the following macro unless they have a special New() method:
      vtkStandardNewMacro(vtkFoo);
    This will implement the New() method in the standard way.  The line
    should appear in the .cxx implementation file, not in the header.
    Using the macro will make it easier to change the standard
    implementation of the method.

Also removed tabs from many files.
parent 316b9b16
......@@ -16,10 +16,13 @@ public:
{
}
vtkTypeMacro(vtkTestVertex,vtkVertex);
vtkTypeRevisionMacro(vtkTestVertex,vtkVertex);
static vtkTestVertex* New() { return new vtkTestVertex; }
vtkTestVertex() { }
};
vtkCxxRevisionMacro(vtkTestVertex, "1.13");
class vtkTestVertex2 : public vtkVertex
{
public:
......@@ -28,11 +31,13 @@ public:
}
// Methods from vtkObject
vtkTypeMacro(vtkTestVertex2,vtkVertex);
vtkTypeRevisionMacro(vtkTestVertex2,vtkVertex);
static vtkTestVertex2* New() { return new vtkTestVertex2; }
vtkTestVertex2() { }
};
vtkCxxRevisionMacro(vtkTestVertex2, "1.13");
VTK_CREATE_CREATE_FUNCTION(vtkTestVertex);
VTK_CREATE_CREATE_FUNCTION(vtkTestVertex2);
......
......@@ -69,9 +69,9 @@ void Test(ostream& strm)
polyVertex->CellBoundary (k, polyVertexCoords[j], ids);
strm << "vtkPolyVertex \t(" << polyVertexCoords[j][0] << ") \t= ";
for (i = 0; i < ids->GetNumberOfIds(); i++)
{
strm << ids->GetId(i) << ", ";
}
{
strm << ids->GetId(i) << ", ";
}
strm << endl;
}
}
......@@ -114,9 +114,9 @@ void Test(ostream& strm)
polyLine->CellBoundary (k, polyLineCoords[j], ids);
strm << "vtkPolyLine \t(" << polyLineCoords[j][0] << ") = \t";
for (i = 0; i < ids->GetNumberOfIds(); i++)
{
strm << ids->GetId(i) << ", ";
}
{
strm << ids->GetId(i) << ", ";
}
strm << endl;
}
}
......@@ -163,9 +163,9 @@ void Test(ostream& strm)
triangleStrip->CellBoundary (k, triangleStripCoords[j], ids);
strm << "vtkTriangleStrip \t(" << triangleStripCoords[j][0] << ", " << triangleStripCoords[j][1] << ") = \t";
for (i = 0; i < ids->GetNumberOfIds(); i++)
{
strm << ids->GetId(i) << ", ";
}
{
strm << ids->GetId(i) << ", ";
}
strm << endl;
}
}
......
......@@ -70,9 +70,9 @@ void Test(ostream& strm)
polyVertex->CellBoundary (k, polyVertexCoords[j], ids);
strm << "vtkPolyVertex \t(" << polyVertexCoords[j][0] << ") \t= ";
for (i = 0; i < ids->GetNumberOfIds(); i++)
{
strm << ids->GetId(i) << ", ";
}
{
strm << ids->GetId(i) << ", ";
}
strm << endl;
}
}
......@@ -115,9 +115,9 @@ void Test(ostream& strm)
polyLine->CellBoundary (k, polyLineCoords[j], ids);
strm << "vtkPolyLine \t(" << polyLineCoords[j][0] << ") = \t";
for (i = 0; i < ids->GetNumberOfIds(); i++)
{
strm << ids->GetId(i) << ", ";
}
{
strm << ids->GetId(i) << ", ";
}
strm << endl;
}
}
......@@ -164,9 +164,9 @@ void Test(ostream& strm)
triangleStrip->CellBoundary (k, triangleStripCoords[j], ids);
strm << "vtkTriangleStrip \t(" << triangleStripCoords[j][0] << ", " << triangleStripCoords[j][1] << ") = \t";
for (i = 0; i < ids->GetNumberOfIds(); i++)
{
strm << ids->GetId(i) << ", ";
}
{
strm << ids->GetId(i) << ", ";
}
strm << endl;
}
}
......
......@@ -324,8 +324,8 @@ void Test(ostream& strm)
vtkVoxel *voxel = vtkVoxel::New();
float voxelCoords[3], voxelWeights[8], voxelPosition[3];
float voxelPoint[9][3] = {{10, 10, 10}, {12, 10, 10}, {12, 12, 10}, {10, 12, 10},
{10, 10, 12}, {12, 10, 12}, {12, 12, 12}, {10, 12, 12},
{11, 11, 11}};
{10, 10, 12}, {12, 10, 12}, {12, 12, 12}, {10, 12, 12},
{11, 11, 11}};
float voxelClosest[3];
voxel->GetPointIds()->SetNumberOfIds(8);
......@@ -365,8 +365,8 @@ void Test(ostream& strm)
vtkHexahedron *hexahedron = vtkHexahedron::New();
float hexahedronCoords[3], hexahedronWeights[8], hexahedronPosition[3];
float hexahedronPoint[9][3] = {{10, 10, 10}, {12, 10, 10}, {12, 12, 10}, {10, 12, 10},
{10, 10, 12}, {12, 10, 12}, {12, 12, 12}, {10, 12, 12},
{11, 11, 11}};
{10, 10, 12}, {12, 10, 12}, {12, 12, 12}, {10, 12, 12},
{11, 11, 11}};
float hexahedronClosest[3];
hexahedron->GetPointIds()->SetNumberOfIds(8);
......
......@@ -83,12 +83,12 @@ void Test(ostream& strm)
for (j = 0; j < 20; j++)
{
for (i = 0; i < 20; i++)
{
shortScalars3D->InsertComponent(l,0,i);
shortScalars3D->InsertComponent(l,0,j);
shortScalars3D->InsertComponent(l,0,k);
l++;
}
{
shortScalars3D->InsertComponent(l,0,i);
shortScalars3D->InsertComponent(l,0,j);
shortScalars3D->InsertComponent(l,0,k);
l++;
}
}
}
......
......@@ -38,12 +38,12 @@ void Test(ostream& strm)
for (k = 0; k < 20; k++)
{
for (j = 0; j < 20; j++)
{
for (i = 0; i < 20; i++)
{
xyzpoints->InsertNextPoint((float) i, (float) j, (float) k);
}
}
{
for (i = 0; i < 20; i++)
{
xyzpoints->InsertNextPoint((float) i, (float) j, (float) k);
}
}
}
sg3D->SetDimensions(20,20,20);
sg3D->SetPoints(xyzpoints); xyzpoints->Delete();
......@@ -124,12 +124,12 @@ void Test(ostream& strm)
for (j = 0; j < 20; j++)
{
for (i = 0; i < 20; i++)
{
shortScalars3D->InsertComponent(l,0,i);
shortScalars3D->InsertComponent(l,0,j);
shortScalars3D->InsertComponent(l,0,k);
l++;
}
{
shortScalars3D->InsertComponent(l,0,i);
shortScalars3D->InsertComponent(l,0,j);
shortScalars3D->InsertComponent(l,0,k);
l++;
}
}
}
......
......@@ -17,7 +17,7 @@ struct vtkTestUtilities
// If slash is true, appends a slash to the resulting string.
// The returned string has to be deleted (with delete[]) by the user.
static char* ExpandDataFileName(int argc, char* argv[],
const char* fname,
const char* fname,
int slash = 0);
// Description:
// Function returning either a command line argument, an environment
......@@ -52,7 +52,7 @@ char* vtkTestUtilities::GetDataRoot(int argc, char* argv[])
}
char* vtkTestUtilities::ExpandDataFileName(int argc, char* argv[],
const char* fname,
const char* fname,
int slash)
{
return vtkTestUtilities::ExpandFileNameWithArgOrEnvOrDefault(
......
......@@ -44,6 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkObjectFactory.h"
#include "vtkPlanes.h"
vtkCxxRevisionMacro(vtkAbstractMapper, "1.22");
// Construct object.
vtkAbstractMapper::vtkAbstractMapper()
{
......@@ -122,7 +124,7 @@ void vtkAbstractMapper::SetClippingPlanes(vtkPlanes *planes)
vtkDataArray *vtkAbstractMapper::GetScalars(vtkDataSet *input,
int scalarMode,
int arrayAccessMode,
int arrayAccessMode,
int arrayId,
const char *arrayName,
int& offset)
......@@ -205,7 +207,7 @@ void vtkAbstractMapper::ShallowCopy(vtkAbstractMapper *mapper)
void vtkAbstractMapper::PrintSelf(ostream& os, vtkIndent indent)
{
this->vtkProcessObject::PrintSelf(os,indent);
this->Superclass::PrintSelf(os,indent);
os << indent << "TimeToDraw: " << this->TimeToDraw << "\n";
......
......@@ -73,7 +73,7 @@ class vtkDataSet;
class VTK_COMMON_EXPORT vtkAbstractMapper : public vtkProcessObject
{
public:
vtkTypeMacro(vtkAbstractMapper,vtkProcessObject);
vtkTypeRevisionMacro(vtkAbstractMapper,vtkProcessObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......
......@@ -46,6 +46,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkDebugLeaks.h"
#include "vtkCriticalSection.h"
vtkCxxRevisionMacro(vtkAbstractTransform, "1.20");
//----------------------------------------------------------------------------
vtkAbstractTransform::vtkAbstractTransform()
{
......@@ -76,7 +78,7 @@ vtkAbstractTransform::~vtkAbstractTransform()
//----------------------------------------------------------------------------
void vtkAbstractTransform::PrintSelf(ostream& os, vtkIndent indent)
{
vtkObject::PrintSelf(os, indent);
this->Superclass::PrintSelf(os, indent);
os << indent << "Inverse: (" << this->MyInverse << ")\n";
}
......@@ -388,7 +390,7 @@ void vtkAbstractTransform::UnRegister(vtkObject *o)
class vtkSimpleTransform : public vtkHomogeneousTransform
{
public:
vtkTypeMacro(vtkSimpleTransform,vtkHomogeneousTransform);
vtkTypeRevisionMacro(vtkSimpleTransform,vtkHomogeneousTransform);
static vtkSimpleTransform *New() {
#ifdef VTK_DEBUG_LEAKS
vtkDebugLeaks::ConstructClass("vtkSimpleTransform");
......@@ -402,6 +404,8 @@ protected:
void operator=(const vtkSimpleTransform&);
};
vtkCxxRevisionMacro(vtkSimpleTransform, "1.20");
//----------------------------------------------------------------------------
vtkTransformConcatenation::vtkTransformConcatenation()
{
......
......@@ -75,7 +75,7 @@ class VTK_COMMON_EXPORT vtkAbstractTransform : public vtkObject
{
public:
vtkTypeMacro(vtkAbstractTransform,vtkObject);
vtkTypeRevisionMacro(vtkAbstractTransform,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......
......@@ -45,19 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkPropCollection.h"
#include "vtkObjectFactory.h"
//-------------------------------------------------------------------------
vtkActor2D* vtkActor2D::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("vtkActor2D");
if(ret)
{
return (vtkActor2D*)ret;
}
// If the factory was unable to create the object, then create it here.
return new vtkActor2D;
}
vtkCxxRevisionMacro(vtkActor2D, "1.31");
vtkStandardNewMacro(vtkActor2D);
// Creates an actor2D with the following defaults:
// position -1, -1 (view coordinates)
......@@ -294,7 +283,7 @@ void vtkActor2D::ShallowCopy(vtkProp *prop)
void vtkActor2D::PrintSelf(ostream& os, vtkIndent indent)
{
this->vtkProp::PrintSelf(os,indent);
this->Superclass::PrintSelf(os,indent);
os << indent << "Layer Number: " << this->LayerNumber << "\n";
os << indent << "PositionCoordinate: " << this->PositionCoordinate << "\n";
......
......@@ -62,7 +62,7 @@ class VTK_COMMON_EXPORT vtkActor2D : public vtkProp
{
public:
void PrintSelf(ostream& os, vtkIndent indent);
vtkTypeMacro(vtkActor2D,vtkProp);
vtkTypeRevisionMacro(vtkActor2D,vtkProp);
// Description:
// Creates an actor2D with the following defaults:
......
......@@ -40,27 +40,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================*/
#include "vtkCollection.h"
#include "vtkActor2DCollection.h"
#include "vtkObjectFactory.h"
//------------------------------------------------------------------------------
vtkActor2DCollection* vtkActor2DCollection::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("vtkActor2DCollection");
if(ret)
{
return (vtkActor2DCollection*)ret;
}
// If the factory was unable to create the object, then create it here.
return new vtkActor2DCollection;
}
vtkCxxRevisionMacro(vtkActor2DCollection, "1.20");
vtkStandardNewMacro(vtkActor2DCollection);
// protected function to delete an element. Internal use only.
void vtkActor2DCollection::DeleteElement(vtkCollectionElement *e)
......
......@@ -64,7 +64,7 @@ class VTK_COMMON_EXPORT vtkActor2DCollection : public vtkPropCollection
// objects from the collection.
static vtkActor2DCollection *New();
vtkTypeMacro(vtkActor2DCollection,vtkPropCollection);
vtkTypeRevisionMacro(vtkActor2DCollection,vtkPropCollection);
// Description:
// Sorts the vtkActor2DCollection by layer number. Smaller layer
......
......@@ -44,18 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkMatrix4x4.h"
#include "vtkObjectFactory.h"
//-------------------------------------------------------------------------
vtkAssemblyNode* vtkAssemblyNode::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("vtkAssemblyNode");
if(ret)
{
return (vtkAssemblyNode*)ret;
}
// If the factory was unable to create the object, then create it here.
return new vtkAssemblyNode;
}
vtkCxxRevisionMacro(vtkAssemblyNode, "1.4");
vtkStandardNewMacro(vtkAssemblyNode);
vtkAssemblyNode::vtkAssemblyNode()
{
......@@ -121,7 +111,7 @@ unsigned long vtkAssemblyNode::GetMTime()
void vtkAssemblyNode::PrintSelf(ostream& os, vtkIndent indent)
{
vtkObject::PrintSelf(os,indent);
this->Superclass::PrintSelf(os,indent);
if ( this->Prop )
{
......
......@@ -80,7 +80,7 @@ public:
// Create an assembly node.
static vtkAssemblyNode *New();
vtkTypeMacro(vtkAssemblyNode,vtkObject);
vtkTypeRevisionMacro(vtkAssemblyNode,vtkObject);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......
......@@ -44,18 +44,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkTransform.h"
#include "vtkObjectFactory.h"
//-----------------------------------------------------------------------------
vtkAssemblyPath* vtkAssemblyPath::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("vtkAssemblyPath");
if(ret)
{
return (vtkAssemblyPath*)ret;
}
// If the factory was unable to create the object, then create it here.
return new vtkAssemblyPath;
}
vtkCxxRevisionMacro(vtkAssemblyPath, "1.4");
vtkStandardNewMacro(vtkAssemblyPath);
vtkAssemblyPath::vtkAssemblyPath()
{
......@@ -164,7 +154,7 @@ unsigned long vtkAssemblyPath::GetMTime()
void vtkAssemblyPath::PrintSelf(ostream& os, vtkIndent indent)
{
vtkCollection::PrintSelf(os,indent);
this->Superclass::PrintSelf(os,indent);
}
......@@ -64,7 +64,7 @@ class vtkProp;
class VTK_COMMON_EXPORT vtkAssemblyPath : public vtkCollection
{
public:
vtkTypeMacro(vtkAssemblyPath,vtkCollection);
vtkTypeRevisionMacro(vtkAssemblyPath,vtkCollection);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
......
......@@ -42,18 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkAssemblyPaths.h"
#include "vtkObjectFactory.h"
//----------------------------------------------------------------------------
vtkAssemblyPaths* vtkAssemblyPaths::New()
{
// First try to create the object from the vtkObjectFactory
vtkObject* ret = vtkObjectFactory::CreateInstance("vtkAssemblyPaths");
if(ret)
{
return (vtkAssemblyPaths*)ret;
}
// If the factory was unable to create the object, then create it here.
return new vtkAssemblyPaths;
}
vtkCxxRevisionMacro(vtkAssemblyPaths, "1.4");
vtkStandardNewMacro(vtkAssemblyPaths);
unsigned long vtkAssemblyPaths::GetMTime()
{
......
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