00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #if defined(_MSC_VER)
00025 #pragma once
00026 #endif
00027
00028 #ifndef PBRT_SHAPES_LOOPSUBDIV_H
00029 #define PBRT_SHAPES_LOOPSUBDIV_H
00030
00031
00032 #include "shape.h"
00033 struct SDVertex;
00034 struct SDFace;
00035
00036
00037 class LoopSubdiv : public Shape {
00038 public:
00039
00040 LoopSubdiv(const Transform *o2w, const Transform *w2o, bool ro,
00041 int nt, int nv, const int *vi,
00042 const Point *P, int nlevels);
00043 ~LoopSubdiv();
00044 bool CanIntersect() const;
00045 void Refine(vector<Reference<Shape> > &refined) const;
00046 BBox ObjectBound() const;
00047 BBox WorldBound() const;
00048 private:
00049
00050 static float beta(int valence) {
00051 if (valence == 3) return 3.f/16.f;
00052 else return 3.f / (8.f * valence);
00053 }
00054 static Point weightOneRing(SDVertex *vert, float beta);
00055 static Point weightBoundary(SDVertex *vert, float beta);
00056 static float gamma(int valence) {
00057 return 1.f / (valence + 3.f / (8.f * beta(valence)));
00058 }
00059
00060
00061 int nLevels;
00062 vector<SDVertex *> vertices;
00063 vector<SDFace *> faces;
00064 };
00065
00066
00067 LoopSubdiv *CreateLoopSubdivShape(const Transform *o2w, const Transform *w2o,
00068 bool reverseOrientation, const ParamSet ¶ms);
00069
00070 #endif // PBRT_SHAPES_LOOPSUBDIV_H