HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GOP_EdgeGroupParser.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  * COMMENTS: This class contains a parser for the edge groups.
7  * The doIt() method returns the number of edges parsed,
8  * or -1 if an error has occured.
9  *
10  */
11 
12 #ifndef __GOP_EdgeGroupParser_h__
13 #define __GOP_EdgeGroupParser_h__
14 
15 #include "GOP_API.h"
16 #include "GOP_Parser.h"
17 
18 #include <GA/GA_PrimitiveTypeId.h>
19 #include <GA/GA_Types.h>
20 
21 ///
22 /// Specifies edges 3-6 and 6-9
23 /// p3-6-9
24 ///
25 /// Specifies edges whose both points lie in foo, foo a point
26 /// group exression.
27 /// p{foo}
28 /// p{3-5:4}
29 /// p{bar* @id>5}
30 
31 class UT_String;
32 class GA_Primitive;
33 class GEO_Detail;
34 class GOP_Manager;
35 class GEO_Primitive;
36 class GA_EdgeGroup;
37 
39 {
40 public:
41  GOP_EdgeGroupParser(GOP_Manager *manager, const GEO_Detail &gdp,
42  const UT_String &str,
43  const GA_PrimitiveTypeId &id,
44  bool strict = true,
45  GA_Index prim_offset = GA_Index(0),
46  GA_Index point_offset = GA_Index(0));
47 
48  // Build a string that contains the id's of the edges in an edge group.
49  // The prim and point offsets are the amount to add to the ids of the
50  // primitives/points for each edge in the group.
51  static void buildGroupToken(const GEO_Detail *gdp,
52  const GA_EdgeGroup *edgegrp,
53  UT_String &token,
54  GA_Index prim_offset = GA_Index(0),
55  GA_Index pt_offset = GA_Index(0));
56  // FIXME: Delete this once we split for 15.0.
57  static void buildGroupToken(const GEO_Detail *gdp,
58  const GA_EdgeGroup *edgegrp,
59  UT_String &token,
60  int prim_offset, int pt_offset);
61 
62  // This is only made public so that code from within the parser
63  // can access it.
64  bool addEdge(GA_Offset pt0, GA_Offset pt1,
65  const GEO_Primitive *pprim);
66 private:
67 
68  virtual void init();
69  virtual void finish();
70  virtual bool dispatch(char c);
71 
72  // State Handlers
73  virtual void handleStart();
74  virtual void handleError();
75 
76  void handleCollectPoint();
77  void handleCollectPrim();
78  void handleCollectSec();
79  void handleCollectName();
80  void handleCollectEdgeU();
81  void handleCollectEdgeV();
82  void handleCollectPointGroup();
83  void handleCollectAll();
84 
85  void handleInverseGroup();
86 
87  bool matchTypeId(const GA_Primitive *prim) const;
88 
89  // State Variables
90  bool myOpenBracket;
91  bool myAllSpaces;
92  bool myRangeStarted;
93  bool myIsNegating;
94  bool myInverse;
95  int myLastPoint;
96  int myIndexStart;
97  int myPrimIndex;
98  int mySecIndex;
99  int myU;
100  GA_PrimitiveTypeId myId;
101 
102  // Edge Specific Methods
103  const GEO_Primitive *getPrimitive(GA_Index prim) const;
104 
105  bool addEdge(GA_Index p0, GA_Index p1, GA_Index prim);
106  bool addPoint(GA_Index p0);
107  bool addAllPrimEdges(GA_Index prim);
108  bool addAllPrimEdges(const GEO_Primitive &prim);
109  bool addPrimEdge(GA_Size vertex_first, GA_Index prim);
110  bool addPrimEdgeRange(GA_Size vertex_first,
111  GA_Size vertex_last,
112  GA_Index prim);
113  bool addPrimRange(GA_Index prim_first, GA_Index prim_last);
114  bool addHullEdge(unsigned int row, unsigned int col,
115  GA_Index prim);
116  bool addPrimGroup(const char *name);
117 
118  const GEO_Detail &myGdp;
119  GA_EdgeGroup *myEdgeGroup; // Group to hold all lone edges
120  GA_EdgeGroup *myInverseEdgeGroup; // Temporary group for inverse edges
121  GOP_Manager *myManager;
122  bool myStrictFlag;
123  GA_Index myPrimOffset;
124  GA_Index myPointOffset;
125 };
126 
127 
128 #endif
virtual bool dispatch(char c)=0
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
virtual void finish()
#define GOP_API
Definition: GOP_API.h:10
GA_Size GA_Offset
Definition: GA_Types.h:617
virtual void handleError()=0
png_bytepp row
Definition: png.h:1836
GLuint const GLchar * name
Definition: glcorearb.h:785
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
virtual void init()
virtual void handleStart()=0