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 #include <GA/GA_Edge.h>
21 
22 ///
23 /// Specifies edges 3-6 and 6-9
24 /// p3-6-9
25 ///
26 /// Specifies edges whose both points lie in foo, foo a point
27 /// group exression.
28 /// p{foo}
29 /// p{3-5:4}
30 /// p{bar* @id>5}
31 
32 class UT_String;
33 class GA_Primitive;
34 class GEO_Detail;
35 class GOP_Manager;
36 class GEO_Primitive;
37 class GA_EdgeGroup;
38 
40 {
41 public:
42  GOP_EdgeGroupParser(GOP_Manager *manager, const GEO_Detail &gdp,
43  const UT_String &str,
44  const GA_PrimitiveTypeId &id,
45  bool strict = true,
46  GA_Index prim_offset = GA_Index(0),
47  GA_Index point_offset = GA_Index(0));
48 
49  // Build a string that contains the id's of the edges in an edge group.
50  // The prim and point offsets are the amount to add to the ids of the
51  // primitives/points for each edge in the group.
52  static void buildGroupToken(const GEO_Detail *gdp,
53  const GA_EdgeGroup *edgegrp,
54  UT_String &token,
55  GA_Index prim_offset = GA_Index(0),
56  GA_Index pt_offset = GA_Index(0));
57 
58  // Build a string representing a single edge element. The prim and point
59  // offsets are the amount to add to the ids of the primitives/points.
60  static void buildElementToken(const GEO_Detail *gdp,
61  const GA_Edge &edge,
62  GA_Offset prim, UT_String &token,
63  GA_Index prim_offset = GA_Index(0),
64  GA_Index pt_offset = GA_Index(0));
65 
66  // This is only made public so that code from within the parser
67  // can access it.
68  bool addEdge(GA_Offset pt0, GA_Offset pt1,
69  const GEO_Primitive *pprim);
70 private:
71 
72  void init() override;
73  void finish() override;
74  bool dispatch(char c) override;
75 
76  // State Handlers
77  void handleStart() override;
78  void handleError() override;
79 
80  void handleCollectPoint();
81  void handleCollectPrim();
82  void handleCollectSec();
83  void handleCollectName();
84  void handleCollectEdgeU();
85  void handleCollectEdgeV();
86  void handleCollectPointGroup();
87  void handleCollectAll();
88 
89  void handleInverseGroup();
90 
91  bool matchTypeId(const GA_Primitive *prim) const;
92 
93  // State Variables
94  bool myOpenBracket;
95  bool myAllSpaces;
96  bool myRangeStarted;
97  bool myIsNegating;
98  bool myInverse;
99  int myLastPoint;
100  int myIndexStart;
101  int myPrimIndex;
102  int mySecIndex;
103  int myU;
104  GA_PrimitiveTypeId myId;
105 
106  // Edge Specific Methods
107  const GEO_Primitive *getPrimitive(GA_Index prim) const;
108 
109  bool addEdge(GA_Index p0, GA_Index p1, GA_Index prim);
110  bool addPoint(GA_Index p0);
111  bool addAllPrimEdges(GA_Index prim);
112  bool addAllPrimEdges(const GEO_Primitive &prim);
113  bool addPrimEdge(GA_Size vertex_first, GA_Index prim);
114  bool addPrimEdgeRange(GA_Size vertex_first,
115  GA_Size vertex_last,
116  GA_Index prim);
117  bool addPrimRange(GA_Index prim_first, GA_Index prim_last);
118  bool addHullEdge(unsigned int row, unsigned int col,
119  GA_Index prim);
120  bool addPrimGroup(const char *name);
121 
122  const GEO_Detail &myGdp;
123  GA_EdgeGroup *myEdgeGroup; // Group to hold all lone edges
124  GA_EdgeGroup *myInverseEdgeGroup; // Temporary group for inverse edges
125  GOP_Manager *myManager;
126  bool myStrictFlag;
127  GA_Index myPrimOffset;
128  GA_Index myPointOffset;
129 };
130 
131 
132 #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:236
virtual void finish()
#define GOP_API
Definition: GOP_API.h:10
GA_Size GA_Offset
Definition: GA_Types.h:646
virtual void handleError()=0
GLuint const GLchar * name
Definition: glcorearb.h:786
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:640
virtual void init()
GLenum GLenum GLsizei void * row
Definition: glad.h:5135
virtual void handleStart()=0