HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GOP_VertexGroupParser.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 vertex groups.
7  * The doIt() method returns the number of vertices parsed,
8  * or -1 if an error has occured.
9  *
10  */
11 
12 #ifndef __GOP_VertexGroupParser_h__
13 #define __GOP_VertexGroupParser_h__
14 
15 #include "GOP_API.h"
16 #include "GOP_Parser.h"
17 #include <GA/GA_ElementGroup.h>
18 #include <GA/GA_Types.h>
19 
20 class GEO_Detail;
21 class GOP_Manager;
22 class GA_VertexGroup;
23 
25 {
26 public:
27  // When an ordered group is requested and an order needs to be imposed by
28  // this parser, it uses the primitive vertex order, not the vertex index
29  // map order.
30  GOP_VertexGroupParser(GOP_Manager *manager, const GEO_Detail &gdp,
31  const UT_String &str, bool strict = true,
32  GA_Index prim_offset = GA_Index(0),
33  bool ordered = false);
34 
35  // Build a string that contains the id's of the vertices in a vertex
36  // group. The offset is the amount to add to the ids of the primitives for
37  // each vertex in the group.
38  static void buildGroupToken(const GA_VertexGroup *vtxgrp,
39  UT_String &token,
41  bool ordered = false);
42 
43  // Build a string representing a single vertex element. The offset is the
44  // amount to add to the id of the primitive.
45  static void buildElementToken(const GEO_Detail *gdp,
46  GA_Offset vertex, UT_String &token,
47  GA_Index offset = GA_Index(0));
48 
49 private:
50 
51  void init() override;
52  void finish() override;
53  bool dispatch(char c) override;
54 
55  // State Handlers
56  void handleStart() override;
57  void handleError() override;
58 
59  void handleCollectPrim();
60  void handleCollectPrim1();
61  void handleCollectName();
62  void handleCollectVertex0();
63  void handleCollectVertex1();
64 
65  // State Variables
66  GA_Index myPrimIndex;
67  GA_Index myPrim1;
68  int myVertex0;
69  int myVertex1;
70 
71  // Vertex Specific Methods
72  bool addVertex();
73  bool addAllPrimVertices(GA_Offset primoff = GA_INVALID_OFFSET);
74  bool addVertexRange(int u0, int u1);
75  bool addPrimGroup(const char *name);
76  bool addVertexGroup(const char *name);
77 
78  // Primitive Specific Methods
79  bool addPrimRange(int u0, int u1);
80 
81  // Utility methods
82  GA_Offset getPrim();
83 
84 
85  const GEO_Detail &myGdp;
86  GA_VertexGroupUPtr myGroup;
87  GOP_Manager *myManager;
88  bool myStrictFlag;
89  bool myOrderedFlag;
90  GA_Index myPrimOffset;
91 };
92 
93 
94 #endif
SIM_API const UT_StringHolder vertex
UT_UniquePtr< GA_VertexGroup > GA_VertexGroupUPtr
virtual bool dispatch(char c)=0
GLdouble u1
Definition: glad.h:2676
virtual void finish()
#define GA_INVALID_OFFSET
Definition: GA_Types.h:694
#define GOP_API
Definition: GOP_API.h:10
GA_Size GA_Offset
Definition: GA_Types.h:653
GLintptr offset
Definition: glcorearb.h:665
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:647
virtual void init()
virtual void handleStart()=0