HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GD_TrimGraph.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: Geometry Library (C++)
7  *
8  * COMMENTS:
9  *
10  * This implements a graph where the graph abstracts trim loops on
11  * a surface. Each vertex of the graph represents an intersection between
12  * two edges, and each edge of the graph represents a segment between
13  * two vertices on a trimLoop.
14  *
15  */
16 
17 #ifndef __GD_TrimGraph_h__
18 #define __GD_TrimGraph_h__
19 
20 #include "GD_API.h"
21 typedef int GD_VERTEX;
22 typedef int GD_EDGE;
23 
25 {
26  GD_NONE = 0,
29 };
30 
31 class GD_TrimLoop;
32 class GD_TrimHitInfo;
33 class GD_TrimVertex;
34 class GD_TrimEdges;
35 class GD_TrimRegion;
36 class GD_Face;
37 
39 {
40 public:
41  // clockwise indicated the direction of the graph.
42  GD_TrimGraph(int clockwise, float tol=1e-4F);
43  ~GD_TrimGraph();
44 
45  // Adds a new loop to the graph. After adding the the new loop, we
46  // would try to find a closed loop. If a closed loop is found, we
47  // return 1, otherwise 0.
48  int addTrimLoop(GD_Face* face, GD_TrimLoop *tloop);
49 
50  // Adds a new vertex to the graph. It serves the purpose of having
51  // one central place to store all the vertices so that it's convenient
52  // to reference a vertex or to delete them at the end.
53  GD_VERTEX addTrimVertex(GD_TrimVertex *vertex);
54 
55  // When a function finds a loop that's made up of two edges, we
56  // call this function. edge1 and edge2 are the indices of the
57  // edges that make up the loop, the "hitinfo" is the infomation
58  // of intersecting edge2 with edge1 [ edge1->intersect(edge2) ]
59  void foundLoop(GD_EDGE edge1, GD_EDGE edge2,
60  const UT_Array<GD_TrimHitInfo> &hitinfo);
61 
62  GD_TrimVertex* getVertex(GD_VERTEX n) const {return myVertices((unsigned)n);};
63  GD_TrimEdges* getEdge(GD_EDGE n) const {return myLoops((unsigned)n);};
64  int vertexCount() const {return (int)myVertices.entries();};
65 
66  // Returns a loop from the graph. This is just a loop that was
67  // identified when adding the loops to the graph. Returns NIL if
68  // no loop was found. It is the caller's responsibility to delete
69  // the returned result.
70  GD_TrimLoop* getLoop() const;
71  GD_TrimGraphError toProfile(GD_TrimRegion *region,
72  const UT_BoundingRect &brect);
73 private:
74  // Tries to find a loop, using "root" as the root of the tree. This
75  // should be able to detect and identify if a cycle exists and it's
76  // connected to the root. However, this makes no guarantee to which
77  // cycle will be found.
78  int findLoop(GD_VERTEX root);
79 
80  // Indicates that we have a loop that is already closed; makes life
81  // a lot easier.
82  void foundClosedLoop(GD_EDGE edge);
83 
84  // Writing out a single closed loop out to the region. The closed loop
85  // has a vertx associated with it that has exactly one vertex, with
86  // the end points of the loop recorded on it.
87  void toProfileClosedLoop(GD_TrimVertex *vertex,
88  GD_TrimRegion *region) const;
89 
90  // Write out a cycle that consist of exactly two loops, (and thus
91  // two vertices, curV and nextV) to the the region.
92  // If region is nil, then we don't write it out. If tloop is not nil,
93  // then, we would return the loop also. Make sure tloop has no
94  // TrimPieces since we are just appending to it without checking.
95  void toProfileTwoLoops(GD_TrimVertex *curV,
96  GD_TrimVertex *nextV,
97  GD_TrimRegion *region,
98  GD_TrimLoop *tloop = 0) const;
99 
100  void toProfileMultiLoops(GD_TrimVertex *nextV,
101  GD_TrimRegion *region,
102  GD_TrimLoop *tloop = 0) const;
103 
104  int myFoundLoop;
105  UT_ValArray<GD_Face*> myFaces;
107  UT_ValArray<GD_TrimVertex*> myVertices;
108  int myClockwise;
109  float myTol;
110 };
111 
112 #endif
113 
SIM_API const UT_StringHolder vertex
int GD_EDGE
Definition: GD_TrimGraph.h:22
int GD_VERTEX
Definition: GD_TrimGraph.h:21
int vertexCount() const
Definition: GD_TrimGraph.h:64
GD_TrimEdges * getEdge(GD_EDGE n) const
Definition: GD_TrimGraph.h:63
GLdouble n
Definition: glcorearb.h:2008
GD_TrimGraphError
Definition: GD_TrimGraph.h:24
#define GD_API
Definition: GD_API.h:10
GD_TrimVertex * getVertex(GD_VERTEX n) const
Definition: GD_TrimGraph.h:62