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