HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PolyKnit.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: GU Library.
7  *
8  * COMMENTS: Class that does the work for the PolyKnit sop.
9  *
10  */
11 #ifndef __GU_PolyKnit_h__
12 #define __GU_PolyKnit_h__
13 
14 #include "GU_API.h"
15 #include <UT/UT_IntArray.h>
16 #include <UT/UT_Array.h>
17 #include <GEO/GEO_Closure.h>
19 
20 class UT_BitArray;
21 class GEO_PrimPoly;
22 class GU_Detail;
23 class gu_WeightPathPair;
24 class gu_WeightPriorityQueue;
25 
26 // The kinds of polygons that can be built with PolyKnit. Meta polygons are
27 // really many polygons that are composed of a path along the connected
28 // geometry.
30 {
35 };
36 
37 /// Parameters for PolyKnit
39 {
40 public:
41  bool myUnique;
45 };
46 
48 {
49 public:
50  GU_PolyKnit(GU_Detail *gdp);
51 
53 
54  /// Builds the polygons in destgdp form the arrays of points and types
55  /// Returns true if completely successful, false otherwise
56  bool buildPolygons(GU_Detail *destgdp,
57  const UT_IntArray &ptarray,
58  const UT_IntArray &typearray,
59  const GU_PolyKnitParms &parms,
60  GA_PrimitiveGroup *resultprims);
61 
62 
63  // Finds the shortest path from srcpt to destpt and returns true.
64  // NOTE: This function assumes that the two points are connected
65  bool getShortestPath(GA_Offset srcpt, GA_Offset destpt,
66  UT_Array<GA_Offset> &ptlist);
67 
68  /// Returns true if the two points are connected, and false otherwise.
69  /// It uses and adds to our point connector
70  bool arePointsConnected(GA_Offset srcpt, GA_Offset destpt);
71 
72 private:
73  // Recalculates the new weights and paths from this new point (srcpt)
74  void updateWeights(GA_Offset srcpt, float src_w,
75  UT_Array<GA_Offset> &src_path,
76  gu_WeightPriorityQueue &pq);
77 
78  void updateWeightsForPoint(GA_Offset srcpt,
79  GA_Offset nextpt,
80  float src_w,
81  UT_Array<GA_Offset> &src_path,
82  gu_WeightPriorityQueue &pq,
83  UT_BitArray &visited);
84 
85  // Helper functions for buildPolygons. They all return true if the
86  // succeed and false otherwise
87  bool buildTriangle(GU_Detail *gdp, const UT_IntArray &ptarray,
88  const UT_Array<GA_Offset> &newptarray,
89  int i, bool reverse_poly, bool remove_degenerates,
90  bool unique, GEO_PrimPoly *&poly);
91  bool buildQuad(GU_Detail *gdp, const UT_IntArray &ptarray,
92  const UT_Array<GA_Offset> &newptarray,
93  int i, bool reverse_poly, bool remove_degenerates,
94  bool unique, bool collapse_quads,
95  GEO_PrimPoly *&poly);
96  bool buildMetaTriangle(GU_Detail *gdp,
97  const UT_IntArray &ptarray,
98  UT_Array<GA_Offset> &newptarray,
99  int idx, bool reverse_poly, bool remove_degenerates,
100  bool unique, GA_PrimitiveGroup *resultprims);
101  bool buildMetaQuad(GU_Detail *gdp, const UT_IntArray &ptarray,
102  UT_Array<GA_Offset> &newptarray,
103  int idx, bool reverse_poly, bool remove_degenerates,
104  bool unique, bool collapse_quads,
105  GA_PrimitiveGroup *resultprims);
106 
107  // Takes the points in srcptlist and copies them to the gdp, making note
108  // of it in newptarray
109  void createNewPoints(GU_Detail *gdp,
110  const UT_Array<GA_Offset> &srcptlist,
111  UT_Array<GA_Offset> &newptarray);
112 
113  // Re-orders the given points so that the two source points are connected
114  // and the two destination points are connected. If we can't do that
115  // we return false, otherwise we return true. Order is also important,
116  // so we try to keep the order (srcpt0 doesn't change)
117  bool reorderPoints(GA_Offset srcpt0, GA_Offset &srcpt1,
118  GA_Offset &destpt0, GA_Offset &destpt1);
119  // This version tries to make sure that destpt0 and destpt1 are connected
120  bool reorderPoints(GA_Offset &srcpt, GA_Offset &destpt0,
121  GA_Offset &destpt1);
122 
123  // Just build a triangle/quad with the given point numbers, the unique flag
124  // says where to grab the points from (the new point list or the gdp),
125  // and the reverse flag says whether or not the point orders should be
126  // reversed
127  GEO_PrimPoly *createTriangle(int i0, int i1, int i2,
128  bool unique, bool reverse, GU_Detail *gdp,
129  UT_Array<GA_Offset> &newptarray);
130  GEO_PrimPoly *createQuad(int i0, int i1, int i2, int i3, bool unique,
131  bool reverse, GU_Detail *gdp,
132  UT_Array<GA_Offset> &newptarray);
133 
134 
135  GU_Detail *myGdp;
136  GEO_Closure myClosure;
137  GEO_PointClassifier myPointClassifier;
138 };
139 
140 #endif
GLint GLint i2
Definition: glad.h:2724
void reverse(I begin, I end)
Definition: pugixml.cpp:7190
GA_Size GA_Offset
Definition: GA_Types.h:646
Parameters for PolyKnit.
Definition: GU_PolyKnit.h:38
GU_PolyKnitType
Definition: GU_PolyKnit.h:29
bool myRemoveDegenerates
Definition: GU_PolyKnit.h:43
GLint i1
Definition: glad.h:2724
#define GU_API
Definition: GU_API.h:14
I unique(I begin, I end)
Definition: pugixml.cpp:7195