Introduction

Getting Started

Programming Guides

API Reference

Additional Resources

HUtility.h
1 // Copyright (c) Tech Soft 3D
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
10 // HUtility.h : interface of the HUtility class
11 // Set of utility methods
12 // All methods are public and static
13 
14 
15 #ifndef _HUTILITY_H
16 #define _HUTILITY_H
17 
18 #ifdef H_PACK_8
19 #pragma pack(push)
20 #pragma pack(8)
21 #endif
22 
23 
24 #include "HTools.h"
25 #include "hic_types.h"
26 
27 class HBaseView;
29 class HSmartSelItem;
30 class HBaseModel;
31 
32 class HShellObject;
33 
34 
35 enum AbsoluteWindowType
36 {
37  RelativeLeft,
38  RelativeRight,
39  RelativeTop,
40  RelativeBottom,
41  NotRelative
42 };
43 
45 {
46 public:
48  {
49  nindex = -1;
50  tcindex = -1;
51  nextindex = -1;
52  }
53  int nindex;
54  int nextindex;
55  int tcindex;
56 };
57 
58 
59 class MVO_API ShellToRegionMapper
60 {
61 public:
63  void AddRegion(HC_KEY originalshell, HC_KEY newshell, int regionnum, bool check = true);
64  HC_KEY GetOriginalShell(HC_KEY newshell, int regionnum);
65  int GetRegionsFromOriginalShell(HC_KEY originalshell, HC_KEY **newshells, int &regionnum);
66  void BuildSegmentTreeRecursive(HC_KEY okey, HC_KEY nkey);
67  void MapSegmentTree(HC_KEY modelkey);
68  void AddSegmentMapping(HC_KEY originalshell, HC_KEY segmentkey);
69 
70  struct vhash_s * m_RegionToShellHash;
71  struct vhash_s * m_ShellToRegionHash;
72  struct vhash_s * m_ShellToSegmentHash;
73 
74 };
75 
76 
77 
78 
79 
81 
84 class MVO_API HShellEdge {
85 public:
90  HShellEdge(int iFirst = 0, int iSecond = 0){
91  Set(iFirst, iSecond);
92  };
94  int GetFirst() const { return m_iFirst; };
96  int GetSecond() const { return m_iSecond; };
101  void Set(int first, int second) {
102  /* first should always be < second to eliminate ambiguity. */
103  if(first < second){
104  m_iFirst = first;
105  m_iSecond = second;
106  } else {
107  m_iFirst = second;
108  m_iSecond = first;
109  }
110  };
111 
112  bool operator<(HShellEdge const & rhs) const {
113  if(m_iFirst != rhs.m_iFirst)
114  return m_iFirst < rhs.m_iFirst;
115  return m_iSecond < rhs.m_iSecond;
116  }
117 
118 private:
119  int m_iFirst;
120  int m_iSecond;
121 };
122 
124 
127 class MVO_API HShellFace{
128 public:
133  HShellFace(HShellObject const * pShell, int const iFaceIndex);
134 
136  int GetPointCount() const ;
137 
139  int GetEdgeCount() const ;
144  HShellEdge const GetEdge(int const iEdgeIndex) const;
148  void OpenEdge(int const iEdgeIndex) const;
152  void CloseEdge() const;
153 
154 private:
155  HShellObject const * m_pShell;
156  int m_iFaceIndex;
157  int m_iPointCount;
158 };
159 
161 
164 class MVO_API HShellRegion{
165 public:
170  HShellRegion(HShellObject const * pShell, int const iRegionIndex);
171  ~HShellRegion(){
172  delete [] m_pRegionFlist;
173  }
176  int GetFaceCount() const;
181  HShellFace const GetFace(int index) const;
182 
183  //void Open() const;
184  //void Close() const;
185 private:
186  HShellObject const * m_pShell;
187  int m_iRegionIndex;
188 
189  int m_iRegionFlistLength;
190  int *m_pRegionFlist;
191 };
192 
193 
195 
198 class MVO_API HShellObject {
199 public:
203  HShellObject(HC_KEY kShellKey);
204  HShellObject(HShellObject const & oShellObj);
205  ~HShellObject();
206 
211  HShellRegion const GetRegion(int const index) const;
212 
214  int GetFaceCount() const;
219  int GetFaceFlistIndex(int index) const;
220 
221  //void Open() const;
222  //void Close() const;
223 
225  HC_KEY GetKey() const ;
227  int GetFlistLen() const ;
229  int const * GetFlist() const ;
232  void GetFlist (int flist[]) const;
233 
234 private:
235  int m_iFlistLen;
236  int * m_pFlist;
237  mutable int * m_pFaceIndexes;
238 
239  HC_KEY m_kShellKey;
240 };
241 
242 
244 
247 class MVO_API HShell {
248 public:
249  HShell()
250  :point_list_len(0),
251  point_list(),
252  normal_list(),
253  face_list_len(0),
254  face_list(0),
255  face_count(0),
256  region_count(0),
257  region_list(0)
258  {}
259  ~HShell()
260  {
261  /* No need to check for null pointers. delete already does that. */
262  delete [] point_list;
263  delete [] normal_list;
264  delete [] face_list;
265  delete [] region_list;
266  }
270 
272  int *face_list;
274 
276  int *region_list;
277 };
278 
280 
284 class MVO_API HShellWrapper {
285 
286 public:
291  HShellWrapper(HC_KEY key) {
292  m_Points = 0;
293  m_Flist = 0;
294  m_VParams = 0;
295  m_VNormals = 0;
296  m_VColors = 0;
297  m_faceregion = 0;
298  m_totalnumfaceslen = 0;
299  m_numfaceslen = 0;
300  m_FNArray = 0;
301  m_faceindirect = 0;
302  Set(key);
303  }
308  m_Key = INVALID_KEY;
309  m_Points = 0;
310  m_Flist = 0;
311  m_VParams = 0;
312  m_VNormals = 0;
313  m_VColors = 0;
314  m_flen = 0;
315  m_plen = 0;
316  m_totalplen = 0;
317  m_totalflen = 0;
318  m_faceregion = 0;
319  m_totalnumfaceslen = 0;
320  m_numfaceslen = 0;
321  m_FNArray = 0;
322  m_faceindirect = 0;
323  }
324  ~HShellWrapper();
325 
336  HC_KEY Insert(int plen, HPoint points[], int flen, int flist[], HC_KEY insertkey = INVALID_KEY);
344  HC_KEY Show(int *plen, HPoint **points, int *flen, int **flist);
348  HC_KEY GetKey() { return m_Key; }
352  void TransformPoints(float matrix[]);
353 
358  HC_KEY Optimize(char *options);
364  HC_KEY Optimize2(char *options);
365 
366  void MakePolygon(int facelen, int face[], HPoint points[]);
367 
368 
371  void OpenOwnerSegment();
372 
375  void BeginFaceIteration();
376 
379  void EndFaceIteration() { ; };
380  int GetFace(int facenum, int **face);
385  int NextFace(int **face);
386 
392  void CalculateFaceCenter(int face[], int flen, HPoint *mid);
399  void AddPoints(HPoint points[], int pnum, HPoint param[] = 0, HPoint normals[] = 0, bool AddImmediately= false);
406  void AddFace(int face[], int fnum, int regionnum, HPoint points[], HPoint normals[] = 0, bool AddImediately= false);
413  void AddFaceDirect(int face[], int fnum, bool reverse = false, bool AddImmediatly= false);
420  void AddFace(HPoint points[], int fnum, bool AddImmediatly= false);
425  void Set(HC_KEY key);
432  void Regenerate(HC_KEY newowner = INVALID_KEY, bool makeSegment = true, bool regenerate = false);
437  void GrowArrays(int fnum);
443  void GrowPointArray(int fnum, bool gorwvparams = false, bool grownormals = false);
444 
445  void GrowPointArray2(int fnum, bool growparamarray = false, bool grownormalarray = false, bool growfnarray = false, bool growcolorarray = false);
446  void AddNextFaceWithDistinctNormals(HPoint const * points, HPoint const * normals, int const * face1, int const * face2, int fnum);
447  void AddNextFaceWithDistinctNormalsAndTexture(HPoint const * points, HPoint const * normals, HPoint const * texcor,int const * face1, int const *face2, int const *face3, int fnum);
448  void AddNextFaceWithDistinctNormalsAndColor(HPoint const *points, HPoint const *normals,int const *face1, int const *face2, HPoint *face3, int fnum);
449 
450 
451  void BeginAddFaces(int pnum);
452  void EndAddFaces();
453 
458  void GrowFaceArray(int fnum);
459 
461  void SubdivideOneQuadFace(int face[], HShellWrapper &wrapper, bool generateIsolines, int *facecolorlist, int &fclnum);
462 
464  void SubdivideOneQuadFace2(int face[]);
469  void SubdivideQuadFaces(bool GenerateIsolines);
470 
474  void SetVertexColors(HPoint *color);
478  void ShowVertexColors(HPoint *color);
483  void SetVertexColors(float *findex);
487  void ShowVertexColors(float *color);
493  void MakeLod(int lodnum, int percent);
499  void FindExtents(HPoint &center, HPoint &min, HPoint &max);
500  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);
501  void ReplaceWithParameters(int plen, HPoint points[], int flen, int flist[], HPoint normals[], float params[], int paranum, bool emptyshell);
502  void Replace(int plen, HPoint points[], int flen, int flist[], HPoint normals[] = 0, bool emptyshell = false);
503 
504  void SetFaceRegion(int regionnum);
505 
506  void SetEmptyShell(HC_KEY segmentkey, bool MakeSegment);
507 
508 
509  int m_plen;
510  int m_flen;
511  HPoint *m_Points;//<! The list of pointst that define the shell.
512  HPoint *m_VParams;
513  HPoint *m_VColors;
514  HPoint *m_VNormals;
515  int *m_Flist;
517 
524  int m_totalnumfaceslen;
525  int m_numfaceslen;
526  int *m_faceregion;
527  int *m_faceindirect;
528  FaceWithNormalInfo *m_FNArray;
529 
530 };
531 
532 
534 
537 class MVO_API HCamera {
538 public:
539  bool valid;
543  float field_width;
544  float field_height;
545  char projection[128];
546 
547  HCamera () {
548  projection[0] = '\0';
549  valid = false;
550  }
551 
553  inline void InvalidateCamera() { projection[0]='\0'; valid = false; }
554 
558  bool CameraDifferent(HCamera &cam);
559 
563  bool CameraDifferentByAngle(HCamera &cam);
564 
565 
568  void GetFromView(HBaseView * view);
569 
571  void Show();
572 
574  void Set() const;
575 };
576 
577 
579 
582 class MVO_API HBSurfVertex
583 {
584 public:
585  double x;
586  double y;
587  double z;
588  double w;
589 
592  inline void Set(double X, double Y, double Z, double W) { x=X, y=Y, z=Z, w=W; }
593 };
594 
596 
600 class MVO_API HPolyline
601 {
602 public:
606 };
607 
609 
613 class MVO_API HShellVertexData
614 {
615 public:
616  /* Constructor initializes this object to an invalid state. */
617  HShellVertexData():m_VertexCount(0), m_pFIndexArraySize(0), m_pFIndexArray(0), m_Key(INVALID_KEY){
618  m_sType[0] = '\0';
619  }
620 
621  /* Destructor free up the resources this object is using. */
622  ~HShellVertexData(){
623  ResetMyself();
624  }
625 
626  /* Sets the key and fills in the members with the correct data for this shell. */
627  void SetKey(HC_KEY const key);
628 
629  /* Return a const string for the type of shell. */
630  char const * const GetType() const {
631  return m_sType;
632  }
633 
634  /* Returns the vertex count for this shell. */
635  int const GetVertexCount() const {
636  return m_VertexCount;
637  }
638 
639  /* Return the key for the shell */
640  HC_KEY const GetKey() const {
641  return m_Key;
642  }
643 
644  /* Return the size the findex array */
645  int const GetFIndexDataSize() const {
646  return m_pFIndexArraySize;
647  }
648 
649  /* Returns a const array for the findex values in this shell. */
650  float const * const GetFIndexData() const {
651  return m_pFIndexArray;
652  }
653 
654  /* Returns a const array (as an argument) for the findex values in this shell.
655  Note that the array must be of the appropriate size, e.g., via a call to GetFIndexDataSize. */
656  void GetFIndexData(float data[]) const;
657 
658  void SetFIndexData(int const size, float const data[]);
659 
660 private:
661  void ResetMyself();
662 
663  int m_VertexCount;
664  int m_pFIndexArraySize;
665  float *m_pFIndexArray;
666  HC_KEY m_Key;
667  char m_sType[32];
668 };
669 
670 
672 
674 typedef struct
675 {
677  int len;
679 
680 
681 enum HWindowCorner
682 {
683  TopLeft,
684  BottomLeft,
685  BottomRight,
686  TopRight
687 };
688 
689 
690 
691 
692 
693 
694 
696 
714 class MVO_API HUserOptions
715 {
716 public:
717 
718  char * m_data;
719  int m_length;
720  bool m_valid;
721 
723  HUserOptions();
724 
726  HUserOptions(const HUserOptions& in_data);
727 
728 
730  ~HUserOptions();
731 
732 
736  bool IsValid();
737 
743  const char * Show_User_Options();
744 
750  const char * Show_One_Net_User_Option(const char * which);
751 
757  const char * Show_One_User_Option(const char * which);
758 
764  const char * Show_Net_User_Options();
765 
766 
767 private:
768 
769  void clear() {
770  delete [] m_data;
771  m_data = 0;
772  m_length = 0;
773  };
774 
775 };
776 
777 
778 
780 
783 class MVO_API HUtility
784 {
785 public:
786 #undef PI
787  static const float PI;
788 
789  enum{X, Y, Z, W};
790  enum{XY, XZ, YZ};
791 
792  static const float EH_Epsilon;
793 
794 
801  static void Order(HPoint* one, HPoint* two);
802 
809  static void Find_Relative_Path(HC_KEY from_seg_key, HC_KEY to_seg_key, char * path);
810 
814  static float GetTime();
815 
816 
821  static void ClampPointToWindow (HPoint * point);
822 
829  static HC_KEY InsertBox (HPoint const * max, HPoint const * min);
830 
838  static HC_KEY InsertWireframeBox (HPoint * max, HPoint * min);
839 
846  static void GenerateCuboidPoints (HPoint const * max, HPoint const * min, HPoint * points);
847 
859  static HC_KEY InsertRectangle (const char * seg, float x0, float y0, float x1, float y1, float z = 0.0f, bool fill = false);
860 
861 
876  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);
877 
884  static void ComputeDoublePrecisionCrossProduct(double * vector1, double * vector2, double * up);
885 
892  static double ComputeDoublePrecisionDotProduct(double * vector1, double * vector2);
893 
899  static double ComputeDoublePrecisionVectorLength(double * vector1);
900 
907  static void GetViewplaneVectors(HC_KEY segment_key, double * view, double * up);
908 
913  static void NormalizeDoublePrecisionVector(double* vector1);
914 
922  static bool PointsEqual(HPoint * point1, HPoint * point2);
923 
935  static bool CreateAxisCircle (HPoint const & center, float radius, int axis, bool convert = true);
936 
937 
944  static void RotateToVector(HPoint start, HPoint end, bool doTranslation = true);
945 
961  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);
962 
970  static void SmoothTransition(HCamera old_camera, const HCamera &new_camera, HBaseView *view);
971 
978  static bool CamerasEqual(const HCamera &camera1, const HCamera &camera2);
979 
987  static void ComputeVectorToVectorRotationMatrix(float matrix[],HPoint v1,HPoint v2);
988 
997  static bool ExtractRGB(char *text,float &r, float &g, float &b);
998 
1009  static void TransitionQuaternion(float quat_old[], float quat_new[], float t, float qt[]);
1010 
1016  static void MatrixToQuaternion(float matrix[], float quaternion[]);
1017 
1023  static void QuaternionToMatrix(float quaternion[], float matrix[]);
1024 
1033  static void SmoothQuaternionTransition(HBaseView *m_pView, char *old_seg, char *new_seg, int num_of_transitions);
1034 
1042  static void SmoothMatrixTransition(HBaseView *m_pView, HC_KEY seg_key, float new_matrix[]);
1043 
1053  static void MultiSmoothTransitions(HBaseView *m_pView, int num_keys, HC_KEY *seg_key, float new_matrix[], HCamera *new_camera = 0);
1054 
1060  static HPoint GetCentroid(HC_KEY seg_key);
1061 
1068  static HPoint GetTransformedCentroid(HC_KEY seg_key, float matrix[] = 0);
1069 
1077  static void URIencode(const char * in_string, MVO_POINTER_SIZED_UINT n, char * out_buffer);
1085  static void URIdecode(const char * in_string, char * out_buffer, MVO_POINTER_SIZED_UINT * n);
1086 
1095  static void GetCameraFromMatrix(float matrix[], HPoint *target, HPoint *position, HPoint *up_vector, HPoint *translation);
1096 
1105  static void GetMatrixFromCamera(HPoint target, HPoint position, HPoint up_vector, HPoint translation, float matrix[]);
1106 
1107 
1141  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,
1142  HPoint &pos, HPoint &target, HPoint &up, char * projection, double &width, double &height, double &near_limit );
1143 
1151  static bool PushAttribute(const char *attName);
1152 
1161  static void PushAttribute(const char *attName, const char *attText);
1162 
1170  static bool PopAttribute(const char *attName);
1171 
1182  static bool ModifyPushedAttribute(const char *attName, const char *newStyle);
1183 
1190  static bool ShowPushedAttribute(const char *attName, HUserOptions& attText);
1191 
1204  static void Recursive_Merge_Shells( HShell *total_info, HShell *max_info, bool do_recurse, bool delete_orig_shells = false, bool insert_null_lods = false );
1205 
1212  static HC_KEY Merge_Shells( bool do_recurse, bool delete_orig_shells = false , bool optimize_shell = true, bool generate_regions = false);
1213 
1221  static HC_KEY Merge_Shells_Generate_Regions( int num_shells, HC_KEY * shell_keys, bool delete_orig_shells = false );
1222 
1232  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 );
1233 
1241  static bool Segment_Shell_Allocate( HShell *total_info, HShell *max_info, bool do_recurse );
1242 
1250  static void Shell_Search( HShell *total_info, HShell *max_info, bool do_recurse );
1251 
1252 
1253 
1264  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);
1265 
1266 
1275  static void CountShellData(HC_KEY shell_key, int * faces, int * vertices, int * triangles, int * tristrips = 0);
1276 
1283  static void FindFileNameExtension(const char * filename_in, char * ext_out, int size = -1);
1284 
1291  static void FindFileNameExtension(__wchar_t const * const filename_in, __wchar_t * ext_out, int size = -1);
1292 #ifdef H_USHORT_OVERLOAD
1293  static void FindFileNameExtension(unsigned short const * const filename_in, unsigned short * ext_out, int size = -1){
1294  FindFileNameExtension((wchar_t const * const)filename_in, (wchar_t*)ext_out, size);
1295  }
1296 #endif
1297 
1302  static void FindUnicodeFileNameExtension(const unsigned short * filename_in, char * ext_out);
1303 
1311  static void FindFileNameAndDirectory(const char * filename_in, char * dir_out, char * filename_out);
1319  static void FindFileNameAndDirectory(__wchar_t const * filename_in, __wchar_t * dir_out, __wchar_t * filename_out);
1320 
1331  static const char* extra_pointer_format();
1335  static HC_KEY CreateScaleIndependentSegment(const char *segname, bool SetCallback = true);
1336 
1340  static HC_KEY GetScaleIndependentGeomSegmentKey(HC_KEY segkey);
1341 
1345  static void SetScaleIndependentGeomPosition(HC_KEY segkey, float x, float y, float z);
1346 
1350  static void GetScaleIndependentGeomPosition(HC_KEY segkey, float &x, float &y, float &z);
1351 
1355  static void RegisterCallbacks();
1356 
1363  static bool IsModelKey(HC_KEY modelkey, HC_KEY objectkey);
1364 
1372  static HC_KEY UserOptionExists(HC_KEY key, const char *attrib, char *result);
1373 
1390  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);
1391 
1401  static int CalculateKeyPath(HC_KEY startkey, HBaseView *view, HC_KEY *keyarray, int maxarray);
1402 
1407  static bool SegmentExists(const char *segment);
1408 
1411  static void UnsetAttributes();
1412 
1420  static int IsChildOf(HC_KEY owner, HC_KEY child, HC_KEY klist[] = 0);
1421 
1427  static bool IsIdentityMatrix(float matrix[]);
1428 
1435  static void ComputeShellNormal(HC_KEY skey, HPoint &tnormal);
1436 
1446  static HC_KEY SelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false);
1447 
1448 
1459  static HC_KEY SmartSelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false);
1460 
1461 
1468  static bool ShowOneHeuristic(const char *type, char *res = 0);
1475  static bool ShowOneRenderingOption(const char *type, char *res = 0);
1476 
1486  static float EaseInEaseOut(float t, float a, float b, float c);
1487 
1492  static void UnwindIncludes(HC_KEY &key);
1493 
1500  static void UnwindIncludes(HC_KEY &newkey, HC_KEY *keys, int count);
1501 
1502 
1509  static bool SafeSetUserOption(const char * opt);
1510 
1517  static bool SafeShowUserOption(char * opt);
1518 
1519 
1524  static void ProjectShell(HC_KEY shellkey);
1525 
1532  static HC_KEY MergeShells(HC_KEY shell1, HC_KEY shell2);
1533 
1539  static void ShowModellingMatrix(float *segment_modelling_matrix);
1540 
1547  static void ConvertLocalPixelsToLocalWindow(HBaseView * view, HPoint *in_system , HPoint *out_system = 0);
1548 
1549 
1556  static HC_KEY GrabSegment(HC_KEY key);
1557 
1562 # define MakeSegment(key) GrabSegment(key)
1563 
1569  static void RenameSegment(HC_KEY segkey, const char *newname);
1570 
1571 
1582  static void InterpolateNormalAlongEdge(HPoint &p1, HPoint &n1, HPoint &p2, HPoint &n2, HPoint &p3, HPoint &n3);
1583 
1589  static void ShowNormals(HC_KEY shellkey, float normallength);
1590 
1596  static bool IsSegmentKey(HC_KEY key);
1597 
1604  static int FindContents(HC_KEY &key);
1605 
1612  static int CalculateMajorAxis(HBaseView *view);
1613 
1614 
1622  static HC_KEY FindOneObject(const char *type, bool l = 0);
1628  static void CloseAllSegments(HC_KEY endkey = INVALID_KEY);
1629 
1634  static void ReadjustTarget(HBaseView *view);
1635 
1640  static bool GetAllowAnimation(HC_KEY key);
1641 
1644  static void SuppressAnimation();
1645 
1653  static int FindFaceByIndex(int findex, int *flist, int flen);
1654 
1661  static bool ShowOneUserOption(const char *option, char *res);
1662 
1668  static HC_KEY GetNextRenumberedKey(HBaseView *view);
1669 
1675  static void NameSegments(HC_KEY &key, HBaseView *view);
1676 
1682  static void MoveToTemp(HC_KEY movekey, HC_KEY tempkey);
1683 
1694  static void ShowContentsWithPath( const char * entitytypes, struct vlist_s **ret_pathlist, bool storePath = false, bool includeIncludes = true, bool filterIncludes = true);
1695 
1696 
1702  static int ustrlen(unsigned short *text);
1703 
1713  static bool RLECompress(int const in_len,
1714  unsigned char const * const in_buf,
1715  int * out_len,
1716  unsigned char * const out_buf);
1717 
1727  static bool ZlibCompress(int const in_len,
1728  unsigned char const * const in_buf,
1729  int & out_len,
1730  unsigned char * const out_buf);
1731 
1741  static bool ZlibDecompress(int const in_len,
1742  unsigned char const * const in_buf,
1743  int & out_len,
1744  unsigned char * const out_buf);
1750  static unsigned short *uconvert(const char *text);
1751 
1762  static bool BuildIncludePath(HC_KEY objectkey, const HC_KEY *includelist, int ilength, HC_KEY *fullpath, int *fplength, HC_KEY matchkey = INVALID_KEY);
1763 
1770  static void BuildIncludePathFromSelection(HSmartSelItem *sitem, int &plen, HC_KEY *fullpath);
1771 
1772 
1781  static void MakeViewSnapshot(HBaseView * view, int width, int height, char ** data);
1782 
1788  static void MakeViewSnapshot(HBaseView * view, HC_KEY image_key);
1789 
1798  static int ConstrainToVector( const float matrix_in[], const HVector &vector, float matrix_out[]);
1799 
1807  static void Camera_To_Transform (HCamera *camera , float *pos, float projection_matrix[], float complete_matrix[]);
1818  static void LocalPixelsToWorld(HCamera *camera, bool righthanded, float xres, float yres, int xwpix, int ywpix, float result[]);
1825  static float ComputeAngleBetweenVector(HPoint p1, HPoint p2);
1826 
1827 
1833  static int strlen16( const unsigned short *p16);
1834 
1843  static void CalculateBoundingInfo(HC_KEY startkey, HPoint &min, HPoint &max, HPoint &delta, HPoint &mid);
1844 
1854  static long ClipPolygonAgainstPlane(long vertexCount, const HPoint vertex[],
1855  const float plane[], HPoint result[], bool *noCut = 0);
1856 
1863  static HFileOutputResult TwoPassPrint(const char *driver, HOutputHandlerOptions *options);
1864 
1872  static HC_KEY OpenSegmentFromKey(HC_KEY key, char *segment);
1873 
1874 
1886  static bool IsPointInsideAllEdges( const float *pt,const float points1[],
1887  int len, const int face1[], const float plane1[], float fudge );
1895  static void IntersectionLinePlane(HPoint *p1, HPoint *p2, HPlane *p, HPoint *res);
1896 
1902  static void DeleteManipulators(HC_KEY key);
1903 
1904 
1919  static void MergePointsIntoShell(int num_shell_points, HPoint plist1[], int num_shell_facelist, int flist1[],
1920  int num_merge_points, HPoint merge_points[], HPoint merge_vectors[],
1921  float tolerance, bool AddExtraPoints, int newpoints[], int *newpointslen);
1922 
1923 
1938  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);
1939 
1941  static void MergePolylines();
1942  static void CreateZebraStripeTexture(int width, int height, int stripwidth, bool horizontal, HPixelRGB colorstripes, HPixelRGB colorbackground);
1943 
1951  static void ascii_to_unicode(char const *ascii, unsigned short *unicode);
1952 
1960  static void unicode_to_ascii(unsigned short const *unicode, char *ascii);
1961 
1970  static void BatchRead(HBaseModel * model, const char * directory, const char * extension);
1971 
1979  static void AdjustPositionToPlane(HBaseView * view, HPoint &position, HPoint point_in_plane);
1980 
1989  static void CalculateCornerImagePosition(HBaseView *view, int iwidth, int iheight, HWindowCorner corner, float &posx, float &posy);
1990  static void OptimizeModelByGrid(HBaseView *view, ShellToRegionMapper *mapper);
1991  static void DecipherTextureString(char *texdef, char *Source, bool *DownSampling = 0, bool *DownSamplingSet = 0, char *ParameterizationSource = 0,
1992  char *InterpolationFilter = 0, char *DecimationFilter = 0, char *Layout = 0, char *Tiling = 0, bool *ValueScaleSet = 0,
1993  bool *ValueScale = 0, float *ValueScaleMin =0, float *ValueScaleMax = 0, char *BlendingMode = 0);
1994 
1995 
1996 private:
1997  static void scale_segment (HIC_Rendition *rendition,HIC_Segment_Info * geo3);
1998  static void activity_change (HIC_Segment *seg, int old_activity, int new_activity);
1999  static bool RestoreAttributeFromOption(const char *attName, HUserOptions& attText);
2000  static void ReplaceCharacter(char *text, char orig, char target);
2001  static bool SetAttribute(const char *attName, const char *attText);
2002  static bool ShowAttribute(const char *attName, char *attText);
2003  static void ShowContentsWithPathAddEntity(HC_KEY key, struct vlist_s *pathlist, int level, HC_KEY *patharray, bool storePath);
2004  static void ShowContentsWithPathRecursive(HC_KEY key, const char *entitytypes, struct vlist_s *pathlist, HC_KEY *patharray, int level, bool storePath, bool includeIncludes, bool filterIncludes);
2005  static void SubdivideOneShell(HShellWrapper &myshell, int numx, int numy, int numz, HPoint &totalmin,
2006  HPoint &totaldeltadiv, HShellWrapper *shellmatrix, HShellWrapper &leftover, float boxdiagonallength, bool DoCut, int regionnum, ShellToRegionMapper *mapper, HC_KEY newkey);
2007 
2008 
2009 };
2010 
2011 
2012 class MVO_API HQualifiedKey
2013 {
2014 public:
2015  HQualifiedKey(HC_KEY key, HC_KEY includelist[], int includelistlength)
2016  {
2017  m_Key = key;
2018  m_pIncludeList = 0;
2019  m_pIncludeList = new HC_KEY[includelistlength];
2020  for (int i = 0; i < includelistlength; i++)
2021  m_pIncludeList[i] = includelist[i];
2022  m_IncludeListLength = includelistlength;
2023  }
2024  ~HQualifiedKey()
2025  {
2026  delete [] m_pIncludeList;
2027  }
2028 
2029  long MakeHashKey()
2030  {
2031  return MakeHashKey(m_Key, m_IncludeListLength,m_pIncludeList);
2032  }
2033 
2034  static long MakeHashKey(HC_KEY key, int includelength, HC_KEY includes[])
2035  {
2036  long hashkey = static_cast<long>(key);
2037  for (int i = 0; i < includelength; i++)
2038  {
2039  hashkey += static_cast<long>(includes[i]);
2040  }
2041  return hashkey;
2042  }
2043 
2044  HC_KEY m_Key;
2045  HC_KEY * m_pIncludeList;
2046  int m_IncludeListLength;
2047 };
2048 
2049 
2050 
2051 
2052 class MVO_API HMergeShellFace
2053 {
2054 
2055 public:
2056  HMergeShellFace()
2057  {
2058  m_pChildFaces = 0;
2059  m_ChildFaceNum = 0;
2060  }
2061  ~HMergeShellFace()
2062  {
2063  if (m_pChildFaces)
2064  delete [] m_pChildFaces;
2065  if (m_pFlist)
2066  delete [] m_pFlist;
2067 
2068  }
2069  void Init(int * flist);
2070  void MakeChildFaces(int & addpoint, HPoint * points, bool AddExtraPoints, int * newpoints, int * newpointslen);
2071  void Divide(int pnum, HPoint * points);
2072 
2073  bool CheckHit(HPoint & p, HPoint & normal, HPoint * plist, HPoint & pres);
2074  HMergeShellFace * FindHitFaceRecursive(HPoint & p, HPoint & normal, HPoint * plist, HPoint & respoint);
2075  HMergeShellFace * FindHitFace(HPoint & p, HPoint & normal, HPoint * plist, HPoint & respoint)
2076  {
2077  return FindHitFaceRecursive(p, normal, plist,respoint);
2078  }
2079  bool CheckIfColinear(HPoint * point);
2080 
2081  int GetLengthRecursive(int l);
2082 
2083  int GetLength()
2084  {
2085  return GetLengthRecursive(0);
2086 
2087  }
2088 
2089  int AddToFacelistRecursive(int * start, int l);
2090 
2091  int AddToFacelist(int * start)
2092  {
2093  return AddToFacelistRecursive(start, 0);
2094 
2095  }
2096 
2097 protected:
2098  HMergeShellFace * m_pChildFaces;
2099  int m_flen;
2100  int * m_pFlist;
2101  int m_ChildFaceNum;
2102 };
2103 
2104 
2105 
2106 class MVO_API ColorPiece{
2107 
2108 public:
2109  ColorPiece(int index[], int len, int col)
2110  {
2111  m_uvindex = new int[len];
2112  m_fllen = new int[len];
2113  m_flindex = new int[len];
2114  for (int i=0;i<len;i++)
2115  m_uvindex[i] = index[i];
2116  m_len = len;
2117  m_col = col;
2118  m_done = false;
2119 
2120  }
2121  ~ColorPiece()
2122  {
2123  delete [] m_uvindex;
2124  delete [] m_fllen;
2125  delete [] m_flindex;
2126  }
2127  int *m_uvindex;
2128  int *m_fllen;
2129  int *m_flindex;
2130  int m_len;
2131  int m_col;
2132 
2133  bool m_done;
2134 
2135 };
2136 
2137 class MVO_API ColorPieceList
2138 {
2139 public:
2140  ColorPieceList();
2141  ~ColorPieceList();
2142  void AddColorPiece(int index[], int len, int col);
2143  ColorPiece * FindMatch(int col, int ii, int ii2, int &rpos, int &rlen, bool &reverse);
2144 
2145  struct vlist_s* m_ColorPieceList;
2146 
2147 
2148 };
2149 
2150 class MVO_API HVerticalUtility :
2151  public HUtility
2152 {
2153 public:
2154 
2155  static void ColorizePointCloud(HC_KEY const segment);
2156 };
2157 
2158 
2159 
2160 class MVO_API HAbsoluteWindow
2161 {
2162 public:
2163  HAbsoluteWindow(HBaseView *view, HC_KEY key,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft,
2164  AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft,
2165  AbsoluteWindowType height_type = RelativeTop, bool sb = false);
2166  HAbsoluteWindow(HBaseView *view, HC_KEY key);
2167  void DecipherOptions();
2168  void AdjustX(float invalue, AbsoluteWindowType wt, float &outvalue);
2169  void AdjustY(float invalue, AbsoluteWindowType wt, float &outvalue);
2170  bool Adjust();
2171  static void AdjustAll(HBaseView *view);
2172  static bool SetWindow(HBaseView *view,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft,
2173  AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft,
2174  AbsoluteWindowType height_type = RelativeTop, bool sb = false);
2175  bool IsPositionInWindow(float x, float y);
2176  static bool IsPositionInWindow(HBaseView *view, float x, float y);
2177  static void CalculateLocalWindowPos(HBaseView *view, float x, float y, float &xout, float &yout);
2178  void CalculateLocalWindowPos(float x, float y, float &xout, float &yout);
2179  static void CalculateOuterWindowPos(HBaseView *view, float x, float y, float &xout, float &yout);
2180  void CalculateOuterWindowPos(float x, float y, float &xout, float &yout);
2181 
2182 
2183 
2184  HBaseView *m_pView;
2185  float m_width;
2186  float m_height;
2187  float m_xpos;
2188  float m_ypos;
2189  AbsoluteWindowType m_xpos_type;
2190  AbsoluteWindowType m_ypos_type;
2191  AbsoluteWindowType m_width_type;
2192  AbsoluteWindowType m_height_type;
2193 
2194  bool m_bShowBackground;
2195 
2196  HC_KEY m_key;
2197 
2198 };
2199 
2200 
2201 
2203 
2218 class MVO_API HUnicodeOptions
2219 {
2220 public:
2221 
2222  wchar_t* m_data;
2223  int m_length;
2224  bool m_valid;
2225 
2227  HUnicodeOptions();
2228 
2230  HUnicodeOptions(const HUnicodeOptions& in_data);
2231 
2232 
2234  ~HUnicodeOptions();
2235 
2236 
2240  bool IsValid();
2241 
2246  const __wchar_t * Show_Unicode_Options();
2247 
2252  const wchar_t* Show_One_Net_Unicode_Option(const __wchar_t* which);
2253 #ifdef _MSC_VER
2254  const unsigned short * Show_One_Net_Unicode_Option(const unsigned short * which);
2255 #endif
2256 
2261  const wchar_t * Show_One_Unicode_Option(const __wchar_t * which);
2262 #ifdef _MSC_VER
2263  const unsigned short * Show_One_Unicode_Option(const unsigned short * which);
2264 #endif
2265 
2269  const __wchar_t* Show_Net_Unicode_Options();
2270 
2271 private:
2272 
2273  void clear() {
2274  delete [] m_data;
2275  m_data = 0;
2276  m_length = 0;
2277  m_valid = false;
2278  }
2279 
2280 };
2281 
2282 
2283 
2284 class BREP_Topology;
2285 
2287 {
2288 public:
2289  BREP_Edge(HC_KEY edgekey)
2290  {
2291  m_edgekey = edgekey;
2292  m_vertex1 = INVALID_KEY;
2293  m_vertex2 = INVALID_KEY;
2294  }
2295 
2296  HC_KEY m_edgekey;
2297  HC_KEY m_vertex1;
2298  HC_KEY m_vertex2;
2299 
2300 };
2301 
2303 {
2304 public:
2305  BREP_CoEdge(BREP_Edge *edge)
2306  {
2307  m_edge = edge;
2308  }
2309 
2310  BREP_Edge * m_edge;
2311 };
2312 
2313 
2314 class MVO_API BREP_Face
2315 {
2316 public:
2317  BREP_Face(HC_KEY facekey);
2318  ~BREP_Face();
2319 
2320  BREP_Edge * AddCoEdge(BREP_Topology *topol, void *edgeid, HC_KEY edgekey);
2321 
2322 
2323  struct vlist_s * m_CoEdgeList;
2324  HC_KEY m_facekey;
2325 };
2326 
2327 class MVO_API BREP_Topology
2328 {
2329 public:
2330 
2331  struct vhash_s * m_FaceHash;
2332 
2333  struct vhash_s * m_EdgeHash;
2334  struct vhash_s * m_VertexHash;
2335 
2336  BREP_Face *m_CurrentFace;
2337  BREP_Topology();
2338  ~BREP_Topology();
2339  BREP_Face *AddFace(HC_KEY facekey);
2340  BREP_Face *GetFace(HC_KEY facekey);
2341  BREP_Edge *FindEdge(void *edgeid);
2342  BREP_Edge *AddEdge(void *edgeid, HC_KEY edgekey);
2343  HC_KEY AddVertex(void *vertexid, HPoint vpos);
2344  HC_KEY FindVertex(void *vertexid);
2345 
2346 
2347 
2348  BREP_Face *GetCurrentFace() { return m_CurrentFace; }
2349 
2350 };
2351 
2352 class H_FORMAT_TEXT;
2353 
2354 class MVO_API HBestImageDriver
2355 {
2356 private:
2357  H_FORMAT_TEXT * m_dvr;
2358 public:
2359  HBestImageDriver(char const * prefer_type = 0);
2360  ~HBestImageDriver();
2361 
2362  HC_KEY GetKey() const;
2363 
2364  operator char const* () const;
2365 };
2366 
2367 
2368 class MVO_API HPVOOptions
2369 {
2370  private:
2371  void * impl;
2372 
2373  public:
2374  HPVOOptions(char const * filename);
2375  ~HPVOOptions();
2376  char const * getOption(char const * option) const;
2377 };
2378 
2379 
2380 #ifdef H_PACK_8
2381 #pragma pack(pop)
2382 #endif
2383 
2384 #endif
The HPixelRGB class is the data type of a rgb pixel.
Definition: HGlobals.h:471
HShellWrapper()
Definition: HUtility.h:307
The HShellObject class is a simple wrapper for a shell.
Definition: HUtility.h:198
int point_list_len
The length of the point list,.
Definition: HUtility.h:267
int m_facepointer
Definition: HUtility.h:519
void Show_One_User_Option(const char *type, char *value)
double w
The knot value of a B-Surface vertex.
Definition: HUtility.h:588
int region_count
The number of regions in the shell.
Definition: HUtility.h:275
HShellWrapper(HC_KEY key)
Definition: HUtility.h:291
The HUtility class contains a set of utility functions and data structures used widely in MVO classes...
Definition: HUtility.h:783
Definition: HUtility.h:2106
static const float PI
default=3.1415926f
Definition: HUtility.h:787
Definition: HUtility.h:2302
Definition: HUtility.h:2327
char * m_data
actual char* to the user options
Definition: HUtility.h:718
Definition: HUtility.h:2160
Definition: HUtility.h:2150
wchar_t * m_data
actual char* to the user options
Definition: HUtility.h:2222
The HCamera class is the data type of a HOOPS Camera Attribute.
Definition: HUtility.h:537
HPoint * point_list
The list of vertices that define the shell.
Definition: HUtility.h:268
HPoint up_vector
The direction of up.
Definition: HUtility.h:542
bool valid
True if the object has been initialized.
Definition: HUtility.h:539
void Show_User_Options(char *list)
double y
The y-coordinate of a B-Surface vertex.
Definition: HUtility.h:586
The HShellRegion class is a simple wrapper for a shell's region.
Definition: HUtility.h:164
HVector * normal_list
The list of normal vectors associated with the shell.
Definition: HUtility.h:269
#define HC_KEY
HC_KEY * patharray
Array of Keys.
Definition: HUtility.h:676
The HSmartSelItem - selection item which can handle instancing.
Definition: HSelectionItem.h:187
Definition: HUtility.h:2137
void Set(int first, int second)
Definition: HUtility.h:101
class HPoint HVector
The HVector class is the data type of a three-dimensional vector.
Definition: HGlobals.h:326
void EndFaceIteration()
Definition: HUtility.h:379
float field_height
The height of the field of view.
Definition: HUtility.h:544
int len
length of key array
Definition: HUtility.h:677
int face_count
The number of faces in the shell.
Definition: HUtility.h:273
int * m_Flist
The list that defines the configuration of the faces in the shell in relation to the points as descri...
Definition: HUtility.h:515
HC_KEY m_Key
The key of the shell.
Definition: HUtility.h:516
int m_plen
The number of points in the points list.
Definition: HUtility.h:509
Definition: HUtility.h:2052
The HUnicodeOptions class is a helper class which wraps up memory management for variable size Unicod...
Definition: HUtility.h:2218
double z
The z-coordinate of a B-Surface vertex.
Definition: HUtility.h:587
Definition: HUtility.h:59
The HUserOptions class is a helper class which wraps up memory management for variable size user opti...
Definition: HUtility.h:714
HPoint target
The area that the camera is directed at.
Definition: HUtility.h:541
void InvalidateCamera()
Definition: HUtility.h:553
HPolyline * m_pNextPolyline
A pointer to a single HPolyline object.
Definition: HUtility.h:605
int face_list_len
The length of the face list.
Definition: HUtility.h:271
int m_flen
The length of the face list.
Definition: HUtility.h:510
The HShellVertexData class encapsulates colormap index information associated with the vertices of a ...
Definition: HUtility.h:613
HPoint * m_pHPointArray
A pointer to an array of HPoint objects.
Definition: HUtility.h:604
void Show_Unicode_Options(unsigned short *options)
int GetFirst() const
Definition: HUtility.h:94
int m_totalplen
Definition: HUtility.h:523
The HBaseModel class is used to store and manage model information.
Definition: HBaseModel.h:47
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:121
Definition: HIOManager.h:830
The HBaseView class defines and manages a view of model information.
Definition: HBaseView.h:332
Definition: HUtility.h:2354
The HShell class is the data type of a HOOPS Shell.
Definition: HUtility.h:247
int m_length
length of current user option
Definition: HUtility.h:719
int * region_list
The list that defines the set of regions in the shell.
Definition: HUtility.h:276
Definition: HUtility.h:2012
void Show_One_Unicode_Option(const unsigned short *requestedOption, unsigned short *options)
The HShellFace class is a simple wrapper for a shell's face.
Definition: HUtility.h:127
int GetSecond() const
Definition: HUtility.h:96
static const float EH_Epsilon
default=0.01
Definition: HUtility.h:792
The HShellWrapper class is wraps shell information and provides methods to manipulate this informatio...
Definition: HUtility.h:284
The HShellEdge class is a simple wrapper for a shell's edge.
Definition: HUtility.h:84
HPoint position
The location of the camera.
Definition: HUtility.h:540
double x
The x-coordinate of a B-Surface vertex.
Definition: HUtility.h:585
void Set(double X, double Y, double Z, double W)
Definition: HUtility.h:592
Definition: HUtility.h:2286
The HPlane class is the data type of a plane.
Definition: HGlobals.h:333
int m_PointCount
Number of points in the polyline.
Definition: HUtility.h:603
Definition: HUtility.h:2368
The HShowContentsWithPathType struct is used by HUtility to store a keypath.
Definition: HUtility.h:674
The HBSurfVertex class is the data type of a B-Surface vertex.
Definition: HUtility.h:582
int * face_list
The face list that defines how faces are formed in the shell.
Definition: HUtility.h:272
HC_KEY GetKey()
Definition: HUtility.h:348
HShellEdge(int iFirst=0, int iSecond=0)
Definition: HUtility.h:90
The HPolyline class is the data type for a three-dimensional polyline.
Definition: HUtility.h:600
Definition: HUtility.h:44
Definition: HUtility.h:2314
int m_length
length of current user option
Definition: HUtility.h:2223
float field_width
The width of the field of view.
Definition: HUtility.h:543
int m_totalflen
Definition: HUtility.h:521