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  ~GP_BilinearXform() override;
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  int forward(GP_Point &p) const override;
34  int forward(GP_PointMatrix &m) const override;
35  int backward(GP_Point &p) const override;
36  int backward(GP_PointMatrix &m) const override;
37 
38  // Set the transformation to identity:
39  void reset() override;
40 
41  // Add a translation by delta to this transform:
42  void translate(float dx, float dy) override;
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  GP_Xform *compose(const GP_Xform &xform,
48  const UT_BoundingRect * = 0) override;
49  GP_Xform *composeInverse(const GP_Xform &xform,
50  const UT_BoundingRect * = 0) override;
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  int copyFrom(const GP_Xform &xform) override;
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  GP_Xform *inverse() override;
62  int inverse(GP_Xform &) override;
63 
64  // Each derived class has its own name and id:
65  const char *getName() const override;
66  unsigned int getType() const override;
67  const char *getJSONToken() const override;
68 
69  // I/O functions returning 0 if OK and -1 otherwise.
70  int save(std::ostream &os, int binary = 0) const override;
71  bool load(UT_IStream &is) override;
72 
73  bool save(UT_JSONWriter &w) const override;
74  bool load(UT_JSONParser &p,
75  UT_JSONParser::traverser &it) override;
76 
77  // Assignment operator defined for a transform of the same type:
78  GP_BilinearXform &operator=(const GP_BilinearXform &xform);
79 
80 
81 protected:
82  // The guts of the mapping process. Return 0 of OK, else -1:
83  int mapForward (GP_Point &data) const;
84  int mapBackward(GP_Point &data) const;
85 
86  // Find the root(s) of a simple equation:
87  float findRoot (const GP_Point &p,
88  const GP_Point &p1, const GP_Point &p2,
89  const GP_Point &p3, const GP_Point &p4) const;
90 
91 private:
92  GP_Point myOriginal[4]; // 0 is upper-left corner, 1 is upper-right, etc
93  GP_Point myMapped [4];
94 };
95 
96 #endif
virtual int save(std::ostream &os, int binary=0) const =0
virtual GP_Xform * inverse()=0
#define GP_API
Definition: GP_API.h:10
virtual bool load(UT_IStream &is)=0
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:76
const GLdouble * m
Definition: glew.h:9124
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:34
virtual int forward(GP_Point &p) const =0
virtual int copyFrom(const GP_Xform &xform)=0
virtual const char * getName() const =0
GLint GLenum GLsizei GLint GLsizei const void * data
Definition: glew.h:1379
virtual unsigned int getType() const =0
const GLuint GLenum const void * binary
Definition: glew.h:3502
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
Traverse an array object in the parser.
virtual const char * getJSONToken() const =0
GLfloat GLfloat p
Definition: glew.h:16321
virtual GP_Xform * compose(const GP_Xform &xform, const UT_BoundingRect *brect=0)=0
virtual void reset()=0
virtual int backward(GP_Point &p) const =0
virtual void translate(float dx, float dy)=0
virtual GP_Xform * composeInverse(const GP_Xform &xform, const UT_BoundingRect *brect=0)=0