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 #include <limits>
28 #include <cmath>
29 
30 class HBaseView;
32 class HSmartSelItem;
33 class HBaseModel;
34 
35 class HShellObject;
36 
37 
38 enum AbsoluteWindowType
39 {
40  RelativeLeft,
41  RelativeRight,
42  RelativeTop,
43  RelativeBottom,
44  NotRelative
45 };
46 
48 {
49 public:
51  {
52  nindex = -1;
53  tcindex = -1;
54  nextindex = -1;
55  }
56  int nindex;
57  int nextindex;
58  int tcindex;
59 };
60 
61 
62 class MVO_API ShellToRegionMapper
63 {
64 public:
66  void AddRegion(HC_KEY originalshell, HC_KEY newshell, int regionnum, bool check = true);
67  HC_KEY GetOriginalShell(HC_KEY newshell, int regionnum);
68  int GetRegionsFromOriginalShell(HC_KEY originalshell, HC_KEY **newshells, int &regionnum);
69  void BuildSegmentTreeRecursive(HC_KEY okey, HC_KEY nkey);
70  void MapSegmentTree(HC_KEY modelkey);
71  void AddSegmentMapping(HC_KEY originalshell, HC_KEY segmentkey);
72 
73  struct vhash_s * m_RegionToShellHash;
74  struct vhash_s * m_ShellToRegionHash;
75  struct vhash_s * m_ShellToSegmentHash;
76 
77 };
78 
79 
80 
81 
82 
84 
87 class MVO_API HShellEdge {
88 public:
93  HShellEdge(int iFirst = 0, int iSecond = 0){
94  Set(iFirst, iSecond);
95  };
97  int GetFirst() const { return m_iFirst; };
99  int GetSecond() const { return m_iSecond; };
104  void Set(int first, int second) {
105  /* first should always be < second to eliminate ambiguity. */
106  if(first < second){
107  m_iFirst = first;
108  m_iSecond = second;
109  } else {
110  m_iFirst = second;
111  m_iSecond = first;
112  }
113  };
114 
115  bool operator<(HShellEdge const & rhs) const {
116  if(m_iFirst != rhs.m_iFirst)
117  return m_iFirst < rhs.m_iFirst;
118  return m_iSecond < rhs.m_iSecond;
119  }
120 
121 private:
122  int m_iFirst;
123  int m_iSecond;
124 };
125 
127 
130 class MVO_API HShellFace{
131 public:
136  HShellFace(HShellObject const * pShell, int const iFaceIndex);
137 
139  int GetPointCount() const ;
140 
142  int GetEdgeCount() const ;
147  HShellEdge const GetEdge(int const iEdgeIndex) const;
151  void OpenEdge(int const iEdgeIndex) const;
155  void CloseEdge() const;
156 
157 private:
158  HShellObject const * m_pShell;
159  int m_iFaceIndex;
160  int m_iPointCount;
161 };
162 
164 
167 class MVO_API HShellRegion{
168 public:
173  HShellRegion(HShellObject const * pShell, int const iRegionIndex);
174  ~HShellRegion(){
175  delete [] m_pRegionFlist;
176  }
179  int GetFaceCount() const;
184  HShellFace const GetFace(int index) const;
185 
186  //void Open() const;
187  //void Close() const;
188 private:
189  HShellObject const * m_pShell;
190  int m_iRegionIndex;
191 
192  int m_iRegionFlistLength;
193  int *m_pRegionFlist;
194 };
195 
196 
198 
201 class MVO_API HShellObject {
202 public:
206  HShellObject(HC_KEY kShellKey);
207  HShellObject(HShellObject const & oShellObj);
208  ~HShellObject();
209 
214  HShellRegion const GetRegion(int const index) const;
215 
217  int GetFaceCount() const;
222  int GetFaceFlistIndex(int index) const;
223 
224  //void Open() const;
225  //void Close() const;
226 
228  HC_KEY GetKey() const ;
230  int GetFlistLen() const ;
232  int const * GetFlist() const ;
235  void GetFlist (int flist[]) const;
236 
237 private:
238  int m_iFlistLen;
239  int * m_pFlist;
240  mutable int * m_pFaceIndexes;
241 
242  HC_KEY m_kShellKey;
243 };
244 
245 
247 
250 class MVO_API HShell {
251 public:
252  HShell()
253  :point_list_len(0),
254  point_list(),
255  normal_list(),
256  face_list_len(0),
257  face_list(0),
258  face_count(0),
259  region_count(0),
260  region_list(0)
261  {}
262  ~HShell()
263  {
264  /* No need to check for null pointers. delete already does that. */
265  delete [] point_list;
266  delete [] normal_list;
267  delete [] face_list;
268  delete [] region_list;
269  }
273 
275  int *face_list;
277 
279  int *region_list;
280 };
281 
283 
287 class MVO_API HShellWrapper {
288 
289 public:
294  HShellWrapper(HC_KEY key) {
295  m_Points = 0;
296  m_Flist = 0;
297  m_VParams = 0;
298  m_VNormals = 0;
299  m_VColors = 0;
300  m_faceregion = 0;
301  m_totalnumfaceslen = 0;
302  m_numfaceslen = 0;
303  m_FNArray = 0;
304  m_faceindirect = 0;
305  Set(key);
306  }
311  m_Key = INVALID_KEY;
312  m_Points = 0;
313  m_Flist = 0;
314  m_VParams = 0;
315  m_VNormals = 0;
316  m_VColors = 0;
317  m_flen = 0;
318  m_plen = 0;
319  m_totalplen = 0;
320  m_totalflen = 0;
321  m_faceregion = 0;
322  m_totalnumfaceslen = 0;
323  m_numfaceslen = 0;
324  m_FNArray = 0;
325  m_faceindirect = 0;
326  }
327  ~HShellWrapper();
328 
339  HC_KEY Insert(int plen, HPoint points[], int flen, int flist[], HC_KEY insertkey = INVALID_KEY);
347  HC_KEY Show(int *plen, HPoint **points, int *flen, int **flist);
351  HC_KEY GetKey() { return m_Key; }
355  void TransformPoints(float matrix[]);
356 
361  HC_KEY Optimize(char *options);
367  HC_KEY Optimize2(char *options);
368 
369  void MakePolygon(int facelen, int face[], HPoint points[]);
370 
371 
374  void OpenOwnerSegment();
375 
378  void BeginFaceIteration();
379 
382  void EndFaceIteration() { ; };
383  int GetFace(int facenum, int **face);
388  int NextFace(int **face);
389 
395  void CalculateFaceCenter(int face[], int flen, HPoint *mid);
402  void AddPoints(HPoint points[], int pnum, HPoint param[] = 0, HPoint normals[] = 0, bool AddImmediately= false);
409  void AddFace(int face[], int fnum, int regionnum, HPoint points[], HPoint normals[] = 0, bool AddImediately= false);
416  void AddFaceDirect(int face[], int fnum, bool reverse = false, bool AddImmediatly= false);
423  void AddFace(HPoint points[], int fnum, bool AddImmediatly= false);
428  void Set(HC_KEY key);
435  void Regenerate(HC_KEY newowner = INVALID_KEY, bool makeSegment = true, bool regenerate = false);
440  void GrowArrays(int fnum);
446  void GrowPointArray(int fnum, bool gorwvparams = false, bool grownormals = false);
447 
448  void GrowPointArray2(int fnum, bool growparamarray = false, bool grownormalarray = false, bool growfnarray = false, bool growcolorarray = false);
449  void AddNextFaceWithDistinctNormals(HPoint const * points, HPoint const * normals, int const * face1, int const * face2, int fnum);
450  void AddNextFaceWithDistinctNormalsAndTexture(HPoint const * points, HPoint const * normals, HPoint const * texcor,int const * face1, int const *face2, int const *face3, int fnum);
451  void AddNextFaceWithDistinctNormalsAndColor(HPoint const *points, HPoint const *normals,int const *face1, int const *face2, HPoint *face3, int fnum);
452 
453 
454  void BeginAddFaces(int pnum);
455  void EndAddFaces();
456 
461  void GrowFaceArray(int fnum);
462 
464  void SubdivideOneQuadFace(int face[], HShellWrapper &wrapper, bool generateIsolines, int *facecolorlist, int &fclnum);
465 
467  void SubdivideOneQuadFace2(int face[]);
472  void SubdivideQuadFaces(bool GenerateIsolines);
473 
477  void SetVertexColors(HPoint *color);
481  void ShowVertexColors(HPoint *color);
486  void SetVertexColors(float *findex);
490  void ShowVertexColors(float *color);
496  void MakeLod(int lodnum, int percent);
502  void FindExtents(HPoint &center, HPoint &min, HPoint &max);
503  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);
504  void ReplaceWithParameters(int plen, HPoint points[], int flen, int flist[], HPoint normals[], float params[], int paranum, bool emptyshell);
505  void Replace(int plen, HPoint points[], int flen, int flist[], HPoint normals[] = 0, bool emptyshell = false);
506 
507  void SetFaceRegion(int regionnum);
508 
509  void SetEmptyShell(HC_KEY segmentkey, bool MakeSegment);
510 
511 
512  int m_plen;
513  int m_flen;
514  HPoint *m_Points;//<! The list of pointst that define the shell.
515  HPoint *m_VParams;
516  HPoint *m_VColors;
517  HPoint *m_VNormals;
518  int *m_Flist;
520 
527  int m_totalnumfaceslen;
528  int m_numfaceslen;
529  int *m_faceregion;
530  int *m_faceindirect;
531  FaceWithNormalInfo *m_FNArray;
532 
533 };
534 
535 
537 
540 class MVO_API HCamera {
541 public:
542  bool valid;
546  float field_width;
547  float field_height;
548  char projection[128];
549 
550  HCamera () {
551  projection[0] = '\0';
552  valid = false;
553  }
554 
556  inline void InvalidateCamera() { projection[0]='\0'; valid = false; }
557 
561  bool CameraDifferent(HCamera &cam);
562 
566  bool CameraDifferentByAngle(HCamera &cam);
567 
568 
571  void GetFromView(HBaseView * view);
572 
574  void Show();
575 
577  void Set() const;
578 };
579 
580 
582 
585 class MVO_API HBSurfVertex
586 {
587 public:
588  double x;
589  double y;
590  double z;
591  double w;
592 
595  inline void Set(double X, double Y, double Z, double W) { x=X, y=Y, z=Z, w=W; }
596 };
597 
599 
603 class MVO_API HPolyline
604 {
605 public:
609 };
610 
612 
616 class MVO_API HShellVertexData
617 {
618 public:
619  /* Constructor initializes this object to an invalid state. */
620  HShellVertexData():m_VertexCount(0), m_pFIndexArraySize(0), m_pFIndexArray(0), m_Key(INVALID_KEY){
621  m_sType[0] = '\0';
622  }
623 
624  /* Destructor free up the resources this object is using. */
625  ~HShellVertexData(){
626  ResetMyself();
627  }
628 
629  /* Sets the key and fills in the members with the correct data for this shell. */
630  void SetKey(HC_KEY const key);
631 
632  /* Return a const string for the type of shell. */
633  char const * const GetType() const {
634  return m_sType;
635  }
636 
637  /* Returns the vertex count for this shell. */
638  int const GetVertexCount() const {
639  return m_VertexCount;
640  }
641 
642  /* Return the key for the shell */
643  HC_KEY const GetKey() const {
644  return m_Key;
645  }
646 
647  /* Return the size the findex array */
648  int const GetFIndexDataSize() const {
649  return m_pFIndexArraySize;
650  }
651 
652  /* Returns a const array for the findex values in this shell. */
653  float const * const GetFIndexData() const {
654  return m_pFIndexArray;
655  }
656 
657  /* Returns a const array (as an argument) for the findex values in this shell.
658  Note that the array must be of the appropriate size, e.g., via a call to GetFIndexDataSize. */
659  void GetFIndexData(float data[]) const;
660 
661  void SetFIndexData(int const size, float const data[]);
662 
663 private:
664  void ResetMyself();
665 
666  int m_VertexCount;
667  int m_pFIndexArraySize;
668  float *m_pFIndexArray;
669  HC_KEY m_Key;
670  char m_sType[32];
671 };
672 
673 
675 
677 typedef struct
678 {
680  int len;
682 
683 
684 enum HWindowCorner
685 {
686  TopLeft,
687  BottomLeft,
688  BottomRight,
689  TopRight
690 };
691 
692 
693 
694 
695 
696 
697 
699 
717 class MVO_API HUserOptions
718 {
719 public:
720 
721  char * m_data;
722  int m_length;
723  bool m_valid;
724 
726  HUserOptions();
727 
729  HUserOptions(const HUserOptions& in_data);
730 
731 
733  ~HUserOptions();
734 
735 
739  bool IsValid();
740 
746  const char * Show_User_Options();
747 
753  const char * Show_One_Net_User_Option(const char * which);
754 
760  const char * Show_One_User_Option(const char * which);
761 
767  const char * Show_Net_User_Options();
768 
769 
770 private:
771 
772  void clear() {
773  delete [] m_data;
774  m_data = 0;
775  m_length = 0;
776  };
777 
778 };
779 
780 
781 
783 
786 class MVO_API HUtility
787 {
788 public:
789 #undef PI
790  static const float PI;
791 
792  enum{X, Y, Z, W};
793  enum{XY, XZ, YZ};
794 
795  static const float EH_Epsilon;
796 
797 
804  static void Order(HPoint* one, HPoint* two);
805 
812  static void Find_Relative_Path(HC_KEY from_seg_key, HC_KEY to_seg_key, char * path);
813 
817  static float GetTime();
818 
819 
824  static void ClampPointToWindow (HPoint * point);
825 
832  static HC_KEY InsertBox (HPoint const * max, HPoint const * min);
833 
841  static HC_KEY InsertWireframeBox (HPoint * max, HPoint * min);
842 
849  static void GenerateCuboidPoints (HPoint const * max, HPoint const * min, HPoint * points);
850 
862  static HC_KEY InsertRectangle (const char * seg, float x0, float y0, float x1, float y1, float z = 0.0f, bool fill = false);
863 
864 
879  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);
880 
887  static void ComputeDoublePrecisionCrossProduct(double * vector1, double * vector2, double * up);
888 
895  static double ComputeDoublePrecisionDotProduct(double * vector1, double * vector2);
896 
902  static double ComputeDoublePrecisionVectorLength(double * vector1);
903 
910  static void GetViewplaneVectors(HC_KEY segment_key, double * view, double * up);
911 
916  static void NormalizeDoublePrecisionVector(double* vector1);
917 
925  static bool PointsEqual(HPoint * point1, HPoint * point2);
926 
938  static bool CreateAxisCircle (HPoint const & center, float radius, int axis, bool convert = true);
939 
940 
947  static void RotateToVector(HPoint start, HPoint end, bool doTranslation = true);
948 
964  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);
965 
973  static void SmoothTransition(HCamera old_camera, const HCamera &new_camera, HBaseView *view);
974 
981  static bool CamerasEqual(const HCamera &camera1, const HCamera &camera2);
982 
990  static void ComputeVectorToVectorRotationMatrix(float matrix[],HPoint v1,HPoint v2);
991 
1000  static bool ExtractRGB(char *text,float &r, float &g, float &b);
1001 
1012  static void TransitionQuaternion(float quat_old[], float quat_new[], float t, float qt[]);
1013 
1019  static void MatrixToQuaternion(float matrix[], float quaternion[]);
1020 
1026  static void QuaternionToMatrix(float quaternion[], float matrix[]);
1027 
1036  static void SmoothQuaternionTransition(HBaseView *m_pView, char *old_seg, char *new_seg, int num_of_transitions);
1037 
1045  static void SmoothMatrixTransition(HBaseView *m_pView, HC_KEY seg_key, float new_matrix[]);
1046 
1056  static void MultiSmoothTransitions(HBaseView *m_pView, int num_keys, HC_KEY *seg_key, float new_matrix[], HCamera *new_camera = 0);
1057 
1063  static HPoint GetCentroid(HC_KEY seg_key);
1064 
1071  static HPoint GetTransformedCentroid(HC_KEY seg_key, float matrix[] = 0);
1072 
1080  static void URIencode(const char * in_string, MVO_POINTER_SIZED_UINT n, char * out_buffer);
1088  static void URIdecode(const char * in_string, char * out_buffer, MVO_POINTER_SIZED_UINT * n);
1089 
1098  static void GetCameraFromMatrix(float matrix[], HPoint *target, HPoint *position, HPoint *up_vector, HPoint *translation);
1099 
1108  static void GetMatrixFromCamera(HPoint target, HPoint position, HPoint up_vector, HPoint translation, float matrix[]);
1109 
1110 
1144  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,
1145  HPoint &pos, HPoint &target, HPoint &up, char * projection, double &width, double &height, double &near_limit );
1146 
1154  static bool PushAttribute(const char *attName);
1155 
1164  static void PushAttribute(const char *attName, const char *attText);
1165 
1173  static bool PopAttribute(const char *attName);
1174 
1185  static bool ModifyPushedAttribute(const char *attName, const char *newStyle);
1186 
1193  static bool ShowPushedAttribute(const char *attName, HUserOptions& attText);
1194 
1207  static void Recursive_Merge_Shells( HShell *total_info, HShell *max_info, bool do_recurse, bool delete_orig_shells = false, bool insert_null_lods = false );
1208 
1215  static HC_KEY Merge_Shells( bool do_recurse, bool delete_orig_shells = false , bool optimize_shell = true, bool generate_regions = false);
1216 
1224  static HC_KEY Merge_Shells_Generate_Regions( int num_shells, HC_KEY * shell_keys, bool delete_orig_shells = false );
1225 
1235  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 );
1236 
1244  static bool Segment_Shell_Allocate( HShell *total_info, HShell *max_info, bool do_recurse );
1245 
1253  static void Shell_Search( HShell *total_info, HShell *max_info, bool do_recurse );
1254 
1255 
1256 
1267  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);
1268 
1269 
1278  static void CountShellData(HC_KEY shell_key, int * faces, int * vertices, int * triangles, int * tristrips = 0);
1279 
1286  static void FindFileNameExtension(const char * filename_in, char * ext_out, int size = -1);
1287 
1294  static void FindFileNameExtension(__wchar_t const * const filename_in, __wchar_t * ext_out, int size = -1);
1295 #ifdef H_USHORT_OVERLOAD
1296  static void FindFileNameExtension(unsigned short const * const filename_in, unsigned short * ext_out, int size = -1){
1297  FindFileNameExtension((wchar_t const * const)filename_in, (wchar_t*)ext_out, size);
1298  }
1299 #endif
1300 
1305  static void FindUnicodeFileNameExtension(const unsigned short * filename_in, char * ext_out);
1306 
1314  static void FindFileNameAndDirectory(const char * filename_in, char * dir_out, char * filename_out);
1322  static void FindFileNameAndDirectory(__wchar_t const * filename_in, __wchar_t * dir_out, __wchar_t * filename_out);
1323 
1334  static const char* extra_pointer_format();
1338  static HC_KEY CreateScaleIndependentSegment(const char *segname, bool SetCallback = true);
1339 
1343  static HC_KEY GetScaleIndependentGeomSegmentKey(HC_KEY segkey);
1344 
1348  static void SetScaleIndependentGeomPosition(HC_KEY segkey, float x, float y, float z);
1349 
1353  static void GetScaleIndependentGeomPosition(HC_KEY segkey, float &x, float &y, float &z);
1354 
1358  static void RegisterCallbacks();
1359 
1366  static bool IsModelKey(HC_KEY modelkey, HC_KEY objectkey);
1367 
1375  static HC_KEY UserOptionExists(HC_KEY key, const char *attrib, char *result);
1376 
1393  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);
1394 
1404  static int CalculateKeyPath(HC_KEY startkey, HBaseView *view, HC_KEY *keyarray, int maxarray);
1405 
1410  static bool SegmentExists(const char *segment);
1411 
1414  static void UnsetAttributes();
1415 
1423  static int IsChildOf(HC_KEY owner, HC_KEY child, HC_KEY klist[] = 0);
1424 
1430  static bool IsIdentityMatrix(float matrix[]);
1431 
1438  static void ComputeShellNormal(HC_KEY skey, HPoint &tnormal);
1439 
1449  static HC_KEY SelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false);
1450 
1451 
1462  static HC_KEY SmartSelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false);
1463 
1464 
1471  static bool ShowOneHeuristic(const char *type, char *res = 0);
1478  static bool ShowOneRenderingOption(const char *type, char *res = 0);
1479 
1489  static float EaseInEaseOut(float t, float a, float b, float c);
1490 
1495  static void UnwindIncludes(HC_KEY &key);
1496 
1503  static void UnwindIncludes(HC_KEY &newkey, HC_KEY *keys, int count);
1504 
1505 
1512  static bool SafeSetUserOption(const char * opt);
1513 
1520  static bool SafeShowUserOption(char * opt);
1521 
1522 
1527  static void ProjectShell(HC_KEY shellkey);
1528 
1535  static HC_KEY MergeShells(HC_KEY shell1, HC_KEY shell2);
1536 
1542  static void ShowModellingMatrix(float *segment_modelling_matrix);
1543 
1550  static void ConvertLocalPixelsToLocalWindow(HBaseView * view, HPoint *in_system , HPoint *out_system = 0);
1551 
1552 
1559  static HC_KEY GrabSegment(HC_KEY key);
1560 
1565 # define MakeSegment(key) GrabSegment(key)
1566 
1572  static void RenameSegment(HC_KEY segkey, const char *newname);
1573 
1574 
1585  static void InterpolateNormalAlongEdge(HPoint &p1, HPoint &n1, HPoint &p2, HPoint &n2, HPoint &p3, HPoint &n3);
1586 
1592  static void ShowNormals(HC_KEY shellkey, float normallength);
1593 
1599  static bool IsSegmentKey(HC_KEY key);
1600 
1607  static int FindContents(HC_KEY &key);
1608 
1615  static int CalculateMajorAxis(HBaseView *view);
1616 
1617 
1625  static HC_KEY FindOneObject(const char *type, bool l = 0);
1631  static void CloseAllSegments(HC_KEY endkey = INVALID_KEY);
1632 
1637  static void ReadjustTarget(HBaseView *view);
1638 
1643  static bool GetAllowAnimation(HC_KEY key);
1644 
1647  static void SuppressAnimation();
1648 
1656  static int FindFaceByIndex(int findex, int *flist, int flen);
1657 
1664  static bool ShowOneUserOption(const char *option, char *res);
1665 
1671  static HC_KEY GetNextRenumberedKey(HBaseView *view);
1672 
1678  static void NameSegments(HC_KEY &key, HBaseView *view);
1679 
1685  static void MoveToTemp(HC_KEY movekey, HC_KEY tempkey);
1686 
1697  static void ShowContentsWithPath( const char * entitytypes, struct vlist_s **ret_pathlist, bool storePath = false, bool includeIncludes = true, bool filterIncludes = true);
1698 
1699 
1705  static int ustrlen(unsigned short *text);
1706 
1716  static bool RLECompress(int const in_len,
1717  unsigned char const * const in_buf,
1718  int * out_len,
1719  unsigned char * const out_buf);
1720 
1730  static bool ZlibCompress(int const in_len,
1731  unsigned char const * const in_buf,
1732  int & out_len,
1733  unsigned char * const out_buf);
1734 
1744  static bool ZlibDecompress(int const in_len,
1745  unsigned char const * const in_buf,
1746  int & out_len,
1747  unsigned char * const out_buf);
1753  static unsigned short *uconvert(const char *text);
1754 
1765  static bool BuildIncludePath(HC_KEY objectkey, const HC_KEY *includelist, int ilength, HC_KEY *fullpath, int *fplength, HC_KEY matchkey = INVALID_KEY);
1766 
1773  static void BuildIncludePathFromSelection(HSmartSelItem *sitem, int &plen, HC_KEY *fullpath);
1774 
1775 
1784  static void MakeViewSnapshot(HBaseView * view, int width, int height, char ** data);
1785 
1791  static void MakeViewSnapshot(HBaseView * view, HC_KEY image_key);
1792 
1801  static int ConstrainToVector( const float matrix_in[], const HVector &vector, float matrix_out[]);
1802 
1810  static void Camera_To_Transform (HCamera *camera , float *pos, float projection_matrix[], float complete_matrix[]);
1821  static void LocalPixelsToWorld(HCamera *camera, bool righthanded, float xres, float yres, int xwpix, int ywpix, float result[]);
1828  static float ComputeAngleBetweenVector(HPoint p1, HPoint p2);
1829 
1830 
1836  static int strlen16( const unsigned short *p16);
1837 
1846  static void CalculateBoundingInfo(HC_KEY startkey, HPoint &min, HPoint &max, HPoint &delta, HPoint &mid);
1847 
1857  static long ClipPolygonAgainstPlane(long vertexCount, const HPoint vertex[],
1858  const float plane[], HPoint result[], bool *noCut = 0);
1859 
1866  static HFileOutputResult TwoPassPrint(const char *driver, HOutputHandlerOptions *options);
1867 
1875  static HC_KEY OpenSegmentFromKey(HC_KEY key, char *segment);
1876 
1877 
1889  static bool IsPointInsideAllEdges( const float *pt,const float points1[],
1890  int len, const int face1[], const float plane1[], float fudge );
1898  static void IntersectionLinePlane(HPoint *p1, HPoint *p2, HPlane *p, HPoint *res);
1899 
1905  static void DeleteManipulators(HC_KEY key);
1906 
1907 
1922  static void MergePointsIntoShell(int num_shell_points, HPoint plist1[], int num_shell_facelist, int flist1[],
1923  int num_merge_points, HPoint merge_points[], HPoint merge_vectors[],
1924  float tolerance, bool AddExtraPoints, int newpoints[], int *newpointslen);
1925 
1926 
1941  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);
1942 
1944  static void MergePolylines();
1945  static void CreateZebraStripeTexture(int width, int height, int stripwidth, bool horizontal, HPixelRGB colorstripes, HPixelRGB colorbackground);
1946 
1954  static void ascii_to_unicode(char const *ascii, unsigned short *unicode);
1955 
1963  static void unicode_to_ascii(unsigned short const *unicode, char *ascii);
1964 
1973  static void BatchRead(HBaseModel * model, const char * directory, const char * extension);
1974 
1982  static void AdjustPositionToPlane(HBaseView * view, HPoint &position, HPoint point_in_plane);
1983 
1992  static void CalculateCornerImagePosition(HBaseView *view, int iwidth, int iheight, HWindowCorner corner, float &posx, float &posy);
1993  static void OptimizeModelByGrid(HBaseView *view, ShellToRegionMapper *mapper);
1994  static void DecipherTextureString(char *texdef, char *Source, bool *DownSampling = 0, bool *DownSamplingSet = 0, char *ParameterizationSource = 0,
1995  char *InterpolationFilter = 0, char *DecimationFilter = 0, char *Layout = 0, char *Tiling = 0, bool *ValueScaleSet = 0,
1996  bool *ValueScale = 0, float *ValueScaleMin =0, float *ValueScaleMax = 0, char *BlendingMode = 0);
1997 
2002  static inline bool IsSafeForSinglePrecision(double element, bool check_roundoff = false) {
2003  if (std::abs(element) > (std::numeric_limits<float>::max)())
2004  return false;
2005  if (check_roundoff) {
2006  if (std::abs(element - static_cast<float>(element)) > std::numeric_limits<float>::epsilon() * 0.001 * std::abs(element))
2007  return false;
2008  }
2009  return true;
2010  }
2011 
2017  static inline bool IsSafeForSinglePrecision(int element_count, double const * elements, bool check_roundoff = false) {
2018  while (element_count-- > 0)
2019  if (!IsSafeForSinglePrecision(*elements++, check_roundoff))
2020  return false;
2021  return true;
2022  }
2023 
2024 
2025 private:
2026  static void scale_segment (HIC_Rendition *rendition,HIC_Segment_Info * geo3);
2027  static void activity_change (HIC_Segment *seg, int old_activity, int new_activity);
2028  static bool RestoreAttributeFromOption(const char *attName, HUserOptions& attText);
2029  static void ReplaceCharacter(char *text, char orig, char target);
2030  static bool SetAttribute(const char *attName, const char *attText);
2031  static bool ShowAttribute(const char *attName, char *attText);
2032  static void ShowContentsWithPathAddEntity(HC_KEY key, struct vlist_s *pathlist, int level, HC_KEY *patharray, bool storePath);
2033  static void ShowContentsWithPathRecursive(HC_KEY key, const char *entitytypes, struct vlist_s *pathlist, HC_KEY *patharray, int level, bool storePath, bool includeIncludes, bool filterIncludes);
2034  static void SubdivideOneShell(HShellWrapper &myshell, int numx, int numy, int numz, HPoint &totalmin,
2035  HPoint &totaldeltadiv, HShellWrapper *shellmatrix, HShellWrapper &leftover, float boxdiagonallength, bool DoCut, int regionnum, ShellToRegionMapper *mapper, HC_KEY newkey);
2036 
2037 
2038 };
2039 
2040 
2041 class MVO_API HQualifiedKey
2042 {
2043 public:
2044  HQualifiedKey(HC_KEY key, HC_KEY includelist[], int includelistlength)
2045  {
2046  m_Key = key;
2047  m_pIncludeList = 0;
2048  m_pIncludeList = new HC_KEY[includelistlength];
2049  for (int i = 0; i < includelistlength; i++)
2050  m_pIncludeList[i] = includelist[i];
2051  m_IncludeListLength = includelistlength;
2052  }
2053  ~HQualifiedKey()
2054  {
2055  delete [] m_pIncludeList;
2056  }
2057 
2058  long MakeHashKey()
2059  {
2060  return MakeHashKey(m_Key, m_IncludeListLength,m_pIncludeList);
2061  }
2062 
2063  static long MakeHashKey(HC_KEY key, int includelength, HC_KEY includes[])
2064  {
2065  long hashkey = static_cast<long>(key);
2066  for (int i = 0; i < includelength; i++)
2067  {
2068  hashkey += static_cast<long>(includes[i]);
2069  }
2070  return hashkey;
2071  }
2072 
2073  HC_KEY m_Key;
2074  HC_KEY * m_pIncludeList;
2075  int m_IncludeListLength;
2076 };
2077 
2078 
2079 
2080 
2081 class MVO_API HMergeShellFace
2082 {
2083 
2084 public:
2085  HMergeShellFace()
2086  {
2087  m_pChildFaces = 0;
2088  m_ChildFaceNum = 0;
2089  }
2090  ~HMergeShellFace()
2091  {
2092  if (m_pChildFaces)
2093  delete [] m_pChildFaces;
2094  if (m_pFlist)
2095  delete [] m_pFlist;
2096 
2097  }
2098  void Init(int * flist);
2099  void MakeChildFaces(int & addpoint, HPoint * points, bool AddExtraPoints, int * newpoints, int * newpointslen);
2100  void Divide(int pnum, HPoint * points);
2101 
2102  bool CheckHit(HPoint & p, HPoint & normal, HPoint * plist, HPoint & pres);
2103  HMergeShellFace * FindHitFaceRecursive(HPoint & p, HPoint & normal, HPoint * plist, HPoint & respoint);
2104  HMergeShellFace * FindHitFace(HPoint & p, HPoint & normal, HPoint * plist, HPoint & respoint)
2105  {
2106  return FindHitFaceRecursive(p, normal, plist,respoint);
2107  }
2108  bool CheckIfColinear(HPoint * point);
2109 
2110  int GetLengthRecursive(int l);
2111 
2112  int GetLength()
2113  {
2114  return GetLengthRecursive(0);
2115 
2116  }
2117 
2118  int AddToFacelistRecursive(int * start, int l);
2119 
2120  int AddToFacelist(int * start)
2121  {
2122  return AddToFacelistRecursive(start, 0);
2123 
2124  }
2125 
2126 protected:
2127  HMergeShellFace * m_pChildFaces;
2128  int m_flen;
2129  int * m_pFlist;
2130  int m_ChildFaceNum;
2131 };
2132 
2133 
2134 
2135 class MVO_API ColorPiece{
2136 
2137 public:
2138  ColorPiece(int index[], int len, int col)
2139  {
2140  m_uvindex = new int[len];
2141  m_fllen = new int[len];
2142  m_flindex = new int[len];
2143  for (int i=0;i<len;i++)
2144  m_uvindex[i] = index[i];
2145  m_len = len;
2146  m_col = col;
2147  m_done = false;
2148 
2149  }
2150  ~ColorPiece()
2151  {
2152  delete [] m_uvindex;
2153  delete [] m_fllen;
2154  delete [] m_flindex;
2155  }
2156  int *m_uvindex;
2157  int *m_fllen;
2158  int *m_flindex;
2159  int m_len;
2160  int m_col;
2161 
2162  bool m_done;
2163 
2164 };
2165 
2166 class MVO_API ColorPieceList
2167 {
2168 public:
2169  ColorPieceList();
2170  ~ColorPieceList();
2171  void AddColorPiece(int index[], int len, int col);
2172  ColorPiece * FindMatch(int col, int ii, int ii2, int &rpos, int &rlen, bool &reverse);
2173 
2174  struct vlist_s* m_ColorPieceList;
2175 
2176 
2177 };
2178 
2179 class MVO_API HVerticalUtility :
2180  public HUtility
2181 {
2182 public:
2183 
2184  static void ColorizePointCloud(HC_KEY const segment);
2185 };
2186 
2187 
2188 
2189 class MVO_API HAbsoluteWindow
2190 {
2191 public:
2192  HAbsoluteWindow(HBaseView *view, HC_KEY key,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft,
2193  AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft,
2194  AbsoluteWindowType height_type = RelativeTop, bool sb = false);
2195  HAbsoluteWindow(HBaseView *view, HC_KEY key);
2196  void DecipherOptions();
2197  void AdjustX(float invalue, AbsoluteWindowType wt, float &outvalue);
2198  void AdjustY(float invalue, AbsoluteWindowType wt, float &outvalue);
2199  bool Adjust();
2200  static void AdjustAll(HBaseView *view);
2201  static bool SetWindow(HBaseView *view,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft,
2202  AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft,
2203  AbsoluteWindowType height_type = RelativeTop, bool sb = false);
2204  bool IsPositionInWindow(float x, float y);
2205  static bool IsPositionInWindow(HBaseView *view, float x, float y);
2206  static void CalculateLocalWindowPos(HBaseView *view, float x, float y, float &xout, float &yout);
2207  void CalculateLocalWindowPos(float x, float y, float &xout, float &yout);
2208  static void CalculateOuterWindowPos(HBaseView *view, float x, float y, float &xout, float &yout);
2209  void CalculateOuterWindowPos(float x, float y, float &xout, float &yout);
2210 
2211 
2212 
2213  HBaseView *m_pView;
2214  float m_width;
2215  float m_height;
2216  float m_xpos;
2217  float m_ypos;
2218  AbsoluteWindowType m_xpos_type;
2219  AbsoluteWindowType m_ypos_type;
2220  AbsoluteWindowType m_width_type;
2221  AbsoluteWindowType m_height_type;
2222 
2223  bool m_bShowBackground;
2224 
2225  HC_KEY m_key;
2226 
2227 };
2228 
2229 
2230 
2232 
2247 class MVO_API HUnicodeOptions
2248 {
2249 public:
2250 
2251  wchar_t* m_data;
2252  int m_length;
2253  bool m_valid;
2254 
2256  HUnicodeOptions();
2257 
2259  HUnicodeOptions(const HUnicodeOptions& in_data);
2260 
2261 
2263  ~HUnicodeOptions();
2264 
2265 
2269  bool IsValid();
2270 
2275  const __wchar_t * Show_Unicode_Options();
2276 
2281  const wchar_t* Show_One_Net_Unicode_Option(const __wchar_t* which);
2282 #ifdef _MSC_VER
2283  const unsigned short * Show_One_Net_Unicode_Option(const unsigned short * which);
2284 #endif
2285 
2290  const wchar_t * Show_One_Unicode_Option(const __wchar_t * which);
2291 #ifdef _MSC_VER
2292  const unsigned short * Show_One_Unicode_Option(const unsigned short * which);
2293 #endif
2294 
2298  const __wchar_t* Show_Net_Unicode_Options();
2299 
2300 private:
2301 
2302  void clear() {
2303  delete [] m_data;
2304  m_data = 0;
2305  m_length = 0;
2306  m_valid = false;
2307  }
2308 
2309 };
2310 
2311 
2312 
2313 class BREP_Topology;
2314 
2316 {
2317 public:
2318  BREP_Edge(HC_KEY edgekey)
2319  {
2320  m_edgekey = edgekey;
2321  m_vertex1 = INVALID_KEY;
2322  m_vertex2 = INVALID_KEY;
2323  }
2324 
2325  HC_KEY m_edgekey;
2326  HC_KEY m_vertex1;
2327  HC_KEY m_vertex2;
2328 
2329 };
2330 
2332 {
2333 public:
2334  BREP_CoEdge(BREP_Edge *edge)
2335  {
2336  m_edge = edge;
2337  }
2338 
2339  BREP_Edge * m_edge;
2340 };
2341 
2342 
2343 class MVO_API BREP_Face
2344 {
2345 public:
2346  BREP_Face(HC_KEY facekey);
2347  ~BREP_Face();
2348 
2349  BREP_Edge * AddCoEdge(BREP_Topology *topol, void *edgeid, HC_KEY edgekey);
2350 
2351 
2352  struct vlist_s * m_CoEdgeList;
2353  HC_KEY m_facekey;
2354 };
2355 
2356 class MVO_API BREP_Topology
2357 {
2358 public:
2359 
2360  struct vhash_s * m_FaceHash;
2361 
2362  struct vhash_s * m_EdgeHash;
2363  struct vhash_s * m_VertexHash;
2364 
2365  BREP_Face *m_CurrentFace;
2366  BREP_Topology();
2367  ~BREP_Topology();
2368  BREP_Face *AddFace(HC_KEY facekey);
2369  BREP_Face *GetFace(HC_KEY facekey);
2370  BREP_Edge *FindEdge(void *edgeid);
2371  BREP_Edge *AddEdge(void *edgeid, HC_KEY edgekey);
2372  HC_KEY AddVertex(void *vertexid, HPoint vpos);
2373  HC_KEY FindVertex(void *vertexid);
2374 
2375 
2376 
2377  BREP_Face *GetCurrentFace() { return m_CurrentFace; }
2378 
2379 };
2380 
2381 class H_FORMAT_TEXT;
2382 
2383 class MVO_API HBestImageDriver
2384 {
2385 private:
2386  H_FORMAT_TEXT * m_dvr;
2387 public:
2388  HBestImageDriver(char const * prefer_type = 0);
2389  ~HBestImageDriver();
2390 
2391  HC_KEY GetKey() const;
2392 
2393  operator char const* () const;
2394 };
2395 
2396 
2397 class MVO_API HPVOOptions
2398 {
2399  private:
2400  void * impl;
2401 
2402  public:
2403  HPVOOptions(char const * filename);
2404  ~HPVOOptions();
2405  char const * getOption(char const * option) const;
2406 };
2407 
2408 
2409 #ifdef H_PACK_8
2410 #pragma pack(pop)
2411 #endif
2412 
2413 #endif
The HPixelRGB class is the data type of a rgb pixel.
Definition: HGlobals.h:471
HShellWrapper()
Definition: HUtility.h:310
The HShellObject class is a simple wrapper for a shell.
Definition: HUtility.h:201
int point_list_len
The length of the point list,.
Definition: HUtility.h:270
int m_facepointer
Definition: HUtility.h:522
void Show_One_User_Option(const char *type, char *value)
double w
The knot value of a B-Surface vertex.
Definition: HUtility.h:591
int region_count
The number of regions in the shell.
Definition: HUtility.h:278
HShellWrapper(HC_KEY key)
Definition: HUtility.h:294
The HUtility class contains a set of utility functions and data structures used widely in MVO classes...
Definition: HUtility.h:786
Definition: HUtility.h:2135
static const float PI
default=3.1415926f
Definition: HUtility.h:790
Definition: HUtility.h:2331
Definition: HUtility.h:2356
char * m_data
actual char* to the user options
Definition: HUtility.h:721
Definition: HUtility.h:2189
Definition: HUtility.h:2179
wchar_t * m_data
actual char* to the user options
Definition: HUtility.h:2251
The HCamera class is the data type of a HOOPS Camera Attribute.
Definition: HUtility.h:540
HPoint * point_list
The list of vertices that define the shell.
Definition: HUtility.h:271
HPoint up_vector
The direction of up.
Definition: HUtility.h:545
bool valid
True if the object has been initialized.
Definition: HUtility.h:542
void Show_User_Options(char *list)
double y
The y-coordinate of a B-Surface vertex.
Definition: HUtility.h:589
The HShellRegion class is a simple wrapper for a shell's region.
Definition: HUtility.h:167
static bool IsSafeForSinglePrecision(int element_count, double const *elements, bool check_roundoff=false)
Definition: HUtility.h:2017
HVector * normal_list
The list of normal vectors associated with the shell.
Definition: HUtility.h:272
#define HC_KEY
HC_KEY * patharray
Array of Keys.
Definition: HUtility.h:679
The HSmartSelItem - selection item which can handle instancing.
Definition: HSelectionItem.h:187
Definition: HUtility.h:2166
void Set(int first, int second)
Definition: HUtility.h:104
class HPoint HVector
The HVector class is the data type of a three-dimensional vector.
Definition: HGlobals.h:326
void EndFaceIteration()
Definition: HUtility.h:382
float field_height
The height of the field of view.
Definition: HUtility.h:547
int len
length of key array
Definition: HUtility.h:680
int face_count
The number of faces in the shell.
Definition: HUtility.h:276
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:518
HC_KEY m_Key
The key of the shell.
Definition: HUtility.h:519
int m_plen
The number of points in the points list.
Definition: HUtility.h:512
Definition: HUtility.h:2081
The HUnicodeOptions class is a helper class which wraps up memory management for variable size Unicod...
Definition: HUtility.h:2247
double z
The z-coordinate of a B-Surface vertex.
Definition: HUtility.h:590
Definition: HUtility.h:62
The HUserOptions class is a helper class which wraps up memory management for variable size user opti...
Definition: HUtility.h:717
HPoint target
The area that the camera is directed at.
Definition: HUtility.h:544
void InvalidateCamera()
Definition: HUtility.h:556
HPolyline * m_pNextPolyline
A pointer to a single HPolyline object.
Definition: HUtility.h:608
int face_list_len
The length of the face list.
Definition: HUtility.h:274
int m_flen
The length of the face list.
Definition: HUtility.h:513
The HShellVertexData class encapsulates colormap index information associated with the vertices of a ...
Definition: HUtility.h:616
static bool IsSafeForSinglePrecision(double element, bool check_roundoff=false)
Definition: HUtility.h:2002
HPoint * m_pHPointArray
A pointer to an array of HPoint objects.
Definition: HUtility.h:607
void Show_Unicode_Options(unsigned short *options)
int GetFirst() const
Definition: HUtility.h:97
int m_totalplen
Definition: HUtility.h:526
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:2383
The HShell class is the data type of a HOOPS Shell.
Definition: HUtility.h:250
int m_length
length of current user option
Definition: HUtility.h:722
int * region_list
The list that defines the set of regions in the shell.
Definition: HUtility.h:279
Definition: HUtility.h:2041
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:130
int GetSecond() const
Definition: HUtility.h:99
static const float EH_Epsilon
default=0.01
Definition: HUtility.h:795
The HShellWrapper class is wraps shell information and provides methods to manipulate this informatio...
Definition: HUtility.h:287
The HShellEdge class is a simple wrapper for a shell's edge.
Definition: HUtility.h:87
HPoint position
The location of the camera.
Definition: HUtility.h:543
double x
The x-coordinate of a B-Surface vertex.
Definition: HUtility.h:588
void Set(double X, double Y, double Z, double W)
Definition: HUtility.h:595
Definition: HUtility.h:2315
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:606
Definition: HUtility.h:2397
The HShowContentsWithPathType struct is used by HUtility to store a keypath.
Definition: HUtility.h:677
The HBSurfVertex class is the data type of a B-Surface vertex.
Definition: HUtility.h:585
int * face_list
The face list that defines how faces are formed in the shell.
Definition: HUtility.h:275
HC_KEY GetKey()
Definition: HUtility.h:351
HShellEdge(int iFirst=0, int iSecond=0)
Definition: HUtility.h:93
The HPolyline class is the data type for a three-dimensional polyline.
Definition: HUtility.h:603
Definition: HUtility.h:47
Definition: HUtility.h:2343
int m_length
length of current user option
Definition: HUtility.h:2252
float field_width
The width of the field of view.
Definition: HUtility.h:546
int m_totalflen
Definition: HUtility.h:524