Ptex
PtexSeparableFilter.h
Go to the documentation of this file.
1 #ifndef PtexSeparableFilter_h
2 #define PtexSeparableFilter_h
3 
4 /*
5 PTEX SOFTWARE
6 Copyright 2009 Disney Enterprises, Inc. All rights reserved
7 
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are
10 met:
11 
12  * Redistributions of source code must retain the above copyright
13  notice, this list of conditions and the following disclaimer.
14 
15  * Redistributions in binary form must reproduce the above copyright
16  notice, this list of conditions and the following disclaimer in
17  the documentation and/or other materials provided with the
18  distribution.
19 
20  * The names "Disney", "Walt Disney Pictures", "Walt Disney Animation
21  Studios" or the names of its contributors may NOT be used to
22  endorse or promote products derived from this software without
23  specific prior written permission from Walt Disney Pictures.
24 
25 Disclaimer: THIS SOFTWARE IS PROVIDED BY WALT DISNEY PICTURES AND
26 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
27 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
28 FOR A PARTICULAR PURPOSE, NONINFRINGEMENT AND TITLE ARE DISCLAIMED.
29 IN NO EVENT SHALL WALT DISNEY PICTURES, THE COPYRIGHT HOLDER OR
30 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND BASED ON ANY
34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
37 */
38 
39 #include "Ptexture.h"
40 
42 
43 class PtexSeparableFilter : public PtexFilter, public Ptex
44 {
45  public:
46  virtual void release() { delete this; }
47  virtual void eval(float* result, int firstchan, int nchannels,
48  int faceid, float u, float v,
49  float uw1, float vw1, float uw2, float vw2,
50  float width, float blur);
51 
52  protected:
54  _tx(tx), _options(opts), _result(0), _weight(0),
55  _firstChanOffset(0), _nchan(0), _ntxchan(0),
56  _dt((DataType)0), _uMode(tx->uBorderMode()), _vMode(tx->vBorderMode()) {}
57  virtual ~PtexSeparableFilter() {}
58 
59  virtual void buildKernel(PtexSeparableKernel& k, float u, float v, float uw, float vw,
60  Res faceRes) = 0;
61 
62  void splitAndApply(PtexSeparableKernel& k, int faceid, const Ptex::FaceInfo& f);
63  void applyAcrossEdge(PtexSeparableKernel& k, int faceid, const Ptex::FaceInfo& f, int eid);
64  void applyToCorner(PtexSeparableKernel& k, int faceid, const Ptex::FaceInfo& f, int eid);
65  void applyToCornerFace(PtexSeparableKernel& k, const Ptex::FaceInfo& f, int eid,
66  int cfaceid, const Ptex::FaceInfo& cf, int ceid);
67  void apply(PtexSeparableKernel& k, int faceid, const Ptex::FaceInfo& f);
68 
69  PtexTexture* _tx; // texture being evaluated
70  Options _options; // options
71  float* _result; // temp result
72  float _weight; // accumulated weight of data in _result
73  int _firstChanOffset; // byte offset of first channel to eval
74  int _nchan; // number of channels to eval
75  int _ntxchan; // number of channels in texture
76  DataType _dt; // data type of texture
77  BorderMode _uMode, _vMode; // border modes (clamp,black,periodic)
78 };
79 
80 #endif
PtexSeparableFilter(PtexTexture *tx, const PtexFilter::Options &opts)
void splitAndApply(PtexSeparableKernel &k, int faceid, const Ptex::FaceInfo &f)
void apply(PtexSeparableKernel &k, int faceid, const Ptex::FaceInfo &f)
Common data structures and enums used throughout the API.
Definition: Ptexture.h:73
virtual void eval(float *result, int firstchan, int nchannels, int faceid, float u, float v, float uw1, float vw1, float uw2, float vw2, float width, float blur)
Apply filter to a ptex data file.
virtual void release()
Release resources held by this pointer (pointer becomes invalid).
Pixel resolution of a given texture.
Definition: Ptexture.h:274
DataType
Type of data stored in texture file.
Definition: Ptexture.h:196
BorderMode
How to handle mesh border when filtering.
Definition: Ptexture.h:204
virtual void buildKernel(PtexSeparableKernel &k, float u, float v, float uw, float vw, Res faceRes)=0
void applyToCornerFace(PtexSeparableKernel &k, const Ptex::FaceInfo &f, int eid, int cfaceid, const Ptex::FaceInfo &cf, int ceid)
Interface for reading data from a ptex file.
Definition: Ptexture.h:439
Information about a face, as stored in the Ptex file header.
Definition: Ptexture.h:237
Choose filter options.
Definition: Ptexture.h:880
void applyAcrossEdge(PtexSeparableKernel &k, int faceid, const Ptex::FaceInfo &f, int eid)
void applyToCorner(PtexSeparableKernel &k, int faceid, const Ptex::FaceInfo &f, int eid)
Public API classes for reading, writing, caching, and filtering Ptex files.
Interface for filtered sampling of ptex data files.
Definition: Ptexture.h:861