Commit 53320c25 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Changed memory model.

parent ef9c4593
......@@ -43,6 +43,7 @@ public:
// Description:
// Specify the input data to map.
virtual void SetInput(vlDataSet *in);
void SetInput(vlDataSet& in) {this->SetInput(&in);};
virtual vlDataSet* GetInput();
protected:
......
......@@ -50,16 +50,13 @@ public:
// as each frame is rendered.
virtual void Render(vlRenderer *) = 0;
// Description:
// Return bounding box of data in terms of (xmin,xmax, ymin,ymax, zmin,zmax).
// Used in the rendering process to automatically create a camera in the
// proper initial configuration.
virtual float *GetBounds() = 0;
void SetLookupTable(vlLookupTable *lut);
vlGetObjectMacro(LookupTable,vlLookupTable);
// Description:
// Specify a lookup table for the mapper to use.
vlSetObjectMacro(LookupTable,vlLookupTable);
vlGetObjectMacro(LookupTable,vlLookupTable);
// Create default lookup table. Generally used to create one when none
// is available.
virtual void CreateDefaultLookupTable();
// Description:
// Turn on/off flag to control whether scalar data is used to color objects.
......@@ -73,6 +70,12 @@ public:
vlSetVector2Macro(ScalarRange,float)
vlGetVectorMacro(ScalarRange,float)
// Description:
// Return bounding box of data in terms of (xmin,xmax, ymin,ymax, zmin,zmax).
// Used in the rendering process to automatically create a camera in the
// proper initial configuration.
virtual float *GetBounds() = 0;
protected:
void (*StartRender)(void *);
void *StartRenderArg;
......@@ -82,6 +85,7 @@ protected:
int ScalarsVisible;
vlTimeStamp BuildTime;
float ScalarRange[2];
int SelfCreatedLookupTable;
};
......
......@@ -40,6 +40,7 @@ public:
// Description:
// Specify the input data to map.
virtual void SetInput(vlPolyData *in);
void SetInput(vlPolyData& in) {this->SetInput(&in);};
virtual vlPolyData* GetInput();
// Description:
......@@ -72,10 +73,14 @@ protected:
vlGeometryPrimitive *Lines;
vlGeometryPrimitive *Polys;
vlGeometryPrimitive *Strips;
vlRGBArray *Colors;
int VertsVisibility;
int LinesVisibility;
int PolysVisibility;
int StripsVisibility;
};
#endif
......
......@@ -55,7 +55,6 @@ vlActor::vlActor()
vlActor::~vlActor()
{
if ( this->Mapper ) this->Mapper->UnRegister(this);
}
// Description:
......
......@@ -13,9 +13,6 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Methods to map abstract DataSet through concrete mappers.
//
#include "DSMapper.hh"
#include "PolyMap.hh"
......@@ -28,20 +25,9 @@ vlDataSetMapper::vlDataSetMapper()
vlDataSetMapper::~vlDataSetMapper()
{
if ( this->Input )
{
this->Input->UnRegister(this);
}
if ( this->GeometryExtractor )
{
this->GeometryExtractor->UnRegister(this);
}
if ( this->PolyMapper )
{
this->PolyMapper->UnRegister(this);
}
// delete internally created objects.
if ( this->GeometryExtractor ) delete this->GeometryExtractor;
if ( this->PolyMapper ) this->PolyMapper;
}
void vlDataSetMapper::SetInput(vlDataSet *in)
......@@ -49,7 +35,6 @@ void vlDataSetMapper::SetInput(vlDataSet *in)
if (in != this->Input )
{
this->Input = in;
this->Input->Register(this);
this->Modified();
}
}
......@@ -89,7 +74,7 @@ void vlDataSetMapper::Render(vlRenderer *ren)
//
// Need a lookup table
//
if ( ! this->LookupTable ) this->SetLookupTable(new vlLookupTable);
if ( this->LookupTable == NULL ) this->CreateDefaultLookupTable();
this->LookupTable->Build();
//
// Now can create appropriate mapper
......@@ -101,10 +86,7 @@ void vlDataSetMapper::Render(vlRenderer *ren)
pm->SetInput(gf);
this->GeometryExtractor = gf;
this->GeometryExtractor->Register(this);
this->PolyMapper = pm;
this->PolyMapper->Register(this);
}
// update ourselves in case something has changed
......@@ -114,7 +96,6 @@ void vlDataSetMapper::Render(vlRenderer *ren)
this->GeometryExtractor->SetInput(this->Input);
this->PolyMapper->Render(ren);
}
void vlDataSetMapper::PrintSelf(ostream& os, vlIndent indent)
......
......@@ -28,14 +28,14 @@ vlMapper::vlMapper()
this->ScalarsVisible = 1;
this->ScalarRange[0] = 0.0; this->ScalarRange[1] = 1.0;
this->SelfCreatedLookupTable = 0;
}
vlMapper::~vlMapper()
{
if (this->LookupTable)
{
this->LookupTable->UnRegister(this);
}
if ( this->SelfCreatedLookupTable && this->LookupTable != NULL)
delete this->LookupTable;
}
// Description:
......@@ -92,6 +92,26 @@ void vlMapper::SetEndRender(void (*f)(void *), void *arg)
}
}
// Description:
// Specify a lookup table for the mapper to use.
void vlMapper::SetLookupTable(vlLookupTable *lut)
{
if ( this->LookupTable != lut )
{
if ( this->SelfCreatedLookupTable ) delete this->LookupTable;
this->SelfCreatedLookupTable = 0;
this->LookupTable = lut;
this->Modified();
}
}
void vlMapper::CreateDefaultLookupTable()
{
if ( this->SelfCreatedLookupTable ) delete this->LookupTable;
this->LookupTable = new vlLookupTable;
this->SelfCreatedLookupTable = 1;
}
void vlMapper::PrintSelf(ostream& os, vlIndent indent)
{
if (this->ShouldIPrint(vlMapper::GetClassName()))
......
......@@ -25,6 +25,8 @@ vlPolyMapper::vlPolyMapper()
this->Lines = NULL;
this->Polys = NULL;
this->Strips = NULL;
this->Colors = NULL;
this->VertsVisibility = 1;
this->LinesVisibility = 1;
this->PolysVisibility = 1;
......@@ -33,10 +35,12 @@ vlPolyMapper::vlPolyMapper()
vlPolyMapper::~vlPolyMapper()
{
if ( this->Input != NULL )
{
this->Input->UnRegister(this);
}
//delete internally created objects
if ( this->Verts != NULL ) delete this->Verts;
if ( this->Lines != NULL ) delete this->Lines;
if ( this->Polys != NULL ) delete this->Polys;
if ( this->Strips != NULL ) delete this->Strips;
if ( this->Colors != NULL ) delete this->Colors;
}
void vlPolyMapper::SetInput(vlPolyData *in)
......@@ -44,7 +48,6 @@ void vlPolyMapper::SetInput(vlPolyData *in)
if (in != this->Input )
{
this->Input = in;
this->Input->Register(this);
this->Modified();
}
}
......@@ -74,7 +77,6 @@ float *vlPolyMapper::GetBounds()
void vlPolyMapper::Render(vlRenderer *ren)
{
vlPointData *pd;
vlRGBArray *colors;
vlScalars *scalars;
int i;
char forceBuild = 0;
......@@ -89,9 +91,8 @@ void vlPolyMapper::Render(vlRenderer *ren)
else
this->Input->Update();
if ( ! this->LookupTable ) this->SetLookupTable(new vlLookupTable);
if ( this->LookupTable == NULL ) this->CreateDefaultLookupTable();
this->LookupTable->Build();
//
// Now send data down to primitives and draw it
//
......@@ -104,39 +105,40 @@ void vlPolyMapper::Render(vlRenderer *ren)
if ( this->ScalarsVisible && (pd=this->Input->GetPointData()) &&
(scalars=pd->GetScalars()) )
{
colors = new vlRGBArray;
colors->Allocate (this->Input->GetNumberOfPoints());
if ( this->Colors == NULL ) this->Colors = new vlRGBArray;
this->Colors->Allocate (this->Input->GetNumberOfPoints());
this->LookupTable->SetTableRange(this->ScalarRange);
for (i=0; i<this->Input->GetNumberOfPoints(); i++)
{
colors->SetColor(i,this->LookupTable->MapValue(scalars->GetScalar(i)));
this->Colors->SetColor(i,this->LookupTable->MapValue(scalars->GetScalar(i)));
}
}
else
{
colors = NULL;
if ( this->Colors ) delete this->Colors;
this->Colors = NULL;
}
if (this->VertsVisibility && this->Input->GetNumberOfVerts())
{
if (!this->Verts) this->Verts = ren->GetPrimitive("points");
this->Verts->Build(this->Input,colors);
this->Verts->Build(this->Input,this->Colors);
}
if ( this->LinesVisibility && this->Input->GetNumberOfLines())
{
if (!this->Lines) this->Lines = ren->GetPrimitive("lines");
this->Lines->Build(this->Input,colors);
this->Lines->Build(this->Input,this->Colors);
}
if ( this->PolysVisibility && this->Input->GetNumberOfPolys())
{
if (!this->Polys) this->Polys = ren->GetPrimitive("polygons");
this->Polys->Build(this->Input,colors);
this->Polys->Build(this->Input,this->Colors);
}
if ( this->StripsVisibility && this->Input->GetNumberOfStrips())
{
if (!this->Strips) this->Strips = ren->GetPrimitive("triangle_strips");
this->Strips->Build(this->Input,colors);
this->Strips->Build(this->Input,this->Colors);
}
this->BuildTime.Modified();
......
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