00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GEO_Detail_h__
00021 #define __GEO_Detail_h__
00022
00023 #include "GEO_API.h"
00024 #include <UT/UT_Color.h>
00025 #include <UT/UT_Vector3.h>
00026 #include <UT/UT_Vector3Array.h>
00027 #include <UT/UT_PtrArray.h>
00028 #include <UT/UT_IntArray.h>
00029 #include <UT/UT_FloatArray.h>
00030 #include <GB/GB_Detail.h>
00031 #include "GEO_Point.h"
00032 #include "GEO_Primitive.h"
00033 #include "GEO_PointList.h"
00034 #include "GEO_PrimList.h"
00035 #include "GEO_AttribDict.h"
00036 #include "GEO_Macros.h"
00037 #include "GEO_AttributeOwner.h"
00038
00039 class UT_Matrix4;
00040 class UT_DMatrix4;
00041 class UT_HashTable;
00042 class UT_String;
00043 class UT_IStream;
00044 class GB_Breakpoint;
00045 class GB_BreakpointGroup;
00046 class GB_Edge;
00047 class GB_EdgeGroup;
00048 class GB_VertexGroup;
00049 class GEO_Vertex;
00050 class GEO_MetaExpression;
00051 class GEO_AttributeHandle;
00052 class GEO_AttributeListHandle;
00053 class GEO_Rolloff;
00054 class GEO_Delta;
00055 class GEO_MirrorParms;
00056 class GEO_PointRedirectArray;
00057 class GEO_PointTree;
00058 class TS_MetaExpression;
00059 class GEO_TempVertexCache;
00060 class GEO_TempPointCache;
00061
00062
00063
00064
00065
00066 #define GEO_STD_ATTRIB_NORMAL "N"
00067 #define GEO_STD_ATTRIB_TEXTURE "uv"
00068 #define GEO_STD_ATTRIB_VELOCITY "v"
00069 #define GEO_STD_ATTRIB_MATERIAL "shop_materialpath"
00070 #define GEO_STD_ATTRIB_OGLSHOP "ogl_shop"
00071 #define GEO_STD_ATTRIB_DIFFUSE "Cd"
00072 #define GEO_STD_ATTRIB_ALPHA "Alpha"
00073 #define GEO_STD_ATTRIB_COM "com"
00074 #define GEO_STD_ATTRIB_DISTANCE "dist"
00075 #define GEO_STD_ATTRIB_LOD "lod"
00076 #define GEO_STD_ATTRIB_REST "rest"
00077 #define GEO_STD_ATTRIB_MASS "mass"
00078 #define GEO_STD_ATTRIB_DRAG "drag"
00079 #define GEO_STD_ATTRIB_TENSION "tension"
00080 #define GEO_STD_ATTRIB_SPRINGK "springk"
00081 #define GEO_STD_ATTRIB_LIFE "life"
00082 #define GEO_STD_ATTRIB_DIST "dist"
00083 #define GEO_STD_ATTRIB_UP "up"
00084 #define GEO_STD_ATTRIB_ID "id"
00085 #define GEO_STD_ATTRIB_PSCALE "pscale"
00086 #define GEO_STD_ATTRIB_CREASE "creaseweight"
00087 #define GEO_STD_ATTRIB_AREA "area"
00088 #define GEO_STD_ATTRIB_PERIMETER "perimeter"
00089 #define GEO_STD_ATTRIB_WIDTH "width"
00090 #define GEO_STD_ATTRIB_LAYERMERGE "layermerge"
00091 #define GEO_STD_ATTRIB_SEGS "segs"
00092 #define GEO_STD_ATTRIB_DIV "div"
00093 #define GEO_STD_ATTRIB_LAGE "lage"
00094 #define GEO_STD_ATTRIB_ARC "arc"
00095 #define GEO_STD_ATTRIB_GEN "gen"
00096 #define GEO_STD_ATTRIB_TUBECAPTURE "tubeCapt"
00097 #define GEO_STD_ATTRIB_PNT_CAPTURE "pCapt"
00098 #define GEO_STD_ATTRIB_PNT_CAPTURE_ALPHA "pCaptAlpha"
00099 #define GEO_STD_ATTRIB_PNT_CAPTURE_PATH "pCaptPath"
00100 #define GEO_STD_ATTRIB_PNT_CAPTURE_DATA "pCaptData"
00101 #define GEO_STD_ATTRIB_CAPTUREFRAME "pCaptFrame"
00102 #define GEO_STD_ATTRIB_CAPT_SKELROOT "pCaptSkelRoot"
00103 #define GEO_STD_ATTRIB_WIRE_CAPT "wireCapt"
00104 #define GEO_STD_ATTRIB_WIRE_CAPT_U "wireCaptU"
00105 #define GEO_STD_ATTRIB_WIRE_CAPT_V "wireCaptV"
00106 #define GEO_STD_ATTRIB_WIRE_CAPT_PRIMU "wireCaptPrimU"
00107 #define GEO_STD_ATTRIB_META_CAPT "metaCapt"
00108 #define GEO_STD_ATTRIB_META_CAPT_FRAME "metaCaptFrame"
00109 #define GEO_STD_ATTRIB_META_CAPT_GROUPS "metaCaptGroups"
00110 #define GEO_STD_ATTRIB_META_CAPT_ROOT "metaCaptRoot"
00111 #define GEO_STD_ATTRIB_META_CAPT_PATHS "metaCaptPaths"
00112 #define GEO_STD_ATTRIB_META_CAPT_DATA "metaCaptData"
00113 #define GEO_STD_ATTRIB_META_CAPT_GROUP_MAP "metaCaptGroupMap"
00114 #define GEO_STD_ATTRIB_META_SLIDE "slideModifier"
00115 #define GEO_STD_ATTRIB_INFLATE_MODIFIER "inflatemodifier"
00116 #define GEO_STD_ATTRIB_INTERNAL_CHANGED_POINTS "internalChangedPoints"
00117 #define GEO_STD_ATTRIB_MUSCLE_REST_ANCHOR "restAnchor"
00118 #define GEO_STD_ATTRIB_MUSCLE_REST_XFORMS "restTransforms"
00119 #define GEO_STD_ATTRIB_MUSCLE_INFLATE_NORM "muscleInflateNormal"
00120 #define GEO_STD_ATTRIB_MUSCLE_POSITION_BIAS "positionbiasvalues"
00121 #define GEO_STD_ATTRIB_RIXLATE "rixlate"
00122 #define GEO_STD_ATTRIB_MATERIAL_PATH "shop_materialpath"
00123
00124
00125
00126
00127 enum GEO_Standard_Attributes {
00128 GEO_ATTRIBUTE_NORMAL,
00129 GEO_ATTRIBUTE_TEXTURE,
00130 GEO_ATTRIBUTE_VELOCITY,
00131 GEO_ATTRIBUTE_MATERIAL,
00132 GEO_ATTRIBUTE_DIFFUSE,
00133 GEO_ATTRIBUTE_ALPHA,
00134 GEO_ATTRIBUTE_COM,
00135 GEO_ATTRIBUTE_DISTANCE,
00136 GEO_ATTRIBUTE_LOD,
00137 GEO_ATTRIBUTE_REST,
00138 GEO_ATTRIBUTE_MASS,
00139 GEO_ATTRIBUTE_DRAG,
00140 GEO_ATTRIBUTE_TENSION,
00141 GEO_ATTRIBUTE_SPRINGK,
00142 GEO_ATTRIBUTE_LIFE,
00143 GEO_ATTRIBUTE_DIST,
00144 GEO_ATTRIBUTE_UP,
00145 GEO_ATTRIBUTE_ID,
00146 GEO_ATTRIBUTE_PSCALE,
00147 GEO_ATTRIBUTE_CREASE,
00148 GEO_ATTRIBUTE_AREA,
00149 GEO_ATTRIBUTE_PERIMETER,
00150 GEO_ATTRIBUTE_WIDTH,
00151 GEO_ATTRIBUTE_OGLSHOP,
00152 GEO_ATTRIBUTE_LAYERMERGE,
00153 GEO_ATTRIBUTE_SEGS,
00154 GEO_ATTRIBUTE_DIV,
00155 GEO_ATTRIBUTE_LAGE,
00156 GEO_ATTRIBUTE_ARC,
00157 GEO_ATTRIBUTE_GEN,
00158 GEO_NUM_STANDARD_ATTRIBUTE
00159 };
00160
00161 class GEO_API GEO_Detail : public GB_Detail {
00162 public:
00163 GEO_Detail();
00164 virtual ~GEO_Detail();
00165
00166
00167
00168
00169 virtual void clearAndDestroy();
00170
00171
00172
00173
00174 virtual int save(const char *, int binary,
00175 const UT_Options *options) const;
00176 virtual int save(ostream& os, int binary,
00177 const UT_Options *options) const;
00178 virtual int load(const char *, const UT_Options *options);
00179 virtual bool load(UT_IStream &is, const UT_Options *options);
00180
00181
00182
00183
00184
00185 virtual int saveVertex(ostream &os,const GB_Vertex &vtx,int b) const;
00186 virtual bool loadVertex(UT_IStream &is,GB_Vertex &vtx);
00187
00188 bool loadPoint(UT_IStream &is, GEO_Point &pt);
00189 int saveBinaryPoint(ostream &os, const GEO_Point &pt) const;
00190 int saveASCIIPoint (ostream &os, const GEO_Point &pt) const;
00191
00192
00193
00194
00195 void merge(GEO_Detail &src, const GB_PrimitiveGroup *primGrp = 0,
00196 int mergePrimGroup = 1, int insertPrimsAtHead= 0,
00197 GEO_PointRedirectArray *dest_to_src_ptarray=0,
00198 bool keep_internal_groups = true);
00199 void mergePoints(const GEO_Detail &src,
00200 const GB_PointGroup *ptGrp = 0,
00201 GEO_Point **ptredirect = 0,
00202 int merge_groups = 1,
00203 bool keep_internal_groups = true);
00204
00205 void merge(GEO_Primitive &sprim, int insertPrimAtHead = 0);
00206
00207 int copy(const GEO_Detail &src, int method = GB_COPY_ONCE,
00208 bool collapse_on_end = true,
00209 bool keep_internal_groups = true);
00210
00211 void collapseIndexAttributes();
00212
00213
00214 void mirror(GEO_MirrorParms &parms);
00215
00216
00217
00218
00219
00220
00221
00222 void transform(const UT_Matrix4 &mat,
00223 const GB_PrimitiveGroup *primGrp = 0,
00224 const GB_PointGroup *pointClosure = 0,
00225 int quickxform = 0,
00226 int keep_vector_lengths = 1,
00227 int check_pasting = 1,
00228 int neg_determinant_flipvector = 1,
00229 int update_ptnormals = 0,
00230 GEO_Delta *geodelta = 0);
00231
00232 void translate(const UT_Vector3 &delta,
00233 const GB_PrimitiveGroup *primGrp = 0,
00234 const GB_PointGroup *pointClosure = 0,
00235 int check_pasting = 1,
00236 int update_ptnormals = 0,
00237 GEO_Delta *geodelta = 0);
00238
00239
00240
00241
00242 void transformPoints(const UT_Matrix4 &mat,
00243 const GB_PointGroup *pointGroup = 0,
00244 const GB_PrimitiveGroup *primClosure = 0,
00245 int quickxform = 0,
00246 int keep_vector_lengths = 1,
00247 int check_pasting = 1,
00248 int neg_determinant_flipvector = 1,
00249 int update_ptnormals = 0,
00250 GEO_Delta *geodelta = 0);
00251
00252 void translatePoints(const UT_Vector3 &delta,
00253 const GB_PointGroup *pointGroup = 0,
00254 int check_pasting = 1,
00255 int update_ptnormals = 0,
00256 GEO_Delta *geodelta = 0);
00257
00258
00259
00260 void transformEdges(const UT_Matrix4 &mat,
00261 const GB_EdgeGroup *edgegrp = 0,
00262 const GB_PrimitiveGroup *primclosure = 0,
00263 int quickxform = 0,
00264 int keep_vector_lengths = 1,
00265 int check_pasting = 1,
00266 int neg_determinant_flipvector = 1,
00267 int update_ptnormals = 0,
00268 GEO_Delta *geodelta = 0);
00269
00270 void translateEdges(const UT_Vector3 &delta,
00271 const GB_EdgeGroup *edgegrp = 0,
00272 int check_pasting = 1,
00273 int update_ptnormals = 0,
00274 GEO_Delta *geodelta = 0);
00275
00276
00277 void transformBreakpoints(const UT_Matrix4 &mat,
00278 const GB_BreakpointGroup *grp = 0,
00279 int quickxform = 0,
00280 int update_ptnormals = 0,
00281 GEO_Delta *geodelta = 0);
00282
00283 void translateBreakpoints(const UT_Vector3 &delta,
00284 const GB_BreakpointGroup *grp = 0,
00285 int update_ptnormals = 0,
00286 GEO_Delta *geodelta = 0);
00287
00288
00289
00290 void transformGroup(const UT_Matrix4 &mat, const GB_BaseGroup &grp,
00291 int quickxform = 0,
00292 int keep_vector_lengths = 1,
00293 int check_pasting = 1,
00294 int neg_determinant_flipvector = 1,
00295 const GB_PointGroup *ptclosure = 0,
00296 const GB_PrimitiveGroup *primclosure = 0,
00297 int update_ptnormals = 0,
00298 GEO_Delta *geodelta = 0);
00299
00300 void translateGroup(const UT_Vector3 &delta,
00301 const GB_BaseGroup &grp,
00302 int check_pasting = 1,
00303 const GB_PointGroup *ptclosure = 0,
00304 int update_ptnormals = 0,
00305 GEO_Delta *geodelta = 0);
00306
00307 void visualizeSoftPoints(const GEO_Rolloff &rolloff,
00308 const GB_PointGroup *ptgroup,
00309 UT_ColorRamp ramp);
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 void computeNormal(const GEO_Point &point, UT_Vector3 &nml) const;
00334
00335
00336
00337 void computeNormalInternal(const GEO_Point &point, UT_Vector3 &nml);
00338
00339
00340 void computeNormal(const GEO_Primitive &prim, UT_Vector3 &nml) const;
00341
00342
00343 void computeNormal(const GB_Edge &edge, UT_Vector3 &nml) const;
00344
00345
00346
00347 void computeNormalInternal(const GB_Edge &edge, UT_Vector3 &nml);
00348
00349
00350
00351 void computeNormal(const GB_Breakpoint &bkpt, UT_Vector3 &nml) const;
00352
00353
00354
00355 void normalTranslatePoints(float length = 1.0F,
00356 int check_pasting = 1,
00357 const GB_PointGroup *grp = 0,
00358 int update_ptnormals = 0,
00359 GEO_Delta *geodelta = 0);
00360 void normalTranslatePrimitives(float length = 1.0F,
00361 int check_pasting = 1,
00362 const GB_PrimitiveGroup *grp = 0,
00363 int update_ptnormals = 0,
00364 GEO_Delta *geodelta = 0);
00365 void normalTranslate(const GB_PointGroup &grp,
00366 float length = 1.0F, int check_pasting = 1,
00367 int update_ptnormals = 0,
00368 GEO_Delta *geodelta = 0);
00369 void normalTranslate(const GB_PrimitiveGroup &grp,
00370 float length = 1.0F, int check_pasting = 1,
00371 int update_ptnormals = 0,
00372 GEO_Delta *geodelta = 0);
00373 void normalTranslate(const GB_EdgeGroup &grp,
00374 float length = 1.0F, int check_pasting = 1,
00375 int update_ptnormals = 0,
00376 GEO_Delta *geodelta = 0);
00377 void normalTranslate(const GB_BreakpointGroup &grp,
00378 float length = 1.0F, int check_pasting = 1,
00379 int update_ptnormals = 0,
00380 GEO_Delta *geodelta = 0);
00381 void normalTranslateGroup(const GB_BaseGroup &grp,
00382 float length = 1.0F, int check_pasting = 1,
00383 int update_ptnormals = 0,
00384 GEO_Delta *geodelta = 0);
00385
00386
00387 void softTransformPoints(const UT_XformOrder &order,
00388 float tx, float ty, float tz,
00389 float rx, float ry, float rz,
00390 float sx, float sy, float sz,
00391 float s_xy, float s_xz, float s_yz,
00392 float px, float py, float pz,
00393 const GEO_Rolloff &rolloff,
00394 const GB_PointGroup *ptgroup = 0,
00395 int quickxform = 0,
00396 int keep_vector_lengths = 1,
00397 int check_pasting = 1,
00398 int neg_determinant_flipvector = 1,
00399 int update_ptnormals = 0,
00400 GEO_Delta *geodelta = 0);
00401 void softTransformEdges(const UT_XformOrder &order,
00402 float tx, float ty, float tz,
00403 float rx, float ry, float rz,
00404 float sx, float sy, float sz,
00405 float s_xy, float s_xz, float s_yz,
00406 float px, float py, float pz,
00407 const GEO_Rolloff &rolloff,
00408 const GB_EdgeGroup *edgegrp = 0,
00409 int quickxform = 0,
00410 int keep_vector_lengths = 1,
00411 int check_pasting = 1,
00412 int neg_determinant_flipvector = 1,
00413 int update_ptnormals = 0,
00414 GEO_Delta *geodelta = 0);
00415
00416
00417 void softTranslatePoints(const UT_Vector3 &delta,
00418 const GEO_Rolloff &rolloff,
00419 const GB_PointGroup *ptgroup = 0,
00420 int check_pasting = 1,
00421 int update_ptnormals = 0,
00422 GEO_Delta *geodelta = 0);
00423 void softTranslateEdges(const UT_Vector3 &delta,
00424 const GEO_Rolloff &rolloff,
00425 const GB_EdgeGroup *edgegrp = 0,
00426 int check_pasting = 1,
00427 int update_ptnormals = 0,
00428 GEO_Delta *geodelta = 0);
00429
00430
00431 void softNormalTranslatePoints(float distance,
00432 const GEO_Rolloff &rolloff,
00433 const GB_PointGroup *ptgroup = 0,
00434 int along_lead_normal = 1,
00435 int check_pasting = 1,
00436 int update_ptnormals = 0,
00437 GEO_Delta *geodelta = 0);
00438
00439
00440
00441
00442
00443 virtual int normal(int internal=0, GB_PrimitiveGroup *primgroup = 0) = 0;
00444 virtual void normal(UT_Vector3Array &output, bool use_internaln = true) const = 0;
00445
00446
00447
00448
00449 enum CaptureType
00450 {
00451 CAPTURE_BONE = 0,
00452 CAPTURE_META,
00453 CAPTURE_WIRE
00454 };
00455
00456
00457
00458 static const char *getPointCaptureAttribName(CaptureType type);
00459
00460
00461
00462
00463 static const char *getPointCaptureIndexAttribName(CaptureType type);
00464
00465
00466
00467 static const char *getPointCaptureFrameAttribName(CaptureType type);
00468
00469
00470
00471 static const char *getPointCaptureRootAttribName(CaptureType type);
00472
00473
00474
00475
00476 static const char *getPointCaptureDataAttribName(CaptureType type);
00477
00478
00479
00480
00481
00482 static int getPointCaptureDataAttribEntrySize(CaptureType t);
00483
00484
00485
00486 bool getCaptureRegionRootPath(UT_String &root_path,
00487 CaptureType t = CAPTURE_BONE) const;
00488 bool setCaptureRegionRootPath(const UT_String &root_path,
00489 CaptureType t = CAPTURE_BONE);
00490
00491
00492
00493 int getCaptureRegionIndex(const UT_String &cregion_name,
00494 CaptureType t = CAPTURE_BONE);
00495
00496
00497
00498
00499 int addCaptureRegion(const UT_String &cregion_name,
00500 const UT_Matrix4 &parent_xform,
00501 const GEO_Detail *tube_gdp);
00502
00503
00504
00505 int addCaptureRegion(const UT_String &cregion_name,
00506 CaptureType type);
00507
00508
00509
00510 int removeCaptureRegion(const UT_String &cregion_name,
00511 CaptureType t = CAPTURE_BONE);
00512
00513
00514
00515
00516 static int constructCaptureRegionDetailData(
00517 const char *cregion_name,
00518 const UT_Matrix4 &parent_xform,
00519 const GEO_Detail *tube_gdp,
00520 float *tube_data );
00521
00522
00523 void setCaptureWeight(int cregion_index, float weight,
00524 const GB_PointGroup *ptgroup = 0,
00525 GEO_Delta *geodelta = 0,
00526 int add_weight = 0,
00527 int clamp_negative = 0,
00528 int normalizeweight = 0,
00529 CaptureType t = CAPTURE_BONE);
00530
00531
00532 void setCaptureWeight(int cregion_index, float weight,
00533 GEO_Point *ppt,
00534 GEO_Delta *geodelta = 0,
00535 int add_weight = 0,
00536 int clamp_negative = 0,
00537 int normalizeweight = 0,
00538 CaptureType t = CAPTURE_BONE);
00539
00540
00541 float getCaptureWeight(int cregion_index, const GEO_Point *ppt,
00542 CaptureType t = CAPTURE_BONE) const;
00543
00544
00545 int addAverageCaptureWeight( const GB_PointGroup *ptgroup,
00546 const UT_String &root_path,
00547 UT_HashTable &averages ) const;
00548
00549 void getCaptureWeights(const GEO_Point *ppt, UT_IntArray ®ions,
00550 UT_FloatArray &weights,
00551 CaptureType t = CAPTURE_BONE) const;
00552 void clearCaptureWeights(GEO_Point *ppt,
00553 CaptureType t = CAPTURE_BONE);
00554
00555 enum VisualizationType
00556 {
00557 VISTYPE_SINGLE,
00558 VISTYPE_MULTIPLE
00559 };
00560
00561
00562 void colorPointsByCaptureWeight(
00563 const UT_PtrArray<const UT_Vector3 *> &colors,
00564 const UT_Vector3 &zero_weight_color,
00565 CaptureType t = CAPTURE_BONE,
00566 VisualizationType vistype = VISTYPE_MULTIPLE,
00567 UT_ColorRamp singlevismode = UT_COLORRAMP_FALSE);
00568
00569 void normalizeCaptureWeights(const GB_PointGroup *ptgroup = 0,
00570 CaptureType t = CAPTURE_BONE);
00571
00572
00573
00574
00575
00576 void clampCaptureWeights(const GB_PointGroup *ptgroup = 0,
00577 bool clamp_low_flag = true,
00578 float low_threshold = 0.0f, float low_val = 0.0f,
00579 bool clamp_hi_flag = false,
00580 float hi_threshold = 1.0f, float hi_val = 1.0f,
00581 CaptureType t = GEO_Detail::CAPTURE_BONE);
00582
00583
00584 void normalizeRelativeCaptureWeights(int idx, GEO_Point *pt,
00585 GEO_Delta *delta=0);
00586
00587
00588
00589
00590
00591
00592 GEO_Point *insertPoint(const GEO_Point *beforeWhich = 0);
00593 GEO_Point *appendPoint() { return insertPoint(0); }
00594 GEO_Point *insertPoint(const UT_Vector4 &pos,
00595 GB_AttributeData &adata,
00596 short stealattrib = 0,
00597 const GEO_Point *beforeWhich = 0);
00598 GEO_Point *appendPoint(const UT_Vector4 &pos,
00599 GB_AttributeData &adata,
00600 short stealattrib = 0)
00601 { return insertPoint(pos, adata, stealattrib); }
00602
00603
00604
00605
00606 GEO_Point *allocateTempPoint();
00607 void deleteTempPoint(GEO_Point *pt);
00608
00609
00610
00611
00612 GEO_Vertex *allocateTempVertex(GEO_Point *pt);
00613 void deleteTempVertex(GEO_Vertex *vtx);
00614
00615
00616
00617
00618
00619
00620
00621 GEO_Primitive *insertPrimitive(unsigned type,
00622 const GEO_Primitive *beforeWhich = 0,
00623 const GEO_Primitive *src = 0,
00624 GEO_Point **ptredirect = 0);
00625 GEO_Primitive *appendPrimitive(unsigned type,
00626 const GEO_Primitive *src = 0,
00627 GEO_Point **ptredirect = 0)
00628 {
00629 return insertPrimitive(type, 0, src, ptredirect);
00630 }
00631 GEO_Primitive *insertPrimitive(GEO_Primitive *prim,
00632 const GEO_Primitive *beforeWhich = 0,
00633 const GEO_Primitive *src = 0,
00634 GEO_Point **ptredirect = 0);
00635 GEO_Primitive *appendPrimitive(GEO_Primitive *prim,
00636 const GEO_Primitive *src = 0,
00637 GEO_Point **ptredirect = 0)
00638 {
00639 return insertPrimitive(prim, 0, src, ptredirect);
00640 }
00641
00642
00643 virtual void deletePrimitive(GB_Primitive &p,int andpoints=0)
00644 {
00645 deletePrimitive((unsigned)p.getNum(), andpoints);
00646 }
00647 virtual void deletePrimitive(unsigned int num, int andpoints = 0);
00648
00649
00650 virtual void deletePrimitives(const GB_PrimitiveGroup &primGrp,
00651 int andpoints = 0);
00652 virtual void deletePrimitives(UT_PtrArray<GEO_Primitive*>& prims_in,
00653 int andpoints = 0);
00654
00655
00656
00657 virtual GB_Breakpoint *allocBreakpoint() const;
00658
00659
00660 virtual void deleteBreakpoints(GB_BreakpointGroup &bkptgrp);
00661
00662
00663
00664
00665
00666 virtual int getPointBBox(UT_BoundingBox *bbox,
00667 const GB_PointGroup *g = 0) const;
00668 virtual int getPointBBox(UT_BoundingBox& bbox, const UT_Matrix4& transform,
00669 const GB_PointGroup *g=0) const;
00670 virtual int getPointBSphere(UT_BoundingSphere *bsphere,
00671 const GB_PointGroup *g = 0,
00672 int updateRequired = 0) const;
00673 virtual int getVertexBBox(UT_BoundingBox *bbox,
00674 const GB_VertexGroup *g = 0) const;
00675 virtual int getVertexBBox(UT_BoundingBox& bbox, const UT_Matrix4& transform,
00676 const GB_VertexGroup *g = 0) const;
00677 virtual int getEdgeBBox(UT_BoundingBox &bbox,
00678 const GB_EdgeGroup &grp) const;
00679 virtual int getEdgeBBox(UT_BoundingBox &bbox, const UT_Matrix4& transform,
00680 const GB_EdgeGroup &grp) const;
00681 virtual int getEdgeBSphere(UT_BoundingSphere &bsphere,
00682 const GB_EdgeGroup &grp,
00683 int updateRequired = 0) const;
00684 virtual int getBreakpointBBox(UT_BoundingBox &bbox,
00685 const GB_BreakpointGroup &grp) const;
00686 virtual int getBreakpointBBox(UT_BoundingBox &bbox, const UT_Matrix4& transform,
00687 const GB_BreakpointGroup &grp) const;
00688 virtual int getBreakpointBSphere(UT_BoundingSphere &bsphere,
00689 const GB_BreakpointGroup &grp,
00690 int updateRequired = 0) const;
00691 virtual int getGroupBBox(UT_BoundingBox *bbox,
00692 const GB_BaseGroup *grp) const;
00693 virtual int getGroupBBox(UT_BoundingBox& bbox, const UT_Matrix4& transform,
00694 const GB_BaseGroup *grp) const;
00695 virtual int getGroupBSphere(UT_BoundingSphere *bsphere,
00696 const GB_BaseGroup *grp,
00697 int updateRequired) const;
00698
00699
00700
00701 int getPointAttribBBox(const char *name,
00702 UT_BoundingBox *bbox,
00703 const GB_PointGroup *g = 0) const;
00704 int getPointAttribBBox(const char *name,
00705 UT_BoundingBox *bbox,
00706 const GB_PrimitiveGroup &g) const;
00707 int getPointAttribBBox(const char *name,
00708 UT_BoundingBox *bbox,
00709 const GB_EdgeGroup &g) const;
00710 int getPointAttribBBox(const char *name,
00711 UT_BoundingBox *bbox,
00712 const GB_VertexGroup &g) const;
00713
00714 int getPointAttribGroupBBox(const char *name,
00715 UT_BoundingBox *bbox,
00716 const GB_BaseGroup *grp) const;
00717
00718 int getVertexAttribBBox(const char *name,
00719 UT_BoundingBox *bbox,
00720 const GB_PointGroup *g = 0) const;
00721 int getVertexAttribBBox(const char *name,
00722 UT_BoundingBox *bbox,
00723 const GB_PrimitiveGroup &g) const;
00724 int getVertexAttribBBox(const char *name,
00725 UT_BoundingBox *bbox,
00726 const GB_EdgeGroup &g) const;
00727 int getVertexAttribBBox(const char *name,
00728 UT_BoundingBox *bbox,
00729 const GB_VertexGroup &g) const;
00730
00731 int getVertexAttribGroupBBox(const char *name,
00732 UT_BoundingBox *bbox,
00733 const GB_BaseGroup *grp) const;
00734
00735
00736 void copyPointAttributes(GEO_Point &dest,
00737 const GEO_Point &src) const;
00738
00739 void copyVertexAttributes(GEO_Vertex &dest,
00740 const GEO_Vertex &src) const;
00741
00742 void copyPointVertexAttributes(GEO_Vertex &dest,
00743 const GEO_Vertex &src) const;
00744
00745 void copyFullVertex(GEO_Vertex &dest,
00746 const GEO_Vertex &src) const;
00747
00748 void copyPrimitiveAttributes(GEO_Primitive &dest,
00749 const GEO_Primitive &src) const;
00750
00751 void copyPointGroups(GEO_Point &dest,
00752 const GEO_Point &src) const;
00753 void copyPrimitiveGroups(GEO_Primitive &dest,
00754 const GEO_Primitive &src) const;
00755
00756
00757
00758
00759
00760
00761 void copyVertex(GEO_Vertex &dest, const GEO_Vertex &src,
00762 int shallow = 0) const;
00763
00764
00765 void blendVertex(GEO_Vertex &dest, const GEO_Vertex &src,
00766 float bias,
00767 GB_FloatOffsets *ptarray,
00768 GB_FloatOffsets *vtxarray) const;
00769
00770 #if 0
00771
00772 void blendVertex(GEO_Vertex &dest, const GEO_Vertex &src,
00773 fpreal bias,
00774 GEO_AttributeHandleList *pdata,
00775 GEO_AttributeHandleList *vdata) const;
00776 #endif
00777
00778
00779
00780
00781
00782
00783 void fixSplineWeights();
00784
00785
00786
00787
00788
00789
00790
00791
00792 int addNormalAttribute(GEO_AttributeOwner who);
00793 int addTextureAttribute(GEO_AttributeOwner who);
00794 int addVelocityAttribute(GEO_AttributeOwner who);
00795 int addAlphaAttribute(GEO_AttributeOwner who);
00796 int addComAttribute(GEO_AttributeOwner who);
00797 int addDiffuseAttribute(GEO_AttributeOwner who);
00798 int addDistanceAttribute(GEO_AttributeOwner who);
00799 int addLODAttribute(GEO_AttributeOwner who);
00800 int addRestAttribute(GEO_AttributeOwner who);
00801 int addTubeCaptureAttribute();
00802
00803
00804 int addCaptureFrameAttribute(CaptureType t = CAPTURE_BONE);
00805
00806
00807 int addCaptureSkelRootAttribute(CaptureType t
00808 = CAPTURE_BONE);
00809
00810
00811 int addPtCapturePathAttribute(CaptureType t =CAPTURE_BONE);
00812
00813
00814
00815 int addPtCaptureAttribute(int num_xforms,
00816 CaptureType t = CAPTURE_BONE);
00817
00818
00819 int addPtIndexPairAttribute(const char *name,
00820 int size_bytes);
00821
00822
00823 int addPointCaptureAttribute(int size,
00824 CaptureType t = CAPTURE_BONE);
00825
00826
00827 int addPointCaptureAlphaAttribute(float dflt);
00828
00829
00830 int addMetaRestTransformsAttribute(int num_xforms);
00831
00832
00833
00834
00835
00836 int addInternalChangedPointsAttribute(
00837 const UT_IntArray &changed_points);
00838
00839 int findNormalAttribute(GEO_AttributeOwner who) const;
00840 int findTextureAttribute(GEO_AttributeOwner who) const;
00841 int findVelocityAttribute(GEO_AttributeOwner who) const;
00842 int findAlphaAttribute(GEO_AttributeOwner who) const;
00843 int findComAttribute(GEO_AttributeOwner who) const;
00844 int findDiffuseAttribute(GEO_AttributeOwner who) const;
00845 int findDistanceAttribute(GEO_AttributeOwner who) const;
00846 int findLODAttribute(GEO_AttributeOwner who) const;
00847 int findRestAttribute(GEO_AttributeOwner who) const;
00848 int findTubeCaptureAttribute() const;
00849
00850
00851
00852 int findCaptureFrameAttribute(CaptureType t = CAPTURE_BONE)
00853 const;
00854
00855
00856 int findCaptureSkelRootAttribute(CaptureType t
00857 = CAPTURE_BONE) const;
00858
00859
00860
00861 int findPtCapturePathAttribute(CaptureType t
00862 = CAPTURE_BONE) const;
00863
00864
00865 int findPtCaptureAttribute(CaptureType t = CAPTURE_BONE)
00866 const;
00867
00868
00869
00870 int findPointCaptureAttribute(CaptureType t = CAPTURE_BONE)
00871 const;
00872
00873 int findPointCaptureAlphaAttribute() const;
00874
00875
00876 int findPtIndexPairAttribute(const char *name) const;
00877
00878
00879 GB_Attribute * findInternalChangedPointsAttribute() const;
00880
00881
00882 int getInternalChangedPointsAttribute(
00883 UT_IntArray &changed_points) const;
00884
00885
00886 int findMetaRestTransformsAttribute() const;
00887
00888 void destroyNormalAttribute(GEO_AttributeOwner who);
00889 void destroyTextureAttribute(GEO_AttributeOwner who);
00890 void destroyVelocityAttribute(GEO_AttributeOwner who);
00891 void destroyAlphaAttribute(GEO_AttributeOwner who);
00892 void destroyComAttribute(GEO_AttributeOwner who);
00893 void destroyDiffuseAttribute(GEO_AttributeOwner who);
00894 void destroyDistanceAttribute(GEO_AttributeOwner who);
00895 void destroyLODAttribute(GEO_AttributeOwner who);
00896 void destroyRestAttribute(GEO_AttributeOwner who);
00897 void destroyTubeCaptureAttribute();
00898
00899
00900 void destroyCaptureFrameAttribute(CaptureType t
00901 = CAPTURE_BONE);
00902
00903
00904 void destroyCaptureSkelRootAttribute(CaptureType t
00905 = CAPTURE_BONE);
00906
00907
00908
00909 void destroyPtCapturePathAttribute(CaptureType t =
00910 CAPTURE_BONE);
00911
00912
00913 void destroyPtCaptureAttribute(CaptureType t =CAPTURE_BONE);
00914
00915
00916
00917 void destroyPointCaptureAttribute(CaptureType t =
00918 CAPTURE_BONE);
00919
00920
00921 void destroyPointCaptureAlphaAttribute();
00922
00923
00924 void destroyPtIndexPairAttribute(const char *name);
00925
00926
00927 void destroyInternalChangedPointsAttribute();
00928
00929
00930 void destroyMetaRestTransformsAttribute();
00931
00932
00933
00934 bool getMetaRestAnchorPath(UT_String &anchorPath);
00935
00936
00937
00938
00939
00940
00941
00942 const char *getStdAttributeName(GEO_Standard_Attributes name,
00943 int layer = -1) const;
00944 void setStdAttributeName(GEO_Standard_Attributes name,
00945 const char *newname);
00946
00947
00948 int getCurrentLayer() const;
00949 void setCurrentLayer(int layer);
00950 void setNumLayers(int numlayer);
00951 int getNumLayers() const;
00952
00953 void setLayerMerge(int preclear, int mask, int srcblend,
00954 int dstblend);
00955 void getLayerMerge(int &preclear, int &mask, int &srcblend,
00956 int &dstblend);
00957
00958 void addVariableName(const char *attr, const char *varname);
00959 void removeVariableName(const char *varname)
00960 { addVariableName(0, varname); }
00961
00962
00963 void getVariableNameMap(UT_String &result) const;
00964
00965
00966 void traverseVariableNames(int (*function)(const char *attr,
00967 const char *varname, void *data),
00968 void *data) const;
00969
00970
00971 int growPtCaptureAttribute(int num_added_xforms,
00972 CaptureType t = CAPTURE_BONE);
00973 int growPointCaptureAttribute(int added_size,
00974 CaptureType t = CAPTURE_BONE);
00975
00976
00977 int shrinkPtCaptureAttribute(int index, int offset,
00978 CaptureType t = CAPTURE_BONE);
00979
00980 int addIndexAttribute(const char *n, const char *dv,
00981 GEO_AttributeOwner who);
00982 int findIndexAttribute(const char *n,
00983 GEO_AttributeOwner who) const;
00984 void destroyIndexAttribute(const char *n,
00985 GEO_AttributeOwner who);
00986
00987 int addPointAttrib(const GB_Attribute *src)
00988 { return ptAttrib.appendClone(src); }
00989 int addPointAttrib(const char *n, int s,
00990 GB_AttribType t, GB_AttribTypeInfo f,
00991 const void *dv)
00992 { return ptAttrib.append(n, s, t, f, dv); }
00993 int addPointAttrib(const char *n, int s,
00994 GB_AttribType t, const void *dv)
00995 { return ptAttrib.append(n, s, t, dv); }
00996
00997 int findPointAttrib(const GB_Attribute *src) const
00998 { return ptAttrib.getOffset(src); }
00999 int findPointAttrib(const char *n, int s,
01000 GB_AttribType t) const
01001 { return ptAttrib.getOffset(n, s, t); }
01002
01003 int findPointAttrib(const char *n, GB_AttribType t) const
01004 { return ptAttrib.getOffset(n, t); }
01005
01006 void destroyPointAttrib(const char *n, int s,
01007 GB_AttribType t)
01008 { ptAttrib.destroy(n, s, t); }
01009
01010 int addVertexAttrib(const GB_Attribute *src)
01011 { return vtxAttrib.appendClone(src); }
01012 int addVertexAttrib(const char *n, int s,
01013 GB_AttribType t, GB_AttribTypeInfo f,
01014 const void *dv)
01015 { return vtxAttrib.append(n, s, t, f, dv); }
01016 int addVertexAttrib(const char *n, int s,
01017 GB_AttribType t, const void *dv)
01018 { return vtxAttrib.append(n, s, t, dv); }
01019
01020 int findVertexAttrib(const GB_Attribute *src) const
01021 { return vtxAttrib.getOffset(src); }
01022 int findVertexAttrib(const char *n, int s,
01023 GB_AttribType t) const
01024 { return vtxAttrib.getOffset(n, s, t); }
01025
01026 void destroyVertexAttrib(const char *n, int s,
01027 GB_AttribType t)
01028 { vtxAttrib.destroy(n, s, t); }
01029
01030 int addPrimAttrib(const GB_Attribute *src)
01031 { return primAttrib.appendClone(src); }
01032 int addPrimAttrib(const char *n, int s, GB_AttribType t,
01033 GB_AttribTypeInfo f, const void *dv)
01034 { return primAttrib.append(n, s, t, f, dv); }
01035 int addPrimAttrib(const char *n, int s, GB_AttribType t,
01036 const void *dv)
01037 { return primAttrib.append(n, s, t, dv); }
01038
01039 int findPrimAttrib(const GB_Attribute *src) const
01040 { return primAttrib.getOffset(src); }
01041 int findPrimAttrib(const char *n, int s,
01042 GB_AttribType t) const
01043 { return primAttrib.getOffset(n, s, t); }
01044
01045 void destroyPrimAttrib(const char *n, int s,
01046 GB_AttribType t)
01047 { primAttrib.destroy(n, s, t); }
01048
01049
01050
01051 int addAttrib(GB_Attribute *src)
01052 { return detailAttrib.appendClone(src); }
01053 int addAttrib(const char *n, int s, GB_AttribType t,
01054 const void *dv)
01055 { return addAttrib(n, s, t, GB_ATTRIB_INFO_NONE, dv); }
01056 int addAttrib(const char *n, int s, GB_AttribType t,
01057 GB_AttribTypeInfo f, const void *dv)
01058 { return detailAttrib.append(n, s, t, f, dv); }
01059
01060 int findAttrib(const GB_Attribute *src) const
01061 { return detailAttrib.getOffset(src); }
01062 int findAttrib(const char *n, int s,
01063 GB_AttribType t) const
01064 { return detailAttrib.getOffset(n, s, t); }
01065 int findAttrib(const char *n, GB_AttribType t) const
01066 { return detailAttrib.getOffset(n, t); }
01067
01068 void destroyAttrib(const char *n, int s, GB_AttribType t)
01069 { detailAttrib.destroy(n, s, t); }
01070 void destroyAttrib(const char *n, GB_AttribType t)
01071 { detailAttrib.destroy(n, t); }
01072
01073
01074
01075
01076
01077
01078
01079 void sortAllAttributes(const GEO_Detail &src);
01080
01081
01082 GEO_PointList &points()
01083 {
01084 return (GEO_PointList&)ptList;
01085 }
01086 GEO_PrimList &primitives()
01087 {
01088 return (GEO_PrimList&)primList;
01089 }
01090 GEO_PointAttribDict &pointAttribs() { return ptAttrib; }
01091 GEO_PrimAttribDict &primitiveAttribs() { return primAttrib; }
01092 GEO_VertexAttribDict &vertexAttribs() { return vtxAttrib; }
01093 GB_AttributeTable &attribs() { return detailAttrib; }
01094
01095 const GEO_PointList &points() const
01096 {
01097 return (const GEO_PointList&)ptList;
01098 }
01099 const GEO_PrimList &primitives() const
01100 {
01101 return (const GEO_PrimList&)primList;
01102 }
01103 const GEO_PointAttribDict &pointAttribs() const { return ptAttrib; }
01104 const GEO_PrimAttribDict &primitiveAttribs() const{ return primAttrib;}
01105 const GEO_VertexAttribDict &vertexAttribs() const { return vtxAttrib; }
01106 const GB_AttributeTable &attribs() const { return detailAttrib;}
01107
01108 void addMetaRef (void) { myMetaCount++; }
01109 void delMetaRef (void) { myMetaCount--; }
01110 void addPasteRef(void) { myPasteCount++; }
01111 void addParticleRef(void) { myParticleCount++; }
01112 void delPasteRef(void) { myPasteCount--; }
01113 void addQuadricRef(void) { myQuadricCount++; }
01114 void delQuadricRef(void) { myQuadricCount--; }
01115 void delParticleRef(void) { myParticleCount--; }
01116 void addVolumeRef() { myVolumeCount++; }
01117 void delVolumeRef() { myVolumeCount--; }
01118
01119
01120 int metaCount () const { return myMetaCount; }
01121 int pasteCount() const { return myPasteCount; }
01122 int quadricCount() const { return myQuadricCount;}
01123 int particleCount() const
01124 { return myParticleCount;}
01125 int volumeCount() const
01126 { return myVolumeCount; }
01127
01128
01129
01130
01131 TS_MetaExpression *getMetaExpression(
01132 GB_PrimitiveGroup *primGroup = 0);
01133 GEO_MetaExpression *getGeoMetaExpression() { return metaExpr; }
01134
01135
01136
01137
01138 unsigned getStandardAttributes(const char *s,
01139 GEO_Standard_Attributes &a);
01140
01141
01142
01143
01144
01145
01146
01147
01148 void stashAll();
01149 void destroyStashed();
01150
01151 void mergeCapturePathAndData(
01152 const GEO_Detail &src,
01153 const GB_Attribute *src_path_atr,
01154 const GB_Attribute *my_path_atr,
01155 int src_size, int my_size,
01156 int *&new_indices);
01157
01158
01159
01160 GEO_AttributeHandle getPointAttribute (const char *attrib_name) const;
01161 GEO_AttributeHandle getPrimAttribute (const char *attrib_name) const;
01162 GEO_AttributeHandle getVertexAttribute(const char *attrib_name) const;
01163 GEO_AttributeHandle getDetailAttribute(const char *attrib_name) const;
01164 GEO_AttributeHandle getAttribute(GEO_AttributeOwner dict,
01165 const char *attrib_name) const;
01166
01167
01168
01169
01170
01171 bool changeAttributeStorage(GEO_AttributeOwner dict,
01172 const char *name,
01173 GB_AttribType new_type);
01174 bool changePointAttributeStorage(const char *nm, GB_AttribType t);
01175 bool changeVertexAttributeStorage(const char *nm, GB_AttribType t);
01176 bool changePrimAttributeStorage(const char *nm, GB_AttribType t);
01177 bool changeDetailAttributeStorage(const char *nm, GB_AttribType t);
01178
01179 GEO_AttributeOwner getAttributeOwner(const GB_AttributeDict &dict) const;
01180 const GB_AttributeDict *getAttributeDict(GEO_AttributeOwner own) const;
01181
01182
01183
01184
01185 void buildPointTree();
01186 void buildPointTree(UT_DMatrix4 &xform);
01187
01188
01189 GEO_PointTree *getPointTree() { return myPointTree; }
01190
01191 void destroyPointTree();
01192
01193
01194
01195
01196 void mergeDetailAttributes( const GEO_Detail &src,
01197 int num_pts_prev );
01198
01199 protected:
01200 virtual GEO_Primitive *newPrimitive(unsigned type) = 0;
01201
01202
01203
01204 virtual GB_Primitive *appendNewPrimitive(unsigned type);
01205
01206
01207 virtual unsigned getPrimitiveType(const char *name) const;
01208 virtual const char *getPrimitiveName(unsigned type) const;
01209
01210
01211 UT_PtrArray<GEO_Point *> myStashedPoints;
01212 UT_PtrArray<GEO_Primitive *> myStashedPrims;
01213
01214 GEO_TempPointCache *myTemporaryPoints;
01215 GEO_TempVertexCache *myTemporaryVertices;
01216
01217 private:
01218 GEO_Primitive *replacePrimitive(unsigned type,
01219 GEO_Primitive *axeme,
01220 const GEO_Primitive *src,
01221 GEO_Point **ptredirect);
01222 GEO_Primitive *replacePrimitive(GEO_Primitive *prim,
01223 GEO_Primitive *axeme,
01224 const GEO_Primitive *src,
01225 GEO_Point **ptredirect);
01226
01227
01228
01229 void mergeCaptureAttributes(const GEO_Detail &src,
01230 int num_pts_before_merge);
01231 void mergeWireCaptureAttributes(const GEO_Detail &src,
01232 int num_pts_before_merge);
01233
01234 void fastMerge(const GEO_Detail &src, int mergegroups,
01235 int collapse = true,
01236 bool merge_internal_groups = true);
01237 void fastMergePoints(const GEO_Detail &src, int mergegroups,
01238 bool merge_internal_groups = true);
01239
01240
01241
01242
01243
01244 GEO_PointAttribDict ptAttrib;
01245 GEO_PrimAttribDict primAttrib;
01246 GEO_VertexAttribDict vtxAttrib;
01247 GB_AttributeTable detailAttrib;
01248
01249 GEO_MetaExpression *metaExpr;
01250
01251
01252
01253
01254 int myPasteCount;
01255 int myMetaCount;
01256 int myQuadricCount;
01257
01258
01259 int myParticleCount;
01260
01261
01262 int myVolumeCount;
01263
01264
01265
01266
01267 int myExpectedPoints;
01268 int myBasePoint;
01269 int myExpectedPrims;
01270 int myBasePrim;
01271
01272
01273
01274 GEO_PointTree *myPointTree;
01275
01276 public:
01277
01278 int addAttribute(const char *, int, GB_AttribType,
01279 const void *dv, GEO_AttributeOwner);
01280 int addAttribute(const char *, int, GB_AttribType,
01281 GB_AttribTypeInfo,
01282 const void *dv, GEO_AttributeOwner);
01283 int growAttribute(const char *name, int added_size,
01284 GB_AttribType type, GEO_AttributeOwner);
01285 int findAttribute(const char *, int, GB_AttribType,
01286 GEO_AttributeOwner) const;
01287 int findAttribute(const char *, GB_AttribType,
01288 GEO_AttributeOwner) const;
01289 void destroyAttribute(const char *, int size,
01290 GB_AttribType, GEO_AttributeOwner);
01291 void destroyAttribute(const char *,
01292 GB_AttribType, GEO_AttributeOwner);
01293
01294 private:
01295 GEO_AttributeHandle getAttributeHandle(const char *name,
01296 const GB_AttributeDict &dict) const;
01297 int saveExtra(ostream &os, int binary) const;
01298 bool loadExtra(UT_IStream &is);
01299 bool loadVersion(UT_IStream &is, int binary);
01300
01301
01302
01303 friend ostream &operator<<(ostream &os, const GEO_Detail &d)
01304 {
01305 d.save(os, 0, 0);
01306 return os;
01307 }
01308 };
01309
01310 #endif