Introduction

Getting Started

Programming Guides

API Reference

Additional Resources

HUtility.h
1 // Copyright (c) Tech Soft 3D, Inc.
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 #undef max
28 #undef min
29 #include <limits>
30 
31 class HBaseView;
33 class HSmartSelItem;
34 class HBaseModel;
35 
36 class HShellObject;
37 
38 
39 enum AbsoluteWindowType
40 {
41  RelativeLeft,
42  RelativeRight,
43  RelativeTop,
44  RelativeBottom,
45  NotRelative
46 };
47 
49 {
50 public:
52  {
53  nindex = -1;
54  tcindex = -1;
55  nextindex = -1;
56  }
57  int nindex;
58  int nextindex;
59  int tcindex;
60 };
61 
62 
63 class MVO_API ShellToRegionMapper
64 {
65 public:
67  void AddRegion(HC_KEY originalshell, HC_KEY newshell, int regionnum, bool check = true);
68  HC_KEY GetOriginalShell(HC_KEY newshell, int regionnum);
69  int GetRegionsFromOriginalShell(HC_KEY originalshell, HC_KEY **newshells, int &regionnum);
70  void BuildSegmentTreeRecursive(HC_KEY okey, HC_KEY nkey);
71  void MapSegmentTree(HC_KEY modelkey);
72  void AddSegmentMapping(HC_KEY originalshell, HC_KEY segmentkey);
73 
74  struct vhash_s * m_RegionToShellHash;
75  struct vhash_s * m_ShellToRegionHash;
76  struct vhash_s * m_ShellToSegmentHash;
77 
78 };
79 
80 
81 
82 
83 
85 
88 class MVO_API HShellEdge {
89 public:
94  HShellEdge(int iFirst = 0, int iSecond = 0){
95  Set(iFirst, iSecond);
96  };
98  int GetFirst() const { return m_iFirst; };
100  int GetSecond() const { return m_iSecond; };
105  void Set(int first, int second) {
106  /* first should always be < second to eliminate ambiguity. */
107  if(first < second){
108  m_iFirst = first;
109  m_iSecond = second;
110  } else {
111  m_iFirst = second;
112  m_iSecond = first;
113  }
114  };
115 
116  bool operator<(HShellEdge const & rhs) const {
117  if(m_iFirst != rhs.m_iFirst)
118  return m_iFirst < rhs.m_iFirst;
119  return m_iSecond < rhs.m_iSecond;
120  }
121 
122 private:
123  int m_iFirst;
124  int m_iSecond;
125 };
126 
128 
131 class MVO_API HShellFace{
132 public:
137  HShellFace(HShellObject const * pShell, int const iFaceIndex);
138 
140  int GetPointCount() const ;
141 
143  int GetEdgeCount() const ;
148  HShellEdge const GetEdge(int const iEdgeIndex) const;
152  void OpenEdge(int const iEdgeIndex) const;
156  void CloseEdge() const;
157 
158 private:
159  HShellObject const * m_pShell;
160  int m_iFaceIndex;
161  int m_iPointCount;
162 };
163 
165 
168 class MVO_API HShellRegion{
169 public:
174  HShellRegion(HShellObject const * pShell, int const iRegionIndex);
175  ~HShellRegion(){
176  delete [] m_pRegionFlist;
177  }
180  int GetFaceCount() const;
185  HShellFace const GetFace(int index) const;
186 
187  //void Open() const;
188  //void Close() const;
189 private:
190  HShellObject const * m_pShell;
191  int m_iRegionIndex;
192 
193  int m_iRegionFlistLength;
194  int *m_pRegionFlist;
195 };
196 
197 
199 
202 class MVO_API HShellObject {
203 public:
207  HShellObject(HC_KEY kShellKey);
208  HShellObject(HShellObject const & oShellObj);
209  ~HShellObject();
210 
215  HShellRegion const GetRegion(int const index) const;
216 
218  int GetFaceCount() const;
223  int GetFaceFlistIndex(int index) const;
224 
225  //void Open() const;
226  //void Close() const;
227 
229  HC_KEY GetKey() const ;
231  int GetFlistLen() const ;
233  int const * GetFlist() const ;
236  void GetFlist (int flist[]) const;
237 
238 private:
239  int m_iFlistLen;
240  int * m_pFlist;
241  mutable int * m_pFaceIndexes;
242 
243  HC_KEY m_kShellKey;
244 };
245 
246 
248 
251 class MVO_API HShell {
252 public:
253  HShell()
254  :point_list_len(0),
255  point_list(),
256  normal_list(),
257  face_list_len(0),
258  face_list(0),
259  face_count(0),
260  region_count(0),
261  region_list(0)
262  {}
263  ~HShell()
264  {
265  /* No need to check for null pointers. delete already does that. */
266  delete [] point_list;
267  delete [] normal_list;
268  delete [] face_list;
269  delete [] region_list;
270  }
274 
276  int *face_list;
278 
280  int *region_list;
281 };
282 
284 
288 class MVO_API HShellWrapper {
289 
290 public:
295  HShellWrapper(HC_KEY key) {
296  m_Points = 0;
297  m_Flist = 0;
298  m_VParams = 0;
299  m_VNormals = 0;
300  m_VColors = 0;
301  m_faceregion = 0;
302  m_totalnumfaceslen = 0;
303  m_numfaceslen = 0;
304  m_FNArray = 0;
305  m_faceindirect = 0;
306  Set(key);
307  }
312  m_Key = INVALID_KEY;
313  m_Points = 0;
314  m_Flist = 0;
315  m_VParams = 0;
316  m_VNormals = 0;
317  m_VColors = 0;
318  m_flen = 0;
319  m_plen = 0;
320  m_totalplen = 0;
321  m_totalflen = 0;
322  m_faceregion = 0;
323  m_totalnumfaceslen = 0;
324  m_numfaceslen = 0;
325  m_FNArray = 0;
326  m_faceindirect = 0;
327  }
328  ~HShellWrapper();
329 
340  HC_KEY Insert(int plen, HPoint points[], int flen, int flist[], HC_KEY insertkey = INVALID_KEY);
348  HC_KEY Show(int *plen, HPoint **points, int *flen, int **flist);
352  HC_KEY GetKey() { return m_Key; }
356  void TransformPoints(float matrix[]);
357 
362  HC_KEY Optimize(char *options);
368  HC_KEY Optimize2(char *options);
369 
370  void MakePolygon(int facelen, int face[], HPoint points[]);
371 
372 
375  void OpenOwnerSegment();
376 
379  void BeginFaceIteration();
380 
383  void EndFaceIteration() { ; };
384  int GetFace(int facenum, int **face);
389  int NextFace(int **face);
390 
396  void CalculateFaceCenter(int face[], int flen, HPoint *mid);
403  void AddPoints(HPoint points[], int pnum, HPoint param[] = 0, HPoint normals[] = 0, bool AddImmediately= false);
410  void AddFace(int face[], int fnum, int regionnum, HPoint points[], HPoint normals[] = 0, bool AddImediately= false);
417  void AddFaceDirect(int face[], int fnum, bool reverse = false, bool AddImmediatly= false);
424  void AddFace(HPoint points[], int fnum, bool AddImmediatly= false);
429  void Set(HC_KEY key);
436  void Regenerate(HC_KEY newowner = INVALID_KEY, bool makeSegment = true, bool regenerate = false);
441  void GrowArrays(int fnum);
447  void GrowPointArray(int fnum, bool gorwvparams = false, bool grownormals = false);
448 
449  void GrowPointArray2(int fnum, bool growparamarray = false, bool grownormalarray = false, bool growfnarray = false, bool growcolorarray = false);
450  void AddNextFaceWithDistinctNormals(HPoint const * points, HPoint const * normals, int const * face1, int const * face2, int fnum);
451  void AddNextFaceWithDistinctNormalsAndTexture(HPoint const * points, HPoint const * normals, HPoint const * texcor,int const * face1, int const *face2, int const *face3, int fnum);
452  void AddNextFaceWithDistinctNormalsAndColor(HPoint const *points, HPoint const *normals,int const *face1, int const *face2, HPoint *face3, int fnum);
453 
454 
455  void BeginAddFaces(int pnum);
456  void EndAddFaces();
457 
462  void GrowFaceArray(int fnum);
463 
465  void SubdivideOneQuadFace(int face[], HShellWrapper &wrapper, bool generateIsolines, int *facecolorlist, int &fclnum);
466 
468  void SubdivideOneQuadFace2(int face[]);
473  void SubdivideQuadFaces(bool GenerateIsolines);
474 
478  void SetVertexColors(HPoint *color);
482  void ShowVertexColors(HPoint *color);
487  void SetVertexColors(float *findex);
491  void ShowVertexColors(float *color);
497  void MakeLod(int lodnum, int percent);
503  void FindExtents(HPoint &center, HPoint &min, HPoint &max);
504  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);
505  void ReplaceWithParameters(int plen, HPoint points[], int flen, int flist[], HPoint normals[], float params[], int paranum, bool emptyshell);
506  void Replace(int plen, HPoint points[], int flen, int flist[], HPoint normals[] = 0, bool emptyshell = false);
507 
508  void SetFaceRegion(int regionnum);
509 
510  void SetEmptyShell(HC_KEY segmentkey, bool MakeSegment);
511 
512 
513  int m_plen;
514  int m_flen;
515  HPoint *m_Points;//<! The list of pointst that define the shell.
516  HPoint *m_VParams;
517  HPoint *m_VColors;
518  HPoint *m_VNormals;
519  int *m_Flist;
521 
528  int m_totalnumfaceslen;
529  int m_numfaceslen;
530  int *m_faceregion;
531  int *m_faceindirect;
532  FaceWithNormalInfo *m_FNArray;
533 
534 };
535 
536 
538 
541 class MVO_API HCamera {
542 public:
543  bool valid;
547  float field_width;
548  float field_height;
549  char projection[128];
550 
551  HCamera () {
552  projection[0] = '\0';
553  valid = false;
554  }
555 
557  inline void InvalidateCamera() { projection[0]='\0'; valid = false; }
558 
562  bool CameraDifferent(HCamera &cam);
563 
567  bool CameraDifferentByAngle(HCamera &cam);
568 
569 
572  void GetFromView(HBaseView * view);
573 
575  void Show() {
576  HC_Show_Camera (&position, &target, &up_vector, &field_width, &field_height, projection);
577  valid = true;
578  };
579 
581  void Set() const {
582  HC_Set_Camera (&position, &target, &up_vector, field_width, field_height, projection);
583  };
584 };
585 
586 
588 
591 class MVO_API HBSurfVertex
592 {
593 public:
594  double x;
595  double y;
596  double z;
597  double w;
598 
601  inline void Set(double X, double Y, double Z, double W) { x=X, y=Y, z=Z, w=W; }
602 };
603 
605 
609 class MVO_API HPolyline
610 {
611 public:
615 };
616 
618 
622 class MVO_API HShellVertexData
623 {
624 public:
625  /* Constructor initializes this object to an invalid state. */
626  HShellVertexData():m_VertexCount(0), m_pFIndexArraySize(0), m_pFIndexArray(0), m_Key(INVALID_KEY){
627  m_sType[0] = '\0';
628  }
629 
630  /* Destructor free up the resources this object is using. */
631  ~HShellVertexData(){
632  ResetMyself();
633  }
634 
635  /* Sets the key and fills in the members with the correct data for this shell. */
636  void SetKey(HC_KEY const key);
637 
638  /* Return a const string for the type of shell. */
639  char const * const GetType() const {
640  return m_sType;
641  }
642 
643  /* Returns the vertex count for this shell. */
644  int const GetVertexCount() const {
645  return m_VertexCount;
646  }
647 
648  /* Return the key for the shell */
649  HC_KEY const GetKey() const {
650  return m_Key;
651  }
652 
653  /* Return the size the findex array */
654  int const GetFIndexDataSize() const {
655  return m_pFIndexArraySize;
656  }
657 
658  /* Returns a const array for the findex values in this shell. */
659  float const * const GetFIndexData() const {
660  return m_pFIndexArray;
661  }
662 
663  /* Returns a const array (as an argument) for the findex values in this shell.
664  Note that the array must be of the appropriate size, e.g., via a call to GetFIndexDataSize. */
665  void GetFIndexData(float data[]) const;
666 
667  void SetFIndexData(int const size, float const data[]);
668 
669 private:
670  void ResetMyself();
671 
672  int m_VertexCount;
673  int m_pFIndexArraySize;
674  float *m_pFIndexArray;
675  HC_KEY m_Key;
676  char m_sType[32];
677 };
678 
679 
681 
683 typedef struct
684 {
686  int len;
688 
689 
690 enum HWindowCorner
691 {
692  TopLeft,
693  BottomLeft,
694  BottomRight,
695  TopRight
696 };
697 
698 
699 
700 
701 
702 
703 
705 
723 class MVO_API HUserOptions
724 {
725 public:
726 
727  char * m_data;
728  int m_length;
729  bool m_valid;
730 
732  HUserOptions();
733 
735  HUserOptions(const HUserOptions& in_data);
736 
737 
739  ~HUserOptions();
740 
741 
745  bool IsValid();
746 
752  const char * Show_User_Options();
753 
759  const char * Show_One_Net_User_Option(const char * which);
760 
766  const char * Show_One_User_Option(const char * which);
767 
773  const char * Show_Net_User_Options();
774 
775 
776 private:
777 
778  void clear() {
779  delete [] m_data;
780  m_data = 0;
781  m_length = 0;
782  };
783 
784 };
785 
786 
787 
789 
792 class MVO_API HUtility
793 {
794 public:
795 #undef PI
796  static const float PI;
797 
798  enum{X, Y, Z, W};
799  enum{XY, XZ, YZ};
800 
801  static const float EH_Epsilon;
802 
803 
810  static void Order(HPoint* one, HPoint* two);
811 
818  static void Find_Relative_Path(HC_KEY from_seg_key, HC_KEY to_seg_key, char * path);
819 
823  static float GetTime();
824 
825 
830  static void ClampPointToWindow (HPoint * point);
831 
838  static HC_KEY InsertBox (HPoint const * max, HPoint const * min);
839 
847  static HC_KEY InsertWireframeBox (HPoint * max, HPoint * min);
848 
855  static void GenerateCuboidPoints (HPoint const * max, HPoint const * min, HPoint * points);
856 
868  static HC_KEY InsertRectangle (const char * seg, float x0, float y0, float x1, float y1, float z = 0.0f, bool fill = false);
869 
870 
885  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);
886 
893  static void ComputeDoublePrecisionCrossProduct(double * vector1, double * vector2, double * up);
894 
901  static double ComputeDoublePrecisionDotProduct(double * vector1, double * vector2);
902 
908  static double ComputeDoublePrecisionVectorLength(double * vector1);
909 
916  static void GetViewplaneVectors(HC_KEY segment_key, double * view, double * up);
917 
922  static void NormalizeDoublePrecisionVector(double* vector1);
923 
931  static bool PointsEqual(HPoint * point1, HPoint * point2);
932 
944  static bool CreateAxisCircle (HPoint const & center, float radius, int axis, bool convert = true);
945 
946 
953  static void RotateToVector(HPoint start, HPoint end, bool doTranslation = true);
954 
970  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);
971 
979  static void SmoothTransition(HCamera old_camera, const HCamera &new_camera, HBaseView *view);
980 
987  static bool CamerasEqual(const HCamera &camera1, const HCamera &camera2);
988 
996  static void ComputeVectorToVectorRotationMatrix(float matrix[],HPoint v1,HPoint v2);
997 
1006  static bool ExtractRGB(char *text,float &r, float &g, float &b);
1007 
1018  static void TransitionQuaternion(float quat_old[], float quat_new[], float t, float qt[]);
1019 
1025  static void MatrixToQuaternion(float matrix[], float quaternion[]);
1026 
1032  static void QuaternionToMatrix(float quaternion[], float matrix[]);
1033 
1042  static void SmoothQuaternionTransition(HBaseView *m_pView, char *old_seg, char *new_seg, int num_of_transitions);
1043 
1051  static void SmoothMatrixTransition(HBaseView *m_pView, HC_KEY seg_key, float new_matrix[]);
1052 
1062  static void MultiSmoothTransitions(HBaseView *m_pView, int num_keys, HC_KEY *seg_key, float new_matrix[], HCamera *new_camera = 0);
1063 
1069  static HPoint GetCentroid(HC_KEY seg_key);
1070 
1077  static HPoint GetTransformedCentroid(HC_KEY seg_key, float matrix[] = 0);
1078 
1086  static void URIencode(const char * in_string, MVO_POINTER_SIZED_UINT n, char * out_buffer);
1094  static void URIdecode(const char * in_string, char * out_buffer, MVO_POINTER_SIZED_UINT * n);
1095 
1104  static void GetCameraFromMatrix(float matrix[], HPoint *target, HPoint *position, HPoint *up_vector, HPoint *translation);
1105 
1114  static void GetMatrixFromCamera(HPoint target, HPoint position, HPoint up_vector, HPoint translation, float matrix[]);
1115 
1116 
1150  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,
1151  HPoint &pos, HPoint &target, HPoint &up, char * projection, double &width, double &height, double &near_limit );
1152 
1160  static bool PushAttribute(const char *attName);
1161 
1170  static void PushAttribute(const char *attName, const char *attText);
1171 
1179  static bool PopAttribute(const char *attName);
1180 
1191  static bool ModifyPushedAttribute(const char *attName, const char *newStyle);
1192 
1199  static bool ShowPushedAttribute(const char *attName, HUserOptions& attText);
1200 
1213  static void Recursive_Merge_Shells( HShell *total_info, HShell *max_info, bool do_recurse, bool delete_orig_shells = false, bool insert_null_lods = false );
1214 
1221  static HC_KEY Merge_Shells( bool do_recurse, bool delete_orig_shells = false , bool optimize_shell = true, bool generate_regions = false);
1222 
1230  static HC_KEY Merge_Shells_Generate_Regions( int num_shells, HC_KEY * shell_keys, bool delete_orig_shells = false );
1231 
1241  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 );
1242 
1250  static bool Segment_Shell_Allocate( HShell *total_info, HShell *max_info, bool do_recurse );
1251 
1259  static void Shell_Search( HShell *total_info, HShell *max_info, bool do_recurse );
1260 
1261 
1262 
1273  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);
1274 
1275 
1284  static void CountShellData(HC_KEY shell_key, int * faces, int * vertices, int * triangles, int * tristrips = 0);
1285 
1292  static void FindFileNameExtension(const char * filename_in, char * ext_out, int size = -1);
1293 
1300  static void FindFileNameExtension(__wchar_t const * const filename_in, __wchar_t * ext_out, int size = -1);
1301 #ifdef H_USHORT_OVERLOAD
1302  static void FindFileNameExtension(unsigned short const * const filename_in, unsigned short * ext_out, int size = -1){
1303  FindFileNameExtension((wchar_t const * const)filename_in, (wchar_t*)ext_out, size);
1304  }
1305 #endif
1306 
1311  static void FindUnicodeFileNameExtension(const unsigned short * filename_in, char * ext_out);
1312 
1320  static void FindFileNameAndDirectory(const char * filename_in, char * dir_out, char * filename_out);
1328  static void FindFileNameAndDirectory(__wchar_t const * filename_in, __wchar_t * dir_out, __wchar_t * filename_out);
1329 
1340  static const char* extra_pointer_format();
1344  static HC_KEY CreateScaleIndependentSegment(const char *segname, bool SetCallback = true);
1345 
1349  static HC_KEY GetScaleIndependentGeomSegmentKey(HC_KEY segkey);
1350 
1354  static void SetScaleIndependentGeomPosition(HC_KEY segkey, float x, float y, float z);
1355 
1359  static void GetScaleIndependentGeomPosition(HC_KEY segkey, float &x, float &y, float &z);
1360 
1364  static void RegisterCallbacks();
1365 
1372  static bool IsModelKey(HC_KEY modelkey, HC_KEY objectkey);
1373 
1381  static HC_KEY UserOptionExists(HC_KEY key, const char *attrib, char *result);
1382 
1399  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);
1400 
1410  static int CalculateKeyPath(HC_KEY startkey, HBaseView *view, HC_KEY *keyarray, int maxarray);
1411 
1416  static bool SegmentExists(const char *segment);
1417 
1420  static void UnsetAttributes();
1421 
1429  static int IsChildOf(HC_KEY owner, HC_KEY child, HC_KEY klist[] = 0);
1430 
1436  static bool IsIdentityMatrix(float matrix[]);
1437 
1444  static void ComputeShellNormal(HC_KEY skey, HPoint &tnormal);
1445 
1455  static HC_KEY SelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false);
1456 
1457 
1468  static HC_KEY SmartSelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false);
1469 
1470 
1477  static bool ShowOneHeuristic(const char *type, char *res = 0);
1484  static bool ShowOneRenderingOption(const char *type, char *res = 0);
1485 
1495  static float EaseInEaseOut(float t, float a, float b, float c);
1496 
1501  static void UnwindIncludes(HC_KEY &key);
1502 
1509  static void UnwindIncludes(HC_KEY &newkey, HC_KEY *keys, int count);
1510 
1511 
1518  static bool SafeSetUserOption(const char * opt);
1519 
1526  static bool SafeShowUserOption(char * opt);
1527 
1528 
1533  static void ProjectShell(HC_KEY shellkey);
1534 
1541  static HC_KEY MergeShells(HC_KEY shell1, HC_KEY shell2);
1542 
1548  static void ShowModellingMatrix(float *segment_modelling_matrix);
1549 
1556  static void ConvertLocalPixelsToLocalWindow(HBaseView * view, HPoint *in_system , HPoint *out_system = 0);
1557 
1558 
1565  static HC_KEY GrabSegment(HC_KEY key);
1566 
1571 # define MakeSegment(key) GrabSegment(key)
1572 
1578  static void RenameSegment(HC_KEY segkey, const char *newname);
1579 
1580 
1591  static void InterpolateNormalAlongEdge(HPoint &p1, HPoint &n1, HPoint &p2, HPoint &n2, HPoint &p3, HPoint &n3);
1592 
1598  static void ShowNormals(HC_KEY shellkey, float normallength);
1599 
1605  static bool IsSegmentKey(HC_KEY key);
1606 
1613  static int FindContents(HC_KEY &key);
1614 
1621  static int CalculateMajorAxis(HBaseView *view);
1622 
1623 
1631  static HC_KEY FindOneObject(const char *type, bool l = 0);
1637  static void CloseAllSegments(HC_KEY endkey = INVALID_KEY);
1638 
1643  static void ReadjustTarget(HBaseView *view);
1644 
1649  static bool GetAllowAnimation(HC_KEY key);
1650 
1653  static void SuppressAnimation();
1654 
1662  static int FindFaceByIndex(int findex, int *flist, int flen);
1663 
1670  static bool ShowOneUserOption(const char *option, char *res);
1671 
1677  static HC_KEY GetNextRenumberedKey(HBaseView *view);
1678 
1684  static void NameSegments(HC_KEY &key, HBaseView *view);
1685 
1691  static void MoveToTemp(HC_KEY movekey, HC_KEY tempkey);
1692 
1703  static void ShowContentsWithPath( const char * entitytypes, struct vlist_s **ret_pathlist, bool storePath = false, bool includeIncludes = true, bool filterIncludes = true);
1704 
1705 
1711  static int ustrlen(unsigned short *text);
1712 
1722  static bool RLECompress(int const in_len,
1723  unsigned char const * const in_buf,
1724  int * out_len,
1725  unsigned char * const out_buf);
1726 
1736  static bool ZlibCompress(int const in_len,
1737  unsigned char const * const in_buf,
1738  int & out_len,
1739  unsigned char * const out_buf);
1740 
1750  static bool ZlibDecompress(int const in_len,
1751  unsigned char const * const in_buf,
1752  int & out_len,
1753  unsigned char * const out_buf);
1759  static unsigned short *uconvert(const char *text);
1760 
1771  static bool BuildIncludePath(HC_KEY objectkey, const HC_KEY *includelist, int ilength, HC_KEY *fullpath, int *fplength, HC_KEY matchkey = INVALID_KEY);
1772 
1779  static void BuildIncludePathFromSelection(HSmartSelItem *sitem, int &plen, HC_KEY *fullpath);
1780 
1781 
1790  static void MakeViewSnapshot(HBaseView * view, int width, int height, char ** data);
1791 
1797  static void MakeViewSnapshot(HBaseView * view, HC_KEY image_key);
1798 
1807  static int ConstrainToVector( const float matrix_in[], const HVector &vector, float matrix_out[]);
1808 
1816  static void Camera_To_Transform (HCamera *camera , float *pos, float projection_matrix[], float complete_matrix[]);
1827  static void LocalPixelsToWorld(HCamera *camera, bool righthanded, float xres, float yres, int xwpix, int ywpix, float result[]);
1834  static float ComputeAngleBetweenVector(HPoint p1, HPoint p2);
1835 
1836 
1842  static int strlen16( const unsigned short *p16);
1843 
1852  static void CalculateBoundingInfo(HC_KEY startkey, HPoint &min, HPoint &max, HPoint &delta, HPoint &mid);
1853 
1863  static long ClipPolygonAgainstPlane(long vertexCount, const HPoint vertex[],
1864  const float plane[], HPoint result[], bool *noCut = 0);
1865 
1872  static HFileOutputResult TwoPassPrint(const char *driver, HOutputHandlerOptions *options);
1873 
1881  static HC_KEY OpenSegmentFromKey(HC_KEY key, char *segment);
1882 
1883 
1895  static bool IsPointInsideAllEdges( const float *pt,const float points1[],
1896  int len, const int face1[], const float plane1[], float fudge );
1904  static void IntersectionLinePlane(HPoint *p1, HPoint *p2, HPlane *p, HPoint *res);
1905 
1911  static void DeleteManipulators(HC_KEY key);
1912 
1913 
1928  static void MergePointsIntoShell(int num_shell_points, HPoint plist1[], int num_shell_facelist, int flist1[],
1929  int num_merge_points, HPoint merge_points[], HPoint merge_vectors[],
1930  float tolerance, bool AddExtraPoints, int newpoints[], int *newpointslen);
1931 
1932 
1947  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);
1948 
1950  static void MergePolylines();
1951  static void CreateZebraStripeTexture(int width, int height, int stripwidth, bool horizontal, HPixelRGB colorstripes, HPixelRGB colorbackground);
1952 
1960  static void ascii_to_unicode(char const *ascii, unsigned short *unicode);
1961 
1969  static void unicode_to_ascii(unsigned short const *unicode, char *ascii);
1970 
1979  static void BatchRead(HBaseModel * model, const char * directory, const char * extension);
1980 
1988  static void AdjustPositionToPlane(HBaseView * view, HPoint &position, HPoint point_in_plane);
1989 
1998  static void CalculateCornerImagePosition(HBaseView *view, int iwidth, int iheight, HWindowCorner corner, float &posx, float &posy);
1999  static void OptimizeModelByGrid(HBaseView *view, ShellToRegionMapper *mapper);
2000  static void DecipherTextureString(char *texdef, char *Source, bool *DownSampling = 0, bool *DownSamplingSet = 0, char *ParameterizationSource = 0,
2001  char *InterpolationFilter = 0, char *DecimationFilter = 0, char *Layout = 0, char *Tiling = 0, bool *ValueScaleSet = 0,
2002  bool *ValueScale = 0, float *ValueScaleMin =0, float *ValueScaleMax = 0, char *BlendingMode = 0);
2003 
2008  static inline bool IsSafeForSinglePrecision(double element, bool check_roundoff = false) {
2009  if (abs(element) > std::numeric_limits<float>::max())
2010  return false;
2011  if (check_roundoff) {
2012  if (abs(element - float(element)) > std::numeric_limits<float>::epsilon() * 0.001 * abs(element))
2013  return false;
2014  }
2015  return true;
2016  }
2017 
2023  static inline bool IsSafeForSinglePrecision(int element_count, double const * elements, bool check_roundoff = false) {
2024  while (element_count-- > 0)
2025  if (!IsSafeForSinglePrecision(*elements++, check_roundoff))
2026  return false;
2027  return true;
2028  }
2029 
2030 
2031 private:
2032  static void scale_segment (HIC_Rendition *rendition,HIC_Segment_Info * geo3);
2033  static void activity_change (HIC_Segment *seg, int old_activity, int new_activity);
2034  static bool RestoreAttributeFromOption(const char *attName, HUserOptions& attText);
2035  static void ReplaceCharacter(char *text, char orig, char target);
2036  static bool SetAttribute(const char *attName, const char *attText);
2037  static bool ShowAttribute(const char *attName, char *attText);
2038  static void ShowContentsWithPathAddEntity(HC_KEY key, struct vlist_s *pathlist, int level, HC_KEY *patharray, bool storePath);
2039  static void ShowContentsWithPathRecursive(HC_KEY key, const char *entitytypes, struct vlist_s *pathlist, HC_KEY *patharray, int level, bool storePath, bool includeIncludes, bool filterIncludes);
2040  static void SubdivideOneShell(HShellWrapper &myshell, int numx, int numy, int numz, HPoint &totalmin,
2041  HPoint &totaldeltadiv, HShellWrapper *shellmatrix, HShellWrapper &leftover, float boxdiagonallength, bool DoCut, int regionnum, ShellToRegionMapper *mapper, HC_KEY newkey);
2042 
2043 
2044 };
2045 
2046 
2047 class MVO_API HQualifiedKey
2048 {
2049 public:
2050  HQualifiedKey(HC_KEY key, HC_KEY includelist[], int includelistlength)
2051  {
2052  m_Key = key;
2053  m_pIncludeList = 0;
2054  m_pIncludeList = new HC_KEY[includelistlength];
2055  for (int i = 0; i < includelistlength; i++)
2056  m_pIncludeList[i] = includelist[i];
2057  m_IncludeListLength = includelistlength;
2058  }
2059  ~HQualifiedKey()
2060  {
2061  delete [] m_pIncludeList;
2062  }
2063 
2064  long MakeHashKey()
2065  {
2066  return MakeHashKey(m_Key, m_IncludeListLength,m_pIncludeList);
2067  }
2068 
2069  static long MakeHashKey(HC_KEY key, int includelength, HC_KEY includes[])
2070  {
2071  long hashkey = static_cast<long>(key);
2072  for (int i = 0; i < includelength; i++)
2073  {
2074  hashkey += static_cast<long>(includes[i]);
2075  }
2076  return hashkey;
2077  }
2078 
2079  HC_KEY m_Key;
2080  HC_KEY * m_pIncludeList;
2081  int m_IncludeListLength;
2082 };
2083 
2084 
2085 
2086 
2087 class MVO_API HMergeShellFace
2088 {
2089 
2090 public:
2091  HMergeShellFace()
2092  {
2093  m_pChildFaces = 0;
2094  m_ChildFaceNum = 0;
2095  }
2096  ~HMergeShellFace()
2097  {
2098  if (m_pChildFaces)
2099  delete [] m_pChildFaces;
2100  if (m_pFlist)
2101  delete [] m_pFlist;
2102 
2103  }
2104  void Init(int * flist);
2105  void MakeChildFaces(int & addpoint, HPoint * points, bool AddExtraPoints, int * newpoints, int * newpointslen);
2106  void Divide(int pnum, HPoint * points);
2107 
2108  bool CheckHit(HPoint & p, HPoint & normal, HPoint * plist, HPoint & pres);
2109  HMergeShellFace * FindHitFaceRecursive(HPoint & p, HPoint & normal, HPoint * plist, HPoint & respoint);
2110  HMergeShellFace * FindHitFace(HPoint & p, HPoint & normal, HPoint * plist, HPoint & respoint)
2111  {
2112  return FindHitFaceRecursive(p, normal, plist,respoint);
2113  }
2114  bool CheckIfColinear(HPoint * point);
2115 
2116  int GetLengthRecursive(int l);
2117 
2118  int GetLength()
2119  {
2120  return GetLengthRecursive(0);
2121 
2122  }
2123 
2124  int AddToFacelistRecursive(int * start, int l);
2125 
2126  int AddToFacelist(int * start)
2127  {
2128  return AddToFacelistRecursive(start, 0);
2129 
2130  }
2131 
2132 protected:
2133  HMergeShellFace * m_pChildFaces;
2134  int m_flen;
2135  int * m_pFlist;
2136  int m_ChildFaceNum;
2137 };
2138 
2139 
2140 
2141 class MVO_API ColorPiece{
2142 
2143 public:
2144  ColorPiece(int index[], int len, int col)
2145  {
2146  m_uvindex = new int[len];
2147  m_fllen = new int[len];
2148  m_flindex = new int[len];
2149  for (int i=0;i<len;i++)
2150  m_uvindex[i] = index[i];
2151  m_len = len;
2152  m_col = col;
2153  m_done = false;
2154 
2155  }
2156  ~ColorPiece()
2157  {
2158  delete [] m_uvindex;
2159  delete [] m_fllen;
2160  delete [] m_flindex;
2161  }
2162  int *m_uvindex;
2163  int *m_fllen;
2164  int *m_flindex;
2165  int m_len;
2166  int m_col;
2167 
2168  bool m_done;
2169 
2170 };
2171 
2172 class MVO_API ColorPieceList
2173 {
2174 public:
2175  ColorPieceList();
2176  ~ColorPieceList();
2177  void AddColorPiece(int index[], int len, int col);
2178  ColorPiece * FindMatch(int col, int ii, int ii2, int &rpos, int &rlen, bool &reverse);
2179 
2180  struct vlist_s* m_ColorPieceList;
2181 
2182 
2183 };
2184 
2185 class MVO_API HVerticalUtility :
2186  public HUtility
2187 {
2188 public:
2189 
2190  static void ColorizePointCloud(HC_KEY const segment);
2191 };
2192 
2193 
2194 
2195 class MVO_API HAbsoluteWindow
2196 {
2197 public:
2198  HAbsoluteWindow(HBaseView *view, HC_KEY key,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft,
2199  AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft,
2200  AbsoluteWindowType height_type = RelativeTop, bool sb = false);
2201  HAbsoluteWindow(HBaseView *view, HC_KEY key);
2202  void DecipherOptions();
2203  void AdjustX(float invalue, AbsoluteWindowType wt, float &outvalue);
2204  void AdjustY(float invalue, AbsoluteWindowType wt, float &outvalue);
2205  bool Adjust();
2206  static void AdjustAll(HBaseView *view);
2207  static bool SetWindow(HBaseView *view,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft,
2208  AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft,
2209  AbsoluteWindowType height_type = RelativeTop, bool sb = false);
2210  bool IsPositionInWindow(float x, float y);
2211  static bool IsPositionInWindow(HBaseView *view, float x, float y);
2212  static void CalculateLocalWindowPos(HBaseView *view, float x, float y, float &xout, float &yout);
2213  void CalculateLocalWindowPos(float x, float y, float &xout, float &yout);
2214  static void CalculateOuterWindowPos(HBaseView *view, float x, float y, float &xout, float &yout);
2215  void CalculateOuterWindowPos(float x, float y, float &xout, float &yout);
2216 
2217 
2218 
2219  HBaseView *m_pView;
2220  float m_width;
2221  float m_height;
2222  float m_xpos;
2223  float m_ypos;
2224  AbsoluteWindowType m_xpos_type;
2225  AbsoluteWindowType m_ypos_type;
2226  AbsoluteWindowType m_width_type;
2227  AbsoluteWindowType m_height_type;
2228 
2229  bool m_bShowBackground;
2230 
2231  HC_KEY m_key;
2232 
2233 };
2234 
2235 
2236 
2238 
2253 class MVO_API HUnicodeOptions
2254 {
2255 public:
2256 
2257  wchar_t* m_data;
2258  int m_length;
2259  bool m_valid;
2260 
2262  HUnicodeOptions();
2263 
2265  HUnicodeOptions(const HUnicodeOptions& in_data);
2266 
2267 
2269  ~HUnicodeOptions();
2270 
2271 
2275  bool IsValid();
2276 
2281  const __wchar_t * Show_Unicode_Options();
2282 
2287  const wchar_t* Show_One_Net_Unicode_Option(const __wchar_t* which);
2288 #ifdef _MSC_VER
2289  const unsigned short * Show_One_Net_Unicode_Option(const unsigned short * which);
2290 #endif
2291 
2296  const wchar_t * Show_One_Unicode_Option(const __wchar_t * which);
2297 #ifdef _MSC_VER
2298  const unsigned short * Show_One_Unicode_Option(const unsigned short * which);
2299 #endif
2300 
2304  const __wchar_t* Show_Net_Unicode_Options();
2305 
2306 private:
2307 
2308  void clear() {
2309  delete [] m_data;
2310  m_data = 0;
2311  m_length = 0;
2312  m_valid = false;
2313  }
2314 
2315 };
2316 
2317 
2318 
2319 class BREP_Topology;
2320 
2322 {
2323 public:
2324  BREP_Edge(HC_KEY edgekey)
2325  {
2326  m_edgekey = edgekey;
2327  m_vertex1 = INVALID_KEY;
2328  m_vertex2 = INVALID_KEY;
2329  }
2330 
2331  HC_KEY m_edgekey;
2332  HC_KEY m_vertex1;
2333  HC_KEY m_vertex2;
2334 
2335 };
2336 
2338 {
2339 public:
2340  BREP_CoEdge(BREP_Edge *edge)
2341  {
2342  m_edge = edge;
2343  }
2344 
2345  BREP_Edge * m_edge;
2346 };
2347 
2348 
2349 class MVO_API BREP_Face
2350 {
2351 public:
2352  BREP_Face(HC_KEY facekey);
2353  ~BREP_Face();
2354 
2355  BREP_Edge * AddCoEdge(BREP_Topology *topol, void *edgeid, HC_KEY edgekey);
2356 
2357 
2358  struct vlist_s * m_CoEdgeList;
2359  HC_KEY m_facekey;
2360 };
2361 
2362 class MVO_API BREP_Topology
2363 {
2364 public:
2365 
2366  struct vhash_s * m_FaceHash;
2367 
2368  struct vhash_s * m_EdgeHash;
2369  struct vhash_s * m_VertexHash;
2370 
2371  BREP_Face *m_CurrentFace;
2372  BREP_Topology();
2373  ~BREP_Topology();
2374  BREP_Face *AddFace(HC_KEY facekey);
2375  BREP_Face *GetFace(HC_KEY facekey);
2376  BREP_Edge *FindEdge(void *edgeid);
2377  BREP_Edge *AddEdge(void *edgeid, HC_KEY edgekey);
2378  HC_KEY AddVertex(void *vertexid, HPoint vpos);
2379  HC_KEY FindVertex(void *vertexid);
2380 
2381 
2382 
2383  BREP_Face *GetCurrentFace() { return m_CurrentFace; }
2384 
2385 };
2386 
2387 class H_FORMAT_TEXT;
2388 
2389 class MVO_API HBestImageDriver
2390 {
2391 private:
2392  H_FORMAT_TEXT * m_dvr;
2393 public:
2394  HBestImageDriver(char const * prefer_type = 0);
2395  ~HBestImageDriver();
2396 
2397  HC_KEY GetKey() const;
2398 
2399  operator char const* () const;
2400 };
2401 
2402 
2403 class MVO_API HPVOOptions
2404 {
2405  private:
2406  void * impl;
2407 
2408  public:
2409  HPVOOptions(char const * filename);
2410  ~HPVOOptions();
2411  char const * getOption(char const * option) const;
2412 };
2413 
2414 
2415 #ifdef H_PACK_8
2416 #pragma pack(pop)
2417 #endif
2418 
2419 #endif
The HPixelRGB class is the data type of a rgb pixel.
Definition: HGlobals.h:471
HShellWrapper()
Definition: HUtility.h:311
The HShellObject class is a simple wrapper for a shell.
Definition: HUtility.h:202
int point_list_len
The length of the point list,.
Definition: HUtility.h:271
int m_facepointer
Definition: HUtility.h:523
void Show_One_User_Option(const char *type, char *value)
double w
The knot value of a B-Surface vertex.
Definition: HUtility.h:597
int region_count
The number of regions in the shell.
Definition: HUtility.h:279
HShellWrapper(HC_KEY key)
Definition: HUtility.h:295
The HUtility class contains a set of utility functions and data structures used widely in MVO classes...
Definition: HUtility.h:792
Definition: HUtility.h:2141
static const float PI
default=3.1415926f
Definition: HUtility.h:796
Definition: HUtility.h:2337
Definition: HUtility.h:2362
char * m_data
actual char* to the user options
Definition: HUtility.h:727
Definition: HUtility.h:2195
Definition: HUtility.h:2185
wchar_t * m_data
actual char* to the user options
Definition: HUtility.h:2257
The HCamera class is the data type of a HOOPS Camera Attribute.
Definition: HUtility.h:541
HPoint * point_list
The list of vertices that define the shell.
Definition: HUtility.h:272
void Show()
Definition: HUtility.h:575
HPoint up_vector
The direction of up.
Definition: HUtility.h:546
bool valid
True if the object has been initialized.
Definition: HUtility.h:543
void Show_User_Options(char *list)
double y
The y-coordinate of a B-Surface vertex.
Definition: HUtility.h:595
The HShellRegion class is a simple wrapper for a shell's region.
Definition: HUtility.h:168
static bool IsSafeForSinglePrecision(int element_count, double const *elements, bool check_roundoff=false)
Definition: HUtility.h:2023
HVector * normal_list
The list of normal vectors associated with the shell.
Definition: HUtility.h:273
#define HC_KEY
HC_KEY * patharray
Array of Keys.
Definition: HUtility.h:685
The HSmartSelItem - selection item which can handle instancing.
Definition: HSelectionItem.h:187
Definition: HUtility.h:2172
void Set(int first, int second)
Definition: HUtility.h:105
class HPoint HVector
The HVector class is the data type of a three-dimensional vector.
Definition: HGlobals.h:326
void EndFaceIteration()
Definition: HUtility.h:383
float field_height
The height of the field of view.
Definition: HUtility.h:548
int len
length of key array
Definition: HUtility.h:686
int face_count
The number of faces in the shell.
Definition: HUtility.h:277
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:519
HC_KEY m_Key
The key of the shell.
Definition: HUtility.h:520
int m_plen
The number of points in the points list.
Definition: HUtility.h:513
Definition: HUtility.h:2087
The HUnicodeOptions class is a helper class which wraps up memory management for variable size Unicod...
Definition: HUtility.h:2253
double z
The z-coordinate of a B-Surface vertex.
Definition: HUtility.h:596
Definition: HUtility.h:63
The HUserOptions class is a helper class which wraps up memory management for variable size user opti...
Definition: HUtility.h:723
HPoint target
The area that the camera is directed at.
Definition: HUtility.h:545
void InvalidateCamera()
Definition: HUtility.h:557
HPolyline * m_pNextPolyline
A pointer to a single HPolyline object.
Definition: HUtility.h:614
int face_list_len
The length of the face list.
Definition: HUtility.h:275
int m_flen
The length of the face list.
Definition: HUtility.h:514
The HShellVertexData class encapsulates colormap index information associated with the vertices of a ...
Definition: HUtility.h:622
static bool IsSafeForSinglePrecision(double element, bool check_roundoff=false)
Definition: HUtility.h:2008
HPoint * m_pHPointArray
A pointer to an array of HPoint objects.
Definition: HUtility.h:613
void Show_Unicode_Options(unsigned short *options)
int GetFirst() const
Definition: HUtility.h:98
int m_totalplen
Definition: HUtility.h:527
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:865
The HBaseView class defines and manages a view of model information.
Definition: HBaseView.h:332
Definition: HUtility.h:2389
The HShell class is the data type of a HOOPS Shell.
Definition: HUtility.h:251
int m_length
length of current user option
Definition: HUtility.h:728
int * region_list
The list that defines the set of regions in the shell.
Definition: HUtility.h:280
Definition: HUtility.h:2047
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:131
int GetSecond() const
Definition: HUtility.h:100
static const float EH_Epsilon
default=0.01
Definition: HUtility.h:801
The HShellWrapper class is wraps shell information and provides methods to manipulate this informatio...
Definition: HUtility.h:288
The HShellEdge class is a simple wrapper for a shell's edge.
Definition: HUtility.h:88
HPoint position
The location of the camera.
Definition: HUtility.h:544
double x
The x-coordinate of a B-Surface vertex.
Definition: HUtility.h:594
void Set() const
Definition: HUtility.h:581
void Set(double X, double Y, double Z, double W)
Definition: HUtility.h:601
Definition: HUtility.h:2321
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:612
Definition: HUtility.h:2403
The HShowContentsWithPathType struct is used by HUtility to store a keypath.
Definition: HUtility.h:683
The HBSurfVertex class is the data type of a B-Surface vertex.
Definition: HUtility.h:591
int * face_list
The face list that defines how faces are formed in the shell.
Definition: HUtility.h:276
HC_KEY GetKey()
Definition: HUtility.h:352
HShellEdge(int iFirst=0, int iSecond=0)
Definition: HUtility.h:94
The HPolyline class is the data type for a three-dimensional polyline.
Definition: HUtility.h:609
Definition: HUtility.h:48
Definition: HUtility.h:2349
int m_length
length of current user option
Definition: HUtility.h:2258
float field_width
The width of the field of view.
Definition: HUtility.h:547
int m_totalflen
Definition: HUtility.h:525