00001 // Copyright (c) 1998-2014 by Tech Soft 3D, Inc. 00002 // 00003 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., 00004 // and considered a trade secret as defined under civil and criminal statutes. 00005 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of 00006 // unauthorized use or misappropriation of its trade secrets. Use of this information 00007 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under 00008 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use. 00009 00010 #ifndef _HSharedKey_H 00011 #define _HSharedKey_H 00012 00013 #ifdef H_PACK_8 00014 #pragma pack(push) 00015 #pragma pack(8) 00016 #endif 00017 00018 #include "HTools.h" 00019 00020 #include "vhash.h" 00021 #include "HStream.h" 00022 #include "HOpcodeShell.h" 00023 #include "HPolyPoly.h" 00024 00025 00026 #define OVERLOAD_INTERPRET_INT(base_class__name__abc) \ 00027 TK_Status Interpret (BStreamFileToolkit & tk, HC_KEY key, int variant = 0) \ 00028 { \ 00029 TK_Status status = base_class__name__abc::Interpret(tk,key,variant); \ 00030 m_key = key; \ 00031 return status; \ 00032 } 00033 #define OVERLOAD_INTERPRET_CHAR(base_class__name__abc) \ 00034 TK_Status Interpret (BStreamFileToolkit & tk, HC_KEY key, char const * name) \ 00035 { \ 00036 TK_Status status = base_class__name__abc::Interpret(tk,key,name); \ 00037 m_key = key; \ 00038 return status; \ 00039 } 00040 00041 #define OVERLOAD_WRITE(base_class__name__abc) \ 00042 TK_Status Write(BStreamFileToolkit & tk) \ 00043 { \ 00044 TK_Status status = base_class__name__abc::Write(tk); \ 00045 m_pPersIdent->AssociateKey(m_key); \ 00046 return status; \ 00047 } 00048 00049 #define OVERLOAD_EXECUTE(base_class___name__abc) \ 00050 TK_Status Execute (BStreamFileToolkit &tk) \ 00051 { \ 00052 TK_Status status = base_class___name__abc::Execute(tk); \ 00053 m_pPersIdent->AssociateKey(last_key (tk)); \ 00054 return status; \ 00055 } 00056 00057 #define OVERLOAD_WRITE_POLY(base_class__name__abc) \ 00058 TK_Status Write(BStreamFileToolkit & tk) \ 00059 { \ 00060 TK_Status status = base_class__name__abc::Write(tk); \ 00061 for (int i = 0; i < m_primitive_count; i++) \ 00062 m_pPersIdent->AssociateKey(m_keys[i]); \ 00063 return status; \ 00064 } 00065 00066 #define OVERLOAD_EXECUTE_POLY(base_class___name__abc) \ 00067 TK_Status Execute (BStreamFileToolkit & tk) \ 00068 { \ 00069 TK_Status status = base_class___name__abc::Execute(tk); \ 00070 for (int i = 0; i < m_primitive_count; i++) \ 00071 m_pPersIdent->AssociateKey(m_keys[i]); \ 00072 return status; \ 00073 } 00074 00080 class MVO_API HSharedKey 00081 { 00082 public: 00084 HSharedKey(); 00085 ~HSharedKey() 00086 { 00087 delete_vhash(m_pKeyIdentHashTable); 00088 delete_vhash(m_pIdentKeyHashTable); 00089 } 00090 00095 long AssociateKey(HC_KEY key); 00096 00101 bool DisAssociateKey(HC_KEY key); 00102 00106 void AssociateKeysInSegment(const char *seg = 0); 00107 00111 void DisAssociateKeysInSegment(const char *seg = 0); 00112 00117 HC_KEY GetKeyFromIdent(long ident); 00118 00123 long GetIdentFromKey(HC_KEY ident); 00124 00128 void SetupStreamToolkit(HStreamFileToolkit *tk); 00129 00132 void Reset(); 00133 00134 private: 00135 unsigned int m_PersCounter; 00136 vhash_t *m_pKeyIdentHashTable; 00137 vhash_t *m_pIdentKeyHashTable; 00138 }; 00139 00140 00142 class TK_PIShell : public HTK_Shell { 00143 public: 00147 TK_PIShell(HSharedKey *persIdent) : HTK_Shell() 00148 { 00149 m_pPersIdent = persIdent; 00150 } 00151 OVERLOAD_INTERPRET_INT(HTK_Shell) 00152 OVERLOAD_WRITE(HTK_Shell) 00153 OVERLOAD_EXECUTE(HTK_Shell) 00154 00160 virtual TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00161 00162 private: 00163 HSharedKey *m_pPersIdent; 00164 HC_KEY m_key; 00165 }; 00166 00168 class TK_PIOpen_Segment : public HTK_Open_Segment { 00169 public: 00173 TK_PIOpen_Segment(HSharedKey *persIdent) : HTK_Open_Segment() 00174 { 00175 m_pPersIdent = persIdent; 00176 } 00177 00178 OVERLOAD_INTERPRET_CHAR(HTK_Open_Segment) 00179 OVERLOAD_WRITE(HTK_Open_Segment) 00180 OVERLOAD_EXECUTE(HTK_Open_Segment) 00181 00187 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00188 00189 private: 00190 HSharedKey *m_pPersIdent; 00191 HC_KEY m_key; 00192 00193 }; 00194 00196 class TK_PICircle : public HTK_Circle { 00197 public: 00201 TK_PICircle(unsigned char opcode, HSharedKey *persIdent) : HTK_Circle(opcode) 00202 { 00203 m_pPersIdent = persIdent; 00204 } 00205 OVERLOAD_INTERPRET_INT(HTK_Circle) 00206 OVERLOAD_WRITE(HTK_Circle) 00207 OVERLOAD_EXECUTE(HTK_Circle) 00208 00214 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00215 00216 private: 00217 HSharedKey *m_pPersIdent; 00218 HC_KEY m_key; 00219 00220 }; 00221 00223 class TK_PIEllipse : public HTK_Ellipse { 00224 public: 00228 TK_PIEllipse(unsigned char opcode, HSharedKey *persIdent) : HTK_Ellipse(opcode) 00229 { 00230 m_pPersIdent = persIdent; 00231 } 00232 OVERLOAD_INTERPRET_INT(HTK_Ellipse) 00233 OVERLOAD_WRITE(HTK_Ellipse) 00234 OVERLOAD_EXECUTE(HTK_Ellipse) 00235 00241 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00242 00243 private: 00244 00245 HSharedKey *m_pPersIdent; 00246 HC_KEY m_key; 00247 00248 00249 }; 00250 00252 class TK_PIGrid : public HTK_Grid { 00253 public: 00257 TK_PIGrid(HSharedKey *persIdent) : HTK_Grid() 00258 { 00259 m_pPersIdent = persIdent; 00260 } 00261 OVERLOAD_INTERPRET_INT(HTK_Grid) 00262 OVERLOAD_WRITE(HTK_Grid) 00263 OVERLOAD_EXECUTE(HTK_Grid) 00264 00270 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00271 00272 private: 00273 HSharedKey *m_pPersIdent; 00274 HC_KEY m_key; 00275 00276 }; 00277 00279 class TK_PIImage : public HTK_Image { 00280 public: 00284 TK_PIImage(HSharedKey *persIdent) : HTK_Image() 00285 { 00286 m_pPersIdent = persIdent; 00287 } 00288 OVERLOAD_INTERPRET_INT(HTK_Image) 00289 OVERLOAD_WRITE(HTK_Image) 00290 OVERLOAD_EXECUTE(HTK_Image) 00291 00297 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **) const; 00298 00299 private: 00300 HSharedKey *m_pPersIdent; 00301 HC_KEY m_key; 00302 00303 00304 }; 00305 00307 class TK_PILine : public HTK_Line { 00308 public: 00312 TK_PILine(HSharedKey *persIdent) : HTK_Line() 00313 { 00314 m_pPersIdent = persIdent; 00315 } 00316 OVERLOAD_INTERPRET_INT(HTK_Line) 00317 OVERLOAD_WRITE(HTK_Line) 00318 OVERLOAD_EXECUTE(HTK_Line) 00319 00325 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00326 00327 private: 00328 HSharedKey *m_pPersIdent; 00329 HC_KEY m_key; 00330 00331 00332 }; 00333 00335 class TK_PIPolypoint : public HTK_Polypoint { 00336 public: 00340 TK_PIPolypoint(unsigned char opcode, HSharedKey *persIdent) : HTK_Polypoint(opcode) 00341 { 00342 m_pPersIdent = persIdent; 00343 } 00344 OVERLOAD_INTERPRET_INT(HTK_Polypoint) 00345 OVERLOAD_WRITE(HTK_Polypoint) 00346 OVERLOAD_EXECUTE(HTK_Polypoint) 00347 00353 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00354 00355 private: 00356 HSharedKey *m_pPersIdent; 00357 HC_KEY m_key; 00358 00359 00360 }; 00361 00363 class TK_PIPolyPolypoint : public HTK_PolyPolypoint { 00364 public: 00368 TK_PIPolyPolypoint(unsigned char opcode, HSharedKey *persIdent) : HTK_PolyPolypoint(opcode) 00369 { 00370 m_pPersIdent = persIdent; 00371 } 00372 OVERLOAD_WRITE_POLY(HTK_PolyPolypoint) 00373 OVERLOAD_EXECUTE_POLY(HTK_PolyPolypoint) 00374 00380 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00381 00382 private: 00383 HSharedKey *m_pPersIdent; 00384 00385 }; 00386 00388 class TK_PIPoint : public HTK_Point { 00389 public: 00393 TK_PIPoint(unsigned char opcode, HSharedKey *persIdent) : HTK_Point(opcode) 00394 { 00395 m_pPersIdent = persIdent; 00396 } 00397 OVERLOAD_INTERPRET_INT(HTK_Point) 00398 OVERLOAD_WRITE(HTK_Point) 00399 OVERLOAD_EXECUTE(HTK_Point) 00400 00406 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00407 00408 private: 00409 HSharedKey *m_pPersIdent; 00410 HC_KEY m_key; 00411 00412 00413 }; 00414 00416 class TK_PISpot_Light : public HTK_Spot_Light { 00417 public: 00421 TK_PISpot_Light(HSharedKey *persIdent) : HTK_Spot_Light() 00422 { 00423 m_pPersIdent = persIdent; 00424 } 00425 OVERLOAD_INTERPRET_INT(HTK_Spot_Light) 00426 OVERLOAD_WRITE(HTK_Spot_Light) 00427 OVERLOAD_EXECUTE(HTK_Spot_Light) 00428 00434 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00435 00436 private: 00437 HSharedKey *m_pPersIdent; 00438 HC_KEY m_key; 00439 00440 00441 }; 00442 00444 class TK_PIArea_Light : public HTK_Area_Light { 00445 public: 00449 TK_PIArea_Light(HSharedKey *persIdent) : HTK_Area_Light() 00450 { 00451 m_pPersIdent = persIdent; 00452 } 00453 OVERLOAD_INTERPRET_INT(HTK_Area_Light) 00454 OVERLOAD_WRITE(HTK_Area_Light) 00455 OVERLOAD_EXECUTE(HTK_Area_Light) 00456 00462 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00463 00464 private: 00465 HSharedKey *m_pPersIdent; 00466 HC_KEY m_key; 00467 00468 00469 }; 00470 00472 class TK_PIMesh : public HTK_Mesh { 00473 public: 00477 TK_PIMesh(HSharedKey *persIdent) : HTK_Mesh() 00478 { 00479 m_pPersIdent = persIdent; 00480 } 00481 OVERLOAD_INTERPRET_INT(HTK_Mesh) 00482 OVERLOAD_WRITE(HTK_Mesh) 00483 OVERLOAD_EXECUTE(HTK_Mesh) 00484 00490 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00491 00492 private: 00493 HSharedKey *m_pPersIdent; 00494 HC_KEY m_key; 00495 00496 00497 }; 00498 00500 class TK_PINURBS_Curve : public HTK_NURBS_Curve { 00501 public: 00505 TK_PINURBS_Curve(HSharedKey *persIdent) : HTK_NURBS_Curve() 00506 { 00507 m_pPersIdent = persIdent; 00508 } 00509 OVERLOAD_INTERPRET_INT(HTK_NURBS_Curve) 00510 OVERLOAD_WRITE(HTK_NURBS_Curve) 00511 OVERLOAD_EXECUTE(HTK_NURBS_Curve) 00512 00518 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00519 00520 private: 00521 HSharedKey *m_pPersIdent; 00522 HC_KEY m_key; 00523 00524 00525 }; 00526 00528 class TK_PICutting_Plane : public HTK_Cutting_Plane { 00529 public: 00533 TK_PICutting_Plane( HSharedKey *persIdent) : HTK_Cutting_Plane() 00534 { 00535 m_pPersIdent = persIdent; 00536 } 00537 OVERLOAD_INTERPRET_INT(HTK_Cutting_Plane) 00538 OVERLOAD_WRITE(HTK_Cutting_Plane) 00539 OVERLOAD_EXECUTE(HTK_Cutting_Plane) 00540 00546 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00547 00548 private: 00549 HSharedKey *m_pPersIdent; 00550 HC_KEY m_key; 00551 00552 00553 }; 00554 00556 class TK_PIText : public HTK_Text { 00557 public: 00561 TK_PIText(unsigned char opcode, HSharedKey *persIdent) : HTK_Text(opcode) 00562 { 00563 m_pPersIdent = persIdent; 00564 } 00565 OVERLOAD_INTERPRET_INT(HTK_Text) 00566 OVERLOAD_WRITE(HTK_Text) 00567 OVERLOAD_EXECUTE(HTK_Text) 00568 00574 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00575 00576 private: 00577 HSharedKey *m_pPersIdent; 00578 HC_KEY m_key; 00579 00580 00581 }; 00582 00584 class TK_PIReferenced_Segment : public HTK_Referenced_Segment { 00585 public: 00589 TK_PIReferenced_Segment(unsigned char opcode, HSharedKey *persIdent) : HTK_Referenced_Segment(opcode) 00590 { 00591 m_pPersIdent = persIdent; 00592 } 00593 OVERLOAD_INTERPRET_INT(HTK_Referenced_Segment) 00594 OVERLOAD_WRITE(HTK_Referenced_Segment) 00595 OVERLOAD_EXECUTE(HTK_Referenced_Segment) 00596 00602 TK_Status Clone (BStreamFileToolkit & tk, BBaseOpcodeHandler **handler) const; 00603 00604 private: 00605 HSharedKey *m_pPersIdent; 00606 HC_KEY m_key; 00607 00608 00609 }; 00610 00611 00612 00613 #ifdef H_PACK_8 00614 #pragma pack(pop) 00615 #endif 00616 00617 #endif 00618 00619 00620 00621 00622 00623 00624 00625