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 #include <cmath>
31 
32 class HBaseView;
34 class HSmartSelItem;
35 class HBaseModel;
36 
37 class HShellObject;
38 
39 
40 enum AbsoluteWindowType
41 {
42  RelativeLeft,
43  RelativeRight,
44  RelativeTop,
45  RelativeBottom,
46  NotRelative
47 };
48 
50 {
51 public:
53  {
54  nindex = -1;
55  tcindex = -1;
56  nextindex = -1;
57  }
58  int nindex;
59  int nextindex;
60  int tcindex;
61 };
62 
63 
64 class MVO_API ShellToRegionMapper
65 {
66 public:
68  void AddRegion(HC_KEY originalshell, HC_KEY newshell, int regionnum, bool check = true);
69  HC_KEY GetOriginalShell(HC_KEY newshell, int regionnum);
70  int GetRegionsFromOriginalShell(HC_KEY originalshell, HC_KEY **newshells, int &regionnum);
71  void BuildSegmentTreeRecursive(HC_KEY okey, HC_KEY nkey);
72  void MapSegmentTree(HC_KEY modelkey);
73  void AddSegmentMapping(HC_KEY originalshell, HC_KEY segmentkey);
74 
75  struct vhash_s * m_RegionToShellHash;
76  struct vhash_s * m_ShellToRegionHash;
77  struct vhash_s * m_ShellToSegmentHash;
78 
79 };
80 
81 
82 
83 
84 
86 
89 class MVO_API HShellEdge {
90 public:
95  HShellEdge(int iFirst = 0, int iSecond = 0){
96  Set(iFirst, iSecond);
97  };
99  int GetFirst() const { return m_iFirst; };
101  int GetSecond() const { return m_iSecond; };
106  void Set(int first, int second) {
107  /* first should always be < second to eliminate ambiguity. */
108  if(first < second){
109  m_iFirst = first;
110  m_iSecond = second;
111  } else {
112  m_iFirst = second;
113  m_iSecond = first;
114  }
115  };
116 
117  bool operator<(HShellEdge const & rhs) const {
118  if(m_iFirst != rhs.m_iFirst)
119  return m_iFirst < rhs.m_iFirst;
120  return m_iSecond < rhs.m_iSecond;
121  }
122 
123 private:
124  int m_iFirst;
125  int m_iSecond;
126 };
127 
129 
132 class MVO_API HShellFace{
133 public:
138  HShellFace(HShellObject const * pShell, int const iFaceIndex);
139 
141  int GetPointCount() const ;
142 
144  int GetEdgeCount() const ;
149  HShellEdge const GetEdge(int const iEdgeIndex) const;
153  void OpenEdge(int const iEdgeIndex) const;
157  void CloseEdge() const;
158 
159 private:
160  HShellObject const * m_pShell;
161  int m_iFaceIndex;
162  int m_iPointCount;
163 };
164 
166 
169 class MVO_API HShellRegion{
170 public:
175  HShellRegion(HShellObject const * pShell, int const iRegionIndex);
176  ~HShellRegion(){
177  delete [] m_pRegionFlist;
178  }
181  int GetFaceCount() const;
186  HShellFace const GetFace(int index) const;
187 
188  //void Open() const;
189  //void Close() const;
190 private:
191  HShellObject const * m_pShell;
192  int m_iRegionIndex;
193 
194  int m_iRegionFlistLength;
195  int *m_pRegionFlist;
196 };
197 
198 
200 
203 class MVO_API HShellObject {
204 public:
208  HShellObject(HC_KEY kShellKey);
209  HShellObject(HShellObject const & oShellObj);
210  ~HShellObject();
211 
216  HShellRegion const GetRegion(int const index) const;
217 
219  int GetFaceCount() const;
224  int GetFaceFlistIndex(int index) const;
225 
226  //void Open() const;
227  //void Close() const;
228 
230  HC_KEY GetKey() const ;
232  int GetFlistLen() const ;
234  int const * GetFlist() const ;
237  void GetFlist (int flist[]) const;
238 
239 private:
240  int m_iFlistLen;
241  int * m_pFlist;
242  mutable int * m_pFaceIndexes;
243 
244  HC_KEY m_kShellKey;
245 };
246 
247 
249 
252 class MVO_API HShell {
253 public:
254  HShell()
255  :point_list_len(0),
256  point_list(),
257  normal_list(),
258  face_list_len(0),
259  face_list(0),
260  face_count(0),
261  region_count(0),
262  region_list(0)
263  {}
264  ~HShell()
265  {
266  /* No need to check for null pointers. delete already does that. */
267  delete [] point_list;
268  delete [] normal_list;
269  delete [] face_list;
270  delete [] region_list;
271  }
275 
277  int *face_list;
279 
281  int *region_list;
282 };
283 
285 
289 class MVO_API HShellWrapper {
290 
291 public:
296  HShellWrapper(HC_KEY key) {
297  m_Points = 0;
298  m_Flist = 0;
299  m_VParams = 0;
300  m_VNormals = 0;
301  m_VColors = 0;
302  m_faceregion = 0;
303  m_totalnumfaceslen = 0;
304  m_numfaceslen = 0;
305  m_FNArray = 0;
306  m_faceindirect = 0;
307  Set(key);
308  }
313  m_Key = INVALID_KEY;
314  m_Points = 0;
315  m_Flist = 0;
316  m_VParams = 0;
317  m_VNormals = 0;
318  m_VColors = 0;
319  m_flen = 0;
320  m_plen = 0;
321  m_totalplen = 0;
322  m_totalflen = 0;
323  m_faceregion = 0;
324  m_totalnumfaceslen = 0;
325  m_numfaceslen = 0;
326  m_FNArray = 0;
327  m_faceindirect = 0;
328  }
329  ~HShellWrapper();
330 
341  HC_KEY Insert(int plen, HPoint points[], int flen, int flist[], HC_KEY insertkey = INVALID_KEY);
349  HC_KEY Show(int *plen, HPoint **points, int *flen, int **flist);
353  HC_KEY GetKey() { return m_Key; }
357  void TransformPoints(float matrix[]);
358 
363  HC_KEY Optimize(char *options);
369  HC_KEY Optimize2(char *options);
370 
371  void MakePolygon(int facelen, int face[], HPoint points[]);
372 
373 
376  void OpenOwnerSegment();
377 
380  void BeginFaceIteration();
381 
384  void EndFaceIteration() { ; };
385  int GetFace(int facenum, int **face);
390  int NextFace(int **face);
391 
397  void CalculateFaceCenter(int face[], int flen, HPoint *mid);
404  void AddPoints(HPoint points[], int pnum, HPoint param[] = 0, HPoint normals[] = 0, bool AddImmediately= false);
411  void AddFace(int face[], int fnum, int regionnum, HPoint points[], HPoint normals[] = 0, bool AddImediately= false);
418  void AddFaceDirect(int face[], int fnum, bool reverse = false, bool AddImmediatly= false);
425  void AddFace(HPoint points[], int fnum, bool AddImmediatly= false);
430  void Set(HC_KEY key);
437  void Regenerate(HC_KEY newowner = INVALID_KEY, bool makeSegment = true, bool regenerate = false);
442  void GrowArrays(int fnum);
448  void GrowPointArray(int fnum, bool gorwvparams = false, bool grownormals = false);
449 
450  void GrowPointArray2(int fnum, bool growparamarray = false, bool grownormalarray = false, bool growfnarray = false, bool growcolorarray = false);
451  void AddNextFaceWithDistinctNormals(HPoint const * points, HPoint const * normals, int const * face1, int const * face2, int fnum);
452  void AddNextFaceWithDistinctNormalsAndTexture(HPoint const * points, HPoint const * normals, HPoint const * texcor,int const * face1, int const *face2, int const *face3, int fnum);
453  void AddNextFaceWithDistinctNormalsAndColor(HPoint const *points, HPoint const *normals,int const *face1, int const *face2, HPoint *face3, int fnum);
454 
455 
456  void BeginAddFaces(int pnum);
457  void EndAddFaces();
458 
463  void GrowFaceArray(int fnum);
464 
466  void SubdivideOneQuadFace(int face[], HShellWrapper &wrapper, bool generateIsolines, int *facecolorlist, int &fclnum);
467 
469  void SubdivideOneQuadFace2(int face[]);
474  void SubdivideQuadFaces(bool GenerateIsolines);
475 
479  void SetVertexColors(HPoint *color);
483  void ShowVertexColors(HPoint *color);
488  void SetVertexColors(float *findex);
492  void ShowVertexColors(float *color);
498  void MakeLod(int lodnum, int percent);
504  void FindExtents(HPoint &center, HPoint &min, HPoint &max);
505  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);
506  void ReplaceWithParameters(int plen, HPoint points[], int flen, int flist[], HPoint normals[], float params[], int paranum, bool emptyshell);
507  void Replace(int plen, HPoint points[], int flen, int flist[], HPoint normals[] = 0, bool emptyshell = false);
508 
509  void SetFaceRegion(int regionnum);
510 
511  void SetEmptyShell(HC_KEY segmentkey, bool MakeSegment);
512 
513 
514  int m_plen;
515  int m_flen;
516  HPoint *m_Points;//<! The list of pointst that define the shell.
517  HPoint *m_VParams;
518  HPoint *m_VColors;
519  HPoint *m_VNormals;
520  int *m_Flist;
522 
529  int m_totalnumfaceslen;
530  int m_numfaceslen;
531  int *m_faceregion;
532  int *m_faceindirect;
533  FaceWithNormalInfo *m_FNArray;
534 
535 };
536 
537 
539 
542 class MVO_API HCamera {
543 public:
544  bool valid;
548  float field_width;
549  float field_height;
550  char projection[128];
551 
552  HCamera () {
553  projection[0] = '\0';
554  valid = false;
555  }
556 
558  inline void InvalidateCamera() { projection[0]='\0'; valid = false; }
559 
563  bool CameraDifferent(HCamera &cam);
564 
568  bool CameraDifferentByAngle(HCamera &cam);
569 
570 
573  void GetFromView(HBaseView * view);
574 
576  void Show();
577 
579  void Set() const;
580 };
581 
582 
584 
587 class MVO_API HBSurfVertex
588 {
589 public:
590  double x;
591  double y;
592  double z;
593  double w;
594 
597  inline void Set(double X, double Y, double Z, double W) { x=X, y=Y, z=Z, w=W; }
598 };
599 
601 
605 class MVO_API HPolyline
606 {
607 public:
611 };
612 
614 
618 class MVO_API HShellVertexData
619 {
620 public:
621  /* Constructor initializes this object to an invalid state. */
622  HShellVertexData():m_VertexCount(0), m_pFIndexArraySize(0), m_pFIndexArray(0), m_Key(INVALID_KEY){
623  m_sType[0] = '\0';
624  }
625 
626  /* Destructor free up the resources this object is using. */
627  ~HShellVertexData(){
628  ResetMyself();
629  }
630 
631  /* Sets the key and fills in the members with the correct data for this shell. */
632  void SetKey(HC_KEY const key);
633 
634  /* Return a const string for the type of shell. */
635  char const * const GetType() const {
636  return m_sType;
637  }
638 
639  /* Returns the vertex count for this shell. */
640  int const GetVertexCount() const {
641  return m_VertexCount;
642  }
643 
644  /* Return the key for the shell */
645  HC_KEY const GetKey() const {
646  return m_Key;
647  }
648 
649  /* Return the size the findex array */
650  int const GetFIndexDataSize() const {
651  return m_pFIndexArraySize;
652  }
653 
654  /* Returns a const array for the findex values in this shell. */
655  float const * const GetFIndexData() const {
656  return m_pFIndexArray;
657  }
658 
659  /* Returns a const array (as an argument) for the findex values in this shell.
660  Note that the array must be of the appropriate size, e.g., via a call to GetFIndexDataSize. */
661  void GetFIndexData(float data[]) const;
662 
663  void SetFIndexData(int const size, float const data[]);
664 
665 private:
666  void ResetMyself();
667 
668  int m_VertexCount;
669  int m_pFIndexArraySize;
670  float *m_pFIndexArray;
671  HC_KEY m_Key;
672  char m_sType[32];
673 };
674 
675 
677 
679 typedef struct
680 {
682  int len;
684 
685 
686 enum HWindowCorner
687 {
688  TopLeft,
689  BottomLeft,
690  BottomRight,
691  TopRight
692 };
693 
694 
695 
696 
697 
698 
699 
701 
719 class MVO_API HUserOptions
720 {
721 public:
722 
723  char * m_data;
724  int m_length;
725  bool m_valid;
726 
728  HUserOptions();
729 
731  HUserOptions(const HUserOptions& in_data);
732 
733 
735  ~HUserOptions();
736 
737 
741  bool IsValid();
742 
748  const char * Show_User_Options();
749 
755  const char * Show_One_Net_User_Option(const char * which);
756 
762  const char * Show_One_User_Option(const char * which);
763 
769  const char * Show_Net_User_Options();
770 
771 
772 private:
773 
774  void clear() {
775  delete [] m_data;
776  m_data = 0;
777  m_length = 0;
778  };
779 
780 };
781 
782 
783 
785 
788 class MVO_API HUtility
789 {
790 public:
791 #undef PI
792  static const float PI;
793 
794  enum{X, Y, Z, W};
795  enum{XY, XZ, YZ};
796 
797  static const float EH_Epsilon;
798 
799 
806  static void Order(HPoint* one, HPoint* two);
807 
814  static void Find_Relative_Path(HC_KEY from_seg_key, HC_KEY to_seg_key, char * path);
815 
819  static float GetTime();
820 
821 
826  static void ClampPointToWindow (HPoint * point);
827 
834  static HC_KEY InsertBox (HPoint const * max, HPoint const * min);
835 
843  static HC_KEY InsertWireframeBox (HPoint * max, HPoint * min);
844 
851  static void GenerateCuboidPoints (HPoint const * max, HPoint const * min, HPoint * points);
852 
864  static HC_KEY InsertRectangle (const char * seg, float x0, float y0, float x1, float y1, float z = 0.0f, bool fill = false);
865 
866 
881  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);
882 
889  static void ComputeDoublePrecisionCrossProduct(double * vector1, double * vector2, double * up);
890 
897  static double ComputeDoublePrecisionDotProduct(double * vector1, double * vector2);
898 
904  static double ComputeDoublePrecisionVectorLength(double * vector1);
905 
912  static void GetViewplaneVectors(HC_KEY segment_key, double * view, double * up);
913 
918  static void NormalizeDoublePrecisionVector(double* vector1);
919 
927  static bool PointsEqual(HPoint * point1, HPoint * point2);
928 
940  static bool CreateAxisCircle (HPoint const & center, float radius, int axis, bool convert = true);
941 
942 
949  static void RotateToVector(HPoint start, HPoint end, bool doTranslation = true);
950 
966  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);
967 
975  static void SmoothTransition(HCamera old_camera, const HCamera &new_camera, HBaseView *view);
976 
983  static bool CamerasEqual(const HCamera &camera1, const HCamera &camera2);
984 
992  static void ComputeVectorToVectorRotationMatrix(float matrix[],HPoint v1,HPoint v2);
993 
1002  static bool ExtractRGB(char *text,float &r, float &g, float &b);
1003 
1014  static void TransitionQuaternion(float quat_old[], float quat_new[], float t, float qt[]);
1015 
1021  static void MatrixToQuaternion(float matrix[], float quaternion[]);
1022 
1028  static void QuaternionToMatrix(float quaternion[], float matrix[]);
1029 
1038  static void SmoothQuaternionTransition(HBaseView *m_pView, char *old_seg, char *new_seg, int num_of_transitions);
1039 
1047  static void SmoothMatrixTransition(HBaseView *m_pView, HC_KEY seg_key, float new_matrix[]);
1048 
1058  static void MultiSmoothTransitions(HBaseView *m_pView, int num_keys, HC_KEY *seg_key, float new_matrix[], HCamera *new_camera = 0);
1059 
1065  static HPoint GetCentroid(HC_KEY seg_key);
1066 
1073  static HPoint GetTransformedCentroid(HC_KEY seg_key, float matrix[] = 0);
1074 
1082  static void URIencode(const char * in_string, MVO_POINTER_SIZED_UINT n, char * out_buffer);
1090  static void URIdecode(const char * in_string, char * out_buffer, MVO_POINTER_SIZED_UINT * n);
1091 
1100  static void GetCameraFromMatrix(float matrix[], HPoint *target, HPoint *position, HPoint *up_vector, HPoint *translation);
1101 
1110  static void GetMatrixFromCamera(HPoint target, HPoint position, HPoint up_vector, HPoint translation, float matrix[]);
1111 
1112 
1146  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,
1147  HPoint &pos, HPoint &target, HPoint &up, char * projection, double &width, double &height, double &near_limit );
1148 
1156  static bool PushAttribute(const char *attName);
1157 
1166  static void PushAttribute(const char *attName, const char *attText);
1167 
1175  static bool PopAttribute(const char *attName);
1176 
1187  static bool ModifyPushedAttribute(const char *attName, const char *newStyle);
1188 
1195  static bool ShowPushedAttribute(const char *attName, HUserOptions& attText);
1196 
1209  static void Recursive_Merge_Shells( HShell *total_info, HShell *max_info, bool do_recurse, bool delete_orig_shells = false, bool insert_null_lods = false );
1210 
1217  static HC_KEY Merge_Shells( bool do_recurse, bool delete_orig_shells = false , bool optimize_shell = true, bool generate_regions = false);
1218 
1226  static HC_KEY Merge_Shells_Generate_Regions( int num_shells, HC_KEY * shell_keys, bool delete_orig_shells = false );
1227 
1237  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 );
1238 
1246  static bool Segment_Shell_Allocate( HShell *total_info, HShell *max_info, bool do_recurse );
1247 
1255  static void Shell_Search( HShell *total_info, HShell *max_info, bool do_recurse );
1256 
1257 
1258 
1269  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);
1270 
1271 
1280  static void CountShellData(HC_KEY shell_key, int * faces, int * vertices, int * triangles, int * tristrips = 0);
1281 
1288  static void FindFileNameExtension(const char * filename_in, char * ext_out, int size = -1);
1289 
1296  static void FindFileNameExtension(__wchar_t const * const filename_in, __wchar_t * ext_out, int size = -1);
1297 #ifdef H_USHORT_OVERLOAD
1298  static void FindFileNameExtension(unsigned short const * const filename_in, unsigned short * ext_out, int size = -1){
1299  FindFileNameExtension((wchar_t const * const)filename_in, (wchar_t*)ext_out, size);
1300  }
1301 #endif
1302 
1307  static void FindUnicodeFileNameExtension(const unsigned short * filename_in, char * ext_out);
1308 
1316  static void FindFileNameAndDirectory(const char * filename_in, char * dir_out, char * filename_out);
1324  static void FindFileNameAndDirectory(__wchar_t const * filename_in, __wchar_t * dir_out, __wchar_t * filename_out);
1325 
1336  static const char* extra_pointer_format();
1340  static HC_KEY CreateScaleIndependentSegment(const char *segname, bool SetCallback = true);
1341 
1345  static HC_KEY GetScaleIndependentGeomSegmentKey(HC_KEY segkey);
1346 
1350  static void SetScaleIndependentGeomPosition(HC_KEY segkey, float x, float y, float z);
1351 
1355  static void GetScaleIndependentGeomPosition(HC_KEY segkey, float &x, float &y, float &z);
1356 
1360  static void RegisterCallbacks();
1361 
1368  static bool IsModelKey(HC_KEY modelkey, HC_KEY objectkey);
1369 
1377  static HC_KEY UserOptionExists(HC_KEY key, const char *attrib, char *result);
1378 
1395  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);
1396 
1406  static int CalculateKeyPath(HC_KEY startkey, HBaseView *view, HC_KEY *keyarray, int maxarray);
1407 
1412  static bool SegmentExists(const char *segment);
1413 
1416  static void UnsetAttributes();
1417 
1425  static int IsChildOf(HC_KEY owner, HC_KEY child, HC_KEY klist[] = 0);
1426 
1432  static bool IsIdentityMatrix(float matrix[]);
1433 
1440  static void ComputeShellNormal(HC_KEY skey, HPoint &tnormal);
1441 
1451  static HC_KEY SelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false);
1452 
1453 
1464  static HC_KEY SmartSelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false);
1465 
1466 
1473  static bool ShowOneHeuristic(const char *type, char *res = 0);
1480  static bool ShowOneRenderingOption(const char *type, char *res = 0);
1481 
1491  static float EaseInEaseOut(float t, float a, float b, float c);
1492 
1497  static void UnwindIncludes(HC_KEY &key);
1498 
1505  static void UnwindIncludes(HC_KEY &newkey, HC_KEY *keys, int count);
1506 
1507 
1514  static bool SafeSetUserOption(const char * opt);
1515 
1522  static bool SafeShowUserOption(char * opt);
1523 
1524 
1529  static void ProjectShell(HC_KEY shellkey);
1530 
1537  static HC_KEY MergeShells(HC_KEY shell1, HC_KEY shell2);
1538 
1544  static void ShowModellingMatrix(float *segment_modelling_matrix);
1545 
1552  static void ConvertLocalPixelsToLocalWindow(HBaseView * view, HPoint *in_system , HPoint *out_system = 0);
1553 
1554 
1561  static HC_KEY GrabSegment(HC_KEY key);
1562 
1567 # define MakeSegment(key) GrabSegment(key)
1568 
1574  static void RenameSegment(HC_KEY segkey, const char *newname);
1575 
1576 
1587  static void InterpolateNormalAlongEdge(HPoint &p1, HPoint &n1, HPoint &p2, HPoint &n2, HPoint &p3, HPoint &n3);
1588 
1594  static void ShowNormals(HC_KEY shellkey, float normallength);
1595 
1601  static bool IsSegmentKey(HC_KEY key);
1602 
1609  static int FindContents(HC_KEY &key);
1610 
1617  static int CalculateMajorAxis(HBaseView *view);
1618 
1619 
1627  static HC_KEY FindOneObject(const char *type, bool l = 0);
1633  static void CloseAllSegments(HC_KEY endkey = INVALID_KEY);
1634 
1639  static void ReadjustTarget(HBaseView *view);
1640 
1645  static bool GetAllowAnimation(HC_KEY key);
1646 
1649  static void SuppressAnimation();
1650 
1658  static int FindFaceByIndex(int findex, int *flist, int flen);
1659 
1666  static bool ShowOneUserOption(const char *option, char *res);
1667 
1673  static HC_KEY GetNextRenumberedKey(HBaseView *view);
1674 
1680  static void NameSegments(HC_KEY &key, HBaseView *view);
1681 
1687  static void MoveToTemp(HC_KEY movekey, HC_KEY tempkey);
1688 
1699  static void ShowContentsWithPath( const char * entitytypes, struct vlist_s **ret_pathlist, bool storePath = false, bool includeIncludes = true, bool filterIncludes = true);
1700 
1701 
1707  static int ustrlen(unsigned short *text);
1708 
1718  static bool RLECompress(int const in_len,
1719  unsigned char const * const in_buf,
1720  int * out_len,
1721  unsigned char * const out_buf);
1722 
1732  static bool ZlibCompress(int const in_len,
1733  unsigned char const * const in_buf,
1734  int & out_len,
1735  unsigned char * const out_buf);
1736 
1746  static bool ZlibDecompress(int const in_len,
1747  unsigned char const * const in_buf,
1748  int & out_len,
1749  unsigned char * const out_buf);
1755  static unsigned short *uconvert(const char *text);
1756 
1767  static bool BuildIncludePath(HC_KEY objectkey, const HC_KEY *includelist, int ilength, HC_KEY *fullpath, int *fplength, HC_KEY matchkey = INVALID_KEY);
1768 
1775  static void BuildIncludePathFromSelection(HSmartSelItem *sitem, int &plen, HC_KEY *fullpath);
1776 
1777 
1786  static void MakeViewSnapshot(HBaseView * view, int width, int height, char ** data);
1787 
1793  static void MakeViewSnapshot(HBaseView * view, HC_KEY image_key);
1794 
1803  static int ConstrainToVector( const float matrix_in[], const HVector &vector, float matrix_out[]);
1804 
1812  static void Camera_To_Transform (HCamera *camera , float *pos, float projection_matrix[], float complete_matrix[]);
1823  static void LocalPixelsToWorld(HCamera *camera, bool righthanded, float xres, float yres, int xwpix, int ywpix, float result[]);
1830  static float ComputeAngleBetweenVector(HPoint p1, HPoint p2);
1831 
1832 
1838  static int strlen16( const unsigned short *p16);
1839 
1848  static void CalculateBoundingInfo(HC_KEY startkey, HPoint &min, HPoint &max, HPoint &delta, HPoint &mid);
1849 
1859  static long ClipPolygonAgainstPlane(long vertexCount, const HPoint vertex[],
1860  const float plane[], HPoint result[], bool *noCut = 0);
1861 
1868  static HFileOutputResult TwoPassPrint(const char *driver, HOutputHandlerOptions *options);
1869 
1877  static HC_KEY OpenSegmentFromKey(HC_KEY key, char *segment);
1878 
1879 
1891  static bool IsPointInsideAllEdges( const float *pt,const float points1[],
1892  int len, const int face1[], const float plane1[], float fudge );
1900  static void IntersectionLinePlane(HPoint *p1, HPoint *p2, HPlane *p, HPoint *res);
1901 
1907  static void DeleteManipulators(HC_KEY key);
1908 
1909 
1924  static void MergePointsIntoShell(int num_shell_points, HPoint plist1[], int num_shell_facelist, int flist1[],
1925  int num_merge_points, HPoint merge_points[], HPoint merge_vectors[],
1926  float tolerance, bool AddExtraPoints, int newpoints[], int *newpointslen);
1927 
1928 
1943  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);
1944 
1946  static void MergePolylines();
1947  static void CreateZebraStripeTexture(int width, int height, int stripwidth, bool horizontal, HPixelRGB colorstripes, HPixelRGB colorbackground);
1948 
1956  static void ascii_to_unicode(char const *ascii, unsigned short *unicode);
1957 
1965  static void unicode_to_ascii(unsigned short const *unicode, char *ascii);
1966 
1975  static void BatchRead(HBaseModel * model, const char * directory, const char * extension);
1976 
1984  static void AdjustPositionToPlane(HBaseView * view, HPoint &position, HPoint point_in_plane);
1985 
1994  static void CalculateCornerImagePosition(HBaseView *view, int iwidth, int iheight, HWindowCorner corner, float &posx, float &posy);
1995  static void OptimizeModelByGrid(HBaseView *view, ShellToRegionMapper *mapper);
1996  static void DecipherTextureString(char *texdef, char *Source, bool *DownSampling = 0, bool *DownSamplingSet = 0, char *ParameterizationSource = 0,
1997  char *InterpolationFilter = 0, char *DecimationFilter = 0, char *Layout = 0, char *Tiling = 0, bool *ValueScaleSet = 0,
1998  bool *ValueScale = 0, float *ValueScaleMin =0, float *ValueScaleMax = 0, char *BlendingMode = 0);
1999 
2004  static inline bool IsSafeForSinglePrecision(double element, bool check_roundoff = false) {
2005  if (std::abs(element) > std::numeric_limits<float>::max())
2006  return false;
2007  if (check_roundoff) {
2008  if (std::abs(element - static_cast<float>(element)) > std::numeric_limits<float>::epsilon() * 0.001 * std::abs(element))
2009  return false;
2010  }
2011  return true;
2012  }
2013 
2019  static inline bool IsSafeForSinglePrecision(int element_count, double const * elements, bool check_roundoff = false) {
2020  while (element_count-- > 0)
2021  if (!IsSafeForSinglePrecision(*elements++, check_roundoff))
2022  return false;
2023  return true;
2024  }
2025 
2026 
2027 private:
2028  static void scale_segment (HIC_Rendition *rendition,HIC_Segment_Info * geo3);
2029  static void activity_change (HIC_Segment *seg, int old_activity, int new_activity);
2030  static bool RestoreAttributeFromOption(const char *attName, HUserOptions& attText);
2031  static void ReplaceCharacter(char *text, char orig, char target);
2032  static bool SetAttribute(const char *attName, const char *attText);
2033  static bool ShowAttribute(const char *attName, char *attText);
2034  static void ShowContentsWithPathAddEntity(HC_KEY key, struct vlist_s *pathlist, int level, HC_KEY *patharray, bool storePath);
2035  static void ShowContentsWithPathRecursive(HC_KEY key, const char *entitytypes, struct vlist_s *pathlist, HC_KEY *patharray, int level, bool storePath, bool includeIncludes, bool filterIncludes);
2036  static void SubdivideOneShell(HShellWrapper &myshell, int numx, int numy, int numz, HPoint &totalmin,
2037  HPoint &totaldeltadiv, HShellWrapper *shellmatrix, HShellWrapper &leftover, float boxdiagonallength, bool DoCut, int regionnum, ShellToRegionMapper *mapper, HC_KEY newkey);
2038 
2039 
2040 };
2041 
2042 
2043 class MVO_API HQualifiedKey
2044 {
2045 public:
2046  HQualifiedKey(HC_KEY key, HC_KEY includelist[], int includelistlength)
2047  {
2048  m_Key = key;
2049  m_pIncludeList = 0;
2050  m_pIncludeList = new HC_KEY[includelistlength];
2051  for (int i = 0; i < includelistlength; i++)
2052  m_pIncludeList[i] = includelist[i];
2053  m_IncludeListLength = includelistlength;
2054  }
2055  ~HQualifiedKey()
2056  {
2057  delete [] m_pIncludeList;
2058  }
2059 
2060  long MakeHashKey()
2061  {
2062  return MakeHashKey(m_Key, m_IncludeListLength,m_pIncludeList);
2063  }
2064 
2065  static long MakeHashKey(HC_KEY key, int includelength, HC_KEY includes[])
2066  {
2067  long hashkey = static_cast<long>(key);
2068  for (int i = 0; i < includelength; i++)
2069  {
2070  hashkey += static_cast<long>(includes[i]);
2071  }
2072  return hashkey;
2073  }
2074 
2075  HC_KEY m_Key;
2076  HC_KEY * m_pIncludeList;
2077  int m_IncludeListLength;
2078 };
2079 
2080 
2081 
2082 
2083 class MVO_API HMergeShellFace
2084 {
2085 
2086 public:
2087  HMergeShellFace()
2088  {
2089  m_pChildFaces = 0;
2090  m_ChildFaceNum = 0;
2091  }
2092  ~HMergeShellFace()
2093  {
2094  if (m_pChildFaces)
2095  delete [] m_pChildFaces;
2096  if (m_pFlist)
2097  delete [] m_pFlist;
2098 
2099  }
2100  void Init(int * flist);
2101  void MakeChildFaces(int & addpoint, HPoint * points, bool AddExtraPoints, int * newpoints, int * newpointslen);
2102  void Divide(int pnum, HPoint * points);
2103 
2104  bool CheckHit(HPoint & p, HPoint & normal, HPoint * plist, HPoint & pres);
2105  HMergeShellFace * FindHitFaceRecursive(HPoint & p, HPoint & normal, HPoint * plist, HPoint & respoint);
2106  HMergeShellFace * FindHitFace(HPoint & p, HPoint & normal, HPoint * plist, HPoint & respoint)
2107  {
2108  return FindHitFaceRecursive(p, normal, plist,respoint);
2109  }
2110  bool CheckIfColinear(HPoint * point);
2111 
2112  int GetLengthRecursive(int l);
2113 
2114  int GetLength()
2115  {
2116  return GetLengthRecursive(0);
2117 
2118  }
2119 
2120  int AddToFacelistRecursive(int * start, int l);
2121 
2122  int AddToFacelist(int * start)
2123  {
2124  return AddToFacelistRecursive(start, 0);
2125 
2126  }
2127 
2128 protected:
2129  HMergeShellFace * m_pChildFaces;
2130  int m_flen;
2131  int * m_pFlist;
2132  int m_ChildFaceNum;
2133 };
2134 
2135 
2136 
2137 class MVO_API ColorPiece{
2138 
2139 public:
2140  ColorPiece(int index[], int len, int col)
2141  {
2142  m_uvindex = new int[len];
2143  m_fllen = new int[len];
2144  m_flindex = new int[len];
2145  for (int i=0;i<len;i++)
2146  m_uvindex[i] = index[i];
2147  m_len = len;
2148  m_col = col;
2149  m_done = false;
2150 
2151  }
2152  ~ColorPiece()
2153  {
2154  delete [] m_uvindex;
2155  delete [] m_fllen;
2156  delete [] m_flindex;
2157  }
2158  int *m_uvindex;
2159  int *m_fllen;
2160  int *m_flindex;
2161  int m_len;
2162  int m_col;
2163 
2164  bool m_done;
2165 
2166 };
2167 
2168 class MVO_API ColorPieceList
2169 {
2170 public:
2171  ColorPieceList();
2172  ~ColorPieceList();
2173  void AddColorPiece(int index[], int len, int col);
2174  ColorPiece * FindMatch(int col, int ii, int ii2, int &rpos, int &rlen, bool &reverse);
2175 
2176  struct vlist_s* m_ColorPieceList;
2177 
2178 
2179 };
2180 
2181 class MVO_API HVerticalUtility :
2182  public HUtility
2183 {
2184 public:
2185 
2186  static void ColorizePointCloud(HC_KEY const segment);
2187 };
2188 
2189 
2190 
2191 class MVO_API HAbsoluteWindow
2192 {
2193 public:
2194  HAbsoluteWindow(HBaseView *view, HC_KEY key,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft,
2195  AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft,
2196  AbsoluteWindowType height_type = RelativeTop, bool sb = false);
2197  HAbsoluteWindow(HBaseView *view, HC_KEY key);
2198  void DecipherOptions();
2199  void AdjustX(float invalue, AbsoluteWindowType wt, float &outvalue);
2200  void AdjustY(float invalue, AbsoluteWindowType wt, float &outvalue);
2201  bool Adjust();
2202  static void AdjustAll(HBaseView *view);
2203  static bool SetWindow(HBaseView *view,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft,
2204  AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft,
2205  AbsoluteWindowType height_type = RelativeTop, bool sb = false);
2206  bool IsPositionInWindow(float x, float y);
2207  static bool IsPositionInWindow(HBaseView *view, float x, float y);
2208  static void CalculateLocalWindowPos(HBaseView *view, float x, float y, float &xout, float &yout);
2209  void CalculateLocalWindowPos(float x, float y, float &xout, float &yout);
2210  static void CalculateOuterWindowPos(HBaseView *view, float x, float y, float &xout, float &yout);
2211  void CalculateOuterWindowPos(float x, float y, float &xout, float &yout);
2212 
2213 
2214 
2215  HBaseView *m_pView;
2216  float m_width;
2217  float m_height;
2218  float m_xpos;
2219  float m_ypos;
2220  AbsoluteWindowType m_xpos_type;
2221  AbsoluteWindowType m_ypos_type;
2222  AbsoluteWindowType m_width_type;
2223  AbsoluteWindowType m_height_type;
2224 
2225  bool m_bShowBackground;
2226 
2227  HC_KEY m_key;
2228 
2229 };
2230 
2231 
2232 
2234 
2249 class MVO_API HUnicodeOptions
2250 {
2251 public:
2252 
2253  wchar_t* m_data;
2254  int m_length;
2255  bool m_valid;
2256 
2258  HUnicodeOptions();
2259 
2261  HUnicodeOptions(const HUnicodeOptions& in_data);
2262 
2263 
2265  ~HUnicodeOptions();
2266 
2267 
2271  bool IsValid();
2272 
2277  const __wchar_t * Show_Unicode_Options();
2278 
2283  const wchar_t* Show_One_Net_Unicode_Option(const __wchar_t* which);
2284 #ifdef _MSC_VER
2285  const unsigned short * Show_One_Net_Unicode_Option(const unsigned short * which);
2286 #endif
2287 
2292  const wchar_t * Show_One_Unicode_Option(const __wchar_t * which);
2293 #ifdef _MSC_VER
2294  const unsigned short * Show_One_Unicode_Option(const unsigned short * which);
2295 #endif
2296 
2300  const __wchar_t* Show_Net_Unicode_Options();
2301 
2302 private:
2303 
2304  void clear() {
2305  delete [] m_data;
2306  m_data = 0;
2307  m_length = 0;
2308  m_valid = false;
2309  }
2310 
2311 };
2312 
2313 
2314 
2315 class BREP_Topology;
2316 
2318 {
2319 public:
2320  BREP_Edge(HC_KEY edgekey)
2321  {
2322  m_edgekey = edgekey;
2323  m_vertex1 = INVALID_KEY;
2324  m_vertex2 = INVALID_KEY;
2325  }
2326 
2327  HC_KEY m_edgekey;
2328  HC_KEY m_vertex1;
2329  HC_KEY m_vertex2;
2330 
2331 };
2332 
2334 {
2335 public:
2336  BREP_CoEdge(BREP_Edge *edge)
2337  {
2338  m_edge = edge;
2339  }
2340 
2341  BREP_Edge * m_edge;
2342 };
2343 
2344 
2345 class MVO_API BREP_Face
2346 {
2347 public:
2348  BREP_Face(HC_KEY facekey);
2349  ~BREP_Face();
2350 
2351  BREP_Edge * AddCoEdge(BREP_Topology *topol, void *edgeid, HC_KEY edgekey);
2352 
2353 
2354  struct vlist_s * m_CoEdgeList;
2355  HC_KEY m_facekey;
2356 };
2357 
2358 class MVO_API BREP_Topology
2359 {
2360 public:
2361 
2362  struct vhash_s * m_FaceHash;
2363 
2364  struct vhash_s * m_EdgeHash;
2365  struct vhash_s * m_VertexHash;
2366 
2367  BREP_Face *m_CurrentFace;
2368  BREP_Topology();
2369  ~BREP_Topology();
2370  BREP_Face *AddFace(HC_KEY facekey);
2371  BREP_Face *GetFace(HC_KEY facekey);
2372  BREP_Edge *FindEdge(void *edgeid);
2373  BREP_Edge *AddEdge(void *edgeid, HC_KEY edgekey);
2374  HC_KEY AddVertex(void *vertexid, HPoint vpos);
2375  HC_KEY FindVertex(void *vertexid);
2376 
2377 
2378 
2379  BREP_Face *GetCurrentFace() { return m_CurrentFace; }
2380 
2381 };
2382 
2383 class H_FORMAT_TEXT;
2384 
2385 class MVO_API HBestImageDriver
2386 {
2387 private:
2388  H_FORMAT_TEXT * m_dvr;
2389 public:
2390  HBestImageDriver(char const * prefer_type = 0);
2391  ~HBestImageDriver();
2392 
2393  HC_KEY GetKey() const;
2394 
2395  operator char const* () const;
2396 };
2397 
2398 
2399 class MVO_API HPVOOptions
2400 {
2401  private:
2402  void * impl;
2403 
2404  public:
2405  HPVOOptions(char const * filename);
2406  ~HPVOOptions();
2407  char const * getOption(char const * option) const;
2408 };
2409 
2410 
2411 #ifdef H_PACK_8
2412 #pragma pack(pop)
2413 #endif
2414 
2415 #endif
The HPixelRGB class is the data type of a rgb pixel.
Definition: HGlobals.h:471
HShellWrapper()
Definition: HUtility.h:312
The HShellObject class is a simple wrapper for a shell.
Definition: HUtility.h:203
int point_list_len
The length of the point list,.
Definition: HUtility.h:272
int m_facepointer
Definition: HUtility.h:524
void Show_One_User_Option(const char *type, char *value)
double w
The knot value of a B-Surface vertex.
Definition: HUtility.h:593
int region_count
The number of regions in the shell.
Definition: HUtility.h:280
HShellWrapper(HC_KEY key)
Definition: HUtility.h:296
The HUtility class contains a set of utility functions and data structures used widely in MVO classes...
Definition: HUtility.h:788
Definition: HUtility.h:2137
static const float PI
default=3.1415926f
Definition: HUtility.h:792
Definition: HUtility.h:2333
Definition: HUtility.h:2358
char * m_data
actual char* to the user options
Definition: HUtility.h:723
Definition: HUtility.h:2191
Definition: HUtility.h:2181
wchar_t * m_data
actual char* to the user options
Definition: HUtility.h:2253
The HCamera class is the data type of a HOOPS Camera Attribute.
Definition: HUtility.h:542
HPoint * point_list
The list of vertices that define the shell.
Definition: HUtility.h:273
HPoint up_vector
The direction of up.
Definition: HUtility.h:547
bool valid
True if the object has been initialized.
Definition: HUtility.h:544
void Show_User_Options(char *list)
double y
The y-coordinate of a B-Surface vertex.
Definition: HUtility.h:591
The HShellRegion class is a simple wrapper for a shell's region.
Definition: HUtility.h:169
static bool IsSafeForSinglePrecision(int element_count, double const *elements, bool check_roundoff=false)
Definition: HUtility.h:2019
HVector * normal_list
The list of normal vectors associated with the shell.
Definition: HUtility.h:274
#define HC_KEY
HC_KEY * patharray
Array of Keys.
Definition: HUtility.h:681
The HSmartSelItem - selection item which can handle instancing.
Definition: HSelectionItem.h:187
Definition: HUtility.h:2168
void Set(int first, int second)
Definition: HUtility.h:106
class HPoint HVector
The HVector class is the data type of a three-dimensional vector.
Definition: HGlobals.h:326
void EndFaceIteration()
Definition: HUtility.h:384
float field_height
The height of the field of view.
Definition: HUtility.h:549
int len
length of key array
Definition: HUtility.h:682
int face_count
The number of faces in the shell.
Definition: HUtility.h:278
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:520
HC_KEY m_Key
The key of the shell.
Definition: HUtility.h:521
int m_plen
The number of points in the points list.
Definition: HUtility.h:514
Definition: HUtility.h:2083
The HUnicodeOptions class is a helper class which wraps up memory management for variable size Unicod...
Definition: HUtility.h:2249
double z
The z-coordinate of a B-Surface vertex.
Definition: HUtility.h:592
Definition: HUtility.h:64
The HUserOptions class is a helper class which wraps up memory management for variable size user opti...
Definition: HUtility.h:719
HPoint target
The area that the camera is directed at.
Definition: HUtility.h:546
void InvalidateCamera()
Definition: HUtility.h:558
HPolyline * m_pNextPolyline
A pointer to a single HPolyline object.
Definition: HUtility.h:610
int face_list_len
The length of the face list.
Definition: HUtility.h:276
int m_flen
The length of the face list.
Definition: HUtility.h:515
The HShellVertexData class encapsulates colormap index information associated with the vertices of a ...
Definition: HUtility.h:618
static bool IsSafeForSinglePrecision(double element, bool check_roundoff=false)
Definition: HUtility.h:2004
HPoint * m_pHPointArray
A pointer to an array of HPoint objects.
Definition: HUtility.h:609
void Show_Unicode_Options(unsigned short *options)
int GetFirst() const
Definition: HUtility.h:99
int m_totalplen
Definition: HUtility.h:528
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:2385
The HShell class is the data type of a HOOPS Shell.
Definition: HUtility.h:252
int m_length
length of current user option
Definition: HUtility.h:724
int * region_list
The list that defines the set of regions in the shell.
Definition: HUtility.h:281
Definition: HUtility.h:2043
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:132
int GetSecond() const
Definition: HUtility.h:101
static const float EH_Epsilon
default=0.01
Definition: HUtility.h:797
The HShellWrapper class is wraps shell information and provides methods to manipulate this informatio...
Definition: HUtility.h:289
The HShellEdge class is a simple wrapper for a shell's edge.
Definition: HUtility.h:89
HPoint position
The location of the camera.
Definition: HUtility.h:545
double x
The x-coordinate of a B-Surface vertex.
Definition: HUtility.h:590
void Set(double X, double Y, double Z, double W)
Definition: HUtility.h:597
Definition: HUtility.h:2317
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:608
Definition: HUtility.h:2399
The HShowContentsWithPathType struct is used by HUtility to store a keypath.
Definition: HUtility.h:679
The HBSurfVertex class is the data type of a B-Surface vertex.
Definition: HUtility.h:587
int * face_list
The face list that defines how faces are formed in the shell.
Definition: HUtility.h:277
HC_KEY GetKey()
Definition: HUtility.h:353
HShellEdge(int iFirst=0, int iSecond=0)
Definition: HUtility.h:95
The HPolyline class is the data type for a three-dimensional polyline.
Definition: HUtility.h:605
Definition: HUtility.h:49
Definition: HUtility.h:2345
int m_length
length of current user option
Definition: HUtility.h:2254
float field_width
The width of the field of view.
Definition: HUtility.h:548
int m_totalflen
Definition: HUtility.h:526