HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOP_Curve.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: SOP Library (C++)
7  *
8  * COMMENTS: The Curve sop generator.
9  *
10  */
11 
12 #ifndef __SOP_Curve_h__
13 #define __SOP_Curve_h__
14 
15 #include "SOP_API.h"
16 #include <math.h>
17 #include <PRM/PRM_Parm.h>
18 #include "SOP_Node.h"
19 
20 
21 #define SC_CVS 0
22 #define SC_BREAKPOINTS 1
23 #define SC_FREEHANDDRAW 2
24 
25 #define SC_POLYGON 0
26 #define SC_NURBS 1
27 #define SC_BEZIER 2
28 
29 #define SC_STR_POINT "%.6g,%.6g,%.6g " // x,y,z
30 #define SC_STR_WEIGHTED_POINT "%.6g,%.6g,%.6g,%.6g " // x,y,z,w
31 #define SC_STR_RELATIVE_POINT "@%.6g,%.6g,%.6g " // @x,y,z
32 #define SC_STR_REL_WEIGHTED_POINT "@%.6g,%.6g,%.6g,%.6g " // @x,y,z,w
33 #define SC_STR_REF_POINT "p%d " // pn
34 #define SC_STR_COPY_POINT "P%d " // Pn
35 #define SC_STR_BREAKPOINT_U "%db[%d] " // xb[u]
36 #define SC_STR_BREAKPOINT_UV "%db[%d,%d] " // xb[u,v]
37 
38 
39 class MSS_FaceState;
40 
41 class SOP_API SOP_Curve : public SOP_Node
42 {
43 
44 public:
45  const char *inputLabel(unsigned idx) const override;
46  int isRefInput(unsigned int i) const override;
47 
48  static OP_Node *myConstructor(OP_Network*, const char *, OP_Operator*);
49  static PRM_Template *buildTemplates();
50  const SOP_NodeVerb *cookVerb() const override;
51 
52  int getTranslateParmIndex() override;
53 
54  // given a number of vertices it calculates how many more are necessary
55  // in order to have a valid gdp, taking into account the current
56  // internal configuration of the SOP
57  int calcCVsNeeded(int numverts);
58 
59  void COORDS(UT_String &str, double t)
60  { evalString(str, "coords", 0, t); }
61 
63  double t)
64  { setString(str, meaning, 2, 0, t); }
65 
66  // SWITCHER
67  int TYPE() { return evalInt("type", 0, 0); }
68  void SET_TYPE(int i, bool dflt = false)
69  {
70  setInt("type", 0, 0, i);
71  if (dflt)
72  getParm("type").overwriteDefaults(0);
73  }
74 
75  int METHOD() { return evalInt("method", 0, 0); }
76  void SET_METHOD(int i, bool dflt = false)
77  {
78  setInt("method", 0, 0, i);
79  if (dflt)
80  getParm("method").overwriteDefaults(0);
81  }
82 
83  int CLOSED() { return evalInt("close", 0, 0); }
84  void SET_CLOSED(int i, bool dflt = false)
85  {
86  setInt("close", 0, 0, i);
87  if (dflt)
88  getParm("close").overwriteDefaults(0);
89  }
90 
91  bool REVERSE(double t) { return evalInt("reverse", 0, t); }
92  // Curve properties options
93  int NORMBASIS() { return evalInt("normalize", 0, 0); }
94 
95  int ORDER() { return evalInt("order", 0, 0); }
96  void SET_ORDER(int i) { setInt("order", 0, 0, i); }
97 
98  int PARMTYPE() { return evalInt("param", 0, 0); }
99 
100 
101  // Fitting options
102  double TOLERANCE(double t) { return evalFloat("tolerance", 0, t); }
103  double SMOOTH(double t) { return evalFloat("smooth", 0, t); }
104  int SHARP() { return evalInt("csharp", 0, 0); }
105 
106  int KEEPINGEO() { return evalInt("keepgeo", 0, 0); }
107 
108 protected:
109  SOP_Curve(OP_Network *net, const char *name, OP_Operator *entry);
110  ~SOP_Curve() override;
111 
112  OP_ERROR cookMySop(OP_Context &context) override;
113 
114 private:
115  friend class MSS_FaceState;
116 };
117 
118 #endif
virtual const SOP_NodeVerb * cookVerb() const
Definition: SOP_Node.h:909
void COORDS(UT_String &str, double t)
Definition: SOP_Curve.h:59
void SET_ORDER(int i)
Definition: SOP_Curve.h:96
int PARMTYPE()
Definition: SOP_Curve.h:98
CH_StringMeaning
void overwriteDefaults(fpreal time)
virtual const char * inputLabel(unsigned idx) const
fpreal evalFloat(int pi, int vi, fpreal t) const
double TOLERANCE(double t)
Definition: SOP_Curve.h:102
UT_ErrorSeverity
Definition: UT_Error.h:25
int TYPE()
Definition: SOP_Curve.h:67
void setString(const UT_StringRef &val, CH_StringMeaning meaning, int parmi, int vectori, fpreal t)
int ORDER()
Definition: SOP_Curve.h:95
int CLOSED()
Definition: SOP_Curve.h:83
PRM_Parm & getParm(int i)
void evalString(UT_String &val, int pi, int vi, fpreal t) const
int SHARP()
Definition: SOP_Curve.h:104
bool REVERSE(double t)
Definition: SOP_Curve.h:91
void SET_CLOSED(int i, bool dflt=false)
Definition: SOP_Curve.h:84
void SET_COORDS(UT_String &str, CH_StringMeaning meaning, double t)
Definition: SOP_Curve.h:62
void SET_TYPE(int i, bool dflt=false)
Definition: SOP_Curve.h:68
GLuint const GLchar * name
Definition: glcorearb.h:786
GLdouble t
Definition: glad.h:2397
double SMOOTH(double t)
Definition: SOP_Curve.h:103
void SET_METHOD(int i, bool dflt=false)
Definition: SOP_Curve.h:76
void setInt(int parmi, int vectori, fpreal t, exint value)
#define SOP_API
Definition: SOP_API.h:10
int METHOD()
Definition: SOP_Curve.h:75
int KEEPINGEO()
Definition: SOP_Curve.h:106
exint evalInt(int pi, int vi, fpreal t) const
virtual OP_ERROR cookMySop(OP_Context &context)=0
virtual int isRefInput(unsigned idx) const
virtual int getTranslateParmIndex()
int NORMBASIS()
Definition: SOP_Curve.h:93