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