00001 // 00002 // Copyright (c) 2000 by Tech Soft 3D, LLC. 00003 // The information contained herein is confidential and proprietary to 00004 // Tech Soft 3D, LLC., and considered a trade secret as defined under 00005 // civil and criminal statutes. Tech Soft 3D shall pursue its civil 00006 // and criminal remedies in the event of unauthorized use or misappropriation 00007 // of its trade secrets. Use of this information by anyone other than 00008 // authorized employees of Tech Soft 3D, LLC. is granted only under a 00009 // written non-disclosure agreement, expressly prescribing the scope and 00010 // manner of such use. 00011 // 00012 // $Id: 87c88f3105dc990fcbf02758f15bad4ebebdfe22 $ 00013 // 00014 00015 // HUtility.h : interface of the HUtility class 00016 // Set of utility methods 00017 // All methods are public and static 00018 00019 00020 #ifndef _HUTILITY_H 00021 #define _HUTILITY_H 00022 00023 #ifdef H_PACK_8 00024 #pragma pack(push) 00025 #pragma pack(8) 00026 #endif 00027 00028 00029 #include "HTools.h" 00030 #include "hic_types.h" 00031 00032 class HBaseView; 00033 class HOutputHandlerOptions; 00034 class HSmartSelItem; 00035 class HBaseModel; 00036 00037 class HShellObject; 00038 00039 00040 enum AbsoluteWindowType 00041 { 00042 RelativeLeft, 00043 RelativeRight, 00044 RelativeTop, 00045 RelativeBottom, 00046 NotRelative 00047 }; 00048 00049 class FaceWithNormalInfo 00050 { 00051 public: 00052 FaceWithNormalInfo() 00053 { 00054 nindex = -1; 00055 tcindex = -1; 00056 nextindex = -1; 00057 } 00058 int nindex; 00059 int nextindex; 00060 int tcindex; 00061 }; 00062 00063 00064 class MVO_API ShellToRegionMapper 00065 { 00066 public: 00067 ShellToRegionMapper(); 00068 void AddRegion(HC_KEY originalshell, HC_KEY newshell, int regionnum, bool check = true); 00069 HC_KEY GetOriginalShell(HC_KEY newshell, int regionnum); 00070 int GetRegionsFromOriginalShell(HC_KEY originalshell, HC_KEY **newshells, int ®ionnum); 00071 void BuildSegmentTreeRecursive(HC_KEY okey, HC_KEY nkey); 00072 void MapSegmentTree(HC_KEY modelkey); 00073 void AddSegmentMapping(HC_KEY originalshell, HC_KEY segmentkey); 00074 00075 struct vhash_s * m_RegionToShellHash; 00076 struct vhash_s * m_ShellToRegionHash; 00077 struct vhash_s * m_ShellToSegmentHash; 00078 00079 }; 00080 00081 00082 00083 00084 00086 00089 class MVO_API HShellEdge { 00090 public: 00095 HShellEdge(int iFirst = 0, int iSecond = 0){ 00096 Set(iFirst, iSecond); 00097 }; 00099 int GetFirst() const { return m_iFirst; }; 00101 int GetSecond() const { return m_iSecond; }; 00106 void Set(int first, int second) { 00107 /* first should always be < second to eliminate ambiguity. */ 00108 if(first < second){ 00109 m_iFirst = first; 00110 m_iSecond = second; 00111 } else { 00112 m_iFirst = second; 00113 m_iSecond = first; 00114 } 00115 }; 00116 00117 bool operator<(HShellEdge const & rhs) const { 00118 if(m_iFirst != rhs.m_iFirst) 00119 return m_iFirst < rhs.m_iFirst; 00120 return m_iSecond < rhs.m_iSecond; 00121 } 00122 00123 private: 00124 int m_iFirst; 00125 int m_iSecond; 00126 }; 00127 00129 00132 class MVO_API HShellFace{ 00133 public: 00138 HShellFace(HShellObject const * pShell, int const iFaceIndex); 00139 00141 int GetPointCount() const ; 00142 00144 int GetEdgeCount() const ; 00149 HShellEdge const GetEdge(int const iEdgeIndex) const; 00153 void OpenEdge(int const iEdgeIndex) const; 00157 void CloseEdge() const; 00158 00159 private: 00160 HShellObject const * m_pShell; 00161 int m_iFaceIndex; 00162 int m_iPointCount; 00163 }; 00164 00166 00169 class MVO_API HShellRegion{ 00170 public: 00175 HShellRegion(HShellObject const * pShell, int const iRegionIndex); 00176 ~HShellRegion(){ 00177 delete [] m_pRegionFlist; 00178 } 00181 int GetFaceCount() const; 00186 HShellFace const GetFace(int index) const; 00187 00188 //void Open() const; 00189 //void Close() const; 00190 private: 00191 HShellObject const * m_pShell; 00192 int m_iRegionIndex; 00193 00194 int m_iRegionFlistLength; 00195 int *m_pRegionFlist; 00196 }; 00197 00198 00200 00203 class MVO_API HShellObject { 00204 public: 00208 HShellObject(HC_KEY kShellKey); 00209 HShellObject(HShellObject const & oShellObj); 00210 ~HShellObject(); 00211 00216 HShellRegion const GetRegion(int const index) const; 00217 00219 int GetFaceCount() const; 00224 int GetFaceFlistIndex(int index) const; 00225 00226 //void Open() const; 00227 //void Close() const; 00228 00230 HC_KEY GetKey() const ; 00232 int GetFlistLen() const ; 00234 int const * GetFlist() const ; 00237 void GetFlist (int *flist) const ; 00238 00239 private: 00240 int m_iFlistLen; 00241 int * m_pFlist; 00242 mutable int * m_pFaceIndexes; 00243 00244 HC_KEY m_kShellKey; 00245 }; 00246 00247 00249 00252 class MVO_API HShell { 00253 public: 00254 HShell() 00255 :point_list_len(0), 00256 point_list(), 00257 normal_list(), 00258 face_list_len(0), 00259 face_list(0), 00260 face_count(0), 00261 region_count(0), 00262 region_list(0) 00263 {} 00264 ~HShell() 00265 { 00266 /* No need to check for null pointers. delete already does that. */ 00267 delete [] point_list; 00268 delete [] normal_list; 00269 delete [] face_list; 00270 delete [] region_list; 00271 } 00272 int point_list_len; 00273 HPoint *point_list; 00274 HVector *normal_list; 00275 00276 int face_list_len; 00277 int *face_list; 00278 int face_count; 00279 00280 int region_count; 00281 int *region_list; 00282 }; 00283 00285 00289 class MVO_API HShellWrapper { 00290 00291 public: 00296 HShellWrapper(HC_KEY key) { 00297 m_Points = 0; 00298 m_Flist = 0; 00299 m_VParams = 0; 00300 m_VNormals = 0; 00301 m_VColors = 0; 00302 m_faceregion = 0; 00303 m_totalnumfaceslen = 0; 00304 m_numfaceslen = 0; 00305 m_FNArray = 0; 00306 m_faceindirect = 0; 00307 Set(key); 00308 } 00312 HShellWrapper() { 00313 m_Key = INVALID_KEY; 00314 m_Points = 0; 00315 m_Flist = 0; 00316 m_VParams = 0; 00317 m_VNormals = 0; 00318 m_VColors = 0; 00319 m_flen = 0; 00320 m_plen = 0; 00321 m_totalplen = 0; 00322 m_totalflen = 0; 00323 m_faceregion = 0; 00324 m_totalnumfaceslen = 0; 00325 m_numfaceslen = 0; 00326 m_FNArray = 0; 00327 m_faceindirect = 0; 00328 } 00329 ~HShellWrapper(); 00330 00341 HC_KEY Insert(int plen, HPoint *points, int flen, int *flist, HC_KEY insertkey = INVALID_KEY); 00349 HC_KEY Show(int *plen, HPoint **points, int *flen, int **flist); 00353 HC_KEY GetKey() { return m_Key; } 00357 void TransformPoints(float *matrix); 00358 00363 HC_KEY Optimize(char *options); 00369 HC_KEY Optimize2(char *options); 00370 00371 void MakePolygon(int facelen, int *face, HPoint *points); 00372 00373 00376 void OpenOwnerSegment(); 00377 00380 void BeginFaceIteration(); 00381 00384 void EndFaceIteration() { ; }; 00385 int GetFace(int facenum, int **face); 00390 int NextFace(int **face); 00391 00397 void CalculateFaceCenter(int *face, int flen, HPoint *mid); 00404 void AddPoints(HPoint *points, int pnum, HPoint *param = 0, HPoint *normals = 0, bool AddImmediatly= false); 00411 void AddFace(int *face, int fnum, int regionnum, HPoint *points, HPoint *normals = 0, bool AddImediatly= false); 00418 void AddFaceDirect(int *face, int fnum, bool reverse = false, bool AddImmediatly= false); 00425 void AddFace(HPoint *points, int fnum, bool AddImmediatly= false); 00430 void Set(HC_KEY key); 00437 void Regenerate(HC_KEY newowner = INVALID_KEY, bool makeSegment = true, bool regenerate = false); 00442 void GrowArrays(int fnum); 00448 void GrowPointArray(int fnum, bool gorwvparams = false, bool grownormals = false); 00449 00450 void GrowPointArray2(int fnum, bool growparamarray = false, bool grownormalarray = false, bool growfnarray = false, bool growcolorarray = false); 00451 void AddNextFaceWithDistinctNormals(HPoint const * points, HPoint const * normals, int const * face1, int const * face2, int fnum); 00452 void AddNextFaceWithDistinctNormalsAndTexture(HPoint const * points, HPoint const * normals, HPoint const * texcor,int const * face1, int const *face2, int const *face3, int fnum); 00453 void AddNextFaceWithDistinctNormalsAndColor(HPoint const *points, HPoint const *normals,int const *face1, int const *face2, HPoint *face3, int fnum); 00454 00455 00456 void BeginAddFaces(int pnum); 00457 void EndAddFaces(); 00458 00463 void GrowFaceArray(int fnum); 00464 00466 void SubdivideOneQuadFace(int *face, HShellWrapper &wrapper, bool generateIsolines, int *facecolorlist, int &fclnum); 00467 00469 void SubdivideOneQuadFace2(int *face); 00474 void SubdivideQuadFaces(bool GenerateIsolines); 00475 00479 void SetVertexColors(HPoint *color); 00483 void ShowVertexColors(HPoint *color); 00488 void SetVertexColors(float *findex); 00492 void ShowVertexColors(float *color); 00498 void MakeLod(int lodnum, int percent); 00504 void FindExtents(HPoint ¢er, HPoint &min, HPoint &max); 00505 void ReplaceWithParameters(int plen, HPoint *points, int flen, int *flist, HPoint *normals = 0, float *params = 0, int paranum = 3, HPoint *vcolors = 0, bool emptyshell = false); 00506 void ReplaceWithParameters(int plen, HPoint *points, int flen, int *flist, HPoint *normals, float *params, int paranum, bool emptyshell); 00507 void Replace(int plen, HPoint *points, int flen, int *flist, HPoint *normals = 0, bool emptyshell = false); 00508 00509 void SetFaceRegion(int regionnum); 00510 00511 void SetEmptyShell(HC_KEY segmentkey, bool MakeSegment); 00512 00513 00514 int m_plen; 00515 int m_flen; 00516 HPoint *m_Points;//<! The list of pointst that define the shell. 00517 HPoint *m_VParams; 00518 HPoint *m_VColors; 00519 HPoint *m_VNormals; 00520 int *m_Flist; 00521 HC_KEY m_Key; 00522 00524 int m_facepointer; 00526 int m_totalflen; 00528 int m_totalplen; 00529 int m_totalnumfaceslen; 00530 int m_numfaceslen; 00531 int *m_faceregion; 00532 int *m_faceindirect; 00533 FaceWithNormalInfo *m_FNArray; 00534 00535 }; 00536 00537 00539 00542 class MVO_API HCamera { 00543 public: 00544 bool valid; 00545 HPoint position; 00546 HPoint target; 00547 HPoint up_vector; 00548 float field_width; 00549 float field_height; 00550 char projection[128]; 00551 00552 HCamera () { 00553 projection[0] = '\0'; 00554 valid = false; 00555 } 00556 00558 inline void InvalidateCamera() { projection[0]='\0'; valid = false; } 00559 00563 bool CameraDifferent(HCamera &cam); 00564 00568 bool CameraDifferentByAngle(HCamera &cam); 00569 00570 00573 void GetFromView(HBaseView * view); 00574 00576 void Show() { 00577 HC_Show_Camera (&position, &target, &up_vector, &field_width, &field_height, projection); 00578 valid = true; 00579 }; 00580 00582 void Set() const { 00583 HC_Set_Camera (&position, &target, &up_vector, field_width, field_height, projection); 00584 }; 00585 }; 00586 00587 00589 00592 class MVO_API HBSurfVertex 00593 { 00594 public: 00595 double x; 00596 double y; 00597 double z; 00598 double w; 00599 00602 inline void Set(double X, double Y, double Z, double W) { x=X, y=Y, z=Z, w=W; } 00603 }; 00604 00606 00610 class MVO_API HPolyline 00611 { 00612 public: 00613 int m_PointCount; 00614 HPoint *m_pHPointArray; 00615 HPolyline *m_pNextPolyline; 00616 }; 00617 00619 00623 class MVO_API HShellVertexData 00624 { 00625 public: 00626 /* Constructor initializes this object to an invalid state. */ 00627 HShellVertexData():m_VertexCount(0), m_pFIndexArraySize(0), m_pFIndexArray(0), m_Key(INVALID_KEY){ 00628 m_sType[0] = '\0'; 00629 } 00630 00631 /* Destructor free up the resources this object is using. */ 00632 ~HShellVertexData(){ 00633 ResetMyself(); 00634 } 00635 00636 /* Sets the key and fills in the members with the correct data for this shell. */ 00637 void SetKey(HC_KEY const key); 00638 00639 /* Return a const string for the type of shell. */ 00640 char const * const GetType() const { 00641 return m_sType; 00642 } 00643 00644 /* Returns the vertex count for this shell. */ 00645 int const GetVertexCount() const { 00646 return m_VertexCount; 00647 } 00648 00649 /* Return the key for the shell */ 00650 HC_KEY const GetKey() const { 00651 return m_Key; 00652 } 00653 00654 /* Return the size the findex array */ 00655 int const GetFIndexDataSize() const { 00656 return m_pFIndexArraySize; 00657 } 00658 00659 /* Returns a const array for the findex values in this shell. */ 00660 float const * const GetFIndexData() const { 00661 return m_pFIndexArray; 00662 } 00663 00664 /* Returns a const array (as an argument) for the findex values in this shell. 00665 Note that the array must be of the appropriate size, e.g., via a call to GetFIndexDataSize. */ 00666 void GetFIndexData(float *data) const; 00667 00668 void SetFIndexData(int const size, float const * const data); 00669 00670 private: 00671 void ResetMyself(); 00672 00673 int m_VertexCount; 00674 int m_pFIndexArraySize; 00675 float *m_pFIndexArray; 00676 HC_KEY m_Key; 00677 char m_sType[32]; 00678 }; 00679 00680 00682 00684 typedef struct 00685 { 00686 HC_KEY *patharray; 00687 int len; 00688 }HShowContentsWithPathType; 00689 00690 00691 enum HWindowCorner 00692 { 00693 TopLeft, 00694 BottomLeft, 00695 BottomRight, 00696 TopRight 00697 }; 00698 00699 00700 00701 00702 00703 00704 00706 00724 class MVO_API HUserOptions 00725 { 00726 public: 00727 00728 char * m_data; 00729 int m_length; 00730 bool m_valid; 00731 00733 HUserOptions(); 00734 00736 HUserOptions(const HUserOptions& in_data); 00737 00738 00740 ~HUserOptions(); 00741 00742 00746 bool IsValid(); 00747 00753 const char * Show_User_Options(); 00754 00760 const char * Show_One_Net_User_Option(const char * which); 00761 00767 const char * Show_One_User_Option(const char * which); 00768 00774 const char * Show_Net_User_Options(); 00775 00776 00777 private: 00778 00779 void clear() { 00780 delete [] m_data; 00781 m_data = 0; 00782 m_length = 0; 00783 }; 00784 00785 }; 00786 00787 00788 00790 00793 class MVO_API HUtility 00794 { 00795 public: 00796 #undef PI 00797 static const float PI; 00798 00799 enum{X, Y, Z, W}; 00800 enum{XY, XZ, YZ}; 00801 00802 static const float EH_Epsilon; 00803 00804 00811 static void Order(HPoint* one, HPoint* two); 00812 00819 static void Find_Relative_Path(HC_KEY from_seg_key, HC_KEY to_seg_key, char * path); 00820 00824 static float GetTime(); 00825 00826 00831 static void ClampPointToWindow (HPoint * point); 00832 00839 static HC_KEY InsertBox (HPoint const * max, HPoint const * min); 00840 00848 static HC_KEY InsertWireframeBox (HPoint * max, HPoint * min); 00849 00856 static void GenerateCuboidPoints (HPoint const * max, HPoint const * min, HPoint * points); 00857 00869 static HC_KEY InsertRectangle (const char * seg, float x0, float y0, float x1, float y1, float z = 0.0f, bool fill = false); 00870 00871 00886 static void InsertArrow(float stick_length, float tip_length, float stick_radius, float arrow_radius, const char *text, const char *stick_color, const char *tip_color, int num_sides = 6, float tip_falloff = 0.05, bool reverse = true); 00887 00894 static void ComputeDoublePrecisionCrossProduct(double * vector1, double * vector2, double * up); 00895 00902 static double ComputeDoublePrecisionDotProduct(double * vector1, double * vector2); 00903 00909 static double ComputeDoublePrecisionVectorLength(double * vector1); 00910 00917 static void GetViewplaneVectors(HC_KEY segment_key, double * view, double * up); 00918 00923 static void NormalizeDoublePrecisionVector(double* vector1); 00924 00932 static bool PointsEqual(HPoint * point1, HPoint * point2); 00933 00945 static bool CreateAxisCircle (HPoint const & center, float radius, int axis, bool convert = true); 00946 00947 00954 static void RotateToVector(HPoint start, HPoint end, bool doTranslation = true); 00955 00971 static void SmoothTransition(const HPoint &co, const HPoint &to, const HPoint &uo, float fieldwidtho, float fieldheighto, const HPoint &cn, const HPoint &tn, const HPoint &un, float fieldwidthn, float fieldheightn, HBaseView *view); 00972 00980 static void SmoothTransition(HCamera old_camera, const HCamera &new_camera, HBaseView *view); 00981 00988 static bool CamerasEqual(const HCamera &camera1, const HCamera &camera2); 00989 00997 static void ComputeVectorToVectorRotationMatrix(float *matrix,HPoint v1,HPoint v2); 00998 01007 static bool ExtractRGB(char *text,float &r, float &g, float &b); 01008 01019 static void TransitionQuaternion(float *quat_old, float *quat_new, float t, float *qt); 01020 01026 static void MatrixToQuaternion(float *matrix, float *quaternion); 01027 01033 static void QuaternionToMatrix(float * quaternion, float *matrix); 01034 01043 static void SmoothQuaternionTransition(HBaseView *m_pView, char *old_seg, char *new_seg, int num_of_transitions); 01044 01052 static void SmoothMatrixTransition(HBaseView *m_pView, HC_KEY seg_key, float *new_matrix); 01053 01063 static void MultiSmoothTransitions(HBaseView *m_pView, int num_keys, HC_KEY *seg_key, float *new_matrix, HCamera *new_camera = 0); 01064 01070 static HPoint GetCentroid(HC_KEY seg_key); 01071 01078 static HPoint GetTransformedCentroid(HC_KEY seg_key, float * matrix = 0); 01079 01087 static void URIencode(const char * in_string, MVO_POINTER_SIZED_UINT n, char * out_buffer); 01095 static void URIdecode(const char * in_string, char * out_buffer, MVO_POINTER_SIZED_UINT * n); 01096 01105 static void GetCameraFromMatrix(float *matrix, HPoint *target, HPoint *position, HPoint *up_vector, HPoint *translation); 01106 01115 static void GetMatrixFromCamera(HPoint target, HPoint position, HPoint up_vector, HPoint translation, float *matrix); 01116 01117 01151 static void GetCameraFromGLFrustum(double const left, double const right, double const bottom , double const top, double const near_z, double const far_z, bool const perspective, 01152 HPoint &pos, HPoint &target, HPoint &up, char * projection, double &width, double &height, double &near_limit ); 01153 01161 static bool PushAttribute(const char *attName); 01162 01171 static void PushAttribute(const char *attName, const char *attText); 01172 01180 static bool PopAttribute(const char *attName); 01181 01192 static bool ModifyPushedAttribute(const char *attName, const char *newStyle); 01193 01200 static bool ShowPushedAttribute(const char *attName, HUserOptions& attText); 01201 01214 static void Recursive_Merge_Shells( HShell *total_info, HShell *max_info, bool do_recurse, bool delete_orig_shells = false, bool insert_null_lods = false ); 01215 01222 static HC_KEY Merge_Shells( bool do_recurse, bool delete_orig_shells = false , bool optimize_shell = true, bool generate_regions = false); 01223 01231 static HC_KEY Merge_Shells_Generate_Regions( int num_shells, HC_KEY * shell_keys, bool delete_orig_shells = false ); 01232 01242 static void Generate_LODs( bool do_recurse = true, bool delete_orig_shells = false, bool insert_null_lods = false, int n_lod_levels = 2, float reduction_ratio = 0.20 ); 01243 01251 static bool Segment_Shell_Allocate( HShell *total_info, HShell *max_info, bool do_recurse ); 01252 01260 static void Shell_Search( HShell *total_info, HShell *max_info, bool do_recurse ); 01261 01262 01263 01274 static void OptimizeSegmentTree(HC_KEY old_seg_key, HC_KEY *new_seg_key, bool transform_shells = true, bool merge_shells = true, bool create_shell_regions = false); 01275 01276 01285 static void CountShellData(HC_KEY shell_key, int * faces, int * vertices, int * triangles, int * tristrips = 0); 01286 01293 static void FindFileNameExtension(const char * filename_in, char * ext_out, int size = -1); 01294 01301 static void FindFileNameExtension(__wchar_t const * const filename_in, __wchar_t * ext_out, int size = -1); 01302 #ifdef H_USHORT_OVERLOAD 01303 static void FindFileNameExtension(unsigned short const * const filename_in, unsigned short * ext_out, int size = -1){ 01304 FindFileNameExtension((wchar_t const * const)filename_in, (wchar_t*)ext_out, size); 01305 } 01306 #endif 01307 01312 static void FindUnicodeFileNameExtension(const unsigned short * filename_in, char * ext_out); 01313 01321 static void FindFileNameAndDirectory(const char * filename_in, char * dir_out, char * filename_out); 01329 static void FindFileNameAndDirectory(__wchar_t const * filename_in, __wchar_t * dir_out, __wchar_t * filename_out); 01330 01341 static const char* extra_pointer_format(); 01345 static HC_KEY CreateScaleIndependentSegment(const char *segname, bool SetCallback = true); 01346 01350 static HC_KEY GetScaleIndependentGeomSegmentKey(HC_KEY segkey); 01351 01355 static void SetScaleIndependentGeomPosition(HC_KEY segkey, float x, float y, float z); 01356 01360 static void GetScaleIndependentGeomPosition(HC_KEY segkey, float &x, float &y, float &z); 01361 01365 static void RegisterCallbacks(); 01366 01373 static bool IsModelKey(HC_KEY modelkey, HC_KEY objectkey); 01374 01382 static HC_KEY UserOptionExists(HC_KEY key, const char *attrib, char *result); 01383 01400 static void InsertRotatedArrow(float stick_length, float tip_length, float stick_radius, float tip_radius, float distance, int adelta, float rotang, const char *stick_color, const char *tip_color, int num_sides, float tip_falloff, bool reverse); 01401 01411 static int CalculateKeyPath(HC_KEY startkey, HBaseView *view, HC_KEY *keyarray, int maxarray); 01412 01417 static bool SegmentExists(const char *segment); 01418 01421 static void UnsetAttributes(); 01422 01430 static int IsChildOf(HC_KEY owner, HC_KEY child, HC_KEY *klist = 0); 01431 01437 static bool IsIdentityMatrix(float* matrix); 01438 01445 static void ComputeShellNormal(HC_KEY skey, HPoint &tnormal); 01446 01456 static HC_KEY SelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false); 01457 01458 01469 static HC_KEY SmartSelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false); 01470 01471 01478 static bool ShowOneHeuristic(const char *type, char *res = 0); 01485 static bool ShowOneRenderingOption(const char *type, char *res = 0); 01486 01496 static float EaseInEaseOut(float t, float a, float b, float c); 01497 01502 static void UnwindIncludes(HC_KEY &key); 01503 01510 static void UnwindIncludes(HC_KEY &newkey, HC_KEY *keys, int count); 01511 01512 01519 static bool SafeSetUserOption(const char * opt); 01520 01527 static bool SafeShowUserOption(char * opt); 01528 01529 01534 static void ProjectShell(HC_KEY shellkey); 01535 01542 static HC_KEY MergeShells(HC_KEY shell1, HC_KEY shell2); 01543 01549 static void ShowModellingMatrix(float *segment_modelling_matrix); 01550 01557 static void ConvertLocalPixelsToLocalWindow(HBaseView * view, HPoint *in_system , HPoint *out_system = 0); 01558 01559 01566 static HC_KEY GrabSegment(HC_KEY key); 01567 01572 # define MakeSegment(key) GrabSegment(key) 01573 01579 static void RenameSegment(HC_KEY segkey, const char *newname); 01580 01581 01592 static void InterpolateNormalAlongEdge(HPoint &p1, HPoint &n1, HPoint &p2, HPoint &n2, HPoint &p3, HPoint &n3); 01593 01599 static void ShowNormals(HC_KEY shellkey, float normallength); 01600 01606 static bool IsSegmentKey(HC_KEY key); 01607 01614 static int FindContents(HC_KEY &key); 01615 01622 static int CalculateMajorAxis(HBaseView *view); 01623 01624 01632 static HC_KEY FindOneObject(const char *type, bool l = 0); 01638 static void CloseAllSegments(HC_KEY endkey = INVALID_KEY); 01639 01644 static void ReadjustTarget(HBaseView *view); 01645 01650 static bool GetAllowAnimation(HC_KEY key); 01651 01654 static void SuppressAnimation(); 01655 01663 static int FindFaceByIndex(int findex, int *flist, int flen); 01664 01671 static bool ShowOneUserOption(const char *option, char *res); 01672 01678 static HC_KEY GetNextRenumberedKey(HBaseView *view); 01679 01685 static void NameSegments(HC_KEY &key, HBaseView *view); 01686 01692 static void MoveToTemp(HC_KEY movekey, HC_KEY tempkey); 01693 01704 static void ShowContentsWithPath( const char * entitytypes, struct vlist_s **ret_pathlist, bool storePath = false, bool includeIncludes = true, bool filterIncludes = true); 01705 01706 01712 static int ustrlen(unsigned short *text); 01713 01723 static bool RLECompress(int const in_len, 01724 unsigned char const * const in_buf, 01725 int * out_len, 01726 unsigned char * const out_buf); 01727 01737 static bool ZlibCompress(int const in_len, 01738 unsigned char const * const in_buf, 01739 int & out_len, 01740 unsigned char * const out_buf); 01741 01751 static bool ZlibDecompress(int const in_len, 01752 unsigned char const * const in_buf, 01753 int & out_len, 01754 unsigned char * const out_buf); 01760 static unsigned short *uconvert(const char *text); 01761 01772 static bool BuildIncludePath(HC_KEY objectkey, const HC_KEY *includelist, int ilength, HC_KEY *fullpath, int *fplength, HC_KEY matchkey = INVALID_KEY); 01773 01780 static void BuildIncludePathFromSelection(HSmartSelItem *sitem, int &plen, HC_KEY *fullpath); 01781 01782 01791 static void MakeViewSnapshot(HBaseView * view, int width, int height, char ** data); 01792 01798 static void MakeViewSnapshot(HBaseView * view, HC_KEY image_key); 01799 01808 static int ConstrainToVector( const float *matrix_in, const HVector &vector, float *matrix_out ) ; 01809 01817 static void Camera_To_Transform (HCamera *camera , float *pos, float *projection_matrix, float *complete_matrix); 01828 static void LocalPixelsToWorld(HCamera *camera, bool righthanded, float xres, float yres, int xwpix, int ywpix, float *result); 01835 static float ComputeAngleBetweenVector(HPoint p1, HPoint p2); 01836 01837 01843 static int strlen16( const unsigned short *p16); 01844 01853 static void CalculateBoundingInfo(HC_KEY startkey, HPoint &min, HPoint &max, HPoint &delta, HPoint &mid); 01854 01864 static long ClipPolygonAgainstPlane(long vertexCount, const HPoint *vertex, 01865 const float *plane, HPoint *result, bool *noCut = 0); 01866 01873 static HFileOutputResult TwoPassPrint(const char *driver, HOutputHandlerOptions *options); 01874 01882 static HC_KEY OpenSegmentFromKey(HC_KEY key, char *segment); 01883 01884 01896 static bool IsPointInsideAllEdges( const float *pt,const float *points1, 01897 int len, const int *face1, const float *plane1, float fudge ); 01905 static void IntersectionLinePlane(HPoint *p1, HPoint *p2, HPlane *p, HPoint *res); 01906 01921 static void MergePointsIntoShell(int num_shell_points, HPoint *plist1, int num_shell_facelist, int *flist1, 01922 int num_merge_points, HPoint *merge_points, HPoint *merge_vectors, 01923 float tolerance, bool AddExtraPoints, int *newpoints, int *newpointslen); 01924 01925 01940 static void SubdivideShells(HC_KEY sskey, HC_KEY startkey, HC_KEY newkey, int numx, int numy, int numz, ShellToRegionMapper *mapper = 0, bool DoCut = true, bool DeleteOriginalShells = false, bool breakShells = false); 01941 01943 static void MergePolylines(); 01944 static void CreateZebraStripeTexture(int width, int height, int stripwidth, bool horizontal, HPixelRGB colorstripes, HPixelRGB colorbackground); 01945 01953 static void ascii_to_unicode(char const *ascii, unsigned short *unicode); 01954 01962 static void unicode_to_ascii(unsigned short const *unicode, char *ascii); 01963 01972 static void BatchRead(HBaseModel * model, const char * directory, const char * extension); 01973 01981 static void AdjustPositionToPlane(HBaseView *, HPoint &position, HPoint point_in_plane); 01982 01991 static void CalculateCornerImagePosition(HBaseView *view, int iwidth, int iheight, HWindowCorner corner, float &posx, float &posy); 01992 static void OptimizeModelByGrid(HBaseView *view, ShellToRegionMapper *mapper); 01993 static void DecipherTextureString(char *texdef, char *Source, bool *DownSampling = 0, bool *DownSamplingSet = 0, char *ParameterizationSource = 0, 01994 char *InterpolationFilter = 0, char *DecimationFilter = 0, char *Layout = 0, char *Tiling = 0, bool *ValueScaleSet = 0, 01995 bool *ValueScale = 0, float *ValueScaleMin =0, float *ValueScaleMax = 0, char *BlendingMode = 0); 01996 01997 01998 private: 01999 static void scale_segment (HIC_Rendition *rendition,HIC_Segment_Info * geo3); 02000 static void activity_change (HIC_Segment *seg, int old_activity, int new_activity); 02001 static bool RestoreAttributeFromOption(const char *attName, HUserOptions& attText); 02002 static void ReplaceCharacter(char *text, char orig, char target); 02003 static bool SetAttribute(const char *attName, const char *attText); 02004 static bool ShowAttribute(const char *attName, char *attText); 02005 static void ShowContentsWithPathAddEntity(HC_KEY key, struct vlist_s *pathlist, int level, HC_KEY *patharray, bool storePath); 02006 static void ShowContentsWithPathRecursive(HC_KEY key, const char *entitytypes, struct vlist_s *pathlist, HC_KEY *patharray, int level, bool storePath, bool includeIncludes, bool filterIncludes); 02007 static void SubdivideOneShell(HShellWrapper &myshell, int numx, int numy, int numz, HPoint &totalmin, 02008 HPoint &totaldeltadiv, HShellWrapper *shellmatrix, HShellWrapper &leftover, float boxdiagonallength, bool DoCut, int regionnum, ShellToRegionMapper *mapper, HC_KEY newkey); 02009 02010 02011 }; 02012 02013 02014 class MVO_API HQualifiedKey 02015 { 02016 public: 02017 HQualifiedKey(HC_KEY key, HC_KEY * includelist, int includelistlength) 02018 { 02019 m_Key = key; 02020 m_pIncludeList = 0; 02021 m_pIncludeList = new HC_KEY[includelistlength]; 02022 for (int i = 0; i < includelistlength; i++) 02023 m_pIncludeList[i] = includelist[i]; 02024 m_IncludeListLength = includelistlength; 02025 } 02026 ~HQualifiedKey() 02027 { 02028 delete [] m_pIncludeList; 02029 } 02030 02031 long MakeHashKey() 02032 { 02033 return MakeHashKey(m_Key, m_IncludeListLength,m_pIncludeList); 02034 } 02035 02036 static long MakeHashKey(HC_KEY key, int includelength, HC_KEY * includes) 02037 { 02038 long hashkey = static_cast<long>(key); 02039 for (int i = 0; i < includelength; i++) 02040 { 02041 hashkey += static_cast<long>(includes[i]); 02042 } 02043 return hashkey; 02044 } 02045 02046 HC_KEY m_Key; 02047 HC_KEY * m_pIncludeList; 02048 int m_IncludeListLength; 02049 }; 02050 02051 02052 02053 02054 class MVO_API HMergeShellFace 02055 { 02056 02057 public: 02058 HMergeShellFace() 02059 { 02060 m_pChildFaces = 0; 02061 m_ChildFaceNum = 0; 02062 } 02063 ~HMergeShellFace() 02064 { 02065 if (m_pChildFaces) 02066 delete [] m_pChildFaces; 02067 if (m_pFlist) 02068 delete [] m_pFlist; 02069 02070 } 02071 void Init(int * flist); 02072 void MakeChildFaces(int & addpoint, HPoint * points, bool AddExtraPoints, int * newpoints, int * newpointslen); 02073 void Divide(int pnum, HPoint * points); 02074 02075 bool CheckHit(HPoint & p, HPoint & normal, HPoint * plist, HPoint & pres); 02076 HMergeShellFace * FindHitFaceRecursive(HPoint & p, HPoint & normal, HPoint * plist, HPoint & respoint); 02077 HMergeShellFace * FindHitFace(HPoint & p, HPoint & normal, HPoint * plist, HPoint & respoint) 02078 { 02079 return FindHitFaceRecursive(p, normal, plist,respoint); 02080 } 02081 bool CheckIfColinear(HPoint * point); 02082 02083 int GetLengthRecursive(int l); 02084 02085 int GetLength() 02086 { 02087 return GetLengthRecursive(0); 02088 02089 } 02090 02091 int AddToFacelistRecursive(int * start, int l); 02092 02093 int AddToFacelist(int * start) 02094 { 02095 return AddToFacelistRecursive(start, 0); 02096 02097 } 02098 02099 protected: 02100 HMergeShellFace * m_pChildFaces; 02101 int m_flen; 02102 int * m_pFlist; 02103 int m_ChildFaceNum; 02104 }; 02105 02106 02107 02108 class MVO_API ColorPiece{ 02109 02110 public: 02111 ColorPiece(int *index, int len, int col) 02112 { 02113 m_uvindex = new int[len]; 02114 m_fllen = new int[len]; 02115 m_flindex = new int[len]; 02116 for (int i=0;i<len;i++) 02117 m_uvindex[i] = index[i]; 02118 m_len = len; 02119 m_col = col; 02120 m_done = false; 02121 02122 } 02123 ~ColorPiece() 02124 { 02125 delete [] m_uvindex; 02126 delete [] m_fllen; 02127 delete [] m_flindex; 02128 } 02129 int *m_uvindex; 02130 int *m_fllen; 02131 int *m_flindex; 02132 int m_len; 02133 int m_col; 02134 02135 bool m_done; 02136 02137 }; 02138 02139 class MVO_API ColorPieceList 02140 { 02141 public: 02142 ColorPieceList(); 02143 ~ColorPieceList(); 02144 void AddColorPiece(int *index, int len, int col); 02145 ColorPiece * FindMatch(int col, int ii, int ii2, int &rpos, int &rlen, bool &reverse); 02146 02147 struct vlist_s* m_ColorPieceList; 02148 02149 02150 }; 02151 02152 class MVO_API HVerticalUtility : 02153 public HUtility 02154 { 02155 public: 02156 02157 static void ColorizePointCloud(HC_KEY const segment); 02158 }; 02159 02160 02161 02162 class MVO_API HAbsoluteWindow 02163 { 02164 public: 02165 HAbsoluteWindow(HBaseView *view, HC_KEY key,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft, 02166 AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft, 02167 AbsoluteWindowType height_type = RelativeTop, bool sb = false); 02168 HAbsoluteWindow(HBaseView *view, HC_KEY key); 02169 void DecipherOptions(); 02170 void AdjustX(float invalue, AbsoluteWindowType wt, float &outvalue); 02171 void AdjustY(float invalue, AbsoluteWindowType wt, float &outvalue); 02172 bool Adjust(); 02173 static void AdjustAll(HBaseView *view); 02174 static bool SetWindow(HBaseView *view,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft, 02175 AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft, 02176 AbsoluteWindowType height_type = RelativeTop, bool sb = false); 02177 bool IsPositionInWindow(float x, float y); 02178 static bool IsPositionInWindow(HBaseView *view, float x, float y); 02179 static void CalculateLocalWindowPos(HBaseView *view, float x, float y, float &xout, float &yout); 02180 void CalculateLocalWindowPos(float x, float y, float &xout, float &yout); 02181 static void CalculateOuterWindowPos(HBaseView *view, float x, float y, float &xout, float &yout); 02182 void CalculateOuterWindowPos(float x, float y, float &xout, float &yout); 02183 02184 02185 02186 HBaseView *m_pView; 02187 float m_width; 02188 float m_height; 02189 float m_xpos; 02190 float m_ypos; 02191 AbsoluteWindowType m_xpos_type; 02192 AbsoluteWindowType m_ypos_type; 02193 AbsoluteWindowType m_width_type; 02194 AbsoluteWindowType m_height_type; 02195 02196 bool m_bShowBackground; 02197 02198 HC_KEY m_key; 02199 02200 }; 02201 02202 02203 02205 02220 class MVO_API HUnicodeOptions 02221 { 02222 public: 02223 02224 wchar_t* m_data; 02225 int m_length; 02226 bool m_valid; 02227 02229 HUnicodeOptions(); 02230 02232 HUnicodeOptions(const HUnicodeOptions& in_data); 02233 02234 02236 ~HUnicodeOptions(); 02237 02238 02242 bool IsValid(); 02243 02248 const __wchar_t * Show_Unicode_Options(); 02249 02254 const wchar_t* Show_One_Net_Unicode_Option(const __wchar_t* which); 02255 #ifdef _MSC_VER 02256 const unsigned short * Show_One_Net_Unicode_Option(const unsigned short * which); 02257 #endif 02258 02263 const wchar_t * Show_One_Unicode_Option(const __wchar_t * which); 02264 #ifdef _MSC_VER 02265 const unsigned short * Show_One_Unicode_Option(const unsigned short * which); 02266 #endif 02267 02271 const __wchar_t* Show_Net_Unicode_Options(); 02272 02273 private: 02274 02275 void clear() { 02276 delete [] m_data; 02277 m_data = 0; 02278 m_length = 0; 02279 m_valid = false; 02280 } 02281 02282 }; 02283 02284 02285 02286 class BREP_Topology; 02287 02288 class BREP_Edge 02289 { 02290 public: 02291 BREP_Edge(HC_KEY edgekey) 02292 { 02293 m_edgekey = edgekey; 02294 m_vertex1 = INVALID_KEY; 02295 m_vertex2 = INVALID_KEY; 02296 } 02297 02298 HC_KEY m_edgekey; 02299 HC_KEY m_vertex1; 02300 HC_KEY m_vertex2; 02301 02302 }; 02303 02304 class BREP_CoEdge 02305 { 02306 public: 02307 BREP_CoEdge(BREP_Edge *edge) 02308 { 02309 m_edge = edge; 02310 } 02311 02312 BREP_Edge * m_edge; 02313 }; 02314 02315 02316 class MVO_API BREP_Face 02317 { 02318 public: 02319 BREP_Face(HC_KEY facekey); 02320 ~BREP_Face(); 02321 02322 BREP_Edge * AddCoEdge(BREP_Topology *topol, void *edgeid, HC_KEY edgekey); 02323 02324 02325 struct vlist_s * m_CoEdgeList; 02326 HC_KEY m_facekey; 02327 }; 02328 02329 class MVO_API BREP_Topology 02330 { 02331 public: 02332 02333 struct vhash_s * m_FaceHash; 02334 02335 struct vhash_s * m_EdgeHash; 02336 struct vhash_s * m_VertexHash; 02337 02338 BREP_Face *m_CurrentFace; 02339 BREP_Topology(); 02340 ~BREP_Topology(); 02341 BREP_Face *AddFace(HC_KEY facekey); 02342 BREP_Face *GetFace(HC_KEY facekey); 02343 BREP_Edge *FindEdge(void *edgeid); 02344 BREP_Edge *AddEdge(void *edgeid, HC_KEY edgekey); 02345 HC_KEY AddVertex(void *vertexid, HPoint vpos); 02346 HC_KEY FindVertex(void *vertexid); 02347 02348 02349 02350 BREP_Face *GetCurrentFace() { return m_CurrentFace; } 02351 02352 }; 02353 02354 class H_FORMAT_TEXT; 02355 02356 class MVO_API HBestImageDriver 02357 { 02358 private: 02359 H_FORMAT_TEXT * m_dvr; 02360 public: 02361 HBestImageDriver(char const * prefer_type = 0); 02362 ~HBestImageDriver(); 02363 02364 HC_KEY GetKey() const; 02365 02366 operator char const* () const; 02367 }; 02368 02369 02370 class MVO_API HPVOOptions 02371 { 02372 private: 02373 void * impl; 02374 02375 public: 02376 HPVOOptions(char const * filename); 02377 ~HPVOOptions(); 02378 char const * getOption(char const * option) const; 02379 }; 02380 02381 02382 #ifdef H_PACK_8 02383 #pragma pack(pop) 02384 #endif 02385 02386 #endif