Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HUtility.h
1 //
2 // Copyright (c) 2000 by Tech Soft 3D, LLC.
3 // The information contained herein is confidential and proprietary to
4 // Tech Soft 3D, LLC., and considered a trade secret as defined under
5 // civil and criminal statutes. Tech Soft 3D shall pursue its civil
6 // and criminal remedies in the event of unauthorized use or misappropriation
7 // of its trade secrets. Use of this information by anyone other than
8 // authorized employees of Tech Soft 3D, LLC. is granted only under a
9 // written non-disclosure agreement, expressly prescribing the scope and
10 // manner of such use.
11 //
12 // $Id: fc74c4045554924bc90f6d13d9e8b63cd26df859 $
13 //
14 
15 // HUtility.h : interface of the HUtility class
16 // Set of utility methods
17 // All methods are public and static
18 
19 
20 #ifndef _HUTILITY_H
21 #define _HUTILITY_H
22 
23 #ifdef H_PACK_8
24 #pragma pack(push)
25 #pragma pack(8)
26 #endif
27 
28 
29 #include "HTools.h"
30 #include "hic_types.h"
31 #include <vector>
32 
33 class HBaseView;
34 class HOutputHandlerOptions;
35 class HSmartSelItem;
36 class HBaseModel;
37 
38 class HShellObject;
39 
40 
41 enum AbsoluteWindowType
42 {
43  RelativeLeft,
44  RelativeRight,
45  RelativeTop,
46  RelativeBottom,
47  NotRelative
48 };
49 
51 {
52 public:
54  {
55  nindex = -1;
56  tcindex = -1;
57  nextindex = -1;
58  }
59  int nindex;
60  int nextindex;
61  int tcindex;
62 };
63 
64 
65 class MVO_API ShellToRegionMapper
66 {
67 public:
69  void AddRegion(HC_KEY originalshell, HC_KEY newshell, int regionnum, bool check = true);
70  HC_KEY GetOriginalShell(HC_KEY newshell, int regionnum);
71  int GetRegionsFromOriginalShell(HC_KEY originalshell, HC_KEY **newshells, int &regionnum);
72  void BuildSegmentTreeRecursive(HC_KEY okey, HC_KEY nkey);
73  void MapSegmentTree(HC_KEY modelkey);
74  void AddSegmentMapping(HC_KEY originalshell, HC_KEY segmentkey);
75 
76  struct vhash_s * m_RegionToShellHash;
77  struct vhash_s * m_ShellToRegionHash;
78  struct vhash_s * m_ShellToSegmentHash;
79 
80 };
81 
82 
83 
84 
85 
87 
90 class MVO_API HShellEdge {
91 public:
96  HShellEdge(int iFirst = 0, int iSecond = 0){
97  Set(iFirst, iSecond);
98  };
100  int GetFirst() const { return m_iFirst; };
102  int GetSecond() const { return m_iSecond; };
107  void Set(int first, int second) {
108  /* first should always be < second to eliminate ambiguity. */
109  if(first < second){
110  m_iFirst = first;
111  m_iSecond = second;
112  } else {
113  m_iFirst = second;
114  m_iSecond = first;
115  }
116  };
117 
118  bool operator<(HShellEdge const & rhs) const {
119  if(m_iFirst != rhs.m_iFirst)
120  return m_iFirst < rhs.m_iFirst;
121  return m_iSecond < rhs.m_iSecond;
122  }
123 
124 private:
125  int m_iFirst;
126  int m_iSecond;
127 };
128 
130 
133 class MVO_API HShellFace{
134 public:
139  HShellFace(HShellObject const * pShell, int const iFaceIndex);
140 
142  int GetPointCount() const ;
143 
145  int GetEdgeCount() const ;
150  HShellEdge const GetEdge(int const iEdgeIndex) const;
154  void OpenEdge(int const iEdgeIndex) const;
158  void CloseEdge() const;
159 
160 private:
161  HShellObject const * m_pShell;
162  int m_iFaceIndex;
163  int m_iPointCount;
164 };
165 
167 
170 class MVO_API HShellRegion{
171 public:
176  HShellRegion(HShellObject const * pShell, int const iRegionIndex);
177  ~HShellRegion(){
178  delete [] m_pRegionFlist;
179  }
182  int GetFaceCount() const;
187  HShellFace const GetFace(int index) const;
188 
189  //void Open() const;
190  //void Close() const;
191 private:
192  HShellObject const * m_pShell;
193  int m_iRegionIndex;
194 
195  int m_iRegionFlistLength;
196  int *m_pRegionFlist;
197 };
198 
199 
201 
204 class MVO_API HShellObject {
205 public:
209  HShellObject(HC_KEY kShellKey);
210  HShellObject(HShellObject const & oShellObj);
211  ~HShellObject();
212 
217  HShellRegion const GetRegion(int const index) const;
218 
220  int GetFaceCount() const;
225  int GetFaceFlistIndex(int index) const;
226 
227  //void Open() const;
228  //void Close() const;
229 
231  HC_KEY GetKey() const ;
233  int GetFlistLen() const ;
235  int const * GetFlist() const ;
238  void GetFlist (int *flist) const ;
239 
240 private:
241  int m_iFlistLen;
242  int * m_pFlist;
243  mutable int * m_pFaceIndexes;
244 
245  HC_KEY m_kShellKey;
246 };
247 
248 
250 
253 class MVO_API HShell {
254 public:
255  HShell()
256  :point_list_len(0),
257  point_list(),
258  normal_list(),
259  face_list_len(0),
260  face_list(0),
261  face_count(0),
262  region_count(0),
263  region_list(0)
264  {}
265  ~HShell()
266  {
267  /* No need to check for null pointers. delete already does that. */
268  delete [] point_list;
269  delete [] normal_list;
270  delete [] face_list;
271  delete [] region_list;
272  }
276 
278  int *face_list;
280 
282  int *region_list;
283 };
284 
286 
290 class MVO_API HShellWrapper {
291 
292 public:
297  HShellWrapper(HC_KEY key) {
298  m_Points = 0;
299  m_Flist = 0;
300  m_VParams = 0;
301  m_VNormals = 0;
302  m_VColors = 0;
303  m_faceregion = 0;
304  m_totalnumfaceslen = 0;
305  m_numfaceslen = 0;
306  m_FNArray = 0;
307  m_faceindirect = 0;
308  Set(key);
309  }
314  m_Key = INVALID_KEY;
315  m_Points = 0;
316  m_Flist = 0;
317  m_VParams = 0;
318  m_VNormals = 0;
319  m_VColors = 0;
320  m_flen = 0;
321  m_plen = 0;
322  m_totalplen = 0;
323  m_totalflen = 0;
324  m_faceregion = 0;
325  m_totalnumfaceslen = 0;
326  m_numfaceslen = 0;
327  m_FNArray = 0;
328  m_faceindirect = 0;
329  }
330  ~HShellWrapper();
331 
342  HC_KEY Insert(int plen, HPoint *points, int flen, int *flist, HC_KEY insertkey = INVALID_KEY);
350  HC_KEY Show(int *plen, HPoint **points, int *flen, int **flist);
354  HC_KEY GetKey() { return m_Key; }
358  void TransformPoints(float *matrix);
359 
364  HC_KEY Optimize(char *options);
370  HC_KEY Optimize2(char *options);
371 
372  void MakePolygon(int facelen, int *face, HPoint *points);
373 
374 
377  void OpenOwnerSegment();
378 
381  void BeginFaceIteration();
382 
385  void EndFaceIteration() { ; };
386  int GetFace(int facenum, int **face);
391  int NextFace(int **face);
392 
398  void CalculateFaceCenter(int *face, int flen, HPoint *mid);
405  void AddPoints(HPoint *points, int pnum, HPoint *param = 0, HPoint *normals = 0, bool AddImmediatly= false);
412  void AddFace(int *face, int fnum, int regionnum, HPoint *points, HPoint *normals = 0, bool AddImediatly= false);
419  void AddFaceDirect(int *face, int fnum, bool reverse = false, bool AddImmediatly= false);
426  void AddFace(HPoint *points, int fnum, bool AddImmediatly= false);
431  void Set(HC_KEY key);
438  void Regenerate(HC_KEY newowner = INVALID_KEY, bool makeSegment = true, bool regenerate = false);
443  void GrowArrays(int fnum);
449  void GrowPointArray(int fnum, bool gorwvparams = false, bool grownormals = false);
450 
451  void GrowPointArray2(int fnum, bool growparamarray = false, bool grownormalarray = false, bool growfnarray = false, bool growcolorarray = false);
452  void AddNextFaceWithDistinctNormals(HPoint const * points, HPoint const * normals, int const * face1, int const * face2, int fnum);
453  void AddNextFaceWithDistinctNormalsAndTexture(HPoint const * points, HPoint const * normals, HPoint const * texcor,int const * face1, int const *face2, int const *face3, int fnum);
454  void AddNextFaceWithDistinctNormalsAndColor(HPoint const *points, HPoint const *normals,int const *face1, int const *face2, HPoint *face3, int fnum);
455 
456 
457  void BeginAddFaces(int pnum);
458  void EndAddFaces();
459 
464  void GrowFaceArray(int fnum);
465 
467  void SubdivideOneQuadFace(int *face, HShellWrapper &wrapper, bool generateIsolines, int *facecolorlist, int &fclnum);
468 
470  void SubdivideOneQuadFace2(int *face);
475  void SubdivideQuadFaces(bool GenerateIsolines);
476 
480  void SetVertexColors(HPoint *color);
484  void ShowVertexColors(HPoint *color);
489  void SetVertexColors(float *findex);
493  void ShowVertexColors(float *color);
499  void MakeLod(int lodnum, int percent);
505  void FindExtents(HPoint &center, HPoint &min, HPoint &max);
506  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);
507  void ReplaceWithParameters(int plen, HPoint *points, int flen, int *flist, HPoint *normals, float *params, int paranum, bool emptyshell);
508  void Replace(int plen, HPoint *points, int flen, int *flist, HPoint *normals = 0, bool emptyshell = false);
509 
510  void SetFaceRegion(int regionnum);
511 
512  void SetEmptyShell(HC_KEY segmentkey, bool MakeSegment);
513 
514 
515  int m_plen;
516  int m_flen;
517  HPoint *m_Points;//<! The list of pointst that define the shell.
518  HPoint *m_VParams;
519  HPoint *m_VColors;
520  HPoint *m_VNormals;
521  int *m_Flist;
523 
530  int m_totalnumfaceslen;
531  int m_numfaceslen;
532  int *m_faceregion;
533  int *m_faceindirect;
534  FaceWithNormalInfo *m_FNArray;
535 
536 };
537 
538 
540 
543 class MVO_API HCamera {
544 public:
545  bool valid;
549  float field_width;
550  float field_height;
551  char projection[128];
552 
553  HCamera () {
554  projection[0] = '\0';
555  valid = false;
556  }
557 
559  inline void InvalidateCamera() { projection[0]='\0'; valid = false; }
560 
564  bool CameraDifferent(HCamera &cam);
565 
569  bool CameraDifferentByAngle(HCamera &cam);
570 
571 
574  void GetFromView(HBaseView * view);
575 
577  void Show() {
578  HC_Show_Camera (&position, &target, &up_vector, &field_width, &field_height, projection);
579  valid = true;
580  };
581 
583  void Set() const {
584  HC_Set_Camera (&position, &target, &up_vector, field_width, field_height, projection);
585  };
586 };
587 
588 
590 
593 class MVO_API HBSurfVertex
594 {
595 public:
596  double x;
597  double y;
598  double z;
599  double w;
600 
603  inline void Set(double X, double Y, double Z, double W) { x=X, y=Y, z=Z, w=W; }
604 };
605 
607 
611 class MVO_API HPolyline
612 {
613 public:
617 };
618 
620 
624 class MVO_API HShellVertexData
625 {
626 public:
627  /* Constructor initializes this object to an invalid state. */
628  HShellVertexData():m_VertexCount(0), m_pFIndexArraySize(0), m_pFIndexArray(0), m_Key(INVALID_KEY){
629  m_sType[0] = '\0';
630  }
631 
632  /* Destructor free up the resources this object is using. */
633  ~HShellVertexData(){
634  ResetMyself();
635  }
636 
637  /* Sets the key and fills in the members with the correct data for this shell. */
638  void SetKey(HC_KEY const key);
639 
640  /* Return a const string for the type of shell. */
641  char const * const GetType() const {
642  return m_sType;
643  }
644 
645  /* Returns the vertex count for this shell. */
646  int const GetVertexCount() const {
647  return m_VertexCount;
648  }
649 
650  /* Return the key for the shell */
651  HC_KEY const GetKey() const {
652  return m_Key;
653  }
654 
655  /* Return the size the findex array */
656  int const GetFIndexDataSize() const {
657  return m_pFIndexArraySize;
658  }
659 
660  /* Returns a const array for the findex values in this shell. */
661  float const * const GetFIndexData() const {
662  return m_pFIndexArray;
663  }
664 
665  /* Returns a const array (as an argument) for the findex values in this shell.
666  Note that the array must be of the appropriate size, e.g., via a call to GetFIndexDataSize. */
667  void GetFIndexData(float *data) const;
668 
669  void SetFIndexData(int const size, float const * const data);
670 
671 private:
672  void ResetMyself();
673 
674  int m_VertexCount;
675  int m_pFIndexArraySize;
676  float *m_pFIndexArray;
677  HC_KEY m_Key;
678  char m_sType[32];
679 };
680 
681 
683 
685 typedef struct
686 {
688  int len;
690 
691 
692 enum HWindowCorner
693 {
694  TopLeft,
695  BottomLeft,
696  BottomRight,
697  TopRight
698 };
699 
700 
701 
702 
703 
704 
705 
707 
725 class MVO_API HUserOptions
726 {
727 public:
728 
729  char * m_data;
730  int m_length;
731  bool m_valid;
732 
734  HUserOptions();
735 
737  HUserOptions(const HUserOptions& in_data);
738 
739 
741  ~HUserOptions();
742 
743 
747  bool IsValid();
748 
754  const char * Show_User_Options();
755 
761  const char * Show_One_Net_User_Option(const char * which);
762 
768  const char * Show_One_User_Option(const char * which);
769 
775  const char * Show_Net_User_Options();
776 
777 
778 private:
779 
780  void clear() {
781  H_SAFE_DELETE_ARRAY(m_data);
782  m_length = 0;
783  };
784 
785 };
786 
787 
788 
790 
793 class MVO_API HUtility
794 {
795 public:
796 #undef PI
797  static const float PI;
798 
799  enum{X, Y, Z, W};
800  enum{XY, XZ, YZ};
801 
802  static const float EH_Epsilon;
803 
804 
811  static void Order(HPoint* one, HPoint* two);
812 
819  static void Find_Relative_Path(HC_KEY from_seg_key, HC_KEY to_seg_key, char * path);
820 
824  static float GetTime();
825 
826 
831  static void ClampPointToWindow (HPoint * point);
832 
839  static HC_KEY InsertBox (HPoint * max, HPoint * min);
840 
848  static HC_KEY InsertWireframeBox (HPoint * max, HPoint * min);
849 
856  static void GenerateCuboidPoints (HPoint * max, HPoint * min, HPoint * points);
857 
869  static HC_KEY InsertRectangle (const char * seg, float x0, float y0, float x1, float y1, float z = 0.0f, bool fill = false);
870 
871 
886  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);
887 
894  static void ComputeDoublePrecisionCrossProduct(double * vector1, double * vector2, double * up);
895 
902  static double ComputeDoublePrecisionDotProduct(double * vector1, double * vector2);
903 
909  static double ComputeDoublePrecisionVectorLength(double * vector1);
910 
917  static void GetViewplaneVectors(HC_KEY segment_key, double * view, double * up);
918 
923  static void NormalizeDoublePrecisionVector(double* vector1);
924 
932  static bool PointsEqual(HPoint * point1, HPoint * point2);
933 
945  static bool CreateAxisCircle (HPoint const & center, float radius, int axis, bool convert = true);
946 
947 
954  static void RotateToVector(HPoint start, HPoint end, bool doTranslation = true);
955 
971  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);
972 
980  static void SmoothTransition(HCamera old_camera, const HCamera &new_camera, HBaseView *view);
981 
988  static bool CamerasEqual(const HCamera &camera1, const HCamera &camera2);
989 
997  static void ComputeVectorToVectorRotationMatrix(float *matrix,HPoint v1,HPoint v2);
998 
1007  static bool ExtractRGB(char *text,float &r, float &g, float &b);
1008 
1019  static void TransitionQuaternion(float *quat_old, float *quat_new, float t, float *qt);
1020 
1026  static void MatrixToQuaternion(float *matrix, float *quaternion);
1027 
1033  static void QuaternionToMatrix(float * quaternion, float *matrix);
1034 
1043  static void SmoothQuaternionTransition(HBaseView *m_pView, char *old_seg, char *new_seg, int num_of_transitions);
1044 
1052  static void SmoothMatrixTransition(HBaseView *m_pView, HC_KEY seg_key, float *new_matrix);
1053 
1063  static void MultiSmoothTransitions(HBaseView *m_pView, int num_keys, HC_KEY *seg_key, float *new_matrix, HCamera *new_camera = 0);
1064 
1070  static HPoint GetCentroid(HC_KEY seg_key);
1071 
1078  static HPoint GetTransformedCentroid(HC_KEY seg_key, float * matrix = 0);
1079 
1087  static void URIencode(const char * in_string, MVO_POINTER_SIZED_UINT n, char * out_buffer);
1095  static void URIdecode(const char * in_string, char * out_buffer, MVO_POINTER_SIZED_UINT * n);
1096 
1105  static void GetCameraFromMatrix(float *matrix, HPoint *target, HPoint *position, HPoint *up_vector, HPoint *translation);
1106 
1115  static void GetMatrixFromCamera(HPoint target, HPoint position, HPoint up_vector, HPoint translation, float *matrix);
1116 
1117 
1151  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,
1152  HPoint &pos, HPoint &target, HPoint &up, char * projection, double &width, double &height, double &near_limit );
1153 
1161  static bool PushAttribute(const char *attName);
1162 
1171  static void PushAttribute(const char *attName, const char *attText);
1172 
1180  static bool PopAttribute(const char *attName);
1181 
1192  static bool ModifyPushedAttribute(const char *attName, const char *newStyle);
1193 
1200  static bool ShowPushedAttribute(const char *attName, HUserOptions& attText);
1201 
1214  static void Recursive_Merge_Shells( HShell *total_info, HShell *max_info, bool do_recurse, bool delete_orig_shells = false, bool insert_null_lods = false );
1215 
1222  static HC_KEY Merge_Shells( bool do_recurse, bool delete_orig_shells = false , bool optimize_shell = true, bool generate_regions = false);
1223 
1231  static HC_KEY Merge_Shells_Generate_Regions( int num_shells, HC_KEY * shell_keys, bool delete_orig_shells = false );
1232 
1242  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 );
1243 
1251  static bool Segment_Shell_Allocate( HShell *total_info, HShell *max_info, bool do_recurse );
1252 
1260  static void Shell_Search( HShell *total_info, HShell *max_info, bool do_recurse );
1261 
1262 
1263 
1274  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);
1275 
1276 
1285  static void CountShellData(HC_KEY shell_key, int * faces, int * vertices, int * triangles, int * tristrips = 0);
1286 
1293  static void FindFileNameExtension(const char * filename_in, char * ext_out, int size = -1);
1294 
1301  static void FindFileNameExtension(__wchar_t const * const filename_in, __wchar_t * ext_out, int size = -1);
1302 #ifdef H_USHORT_OVERLOAD
1303  static void FindFileNameExtension(unsigned short const * const filename_in, unsigned short * ext_out, int size = -1){
1304  FindFileNameExtension((wchar_t const * const)filename_in, (wchar_t*)ext_out, size);
1305  }
1306 #endif
1307 
1312  static void FindUnicodeFileNameExtension(const unsigned short * filename_in, char * ext_out);
1313 
1321  static void FindFileNameAndDirectory(const char * filename_in, char * dir_out, char * filename_out);
1329  static void FindFileNameAndDirectory(__wchar_t const * filename_in, __wchar_t * dir_out, __wchar_t * filename_out);
1330 
1341  static const char* extra_pointer_format();
1345  static HC_KEY CreateScaleIndependentSegment(const char *segname, bool SetCallback = true);
1346 
1350  static HC_KEY GetScaleIndependentGeomSegmentKey(HC_KEY segkey);
1351 
1355  static void SetScaleIndependentGeomPosition(HC_KEY segkey, float x, float y, float z);
1356 
1360  static void GetScaleIndependentGeomPosition(HC_KEY segkey, float &x, float &y, float &z);
1361 
1365  static void RegisterCallbacks();
1366 
1373  static bool IsModelKey(HC_KEY modelkey, HC_KEY objectkey);
1374 
1382  static HC_KEY UserOptionExists(HC_KEY key, const char *attrib, char *result);
1383 
1400  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);
1401 
1411  static int CalculateKeyPath(HC_KEY startkey, HBaseView *view, HC_KEY *keyarray, int maxarray);
1412 
1417  static bool SegmentExists(const char *segment);
1418 
1421  static void UnsetAttributes();
1422 
1430  static int IsChildOf(HC_KEY owner, HC_KEY child, HC_KEY *klist = 0);
1431 
1437  static bool IsIdentityMatrix(float* matrix);
1438 
1445  static void ComputeShellNormal(HC_KEY skey, HPoint &tnormal);
1446 
1456  static HC_KEY SelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false);
1457 
1458 
1469  static HC_KEY SmartSelectUnderCursor(HBaseView *view, float x, float y, bool doSelection = true, bool DeSelect = false);
1470 
1471 
1478  static bool ShowOneHeuristic(const char *type, char *res = 0);
1485  static bool ShowOneRenderingOption(const char *type, char *res = 0);
1486 
1496  static float EaseInEaseOut(float t, float a, float b, float c);
1497 
1502  static void UnwindIncludes(HC_KEY &key);
1503 
1510  static void UnwindIncludes(HC_KEY &newkey, HC_KEY *keys, int count);
1511 
1512 
1519  static bool SafeSetUserOption(const char * opt);
1520 
1527  static bool SafeShowUserOption(char * opt);
1528 
1529 
1534  static void ProjectShell(HC_KEY shellkey);
1535 
1542  static HC_KEY MergeShells(HC_KEY shell1, HC_KEY shell2);
1543 
1549  static void ShowModellingMatrix(float *segment_modelling_matrix);
1550 
1557  static void ConvertLocalPixelsToLocalWindow(HBaseView * view, HPoint *in_system , HPoint *out_system = 0);
1558 
1559 
1566  static HC_KEY GrabSegment(HC_KEY key);
1567 
1572 # define MakeSegment(key) GrabSegment(key)
1573 
1579  static void RenameSegment(HC_KEY segkey, const char *newname);
1580 
1581 
1592  static void InterpolateNormalAlongEdge(HPoint &p1, HPoint &n1, HPoint &p2, HPoint &n2, HPoint &p3, HPoint &n3);
1593 
1599  static void ShowNormals(HC_KEY shellkey, float normallength);
1600 
1606  static bool IsSegmentKey(HC_KEY key);
1607 
1614  static int FindContents(HC_KEY &key);
1615 
1622  static int CalculateMajorAxis(HBaseView *view);
1623 
1624 
1632  static HC_KEY FindOneObject(const char *type, bool l = 0);
1638  static void CloseAllSegments(HC_KEY endkey = INVALID_KEY);
1639 
1644  static void ReadjustTarget(HBaseView *view);
1645 
1650  static bool GetAllowAnimation(HC_KEY key);
1651 
1654  static void SuppressAnimation();
1655 
1663  static int FindFaceByIndex(int findex, int *flist, int flen);
1664 
1671  static bool ShowOneUserOption(const char *option, char *res);
1672 
1678  static HC_KEY GetNextRenumberedKey(HBaseView *view);
1679 
1685  static void NameSegments(HC_KEY &key, HBaseView *view);
1686 
1692  static void MoveToTemp(HC_KEY movekey, HC_KEY tempkey);
1693 
1704  static void ShowContentsWithPath( const char * entitytypes, struct vlist_s **ret_pathlist, bool storePath = false, bool includeIncludes = true, bool filterIncludes = true);
1705 
1706 
1712  static int ustrlen(unsigned short *text);
1713 
1723  static bool RLECompress(int const in_len,
1724  unsigned char const * const in_buf,
1725  int * out_len,
1726  unsigned char * const out_buf);
1727 
1737  static bool ZlibCompress(int const in_len,
1738  unsigned char const * const in_buf,
1739  int & out_len,
1740  unsigned char * const out_buf);
1741 
1751  static bool ZlibDecompress(int const in_len,
1752  unsigned char const * const in_buf,
1753  int & out_len,
1754  unsigned char * const out_buf);
1760  static unsigned short *uconvert(const char *text);
1761 
1772  static bool BuildIncludePath(HC_KEY objectkey, const HC_KEY *includelist, int ilength, HC_KEY *fullpath, int *fplength, HC_KEY matchkey = INVALID_KEY);
1773 
1780  static void BuildIncludePathFromSelection(HSmartSelItem *sitem, int &plen, HC_KEY *fullpath);
1781 
1782 
1791  static void MakeViewSnapshot(HBaseView * view, int width, int height, char ** data);
1792 
1798  static void MakeViewSnapshot(HBaseView * view, HC_KEY image_key);
1799 
1808  static int ConstrainToVector( const float *matrix_in, const HVector &vector, float *matrix_out ) ;
1809 
1817  static void Camera_To_Transform (HCamera *camera , float *pos, float *projection_matrix, float *complete_matrix);
1828  static void LocalPixelsToWorld(HCamera *camera, bool righthanded, float xres, float yres, int xwpix, int ywpix, float *result);
1835  static float ComputeAngleBetweenVector(HPoint p1, HPoint p2);
1836 
1837 
1843  static int strlen16( const unsigned short *p16);
1844 
1853  static void CalculateBoundingInfo(HC_KEY startkey, HPoint &min, HPoint &max, HPoint &delta, HPoint &mid);
1854 
1864  static long ClipPolygonAgainstPlane(long vertexCount, const HPoint *vertex,
1865  const float *plane, HPoint *result, bool *noCut = 0);
1866 
1873  static HFileOutputResult TwoPassPrint(const char *driver, HOutputHandlerOptions *options);
1874 
1882  static HC_KEY OpenSegmentFromKey(HC_KEY key, char *segment);
1883 
1884 
1896  static bool IsPointInsideAllEdges( const float *pt,const float *points1,
1897  int len, const int *face1, const float *plane1, float fudge );
1905  static void IntersectionLinePlane(HPoint *p1, HPoint *p2, HPlane *p, HPoint *res);
1906 
1921  static void MergePointsIntoShell(int num_shell_points, HPoint *plist1, int num_shell_facelist, int *flist1,
1922  int num_merge_points, HPoint *merge_points, HPoint *merge_vectors,
1923  float tolerance, bool AddExtraPoints, int *newpoints, int *newpointslen);
1924 
1925 
1940  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);
1941 
1943  static void MergePolylines();
1944  static void CreateZebraStripeTexture(int width, int height, int stripwidth, bool horizontal, HPixelRGB colorstripes, HPixelRGB colorbackground);
1945 
1953  static void ascii_to_unicode(char const *ascii, unsigned short *unicode);
1954 
1962  static void unicode_to_ascii(unsigned short const *unicode, char *ascii);
1963 
1972  static void BatchRead(HBaseModel * model, const char * directory, const char * extension);
1973 
1981  static void AdjustPositionToPlane(HBaseView *, HPoint &position, HPoint point_in_plane);
1982 
1991  static void CalculateCornerImagePosition(HBaseView *view, int iwidth, int iheight, HWindowCorner corner, float &posx, float &posy);
1992  static void OptimizeModelByGrid(HBaseView *view, ShellToRegionMapper *mapper);
1993  static void DecipherTextureString(char *texdef, char *Source, bool *DownSampling = 0, bool *DownSamplingSet = 0, char *ParameterizationSource = 0,
1994  char *InterpolationFilter = 0, char *DecimationFilter = 0, char *Layout = 0, char *Tiling = 0, bool *ValueScaleSet = 0,
1995  bool *ValueScale = 0, float *ValueScaleMin =0, float *ValueScaleMax = 0, char *BlendingMode = 0);
1996 
1997 
1998 private:
1999  static void scale_segment (HIC_Rendition *rendition,HIC_Segment_Info * geo3);
2000  static void activity_change (HIC_Segment *seg, int old_activity, int new_activity);
2001  static bool RestoreAttributeFromOption(const char *attName, HUserOptions& attText);
2002  static void ReplaceCharacter(char *text, char orig, char target);
2003  static bool SetAttribute(const char *attName, const char *attText);
2004  static bool ShowAttribute(const char *attName, char *attText);
2005  static void ShowContentsWithPathAddEntity(HC_KEY key, struct vlist_s *pathlist, int level, HC_KEY *patharray, bool storePath);
2006  static void ShowContentsWithPathRecursive(HC_KEY key, const char *entitytypes, struct vlist_s *pathlist, HC_KEY *patharray, int level, bool storePath, bool includeIncludes, bool filterIncludes);
2007  static void SubdivideOneShell(HShellWrapper &myshell, int numx, int numy, int numz, HPoint &totalmin,
2008  HPoint &totaldeltadiv, HShellWrapper *shellmatrix, HShellWrapper &leftover, float boxdiagonallength, bool DoCut, int regionnum, ShellToRegionMapper *mapper, HC_KEY newkey);
2009 
2010 
2011 };
2012 
2014 {
2015  TwoPassPrintFontInfo(HC_KEY segmentKey, float size, char * units)
2016  {
2017  m_SegmentKey = segmentKey;
2018  m_Size = size;
2019  strcpy(m_Units, units);
2020  }
2021 
2022  HC_KEY m_SegmentKey;
2023  float m_Size;
2024  char m_Units[64];
2025 };
2026 
2027 
2028 class MVO_API HQualifiedKey
2029 {
2030 public:
2031  HQualifiedKey(HC_KEY key, HC_KEY *includelist, int includelistlength)
2032  {
2033  m_Key = key;
2034  m_pIncludeList = 0;
2035  m_pIncludeList = new HC_KEY[includelistlength];
2036  for (int i=0;i<includelistlength;i++)
2037  m_pIncludeList[i] = includelist[i];
2038  m_IncludeListLength = includelistlength;
2039  }
2040  ~HQualifiedKey()
2041  {
2042  delete [] m_pIncludeList;
2043  }
2044 
2045  long MakeHashKey()
2046  {
2047  return (MakeHashKey(m_Key, m_IncludeListLength,m_pIncludeList));
2048  }
2049 
2050  static long MakeHashKey(HC_KEY key, int includelength, HC_KEY *includes)
2051  {
2052  long hashkey = key;
2053  for (int i=0;i<includelength;i++)
2054  {
2055  hashkey+=includes[i];
2056  }
2057  return hashkey;
2058  }
2059 
2060 
2061  HC_KEY m_Key;
2062  HC_KEY *m_pIncludeList;
2063  int m_IncludeListLength;
2064 };
2065 
2066 
2067 
2068 
2069 class MVO_API HMergeShellFace
2070 {
2071 
2072 public:
2073  HMergeShellFace()
2074  {
2075  m_pChildFaces = 0;
2076  m_ChildFaceNum = 0;
2077  }
2078  ~HMergeShellFace()
2079  {
2080  if (m_pChildFaces)
2081  delete [] m_pChildFaces;
2082  if (m_pFlist)
2083  delete [] m_pFlist;
2084 
2085  }
2086  void Init(int *flist);
2087  void MakeChildFaces(int &addpoint, HPoint *points, bool AddExtraPoints, int *newpoints, int *newpointslen);
2088  void Divide(int pnum, HPoint *points);
2089 
2090  bool CheckHit(HPoint &p, HPoint &normal, HPoint *plist, HPoint &pres);
2091  HMergeShellFace *FindHitFaceRecursive(HPoint &p, HPoint &normal, HPoint *plist, HPoint &respoint);
2092  HMergeShellFace *FindHitFace(HPoint &p, HPoint &normal, HPoint *plist, HPoint &respoint)
2093  {
2094  return FindHitFaceRecursive(p, normal, plist,respoint);
2095  }
2096  bool CheckIfColinear(HPoint *point);
2097 
2098  int GetLengthRecursive(int l);
2099 
2100 
2101  int GetLength()
2102  {
2103  return (GetLengthRecursive(0));
2104 
2105  }
2106 
2107  int AddToFacelistRecursive(int *start, int l);
2108 
2109 
2110  int AddToFacelist(int *start)
2111  {
2112  return (AddToFacelistRecursive(start, 0));
2113 
2114  }
2115 
2116 
2117 protected:
2118  HMergeShellFace *m_pChildFaces;
2119  int m_flen;
2120  int *m_pFlist;
2121 
2122  int m_ChildFaceNum;
2123 
2124 
2125 
2126 };
2127 
2128 
2129 
2130 class MVO_API ColorPiece{
2131 
2132 public:
2133  ColorPiece(int *index, int len, int col)
2134  {
2135  m_uvindex = new int[len];
2136  m_fllen = new int[len];
2137  m_flindex = new int[len];
2138  for (int i=0;i<len;i++)
2139  m_uvindex[i] = index[i];
2140  m_len = len;
2141  m_col = col;
2142  m_done = false;
2143 
2144  }
2145  ~ColorPiece()
2146  {
2147  delete [] m_uvindex;
2148  delete [] m_fllen;
2149  delete [] m_flindex;
2150  }
2151  int *m_uvindex;
2152  int *m_fllen;
2153  int *m_flindex;
2154  int m_len;
2155  int m_col;
2156 
2157  bool m_done;
2158 
2159 };
2160 
2161 class MVO_API ColorPieceList
2162 {
2163 public:
2164  ColorPieceList();
2165  ~ColorPieceList();
2166  void AddColorPiece(int *index, int len, int col);
2167  ColorPiece * FindMatch(int col, int ii, int ii2, int &rpos, int &rlen, bool &reverse);
2168 
2169  struct vlist_s* m_ColorPieceList;
2170 
2171 
2172 };
2173 
2174 class MVO_API HVerticalUtility :
2175  public HUtility
2176 {
2177 public:
2178 
2179  static void ColorizePointCloud(HC_KEY const segment);
2180 };
2181 
2182 
2183 
2184 class MVO_API HAbsoluteWindow
2185 {
2186 public:
2187  HAbsoluteWindow(HBaseView *view, HC_KEY key,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft,
2188  AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft,
2189  AbsoluteWindowType height_type = RelativeTop, bool sb = false);
2190  HAbsoluteWindow(HBaseView *view, HC_KEY key);
2191  void DecipherOptions();
2192  void AdjustX(float invalue, AbsoluteWindowType wt, float &outvalue);
2193  void AdjustY(float invalue, AbsoluteWindowType wt, float &outvalue);
2194  bool Adjust();
2195  static void AdjustAll(HBaseView *view);
2196  static bool SetWindow(HBaseView *view,float xpos, float ypos, float width, float height, AbsoluteWindowType xpos_type = RelativeLeft,
2197  AbsoluteWindowType ypos_type = RelativeTop, AbsoluteWindowType width_type = RelativeLeft,
2198  AbsoluteWindowType height_type = RelativeTop, bool sb = false);
2199  bool IsPositionInWindow(float x, float y);
2200  static bool IsPositionInWindow(HBaseView *view, float x, float y);
2201  static void CalculateLocalWindowPos(HBaseView *view, float x, float y, float &xout, float &yout);
2202  void CalculateLocalWindowPos(float x, float y, float &xout, float &yout);
2203  static void CalculateOuterWindowPos(HBaseView *view, float x, float y, float &xout, float &yout);
2204  void CalculateOuterWindowPos(float x, float y, float &xout, float &yout);
2205 
2206 
2207 
2208  HBaseView *m_pView;
2209  float m_width;
2210  float m_height;
2211  float m_xpos;
2212  float m_ypos;
2213  AbsoluteWindowType m_xpos_type;
2214  AbsoluteWindowType m_ypos_type;
2215  AbsoluteWindowType m_width_type;
2216  AbsoluteWindowType m_height_type;
2217 
2218  bool m_bShowBackground;
2219 
2220  HC_KEY m_key;
2221 
2222 };
2223 
2224 
2225 
2227 
2242 class MVO_API HUnicodeOptions
2243 {
2244 public:
2245 
2246  wchar_t* m_data;
2247  int m_length;
2248  bool m_valid;
2249 
2251  HUnicodeOptions();
2252 
2254  HUnicodeOptions(const HUnicodeOptions& in_data);
2255 
2256 
2258  ~HUnicodeOptions();
2259 
2260 
2264  bool IsValid();
2265 
2270  const __wchar_t * Show_Unicode_Options();
2271 
2276  const wchar_t* Show_One_Net_Unicode_Option(const __wchar_t* which);
2277 #ifdef _MSC_VER
2278  const unsigned short * Show_One_Net_Unicode_Option(const unsigned short * which);
2279 #endif
2280 
2285  const wchar_t * Show_One_Unicode_Option(const __wchar_t * which);
2286 #ifdef _MSC_VER
2287  const unsigned short * Show_One_Unicode_Option(const unsigned short * which);
2288 #endif
2289 
2293  const __wchar_t* Show_Net_Unicode_Options();
2294 
2295 private:
2296 
2297  void clear() {
2298  H_SAFE_DELETE_ARRAY(m_data);
2299  m_length = 0;
2300  m_valid = false;
2301  };
2302 
2303 };
2304 
2305 
2306 
2307 class BREP_Topology;
2308 
2310 {
2311 public:
2312  BREP_Edge(HC_KEY edgekey)
2313  {
2314  m_edgekey = edgekey;
2315  m_vertex1 = INVALID_KEY;
2316  m_vertex2 = INVALID_KEY;
2317  }
2318 
2319  HC_KEY m_edgekey;
2320  HC_KEY m_vertex1;
2321  HC_KEY m_vertex2;
2322 
2323 };
2324 
2326 {
2327 public:
2328  BREP_CoEdge(BREP_Edge *edge)
2329  {
2330  m_edge = edge;
2331  }
2332 
2333  BREP_Edge * m_edge;
2334 };
2335 
2336 
2337 class MVO_API BREP_Face
2338 {
2339 public:
2340  BREP_Face(HC_KEY facekey);
2341  ~BREP_Face();
2342 
2343  BREP_Edge * AddCoEdge(BREP_Topology *topol, void *edgeid, HC_KEY edgekey);
2344 
2345 
2346  struct vlist_s * m_CoEdgeList;
2347  HC_KEY m_facekey;
2348 };
2349 
2350 class MVO_API BREP_Topology
2351 {
2352 public:
2353 
2354  struct vhash_s * m_FaceHash;
2355 
2356  struct vhash_s * m_EdgeHash;
2357  struct vhash_s * m_VertexHash;
2358 
2359  BREP_Face *m_CurrentFace;
2360  BREP_Topology();
2361  ~BREP_Topology();
2362  BREP_Face *AddFace(HC_KEY facekey);
2363  BREP_Face *GetFace(HC_KEY facekey);
2364  BREP_Edge *FindEdge(void *edgeid);
2365  BREP_Edge *AddEdge(void *edgeid, HC_KEY edgekey);
2366  HC_KEY AddVertex(void *vertexid, HPoint vpos);
2367  HC_KEY FindVertex(void *vertexid);
2368 
2369 
2370 
2371  BREP_Face *GetCurrentFace() { return m_CurrentFace; }
2372 
2373 };
2374 
2375 class H_FORMAT_TEXT;
2376 
2377 class MVO_API HBestImageDriver
2378 {
2379 private:
2380  H_FORMAT_TEXT * m_dvr;
2381 public:
2382  HBestImageDriver(char const * prefer_type = 0);
2383  ~HBestImageDriver();
2384 
2385  HC_KEY GetKey() const;
2386 
2387  operator char const* () const;
2388 };
2389 
2390 
2391 class MVO_API HPVOOptions
2392 {
2393  private:
2394  void * impl;
2395 
2396  public:
2397  HPVOOptions(char const * filename);
2398  ~HPVOOptions();
2399  char const * getOption(char const * option) const;
2400 };
2401 
2402 
2403 #ifdef H_PACK_8
2404 #pragma pack(pop)
2405 #endif
2406 
2407 #endif
The HPixelRGB class is the data type of a rgb pixel.
Definition: HGlobals.h:478
HShellWrapper()
Definition: HUtility.h:313
The HShellObject class is a simple wrapper for a shell.
Definition: HUtility.h:204
int point_list_len
The length of the point list,.
Definition: HUtility.h:273
int m_facepointer
Definition: HUtility.h:525
double w
The knot value of a B-Surface vertex.
Definition: HUtility.h:599
int region_count
The number of regions in the shell.
Definition: HUtility.h:281
HShellWrapper(HC_KEY key)
Definition: HUtility.h:297
Definition: HUtility.h:2013
The HUtility class contains a set of utility functions and data structures used widely in MVO classes...
Definition: HUtility.h:793
Definition: HUtility.h:2130
static const float PI
default=3.1415926f
Definition: HUtility.h:797
Definition: HUtility.h:2325
Definition: HUtility.h:2350
char * m_data
actual char* to the user options
Definition: HUtility.h:729
Definition: HUtility.h:2184
void Show_One_User_Option(const char *type, char *value)
Definition: HUtility.h:2174
#define HC_KEY
void Show_Unicode_Options(unsigned short *options)
wchar_t * m_data
actual char* to the user options
Definition: HUtility.h:2246
The HCamera class is the data type of a HOOPS Camera Attribute.
Definition: HUtility.h:543
HPoint * point_list
The list of vertices that define the shell.
Definition: HUtility.h:274
void Show()
Definition: HUtility.h:577
HPoint up_vector
The direction of up.
Definition: HUtility.h:548
bool valid
True if the object has been initialized.
Definition: HUtility.h:545
double y
The y-coordinate of a B-Surface vertex.
Definition: HUtility.h:597
The HShellRegion class is a simple wrapper for a shell's region.
Definition: HUtility.h:170
HVector * normal_list
The list of normal vectors associated with the shell.
Definition: HUtility.h:275
HC_KEY * patharray
Array of Keys.
Definition: HUtility.h:687
The HSmartSelItem - selection item which can handle instancing.
Definition: HSelectionItem.h:192
Definition: HUtility.h:2161
void Set(int first, int second)
Definition: HUtility.h:107
class HPoint HVector
The HVector class is the data type of a three-dimensional vector.
Definition: HGlobals.h:332
void EndFaceIteration()
Definition: HUtility.h:385
float field_height
The height of the field of view.
Definition: HUtility.h:550
int len
length of key array
Definition: HUtility.h:688
int face_count
The number of faces in the shell.
Definition: HUtility.h:279
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:521
HC_KEY m_Key
The key of the shell.
Definition: HUtility.h:522
int m_plen
The number of points in the points list.
Definition: HUtility.h:515
Definition: HUtility.h:2069
The HUnicodeOptions class is a helper class which wraps up memory management for variable size Unicod...
Definition: HUtility.h:2242
double z
The z-coordinate of a B-Surface vertex.
Definition: HUtility.h:598
Definition: HUtility.h:65
The HUserOptions class is a helper class which wraps up memory management for variable size user opti...
Definition: HUtility.h:725
HPoint target
The area that the camera is directed at.
Definition: HUtility.h:547
void InvalidateCamera()
Definition: HUtility.h:559
HPolyline * m_pNextPolyline
A pointer to a single HPolyline object.
Definition: HUtility.h:616
int face_list_len
The length of the face list.
Definition: HUtility.h:277
int m_flen
The length of the face list.
Definition: HUtility.h:516
The HShellVertexData class encapsulates colormap index information associated with the vertices of a ...
Definition: HUtility.h:624
HPoint * m_pHPointArray
A pointer to an array of HPoint objects.
Definition: HUtility.h:615
int GetFirst() const
Definition: HUtility.h:100
int m_totalplen
Definition: HUtility.h:529
The HBaseModel class is used to store and manage model information.
Definition: HBaseModel.h:52
The HPoint class is the data type of a three-dimensional point.
Definition: HGlobals.h:126
The HBaseView class defines and manages a view of model information.
Definition: HBaseView.h:337
Definition: HUtility.h:2377
The HShell class is the data type of a HOOPS Shell.
Definition: HUtility.h:253
int m_length
length of current user option
Definition: HUtility.h:730
void HC_Show_Camera(HC_POINT *position, HC_POINT *target, HC_VECTOR *up, float *width, float *height, char *projection)
int * region_list
The list that defines the set of regions in the shell.
Definition: HUtility.h:282
void HC_Set_Camera(const HC_POINT *position, const HC_POINT *target, const HC_VECTOR *up, double width, double height, const char *projection)
Definition: HUtility.h:2028
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:133
int GetSecond() const
Definition: HUtility.h:102
static const float EH_Epsilon
default=0.01
Definition: HUtility.h:802
The HShellWrapper class is wraps shell information and provides methods to manipulate this informatio...
Definition: HUtility.h:290
The HShellEdge class is a simple wrapper for a shell's edge.
Definition: HUtility.h:90
HPoint position
The location of the camera.
Definition: HUtility.h:546
double x
The x-coordinate of a B-Surface vertex.
Definition: HUtility.h:596
void Set() const
Definition: HUtility.h:583
void Set(double X, double Y, double Z, double W)
Definition: HUtility.h:603
Definition: HUtility.h:2309
The HPlane class is the data type of a plane.
Definition: HGlobals.h:339
int m_PointCount
Number of points in the polyline.
Definition: HUtility.h:614
Definition: HUtility.h:2391
The HShowContentsWithPathType struct is used by HUtility to store a keypath.
Definition: HUtility.h:685
The HBSurfVertex class is the data type of a B-Surface vertex.
Definition: HUtility.h:593
int * face_list
The face list that defines how faces are formed in the shell.
Definition: HUtility.h:278
HC_KEY GetKey()
Definition: HUtility.h:354
HShellEdge(int iFirst=0, int iSecond=0)
Definition: HUtility.h:96
The HPolyline class is the data type for a three-dimensional polyline.
Definition: HUtility.h:611
Definition: HUtility.h:50
Definition: HUtility.h:2337
int m_length
length of current user option
Definition: HUtility.h:2247
void Show_User_Options(char *list)
float field_width
The width of the field of view.
Definition: HUtility.h:549
int m_totalflen
Definition: HUtility.h:527