Open PaperOpt
OpenPaperOpt/RndVolume.h
Go to the documentation of this file.
00001 #ifndef RNDVOLUME_H
00002 #define RNDVOLUME_H
00003 
00004 #ifndef MAX_THREADS
00005 #define MAX_THREADS  2 //Controlls number of tagslots in render objects
00006 //and thus the maximum number of CPU's that can be
00007 //used simultaniously
00008 #endif
00009 
00010 
00011 
00012 #include "utilities.h"
00013 #include "V2.h"
00014 #include "V3.h"
00015 #include "FiberStatic.h"
00016 #include "Staticsheet.h"
00017 #include "RndFiber.h"
00018 #include "OrientClipBox.h"
00019 #include "RndFiberSeg.h"
00020 #include "RndHitSortTag.h"
00021 
00022 
00023 using namespace std;
00024 
00025 namespace p3d{
00026 
00032         class RndVolume{
00033 
00034                 friend class RndRay;
00035 
00036         private:
00037                 //Size of surface
00038                 //mSizeX and mSizeY come from the size of the volume
00039                 //mSizeZ comes from the calculation of mBotZ and mTopZ
00040                 double mSizeX,mSizeY,mSizeZ;   //um
00041                 //mSizeZ=mTopZ-mBotZ
00042                 double mBotZ,mTopZ;    //um, used for lattice only, NOTE: larger span than mSizeZ
00043 
00044                 //Fiber access
00045                 //lattice size
00046                 double mSizeAccX,mSizeAccY,mSizeAccZ;
00047                 //double mSizeInvAccX,mSizeInvAccY,mSizeInvAccZ;
00048                 //lattice amount
00049                 int   mNumAccX,mNumAccY,mNumAccZ;
00050 
00051                 AutoDeleteV<int> mAccPtrs; //Indexorder, X,Y,Z (x-least significant)
00052                 vector<ClipBoxRef> mAccLinks;
00053                 //Fibers
00054                 vector<RndFiber*> mFibers;
00055 
00056                 AutoDeleteV<OrientClipBox> mClipBoxes;
00057                 int   mNumClipBoxes;
00058 
00059                 //Lookups used by rays
00060                 vector<RndHitSortTag> mRayTagVecs[MAX_THREADS];
00061 
00062                 //Raycounter, used to alloc unique raynumbers for intersection testing
00063                 long  mRayCounter;
00064 
00065         public:
00066 
00067                 RndVolume(Staticsheet* simVol,double maxAccSidelen=30,int boxLen=5,double p1=0,double p2=0);
00068                 ~RndVolume();
00069 
00070                 int  GetDataSize();
00076                 void ResetRaycounter();
00077         private:
00078 
00079                 void AddClipBoxLink(int no,int x,int y,int z);
00080                 int  GetChainLength(int idx);
00081                 vector<RndHitSortTag>* GetSortVector(int idx) {return mRayTagVecs+idx;}
00082 
00083                 int  GetAccPtr(int x,int y,int z) const {return mAccPtrs[x+(y+z*mNumAccY)*mNumAccX];}
00084                 //NOTE: No checking performed...
00085 
00086                 int  GetNewRayNumber() {return (mRayCounter++);}
00087 
00088                 vector<ClipBoxRef>::iterator GetClipBoxLinks() {return mAccLinks.begin();}
00089                 OrientClipBox* GetClipBoxes() {return mClipBoxes;}
00090         };
00091 }
00092 
00093 #endif