00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __MSS_PolyKnitState_H__
00022 #define __MSS_PolyKnitState_H__
00023
00024 #include "MSS_API.h"
00025 #include <UT/UT_HashTable.h>
00026 #include <UT/UT_Vector3.h>
00027 #include <UI/UI_Value.h>
00028 #include "MSS_SingleOpBaseState.h"
00029
00030 class GB_PointRefArray;
00031 class GEO_Point;
00032 class GU_Detail;
00033 class SOP_Node;
00034 class SOP_PolyKnit;
00035 class JEDI_View;
00036 class GUI_DetailLook;
00037 class GUI_DisplayOption;
00038 class BM_View;
00039 class RE_Render;
00040 class mss_NodeEntry;
00041
00042
00043
00044 class MSS_API MSS_PolyKnitPoint
00045 {
00046 public:
00047 bool operator==(const MSS_PolyKnitPoint &p)
00048 {
00049 return (oppath == p.oppath &&
00050 local_index == p.local_index &&
00051 merged_index == p.merged_index &&
00052 shared_edge == p.shared_edge &&
00053 meta_edge == p.meta_edge &&
00054 cache_index == p.cache_index &&
00055 point_list == p.point_list);
00056 }
00057 const MSS_PolyKnitPoint &operator=(const MSS_PolyKnitPoint &p)
00058 {
00059 oppath.harden(p.oppath);
00060 local_index = p.local_index;
00061 merged_index = p.merged_index;
00062 shared_edge = p.shared_edge;
00063 meta_edge = p.meta_edge;
00064 cache_index = p.cache_index;
00065 point_list = p.point_list;
00066
00067 return *this;
00068 }
00069
00070 UT_String oppath;
00071 int local_index;
00072 int merged_index;
00073 int shared_edge;
00074 bool meta_edge;
00075
00076 UT_Vector3 tmp_pos;
00077
00078
00079
00080
00081
00082
00083
00084
00085 int cache_index;
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 UT_IntArray point_list;
00098 };
00099
00100
00101 class MSS_API MSS_PolyKnitStateFlags
00102 {
00103 public:
00104 MSS_PolyKnitStateFlags() {
00105 validpick = 0;
00106 uselocate = 1;
00107
00108 }
00109 unsigned validpick :1,
00110 uselocate :1;
00111
00112 };
00113
00114 class MSS_API MSS_PolyKnitState : public MSS_SingleOpBaseState
00115 {
00116 public:
00117
00118 MSS_PolyKnitState(JEDI_View &view, PI_StateTemplate &templ,
00119 BM_SceneManager *scene);
00120 virtual ~MSS_PolyKnitState(void);
00121
00122
00123
00124 static BM_State *ourConstructor(BM_View &view,
00125 PI_StateTemplate &templ,
00126 BM_SceneManager *scene);
00127 static PRM_Template ourTemplateList[];
00128
00129
00130 virtual const char *className() const;
00131
00132 virtual void initializeUI(PRM_Template *templates=0);
00133
00134
00135 virtual int handleMouseEvent(UI_Event *event);
00136
00137 virtual void handleOpNodeChange(OP_Node &node);
00138
00139 void handleOpEvent(OP_Node *node, OP_EventType type,
00140 void *data);
00141
00142 static void opEvent(OP_Node *caller, void *callee,
00143 OP_EventType type, void *data);
00144
00145 void renderForPicking(RE_Render *r, short x, short y);
00146
00147 protected:
00148
00149
00150 virtual int enter(BM_SimpleState::BM_EntryType how);
00151 virtual void exit (void);
00152
00153
00154 virtual void interrupt(BM_SimpleState * = 0);
00155 virtual void resume (BM_SimpleState * = 0);
00156
00157
00158 virtual void restart(void);
00159
00160
00161 virtual int handleParameterEvent(UI_Event *event);
00162
00163 virtual int handleKeyTypeEvent(UI_Event *event,
00164 BM_Viewport &);
00165
00166
00167 virtual void setBuild(int yesNo);
00168
00169
00170 virtual void doGenerate();
00171
00172
00173 virtual void doRender(RE_Render *r, short x, short y, int ghost);
00174
00175 private:
00176 SOP_PolyKnit *getPolyKnitSOP(void) const
00177 { return (SOP_PolyKnit *)BM_SingleOpState::getNode(); }
00178
00179
00180 void renderStrip(RE_Render *r, int ghost);
00181 void renderPosFeedback(RE_Render *r, int ghost);
00182 void renderMetaEdge(RE_Render *r, int ghost,
00183 const UT_IntArray &ptlist,
00184 const char *oppath);
00185
00186 bool pickPoint(UI_Event *event, MSS_PolyKnitPoint &data,
00187 bool nonmeta);
00188
00189
00190 void showFeedback(int yesNo);
00191
00192 void handleFeedbackChange(UI_Event *event);
00193
00194
00195 void calculatePosition(UI_Event *event,
00196 UT_Vector3 &pos);
00197
00198 bool validForRender(GUI_DetailLook *detail,
00199 const GUI_DisplayOption &dopt);
00200
00201 void finishBuilding();
00202 bool filterPointListAndConnectOps();
00203 void updateParameters();
00204
00205
00206 void deleteAllPoints(bool andsopparm = true);
00207
00208
00209 void updateNodeAndPointInfo(MSS_PolyKnitPoint &data,
00210 int ptindex,
00211 bool updatesharedflag = true);
00212
00213
00214
00215 void updatePath(MSS_PolyKnitPoint &pt0,
00216 MSS_PolyKnitPoint &pt1);
00217
00218 void addPoint(const MSS_PolyKnitPoint &data,
00219 bool updatesharedflag = true);
00220 void deletePoint(const char *oppath);
00221
00222
00223
00224 bool getPos(const MSS_PolyKnitPoint &point,
00225 UT_Vector3 &pos, bool worldpos = true);
00226
00227 void xformToWorld(UT_Vector3 &pos, int index);
00228
00229 void xformToWorld(UT_Vector3 &pos, const char *oppath);
00230
00231
00232 void updatePrompt();
00233
00234
00235
00236 void updateFromSOP(const UT_Vector3 &pos);
00237
00238
00239 void addSopPoints(const UT_IntArray &point_array,
00240 const UT_IntArray &type_list,
00241 const UT_PtrArray<GU_Detail *> &gdplist,
00242 const UT_StringArray &oppathlist);
00243
00244
00245
00246 bool extendForward(const UT_Vector3 &pos,
00247 const GEO_Point &firstpt,
00248 const GEO_Point &lastpt);
00249
00250
00251
00252 void updatePointIndex(MSS_PolyKnitPoint &data,
00253 int merged_index,
00254 const UT_PtrArray<GU_Detail *> &gdplist,
00255 const UT_StringArray &oppathlist);
00256
00257
00258 void reverseArray(UT_IntArray &arr);
00259
00260
00261 void flipTypes();
00262
00263 const GU_Detail *getInputGdp(const SOP_Node *sop, int idx=0);
00264 const SOP_Node *getInputSOP();
00265
00266
00267 bool isImplicit(const SOP_Node *node);
00268
00269
00270 void addNode(const char *oppath);
00271 void removeNode(int index);
00272
00273
00274 void dumpPointList();
00275
00276
00277
00278 UT_RefArray<MSS_PolyKnitPoint> myPointList;
00279
00280
00281 UT_String myPointsString;
00282
00283
00284 UT_Vector3 myNextPoint;
00285
00286 MSS_PolyKnitStateFlags myStateFlags;
00287
00288
00289
00290 short myLastMouseDown;
00291
00292 UI_Value mySelFinishedValue;
00293
00294 UI_Value myFeedbackVal;
00295
00296 UT_PtrArray<mss_NodeEntry *> myNodeArray;
00297 UT_HashTable myNodeTable;
00298
00299
00300
00301 UT_IntArray myTypeArray;
00302 int myNumVerts;
00303
00304 BM_State::BM_GenerateMode myLastGenMode;
00305
00306
00307
00308
00309 bool myReverseOutput;
00310 };
00311
00312 #endif