00001 /*
00002 File: HRLink.h
00003
00004 Function: Defines a link type for use with hierarchical/
00005 wavelet radiosity methods.
00006
00007 Author(s): Andrew Willmott
00008
00009 Copyright: (c) 1997-2000, Andrew Willmott
00010 */
00011
00012
00013 #ifndef __HRLink__
00014 #define __HRLink__
00015
00016 #include "cl/List.h"
00017 #include "gcl/Renderer.h"
00018
00019
00020 // --- Link between two hierarchical elements ---------------------------------
00021
00022
00023 class HRElem;
00024
00025 enum RefChoice { kSubNone, kSubFrom, kSubTo, kSubBoth };
00026
00027 class HRLink : public Node
00028 {
00029 public:
00030 HRLink();
00031
00032 virtual HRLink *New() = 0;
00034 virtual Void FreeLink(HRLink *link);
00036
00037 Bool MakeLink(
00038 HRElem *fromElem,
00039 HRElem *toElem,
00040 HRLink *parentLink = 0,
00041 Bool forceVisReuse = false
00042 );
00044 virtual Bool CalcTransport() = 0;
00047 virtual Bool CalcVisibility(HRLink *parentLink, Bool forceVisReuse);
00051 virtual Void Gather() = 0;
00055 Bool NeedVisibility(HRLink *parentLink);
00057
00058 virtual RefChoice RefineOracle();
00060
00061 virtual GCLReal Error() = 0;
00062 virtual GCLReal BFAError() = 0;
00063
00064 HRLink *CreateSubLink(HRElem *from, HRElem *to);
00069 virtual Void Print(ostream &s);
00070 virtual Void DrawLink(Renderer &r, GCLReal left,
00071 GCLReal top, GCLReal right,
00072 GCLReal bottom, GCLReal weight);
00073 virtual GCLReal Strength() = 0;
00074 virtual Void DebugInfo();
00075
00076 // Fields
00077 HRElem *from, *to;
00078 GCLReal visibility;
00079 Flags8 flags;
00080 };
00081
00082 ostream &operator << (ostream &s, HRLink &rl);
00083
00084 typedef List HRLinkList;
00085 typedef Iter<HRLink> HRLinkIter;
00086
00087 ostream &operator << (ostream &s, HRLink &l);
00088
00089 inline Vector safe_norm(const Vector &v)
00090 {
00091 GCLReal r;
00092 Vector result;
00093
00094 r = len(v);
00095 result = v;
00096 if (r > 0.0)
00097 result /= r;
00098
00099 return(result);
00100 }
00101
00102 #endif