HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_CurveSet.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: GU library (C++)
7  *
8  * COMMENTS: Describes a set of space curves. Creates nodes
9  * whereever the space curves intersect, recording which
10  * curves and where they intersected. Curves are
11  * also given an index when they are added, allowing
12  * easy cross referencing to other data structures.
13  *
14  */
15 
16 #ifndef __GU_CurveSet_h__
17 #define __GU_CurveSet_h__
18 
19 #include "GU_API.h"
20 #include <UT/UT_Array.h>
21 #include <UT/UT_ValArray.h>
22 #include <UT/UT_Vector3.h>
23 
24 // Node iterator:
25 #define FOR_ALL_NODES(curveset, node) \
26  for (node = curveset.getHeadNode(); node; node = node->next())
27 
28 class GD_TrimLoop;
29 class GU_CurveSet;
30 class GU_CurveNode;
31 class GEO_Face;
32 class GU_Detail;
33 
35 {
36 public:
37  // Not a very intelligent == operator, something is required for
38  // NT build though.
39  int operator==(const GU_CurveSetInfo &curveInfo)
40  { return curve == curveInfo.curve; }
41 
44 
45  void removeNode(const GU_CurveNode *node);
46 };
47 
49 {
50 public:
51  int operator==(const GU_CurveNodeInfo & /*ni*/)
52  { return 1; } // Req'd for NT
53 
54  // data
55  int curveidx; // The curve that hits this node.
56  float u; // Where that curve isects.
57  float d2; // Distance of curve to this node
58 };
59 
61 {
62 public:
63  void addCurve(GU_CurveSetInfo &curveinfo, int curveidx,
64  float u, float d2, const UT_Vector3 &pt);
65 
66  GU_CurveNode *next() const { return myNext; }
67  int degree() const { return myDegree; }
68  GU_CurveNodeInfo &operator()(int i) { return myEdges(i); }
69  GU_CurveNodeInfo operator()(int i) const { return myEdges(i); }
70  UT_Vector3 &point() { return myPt; }
71  UT_Vector3 point() const { return myPt; }
72  UT_Vector3 &normal() { return myNormal; }
73  UT_Vector3 normal() const { return myNormal; }
74 
75 public:
76  // data
77  UT_Vector3 myPt; // Where isection is
78  UT_Vector3 myNormal; // Orientation of node
79  int myDegree; // # curves isecting here
80  UT_Array<GU_CurveNodeInfo> myEdges; // All edges hitting here.
81  GU_CurveNode *myNext; // Next in chain.
82  float myD2; // Dist of isect to point.
83 };
84 
86 {
87 public:
88  GU_CurveSet(int useEnds = 0);
89  ~GU_CurveSet();
90 
91  // Merges two curvesets. Curve indices are changed:
92  void merge(GU_CurveSet &curveset);
93 
94  // Adds new curve. Returns its index
95  // Not const as intersection info is generated.
96  int merge(GEO_Face &curve);
97 
98  int isEmpty() const
99  { return (myCurves.entries()) ? 0 : 1; }
100  int numCurves() const { return myCurves.entries(); }
101 
102  // Clears all local information without destroying the refarray.
103  void reset();
104 
105  GU_CurveSetInfo &operator()(int i) { return myCurves(i); }
106  GU_CurveSetInfo operator()(int i) const { return myCurves(i); }
107 
108  // Not a very intelligent == operator, something is required for
109  // NT build though.
110  int operator==(const GU_CurveSet &curveSet)
111  { return myCurves == curveSet.myCurves; }
112 
113  // Builds topological info of set.
114  void buildNodeList(float tol = 1e-3);
115 
116  GU_CurveNode *getHeadNode() const { return myNodes; }
117 
118 private:
119  // Eliminates topological information of set.
120  void clearNodeList();
121 
122  GU_CurveNode *findNode(const UT_Vector3 &p,
123  float tol = 1e-3) const;
124  GU_CurveNode *createNode(const UT_Vector3 &p);
125 
126  // List of all curves that are present.
127  UT_Array<GU_CurveSetInfo> myCurves;
128  // Head of the node list.
130  // True if we only use ends of curves.
131  int myUseEnds;
132 };
133 
134 #endif
135 
UT_Array< GU_CurveNodeInfo > myEdges
Definition: GU_CurveSet.h:80
int operator==(const GU_CurveNodeInfo &)
Definition: GU_CurveSet.h:51
GU_CurveSetInfo & operator()(int i)
Definition: GU_CurveSet.h:105
UT_Vector3 point() const
Definition: GU_CurveSet.h:71
myNodes
Definition: UT_RTreeImpl.h:708
UT_Vector3 & normal()
Definition: GU_CurveSet.h:72
GU_CurveSetInfo operator()(int i) const
Definition: GU_CurveSet.h:106
UT_Vector3 myPt
Definition: GU_CurveSet.h:77
GU_CurveNodeInfo & operator()(int i)
Definition: GU_CurveSet.h:68
int numCurves() const
Definition: GU_CurveSet.h:100
GU_CurveNode * myNext
Definition: GU_CurveSet.h:81
GLboolean reset
Definition: glad.h:5138
#define GU_API
Definition: GU_API.h:14
int degree() const
Definition: GU_CurveSet.h:67
UT_ValArray< GU_CurveNode * > nodes
Definition: GU_CurveSet.h:43
UT_Vector3 normal() const
Definition: GU_CurveSet.h:73
int operator==(const GU_CurveSet &curveSet)
Definition: GU_CurveSet.h:110
GU_CurveNode * next() const
Definition: GU_CurveSet.h:66
int isEmpty() const
Definition: GU_CurveSet.h:98
int operator==(const GU_CurveSetInfo &curveInfo)
Definition: GU_CurveSet.h:39
GU_CurveNode * getHeadNode() const
Definition: GU_CurveSet.h:116
UT_Vector3 & point()
Definition: GU_CurveSet.h:70
UT_Vector3 myNormal
Definition: GU_CurveSet.h:78
GU_CurveNodeInfo operator()(int i) const
Definition: GU_CurveSet.h:69
GEO_Face * curve
Definition: GU_CurveSet.h:42