HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GP_BilinearXform.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: Domain pasting Library (C++)
7  *
8  * COMMENTS: Bi-linear domain transformation class.
9  *
10  */
11 
12 #ifndef __GP_BilinearXform_h__
13 #define __GP_BilinearXform_h__
14 
15 #include "GP_API.h"
16 #include "GP_Xform.h"
17 #include <iosfwd>
18 
20 {
21 public:
22  // Class c-tors and d-tor.
23  GP_BilinearXform(const UT_BoundingRect *brect = 0);
24  GP_BilinearXform(const GP_BilinearXform &xform);
25  GP_BilinearXform(const GP_Point &a1, const GP_Point &a2,
26  const GP_Point &a3, const GP_Point &a4,
27  const GP_Point &b1, const GP_Point &b2,
28  const GP_Point &b3, const GP_Point &b4);
29  virtual ~GP_BilinearXform(void);
30 
31  // Apply this transformation to the data forward or backward:
32  // Return 0 if OK and -1 if error (eg. can't invert).
33  virtual int forward (GP_Point &p) const;
34  virtual int forward (GP_PointMatrix &m) const;
35  virtual int backward(GP_Point &p) const;
36  virtual int backward(GP_PointMatrix &m) const;
37 
38  // Set the transformation to identity:
39  virtual void reset(void);
40 
41  // Add a translation by delta to this transform:
42  virtual void translate(float dx, float dy);
43 
44  // Compose us with the given transformation. Return 0 if we cannot compress
45  // the composition. Otherwise return a pointer to the transformation, which
46  // will be us or a new xform of a different type.
47  virtual GP_Xform *compose(const GP_Xform &xform,
48  const UT_BoundingRect * = 0);
49  virtual GP_Xform *composeInverse(const GP_Xform &xform,
50  const UT_BoundingRect * = 0);
51 
52  // Copy your data from the other guy if both xforms have the same type.
53  // Return 0 if same type, else -1.
54  virtual int copyFrom(const GP_Xform &xform);
55 
56  // Return an inverse transformation. The first method allocates
57  // space for the object and return 0 if it fails somewhere. The second
58  // method returns the inverse in the reference provided as long as it's
59  // the appropriate type, and returns 0. If the xform is not the right type,
60  // or the inverse can't be computed, it returns -1.
61  virtual GP_Xform *inverse(void);
62  virtual int inverse(GP_Xform &);
63 
64  // Each derived class has its own name and id:
65  virtual const char *getName(void) const;
66  virtual unsigned int getType(void) const;
67  virtual const char *getJSONToken(void) const;
68 
69  // I/O functions returning 0 if OK and -1 otherwise.
70  virtual int save(std::ostream &os, int binary = 0) const;
71  virtual bool load(UT_IStream &is);
72 
73  virtual bool save(UT_JSONWriter &w) const;
74  virtual bool load(UT_JSONParser &p, UT_JSONParser::traverser &it);
75 
76  // Assignment operator defined for a transform of the same type:
77  GP_BilinearXform &operator=(const GP_BilinearXform &xform);
78 
79 
80 protected:
81  // The guts of the mapping process. Return 0 of OK, else -1:
82  int mapForward (GP_Point &data) const;
83  int mapBackward(GP_Point &data) const;
84 
85  // Find the root(s) of a simple equation:
86  float findRoot (const GP_Point &p,
87  const GP_Point &p1, const GP_Point &p2,
88  const GP_Point &p3, const GP_Point &p4) const;
89 
90 private:
91  GP_Point myOriginal[4]; // 0 is upper-left corner, 1 is upper-right, etc
92  GP_Point myMapped [4];
93 };
94 
95 #endif
virtual int save(std::ostream &os, int binary=0) const =0
#define GP_API
Definition: GP_API.h:10
virtual const char * getJSONToken(void) const =0
virtual bool load(UT_IStream &is)=0
const GLuint GLenum const void * binary
Definition: glcorearb.h:1923
virtual void reset(void)=0
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:75
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:32
virtual int forward(GP_Point &p) const =0
virtual int copyFrom(const GP_Xform &xform)=0
Traverse an array object in the parser.
GLboolean * data
Definition: glcorearb.h:130
virtual GP_Xform * inverse(void)=0
virtual GP_Xform * compose(const GP_Xform &xform, const UT_BoundingRect *brect=0)=0
virtual const char * getName(void) const =0
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
virtual int backward(GP_Point &p) const =0
virtual unsigned int getType(void) const =0
virtual void translate(float dx, float dy)=0
virtual GP_Xform * composeInverse(const GP_Xform &xform, const UT_BoundingRect *brect=0)=0