Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

HRElem.h

Go to the documentation of this file.
00001 /*
00002     File:       HRElem.h
00003 
00004     Function:   Defines the element type used by the various hierarchical
00005                 radiosity methods.
00006 
00007     Author:     Andrew Willmott
00008 
00009     Copyright:  (c) 2000, Andrew Willmott
00010 */
00011 
00012 #ifndef __HRElem__
00013 #define __HRElem__
00014 
00015 #include "HRLink.h"
00016 #include "cl/PtrArray.h"
00017 
00018 
00019 // --- Hierarchical Radiosity Element -----------------------------------------
00020 
00021 
00022 struct HRStats
00023 {
00024     Void    Init();
00025 
00026     Int     numLinks;
00027     Int     numPatches;
00028     Int     numVolClusters;
00029     Int     numFaceClusters;
00030     Int     numAliens;
00031 };
00032 
00033 enum HRFlags
00034 {
00035     hrPatch             = 0x0001,       
00036     hrCluster           = 0x0002,       
00037     hrFaceClus          = 0x0004,       
00038     hrIntNode           = 0x0010,       
00039     hrHasLights         = 0x0020,       
00040     hrHasNonLights      = 0x0040,       
00041     hrMixed             = 0x0060,       
00042     hrMark              = 0x0080,       
00043     hrAll               = 0xFFFF
00044 };
00045 
00046 typedef PtrArray<HRLinkList> LinkStack;
00047 
00048 class ShadeInfo
00049 {
00050 public:
00051     ShadeInfo();
00052     
00053     LinkStack       linkStack;  
00054     Int             level;      
00055     Void            *data;      
00056 };
00057 
00058 
00059 class HRElem
00061 {
00062 public:
00063                     HRElem();
00064     virtual         ~HRElem();
00065 
00066     virtual Void    Reset();
00067                     // clear all data structures associated with this elt.
00068 
00069     //  Link refinement
00070     Bool            Refine();
00075     Bool            RefineLink(HRLink *link, Int levels);
00077     Void            RefineFurther(Void*);
00079 
00080     //  Solving
00081     Void            PushPull(Void *v = 0);
00083     Void            GatherAll(Void *v = 0);
00085     Void            Gather();
00087 
00088     //  Stub routines for wavelet radiosity 
00089     
00090     virtual Bool    IsLeaf() = 0;
00092     virtual Void    ApplyToChildren(Void (HRElem::*method)(Void*), 
00093                                     Void *ref = 0) = 0;
00095     virtual Void    MakeChildLinks(HRElem *other, HRLink *link,
00096                                    Int which, Int levels) = 0;
00098     virtual Void    DistributeColours();
00101     virtual Void    DistributeColoursBest(ShadeInfo &shadeInfo);
00105     //  Standard hierarchy routines.
00106 
00107     virtual GCLReal Error() = 0;
00109     virtual Void    Add() = 0;
00111     virtual Void    Push() = 0;
00113     virtual Void    Pull() = 0;
00115     virtual Void    ClearB() = 0;
00117     virtual Void    ClearR() = 0;
00119     virtual Void    CalcLeafRadiosity() = 0;
00121     virtual Void    InitRad();
00123         
00124     //  Visualisation stuff
00125 
00126     Void            DrawMatrix(Renderer &r, Int baseNum);
00127     virtual Void    DrawMatrixRec(Void *dmi);
00128     Void            DrawContributors(Renderer &r);
00130     Void            DrawContributorsRec(Void *r);
00131     Void            DrawElem(Renderer &r);
00133     virtual Void    DrawNodeElem(Renderer &r) = 0;
00135     virtual Void    DrawLeafElem(Renderer &r) = 0;
00137 
00138     // misc.
00139     
00140     Void            CalcStats(Void *statsIn);
00142     Void            DumpHierarchy(Void *v = 0);
00143 
00144     Bool            IsPatch()
00145                     { return(flags.IsSet(hrPatch)); };
00146     Bool            IsCluster()
00147                     { return(flags.IsSet(hrCluster)); };
00148     Bool            IsFaceClus()
00149                     { return(flags.IsSet(hrFaceClus)); };
00150 
00151     // Fields: just the links to other elements & flags.
00152     
00153     Flags16         flags;
00154     HRLinkList      links;
00155     UInt32          id;
00156     static UInt32   gID;
00157 #ifdef RAD_VIS
00158     virtual Void    SetHighlight(Int n)
00159                     { eltHighlight = n; };
00160     HRElem          *eltParent; 
00161     Byte            eltHighlight;
00162 #endif
00163 
00164 // --- Generic wavelet radiosity routines -------------------------------------
00165 
00166     // these are more flexible than the hard-coded routines in the
00167     // HaarLink && Flatlet/Multiwavelet links. 
00168     
00169     GCLReal         EltVis(HRElem *toElt); 
00170     GCLReal         EltVisToPoint(Point &p);
00172 
00173     virtual Void    EltSetVisPoints(HRElem *to, Point p[]) = 0;
00175     virtual Void    EltUpdateBounds(Point &min, Point &max) = 0;
00177 
00178     virtual GCLReal EltProjArea(const Vector &v) = 0;
00181     virtual GCLReal EltArea() = 0;
00183     virtual Point   EltCentre() = 0;
00185     virtual Colour  EltRho() = 0;
00187 
00188     virtual Void    EltSampleTransport(Int numSamples, Point p[], Vector n[],
00189                         Matd &coeffs) = 0;
00193     virtual GCLReal EltCalcTransport(HRElem *from, Matd &coeffs) = 0;
00198     virtual Int     NumCoeffs() { return 1; };
00199     virtual Colour  *R_Coeffs() = 0;
00201     virtual Colour  *B_Coeffs() = 0;
00203 
00204     // cluster/vector radiosity
00205     virtual Colour  EltE() = 0;
00206     virtual Colour  EltBA();
00208     virtual Void    AddIrradiance(const Colour &E, const Vector &m) = 0;
00209     virtual Void    AddChanIrradiance(const Colour &E, Int chan);
00210     virtual Colour  GetPower(const Vector &m) = 0;
00211     virtual Void    EltGetSamples(Int numSamples, Point pts[]) = 0;
00212     virtual GCLReal EltMaxProjArea(const Vector &v);
00215 
00216     virtual Void    DebugInfo();
00217 
00218     static ostream  *out;
00219 };
00220 
00221 typedef HRElem              *HRElemPtr;
00222 typedef PtrArray<HRElem>    HRElemList;
00223 
00224 struct DMInfo
00226 {
00227     Renderer    *r;
00228     Int         baseNum;
00229 };
00230 
00231 GCLReal VecError(const SubVecd &v);
00233 
00234 #endif

Generated at Sat Aug 5 00:26:52 2000 for Radiator by doxygen 1.1.0 written by Dimitri van Heesch, © 1997-2000