HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GU_Copy.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_Copy.h ( GU Library, C++)
7  *
8  * COMMENTS: Copy one gdp with a transform. Optionally with a template
9  * object
10  *
11  * When a template is used, the copies will be made in the
12  * loop order:
13  * foreach template_point {
14  * foreach copy {
15  * getmatrix();
16  * makecopy();
17  * }
18  * }
19  * This allows for a cumulative transform to be applied.
20  */
21 
22 #ifndef __GU_Copy__
23 #define __GU_Copy__
24 
25 #include "GU_API.h"
26 #include <UT/UT_VectorTypes.h>
27 class GA_PrimitiveGroup;
28 class GA_PointGroup;
29 class GU_Detail;
30 class UT_String;
31 class UT_Interrupt;
32 class GEO_Primitive;
33 
34 class gu_CopyAttribMap;
35 class gu_CopyTransformAttributes;
36 
37 typedef int (*GU_CopyTransformCallback)(UT_Matrix4 &, int copynum,
38  const GU_Detail *templategdp,
39  GA_Offset templateptoff,
40  int template_pt_num, void *data);
41 
43 
44 typedef int (*GU_CopySourceCallback)
45  (const GU_Detail *&src, const GA_PrimitiveGroup *&grp,
46  void *data);
47 
49 {
50 public:
51  GU_CopyParms();
52  ~GU_CopyParms();
53 
57  GU_MUL_ATTRIB };
58 
59  void setTemplate(const GU_Detail &gdp, const GA_PointGroup *ptgrp=0);
60 
61  // Patterns for attribute copying from template to copies...
62  // The template geometry must be set before these methods are called
63  void setPointAttrib(const char *pattern, GU_AttribOp op);
64  void setPrimAttrib(const char *pattern, GU_AttribOp op);
65  void setVertexAttrib(const char *pattern, GU_AttribOp op);
66  void setKeepVectorLength(int onoff) { myKeepFlag = onoff; }
67  void setPreserveGroups(int onoff) { myPreserveGroups = onoff; }
68  void setKeepInternalGroups(bool keep) { myKeepInternalGroups = keep; }
70  {
71  myXformCallback = callback;
72  }
74  {
75  myGNameCallback = callback;
76  }
77 
78  // If a setSource is used, the callback is ignored.
79 
80  void setSource(const GU_Detail *gdp,
81  const GA_PrimitiveGroup *primgrp=0)
82  {
83  mySource = gdp;
84  myPrimGroup = primgrp;
85  }
86 
88  {
89  mySourceCallback = callback;
90  }
91 
92  void copy(GU_Detail &gdp, int ncopies, void *data = 0);
93 
94 
95  // Apply attribute operations to point/primitive/vertex attributes
96  void applyPointMap(GA_Offset ptoff, GA_Offset tptoff) const;
97  void applyPrimMap(GA_Detail *detail, GA_Offset primoff, GA_Offset tptoff) const;
98 
99  bool needToApplyPointMap() const
100  {
101  return myPointMap;
102  }
103  bool needToApplyPrimMap() const
104  {
105  return myPrimMap || myVertexMap;
106  }
107 
108 private:
109 
110  bool singleCopy(gu_CopyTransformAttributes &xformer,
111  GU_Detail *gdp, int ncopies, void *data,
112  GA_Offset tptoff, int tnum, int ltnum,
113  UT_Interrupt *boss,
114  bool multi_merge);
115  bool multiCopy(GU_Detail *gdp,
116  int ncopies,
117  void *data,
118  UT_Interrupt *boss);
119 
120  void setAttribMap(gu_CopyAttribMap *&, const char *pattern,
121  GU_AttribOp op);
122 
123  // Ensure that we have the correct attributes on gdp and that the offsets
124  // are correct (c.f. the src). We append any maps after the source
125  // attribs.
126  void fixAttribMaps(GU_Detail &gdp, const GU_Detail *src);
127 
128  GU_CopyTransformCallback myXformCallback;
129  GU_CopyGroupNameCallback myGNameCallback;
130  GU_CopySourceCallback mySourceCallback;
131  const GU_Detail *myTemplate;
132  const GU_Detail *mySource;
133  const GA_PrimitiveGroup *myPrimGroup;
134  const GA_PointGroup *myPointGroup;
135  gu_CopyAttribMap *myPointMap;
136  gu_CopyAttribMap *myPrimMap;
137  gu_CopyAttribMap *myVertexMap;
138 
139  int mySourcePointCount;
140  int mySourcePrimCount;
141  int myKeepFlag;
142  int myPreserveGroups;
143  bool myKeepInternalGroups;
144 };
145 
146 #endif
147 
void setKeepVectorLength(int onoff)
Definition: GU_Copy.h:66
void setGroupNameCallback(GU_CopyGroupNameCallback callback)
Definition: GU_Copy.h:73
void setSourceCallback(GU_CopySourceCallback callback)
Definition: GU_Copy.h:87
void setPreserveGroups(int onoff)
Definition: GU_Copy.h:67
GA_Size GA_Offset
Definition: GA_Types.h:617
bool needToApplyPrimMap() const
Definition: GU_Copy.h:103
void setTransformCallback(GU_CopyTransformCallback callback)
Definition: GU_Copy.h:69
int(* GU_CopyGroupNameCallback)(UT_String &, void *data)
Definition: GU_Copy.h:42
bool needToApplyPointMap() const
Definition: GU_Copy.h:99
#define GU_API
Definition: GU_API.h:11
GLboolean * data
Definition: glcorearb.h:130
int(* GU_CopyTransformCallback)(UT_Matrix4 &, int copynum, const GU_Detail *templategdp, GA_Offset templateptoff, int template_pt_num, void *data)
Definition: GU_Copy.h:37
typedef int
Definition: png.h:1175
Container class for all geometry.
Definition: GA_Detail.h:96
int(* GU_CopySourceCallback)(const GU_Detail *&src, const GA_PrimitiveGroup *&grp, void *data)
Definition: GU_Copy.h:45
void setSource(const GU_Detail *gdp, const GA_PrimitiveGroup *primgrp=0)
Definition: GU_Copy.h:80
void setKeepInternalGroups(bool keep)
Definition: GU_Copy.h:68
int keep
Definition: png.h:2568
GLenum src
Definition: glcorearb.h:1792