00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __SOP_Node_h__
00022 #define __SOP_Node_h__
00023
00024 #include "SOP_API.h"
00025 #include <UT/UT_Lock.h>
00026 #include <UT/UT_SymbolTable.h>
00027 #include <UT/UT_IntArray.h>
00028 #include <UT/UT_RefArray.h>
00029 #include <UT/UT_String.h>
00030 #include <CH/CH_LocalVariable.h>
00031 #include <GU/GU_Detail.h>
00032 #include <GU/GU_DetailHandle.h>
00033 #include <GU/GU_DetailGroupPair.h>
00034 #include <GU/GU_SelectType.h>
00035 #include <OP/OP_InputChangeHelper.h>
00036 #include <OP/OP_Network.h>
00037 #include <GOP/GOP_Manager.h>
00038 #include "SOP_Error.h"
00039 #include "SOP_Guide.h"
00040 #include "SOP_NodeFlags.h"
00041
00042 class UT_InfoTree;
00043 class UT_Undo;
00044 class GB_VertexGroup;
00045 class GU_Selection;
00046 class GU_Topology;
00047 class OP_OperatorTable;
00048 class SOP_Node;
00049 class SOP_SoftLockData;
00050 class DD_Source;
00051
00052 extern "C" {
00053 SYS_VISIBILITY_EXPORT extern void newSopOperator(OP_OperatorTable *table);
00054 };
00055
00056 class sopVarInfo;
00057
00058 class SOP_API sop_attribRef
00059 {
00060 public:
00061 UT_String myName;
00062 int mySize;
00063 GB_AttribType myType;
00064 };
00065
00066
00067 typedef float (SOP_Node::*SOP_LocalVarFunc)
00068 (sopVarInfo *varinfo);
00069
00070 class SOP_API sopVarInfo
00071 {
00072 public:
00073 CH_LocalVariable myVar;
00074 int myTable;
00075 GB_AttributeRef myOffset;
00076 int myTupleIndex;
00077 float myDefault;
00078 GB_AttribType myType;
00079 GEO_AttributeOwner myDictionary;
00080 int myVaridx;
00081 SOP_LocalVarFunc myCallback;
00082 };
00083
00084
00085 SOP_API extern void SOPfillMetaKernelMenu(void *, PRM_Name *names, int size,
00086 const PRM_SpareData *, PRM_Parm *);
00087
00088 #define SOP_LOCALVAR_START 1000000 // Start of local variable indices
00089
00090
00091
00092 typedef void sopVisualizeCallback(void * , SOP_Node *, OP_Context &, GU_Detail *);
00093
00094 class SOP_API SOP_Node : public OP_Network
00095 {
00096 public:
00097 virtual const char *getChildType() const;
00098 virtual const char *getOpType() const;
00099
00100 virtual OP_OpTypeId getChildTypeID() const;
00101 virtual OP_OpTypeId getOpTypeID() const;
00102
00103 const SOP_NodeFlags &getFlags() const { return mySopFlags; }
00104
00105
00106 virtual int isCookingRender() const
00107 { return getCreator()->isCookingRender(); }
00108
00109
00110
00111 virtual void opChanged(OP_EventType reason, void *data=0);
00112
00113
00114
00115
00116
00117
00118 virtual const CH_LocalVariable *resolveVariable(const char *name);
00119 virtual const CH_LocalVariable *resolveExtraVariableForSyntaxHighlight(
00120 const char *name);
00121
00122
00123
00124
00125
00126 void setVariableOrder(int detail, int prim,
00127 int pt, int vtx);
00128
00129
00130 int getVariableOrder(int level) const;
00131
00132 int getVariablePrecedence(int var) const;
00133
00134
00135
00136
00137
00138 virtual bool usesFootprint() const { return true; }
00139
00140 void setVisualizeCallback(sopVisualizeCallback *callback, void *data);
00141
00142 private:
00143 void clearLocalVars();
00144
00145
00146 virtual void clearCache();
00147
00148 public:
00149
00150
00151
00152
00153
00154 static void setCaptureOverrideFlag( bool flag )
00155 {
00156 theGlobalCaptOverride = flag;
00157 }
00158 static bool getCaptureOverrideFlag()
00159 {
00160 return theGlobalCaptOverride;
00161 }
00162
00163
00164
00165
00166
00167 void setupLocalVars();
00168
00169
00170
00171
00172 void resetLocalVarRefs();
00173
00174 void setCurGdh(int index,
00175 const GU_DetailHandle &gdh);
00176 void clearCurGdh(int index);
00177 const GU_DetailHandle &getCurGdh(int index);
00178
00179
00180 virtual float getVariableValue(int index, int thread);
00181
00182
00183
00184 bool getVariableValueFP(fpreal &val, int index);
00185
00186
00187
00188 virtual void getVariableString(int index, UT_String &value,
00189 int thread);
00190
00191
00192
00193
00194
00195 class SOP_API AttribTupleIndexArg
00196 {
00197 public:
00198 explicit AttribTupleIndexArg(int index) : myIndex(index) {}
00199 operator int() const { return myIndex; }
00200 private:
00201 int myIndex;
00202
00203 };
00204
00205
00206
00207 void addGenericVariable(const char *varname,
00208 GEO_Standard_Attributes attr,
00209 const AttribTupleIndexArg &tuple_idx,
00210 int sz, GB_AttribType type,
00211 float ladefault = 0.0f);
00212 void addGenericVariable(const char *varname,
00213 const char *attribname,
00214 const AttribTupleIndexArg &tuple_idx,
00215 int sz, GB_AttribType type,
00216 float ladefault = 0.0F);
00217 void addGenericVariable(const char *varname,
00218 int varidx,
00219 SOP_LocalVarFunc callback,
00220 float ladefault = 0.0F);
00221
00222
00223
00224 void addGenericVariable(const GU_Detail *gdp,
00225 int gdpidx,
00226 const char *varname,
00227 const char *attribname,
00228 const AttribTupleIndexArg &tuple_idx,
00229 int sz, GB_AttribType type,
00230 float ladefault = 0.0F);
00231 void addGenericVariable(int gpdidx,
00232 const char *varname,
00233 int varidx,
00234 SOP_LocalVarFunc callback,
00235 float ladefault = 0.0F);
00236 void addSpecificVariable(const GU_Detail *gdp,
00237 int gdpidx,
00238 const char *varname,
00239 const char *attribname,
00240 const AttribTupleIndexArg &tuple_idx,
00241 int sz, GB_AttribType type,
00242 GEO_AttributeOwner dictionary,
00243 float ladefault = 0.0F);
00244 void addSpecificVariable(int gpidx,
00245 const char *varname,
00246 int varidx,
00247 GEO_AttributeOwner dictionary,
00248 SOP_LocalVarFunc callback,
00249 float ladefault = 0.0F);
00250
00251 static int addCustomVariableCallback(const char *attr,
00252 const char *varname, void *data);
00253 void addCustomVariable(const char *attr,
00254 const char *varname);
00255
00256 void cacheVarPtBox(int gpdidx);
00257 void cacheVarPrimBox(int gpdidx);
00258
00259
00260
00261
00262
00263 float varCallbackT(sopVarInfo *varinfo);
00264
00265 float varCallbackPT(sopVarInfo *varinfo);
00266 float varCallbackPR(sopVarInfo *varinfo);
00267 float varCallbackVTX(sopVarInfo *varinfo);
00268
00269 float varCallbackNPT(sopVarInfo *varinfo);
00270 float varCallbackNPR(sopVarInfo *varinfo);
00271 float varCallbackNVTX(sopVarInfo *varinfo);
00272
00273 float varCallbackCE(sopVarInfo *varinfo);
00274 float varCallbackMIN(sopVarInfo *varinfo);
00275 float varCallbackMAX(sopVarInfo *varinfo);
00276 float varCallbackSIZE(sopVarInfo *varinfo);
00277 float varCallbackLIFE(sopVarInfo *varinfo);
00278 float varCallbackBB(sopVarInfo *varinfo);
00279 float varCallbackWEIGHT(sopVarInfo *varinfo);
00280
00281
00282
00283 const GU_DetailHandle &curGdh(int index) const
00284 { UT_ASSERT(index == 0 || index == 1); return myCurGdh[index]; }
00285
00286
00287
00288
00289 int curVertexNum(int index) const
00290 { UT_ASSERT(index == 0 || index == 1); return myCurVtxNum[index]; }
00291
00292 const GEO_Vertex *curVertex(int index) const
00293 { UT_ASSERT(index == 0 || index == 1); return myCurVtx[index]; }
00294
00295 const GEO_Point *curPoint(int index) const
00296 { UT_ASSERT(index == 0 || index == 1); return myCurPt[index]; }
00297
00298 const GEO_Primitive *curPrim(int index) const
00299 { UT_ASSERT(index == 0 || index == 1); return myCurPrim[index]; }
00300
00301
00302 UT_BoundingBox curPointBBox(int index)
00303 {
00304 UT_ASSERT(index == 0 || index == 1);
00305 cacheVarPtBox(index);
00306 return myCurPtBox[index];
00307 }
00308
00309
00310 UT_BoundingBox curPrimBBox(int index)
00311 {
00312 UT_ASSERT(index == 0 || index == 1);
00313 cacheVarPrimBox(index);
00314 return myCurPrimBox[index];
00315 }
00316
00317
00318
00319 void setPivotParmToGroupCentroid(OP_Context &context);
00320
00321 private:
00322
00323 void getGroupMenuHeader( int sourcenum, const char * title,
00324 UT_String & header );
00325
00326 static void buildSopGroups( const GU_Detail *src,
00327 const char * prim_header,
00328 const char * pt_header,
00329 PRM_Name *menuEntries, int themenusize,
00330 unsigned type, int start,
00331 bool includeselection, PRM_Parm *parm );
00332
00333 static int buildSopEdgeGroups( const GU_Detail *src,
00334 const char * edge_header,
00335 const char *prim_header, const char *pt_header,
00336 PRM_Name *menuEntries, int themenusize,
00337 bool addprim, int start,
00338 PRM_Parm *parm );
00339
00340 static int buildSopBreakpointGroups( const GU_Detail *src,
00341 const char * brkpt_header,
00342 const char * prim_header, const char *pt_header,
00343 PRM_Name *choicenames, int menusize,
00344 bool addprim, int start,
00345 PRM_Parm *parm );
00346
00347 public:
00348
00349
00350 static void buildGroupsFromSop( SOP_Node * src_sop,
00351 PRM_Parm *parm, const PRM_SpareData *spare,
00352 unsigned type, int start,
00353 PRM_Name *menuEntries, int thelistsize );
00354
00355 static int buildEdgeGroupsFromSop( SOP_Node * src_sop,
00356 PRM_Parm *parm, const PRM_SpareData *spare,
00357 bool addprim, int start,
00358 PRM_Name *menuEntries, int thelistsize );
00359
00360 static int buildBreakpointGroupsFromSop( SOP_Node * src_sop,
00361 PRM_Parm *parm, const PRM_SpareData *spare,
00362 bool addprim, int start,
00363 PRM_Name *menuEntries, int thelistsize );
00364
00365 void buildNamedPrims(int thesourcenum,
00366 PRM_Name *thechoicenames,
00367 int themenusize,
00368 PRM_Parm *parm,
00369 bool globvectors,
00370 bool numberedvolumes);
00371
00372 void buildInputGroups(int thesourcenum,
00373 PRM_Name *thechoicenames,
00374 int themenusize,
00375 unsigned type, int start,
00376 bool includeselection,
00377 PRM_Parm *parm);
00378
00379 int buildInputEdgeGroups(int sourcenum,
00380 PRM_Name *choicenames, int menusize,
00381 bool addprim, int start,
00382 PRM_Parm *parm);
00383
00384 int buildInputBreakpointGroups(int sourcenum,
00385 PRM_Name *choicenames, int menusize,
00386 bool addprim, int start,
00387 PRM_Parm *parm);
00388
00389 virtual int setModelLock(int lock_type,
00390 void *modeler = 0,
00391 int allow_softlock_promotion=0,
00392 UT_Undo *undo = 0);
00393
00394
00395 virtual OP_DATA_TYPE getCookedDataType() const;
00396
00397 virtual void *getCookedData(OP_Context &ctx);
00398
00399 virtual bool getBoundingBox(UT_BoundingBox &box, OP_Context &ctx);
00400
00401
00402
00403
00404
00405
00406 const GU_Detail *getCookedGeo(OP_Context &, int forced = 0);
00407 GU_DetailHandle getCookedGeoHandle(OP_Context &, int forced = 0);
00408 const SOP_Guide *getCookedGuide1() const;
00409 const SOP_Guide *getCookedGuide2() const;
00410
00411
00412
00413 const GU_Detail *getLastGeo();
00414
00415
00416
00417
00418
00419 const GU_Detail *getInputLastGeo(int input, double time);
00420
00421 OP_ERROR cookGuide1(OP_Context &context);
00422 OP_ERROR cookGuide2(OP_Context &context);
00423
00424 OP_ERROR cookGuideList(OP_Context &context,
00425 UT_RefArray<GU_DetailHandle> &list);
00426
00427
00428
00429
00430 virtual GOP_GuideListType getGuideListType() const
00431 { return OP_GUIDELIST_GUDETAIL; }
00432
00433 virtual OP_ERROR lockInput(unsigned idx, OP_Context &context);
00434 void unlockInput(unsigned idx);
00435 virtual OP_ERROR lockInputs(OP_Context &context);
00436 void unlockInputs();
00437
00438 static void buildOperatorTable(OP_OperatorTable &table);
00439 static void initializeExpressions();
00440
00441
00442
00443
00444
00445
00446 bool forceValidGroupName(UT_String &name,
00447 UT_ErrorSeverity severity);
00448
00449
00450
00451
00452
00453 bool forceValidGroupPrefix(UT_String &prefix,
00454 UT_ErrorSeverity severity);
00455
00456 void expandGroupNames(const char *pattern,
00457 UT_String &outNames,
00458 int isPrims,
00459 GU_Detail *pgdp);
00460 void expandGroupNames(const char *pattern,
00461 UT_String &outNames,
00462 int isPrims)
00463 { expandGroupNames(pattern, outNames, isPrims, gdp); }
00464
00465 const GB_PrimitiveGroup *parsePrimitiveGroups(const char *pattern,
00466 GU_Detail *pgdp,
00467 int allow_numeric=1,
00468 int ordered = 1,
00469 bool strict = false,
00470 int offset = 0);
00471 const GB_PrimitiveGroup *parsePrimitiveGroups(const char *pattern)
00472 { return parsePrimitiveGroups(pattern, gdp); }
00473
00474 GB_PrimitiveGroup *parsePrimitiveGroupsCopy(const char *pattern,
00475 GU_Detail *pgdp,
00476 int allow_numeric=1,
00477 int ordered = 1,
00478 bool strict = false);
00479 GB_PrimitiveGroup *parsePrimitiveGroupsCopy(const char *pattern)
00480 {return parsePrimitiveGroupsCopy(pattern,gdp);}
00481
00482 const GB_PointGroup *parsePointGroups(const char *pattern,
00483 GU_Detail *pgdp,
00484 int allow_numeric=1,
00485 int ordered = 1,
00486 bool strict = false,
00487 int offset = 0);
00488 const GB_PointGroup *parsePointGroups(const char *pattern)
00489 { return parsePointGroups(pattern, gdp); }
00490
00491 GB_PointGroup *parsePointGroupsCopy(const char *pattern,
00492 GU_Detail *pgdp,
00493 int allow_numeric=1,
00494 int ordered = 1,
00495 bool strict = false);
00496 GB_PointGroup *parsePointGroupsCopy(const char *pattern)
00497 { return parsePointGroupsCopy(pattern, gdp); }
00498
00499 const GB_EdgeGroup *parseEdgeGroups(const char *pattern,
00500 GU_Detail *pgdp,
00501 bool strict = true,
00502 int prim_offset = 0,
00503 int point_offset = 0);
00504 const GB_EdgeGroup *parseEdgeGroups(const char *pattern)
00505 { return parseEdgeGroups(pattern, gdp); }
00506
00507 GB_EdgeGroup *parseEdgeGroupsCopy(const char *pattern,
00508 GU_Detail *pgdp);
00509 GB_EdgeGroup *parseEdgeGroupsCopy(const char *pattern)
00510 { return parseEdgeGroupsCopy(pattern, gdp); }
00511
00512 const GB_BreakpointGroup *parseBreakpointGroups(const char *pattern,
00513 GU_Detail *pgdp,
00514 bool strict = true,
00515 int offset = 0);
00516 const GB_BreakpointGroup *parseBreakpointGroups(const char *pattern)
00517 { return parseBreakpointGroups(pattern, gdp); }
00518
00519 GB_BreakpointGroup *parseBreakpointGroupsCopy(const char *pattern,
00520 GU_Detail *pgdp);
00521 GB_BreakpointGroup *parseBreakpointGroupsCopy(const char *pattern)
00522 {return parseBreakpointGroupsCopy(pattern,gdp);}
00523
00524 const GB_VertexGroup *parseVertexGroups(const char *pattern,
00525 GU_Detail *pgdp,
00526 bool strict = true,
00527 int offset = 0);
00528 const GB_VertexGroup *parseVertexGroups(const char *pattern)
00529 { return parseVertexGroups(pattern, gdp); }
00530
00531 GB_VertexGroup *parseVertexGroupsCopy(const char *pattern,
00532 GU_Detail *pgdp);
00533 GB_VertexGroup *parseVertexGroupsCopy(const char *pattern)
00534 { return parseVertexGroupsCopy(pattern, gdp); }
00535
00536 const GB_BaseGroup *parseAllGroups(const char *pattern,
00537 GU_Detail *pgdp=0,
00538 int allow_numeric=1,
00539 int ordered=1,
00540 unsigned int mask = GBGROUP);
00541 const GB_BaseGroup *parseAllGroups(const char *pattern)
00542 { return parseAllGroups(pattern, gdp); }
00543
00544 GB_BaseGroup *parseAllGroupsCopy(const char *pattern,
00545 GU_Detail *pgdp=0,
00546 int allow_numeric=1,
00547 int ordered=1,
00548 unsigned int mask = GBGROUP);
00549 GB_BaseGroup *parseAllGroupsCopy(const char *pattern)
00550 { return parseAllGroupsCopy(pattern, gdp); }
00551
00552
00553
00554
00555
00556
00557
00558 int destroyAdhocGroup (const GB_BaseGroup *group)
00559 { return myGroupParse.destroyAdhocGroup(group); }
00560 void destroyAdhocGroups()
00561 { myGroupParse.destroyAdhocGroups(); }
00562 void destroyAdhocGroups(const GU_Detail *g)
00563 { myGroupParse.destroyAdhocGroups(g); }
00564
00565
00566
00567 void select(void);
00568
00569 void select(GU_SelectionType stype);
00570
00571 void select(const GB_BaseGroup &group, int use_gtype = 1,
00572 int add_to_sel = 0);
00573 void select(GEO_Primitive &prim, int sel_prim = 1,
00574 int add_to_sel = 0);
00575 void select(GEO_Point &point, int point_sel = 1,
00576 int add_to_sel = 0);
00577 void selectFrom(GEO_Primitive &prim, int sel_prim = 1,
00578 int add_to_sel = 0);
00579 void selectFrom(GEO_Point &point, int point_sel = 1,
00580 int add_to_sel = 0);
00581
00582
00583
00584
00585
00586 void selectInputGroup(GB_BaseGroup *group,
00587 int grouptype);
00588
00589
00590
00591 void clearSelection(void);
00592
00593
00594
00595 void clearSelection(GU_SelectionType stype);
00596
00597
00598
00599
00600 int destroySelection(void);
00601
00602
00603 int selectionEnabled(void) const
00604 {
00605 return getHighlight();
00606 }
00607
00608 bool hasCookedSelection(void) const
00609 {
00610 return myHasCookedSelection;
00611 }
00612
00613
00614
00615
00616
00617 bool copyTempSelections(OP_Context &context, SOP_Node *src);
00618
00619 virtual void resetSimulation (void) {}
00620
00621 virtual int getNetOverviewColor( UT_Color &color );
00622
00623 void addInstanceReference(SOP_Node *node);
00624 void clearInstanceReference(SOP_Node *node);
00625
00626
00627
00628
00629
00630
00631
00632
00633 void makeInstanceOf(SOP_Node *node);
00634
00635
00636
00637
00638 void makePreserveRequest();
00639
00640 virtual void setVisualization(int) {}
00641 virtual void setForceCapture(int) {}
00642
00643 virtual void getNodeSpecificInfoText(OP_Context &context,
00644 int verbose,
00645 UT_WorkBuffer &text);
00646
00647
00648 virtual void fillInfoTreeNodeSpecific(UT_InfoTree &tree,
00649 float time);
00650
00651
00652
00653
00654
00655
00656
00657 virtual const char *getDefaultSelectedInfoTreeBranchName() const;
00658
00659
00660
00661 static PRM_SpareData theFirstInput;
00662 static PRM_SpareData theSecondInput;
00663 static PRM_SpareData theThirdInput;
00664 static PRM_SpareData theFourthInput;
00665
00666
00667 virtual fpreal getW() const;
00668
00669 virtual fpreal getH() const;
00670
00671
00672 protected:
00673 SOP_Node(OP_Network *parent, const char *name, OP_Operator *entry);
00674 virtual ~SOP_Node();
00675
00676
00677
00678 virtual void setUniqueId(int id);
00679 virtual void clearUniqueId();
00680
00681
00682
00683
00684
00685
00686
00687 int removeAdhocGroup (const GB_BaseGroup *group)
00688 { return myGroupParse.removeAdhocGroup(group); }
00689 void removeAdhocGroups()
00690 { myGroupParse.removeAdhocGroups(); }
00691
00692
00693
00694
00695
00696
00697
00698 virtual OP_ERROR cookMe (OP_Context &context);
00699 virtual OP_ERROR bypassMe (OP_Context &context, int &copied_input);
00700 virtual OP_ERROR cookMySop(OP_Context &context) = 0;
00701 virtual OP_ERROR cookMyGuide1(OP_Context &context);
00702 virtual OP_ERROR cookMyGuide2(OP_Context &context);
00703 virtual OP_ERROR cookMyGuideList(OP_Context &context,
00704 UT_RefArray<GU_DetailHandle> &list);
00705
00706 virtual OP_ERROR pubCookInputGroups(OP_Context &context, int alone = 0);
00707
00708 virtual void checkInputChanged(int parm_index, int group_type_index,
00709 GU_DetailGroupPair &detail_group_pair,
00710 GU_Detail *pgdp, const GB_BaseGroup *group);
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731 virtual OP_ERROR cookInputPrimitiveGroups(OP_Context &context,
00732 const GB_PrimitiveGroup *&group,
00733 GU_DetailGroupPair &detail_group_pair,
00734 int alone = 0, bool do_selection = true,
00735 int input_index = 0, int parm_index = 0,
00736 int group_type_index = -1,
00737 bool allow_reference = true,
00738 bool fetchgdp = true,
00739 GU_Detail *pgdp = NULL);
00740
00741
00742 virtual OP_ERROR cookInputPointGroups(OP_Context &context,
00743 const GB_PointGroup *&group,
00744 GU_DetailGroupPair &detail_group_pair,
00745 int alone = 0, bool do_selection = true,
00746 int input_index = 0, int parm_index = 0,
00747 int group_type_index = -1,
00748 bool allow_reference = true,
00749 bool fetchgdp = true,
00750 GU_Detail *pgdp = NULL);
00751
00752
00753 virtual OP_ERROR cookInputEdgeGroups(OP_Context &context,
00754 const GB_EdgeGroup *&group,
00755 GU_DetailGroupPair &detail_group_pair,
00756 int alone = 0, bool do_selection = true,
00757 int input_index = 0, int parm_index = 0,
00758 int group_type_index = -1,
00759
00760
00761
00762
00763 bool allow_reference = false,
00764 bool fetchgdp = true,
00765 GU_Detail *pgdp = NULL);
00766
00767
00768
00769
00770
00771 virtual OP_ERROR cookInputAllGroups(OP_Context &context,
00772 const GB_BaseGroup *&group,
00773 GU_DetailGroupPair &detail_group_pair,
00774 int alone = 0, bool do_selection = true,
00775 int input_index = 0, int parm_index = 0,
00776 int group_type_index = -1,
00777 bool allow_reference = false,
00778 bool is_default_prim = true,
00779 bool fetchgdp = true,
00780 GU_Detail *pgdp = NULL);
00781
00782
00783
00784
00785
00786
00787 const GB_BaseGroup *parseInputGroup(const UT_String &groupname,
00788 int grouptype, GU_Detail *gdp,
00789 bool allow_reference, bool is_default_prim);
00790
00791 private:
00792
00793 OP_ERROR cookInputGroupsPrologue(OP_Context &context, bool fetchgdp,
00794 int alone, int input_index,
00795 GU_Detail *&pgdp);
00796
00797
00798 void cookInputGroupsEpilogue(int parm_index, int group_type_index,
00799 GU_DetailGroupPair &detail_group_pair,
00800 GU_Detail *pgdp, const GB_BaseGroup *group,
00801 bool fetchgdp, int alone);
00802
00803 protected:
00804 virtual void inputConnectChanged(int which_input);
00805
00806
00807
00808
00809
00810
00811
00812
00813 const GU_Detail *inputGeo(int index, OP_Context &)
00814 { return inputGeo(index); }
00815 const GU_Detail *inputGeo(int index) const;
00816 GU_DetailHandle inputGeoHandle(int index) const;
00817
00818
00819
00820
00821
00822
00823 void addError(int code, const char *msg = 0)
00824 { getLockedErrorManager()->addError(SOP_OPTYPE_NAME,
00825 code, msg); }
00826 void addMessage(SOP_ErrorCodes code, const char *msg = 0)
00827 { getLockedErrorManager()->addMessage(SOP_OPTYPE_NAME,
00828 code, msg); }
00829 void addWarning(SOP_ErrorCodes code, const char *msg = 0)
00830 { getLockedErrorManager()->addWarning(SOP_OPTYPE_NAME,
00831 code, msg); }
00832 void addFatal(SOP_ErrorCodes code, const char *msg = 0)
00833 { getLockedErrorManager()->addFatal(SOP_OPTYPE_NAME,
00834 code, msg); }
00835 void addSystemError(const char *msg = 0)
00836 { getLockedErrorManager()->systemError(msg);}
00837 void addCommonError(UT_CommonErrorCode what,
00838 const char *msg = 0)
00839 { getLockedErrorManager()->commonError(what, msg);}
00840
00841
00842
00843
00844 SOP_Node *getObjectsSopNode(const char *objectName,
00845 OP_Context &context,
00846 UT_Matrix4 *xform = 0,
00847 float *rx = 0,
00848 float *ry = 0,
00849 float *rz = 0);
00850
00851
00852
00853
00854
00855
00856
00857 public:
00858 static PRM_ChoiceList allGroupMenu;
00859 static PRM_ChoiceList groupMenu;
00860 static PRM_ChoiceList primGroupMenu;
00861 static PRM_ChoiceList pointGroupMenu;
00862 static PRM_ChoiceList edgeGroupMenu;
00863 static PRM_ChoiceList breakpointGroupMenu;
00864 static PRM_ChoiceList primNamedGroupMenu;
00865 static PRM_ChoiceList pointNamedGroupMenu;
00866 static PRM_ChoiceList namedPrimsMenu;
00867 static PRM_ChoiceList namedPrimsGlobMenu;
00868 static PRM_ChoiceList namedVolumesMenu;
00869 static PRM_ChoiceList namedVolumesGlobMenu;
00870
00871 protected:
00872
00873 int parseGroups(const char *pattern,
00874 GU_Detail *gdp,
00875 const GB_PrimitiveGroup *&prim,
00876 const GB_PointGroup *&points,
00877 bool strict = false);
00878
00879 int parseGroupsCopy(const char *pattern,
00880 GU_Detail *gdp,
00881 GB_PrimitiveGroup *&prim,
00882 GB_PointGroup *&points,
00883 int unify,
00884 bool strict = false);
00885
00886 public:
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896 int fillAttribNameMenu(PRM_Name *menu_entries,
00897 int max_menu_size,
00898 GEO_AttributeOwner dictionary,
00899 int input_index,
00900 bool (*approve)(const GB_Attribute*,void*)=NULL,
00901 void *approve_data = NULL);
00902
00903
00904 static void removeMenuDuplicates(PRM_Name *menuEntries, int size);
00905
00906
00907 static bool approveUserAttribsOnlyCB(const GB_Attribute *atr,
00908 void *data);
00909
00910 protected:
00911
00912
00913
00914 void getVectorAttribOffsets( const char * attrib_names,
00915 UT_RefArray<GB_AttributeRef> &vertex_offsets,
00916 UT_RefArray<GB_AttributeRef> &point_offsets,
00917 UT_RefArray<GB_AttributeRef> &prim_offsets);
00918
00919
00920
00921 void getVectorAttribOffsets(const GB_AttributeDict &dict,
00922 const char * attrib_string,
00923 UT_RefArray<GB_AttributeRef> &offsets,
00924 UT_String &bad_attribs);
00925
00926 protected:
00927
00928
00929
00930 virtual int acceptDragDrop(DD_Source &src, const char *l);
00931 virtual int testDragDrop(DD_Source &src);
00932 virtual void getDragDropChoice(DD_Source &src,
00933 DD_ChoiceList &choices);
00934
00935
00936
00937 int parseEachGroup(const char *pattern,
00938 GroupOperation operation,
00939 void *data, int isPrim,
00940 GU_Detail *pgdp=0,
00941 bool strict = false,
00942 bool allow_adhoc = false);
00943
00944
00945
00946
00947 void subdividePrimitiveGroup(
00948 GroupOperation operation,
00949 const GB_PrimitiveGroup *group,
00950 void *data, int optype,
00951 int opstep, const char *oplabel,
00952 GU_Detail *gdp=0);
00953 void subdivideMixPrimitiveGroup(
00954 GroupOperation operation,
00955 const GB_PrimitiveGroup *group,
00956 void *data, int optype,
00957 int opstep, const char *oplabel,
00958 GU_Detail *gdp=0);
00959 void subdividePointGroup(
00960 GroupOperation operation,
00961 const GB_PointGroup *group,
00962 void *data, int optype,
00963 int opstep, const char *oplabel,
00964 GU_Detail *gdp=0);
00965
00966
00967
00968
00969 GB_PrimitiveGroup *createAdhocPrimGroup (GU_Detail &geo,
00970 const char *p="adhoc")
00971 { return myGroupParse.createPrimitiveGroup (geo, p); }
00972 GB_PointGroup *createAdhocPointGroup(GU_Detail &geo,
00973 const char *p="adhoc")
00974 { return myGroupParse.createPointGroup (geo, p); }
00975 GB_EdgeGroup *createAdhocEdgeGroup (GU_Detail &geo,
00976 const char *p="adhoc")
00977 { return myGroupParse.createEdgeGroup(geo, p); }
00978 GB_VertexGroup *createAdhocVertexGroup (GU_Detail &geo,
00979 const char *p="adhoc")
00980 { return myGroupParse.createVertexGroup(geo, p); }
00981 GB_BreakpointGroup *createAdhocBreakpointGroup (GU_Detail &geo,
00982 const char *p="adhoc")
00983 { return myGroupParse.createBreakpointGroup(geo, p); }
00984
00985
00986
00987
00988
00989
00990
00991
00992 void clearInstance(int duplicate = 0);
00993
00994
00995
00996
00997
00998
00999
01000
01001 virtual bool shouldResetGeoToEmpty() const { return true; }
01002
01003
01004
01005
01006
01007 OP_ERROR duplicateSource(unsigned index, OP_Context &context,
01008 GU_Detail *gdp, int clean=1);
01009 OP_ERROR duplicateSource(unsigned index, OP_Context &context)
01010 { return duplicateSource(index, context, gdp); }
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024 OP_ERROR duplicatePointSource(unsigned index, OP_Context &ctx,
01025 GU_Detail *gdp, int clean = 1,
01026 bool wattrib = true,
01027 bool *fully = 0);
01028 OP_ERROR duplicatePointSource(unsigned index, OP_Context &ctx)
01029 { return duplicatePointSource(index, ctx, gdp); }
01030
01031
01032
01033 OP_ERROR duplicateChangedSource(unsigned idx, OP_Context &ctx,
01034 int *changed = 0, bool force=false);
01035
01036
01037 OP_ERROR duplicateSourceGroup(const GU_Detail *src_gdp,
01038 const GB_PrimitiveGroup *primgroup,
01039 GU_Detail *dest_gdp=0);
01040
01041
01042 void resetChangedSourceFlags();
01043
01044
01045
01046
01047
01048
01049
01050 OP_ERROR checkChangedSourceFlags(unsigned idx, OP_Context &ctx,
01051 int *changed);
01052
01053
01054
01055
01056
01057
01058
01059
01060 bool useInputSource(unsigned idx, bool &changed, bool force)
01061 {
01062 return myInputChangeHelper.useInput(
01063 *this, idx, changed, force);
01064 }
01065
01066
01067
01068
01069 OP_ERROR duplicateChangedSource(unsigned idx, OP_Context &ctx,
01070 GU_Topology &tp, int *changed,
01071 GU_Detail *gdp, int clean=1);
01072 OP_ERROR duplicateChangedSource(unsigned idx, OP_Context &ctx,
01073 GU_Topology &tp, int *changed=0)
01074 { return duplicateChangedSource(idx, ctx, tp, changed,
01075 gdp); }
01076
01077
01078 virtual void deleteCookedData(void);
01079 virtual int deleteNodeData(void *);
01080 virtual void *copyNodeData (void *);
01081
01082
01083
01084 GB_PrimitiveGroup *getPastedSurfaces(void)
01085 {
01086 return gdp->getPastedSurfaces("_sop_all_pasted_");
01087 }
01088 GB_PrimitiveGroup *getPastedSurfaces(GB_PrimitiveGroup *&used)
01089 {
01090 return gdp->getPastedSurfaces(used,
01091 "_sop_all_pasted_",
01092 "_sop_used_pasted_");
01093 }
01094 void updatePastedDisplacement(const GEO_Point &ppt,
01095 const GB_PrimitiveGroup *all,
01096 GB_PrimitiveGroup *used)
01097 {
01098 gdp->updatePastedDisplacement(ppt, all, used);
01099 }
01100 int updatePastedDisplacements(void)
01101 {
01102
01103 return gdp->updatePastedDisplacements();
01104 }
01105 int updatePastedDependents(GB_PrimitiveGroup *all,
01106 GB_PrimitiveGroup *used)
01107 {
01108
01109 return gdp->updatePastedDependents(all, used);
01110 }
01111
01112
01113 void convertPivotAboutGroupCentroid(
01114 PRM_Parm &grppivot_parm,
01115 int pivot_parm_idx,
01116 const UT_Vector3 *centroid = 0);
01117
01118
01119
01120 virtual bool getGroupCentroid(OP_Context & ,
01121 UT_Vector3 & )
01122 { return false; }
01123
01124
01125
01126
01127 virtual OP_ERROR save(ostream &os, const OP_SaveFlags &flags,
01128 const char *pathPrefix);
01129 virtual bool load(UT_IStream &is, const char *extension,
01130 const char *path=0);
01131
01132 void refreshGdp();
01133
01134
01135
01136
01137
01138
01139
01140
01141 GU_DetailHandle myGdpHandle;
01142
01143
01144
01145
01146 GU_Detail *gdp;
01147 SOP_Guide *myGuide1;
01148 SOP_Guide *myGuide2;
01149 SOP_NodeFlags mySopFlags;
01150
01151 private:
01152
01153
01154
01155
01156
01157 virtual OP_ERROR saveIntrinsic(ostream &os, const OP_SaveFlags &flags);
01158
01159 virtual bool loadPacket(UT_IStream &is, short class_id, short sig,
01160 const char *path=0);
01161 virtual bool loadPacket(UT_IStream &is, const char *token,
01162 const char *path=0);
01163
01164 virtual void clearAndDestroy(void);
01165
01166 virtual int saveCookedData(const char *, OP_Context &);
01167 virtual int saveCookedData(ostream &os, OP_Context &, int binary = 0);
01168 virtual bool loadCookedData(UT_IStream &is, const char *path=0);
01169
01170
01171
01172
01173 bool loadHardCookedData(UT_IStream &is, const char *path=0);
01174
01175 virtual const char *getFileExtension(int binary) const;
01176
01177 int softLockable(const GU_Detail &unmodelled_gdp,
01178 const GU_Detail &modelled_gdp) const;
01179
01180
01181
01182
01183 int storeSoftLockData(OP_Context &context, int prev_lock,
01184 SOP_SoftLockData *old_slockdata=0);
01185
01186 sopVisualizeCallback *myVisualizeCallback;
01187 void *myVisualizeCallbackData;
01188
01189 protected:
01190
01191
01192
01193 GU_Selection *newSelection(GU_SelectionType stype);
01194 GU_Selection *newSelection(const GB_BaseGroup &group);
01195
01196
01197 public:
01198
01199 virtual void unloadDataHack();
01200
01201 virtual bool unloadData();
01202
01203
01204
01205
01206 virtual int64 getLoadedMemoryUsage() const;
01207
01208
01209 bool isLoaded() const;
01210
01211 private:
01212 OP_InputChangeHelper myInputChangeHelper;
01213
01214
01215
01216
01217
01218
01219 UT_PtrArray<GU_DetailHandle *> myInputGeoHandles;
01220
01221 GOP_Manager myGroupParse;
01222
01223 friend class SOP_UndoModel;
01224 friend class SOP_CacheManager;
01225 friend class SOP_CacheData;
01226
01227
01228
01229
01230 SOP_SoftLockData *mySoftLockData;
01231
01232 bool myHasCookedSelection;
01233
01234
01235
01236
01237
01238 static bool theGlobalCaptOverride;
01239
01240 UT_Lock myInstancingOpsLock;
01241 UT_IntArray myInstancingOps;
01242 int myInstanceOp;
01243
01244 public:
01245
01246
01247 void setUsesSOPLocalVar()
01248 { myUsesSOPLocalVar = true; }
01249 protected:
01250
01251 UT_SymbolTable myLocalVarTable;
01252 UT_PtrArray<sopVarInfo *> myLocalVarArray;
01253 int myLocalVarOrder;
01254
01255
01256
01257
01258
01259
01260 bool myUsesSOPLocalVar;
01261 private:
01262
01263
01264
01265 bool myLocalVarActive;
01266 const GU_Detail *myCurGdp[2];
01267 GU_DetailHandle myCurGdh[2];
01268
01269 protected:
01270 const GEO_Vertex *myCurVtx[2];
01271 int myCurVtxNum[2];
01272 const GEO_Point *myCurPt[2];
01273 const GEO_Primitive *myCurPrim[2];
01274 int myCurBuiltPtBox[2];
01275 UT_BoundingBox myCurPtBox[2];
01276 int myCurBuiltPrimBox[2];
01277 UT_BoundingBox myCurPrimBox[2];
01278
01279 int myCurGdpVal;
01280
01281
01282 int myLocalVarOrderCache;
01283 int myCurrentLayerCache;
01284
01285
01286
01287 UT_RefArray<sop_attribRef> myAttribCache[2][4];
01288 UT_String myVarMapCache[2];
01289 };
01290
01291
01292
01293 SOP_API extern void
01294 SOPgetVexReservedTemplateLists(UT_PtrArray<PRM_Template *> &tplatelists);
01295
01296 #endif