1 | #ifndef _GvsPreprocessor_H__
|
---|
2 | #define _GvsPreprocessor_H__
|
---|
3 |
|
---|
4 | #include <fstream>
|
---|
5 | #include <stack>
|
---|
6 | using namespace std;
|
---|
7 |
|
---|
8 | #include "Preprocessor.h"
|
---|
9 |
|
---|
10 | namespace GtpVisibilityPreprocessor {
|
---|
11 |
|
---|
12 | class Exporter;
|
---|
13 | class VssRay;
|
---|
14 |
|
---|
15 |
|
---|
16 | typedef stack<VssRay *> RayQueue;
|
---|
17 |
|
---|
18 | /** Sampling based visibility preprocessing. The implementation is
|
---|
19 | based on heuristical sampling of view space.
|
---|
20 | */
|
---|
21 | class GvsPreprocessor : public Preprocessor {
|
---|
22 |
|
---|
23 | public:
|
---|
24 |
|
---|
25 | GvsPreprocessor();
|
---|
26 | ~GvsPreprocessor() {}
|
---|
27 |
|
---|
28 | virtual bool ComputeVisibility();
|
---|
29 |
|
---|
30 |
|
---|
31 | protected:
|
---|
32 |
|
---|
33 | /** Runs the adaptive sampling. The method starts with a number of random rays given
|
---|
34 | by the queue and continues as long it finds new visible geometry (i.e., the queue is
|
---|
35 | not empty).
|
---|
36 |
|
---|
37 | @returns the number of samples cast.
|
---|
38 | */
|
---|
39 | int RunSampling();
|
---|
40 |
|
---|
41 | /** One pass of the sampling preprocessor. Continues as long as at least passSample
|
---|
42 | rays have been cast.
|
---|
43 | @returns the number of samples cast.
|
---|
44 | */
|
---|
45 | int Pass(const int passSamples);
|
---|
46 |
|
---|
47 | /** Generates the rays starting the adaptive visibility sampling process.
|
---|
48 | */
|
---|
49 | int CastAvsSamples(
|
---|
50 | const int samplesPerPass,
|
---|
51 | const int sampleType,
|
---|
52 | RayQueue &passSamples);
|
---|
53 |
|
---|
54 | /** Uses the information gained from the ray for doing adaptive border sampling.
|
---|
55 | This function tries to find the border of the triangle found visible by the
|
---|
56 | current ray. New rays are generated which sample this border.
|
---|
57 |
|
---|
58 | We use the following strategies:
|
---|
59 |
|
---|
60 | a) if new triangle was found: adaptive border sampling
|
---|
61 | b) if triangle was found reverse sampling
|
---|
62 | */
|
---|
63 | int HandleRay(VssRay &ray);
|
---|
64 |
|
---|
65 | /**
|
---|
66 | */
|
---|
67 | int AdaptiveBorderSampling(VssRay &ray);
|
---|
68 |
|
---|
69 | int ReverseSampling(VssRay &ray);
|
---|
70 |
|
---|
71 | /** Cast samples according to a specific sampling strategy.
|
---|
72 | */
|
---|
73 | int CastPassSamples(
|
---|
74 | const int samplesPerPass,
|
---|
75 | const int sampleType,
|
---|
76 | VssRayContainer &passSamples) const;
|
---|
77 |
|
---|
78 |
|
---|
79 |
|
---|
80 | //////////////////////
|
---|
81 |
|
---|
82 | ofstream mStats;
|
---|
83 | int mSamples;
|
---|
84 | int mSamplesPerPass;
|
---|
85 | RayQueue mRayQueue;
|
---|
86 | int mSamplingType;
|
---|
87 | int mTotalSamples;
|
---|
88 | };
|
---|
89 |
|
---|
90 | };
|
---|
91 |
|
---|
92 | #endif
|
---|