00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __GU_Copy__
00031 #define __GU_Copy__
00032
00033 #include "GU_API.h"
00034 #include <UT/UT_VectorTypes.h>
00035 class GB_PrimitiveGroup;
00036 class GB_PointGroup;
00037 class GU_Detail;
00038 class UT_String;
00039 class UT_Interrupt;
00040
00041 class gu_CopyAttribMap;
00042
00043 typedef int (*GU_CopyTransformCallback)(UT_Matrix4 &, int copynum,
00044 const GEO_Point *template_point,
00045 int template_pt_num, void *data);
00046
00047 typedef int (*GU_CopyGroupNameCallback)(UT_String &, void *data);
00048
00049 typedef int (*GU_CopySourceCallback)
00050 (const GU_Detail *&src, const GB_PrimitiveGroup *&grp,
00051 void *data);
00052
00053
00054 class GU_API GU_CopyParms {
00055 public:
00056 GU_CopyParms();
00057 ~GU_CopyParms();
00058
00059 enum GU_AttribOp { GU_SET_ATTRIB,
00060 GU_ADD_ATTRIB,
00061 GU_SUB_ATTRIB,
00062 GU_MUL_ATTRIB };
00063
00064 void setTemplate(const GU_Detail &gdp, const GB_PointGroup *ptgrp=0);
00065
00066
00067
00068 void setPointAttrib(const char *pattern, GU_AttribOp op);
00069 void setPrimAttrib(const char *pattern, GU_AttribOp op);
00070 void setVertexAttrib(const char *pattern, GU_AttribOp op);
00071 void setKeepVectorLength(int onoff) { myKeepFlag = onoff; }
00072 void setPreserveGroups(int onoff) { myPreserveGroups = onoff; }
00073 void setTransformCallback(GU_CopyTransformCallback callback)
00074 {
00075 myXformCallback = callback;
00076 }
00077 void setGroupNameCallback(GU_CopyGroupNameCallback callback)
00078 {
00079 myGNameCallback = callback;
00080 }
00081
00082
00083
00084 void setSource(const GU_Detail *gdp,
00085 const GB_PrimitiveGroup *primgrp=0)
00086 {
00087 mySource = gdp;
00088 myPrimGroup = primgrp;
00089 }
00090
00091 void setSourceCallback(GU_CopySourceCallback callback)
00092 {
00093 mySourceCallback = callback;
00094 }
00095
00096 void copy(GU_Detail &gdp, int ncopies, void *data = 0);
00097
00098 private:
00099
00100 void transform(GU_Detail *gdp, const UT_Matrix4 &xform,
00101 GB_PrimitiveGroup *grp, int primcnt,
00102 int ptcnt,
00103 const GEO_Point *tppt = 0);
00104
00105 int singleCopy(GU_Detail *gdp, int ncopies, void *data,
00106 const GEO_Point *ptptr, int tnum, int ltnum,
00107 UT_Interrupt *boss);
00108
00109 void setAttribMap(gu_CopyAttribMap *&, const char *pattern,
00110 GU_AttribOp op);
00111
00112
00113
00114
00115 void fixAttribMaps(GU_Detail &gdp, const GU_Detail *src);
00116
00117
00118 void applyPointMap(GEO_Point *ppt, const GEO_Point *tppt);
00119 void applyPrimMap(GEO_Primitive *prim, const GEO_Point *tppt);
00120
00121 GU_CopyTransformCallback myXformCallback;
00122 GU_CopyGroupNameCallback myGNameCallback;
00123 GU_CopySourceCallback mySourceCallback;
00124 const GU_Detail *myTemplate;
00125 const GU_Detail *mySource;
00126 const GB_PrimitiveGroup *myPrimGroup;
00127 const GB_PointGroup *myPointGroup;
00128 gu_CopyAttribMap *myPointMap;
00129 gu_CopyAttribMap *myPrimMap;
00130 gu_CopyAttribMap *myVertexMap;
00131
00132 int mySourcePointCount;
00133 int mySourcePrimCount;
00134 int myXformFlag;
00135 int myKeepFlag;
00136 int myPreserveGroups;
00137 };
00138
00139 #endif
00140