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

Revision 1771, 3.5 KB checked in by bittner, 18 years ago (diff)

merge, preparing sampling strategy support for mixed distributions, filter changes, histogram output for preprocessor

  • 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#if 0
32        struct PendingRay
33        {
34                PendingRay(VssRay *ray, const bool d)
35                        : mRay(ray), mFoundDiscontinuity(d)
36                {}
37
38                VssRay *mRay;
39                bool mFoundDiscontinuity;
40        };
41
42        typedef stack<PendingRay> PendingQueue;
43#endif
44        typedef stack<VssRay *> RayQueue;
45
46        /** Runs the adaptive sampling until the ray queue is empty.
47                The method starts with a number of random rays given
48                by the queue and continues as long it finds new visible geometry
49                (i.e., the queue is     not empty).
50
51                @returns the number of samples cast.
52        */
53        int ProcessQueue();
54
55        /** One pass of the sampling preprocessor.
56                Continues as long as at least passSample rays have been cast.
57                @returns the number of samples cast.
58        */
59        int Pass();
60
61        /** Generates the rays starting the adaptive visibility sampling process.
62        */
63        int CastInitialSamples(const int numSamples, const int sampleType);
64
65        /** Uses the information gained from the ray for doing adaptive border sampling.
66                This function tries to find the border of the triangle found visible by the
67                current ray. New rays are generated which sample this border.
68               
69                We use the following strategies:
70
71                a) if new triangle was found: adaptive border sampling
72                b) if triangle was found reverse sampling
73        */
74        bool HandleRay(VssRay *ray);
75
76        /** The adaptive border sampling step. It aims to find neighbouring
77                triangles of the one hit by the current ray.
78        */     
79        int AdaptiveBorderSampling(const VssRay &currentRay);
80       
81        /** The reverse sampling step. It is started once the cast
82                ray finds a discontinuity, i.e., a closer triangle.
83                Then the process tries to find a ray from the old
84                triangle passing through a gap.
85        */
86        VssRay *ReverseSampling(const VssRay &currentRay,
87                                                        const Triangle3 &hitTriangle,
88                                                        const VssRay &oldRay);
89
90        /** Returns true if we sampled a closer triangle than with the previous ray.
91                Does reverse sampling if gap found.
92        */
93        bool CheckDiscontinuity(const VssRay &currentRay,
94                                                        const Triangle3 &hitTriangle,
95                                                        const VssRay &oldRay);
96
97        /** Adds new samples to the ray queue and classifies them
98                with respect to the previous ray.
99        */
100        void EnqueueRays(VssRayContainer &samples);
101
102        /** Hepler function for adaptive border sampling. It finds
103                new sample points around a triangle in a eps environment
104        */
105        void EnlargeTriangle(VertexContainer &vertices,
106                                                 const Triangle3 &hitTriangle,
107                                                 const VssRay &ray);
108
109        int SubdivideEdge(
110                const Triangle3 &hitTriangle,
111                const Vector3 &p1,
112                const Vector3 &p2,
113                const VssRay &x,
114                const VssRay &y,
115                const VssRay &oldRay);
116
117        void Visualize();
118
119        //////////////////////
120
121
122        int mSamplesPerPass;
123        int mTotalSamples;
124        int mInitialSamples;
125
126        RayQueue mRayQueue;
127        int mSamplingType;
128
129        //AxisAlignedBox3 mViewSpaceBox;
130        float mEps;
131        float mThreshold;
132        VssRayContainer mVssRays;
133       
134        ///////////
135        // stats
136        int mSampleContriPerPass;
137        int mTotalSampleContri;
138        int mReverseSamples;
139        int mBorderSamples;
140        int mGvsPass;
141};
142
143};
144
145#endif
Note: See TracBrowser for help on using the repository browser.