HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_Closure.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: GEO Library.
7  *
8  * COMMENTS: This file contains useful tools for finding closures.
9  *
10  */
11 
12 #pragma once
13 
14 #ifndef __GEO_Closure_h__
15 #define __GEO_Closure_h__
16 
17 #include "GEO_API.h"
18 #include "GEO_PrimType.h"
19 #include "GEO_PrimTypeCompat.h"
20 #include <GA/GA_Types.h>
21 
22 #include <UT/UT_IntArray.h>
23 
24 class GA_Group;
25 class GA_PointGroup;
26 class GA_EdgeGroup;
27 class GA_PrimitiveGroup;
28 class GA_VertexGroup;
29 class GA_BreakpointGroup;
30 namespace GA_PrimCompat { class TypeMask; }
31 class GEO_Face;
32 class GEO_Detail;
33 
34 template<typename T, bool B> class GA_EdgeT;
36 
37 
39 {
40 public:
41  GEO_Closure(GEO_Detail &gdp);
42  ~GEO_Closure();
43 
44  /// This uses the GA_Topology attributes to find primitives
45  /// using an edge.
46  void findPrimsUsingEdge(const GA_Edge &edge,
47  UT_IntArray &primlist);
48  /// NOTE: This sorts and removes duplicates for compatibility
49  /// NOTE: Unlike that findPrimsUsingEdge, this checks
50  /// GA_Primitive::hasEdge, not just that both points are contained.
51  void findPrimsUsingEdgeSort(const GA_Edge &edge,
52  UT_IntArray &primlist);
53 
54  /// This uses the GA_Topology attributes to find polygons
55  /// using an edge.
56  void findPolysUsingEdge(const GA_Edge &edge,
57  UT_IntArray &primlist);
58 
59  /// This uses the GA_Topology attributes to find primitives
60  /// using a point.
61  void findPrimsUsingPoint(const GA_Offset pt,
62  UT_IntArray &primlist);
63 
64  /// This uses the GA_Topology attributes to find polygons
65  /// using a point.
66  void findPolysUsingPoint(const GA_Offset pt,
67  UT_IntArray &primlist);
68 
69  // Return 1 if the two faces share a point, and 0 otherwise. Also return
70  // the indices of the vertices on the two faces in vtxidx0 (for face 0) and
71  // vtxidx1 (for face 1). Assumes both faces are open.
72  static int getSharedPoint(GEO_Face *face0, GEO_Face *face1,
73  int &vtxidx0, int &vtxidx1);
74 
75  // Assumes both faces are open and returns 1 if they share a common point,
76  // and 0 otherwise.
77  static int haveSharedPoint(GEO_Face *face0, GEO_Face *face1);
78 
79  // Returns the number of unique edges shared by this point.
80  GA_Size getNumSharedEdges(GA_Offset pt);
81 
82  /// @note Caller is responsible for calling destroyPrimitiveGroup() AND
83  /// for calling delete prefarr (for the functions using a prefarr).
84  /// @{
85  GA_PrimitiveGroup *getPrimitiveClosure(const GA_EdgeGroup &edgegroup,
86  GA_PrimitiveGroup *primgrp = 0);
87  GA_PrimitiveGroup *getEdgePointClosure(const GA_Edge &edge,
88  GA_PrimitiveGroup *primgrp = 0);
89  /// @}
90 
91  /// If the group is not given, all the prims of type mask are returned
92  /// in the primitive group.
93  /// @note Caller is responsible for calling destroyPrimitiveGroup()
94  GA_PrimitiveGroup *getPrimitiveClosure(const GA_BreakpointGroup *grp = 0,
97 
98  /// Point closures
99  /// @note Caller is responsible for calling destroyPointGroup()
100  /// @{
101  GA_PointGroup *getPointClosure(const GA_Group &group);
102  GA_PointGroup *getPointClosure(const GA_PointGroup &ptgroup);
103  GA_PointGroup *getPointClosure(const GA_EdgeGroup &edgegroup);
104  GA_PointGroup *getPointClosure(const GA_PrimitiveGroup &primgroup);
105  GA_PointGroup *getPointClosure(const GA_VertexGroup &vtxgroup);
106  /// @}
107 
108  /// Vertex closures
109  /// @note Caller is responsible for calling destroyVertexGroup()
110  /// @{
111  GA_VertexGroup *getVertexClosure(const GA_Group &group);
112  GA_VertexGroup *getVertexClosure(const GA_PointGroup &ptgroup);
113  GA_VertexGroup *getVertexClosure(const GA_EdgeGroup &edgegroup);
114  GA_VertexGroup *getVertexClosure(const GA_PrimitiveGroup &primgroup);
115  GA_VertexGroup *getVertexClosure(const GA_VertexGroup &vtxgroup);
116  /// @}
117 
118  // Primitive closures
119  /// @note Caller is responsible for calling destroyPrimitiveGroup()
120  /// @{
121  GA_PrimitiveGroup *getPrimitiveClosure(const GA_Group &group);
122  GA_PrimitiveGroup *getPrimitiveClosure(const GA_PointGroup &ptgroup);
123  GA_PrimitiveGroup *getPrimitiveClosure(
124  const GA_PrimitiveGroup &primgroup);
125  GA_PrimitiveGroup *getPrimitiveClosure(const GA_VertexGroup &vtxgroup);
126  /// @}
127 
128  /// Detached point closures
129  /// @note Caller is responsible for deleting the group.
130  /// @{
131  static GA_PointGroup *getDetachedPointClosure(
132  const GEO_Detail &gdp,
133  const GA_Group &group);
134  static GA_PointGroup *getDetachedPointClosure(
135  const GEO_Detail &gdp,
136  const GA_PointGroup &ptgroup);
137  static GA_PointGroup *getDetachedPointClosure(
138  const GEO_Detail &gdp,
139  const GA_EdgeGroup &edgegroup);
140  static GA_PointGroup *getDetachedPointClosure(
141  const GEO_Detail &gdp,
142  const GA_PrimitiveGroup &primgroup);
143  static GA_PointGroup *getDetachedPointClosure(
144  const GEO_Detail &gdp,
145  const GA_VertexGroup &vtxgroup);
146  /// @}
147 
148  /// Detached vertex closures
149  /// @note Caller is responsible for deleting the group.
150  /// @{
151  static GA_VertexGroup *getDetachedVertexClosure(
152  const GEO_Detail &gdp,
153  const GA_Group &group);
154  static GA_VertexGroup *getDetachedVertexClosure(
155  const GEO_Detail &gdp,
156  const GA_PointGroup &ptgroup);
157  static GA_VertexGroup *getDetachedVertexClosure(
158  const GEO_Detail &gdp,
159  const GA_EdgeGroup &edgegroup);
160  static GA_VertexGroup *getDetachedVertexClosure(
161  const GEO_Detail &gdp,
162  const GA_PrimitiveGroup &primgroup);
163  static GA_VertexGroup *getDetachedVertexClosure(
164  const GEO_Detail &gdp,
165  const GA_VertexGroup &vtxgroup);
166  /// @}
167 
168  // Detached primitive closures
169  /// @note Caller is responsible for deleting the group.
170  /// @{
171  static GA_PrimitiveGroup *getDetachedPrimitiveClosure(
172  const GEO_Detail &gdp,
173  const GA_Group &group);
174  static GA_PrimitiveGroup *getDetachedPrimitiveClosure(
175  const GEO_Detail &gdp,
176  const GA_PointGroup &ptgroup);
177  static GA_PrimitiveGroup *getDetachedPrimitiveClosure(
178  const GEO_Detail &gdp,
179  const GA_PrimitiveGroup &primgroup);
180  static GA_PrimitiveGroup *getDetachedPrimitiveClosure(
181  const GEO_Detail &gdp,
182  const GA_VertexGroup &vtxgroup);
183  /// @}
184 
185 private:
186  GEO_Detail &myGdp;
187 };
188 #endif
GLint GLuint mask
Definition: glcorearb.h:123
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:211
GA_Size GA_Offset
Definition: GA_Types.h:617
#define GEO_API
Definition: GEO_API.h:10
Contains transitional objects to provide some backward compatibility for code that references old GEO...
GEO_API const TypeMask GEOSPLINE