Commit bd37b686 authored by Ken Martin's avatar Ken Martin
Browse files

checkin of new render arch and New methods

parent 34c20ec1
......@@ -55,6 +55,7 @@ class VTK_EXPORT vtkByteSwap
{
public:
void Delete() {delete this;};
static vtkByteSwap *New() {return new vtkByteSwap;};
static void Swap2LE(short *s);
static void Swap4LE(char *c);
......
......@@ -55,6 +55,8 @@ class VTK_EXPORT vtkImplicitFunctionCollection : public vtkCollection
{
public:
char *GetClassName() {return "vtkImplicitFunctionCollection";};
static vtkImplicitFunctionCollection *New()
{return new vtkImplicitFunctionCollection;};
void AddItem(vtkImplicitFunction *);
void RemoveItem(vtkImplicitFunction *);
......
......@@ -55,6 +55,7 @@ class VTK_EXPORT vtkIndent
{
public:
vtkIndent(int ind=0) {this->Indent=ind;};
static vtkIndent *New() {return new vtkIndent;};
vtkIndent GetNextIndent();
int Indent;
......
......@@ -56,7 +56,9 @@ class VTK_EXPORT vtkMath
{
public:
vtkMath() {};
static vtkMath *New() {return new vtkMath;};
virtual char *GetClassName() {return "vtkMath";};
// constants
static float Pi() {return 3.14159265358979;};
static float DegreesToRadians() {return 0.017453292;};
......
......@@ -74,6 +74,9 @@ public:
vtkPriorityQueue();
vtkPriorityQueue(const int sz, const int ext=1000);
~vtkPriorityQueue();
static vtkPriorityQueue *New() {return new vtkPriorityQueue;};
char *GetClassName() {return "vtkPriorityQueue";};
void PrintSelf(ostream& os, vtkIndent indent);
int Pop(float &priority, int location=0);
......
......@@ -57,7 +57,8 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
class VTK_EXPORT vtkTensor
{
public:
vtkTensor(int dim=3);
inline vtkTensor(int dim=3);
static vtkTensor *New() {return new vtkTensor;};
void Initialize();
float GetComponent(int i, int j);
void SetComponent(int i, int j, float v);
......
......@@ -55,6 +55,8 @@ class VTK_EXPORT vtkTimeStamp
{
public:
vtkTimeStamp() {this->ModifiedTime = 0;};
virtual char *GetClassName() {return "vtkTimeStamp";};
static vtkTimeStamp *New() {return new vtkTimeStamp;};
// Description:
// Set this objects time to the current time. The current time is
......
......@@ -55,6 +55,7 @@ class VTK_EXPORT vtkTransformCollection : public vtkCollection
{
public:
char *GetClassName() {return "vtkTransformCollection";};
static vtkTransformCollection *New() {return new vtkTransformCollection;};
void AddItem(vtkTransform *);
void RemoveItem(vtkTransform *);
......
......@@ -49,12 +49,7 @@ vtkXglrRenderer \
vtkXglrTexture
ABSTRACT_H = \
vtkActorDevice \
vtkCameraDevice \
vtkLightDevice \
vtkPropertyDevice \
vtkRayBounder \
vtkTextureDevice
vtkRayBounder
CONCRETE_H = \
vtkActorCollection \
......@@ -70,7 +65,6 @@ ABSTRACT = \
vtkDataWriter \
vtkExporter \
vtkMapper \
vtkPolyMapperDevice \
vtkProp \
vtkVolumeMapper \
vtkVolumeReader \
......
......@@ -2,15 +2,14 @@ catch {load vtktcl}
# this is a tcl version of the Mace example
# get the interactor ui
source vtkInt.tcl
# First create the render master
#
vtkRenderMaster rm
# Now create the RenderWindow, Renderer and both Actors
#
set renWin [rm MakeRenderWindow]
set ren1 [$renWin MakeRenderer]
set iren [$renWin MakeRenderWindowInteractor]
vtkRenderWindow renWin
vtkRenderer ren1
renWin AddRenderers ren1
vtkRenderWindowInteractor iren
iren SetRenderWindow renWin
# create a sphere source and actor
#
......@@ -36,17 +35,17 @@ vtkLODActor spikeActor
# Add the actors to the renderer, set the background and size
#
$ren1 AddActors sphereActor
$ren1 AddActors spikeActor
$ren1 SetBackground 0.1 0.2 0.4
$renWin SetSize 300 300
ren1 AddActors sphereActor
ren1 AddActors spikeActor
ren1 SetBackground 0.1 0.2 0.4
renWin SetSize 300 300
# render the image
#
$iren SetUserMethod {wm deiconify .vtkInteract}
set cam1 [$ren1 GetActiveCamera]
iren SetUserMethod {wm deiconify .vtkInteract}
set cam1 [ren1 GetActiveCamera]
$cam1 Zoom 1.4
$iren Initialize
iren Initialize
#$renWin SetFileName "mace.tcl.ppm"
#$renWin SaveImageAsPPM
......
......@@ -15,6 +15,12 @@ if {[set pos [lsearch $files "vtkInt.tcl"]] != -1} {
if {[set pos [lsearch $files "vtkInclude.tcl"]] != -1} {
set files [lreplace $files $pos $pos ]
}
if {[set pos [lsearch $files "TkInteractor.tcl"]] != -1} {
set files [lreplace $files $pos $pos ]
}
if {[set pos [lsearch $files "TkRenderWidget.tcl"]] != -1} {
set files [lreplace $files $pos $pos ]
}
if {[set pos [lsearch $files "colors.tcl"]] != -1} {
set files [lreplace $files $pos $pos ]
}
......
......@@ -42,7 +42,6 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <math.h>
#include "vtkActor.h"
#include "vtkActorDevice.h"
#include "vtkRenderWindow.h"
// Description:
......@@ -61,8 +60,6 @@ vtkActor::vtkActor()
this->Scale[2] = 1.0;
this->SelfCreatedProperty = 0;
this->Device = NULL;
this->TraversalLocation = 0;
}
......@@ -71,10 +68,6 @@ vtkActor::~vtkActor()
if ( this->SelfCreatedProperty && this->Property != NULL)
this->Property->Delete();
if (this->Device)
{
this->Device->Delete();
}
}
// Description:
......@@ -98,6 +91,46 @@ vtkActor& vtkActor::operator=(const vtkActor& actor)
return *this;
}
#ifdef USE_GLR
#include "vtkGlrActor.h"
#endif
#ifdef USE_OGLR
#include "vtkOglrActor.h"
#endif
#ifdef USE_SBR
#include "vtkSbrActor.h"
#endif
#ifdef USE_XGLR
#include "vtkXglrActor.h"
#endif
#ifdef _WIN32
#include "vtkOglrActor.h"
#endif
// return the correct type of Actor
vtkActor *vtkActor::New()
{
char *temp = vtkRenderWindow::GetRenderLibrary();
#ifdef USE_SBR
if (!strncmp("sbr",temp,4)) return vtkSbrActor::New();
#endif
#ifdef USE_GLR
if (!strncmp("glr",temp,3)) return vtkGlrActor::New();
#endif
#ifdef USE_OGLR
if (!strncmp("oglr",temp,4)) return vtkOglrActor::New();
#endif
#ifdef _WIN32
if (!strncmp("woglr",temp,5)) return vtkOglrActor::New();
#endif
#ifdef USE_XGLR
if (!strncmp("xglr",temp,4)) return vtkXglrActor::New();
#endif
return new vtkActor;
}
// Description:
// This causes the actor to be rendered. It in turn will render the actor's
// property, texture map and then mapper. If a property hasn't been
......@@ -113,17 +146,12 @@ void vtkActor::Render(vtkRenderer *ren)
// force creation of a property
this->GetProperty();
}
this->Property->Render(ren, this);
this->Property->Render(this, ren);
// render the texture */
if (this->Texture) this->Texture->Render(ren);
if (!this->Device)
{
this->Device = ren->GetRenderWindow()->MakeActor();
}
this->Device->Render(this,ren,this->Mapper);
this->Render(ren,this->Mapper);
}
void vtkActor::SetProperty(vtkProperty *lut)
......@@ -141,7 +169,7 @@ vtkProperty *vtkActor::GetProperty()
{
if ( this->Property == NULL )
{
this->Property = new vtkProperty;
this->Property = vtkProperty::New();
this->SelfCreatedProperty = 1;
}
return this->Property;
......@@ -303,7 +331,7 @@ void vtkActor::Update()
void vtkActor::BuildPaths(vtkAssemblyPaths *vtkNotUsed(paths),
vtkActorCollection *path)
{
vtkActor *copy=new vtkActor;
vtkActor *copy= vtkActor::New();
vtkActor *previous;
*copy = *this;
......
......@@ -65,8 +65,6 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkAssemblyPaths.h"
class vtkRenderer;
class vtkActorDevice;
class vtkProperty;
class vtkMapper;
class VTK_EXPORT vtkActor : public vtkProp
......@@ -74,11 +72,12 @@ class VTK_EXPORT vtkActor : public vtkProp
public:
vtkActor();
~vtkActor();
static vtkActor *New() {return new vtkActor;};
static vtkActor *New();
char *GetClassName() {return "vtkActor";};
void PrintSelf(ostream& os, vtkIndent indent);
virtual void Render(vtkRenderer *ren);
virtual void Render(vtkRenderer *, vtkMapper *) {};
vtkActor &operator=(const vtkActor& actor);
......@@ -163,7 +162,6 @@ protected:
vtkMapper *Mapper;
float Scale[3];
int SelfCreatedProperty;
vtkActorDevice *Device;
// this stuff supports multiple-part actors (e.g. assemblies)
int TraversalLocation;
......
......@@ -43,7 +43,6 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkMath.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkCameraDevice.h"
#include "vtkTimeStamp.h"
// Description:
......@@ -89,37 +88,47 @@ vtkCamera::vtkCamera()
this->WindowCenter[1] = 0.0;
this->FocalDisk = 1.0;
this->Device = NULL;
this->Stereo = 0;
this->VPN_dot_DOP = 0.0;
}
vtkCamera::~vtkCamera()
#ifdef USE_GLR
#include "vtkGlrCamera.h"
#endif
#ifdef USE_OGLR
#include "vtkOglrCamera.h"
#endif
#ifdef USE_SBR
#include "vtkSbrCamera.h"
#endif
#ifdef USE_XGLR
#include "vtkXglrCamera.h"
#endif
#ifdef _WIN32
#include "vtkOglrCamera.h"
#endif
// return the correct type of Camera
vtkCamera *vtkCamera::New()
{
if (this->Device)
{
this->Device->Delete();
}
}
void vtkCamera::Render(vtkRenderer *ren)
{
if (!this->Device)
{
this->Device = ren->GetRenderWindow()->MakeCamera();
}
// find out if we should stereo render
this->Stereo = (ren->GetRenderWindow())->GetStereoRender();
this->Device->Render(this,ren);
// if we have a stereo renderer, draw other eye next time
if (this->Stereo)
{
if (this->LeftEye) this->LeftEye = 0;
else this->LeftEye = 1;
}
char *temp = vtkRenderWindow::GetRenderLibrary();
#ifdef USE_SBR
if (!strncmp("sbr",temp,4)) return vtkSbrCamera::New();
#endif
#ifdef USE_GLR
if (!strncmp("glr",temp,3)) return vtkGlrCamera::New();
#endif
#ifdef USE_OGLR
if (!strncmp("oglr",temp,4)) return vtkOglrCamera::New();
#endif
#ifdef _WIN32
if (!strncmp("woglr",temp,5)) return vtkOglrCamera::New();
#endif
#ifdef USE_XGLR
if (!strncmp("xglr",temp,4)) return vtkXglrCamera::New();
#endif
return new vtkCamera;
}
void vtkCamera::SetPosition(float X, float Y, float Z)
......
......@@ -47,9 +47,6 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
// model including view up vector, clipping planes, and
// camera perspective.
// .SECTION see also
// vtkCameraDevice
#ifndef __vtkCamera_h
#define __vtkCamera_h
......@@ -57,15 +54,13 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include "vtkTransform.h"
class vtkRenderer;
class vtkCameraDevice;
class VTK_EXPORT vtkCamera : public vtkObject
{
public:
vtkCamera();
~vtkCamera();
void PrintSelf(ostream& os, vtkIndent indent);
static vtkCamera *New() {return new vtkCamera;};
static vtkCamera *New();
char *GetClassName() {return "vtkCamera";};
// Description:
......@@ -100,9 +95,9 @@ class VTK_EXPORT vtkCamera : public vtkObject
// Description:
// This method causes the camera to set up whatever is required for
// viewing the scene. This is actually handled by an instance of
// vtkCameraDevice, which is created automatically.
virtual void Render(vtkRenderer *ren);
// viewing the scene. This is actually handled by an subclass of
// vtkCamera, which is created through New()
virtual void Render(vtkRenderer *) {};
// Description:
// Set/Get the camera view angle (i.e., the width of view in degrees).
......@@ -228,7 +223,6 @@ class VTK_EXPORT vtkCamera : public vtkObject
// rays must be updated.
float VPN_dot_DOP;
vtkCameraDevice *Device;
};
inline void vtkCamera::SetWindowCenter( float x, float y )
......
......@@ -102,7 +102,7 @@ void vtkDataSetMapper::Render(vtkRenderer *ren, vtkActor *act)
if ( this->PolyMapper == NULL )
{
vtkGeometryFilter *gf = new vtkGeometryFilter();
vtkPolyMapper *pm = new vtkPolyMapper;
vtkPolyMapper *pm = vtkPolyMapper::New();
pm->SetInput(gf->GetOutput());
this->GeometryExtractor = gf;
......
......@@ -41,16 +41,15 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#include <math.h>
#include "vtkGlrRenderer.h"
#include "vtkGlrActor.h"
#include "vtkActor.h"
// Description:
// Implement base class method.
void vtkGlrActor::Render(vtkActor *actor, vtkRenderer *ren, vtkMapper *mapper)
void vtkGlrActor::Render(vtkRenderer *ren, vtkMapper *mapper)
{
static vtkMatrix4x4 matrix;
// build transformation
actor->GetMatrix(matrix);
this->GetMatrix(matrix);
matrix.Transpose();
// insert model transformation
......@@ -58,7 +57,7 @@ void vtkGlrActor::Render(vtkActor *actor, vtkRenderer *ren, vtkMapper *mapper)
multmatrix((float (*)[4])(matrix[0]));
// send a render to the mapper; update pipeline
mapper->Render(ren,actor);
mapper->Render(ren,this);
// pop transformation matrix
popmatrix();
......
......@@ -46,11 +46,11 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#ifndef __vtkGlrActor_h
#define __vtkGlrActor_h
#include "vtkActorDevice.h"
#include "vtkActor.h"
class vtkGlrRenderer;
class VTK_EXPORT vtkGlrActor : public vtkActorDevice
class VTK_EXPORT vtkGlrActor : public vtkActor
{
protected:
......@@ -58,7 +58,7 @@ public:
static vtkGlrActor *New() {return new vtkGlrActor;};
char *GetClassName() {return "vtkGlrActor";};
void Render(vtkActor *a, vtkRenderer *ren, vtkMapper *mapper);
void Render(vtkRenderer *ren, vtkMapper *mapper);
};
#endif
......
......@@ -45,14 +45,7 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
// Description:
// Implement base class method.
void vtkGlrCamera::Render(vtkCamera *cam, vtkRenderer *ren)
{
this->Render(cam, (vtkGlrRenderer *)ren);
}
// Description:
// Actual camera render method.
void vtkGlrCamera::Render(vtkCamera *cam, vtkGlrRenderer *ren)
void vtkGlrCamera::Render(vtkRenderer *ren)
{
float aspect[3];
float *vport;
......@@ -60,14 +53,13 @@ void vtkGlrCamera::Render(vtkCamera *cam, vtkGlrRenderer *ren)
long width,height;
long clr;
int left,right,bottom,top;
int stereo;
vtkMatrix4x4 matrix;
// get the bounds of the window
getsize(&width,&height);
// find out if we should stereo render
stereo = ((vtkGlrRenderWindow*)(ren->GetRenderWindow()))->GetStereoRender();
this->Stereo = ((vtkGlrRenderWindow*)(ren->GetRenderWindow()))->GetStereoRender();
// must use width -1 and height -1 because width*1.0 = width,
// but the maximum pixel value allowed is width -1
......@@ -79,12 +71,12 @@ void vtkGlrCamera::Render(vtkCamera *cam, vtkGlrRenderer *ren)
right = (int)(vport[2]*width);
// if were on a stereo renderer draw to special parts of screen
if (stereo)
if (this->Stereo)
{
switch ((ren->GetRenderWindow())->GetStereoType())
{
case VTK_STEREO_CRYSTAL_EYES:
if (cam->GetLeftEye())
if (this->LeftEye)
{
bottom = (int)(532 + (1023-532)*vport[1]);
top = (int)(532 + (1023-532)*vport[3]);
......@@ -109,7 +101,7 @@ void vtkGlrCamera::Render(vtkCamera *cam, vtkGlrRenderer *ren)
viewport(left,right,bottom,top);
/* for stereo we have to fiddle with aspect */
if (stereo)
if (this->Stereo)
{
switch ((ren->GetRenderWindow())->GetStereoType())
{
......@@ -131,7 +123,7 @@ void vtkGlrCamera::Render(vtkCamera *cam, vtkGlrRenderer *ren)
ren->SetAspect(aspect);
mmode(MPROJECTION);
matrix = cam->GetPerspectiveTransform(aspect[0]/aspect[1],-1,1);
matrix = this->GetPerspectiveTransform(aspect[0]/aspect[1],-1,1);
matrix.Transpose();
// insert camera view transformation
loadmatrix((const float (*)[4])(matrix[0]));
......@@ -141,7 +133,7 @@ void vtkGlrCamera::Render(vtkCamera *cam, vtkGlrRenderer *ren)
// render action after the actors! message sis sent
mmode(MVIEWING);
pushmatrix();
matrix = cam->GetViewTransform();
matrix = this->GetViewTransform();
matrix.Transpose();
// insert camera view transformation
......@@ -161,4 +153,11 @@ void vtkGlrCamera::Render(vtkCamera *cam, vtkGlrRenderer *ren)
czclear(clr, getgdesc(GD_ZMAX));
vtkDebugMacro(<< "czclear: " << clr << "\n");
}
// if we have a stereo renderer, draw other eye next time
if (this->Stereo)
{
if (this->LeftEye) this->LeftEye = 0;
else this->LeftEye = 1;
}
}
......@@ -46,18 +46,17 @@ MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
#ifndef __vtkGlrCamera_h
#define __vtkGlrCamera_h
#include "vtkCameraDevice.h"
#include "vtkCamera.h"
class vtkGlrRenderer;
class VTK_EXPORT vtkGlrCamera : public vtkCameraDevice
class VTK_EXPORT vtkGlrCamera : public vtkCamera
{
public:
static vtkGlrCamera *New() {return new vtkGlrCamera;};
char *GetClassName() {return "vtkGlrCamera";};
void Render(vtkCamera *cam, vtkRenderer *ren);
void Render(vtkCamera *cam, vtkGlrRenderer *ren);
void Render(vtkRenderer *ren);
};
......
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