source: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h @ 1489

Revision 1489, 2.7 KB checked in by mattausch, 18 years ago (diff)
  • Property svn:executable set to *
Line 
1#ifndef _GvsPreprocessor_H__
2#define _GvsPreprocessor_H__
3
4#include <fstream>
5#include <stack>
6using namespace std;
7
8#include "Preprocessor.h"
9
10namespace GtpVisibilityPreprocessor {
11
12class Exporter;
13class VssRay;
14
15
16
17/** Sampling based visibility preprocessing. The implementation is
18        based on heuristical sampling of view space.
19*/
20class GvsPreprocessor : public Preprocessor {
21
22public:
23
24        GvsPreprocessor();
25        ~GvsPreprocessor() {}
26
27        virtual bool ComputeVisibility();
28       
29
30protected:
31
32        struct GvsRayInfo
33        {
34                GvsRayInfo(VssRay *ray, const bool d)
35                        : mRay(ray), mFoundDiscontinuity(d)
36                {}
37
38                VssRay *mRay;
39                bool mFoundDiscontinuity;
40        };
41
42
43        typedef stack<GvsRayInfo> RayQueue;
44
45        /** Runs the adaptive sampling until the ray queue is empty.
46                The method starts with a number of random rays given
47                by the queue and continues as long it finds new visible geometry
48                (i.e., the queue is     not empty).
49
50                @returns the number of samples cast.
51        */
52        int ProcessQueue();
53
54        /** One pass of the sampling preprocessor.
55                Continues as long as at least passSample rays have been cast.
56                @returns the number of samples cast.
57        */
58        int Pass();
59
60        /** Generates the rays starting the adaptive visibility sampling process.
61        */
62        int CastInitialSamples(const int numSamples, const int sampleType);
63
64        /** Uses the information gained from the ray for doing adaptive border sampling.
65                This function tries to find the border of the triangle found visible by the
66                current ray. New rays are generated which sample this border.
67               
68                We use the following strategies:
69
70                a) if new triangle was found: adaptive border sampling
71                b) if triangle was found reverse sampling
72        */
73        int HandleRay(const GvsRayInfo &ray);
74
75        /** The adaptive border sampling step. It aims to find neighbouring
76                triangles of the one hit by the previous ray.
77        */     
78        int AdaptiveBorderSampling(const VssRay &prevRay);
79       
80        /** The reverse sampling step. It is started once the cast
81                ray finds a discontinuity, i.e., a closer triangle.
82                Then the process tries to find a ray from the old
83                triangle passing through a gap.
84        */
85        int ReverseSampling(const VssRay &prevRay);
86
87        /** Returns true if we sampled a closer triangle than with the previous ray.
88        */
89        const bool DiscontinuityFound(const VssRay &ray, const VssRay &prevRay) const;
90
91        /** Adds new samples to the ray queue and classifies them
92                with respect to the previous ray.
93        */
94        void EnqueueSamples(VssRayContainer &samples, VssRay *prevRay = NULL);
95       
96        //////////////////////
97
98        ofstream mStats;
99
100        int mSamplesPerPass;
101        RayQueue mRayQueue;
102        int mSamplingType;
103        int mTotalSamples;
104        int mInitialSamples;
105        AxisAlignedBox3 mViewSpaceBox;
106        float mEps;
107};
108
109};
110
111#endif
Note: See TracBrowser for help on using the repository browser.