~ubuntu-branches/ubuntu/intrepid/blender/intrepid-updates

« back to all changes in this revision

Viewing changes to extern/qdune/primitives/Patches.h

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-08-08 02:45:40 UTC
  • mfrom: (12.1.14 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080808024540-kkjp7ekfivzhuw3l
Tags: 2.46+dfsg-4
* Fix python syntax warning in import_dxf.py, which led to nasty output
  in installation/upgrade logs during byte-compilation, using a patch
  provided by the script author (Closes: #492280):
   - debian/patches/45_fix_python_syntax_warning

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//----------------------------------------------
 
2
// Bilinear/bicubic patches & patch meshes
 
3
//----------------------------------------------
 
4
 
 
5
#ifndef _PATCHES_H
 
6
#define _PATCHES_H
 
7
 
 
8
#include "Parametric.h"
 
9
#include "Polygons.h"
 
10
#include "qdVector.h"
 
11
 
 
12
#include "QDRender.h"
 
13
__BEGIN_QDRENDER
 
14
 
 
15
//------------------------------------------------------------------------------
 
16
// BilinearPatch
 
17
 
 
18
class BilinearPatch : public Parametric
 
19
{
 
20
public:
 
21
        BilinearPatch();
 
22
        BilinearPatch(RtInt n, RtToken tokens[], RtPointer parms[]);
 
23
        // only used for polygon & patchmesh splitting
 
24
        BilinearPatch(const Primitive& p, const RtPoint p0, const RtPoint p1,
 
25
                                                                                                                                                const RtPoint p2, const RtPoint p3);
 
26
        virtual ~BilinearPatch();
 
27
 
 
28
        virtual void post_init();
 
29
 
 
30
        virtual Bound bound();
 
31
        virtual Parametric* duplicateSelf() { return new BilinearPatch(*this); }
 
32
 
 
33
        virtual bool in_camspace() const { return true; }
 
34
 
 
35
protected:
 
36
        virtual void eval(float u, float v, RtPoint P, RtVector dPdu=NULL, RtVector dPdv=NULL) const;
 
37
        // control points
 
38
        RtPoint hull[4];
 
39
};
 
40
 
 
41
//------------------------------------------------------------------------------
 
42
// BilinearPatchMesh
 
43
// only splits the patchmesh into its individual patches, dice() never called
 
44
 
 
45
class BilinearPatchMesh : public Primitive
 
46
{
 
47
public:
 
48
        BilinearPatchMesh(RtInt nu, bool uperiodic, RtInt nv, bool vperiodic,
 
49
                                                                                RtInt n, RtToken tokens[], RtPointer parms[]);
 
50
        virtual ~BilinearPatchMesh();
 
51
        virtual void post_init() {}
 
52
        virtual bool boundable() { return true; }
 
53
        virtual Bound bound();
 
54
        virtual bool splitable() { return true; }
 
55
        virtual void split(const Framework &f, bool usplit, bool vsplit, splitbprims_t* spb=NULL);
 
56
        virtual bool diceable(MicroPolygonGrid &g, Hider &h, bool &usplit, bool &vsplit) { return false; }
 
57
        virtual void dice(MicroPolygonGrid &g, bool Pclose=false);
 
58
protected:
 
59
        // data
 
60
        RtFloat* pts; // RtFloat here, since besides 'P', data could also be 'Pz' or 'Pw'
 
61
        bool uperiodic, vperiodic;
 
62
        float du, dv;
 
63
        int nu, nv, nupatches, nvpatches, nuvarying, nvvarying;
 
64
        int mtype, num_verts; // mtype will be one of (0, 1, 2) for P/Pz/Pw respectivly
 
65
};
 
66
 
 
67
// helper function, split data for new patch, also called by Polygons.cpp
 
68
void splitPrimVars(const Primitive* parent, Primitive* newp,
 
69
                   int uni_idx, int vary_idx[4], int* vert_idx, bool cubic=false);
 
70
 
 
71
//------------------------------------------------------------------------------
 
72
// BicubicPatch
 
73
 
 
74
class BicubicPatch : public Primitive
 
75
{
 
76
        friend class SDPatch;
 
77
        friend class JS_SDPatch;
 
78
public:
 
79
        BicubicPatch();
 
80
        // only used for splitting patchmesh
 
81
        BicubicPatch(const Primitive& p, const Point3 _hull[16]);
 
82
        BicubicPatch(RtInt n, RtToken tokens[], RtPointer parms[]);
 
83
        virtual ~BicubicPatch();
 
84
        virtual void post_init();
 
85
 
 
86
        virtual bool boundable() { return true; }
 
87
        virtual Bound bound();
 
88
 
 
89
        virtual bool splitable() { return true; }
 
90
        virtual void split(const Framework &f, bool usplit, bool vsplit, splitbprims_t* spb=NULL);
 
91
        virtual bool diceable(MicroPolygonGrid &g, Hider &h, bool &usplit, bool &vsplit);
 
92
        virtual void dice(MicroPolygonGrid &g, bool Pclose=false);
 
93
 
 
94
        Primitive* duplicateSelf();
 
95
 
 
96
        virtual bool in_camspace() const { return true; }
 
97
 
 
98
        virtual void get_uvlim(float uvl[4]) const { uvl[0] = umin, uvl[1] = umax, uvl[2] = vmin, uvl[3] = vmax; }
 
99
 
 
100
protected:
 
101
        RtPoint hull[16];
 
102
        float umin, umax, vmin, vmax;
 
103
        bool subd_bspline;
 
104
};
 
105
 
 
106
//------------------------------------------------------------------------------
 
107
// BicubicPatchMesh
 
108
// only splits the patchmesh into its individual patches, dice() is never called
 
109
 
 
110
class BicubicPatchMesh : public Primitive
 
111
{
 
112
public:
 
113
        BicubicPatchMesh(RtInt nu, bool uperiodic, RtInt nv, bool vperiodic,
 
114
                                                                                RtInt n, RtToken tokens[], RtPointer parms[]);
 
115
        virtual ~BicubicPatchMesh();
 
116
        virtual void post_init() {}
 
117
        virtual bool boundable() { return true; }
 
118
        virtual Bound bound();
 
119
        virtual bool splitable() { return true; }
 
120
        virtual void split(const Framework &f, bool usplit, bool vsplit, splitbprims_t* spb=NULL);
 
121
        virtual bool diceable(MicroPolygonGrid &g, Hider &h, bool &usplit, bool &vsplit) { return false; }
 
122
        virtual void dice(MicroPolygonGrid &g, bool Pclose=false);
 
123
protected:
 
124
        RtFloat* pts; // RtFloat here, since besides 'P', data could also be 'Pz' or 'Pw'
 
125
        bool uperiodic, vperiodic;
 
126
        float du, dv;
 
127
        int nu, nv, ustep, vstep, nupatches, nvpatches, nuvarying, nvvarying;
 
128
        int mtype, num_verts; // mtype will be one of (0, 1, 2) for P/Pz/Pw respectivly
 
129
};
 
130
 
 
131
__END_QDRENDER
 
132
 
 
133
#endif // _PATCHES_H