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

new collections

parent 3f4817b0
......@@ -16,31 +16,19 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlActorC_hh
#define __vlActorC_hh
#include "Collect.hh"
#include "Actor.hh"
class vlActorListElement
class vlActorCollection : public vlCollection
{
public:
vlActor *Actor;
vlActorListElement *Next;
};
class vlActorCollection : public vlObject
{
public:
int NumberOfItems;
private:
vlActorListElement *Top;
vlActorListElement *Bottom;
public:
vlActorCollection();
void AddMember(vlActor *);
int GetNumberOfMembers();
vlActor *GetMember(int num);
void PrintSelf(ostream& os, vlIndent indent);
void AddItem(vlActor *a) {this->vlCollection::AddItem((vlObject *)a);};
void RemoveItem(vlActor *a)
{this->vlCollection::RemoveItem((vlObject *)a);};
int IsItemPresent(vlActor *a)
{return this->vlCollection::IsItemPresent((vlObject *)a);};
vlActor *GetItem(int num)
{ return (vlActor *)(this->vlCollection::GetItem(num));};
char *GetClassName() {return "vlActorCollection";};
};
......
......@@ -16,32 +16,21 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlLightC_hh
#define __vlLightC_hh
#include "Collect.hh"
#include "Light.hh"
class vlLightListElement
class vlLightCollection : public vlCollection
{
public:
vlLight *Light;
vlLightListElement *Next;
};
class vlLightCollection : public vlObject
{
public:
int NumberOfItems;
private:
vlLightListElement *Top;
vlLightListElement *Bottom;
public:
vlLightCollection();
void AddItem(vlLight *a) {this->vlCollection::AddItem((vlObject *)a);};
void RemoveItem(vlLight *a)
{this->vlCollection::RemoveItem((vlObject *)a);};
int IsItemPresent(vlLight *a)
{return this->vlCollection::IsItemPresent((vlObject *)a);};
vlLight *GetItem(int num)
{ return (vlLight *)(this->vlCollection::GetItem(num));};
char *GetClassName() {return "vlLightCollection";};
void AddMember(vlLight *);
int GetNumberOfMembers();
vlLight *GetMember(int num);
void PrintSelf(ostream& os, vlIndent indent);
};
#endif
......@@ -16,33 +16,23 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#ifndef __vlRendererCollection_hh
#define __vlRendererColleciton_hh
#include "Collect.hh"
#include "Renderer.hh"
class vlRendererListElement
class vlRendererCollection : public vlCollection
{
public:
vlRenderer *Renderer;
vlRendererListElement *Next;
};
class vlRendererCollection : public vlObject
{
public:
int NumberOfItems;
private:
vlRendererListElement *Top;
vlRendererListElement *Bottom;
void AddItem(vlRenderer *a)
{this->vlCollection::AddItem((vlObject *)a);};
void RemoveItem(vlRenderer *a)
{this->vlCollection::RemoveItem((vlObject *)a);};
int IsItemPresent(vlRenderer *a)
{return this->vlCollection::IsItemPresent((vlObject *)a);};
vlRenderer *GetItem(int num)
{ return (vlRenderer *)(this->vlCollection::GetItem(num));};
char *GetClassName() {return "vlRendererCollection";};
public:
void Render();
char *GetClassName() {return "vlRendererCollection";};
void PrintSelf(ostream& os, vlIndent indent);
vlRendererCollection();
void AddMember(vlRenderer *);
int GetNumberOfMembers();
vlRenderer *GetMember(int num);
};
#endif
......@@ -47,9 +47,9 @@ int vlGlrRenderer::UpdateActors()
mmode(MVIEWING);
// loop through actors
for (num = 1; num <= this->Actors.GetNumberOfMembers(); num++)
for (num = 1; num <= this->Actors.GetNumberOfItems(); num++)
{
anActor = this->Actors.GetMember(num);
anActor = this->Actors.GetItem(num);
// if it's invisible, we can skip the rest
visibility = anActor->GetVisibility();
......@@ -121,9 +121,9 @@ int vlGlrRenderer::UpdateLights ()
mmode(MVIEWING);
pushmatrix();
for (i = 1; i <= this->Lights.GetNumberOfMembers(); i++)
for (i = 1; i <= this->Lights.GetNumberOfItems(); i++)
{
light = this->Lights.GetMember(i);
light = this->Lights.GetItem(i);
status = light->GetSwitch();
......
......@@ -17,81 +17,15 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include <iostream.h>
#include "RenderC.hh"
vlRendererCollection::vlRendererCollection()
{
this->NumberOfItems = 0;
this->Top = NULL;
this->Bottom = NULL;
}
void vlRendererCollection::AddMember(vlRenderer *Renderer)
{
vlRendererListElement *elem;
elem = new vlRendererListElement;
if (!this->Top)
{
this->Top = elem;
}
else
{
this->Bottom->Next = elem;
}
this->Bottom = elem;
elem->Renderer = Renderer;
elem->Next = NULL;
this->NumberOfItems++;
}
int vlRendererCollection::GetNumberOfMembers()
{
return this->NumberOfItems;
}
vlRenderer *vlRendererCollection::GetMember(int num)
{
int i;
vlRendererListElement *elem;
if (num > this->NumberOfItems)
{
vlErrorMacro(<< "Renderer: Requesting illegal index\n");
return this->Top->Renderer;
}
elem = this->Top;
for (i = 1; i < num; i++)
{
elem = elem->Next;
}
return (elem->Renderer);
}
void vlRendererCollection::Render()
{
int i;
vlRendererListElement *elem;
vlRenderer *elem;
elem = this->Top;
for (i = 0; i < this->NumberOfItems; i++)
{
elem->Renderer->Render();
elem = elem->Next;
}
}
void vlRendererCollection::PrintSelf(ostream& os, vlIndent indent)
{
if (this->ShouldIPrint(vlRendererCollection::GetClassName()))
for (i = 1; i <= this->GetNumberOfItems(); i++)
{
vlObject::PrintSelf(os,indent);
os << indent << "Number Of Members: " << this->NumberOfItems << "\n";
elem = this->GetItem(i);
elem->Render();
}
}
......@@ -52,9 +52,9 @@ int vlSbrRenderer::UpdateActors()
int count = 0;
// loop through actors
for (num = 1; num <= this->Actors.GetNumberOfMembers(); num++)
for (num = 1; num <= this->Actors.GetNumberOfItems(); num++)
{
anActor = this->Actors.GetMember(num);
anActor = this->Actors.GetItem(num);
// if it's invisible, we can skip the rest
visibility = anActor->GetVisibility();
......@@ -115,9 +115,9 @@ int vlSbrRenderer::UpdateLights ()
cur_light= this->NumberOfLightsBound;
for (i = 1; i <= this->Lights.GetNumberOfMembers(); i++)
for (i = 1; i <= this->Lights.GetNumberOfItems(); i++)
{
light = this->Lights.GetMember(i);
light = this->Lights.GetItem(i);
status = light->GetSwitch();
......
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