HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SOP_PolySplit2.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: PolySplit tool. Slices and dices polygons.
9  *
10  */
11 
12 #ifndef __SOP_PolySplit2_h__
13 #define __SOP_PolySplit2_h__
14 
15 #include "SOP_API.h"
16 #include <GEO/GEO_PrimClassifier.h>
17 #include <UT/UT_ValArray.h>
18 #include "SOP_Node.h"
19 
20 class MSS_PolySplitState2;
21 class GU_RayIntersect;
22 
24 {
25 public:
26  SOP_PolySplit2(OP_Network *net, const char *name,
27  OP_Operator *entry);
28  virtual ~SOP_PolySplit2();
29 
30  virtual bool updateParmsFlags();
31 
32  static OP_Node *myConstructor(OP_Network *net,
33  const char *name,
34  OP_Operator *entry);
35 
36  static PRM_Template myTemplateList[];
37 
38 protected:
39  virtual OP_ERROR cookMySop(OP_Context &context);
40  virtual const char *inputLabel(unsigned idx) const;
41 
42 private:
43  // projects the points in curve onto the input geometry, and converts their
44  // locations into GU_SplitLoc's. If they are close to points or edges they
45  // are snapped to them to preserve topology
46  // curve must contain the points to be projected
47  // splitlocs will contain the projected SplitLoc's if successful upon return
48  // tol is the tolerance used for snapping points to existing points/edges
49  // returns true if successful, false otherwise
50  bool projectCurvePoints(const GU_Detail *curve,
51  GU_SplitLocArray &splitlocs,
52  float tol);
53 
54  // returns true if there is a splitloc without a polygon pointer, which
55  // occurs when the split string is of the form "p2-3" and edge 2-3 does not
56  // exist
57  bool pointsWithoutPoly(const GU_SplitLocArray &splitlocs);
58 
59  // returns true if all of the splitlocs are on the same connected component
60  // of the geometry
61  bool pointsOnSameComponent(const GU_SplitLocArray &splitlocs);
62 
63  // returns true if all of the splitlocs are on edges. Used to check edgeloop
64  // data
65  bool allPointsOnEdges(const GU_SplitLocArray &splitlocs);
66 
67  // returns true if all of the splitlocs are not on faces.
68  bool allPointsOffFaces(const GU_SplitLocArray &splitlocs);
69 
70  // Properties
71  void getSplitLoc(UT_String &str, fpreal t)
72  { evalString(str, "splitloc", 0, t); }
73 
74  void setSplitLoc(UT_String &str, fpreal t, CH_StringMeaning meaning)
75  { setString(str, meaning, "splitloc", 0, t); }
76 
77  int PATHTYPE() { return evalInt("pathtype", 0, 0); }
78  // MSS needs this so it can create the node in quad strip mode
79  void SET_PATHTYPE(int i) { setInt("pathtype", 0, 0, i); }
80 
81  int CLOSED() { return evalInt("close", 0, 0); }
82  void SET_CLOSED(int i) { setInt("close", 0, 0, i); }
83 
84  int ALLOWFACES() { return evalInt("allowfaces", 0, 0); }
85  void SET_ALLOWFACES(int i) { setInt("allowfaces", 0, 0, i); }
86 
87  int NUMLOOPS() { return evalInt("numloops", 0, 0); }
88  int PARALLELLOOP() { return evalInt("parallellooptoggle", 0, 0); }
89  void SET_PARALLELLOOP(int i) { setInt("parallellooptoggle", 0, 0, i); }
90  int PARALLELFLIP() { return evalInt("parallelfliptoggle", 0, 0); }
91  void SET_PARALLELFLIP(int i) { setInt("parallelfliptoggle", 0, 0, i); }
92 
93  int QUADCOMPLETE() { return evalInt("quadcomplete", 0, 0); }
94  void SET_QUADCOMPLETE(int i) { setInt("quadcomplete", 0, 0, i); }
95 
96  int EDGEPERCENTTOGGLE() { return evalInt("edgepercenttoggle", 0, 0); }
97  void SET_EDGEPERCENTTOGGLE(int i) { setInt("edgepercenttoggle", 0, 0, i); }
98  float EDGEPERCENTAGE() { return evalFloat("edgepercent", 0, 0); }
99 
100  int UPDATENORMS(fpreal t) { return evalInt("updatenorms", 0, t); }
101 
102  int CREATEGROUP() { return evalInt("grouptoggle", 0, 0); }
103  void GROUPNAME(UT_String &str, fpreal t) { evalString(str, "groupname", 0, t); }
104  int GROUPAPPEND() { return evalInt("groupappend", 0, 0); }
105 
106  float TOLERANCE(fpreal t) { return evalFloat("tolerance", 0, t); }
107 
108  // returns true if there is something in the second input
109  bool curveInput() { return getInput(1) != NULL; }
110 
111  // cached data about input 1 (the geomtry we are splitting) so that we can
112  // keep the GU_RayIntersect between cooks. This is especially important when
113  // editing the input curve in the viewport, because at that point we will be
114  // cooking every frame, and constructing a GU_RayIntersect is very expensive
115  GU_RayIntersect *myRayIntersect;
116  exint myCachedInputCookCount;
117  exint myCachedInputUniqueId;
118  GEO_PrimClassifier myPrimClassifier;
119 
120  friend class sop_SplitParser2;
121  friend class MSS_PolySplitState2;
122 };
123 
124 #endif
virtual bool updateParmsFlags()
CH_StringMeaning
virtual const char * inputLabel(unsigned idx) const
fpreal evalFloat(int pi, int vi, fpreal t) const
UT_ErrorSeverity
Definition: UT_Error.h:25
png_uint_32 i
Definition: png.h:2877
int64 exint
Definition: SYS_Types.h:109
void evalString(UT_String &val, int pi, int vi, fpreal t) const
OP_Node * getInput(unsigned idx, bool mark_used=false) const
Returns the node connected to a particular input (may be null).
GLuint const GLchar * name
Definition: glcorearb.h:785
double fpreal
Definition: SYS_Types.h:263
void setInt(int parmi, int vectori, fpreal t, exint value)
#define SOP_API
Definition: SOP_API.h:10
void setString(const UT_String &val, CH_StringMeaning meaning, int parmi, int vectori, fpreal t)
exint evalInt(int pi, int vi, fpreal t) const
virtual OP_ERROR cookMySop(OP_Context &context)=0