source: GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp @ 2694

Revision 2694, 36.3 KB checked in by mattausch, 16 years ago (diff)

worked on moving objects

  • Property svn:executable set to *
Line 
1#include "Environment.h"
2#include "GvsPreprocessor.h"
3#include "GlRenderer.h"
4#include "VssRay.h"
5#include "ViewCellsManager.h"
6#include "Triangle3.h"
7#include "IntersectableWrapper.h"
8#include "Plane3.h"
9#include "RayCaster.h"
10#include "Exporter.h"
11#include "SamplingStrategy.h"
12#include "BvHierarchy.h"
13#include "Polygon3.h"
14#include "IntersectableWrapper.h"
15
16
17
18namespace GtpVisibilityPreprocessor
19{
20 
21#define GVS_DEBUG 0
22#define NOT_ACCOUNTED_OBJECT 0
23#define ACCOUNTED_OBJECT 2
24#define SHOW_QT_VISUALIZATION 0
25
26static const float MIN_DIST = 0.001f;
27
28static ObjectContainer myobjects;
29
30
31/** Visualization structure for the GVS algorithm.
32*/
33struct VizStruct
34{
35        Polygon3 *enlargedTriangle;
36        Triangle3 originalTriangle;
37        VssRay *ray;
38};
39
40static vector<VizStruct> vizContainer;
41
42
43
44
45GvsPreprocessor::GvsPreprocessor():
46Preprocessor(),
47mProcessedViewCells(0),
48mCurrentViewCell(NULL),
49mCurrentViewPoint(Vector3(0.0f, 0.0f, 0.0f)),
50mOnlyRandomSampling(false)
51//mOnlyRandomSampling(true)
52{
53        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.totalSamples", mTotalSamples);
54        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.initialSamples", mInitialSamples);
55        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.gvsSamplesPerPass", mGvsSamplesPerPass);
56        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.minContribution", mMinContribution);
57        Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.epsilon", mEps);
58        Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.threshold", mThreshold);   
59        Environment::GetSingleton()->GetBoolValue("GvsPreprocessor.perViewCell", mPerViewCell);
60        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.maxViewCells", mMaxViewCells);
61
62        Environment::GetSingleton()->GetBoolValue("Preprocessor.evaluatePixelError", mEvaluatePixelError);
63
64        Environment::GetSingleton()->GetBoolValue("ViewCells.useKdPvs", mUseKdPvs);
65
66
67        char gvsStatsLog[100];
68        Environment::GetSingleton()->GetStringValue("GvsPreprocessor.stats", gvsStatsLog);
69        mGvsStatsStream.open(gvsStatsLog);
70
71        cout << "number of gvs samples per pass: " << mGvsSamplesPerPass << endl;
72        cout << "number of samples per pass: " << mSamplesPerPass << endl;
73        cout << "only random sampling: " << mOnlyRandomSampling << endl;
74
75        Debug << "Gvs preprocessor options" << endl;
76        Debug << "number of total samples: " << mTotalSamples << endl;
77        Debug << "number of initial samples: " << mInitialSamples << endl;
78        Debug << "threshold: " << mThreshold << endl;
79        Debug << "epsilon: " << mEps << endl;
80        Debug << "stats: " << gvsStatsLog << endl;
81        Debug << "per view cell: " << mPerViewCell << endl;
82        Debug << "max view cells: " << mMaxViewCells << endl;
83        Debug << "min contribution: " << mMinContribution << endl;
84
85        mDistribution = new ViewCellBasedDistribution(*this, NULL);
86
87        mGvsStats.Reset();
88
89        // hack: some generic statistical values that can be read
90        // by an application using the preprocessor
91        for (int i = 0; i < 2; ++ i)
92                mGenericStats[i] = 0;
93}
94
95
96GvsPreprocessor::~GvsPreprocessor()
97{
98        delete mDistribution;
99        ClearRayQueue();
100}
101
102
103void GvsPreprocessor::ClearRayQueue()
104{
105        // clean ray queue
106        while (!mRayQueue.empty())
107        {
108                // handle next ray
109                VssRay *ray = mRayQueue.top();
110                mRayQueue.pop();
111
112                //delete ray;
113        }
114}
115
116
117ViewCell *GvsPreprocessor::NextViewCell()
118{
119        if (mProcessedViewCells == (int)mViewCells.size())
120                return NULL; // no more view cells
121
122        ViewCell *vc = mViewCells[mProcessedViewCells];
123
124   if (!vc->GetMesh())
125                mViewCellsManager->CreateMesh(vc);
126
127        mGvsStats.mViewCellId = vc->GetId();
128
129        Debug << "vc: " << vc->GetId() << endl;
130
131        ++ mProcessedViewCells;
132   
133        return vc;
134}
135
136
137int GvsPreprocessor::CheckDiscontinuity(const VssRay &currentRay,
138                                                                                const Triangle3 &hitTriangle,
139                                                                                const VssRay &oldRay)
140{
141        // the predicted hitpoint: we expect to hit the same mesh again
142        const Vector3 predictedHit = CalcPredictedHitPoint(currentRay, hitTriangle, oldRay);
143
144        const float predictedLen = Magnitude(predictedHit - currentRay.mOrigin);
145        const float len = Magnitude(currentRay.mTermination - currentRay.mOrigin);
146       
147        // distance large => this is likely to be a discontinuity
148#if 1
149        if ((predictedLen - len) > mThreshold)
150#else // rather use relative distance
151        if ((predictedLen / len) > mThreshold)
152#endif
153        {
154                // apply reverse sampling to find the gap
155                VssRay *newRay = ReverseSampling(currentRay, hitTriangle, oldRay);
156
157                if (!newRay)
158                        return 1;
159
160                // set flag for visualization
161                if (0) newRay->mFlags |= VssRay::ReverseSample;
162               
163                // check if ray is not further processed (ray not deleted because using ray pool)
164                HandleRay(newRay);
165               
166                return 1;
167        }
168
169        return 0;
170}
171
172
173void GvsPreprocessor::CountObject(Intersectable *triObj)
174{
175        if ((triObj->mCounter != (NOT_ACCOUNTED_OBJECT + 1)) &&
176                (triObj->mCounter != (ACCOUNTED_OBJECT + 1)))
177        {
178                ++ triObj->mCounter;
179                ++ mGenericStats[1];
180        }
181}
182
183
184void GvsPreprocessor::UpdateStatsForVisualization(KdIntersectable *kdInt)
185{
186        //mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt);
187
188        // count new objects in pvs due to kd node conversion   
189        myobjects.clear();
190        mKdTree->CollectObjects(kdInt->GetItem(), myobjects);
191
192        ObjectContainer::const_iterator oit, oit_end = myobjects.end();
193
194        for (oit = myobjects.begin(); oit != oit_end; ++ oit)
195                CountObject(*oit);
196}       
197
198
199bool GvsPreprocessor::HasContribution(VssRay &ray)
200{
201        if (!ray.mTerminationObject)
202                return false;
203
204        bool result;
205
206        if (!mPerViewCell)
207        {
208                // store the rays + the intersected view cells
209                const bool storeViewCells = false; //GVS_DEBUG;
210
211                mViewCellsManager->ComputeSampleContribution(ray,
212                                                                                                         true,
213                                                                                                         storeViewCells,
214                                                                                                         true);
215
216                result = ray.mPvsContribution > 0;
217        }
218        else // original per view cell gvs
219        {
220                Intersectable *obj = ray.mTerminationObject;
221
222                // test if triangle was accounted for yet
223                result = AddTriangleObject(obj);
224               
225                if (mUseKdPvs && (1 || result))
226                {
227                        // exchange the triangle with the node in the pvs for kd pvs
228                        KdNode *node = mKdTree->GetPvsNode(ray.mTermination);
229
230                        //KdNode *node = mKdTree->GetPvsNodeCheck(ray.mTermination, obj);
231                        //if (!node) cerr << "e " << obj->GetBox() << " " << ray.mTermination << endl; else
232                        if (!node->Mailed())
233                        {//cout<<"o ";
234                                // add to pvs
235                                node->Mail();
236                                KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node);
237                                mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f);
238
239                                if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt); 
240                        }
241                }
242        }
243
244        return result;
245}
246
247
248bool GvsPreprocessor::HandleRay(VssRay *vssRay)
249{
250        if (!HasContribution(*vssRay))
251                return false;
252
253        if (0 && GVS_DEBUG)
254                mVssRays.push_back(new VssRay(*vssRay));
255
256        // add new ray to ray queue
257        mRayQueue.push(vssRay);
258
259        ++ mGvsStats.mTotalContribution;
260
261        return true;
262}
263
264
265/** Creates 3 new vertices for triangle vertex with specified index.
266*/
267void GvsPreprocessor::CreateDisplacedVertices(VertexContainer &vertices,
268                                                                                          const Triangle3 &hitTriangle,
269                                                                                          const VssRay &ray,
270                                                                                          const int index) const
271{
272        const int indexU = (index + 1) % 3;
273        const int indexL = (index == 0) ? 2 : index - 1;
274
275        const Vector3 a = hitTriangle.mVertices[index] - ray.GetOrigin();
276        const Vector3 b = hitTriangle.mVertices[indexU] - hitTriangle.mVertices[index];
277        const Vector3 c = hitTriangle.mVertices[index] - hitTriangle.mVertices[indexL];
278       
279        const float len = Magnitude(a);
280       
281        const Vector3 dir1 = Normalize(CrossProd(a, b)); //N((pi-xp)×(pi+1- pi));
282        const Vector3 dir2 = Normalize(CrossProd(a, c)); // N((pi-xp)×(pi- pi-1))
283        const Vector3 dir3 = DotProd(dir2, dir1) > 0 ? // N((pi-xp)×di,i-1+di,i+1×(pi-xp))
284                Normalize(dir2 + dir1) : Normalize(CrossProd(a, dir1) + CrossProd(dir2, a));
285
286        // compute the new three hit points
287        // pi, i + 1:  pi+ e·|pi-xp|·di, j
288        const Vector3 pt1 = hitTriangle.mVertices[index] + mEps * len * dir1;
289        // pi, i - 1:  pi+ e·|pi-xp|·di, j
290    const Vector3 pt2 = hitTriangle.mVertices[index] + mEps * len * dir2;
291        // pi, i:  pi+ e·|pi-xp|·di, j
292        const Vector3 pt3 = hitTriangle.mVertices[index] + mEps * len * dir3;
293       
294        vertices.push_back(pt2);
295        vertices.push_back(pt3);
296        vertices.push_back(pt1);
297}
298
299
300void GvsPreprocessor::EnlargeTriangle(VertexContainer &vertices,
301                                                                          const Triangle3 &hitTriangle,
302                                                                          const VssRay &ray) const
303{
304        CreateDisplacedVertices(vertices, hitTriangle, ray, 0);
305        CreateDisplacedVertices(vertices, hitTriangle, ray, 1);
306        CreateDisplacedVertices(vertices, hitTriangle, ray, 2);
307}
308
309
310Vector3 GvsPreprocessor::CalcPredictedHitPoint(const VssRay &newRay,
311                                                                                           const Triangle3 &hitTriangle,
312                                                                                           const VssRay &oldRay) const
313{
314        // find the intersection of the plane induced by the
315        // hit triangle with the new ray
316        Plane3 plane(hitTriangle.GetNormal(), hitTriangle.mVertices[0]);
317
318        const Vector3 hitPt =
319                plane.FindIntersection(newRay.mTermination, newRay.mOrigin);
320       
321        return hitPt;
322}
323
324
325static bool EqualVisibility(const VssRay &a, const VssRay &b)
326{
327        return a.mTerminationObject == b.mTerminationObject;
328}
329
330
331int GvsPreprocessor::SubdivideEdge(const Triangle3 &hitTriangle,
332                                                                   const Vector3 &p1,
333                                                                   const Vector3 &p2,
334                                                                   const VssRay &ray1,
335                                                                   const VssRay &ray2,
336                                                                   const VssRay &oldRay)
337{
338        //cout <<"y"<<Magnitude(p1 - p2) << " ";
339        int castRays = 0;
340
341        // cast reverse rays if necessary
342        castRays += CheckDiscontinuity(ray1, hitTriangle, oldRay);
343        castRays += CheckDiscontinuity(ray2, hitTriangle, oldRay);
344
345        if (EqualVisibility(ray1, ray2) || (SqrMagnitude(p1 - p2) <= MIN_DIST))
346        {
347                return castRays;
348        }
349       
350        // the new subdivision point
351        const Vector3 p = (p1 + p2) * 0.5f;
352        //cout << "p: " << p << " " << p1 << " " << p2 << endl;
353        // cast ray into the new point
354        SimpleRay sray(oldRay.mOrigin, p - oldRay.mOrigin, SamplingStrategy::GVS, 1.0f);
355
356        VssRay *newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell);
357       
358        ++ castRays;
359
360        if (!newRay) return castRays;
361
362        //newRay->mFlags |= VssRay::BorderSample;
363
364        // add new ray to queue
365        const bool enqueued = HandleRay(newRay);
366
367        // subdivide further
368        castRays += SubdivideEdge(hitTriangle, p1, p, ray1, *newRay, oldRay);
369        castRays += SubdivideEdge(hitTriangle, p, p2, *newRay, ray2, oldRay);
370
371        // this ray will not be further processed
372        // note: ray deletion is handled by ray pool
373
374        return castRays;
375}
376
377
378int GvsPreprocessor::AdaptiveBorderSampling(const VssRay &currentRay)
379{
380        Intersectable *tObj = currentRay.mTerminationObject;
381        // q matt: can this be possible
382        if (!tObj) return 0;
383
384        Triangle3 hitTriangle;
385
386        // other types not implemented yet
387        if (tObj->Type() == Intersectable::TRIANGLE_INTERSECTABLE)
388                hitTriangle = static_cast<TriangleIntersectable *>(tObj)->GetItem();
389        else
390                cout << "border sampling: " << Intersectable::GetTypeName(tObj) << " not yet implemented" << endl;
391
392        //cout << "type: " << Intersectable::GetTypeName(tObj) << endl;
393
394        VertexContainer enlargedTriangle;
395       
396        /// create 3 new hit points for each vertex
397        EnlargeTriangle(enlargedTriangle, hitTriangle, currentRay);
398       
399        /// create rays from sample points and handle them
400        SimpleRayContainer simpleRays;
401        simpleRays.reserve(9);
402
403        VertexContainer::const_iterator vit, vit_end = enlargedTriangle.end();
404
405        for (vit = enlargedTriangle.begin(); vit != vit_end; ++ vit)
406        {
407                const Vector3 rayDir = (*vit) - currentRay.GetOrigin();
408
409                SimpleRay sr(currentRay.GetOrigin(), rayDir, SamplingStrategy::GVS, 1.0f);
410                simpleRays.AddRay(sr); 
411        }
412
413        if (0)
414        {
415                // visualize enlarged triangles
416                VizStruct dummy;
417                dummy.enlargedTriangle = new Polygon3(enlargedTriangle);
418                dummy.originalTriangle = hitTriangle;
419                vizContainer.push_back(dummy);
420        }
421
422        // cast rays to triangle vertices and determine visibility
423        VssRayContainer vssRays;
424
425        // don't cast double rays as we need only the forward rays
426        const bool castDoubleRays = !mPerViewCell;
427        // cannot prune invalid rays because we have to compare adjacent  rays.
428        const bool pruneInvalidRays = false;
429
430
431        //////////
432        //-- fill up simple rays with random rays so we can cast 16
433
434        //const int numRandomRays = 0;
435        const int numRandomRays = 16 - (int)simpleRays.size();
436
437        GenerateRays(numRandomRays, *mDistribution, simpleRays);
438
439
440        /////////////////////
441
442        // keep origin for per view cell sampling
443        CastRays(simpleRays, vssRays, castDoubleRays, pruneInvalidRays);
444
445        const int numBorderSamples = (int)vssRays.size() - numRandomRays;
446
447#if 0
448        // set flags
449        VssRayContainer::const_iterator rit, rit_end = vssRays.end();
450        for (rit = vssRays.begin(); rit != rit_end; ++ rit, ++ i)
451                (*rit)->mFlags |= VssRay::BorderSample;
452#endif
453
454        int castRays = (int)simpleRays.size();
455
456        VssRayContainer invalidSamples;
457
458        // handle rays
459        EnqueueRays(vssRays, invalidSamples);
460
461    // recursivly subdivide each edge
462        for (int i = 0; i < numBorderSamples; ++ i)
463        {
464                castRays += SubdivideEdge(hitTriangle,
465                                                                  enlargedTriangle[i],
466                                                                  enlargedTriangle[(i + 1) % numBorderSamples],
467                                                                  *vssRays[i],
468                                                                  *vssRays[(i + 1) % numBorderSamples],
469                                                                  currentRay);
470        }
471       
472        mGvsStats.mBorderSamples += castRays;
473
474        //CLEAR_CONTAINER(invalidSamples);
475       
476        //cout << "here3 cast rays: " << castRays << endl;
477        return castRays;
478}
479
480
481bool GvsPreprocessor::GetPassingPoint(const VssRay &currentRay,
482                                                                          const Triangle3 &occluder,
483                                                                          const VssRay &oldRay,
484                                                                          Vector3 &newPoint) const
485{
486        //-- The plane p = (xp, hit(x), hit(xold)) is intersected
487        //-- with the newly found occluder (xold is the previous ray from
488        //-- which x was generated). On the intersecting line, we select a point
489        //-- pnew which lies just outside of the new triangle so the ray
490        //-- just passes through the gap
491
492        const Plane3 plane(currentRay.GetOrigin(),
493                                           currentRay.GetTermination(),
494                                           oldRay.GetTermination());
495       
496        Vector3 pt1, pt2;
497
498        const bool intersects = occluder.GetPlaneIntersection(plane, pt1, pt2);
499
500        if (!intersects)
501        {
502                //cerr << "big error!! no intersection " << pt1 << " " << pt2 << endl;
503                return false;
504        }
505
506        // get the intersection point on the old ray
507        const Plane3 triPlane(occluder.GetNormal(), occluder.mVertices[0]);
508
509        const float t = triPlane.FindT(oldRay.mOrigin, oldRay.mTermination);
510        const Vector3 pt3 = oldRay.mOrigin + t * (oldRay.mTermination - oldRay.mOrigin);
511
512        // Evaluate new hitpoint just outside the triangle
513        const float eps = mEps;
514
515        // the point is chosen to be on the side closer to the original ray
516        if (Distance(pt1, pt3) < Distance(pt2, pt3))
517                newPoint = pt1 + eps * (pt1 - pt2);
518        else
519                newPoint = pt2 + eps * (pt2 - pt1);
520
521        //cout << "passing point: " << newPoint << endl << endl;
522        return true;
523}
524
525
526VssRay *GvsPreprocessor::ReverseSampling(const VssRay &currentRay,
527                                                                                 const Triangle3 &hitTriangle,
528                                                                                 const VssRay &oldRay)
529{
530        // get triangle occluding the path to the hit mesh
531        Triangle3 occluder;
532        Intersectable *tObj = currentRay.mTerminationObject;
533
534        // q: why can this happen?
535        if (!tObj)
536                return NULL;
537
538        // other types not implemented yet
539        if (tObj->Type() == Intersectable::TRIANGLE_INTERSECTABLE)
540        {
541                occluder = static_cast<TriangleIntersectable *>(tObj)->GetItem();
542        }
543        else
544        {
545                cout << "reverse sampling: " << tObj->Type() << " not yet implemented" << endl;
546        }
547        // get a point which is passing just outside of the occluder
548    Vector3 newPoint;
549
550        // why is there sometimes no intersecton found?
551        if (!GetPassingPoint(currentRay, occluder, oldRay, newPoint))
552                return NULL;
553
554        const Vector3 predicted = CalcPredictedHitPoint(currentRay, hitTriangle, oldRay);
555
556        Vector3 newDir, newOrigin;
557
558        //-- Construct the mutated ray with xnew,
559        //-- dir = predicted(x)- pnew as direction vector
560        newDir = predicted - newPoint;
561
562        // take xnew, p = intersect(viewcell, line(pnew, predicted(x)) as origin ?
563        // difficult to say!!
564        const float offset = 0.5f;
565        newOrigin = newPoint - newDir * offset;
566       
567
568        //////////////
569        //-- for per view cell sampling, we must check for intersection
570        //-- with the current view cell
571
572    if (mPerViewCell)
573        {
574                // send ray to view cell
575                static Ray ray;
576                ray.Clear();
577                ray.Init(newOrigin, -newDir, Ray::LOCAL_RAY);
578               
579                //cout << "z";
580                // check if ray intersects view cell
581                if (!mCurrentViewCell->CastRay(ray))
582                        return NULL;
583
584                Ray::Intersection &hit = ray.intersections[0];
585       
586                //cout << "q";
587                // the ray starts from the view cell
588                newOrigin = ray.Extrap(hit.mT);
589        }
590
591        const SimpleRay simpleRay(newOrigin, newDir, SamplingStrategy::GVS, 1.0f);
592
593        VssRay *reverseRay =
594                mRayCaster->CastRay(simpleRay, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell);
595
596    ++ mGvsStats.mReverseSamples;
597
598        return reverseRay;
599}
600
601
602int GvsPreprocessor::CastInitialSamples(int numSamples)
603{       
604        const long startTime = GetTime();
605
606        // generate simple rays
607        SimpleRayContainer simpleRays;
608       
609        ViewCellBorderBasedDistribution vcStrat(*this, mCurrentViewCell);
610    GenerateRays(numSamples, *mDistribution, simpleRays);
611
612        //cout << "sr: " << simpleRays.size() << endl;
613        // generate vss rays
614        VssRayContainer samples;
615       
616        const bool castDoubleRays = !mPerViewCell;
617        const bool pruneInvalidRays = true;
618       
619        CastRays(simpleRays, samples, castDoubleRays, pruneInvalidRays);
620       
621        VssRayContainer invalidSamples;
622
623        // add to ray queue
624        EnqueueRays(samples, invalidSamples);
625
626        //CLEAR_CONTAINER(invalidSamples);
627        //Debug << "generated " <<  numSamples << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl;
628        return (int)simpleRays.size();
629}
630
631
632void GvsPreprocessor::EnqueueRays(VssRayContainer &samples, VssRayContainer &invalidSamples)
633{
634        // add samples to ray queue
635        VssRayContainer::const_iterator vit, vit_end = samples.end();
636        for (vit = samples.begin(); vit != vit_end; ++ vit)
637        {
638                VssRay *ray = *vit;
639
640                HandleRay(ray);
641                //if (!HandleRay(ray)) invalidSamples.push_back(ray);
642        }
643}
644
645
646int GvsPreprocessor::ProcessQueue()
647{
648        ++ mGvsStats.mGvsPass;
649
650        int castSamples = 0;
651
652        while (!mRayQueue.empty())//&& (mGvsStats.mTotalSamples + castSamples < mTotalSamples) )
653        {
654                // handle next ray
655                VssRay *ray = mRayQueue.top();
656                mRayQueue.pop();
657               
658                const int newSamples = AdaptiveBorderSampling(*ray);
659
660                castSamples += newSamples;
661                // note: don't have to delete because handled by ray pool
662        }
663
664        /*if (mRayCaster->mVssRayPool.mIndex > mSamplesPerPass)
665        {
666                cout << "warning: new samples: " << castSamples << " " << "queue: "  << (int)mRayQueue.size() << endl;
667                Debug << "warning: new samples: " << castSamples << " " << "queue: "  << (int)mRayQueue.size() << endl;
668        }*/
669
670        return castSamples;
671}
672
673
674void ExportVssRays(Exporter *exporter, const VssRayContainer &vssRays)
675{
676        VssRayContainer vcRays, vcRays2, vcRays3;
677
678        VssRayContainer::const_iterator rit, rit_end = vssRays.end();
679
680        // prepare some rays for output
681        for (rit = vssRays.begin(); rit != rit_end; ++ rit)
682        {
683                //const float p = RandomValue(0.0f, (float)vssRays.size());
684
685                if (1)//(p < raysOut)
686                {
687                        if ((*rit)->mFlags & VssRay::BorderSample)
688                        {
689                                vcRays.push_back(*rit);
690                        }
691                        else if ((*rit)->mFlags & VssRay::ReverseSample)
692                        {
693                                vcRays2.push_back(*rit);
694                        }
695                        else
696                        {
697                                vcRays3.push_back(*rit);
698                        }       
699                }
700        }
701
702        exporter->ExportRays(vcRays, RgbColor(1, 0, 0));
703        exporter->ExportRays(vcRays2, RgbColor(0, 1, 0));
704        exporter->ExportRays(vcRays3, RgbColor(1, 1, 1));
705}
706
707
708void GvsPreprocessor::VisualizeViewCell(const ObjectContainer &objects)
709{
710    Intersectable::NewMail();
711        Material m;
712       
713        char str[64]; sprintf(str, "pass%06d.wrl", mProcessedViewCells);
714
715        Exporter *exporter = Exporter::GetExporter(str);
716        if (!exporter)
717                return;
718
719        ObjectContainer::const_iterator oit, oit_end = objects.end();
720
721        for (oit = objects.begin(); oit != oit_end; ++ oit)
722        {
723                Intersectable *intersect = *oit;
724               
725                m = RandomMaterial();
726                exporter->SetForcedMaterial(m);
727                exporter->ExportIntersectable(intersect);
728        }
729
730        cout << "vssrays: " << (int)mVssRays.size() << endl;
731        ExportVssRays(exporter, mVssRays);
732
733
734        /////////////////
735        //-- export view cell geometry
736
737        //exporter->SetWireframe();
738
739        m.mDiffuseColor = RgbColor(0, 1, 0);
740        exporter->SetForcedMaterial(m);
741
742        AxisAlignedBox3 bbox = mCurrentViewCell->GetMesh()->mBox;
743        exporter->ExportBox(bbox);
744        //exporter->SetFilled();
745
746        delete exporter;
747}
748
749
750void GvsPreprocessor::VisualizeViewCells()
751{
752        char str[64]; sprintf(str, "tmp/pass%06d_%04d-", mProcessedViewCells, mPass);
753                       
754        // visualization
755        if (mGvsStats.mPassContribution > 0)
756        {
757                const bool exportRays = true;
758                const bool exportPvs = true;
759
760                mViewCellsManager->ExportSingleViewCells(mObjects,
761                                                                                                 10,
762                                                                                                 false,
763                                                                                                 exportPvs,
764                                                                                                 exportRays,
765                                                                                                 1000,
766                                                                                                 str);
767        }
768
769        // remove pass samples
770        ViewCellContainer::const_iterator vit, vit_end = mViewCellsManager->GetViewCells().end();
771
772        for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit)
773        {
774                (*vit)->DelRayRefs();
775        }
776}
777
778
779void GvsPreprocessor::CompileViewCellsFromPointList()
780{
781        ViewCell::NewMail();
782
783        // Receive list of view cells from view cells manager
784        ViewCellPointsList *vcPoints = mViewCellsManager->GetViewCellPointsList();
785
786        vector<ViewCellPoints *>::const_iterator vit, vit_end = vcPoints->end();
787
788        for (vit = vcPoints->begin(); vit != vit_end; ++ vit)
789        {
790                ViewCellPoints *vp = *vit;
791
792                if (vp->first) // view cell  specified
793                {
794                        ViewCell *viewCell = vp->first;
795
796                        if (!viewCell->Mailed())
797                        {
798                                viewCell->Mail();
799                                mViewCells.push_back(viewCell);
800
801                                if (mViewCells.size() >= mMaxViewCells)
802                                        break;
803                        }
804                }
805                else // no view cell specified => compute view cells using view point
806                {
807                        SimpleRayContainer::const_iterator rit, rit_end = vp->second.end();
808
809                        for (rit = vp->second.begin(); rit != rit_end; ++ rit)
810                        {
811                                SimpleRay ray = *rit;
812
813                                ViewCell *viewCell = mViewCellsManager->GetViewCell(ray.mOrigin);
814
815                                if (viewCell && !viewCell->Mailed())
816                                {
817                                        viewCell->Mail();
818                                        mViewCells.push_back(viewCell);
819
820                                        if (mViewCells.size() >= mMaxViewCells)
821                                                break;
822                                }
823                        }
824                }
825        }
826}
827
828
829void GvsPreprocessor::CompileViewCellsList()
830{
831        if (!mViewCellsManager->GetViewCellPointsList()->empty())
832        {
833                cout << "processing view point list" << endl;
834                CompileViewCellsFromPointList();
835        }
836        else
837        {
838                ViewCell::NewMail();
839
840                while ((int)mViewCells.size() < mMaxViewCells)
841                {
842                        const int tries = 10000;
843                        int i = 0;
844
845                        for (i = 0; i < tries; ++ i)
846                        {
847                                const int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f);
848
849                                ViewCell *viewCell = mViewCellsManager->GetViewCell(idx);
850
851                                if (!viewCell->Mailed())
852                                {
853                                        viewCell->Mail();
854                                        break;
855                                }
856
857                                mViewCells.push_back(viewCell);
858                        }
859
860                        if (i == tries)
861                        {
862                                cerr << "big error! no view cell found" << endl;
863                                break;
864                        }
865                }
866        }
867
868        cout << "\ncomputing list of " << mViewCells.size() << " view cells" << endl;
869}
870
871
872void GvsPreprocessor::IntersectWithViewCell()
873{
874        AxisAlignedBox3 box = mCurrentViewCell->GetBox();
875
876        int oldTrianglePvs = (int)mTrianglePvs.size();
877        int newKdObj = 0;
878
879        // compute pvs kd nodes that intersect view cell
880        ObjectContainer kdobjects;
881
882        // find intersecting objects not in pvs (i.e., only unmailed)
883        mKdTree->CollectKdObjects(box, kdobjects);
884
885        ObjectContainer pvsKdObjects;
886
887        ObjectContainer::const_iterator oit, oit_end = kdobjects.end();
888
889        for (oit = kdobjects.begin(); oit != oit_end; ++ oit)
890        {
891        KdIntersectable *kdInt = static_cast<KdIntersectable *>(*oit);
892       
893                myobjects.clear();
894                mKdTree->CollectObjectsWithDublicates(kdInt->GetItem(), myobjects);
895
896                // account for kd object pvs
897                bool addkdobj = false;
898
899                ObjectContainer::const_iterator oit, oit_end = myobjects.end();
900
901                for (oit = myobjects.begin(); oit != oit_end; ++ oit)
902                {
903                        TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit);
904             
905                        // test if the triangle itself intersects
906                        if (box.Intersects(triObj->GetItem()))
907                                addkdobj = AddTriangleObject(triObj);
908                }
909               
910                // add node to kd pvs
911                if (1 && addkdobj)
912                {
913                        ++ newKdObj;
914                        mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f);
915                        //mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f);
916                        if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt);
917                }
918        }
919
920        cout << "added " << (int)mTrianglePvs.size() - oldTrianglePvs << " triangles (" << newKdObj << " objects) by intersection" << endl;
921}
922
923
924void GvsPreprocessor::PerViewCellComputation()
925{
926        while (mCurrentViewCell = NextViewCell())
927        {
928                // hack: reset counters
929                ObjectContainer::const_iterator oit, oit_end = mObjects.end();
930
931                for (oit = mObjects.begin(); oit != oit_end; ++ oit)
932                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT;
933
934                mDistribution->SetViewCell(mCurrentViewCell);
935        ComputeViewCell();
936        }
937}
938
939
940void GvsPreprocessor::PerViewCellComputation2()
941{
942        while (1)
943        {
944                if (!mRendererWidget)
945                        continue;
946
947        mCurrentViewCell = mViewCellsManager->GetViewCell(mRendererWidget->GetViewPoint());
948
949                // no valid view cell or view cell already computed
950                if (!mCurrentViewCell || !mCurrentViewCell->GetPvs().Empty() || !mRendererWidget->mComputeGVS)
951                        continue;
952
953                mRendererWidget->mComputeGVS = false;
954                // hack: reset counters
955                ObjectContainer::const_iterator oit, oit_end = mObjects.end();
956
957                for (oit = mObjects.begin(); oit != oit_end; ++ oit)
958                        (*oit)->mCounter = NOT_ACCOUNTED_OBJECT;
959
960                ComputeViewCell();
961                ++ mProcessedViewCells;
962        }
963}
964
965
966void GvsPreprocessor::StorePvs(const ObjectContainer &objectPvs)
967{
968        ObjectContainer::const_iterator oit, oit_end = objectPvs.end();
969
970        for (oit = objectPvs.begin(); oit != oit_end; ++ oit)
971        {
972                mCurrentViewCell->GetPvs().AddSample(*oit, 1);
973        }
974}
975
976
977void GvsPreprocessor::UpdatePvs(ViewCell *currentViewCell)
978{
979        ObjectPvs newPvs;
980        BvhLeaf::NewMail();
981
982        ObjectPvsIterator pit = currentViewCell->GetPvs().GetIterator();
983
984        // output PVS of view cell
985        while (pit.HasMoreEntries())
986        {               
987                Intersectable *intersect = pit.Next();
988
989                BvhLeaf *bv = intersect->mBvhLeaf;
990
991                if (!bv || bv->Mailed())
992                        continue;
993               
994                bv->Mail();
995
996                //m.mDiffuseColor = RgbColor(1, 0, 0);
997                newPvs.AddSampleDirty(bv, 1.0f);
998        }
999
1000        newPvs.SimpleSort();
1001
1002        currentViewCell->SetPvs(newPvs);
1003}
1004
1005 
1006void GvsPreprocessor::GetObjectPvs(ObjectContainer &objectPvs) const
1007{
1008        objectPvs.reserve((int)mTrianglePvs.size());
1009
1010        BvhLeaf::NewMail();
1011
1012        ObjectContainer::const_iterator oit, oit_end = mTrianglePvs.end();
1013
1014        for (oit = mTrianglePvs.begin(); oit != oit_end; ++ oit)
1015        {
1016                Intersectable *intersect = *oit;
1017       
1018                BvhLeaf *bv = intersect->mBvhLeaf;
1019
1020                // hack: reset counter
1021                (*oit)->mCounter = NOT_ACCOUNTED_OBJECT;
1022
1023                if (!bv || bv->Mailed())
1024                        continue;
1025
1026                bv->Mail();
1027                objectPvs.push_back(bv);
1028        }
1029}
1030
1031
1032void GvsPreprocessor::GlobalComputation()
1033{
1034        int passSamples = 0;
1035        int oldContribution = 0;
1036
1037        while (mGvsStats.mTotalSamples < mTotalSamples)
1038        {
1039                mRayCaster->InitPass();
1040
1041                // Ray queue empty =>
1042                // cast a number of uniform samples to fill ray queue
1043                int newSamples = CastInitialSamples(mInitialSamples);
1044
1045                if (!mOnlyRandomSampling)
1046                        newSamples += ProcessQueue();
1047
1048                passSamples += newSamples;
1049                mGvsStats.mTotalSamples += newSamples;
1050
1051                if (passSamples % (mGvsSamplesPerPass + 1) == mGvsSamplesPerPass)
1052                {
1053                        ++ mPass;
1054
1055                        mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution;
1056
1057                        ////////
1058                        //-- stats
1059
1060                        //cout << "\nPass " << mPass << " #samples: " << mGvsStats.mTotalSamples << " of " << mTotalSamples << endl;
1061                        mGvsStats.mPass = mPass;
1062                        mGvsStats.Stop();
1063                        mGvsStats.Print(mGvsStatsStream);
1064
1065                        // reset
1066                        oldContribution = mGvsStats.mTotalContribution;
1067                        mGvsStats.mPassContribution = 0;
1068                        passSamples = 0;
1069
1070                        if (GVS_DEBUG)
1071                                VisualizeViewCells();
1072                }
1073        }
1074}
1075
1076
1077bool GvsPreprocessor::ComputeVisibility()
1078{
1079        cout << "Gvs Preprocessor started\n" << flush;
1080        const long startTime = GetTime();
1081
1082        //Randomize(0);
1083        mGvsStats.Reset();
1084        mGvsStats.Start();
1085
1086        if (!mLoadViewCells)
1087        {       
1088                /// construct the view cells from the scratch
1089                ConstructViewCells();
1090                // reset pvs already gathered during view cells construction
1091                mViewCellsManager->ResetPvs();
1092                cout << "finished view cell construction" << endl;
1093        }
1094
1095        if (mPerViewCell)
1096        {
1097#if 1
1098                // provide list of view cells to compute
1099                CompileViewCellsList();
1100
1101                // start per view cell gvs
1102                PerViewCellComputation();
1103#else
1104                PerViewCellComputation2();
1105
1106#endif
1107        }
1108        else
1109        {
1110                GlobalComputation();
1111        }
1112
1113        cout << "cast " << mGvsStats.mTotalSamples / (1e3f * TimeDiff(startTime, GetTime())) << "M single rays/s" << endl;
1114
1115        if (GVS_DEBUG)
1116        {
1117                Visualize();
1118                CLEAR_CONTAINER(mVssRays);
1119        }
1120       
1121        // export the preprocessed information to a file
1122        if (0 && mExportVisibility)
1123        {
1124                ExportPreprocessedData(mVisibilityFileName);
1125        }
1126       
1127        // compute the pixel error of this visibility solution
1128        if (mEvaluatePixelError)
1129        {
1130                ComputeRenderError();
1131        }
1132
1133        return true;
1134}
1135
1136
1137void GvsPreprocessor::DeterminePvsObjects(VssRayContainer &rays)
1138{
1139        // store triangle directly
1140        mViewCellsManager->DeterminePvsObjects(rays, true);
1141}
1142
1143
1144void GvsPreprocessor::Visualize()
1145{
1146        Exporter *exporter = Exporter::GetExporter("gvs.wrl");
1147
1148        if (!exporter)
1149                return;
1150       
1151        vector<VizStruct>::const_iterator vit, vit_end = vizContainer.end();
1152       
1153        for (vit = vizContainer.begin(); vit != vit_end; ++ vit)
1154        {
1155                exporter->SetWireframe();
1156                exporter->ExportPolygon((*vit).enlargedTriangle);
1157                //Material m;
1158                exporter->SetFilled();
1159                Polygon3 poly = Polygon3((*vit).originalTriangle);
1160                exporter->ExportPolygon(&poly);
1161        }
1162
1163        VssRayContainer::const_iterator rit, rit_end = mVssRays.end();
1164
1165        for (rit = mVssRays.begin(); rit != rit_end; ++ rit)
1166        {
1167                Intersectable *obj = (*rit)->mTerminationObject;
1168                exporter->ExportIntersectable(obj);
1169        }
1170
1171        ExportVssRays(exporter, mVssRays);
1172       
1173        delete exporter;
1174}
1175
1176
1177void GvsStatistics::Print(ostream &app) const
1178{
1179        app << "#ViewCells\n" << mViewCells << endl;
1180        app << "#Id\n" << mViewCellId << endl;
1181        app << "#Time\n" << mTimePerViewCell << endl;;
1182        app << "#TriPvs\n" << mTrianglePvs << endl;
1183        app << "#ObjectPvs\n" << mPerViewCellPvs << endl;
1184        app << "#UpdatedPvs\n" << (int)mPvsCost << endl;
1185
1186        app << "#PerViewCellSamples\n" << mPerViewCellSamples << endl;
1187        app << "#RaysPerSec\n" << RaysPerSec() << endl;
1188       
1189        app << "#TotalPvs\n" << mTotalPvs << endl;
1190        app << "#TotalTime\n" << mTotalTime << endl;
1191        app << "#TotalSamples\n" << mTotalSamples << endl;
1192
1193        app << "#TotalTrianglePvs\n" << mTotalTrianglePvs << endl;
1194       
1195        if (0)
1196        {
1197                app << "#ReverseSamples\n" << mReverseSamples << endl;
1198                app << "#BorderSamples\n" << mBorderSamples << endl;
1199
1200                app << "#Pass\n" << mPass << endl;
1201                app << "#ScDiff\n" << mPassContribution << endl;
1202                app << "#GvsRuns\n" << mGvsPass << endl;       
1203
1204                app     << "#SamplesContri\n" << mTotalContribution << endl;
1205        }
1206
1207        app << endl;
1208}
1209
1210
1211void GvsPreprocessor::ComputeViewCell()
1212{
1213        mCurrentViewCell->GetMesh()->ComputeBoundingBox();
1214
1215        KdNode::NewMail();
1216
1217        const long startTime = GetTime();
1218
1219        cout << "\n***********************\n"
1220                << "computing view cell " << mProcessedViewCells
1221                << " (id: " << mCurrentViewCell->GetId() << ")" << endl;
1222        cout << "bb: " << mCurrentViewCell->GetBox() << endl;
1223
1224        mGvsStats.mPerViewCellSamples = 0;
1225
1226        int oldContribution = mGvsStats.mTotalContribution;
1227        int passSamples = 0;
1228
1229        for (int i = 0; i < 0; ++ i)
1230                mGenericStats[i] = 0;
1231
1232        while (1)
1233        {
1234                int oldPvsSize = mCurrentViewCell->GetPvs().GetSize();
1235
1236                mRayCaster->InitPass();
1237
1238                // Ray queue empty =>
1239                // cast a number of uniform samples to fill ray queue
1240                int newSamples = CastInitialSamples(mInitialSamples);
1241
1242                if (!mOnlyRandomSampling)
1243                {
1244                        int samplesPerRun = ProcessQueue();
1245                        newSamples += samplesPerRun;
1246                        //if (samplesPerRun > 0) cout << "spr: " << samplesPerRun << " ";
1247                }
1248
1249                passSamples += newSamples;
1250        mGvsStats.mPerViewCellSamples += newSamples;
1251
1252                if (passSamples >= mGvsSamplesPerPass)
1253                {
1254                        if (GVS_DEBUG) VisualizeViewCell(mTrianglePvs);
1255
1256                        //const bool convertPerPass = true;
1257                        const bool convertPerPass = false;
1258
1259                        if (convertPerPass)
1260                        {       
1261                                int newObjects = ConvertObjectPvs();
1262
1263                                cout << "added " << newObjects << " triangles to triangle pvs" << endl;
1264                                mGvsStats.mTotalContribution += newObjects;
1265                        }
1266
1267                        ++ mPass;
1268                        mGvsStats.mPassContribution = mGvsStats.mTotalContribution - oldContribution;
1269
1270
1271                        ////////
1272                        //-- stats
1273
1274                        mGvsStats.mPass = mPass;
1275
1276                        cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl;
1277                        cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl;
1278                        cout << "obj contri=" << mCurrentViewCell->GetPvs().GetSize() - oldPvsSize << " (of " << mMinContribution << ")" << endl;
1279
1280                        // termination criterium
1281                        if (mGvsStats.mPassContribution < mMinContribution)
1282                                break;
1283
1284                        // reset
1285                        oldContribution = mGvsStats.mTotalContribution;
1286                        mGvsStats.mPassContribution = 0;
1287                        passSamples = 0;
1288                }
1289        }
1290       
1291        // at last compute objects that directly intersect view cell
1292        IntersectWithViewCell();
1293
1294               
1295        ////////
1296        //-- stats
1297
1298        // timing
1299        mGvsStats.mTimePerViewCell = TimeDiff(startTime, GetTime()) * 1e-3f;
1300
1301        ComputeStats();
1302
1303        // clean up
1304        mTrianglePvs.clear();
1305}
1306
1307
1308void GvsPreprocessor::ComputeStats()
1309{
1310        // compute pvs size using larger (bvh objects)
1311        // note: for kd pvs we had to do this during gvs computation
1312
1313        if (!mUseKdPvs)
1314        {
1315                ObjectContainer objectPvs;
1316
1317                // optain object pvs
1318                GetObjectPvs(objectPvs);
1319
1320                // add pvs
1321                ObjectContainer::const_iterator it, it_end = objectPvs.end();
1322
1323                for (it = objectPvs.begin(); it != it_end; ++ it)
1324                {
1325                        mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f);
1326                }
1327
1328                cout << "triangle pvs of " << (int)mTrianglePvs.size()
1329                        << " was converted to object pvs of " << (int)objectPvs.size() << endl;
1330
1331                mGvsStats.mPerViewCellPvs = (int)objectPvs.size();
1332                mGvsStats.mPvsCost = 0; // todo objectPvs.EvalPvsCost();
1333        }
1334        else if (0)
1335        {
1336                //KdNode::NewMail();
1337
1338                // compute pvs kd nodes that intersect view cell
1339                ObjectContainer mykdobjects;
1340
1341                // extract kd pvs
1342                ObjectContainer::const_iterator it, it_end = mTrianglePvs.end();
1343
1344                for (it = mTrianglePvs.begin(); it != it_end; ++ it)
1345                {
1346                        Intersectable *obj = *it;
1347                        // find intersecting objects not yet in pvs (i.e., only unmailed)
1348                        mKdTree->CollectKdObjects(obj->GetBox(), mykdobjects);
1349                }
1350
1351                // add pvs
1352                it_end = mykdobjects.end();
1353
1354                for (it = mykdobjects.begin(); it != it_end; ++ it)
1355                {
1356                        mCurrentViewCell->GetPvs().AddSampleDirty(*it, 1.0f);
1357                }
1358
1359                cout << "added " << (int)mykdobjects.size() << " new objects " << endl;
1360
1361                mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize();
1362                mGvsStats.mPvsCost = mCurrentViewCell->GetPvs().EvalPvsCost();
1363
1364        }
1365
1366        mGvsStats.mTrianglePvs = (int)mTrianglePvs.size();
1367
1368
1369        ////////////////
1370        // global values
1371
1372        mGvsStats.mViewCells = mProcessedViewCells;
1373        mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs;
1374        mGvsStats.mTotalTime += mGvsStats.mTimePerViewCell;
1375    mGvsStats.mTotalPvs += mGvsStats.mPerViewCellPvs;
1376        mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples;
1377
1378        mGvsStats.Stop();
1379        mGvsStats.Print(mGvsStatsStream);
1380
1381        cout << "id: " << mCurrentViewCell->GetId() << " pvs cost: "
1382             << mGvsStats.mPvsCost << " pvs tri: " << mTrianglePvs.size() << endl;
1383}
1384
1385
1386ObjectContainer triangles;
1387
1388int GvsPreprocessor::ConvertObjectPvs()
1389{
1390        int newObjects = 0;
1391
1392        ObjectPvsIterator pit = mCurrentViewCell->GetPvs().GetIterator();
1393
1394        triangles.clear();
1395
1396        // output PVS of view cell
1397        while (pit.HasMoreEntries())
1398        {               
1399                KdIntersectable *kdInt = static_cast<KdIntersectable *>(pit.Next());
1400
1401                mKdTree->CollectObjectsWithDublicates(kdInt->GetItem(), triangles);
1402
1403                ObjectContainer::const_iterator oit, oit_end = triangles.end();
1404
1405                for (oit = triangles.begin(); oit != oit_end; ++ oit)
1406                {
1407                        if (AddTriangleObject(*oit))
1408                                ++ newObjects;
1409                }
1410        }
1411
1412        return newObjects;
1413}
1414
1415
1416bool GvsPreprocessor::AddTriangleObject(Intersectable *triObj)
1417{
1418        if ((triObj->mCounter < ACCOUNTED_OBJECT))
1419        {
1420                triObj->mCounter += ACCOUNTED_OBJECT;
1421
1422                mTrianglePvs.push_back(triObj);
1423                mGenericStats[0] = (int)mTrianglePvs.size();
1424                return true;
1425        }
1426
1427        return false;
1428}
1429
1430
1431
1432}
Note: See TracBrowser for help on using the repository browser.