hps.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 #ifndef HPS_H
11 #define HPS_H
12 
13 #ifdef _MSC_VER
14 # ifndef STATIC_APP
15 # ifdef HPS_CORE_BUILD
16 # define HPS_API __declspec (dllexport)
17 # define EXPIMP_TEMPLATE
18 # else
19 # define HPS_API __declspec (dllimport)
20 # define EXPIMP_TEMPLATE extern
21 # endif
22 # define HPS_TEMPLATE_API __declspec (dllexport)
23 # endif
24 # ifdef _WINDOWS_
25 # undef Ellipse
26 # undef Polyline
27 # undef Polygon
28 # undef Rectangle
29 # undef min
30 # undef max
31 # endif
32 # pragma warning(push)
33 # pragma warning(disable: 4251) //Not an issue as long as debug and release libraries aren't mixed
34 #else
35 # include <limits.h>
36 # include <stddef.h>
37 # ifdef LINUX_SYSTEM
38 # ifndef STATIC_APP
39 # ifdef HPS_CORE_BUILD
40 # define HPS_API __attribute__ ((visibility ("default")))
41 # define EXPIMP_TEMPLATE
42 # else
43 # define EXPIMP_TEMPLATE extern
44 # endif
45 # define HPS_TEMPLATE_API __attribute__ ((visibility ("default")))
46 # endif
47 # endif
48 #endif
49 #ifndef HPS_API
50 # define HPS_API
51 #endif
52 #ifndef HPS_TEMPLATE_API
53 # define HPS_TEMPLATE_API
54 #endif
55 #ifndef EXPIMP_TEMPLATE
56 # define EXPIMP_TEMPLATE
57 #endif
58 #ifndef ENUM_CLASS
59 # define ENUM_CLASS enum class
60 #endif
61 
62 #define NO_HPS_API
63 
64 #include <stdint.h>
65 #include <memory>
66 #include <vector>
67 #include <math.h>
68 #include <float.h>
69 #include <limits>
70 #include <stdexcept>
71 #include <algorithm>
72 #include <cstring>
73 
74 
75 namespace HPSI
76 {
77  class Impl;
78  class KeyImpl;
79  class TicketImpl;
80  class EventDispatcherImpl;
81  class AbstractImage;
82  class String;
83 };
84 
85 namespace HPS
86 {
87 
88  // unimplemented
89 
90 
91 //Begin Info
93 class HPS_API Info
94 {
95 public:
96 
99  enum class Code : uint32_t
100  {
101  Unknown,
102  Exchange,
103  Publish,
104  Data,
105  Key,
106  Geometry,
107  Database,
108  Driver,
109  Internal,
110  Memory,
111  System,
112  Unsupported,
113  DWG,
114  Parasolid,
115  };
116 
117 private:
118  Info() {}
119 };
120 
121 
122 //Begin Info
124 class HPS_API Emergency
125 {
126 public:
127 
130  enum class Code : uint32_t
131  {
132  Unknown,
133  Fatal,
134  SoftMemoryLimit,
135  HardMemoryLimit,
136  };
137 
138 private:
139  Emergency() {}
140 };
141 
142 
143 //Begin Window
145 class HPS_API Window
146 {
147 public:
148 
153  enum class Driver : uint32_t
154  {
155  Default3D,
156  OpenGL,
157  OpenGL2,
158  DirectX11,
159  OpenGL1Deprecated,
160  Vulkan,
161  OpenGL2Mesa,
162  };
163 
166  enum class UpdateStatus : uint32_t
167  {
168  InProgress,
169  Completed,
170  TimedOut,
171  Interrupted,
172  Failed
173  };
174 
178  enum class UpdateType : uint32_t
179  {
181  Default,
182 
187  Complete,
188 
190  Refresh,
191 
193  CompileOnly,
194 
198  Exhaustive,
199  };
200 
203  enum class Mobility : uint32_t
204  {
205  Locked,
206  Floating,
207  FixedRatio,
208  Free
209  };
210 
213  enum class FrameSize : uint32_t
214  {
215  Single,
216  Double
217  };
218 
221  enum class FrameOptions : uint32_t
222  {
223  Inset,
224  Overlay
225  };
226 
229  enum class ImageFormat : uint32_t
230  {
231  Default,
232  RGBA,
233  RGB,
234  Jpeg,
235  Png
236  };
237 
238 private:
239  Window() {}
240 };
241 
242 //Begin Subwindow
244 class HPS_API Subwindow
245 {
246 public:
247  enum class Background : uint32_t
248  {
249  SolidColor,
250  Image,
251  Cubemap,
252  Blend,
253  Transparent,
254  Interactive,
255 
256  GradientTopToBottom,
257  GradientBottomToTop,
258  GradientLeftToRight,
259  GradientRightToLeft,
260  GradientTopLeftToBottomRight,
261  GradientTopRightToBottomLeft,
262  GradientBottomLeftToTopRight,
263  GradientBottomRightToTopLeft,
264  };
265 
266  enum class Type : uint32_t
267  {
268  Standard,
269  Lightweight
270  };
271 
272  enum class Border : uint32_t
273  {
274  None,
275  Inset,
276  InsetBold,
277  Overlay,
278  OverlayBold
279  };
280 
281 
283  enum class RenderingAlgorithm : uint32_t
284  {
287  ZBuffer,
288 
294  HiddenLine,
295 
301  FastHiddenLine,
302 
319  Priority
320  };
321 
322 private:
323  Subwindow() {}
324 };
325 //End Subwindow
326 
328 class HPS_API Style
329 {
330 public:
331 
334  enum class Type : uint32_t
335  {
336  Segment,
337  Named
338  };
339 
342  enum class AppendMode : uint32_t
343  {
344  None,
345  And,
346  Or
347  };
348 
349 private:
350  Style() {}
351 };
352 
353 
355 class HPS_API Shell
356 {
357 public:
358 
361  enum class Component : uint32_t
362  {
363  Faces,
364  Edges,
365  Vertices
366  };
367 
368  /* \enum ToleranceUnits
369  * Enumerates the Tolerance Units used to determine if points can be merged during shell optimization. */
370  enum class ToleranceUnits : uint32_t
371  {
372  ObjectSpace,
373  FeatureSizePercentage
374  };
375 
376  /* \enum HandednessOptimization
377  * Enumerates the shell optimization options with regards to handedness. */
378  enum class HandednessOptimization : uint32_t
379  {
380  None,
381  Fix,
382  Reverse
383  };
384 
385  /* \enum RelationResults
386  * Enumerates the results of a shell relation computation. */
387  enum class Relation : uint32_t
388  {
389  On,
390  Off,
391  In,
392  Out
393  };
394 
395  /* \enum RelationTest
396  * Enumerates the test options for a shell relation computation. */
397  enum class RelationTest : uint32_t
398  {
399  Simple,
400  Enclosure,
401  Distance
402  };
403 
404 private:
405  Shell() {}
406 };
407 
408 
410 class HPS_API Mesh
411 {
412 public:
413 
416  enum class Component : uint32_t
417  {
418  Faces,
419  Edges,
420  Vertices
421  };
422 
423 private:
424  Mesh() {}
425 };
426 
427 
429 class HPS_API InfiniteLine
430 {
431 public:
432 
435  enum class Type : uint32_t
436  {
437  Line,
438  Ray
439  };
440 
441 private:
442  InfiniteLine() {}
443 };
444 
445 
447 class HPS_API Trim
448 {
449 public:
450 
453  enum class Type : uint32_t
454  {
455  Line,
456  Curve
457  };
458 
462  enum class Operation : uint32_t
463  {
464  Keep,
465  Remove
466  };
467 
468 private:
469  Trim() {}
470 };
471 
472 
474 class HPS_API Spotlight
475 {
476 public:
477 
480  enum class OuterConeUnits : uint32_t
481  {
485  Degrees,
489  FieldRadius
490  };
491 
494  enum class InnerConeUnits : uint32_t
495  {
499  Degrees,
503  FieldRadius,
506  Percent
507  };
508 
509 private:
510  Spotlight() {}
511 };
512 
513 
515 class HPS_API Cylinder
516 {
517 public:
518 
521  enum class Component : uint32_t
522  {
523  Faces,
524  Edges,
525  };
526 
529  enum class Capping : uint32_t
530  {
531  None,
532  First,
533  Last,
534  Both
535  };
536 
539  enum class Orientation : uint32_t
540  {
541  Default,
542  DefaultRadii,
543  InvertRadii,
544  InvertRadiiOnly,
545  DefaultColors,
546  InvertColors,
547  InvertColorsOnly,
548  InvertAll
549  };
550 
551 private:
552  Cylinder() {}
553 };
554 
555 
557 class HPS_API HighlightSearch
558 {
559 public:
560 
563  enum class Scope : uint32_t
564  {
565  AtOrAbovePath,
566  AtOrBelowPath,
567  ExactPath
568  };
569 
570 private:
571  HighlightSearch() {}
572 };
573 
575 class HPS_API Search
576 {
577 public:
578 
581  enum class Space : uint32_t
582  {
583  SegmentOnly,
584  Subsegments,
585  SubsegmentsAndIncludes
586  };
587 
590  enum class Behavior : uint32_t
591  {
592  Exhaustive,
593  FirstMatch
594  };
595 
598  enum class Type : uint32_t
599  {
600  None = 0x00000000,
601  Everything = 0x00ffffff,
602 
603  Include = 0x00000042,
604  Segment = 0x00000043,
605 
606  Includer = 0x00000100,
607 
608  // Geometry
609  Geometry = 0x10000000,
610 
611  CuttingSection = 0x10000026,
612  Shell = 0x10000028,
613  Mesh = 0x10000029,
614  Grid = 0x1000002a,
615  NURBSSurface = 0x1000002b,
616  Cylinder = 0x1000002d,
617  Sphere = 0x1000002e,
618  Polygon = 0x1000002f,
619  Circle = 0x10000030,
620  //unused = 0x10000031,
621  CircularWedge = 0x10000032,
622  Ellipse = 0x10000033,
623  Line = 0x10000034,
624  NURBSCurve = 0x10000037,
625  CircularArc = 0x10000038,
626  EllipticalArc = 0x10000039,
627  InfiniteLine = 0x1000003a,
628  //unused = 0x1000003b,
629  Marker = 0x1000003c,
630  Text = 0x1000003e,
631  Reference = 0x10000041,
632 
633  DistantLight = 0x10000100,
634  Spotlight = 0x10000101,
635  InfiniteRay = 0x10000102,
636 
637  // Attributes
638  Attribute = 0x20000000,
639 
640  Priority = 0x20000001,
641 
642  // Simple Attributes
643  Material = 0x2000000b,
644  PBRMaterial = 0x2000000c,
645  Camera = 0x2000000f,
646  ModellingMatrix = 0x20000011,
647  UserData = 0x20000022,
648  TextureMatrix = 0x20000024,
649 
650  // Complex Attributes
651  Culling = 0x20001000,
652  CullingBackFace = 0x20001001,
653  CullingExtent = 0x20001002,
654  CullingVector = 0x20001003,
655  CullingVectorTolerance = 0x20001004,
656  CullingFrustum = 0x20001005,
657  CullingDeferralExtent = 0x20001006,
658  CullingVolume = 0x20001007,
659  CullingDistance = 0x20001008,
660 
661  CurveAttribute = 0x20002000,
662  CurveAttributeBudget = 0x20002001,
663  CurveAttributeContinuedBudget = 0x20002002,
664  CurveAttributeViewDependent = 0x20002003,
665  CurveAttributeMaximumDeviation = 0x20002004,
666  CurveAttributeMaximumAngle = 0x20002005,
667  CurveAttributeMaximumLength = 0x20002006,
668 
669  CylinderAttribute = 0x20003000,
670  CylinderAttributeTessellation = 0x20003001,
671  CylinderAttributeOrientation = 0x20003002,
672 
673  EdgeAttribute = 0x20004000,
674  EdgeAttributePattern = 0x20004016,
675  EdgeAttributeWeight = 0x20004017,
676  EdgeAttributeHardAngle = 0x20004018,
677 
678  LightingAttribute = 0x20005000,
679  LightingAttributeInterpolation = 0x20005001,
680 
681  LineAttribute = 0x20006000,
682  LineAttributePattern = 0x2000601a,
683  LineAttributeWeight = 0x2000601b,
684 
685  MarkerAttribute = 0x20007000,
686  MarkerAttributeGlyphRotation = 0x2000701a,
687  MarkerAttributeSize = 0x2000701c,
688  MarkerAttributeSymbol = 0x2000701d,
689  MarkerAttributePreference = 0x2000701e,
690 
691  SurfaceAttribute = 0x20008000,
692  SurfaceAttributeBudget = 0x20008001,
693  SurfaceAttributeMaximumFacetDeviation = 0x20008002,
694  SurfaceAttributeMaximumFacetAngle = 0x20008003,
695  SurfaceAttributeMaximumFacetWidth = 0x20008004,
696  SurfaceAttributeTrimCurveBudget = 0x20008005,
697  SurfaceAttributeMaximumTrimCurveDeviation = 0x20008006,
698 
699  Selectability = 0x20009000,
700  SelectabilityWindows = 0x20009001,
701  SelectabilityEdges = 0x20009002,
702  SelectabilityFaces = 0x20009003,
703  SelectabilityLights = 0x20009004,
704  SelectabilityLines = 0x20009005,
705  SelectabilityMarkers = 0x20009006,
706  SelectabilityVertices = 0x20009007,
707  SelectabilityText = 0x20009008,
708 
709  SphereAttribute = 0x2000a000,
710  SphereAttributeTessellation = 0x2000a001,
711 
712  Subwindow = 0x2000b000,
713  SubwindowEitherType = 0x2000b001,
714  SubwindowStandard = 0x2000b00e,
715  SubwindowLightweight = 0x2000b002,
716  SubwindowBackground = 0x2000b003,
717  SubwindowBorder = 0x2000b004,
718  SubwindowRenderingAlgorithm = 0x2000b005,
719 
720  TextAttribute = 0x2000c000,
721  TextAttributeAlignment = 0x2000c01e,
722  TextAttributeBold = 0x2000c002,
723  TextAttributeItalic = 0x2000c003,
724  TextAttributeOverline = 0x2000c004,
725  TextAttributeStrikethrough = 0x2000c005,
726  TextAttributeUnderline = 0x2000c006,
727  TextAttributeSlant = 0x2000c007,
728  TextAttributeLineSpacing = 0x2000c008,
729  TextAttributeRotation = 0x2000c00a,
730  TextAttributeExtraSpace = 0x2000c00b,
731  TextAttributeGreeking = 0x2000c00c,
732  TextAttributeSizeTolerance = 0x2000c00d,
733  TextAttributeSize = 0x2000c00e,
734  TextAttributeFont = 0x2000c00f,
735  TextAttributeTransform = 0x2000c010,
736  TextAttributeRenderer = 0x2000c011,
737  TextAttributePreference = 0x2000c012,
738  TextAttributePath = 0x2000c020,
739  TextAttributeSpacing = 0x2000c021,
740  TextAttributeBackground = 0x2000c022,
741  TextAttributeBackgroundMargins = 0x2000c023,
742  TextAttributeBackgroundStyle = 0x2000c024,
743  TextAttributeLeaderLine = 0x2000c025,
744 
745  Transparency = 0x2000d000,
746  TransparencyMethod = 0x2000d001,
747  TransparencyAlgorithm = 0x2000d002,
748  TransparencyDepthPeelingLayers = 0x2000d004,
749  TransparencyDepthPeelingMinimumArea = 0x2000d005,
750  TransparencyDepthWriting = 0x2000d006,
751 
752  Visibility = 0x2000e000,
753  VisibilityCuttingSections = 0x2000e001,
754  VisibilityCutEdges = 0x2000e002,
755  VisibilityCutFaces = 0x2000e003,
756  VisibilityWindows = 0x2000e004,
757  VisibilityText = 0x2000e005,
758  VisibilityLines = 0x2000e006,
759  VisibilityEdgeLights = 0x2000e007,
760  VisibilityMarkerLights = 0x2000e008,
761  VisibilityFaceLights = 0x2000e009,
762  VisibilityGenericEdges = 0x2000e00a,
763  VisibilityHardEdges = 0x2000e00b,
764  VisibilityAdjacentEdges = 0x2000e00c,
765  VisibilityInteriorSilhouetteEdges = 0x2000e00d,
766  VisibilityShadowEmitting = 0x2000e00e,
767  VisibilityShadowReceiving = 0x2000e00f,
768  VisibilityShadowCasting = 0x2000e010,
769  VisibilityMarkers = 0x2000e011,
770  VisibilityVertices = 0x2000e012,
771  VisibilityFaces = 0x2000e013,
772  VisibilityPerimeterEdges = 0x2000e014,
773  VisibilityNonCulledEdges = 0x2000e015,
774  VisibilityMeshQuadEdges = 0x2000e016,
775  VisibilityEdges = 0x2000e017,
776  VisibilityLeaderLines = 0x2000e018,
777 
778  VisualEffects = 0x2000f000,
779  VisualEffectsPostProcessEffectsEnabled = 0x2000f001,
780  VisualEffectsAntiAliasing = 0x2000f002,
781  VisualEffectsShadowMaps = 0x2000f003,
782  VisualEffectsSimpleShadow = 0x2000f004,
783  VisualEffectsSimpleShadowPlane = 0x2000f005,
784  VisualEffectsSimpleShadowLightDirection = 0x2000f006,
785  VisualEffectsSimpleShadowColor = 0x2000f007,
786  VisualEffectsSimpleReflection = 0x2000f008,
787  VisualEffectsSimpleReflectionPlane = 0x2000f009,
788  VisualEffectsSimpleReflectionVisibility = 0x2000f00a,
789  VisualEffectsEyeDomeLightingBackColor = 0x2000f00b,
790 
791  Performance = 0x20010000,
792  PerformanceDisplayLists = 0x20010001,
793  PerformanceStaticModel = 0x20010002,
794  StaticModelSegment = 0x40000043,
795 
796  DrawingAttribute = 0x20011000,
797  DrawingAttributePolygonHandedness = 0x20011001,
798  DrawingAttributeDepthRange = 0x20011002,
799  DrawingAttributeFaceDisplacement = 0x20011003,
800  DrawingAttributeGeneralDisplacement = 0x20011004,
801  DrawingAttributeVertexDisplacement = 0x20011005,
802  DrawingAttributeOverlay = 0x20011006,
803  DrawingAttributeDeferral = 0x20011007,
804  DrawingAttributeVertexDecimation = 0x20011008,
805  DrawingAttributeVertexRandomization = 0x20011009,
806  DrawingAttributeOverrideInternalColor = 0x2001100a,
807  DrawingAttributeClipRegion = 0x20011013,
808  DrawingAttributeWorldHandedness = 0x20011019,
809 
810 
811  HiddenLineAttribute = 0x20012000,
812  HiddenLineAttributeAlgorithm = 0x20012001,
813  HiddenLineAttributeColor = 0x20012002,
814  HiddenLineAttributeDimFactor = 0x20012003,
815  HiddenLineAttributeFaceDisplacement = 0x20012004,
816  HiddenLineAttributeLinePattern = 0x20012005,
817  HiddenLineAttributeLineSort = 0x20012006,
818  HiddenLineAttributeRenderFaces = 0x20012007,
819  HiddenLineAttributeRenderText = 0x20012008,
820  HiddenLineAttributeSilhouetteCleanup = 0x20012009,
821  HiddenLineAttributeTransparencyCutoff = 0x2001200a,
822  HiddenLineAttributeVisibility = 0x2001200b,
823  HiddenLineAttributeWeight = 0x2001200c,
824 
825 
826  SegmentStyle = 0x20013001,
827  NamedStyle = 0x20013002,
828  MaterialPalette = 0x20013003,
829  Portfolio = 0x20013004,
830 
831  ContourLine = 0x20014000,
832  ContourLineVisibility = 0x20014001,
833  ContourLinePosition = 0x20014002,
834  ContourLineColor = 0x20014003,
835  ContourLinePattern = 0x20014004,
836  ContourLineWeight = 0x20014005,
837  ContourLineLighting = 0x20014006,
838 
839  Condition = 0x20015000,
840 
841  Bounding = 0x20016000,
842  BoundingVolume = 0x20016001,
843  BoundingExclusion = 0x20016002,
844 
845  AttributeLock = 0x20017000,
846  AttributeLockSetting = 0x20017001,
847  AttributeLockSubsegmentOverride = 0x20017002,
848 
849  TransformMask = 0x20018000,
850  TransformMaskCamera = 0x20018001,
851  TransformMaskCameraTranslation = 0x20018002,
852  TransformMaskCameraScale = 0x20018003,
853  TransformMaskCameraOffset = 0x20018004,
854  TransformMaskCameraRotation = 0x20018005,
855  TransformMaskCameraPerspectiveScale = 0x20018006,
856  TransformMaskCameraProjection = 0x20018007,
857  TransformMaskModellingMatrix = 0x20018008,
858  TransformMaskModellingMatrixTranslation = 0x20018009,
859  TransformMaskModellingMatrixScale = 0x20018010,
860  TransformMaskModellingMatrixOffset = 0x20018011,
861  TransformMaskModellingMatrixRotation = 0x20018012,
862 
863  ColorInterpolation = 0x20019000,
864  ColorInterpolationFaceColor = 0x20019001,
865  ColorInterpolationEdgeColor = 0x20019002,
866  ColorInterpolationMarkerColor = 0x20019003,
867  ColorInterpolationFaceIndex = 0x20019004,
868  ColorInterpolationEdgeIndex = 0x20019005,
869  ColorInterpolationMarkerIndex = 0x20019006,
870 
871  CuttingSectionAttribute = 0x2001a000,
872  CuttingSectionAttributeCuttingLevel = 0x2001a001,
873  CuttingSectionAttributeCappingLevel = 0x2001a002,
874  CuttingSectionAttributeMaterialPreference = 0x2001a003,
875  CuttingSectionAttributeEdgeWeight = 0x2001a004,
876  CuttingSectionAttributeTolerance = 0x2001a005,
877  CuttingSectionAttributeCappingUsage = 0x2001a006,
878 
879  };
880 
881 private:
882  Search() {}
883 };
884 
885 
887 class HPS_API Material
888 {
889 public:
890 
893  enum class Type : uint32_t
894  {
895  None = 0,
896  FullMaterial,
897  RGBColor,
898  RGBAColor,
899  MaterialIndex,
900  TextureName,
901  ModulatedTexture,
902  CubeMapName,
903  ModulatedCubeMap,
904  GlossValue,
905  DiffuseChannelAlpha
906  };
907 
910  enum class Channel : uint32_t
911  {
912  DiffuseColor = 1,
913  DiffuseTexture = 2,
914  Specular = 3,
915  Emission = 4,
916  Transmission = 5,
917  Mirror = 6,
918  Bump = 7,
919  EnvironmentTexture = 8,
920  EnvironmentCubeMap = 9,
921  Gloss = 10,
922  Alpha = 11
923  };
924 
926  class HPS_API Color
927  {
928  public:
929 
932  enum class Channel : uint32_t
933  {
934  DiffuseColor = 1,
935  Specular = 3,
936  Emission = 4,
937  Mirror = 6
938  };
939 
940  private:
941  Color() {}
942  };
943 
945  class HPS_API Texture
946  {
947  public:
948 
951  enum class Channel : uint32_t
952  {
953  DiffuseTexture = 2,
954  Specular = 3,
955  Emission = 4,
956  Transmission = 5,
957  Mirror = 6,
958  Bump = 7,
959  EnvironmentTexture = 8,
960  EnvironmentCubeMap = 9
961  };
962 
965  enum class Parameterization : uint32_t
966  {
968  Cylinder,
969 
971  PhysicalReflection,
972 
974  Object,
975 
981  NaturalUV,
982 
984  ReflectionVector,
985 
987  SurfaceNormal,
988 
990  Sphere,
991 
993  UV,
994 
996  World
997  };
998 
1001  enum class Tiling : uint32_t
1002  {
1005  Clamp,
1006 
1008  Repeat,
1009 
1011  Reflect,
1012 
1015  Trim
1016  };
1017 
1020  enum class Interpolation : uint32_t
1021  {
1023  None,
1024 
1026  Bilinear
1027  };
1028 
1031  enum class Decimation : uint32_t
1032  {
1034  None,
1035 
1038  Anisotropic,
1039 
1041  Mipmap
1042  };
1043 
1047  enum class ChannelMapping : uint32_t
1048  {
1049  Red,
1050  Green,
1051  Blue,
1052  Alpha,
1053  Zero,
1054  One,
1055  Luminance
1056  };
1057 
1058  private:
1059  Texture() {}
1060  };
1061 
1062 private:
1063  Material() {}
1064 };
1065 
1066 
1067 class HPS_API PostProcessEffects
1068 {
1069 public:
1070 
1071  class HPS_API AmbientOcclusion
1072  {
1073  public:
1074 
1077  enum class Quality : uint32_t
1078  {
1079  Fastest,
1080  Nicest
1081  };
1082 
1083  private:
1084  AmbientOcclusion() {}
1085  };
1086 
1087  class HPS_API Bloom
1088  {
1089  public:
1093  enum class Shape : uint32_t
1094  {
1095  Star,
1096  Radial
1097  };
1098 
1099  private:
1100  Bloom() {}
1101  };
1102 
1103 private:
1104  PostProcessEffects() {}
1105 };
1106 
1107 class HPS_API Performance
1108 {
1109 public:
1110 
1114  enum class DisplayLists : uint32_t
1115  {
1117  None,
1118 
1121  Geometry,
1122 
1125  Segment
1126  };
1127 
1136  enum class StaticModel : uint32_t
1137  {
1138  None,
1139  Attribute,
1140  AttributeSpatial
1141  };
1142 
1148  enum class StaticConditions : uint32_t
1149  {
1153  Independent,
1154 
1161  Single
1162 
1163  /* placeholder. Option would generate different optimized trees at the cost of memory. */
1164  //Multiple //!< An optimized segment tree will be used for rendering. The tree will be sorted based on both attributes and spatial locations of objects. This is particularly useful for very large, spatially dispersed models.
1165  };
1166 
1167 
1168 private:
1169  Performance() {}
1170 };
1171 
1172 
1173 class HPS_API AttributeLock
1174 {
1175 public:
1176 
1178  enum class Type : uint32_t
1179  {
1180  Everything = 0x01000000,
1181 
1182  Visibility = 0x02000000,
1183 
1184  VisibilityCuttingSections,
1185  VisibilityCutEdges,
1186  VisibilityCutFaces,
1187  VisibilityWindows,
1188  VisibilityText,
1189  VisibilityLines,
1190  VisibilityEdgeLights,
1191  VisibilityMarkerLights,
1192  VisibilityFaceLights,
1193  VisibilityGenericEdges,
1194  VisibilityHardEdges,
1195  VisibilityAdjacentEdges,
1196  VisibilityInteriorSilhouetteEdges,
1197  VisibilityShadowEmitting,
1198  VisibilityShadowReceiving,
1199  VisibilityShadowCasting,
1200  VisibilityMarkers,
1201  VisibilityVertices,
1202  VisibilityFaces,
1203  VisibilityPerimeterEdges,
1204  VisibilityNonCulledEdges,
1205  VisibilityMeshQuadEdges,
1206  VisibilityCutGeometry,
1207  VisibilityEdges,
1208  VisibilityGeometry,
1209  VisibilityLights,
1210  VisibilityShadows,
1211 
1212  Material = 0x03000000,
1213 
1214  MaterialGeometry,
1215  MaterialCutGeometry,
1216 
1217  MaterialAmbientLightUpColor,
1218  MaterialAmbientLightDownColor,
1219  MaterialAmbientLightColor,
1220 
1221  MaterialWindowColor,
1222  MaterialWindowContrastColor,
1223 
1224  MaterialLightColor,
1225  MaterialLineColor,
1226  MaterialMarkerColor,
1227  MaterialTextColor,
1228  MaterialCutEdgeColor,
1229 
1230  MaterialVertex,
1231  MaterialVertexDiffuse,
1232  MaterialVertexDiffuseColor,
1233  MaterialVertexDiffuseAlpha,
1234  MaterialVertexDiffuseTexture,
1235  MaterialVertexSpecular,
1236  MaterialVertexMirror,
1237  MaterialVertexTransmission,
1238  MaterialVertexEmission,
1239  MaterialVertexEnvironment,
1240  MaterialVertexBump,
1241  MaterialVertexGloss,
1242 
1243  MaterialEdge,
1244  MaterialEdgeDiffuse,
1245  MaterialEdgeDiffuseColor,
1246  MaterialEdgeDiffuseAlpha,
1247  MaterialEdgeDiffuseTexture,
1248  MaterialEdgeSpecular,
1249  MaterialEdgeMirror,
1250  MaterialEdgeTransmission,
1251  MaterialEdgeEmission,
1252  MaterialEdgeEnvironment,
1253  MaterialEdgeBump,
1254  MaterialEdgeGloss,
1255 
1256  MaterialFace,
1257  MaterialFaceDiffuse,
1258  MaterialFaceDiffuseColor,
1259  MaterialFaceDiffuseAlpha,
1260  MaterialFaceDiffuseTexture,
1261  MaterialFaceSpecular,
1262  MaterialFaceMirror,
1263  MaterialFaceTransmission,
1264  MaterialFaceEmission,
1265  MaterialFaceEnvironment,
1266  MaterialFaceBump,
1267  MaterialFaceGloss,
1268 
1269  MaterialBackFace,
1270  MaterialBackFaceDiffuse,
1271  MaterialBackFaceDiffuseColor,
1272  MaterialBackFaceDiffuseAlpha,
1273  MaterialBackFaceDiffuseTexture,
1274  MaterialBackFaceSpecular,
1275  MaterialBackFaceMirror,
1276  MaterialBackFaceTransmission,
1277  MaterialBackFaceEmission,
1278  MaterialBackFaceEnvironment,
1279  MaterialBackFaceBump,
1280  MaterialBackFaceGloss,
1281 
1282  MaterialFrontFace,
1283  MaterialFrontFaceDiffuse,
1284  MaterialFrontFaceDiffuseColor,
1285  MaterialFrontFaceDiffuseAlpha,
1286  MaterialFrontFaceDiffuseTexture,
1287  MaterialFrontFaceSpecular,
1288  MaterialFrontFaceMirror,
1289  MaterialFrontFaceTransmission,
1290  MaterialFrontFaceEmission,
1291  MaterialFrontFaceEnvironment,
1292  MaterialFrontFaceBump,
1293  MaterialFrontFaceGloss,
1294 
1295  MaterialCutFace,
1296  MaterialCutFaceDiffuse,
1297  MaterialCutFaceDiffuseColor,
1298  MaterialCutFaceDiffuseAlpha,
1299  MaterialCutFaceDiffuseTexture,
1300  MaterialCutFaceSpecular,
1301  MaterialCutFaceMirror,
1302  MaterialCutFaceTransmission,
1303  MaterialCutFaceEmission,
1304  MaterialCutFaceEnvironment,
1305  MaterialCutFaceBump,
1306  MaterialCutFaceGloss,
1307 
1308  Camera = 0x04000000,
1309  };
1310 
1311 private:
1312  AttributeLock() {}
1313 };
1314 
1315 class HPS_API Drawing
1316 {
1317 public:
1318 
1321  enum class Handedness : uint32_t
1322  {
1323  None,
1324  Left,
1325  Right
1326  };
1327 
1330  enum class Overlay : uint32_t
1331  {
1333  None,
1334 
1337  Default,
1338 
1341  WithZValues,
1342 
1347  InPlace,
1348  };
1349 
1352  enum class ClipOperation : uint32_t
1353  {
1354  Keep,
1355  Remove,
1356  };
1357 
1360  enum class ClipSpace : uint32_t
1361  {
1362  Window,
1363  World,
1364  Object,
1365  };
1366 
1367 private:
1368  Drawing() {}
1369 };
1370 
1371 
1372 class HPS_API HiddenLine
1373 {
1374 public:
1375 
1379  enum class Algorithm : uint32_t
1380  {
1381  None,
1382  ZBuffer,
1383  ZSort,
1384  };
1385 
1386 private:
1387  HiddenLine() {}
1388 };
1389 
1390 
1392 class HPS_API Selection
1393 {
1394 public:
1395 
1398  enum class Level : uint32_t
1399  {
1400  Segment,
1401  Entity,
1402  Subentity,
1403  };
1404 
1407  enum class Sorting: uint32_t
1408  {
1409  Off,
1410 
1417  Proximity,
1418 
1419  ZSorting,
1420 
1421  Default
1422  };
1423 
1426  enum class Algorithm : uint32_t
1427  {
1430  Visual,
1431 
1434  Analytic
1435  };
1436 
1439  enum class Granularity : uint32_t
1440  {
1441  General,
1442  Detailed
1443  };
1444 
1445 private:
1446  Selection() {}
1447 };
1448 
1449 
1453 
1455 class HPS_API Camera
1456 {
1457 public:
1458 
1461  enum class Projection : uint32_t
1462  {
1463  Default = 1 ,
1464  Perspective,
1465  Orthographic,
1466  Stretched,
1467  };
1468 
1469 private:
1470  Camera() {}
1471 };
1472 
1473 
1475 class HPS_API Selectability
1476 {
1477 public:
1481  enum class Value : uint32_t
1482  {
1483  Off = 0,
1484  On,
1485  ForcedOn
1486  };
1487 
1488 private:
1489  Selectability() {}
1490 };
1491 
1492 
1494 class HPS_API Transparency
1495 {
1496 public:
1497 
1500  enum class Method : uint32_t
1501  {
1502  None,
1503  Blended,
1504  ScreenDoor
1505  };
1506 
1509  enum class Algorithm : uint32_t
1510  {
1511  None,
1512  Painters,
1513  ZSortNicest,
1514  ZSortFastest,
1515  DepthPeeling,
1516  WeightedBlended
1517  };
1518 
1522  enum class AreaUnits : uint32_t
1523  {
1524  Percent,
1525  Pixels
1526  };
1527 
1531  enum class Preference
1532  {
1533  Nicest,
1534  Fastest,
1535  };
1536 
1537 private:
1538  Transparency() {}
1539 };
1540 
1541 
1543 class HPS_API Marker
1544 {
1545 public:
1547  enum class DrawingPreference : uint32_t
1548  {
1549  Nicest, // !< Markers should always be drawn at the requested size at the possible cost of performance.
1550  Fastest,
1551  };
1552 
1555  enum class SizeUnits : uint32_t
1556  {
1557  ScaleFactor,
1558  ObjectSpace,
1559  SubscreenRelative,
1560  WindowRelative,
1561  WorldSpace,
1562  Points,
1563  Pixels
1564  };
1565 
1566 private:
1567  Marker() {}
1568 };
1569 
1570 
1572 class HPS_API Lighting
1573 {
1574 public:
1575 
1578  enum class InterpolationAlgorithm : uint32_t
1579  {
1580  Phong,
1581  Gouraud,
1582  Flat
1583  };
1584 
1585 private:
1586  Lighting() {}
1587 };
1588 
1590 class HPS_API Text
1591 {
1592 public:
1593 
1596  enum class Alignment : uint32_t
1597  {
1598  TopLeft,
1599  CenterLeft,
1600  BottomLeft,
1601  TopCenter,
1602  Center,
1603  BottomCenter,
1604  TopRight,
1605  CenterRight,
1606  BottomRight
1607  };
1608 
1611  enum class ReferenceFrame : uint32_t
1612  {
1613  WorldAligned,
1614  PathAligned
1615  };
1616 
1619  enum class Justification : uint32_t
1620  {
1621  Left,
1622  Right,
1623  Center
1624  };
1625 
1628  enum class Transform : uint32_t
1629  {
1631  Transformable,
1634  NonTransformable,
1636  CharacterPositionOnly,
1639  CharacterPositionAdjusted,
1641  NonScalingTransformable
1642  };
1643 
1646  enum class Renderer : uint32_t
1647  {
1648  Default,
1649  Driver,
1650  Truetype,
1651  };
1652 
1655  enum class Preference : uint32_t
1656  {
1657  Default,
1658  Vector,
1659  Raster,
1660  Exterior
1661  };
1662 
1665  enum class Rotation : uint32_t
1666  {
1667  None,
1668  Rotate,
1669  FollowPath
1670  };
1671 
1672 
1675  enum class SizeUnits : uint32_t
1676  {
1677  ObjectSpace,
1678  SubscreenRelative,
1679  WindowRelative,
1680  WorldSpace,
1681  Points,
1682  Pixels
1683  };
1684 
1687  enum class SizeToleranceUnits : uint32_t
1688  {
1689  ObjectSpace,
1690  SubscreenRelative,
1691  WindowRelative,
1692  WorldSpace,
1693  Points,
1694  Pixels,
1695  Percent
1696  };
1697 
1700  enum class MarginUnits : uint32_t
1701  {
1702  ObjectSpace,
1703  SubscreenRelative,
1704  WindowRelative,
1705  WorldSpace,
1706  Points,
1707  Pixels,
1708  Percent
1709  };
1710 
1713  enum class GreekingUnits : uint32_t
1714  {
1715  ObjectSpace,
1716  SubscreenRelative,
1717  WindowRelative,
1718  WorldSpace,
1719  Points,
1720  Pixels
1721  };
1722 
1725  enum class GreekingMode : uint32_t
1726  {
1727  Nothing,
1728  Lines,
1729  Box
1730  };
1731 
1734  enum class RegionAlignment : uint32_t
1735  {
1736  Top,
1737  Center,
1738  Bottom
1739  };
1740 
1743  enum class LeaderLineSpace : uint32_t
1744  {
1745  Object,
1746  World,
1747  };
1748 
1751  enum class RegionFitting : uint32_t
1752  {
1753  Left,
1754  Center,
1755  Right,
1756  Spacing,
1757  Width,
1758  Auto,
1759  };
1760 private:
1761  Text() {}
1762 };
1763 
1764 
1766 class HPS_API Line
1767 {
1768 public:
1769 
1773  enum class CoordinateSpace : uint32_t
1774  {
1775  Object,
1776  World,
1777  NormalizedInnerWindow,
1778  NormalizedInnerPixel
1779  };
1780 
1784  enum class SizeUnits : uint32_t
1785  {
1786  ScaleFactor,
1787  ObjectSpace,
1788  SubscreenRelative,
1789  WindowRelative,
1790  WorldSpace,
1791  Points,
1792  Pixels
1793  };
1794 
1795 private:
1796  Line() {}
1797 };
1798 
1799 
1801 class HPS_API Edge
1802 {
1803 public:
1804 
1807  enum class SizeUnits : uint32_t
1808  {
1809  ScaleFactor,
1810  ObjectSpace,
1811  SubscreenRelative,
1812  WindowRelative,
1813  WorldSpace,
1814  Points,
1815  Pixels
1816  };
1817 
1818 private:
1819  Edge() {}
1820 };
1821 
1822 
1824 class HPS_API CuttingSection
1825 {
1826 public:
1827 
1830  enum class Mode : uint32_t
1831  {
1832  None,
1833  Round,
1834  Square,
1835  Plane
1836  };
1837 
1840  enum class CappingLevel : uint32_t
1841  {
1842  Entity,
1843  Segment,
1844  SegmentTree
1845  };
1846 
1849  enum class CappingUsage : uint32_t
1850  {
1851  Off,
1852  On,
1853  Visibility
1854  };
1855 
1858  enum class ToleranceUnits : uint32_t
1859  {
1860  Percent,
1861  WorldSpace,
1862  };
1863 
1866  enum class CuttingLevel : uint32_t
1867  {
1868  Global,
1869  Local,
1870  };
1871 
1874  enum class MaterialPreference : uint32_t
1875  {
1876  Explicit,
1877  Implicit,
1878  };
1879 
1882  enum class GatheringLevel : uint32_t
1883  {
1884  Segment,
1885  SegmentTree
1886  };
1887 
1888 private:
1889  CuttingSection() {}
1890 };
1891 
1893 class HPS_API ContourLine
1894 {
1895 public:
1896 
1900  enum class Mode : uint32_t
1901  {
1902  Repeating,
1903  Explicit,
1904  };
1905 
1906 private:
1907  ContourLine() {}
1908 };
1909 
1912 enum class IOResult : uint32_t
1913 {
1914  Success,
1915  Failure,
1916  FileNotFound,
1917  UnableToOpenFile,
1918  InvalidOptions,
1919  InvalidSegment,
1920  InProgress,
1921  Canceled,
1922  UnableToLoadLibraries,
1923  VersionIncompatibility,
1924  InitializationFailed,
1925  UnsupportedFormat,
1926  InvalidFile,
1927 };
1928 
1930 class HPS_API LinePattern
1931 {
1932 public:
1933 
1936  enum class SizeUnits : uint32_t
1937  {
1938  ObjectSpace,
1939  SubscreenRelative,
1940  WindowRelative,
1941  WorldSpace,
1942  Points,
1943  Pixels,
1944  ScaleFactor
1945  };
1946 
1949  enum class InsetBehavior : uint32_t
1950  {
1951  Overlap,
1952  Trim,
1953  Inline
1954  };
1955 
1959  enum class Join : uint32_t
1960  {
1961  Mitre,
1962  Round,
1963  Bevel
1964  };
1965 
1968  enum class Cap : uint32_t
1969  {
1972  Butt,
1975  Square,
1978  Round,
1980  Mitre
1981  };
1982 
1985  enum class Justification : uint32_t
1986  {
1989  Center,
1991  Stretch
1992  };
1993 
1996  enum class Modifier : uint32_t
1997  {
1998  GlyphName,
1999  Enumerated
2000  };
2001 
2002 
2016  enum class Default : uint32_t
2017  {
2018  Solid,
2019  DashDot,
2020  Dashed,
2021  Dotted,
2022  Dash2Dot,
2023  Dash3Dot,
2024  LongDash,
2025  LongDashShortDash,
2026  LongDash2ShortDash,
2027  FineDot,
2028  };
2029 
2030 private:
2031  LinePattern() {}
2032 };
2033 
2034 
2036 class HPS_API Shape
2037 {
2038 public:
2039  enum class Default : uint32_t
2040  {
2041  Rectangle,
2042  RoundedRectangle,
2043  Oval,
2044  Ellipse,
2045  };
2046 
2047 private:
2048  Shape() {}
2049 };
2050 
2051 
2052 //Begin Glyphs
2054 class HPS_API Glyph
2055 {
2056 public:
2057 
2060  enum class Fill : uint32_t
2061  {
2062  None,
2063  Continuous,
2064  New,
2065  NewLoop
2066  };
2067 
2070  enum class ColorSource : uint32_t
2071  {
2072  Default,
2073  Explicit,
2074  Indexed
2075  };
2076 
2080  enum class Default : uint32_t
2081  {
2082  Circle,
2083  CircleWithDot,
2084  CircleWithPlus,
2085  CircleWithTimes,
2086  CircleWithCircle,
2087  SolidCircle,
2088  Dot,
2089  Plus,
2090  Times,
2091  Splat,
2092  Box,
2093  BoxWithDot,
2094  BoxWithTimes,
2095  SolidBox,
2096  Diamond,
2097  DiamondWithDot,
2098  DiamondWithPlus,
2099  SolidDiamond,
2100  TriangleUp,
2101  TriangleUpWithDot,
2102  SolidTriangleUp,
2103  TriangleDown,
2104  TriangleDownWithDot,
2105  SolidTriangleDown,
2106  TriangleRight,
2107  TriangleRightWithDot,
2108  SolidTriangleRight,
2109  TriangleLeft,
2110  TriangleLeftWithDot,
2111  SolidTriangleLeft,
2112  TriangleUpV,
2113  SolidTriangleUpV,
2114  TriangleDownV,
2115  SolidTriangleDownV,
2116  TriangleRightV,
2117  SolidTriangleRightV,
2118  TriangleLeftV,
2119  SolidTriangleLeftV,
2120  LetterY,
2121  LetterZ,
2122  CircleLetterY,
2123  CircleLetterZ,
2124  VerticalBar,
2125  HorizontalBar,
2126  SlantLeft,
2127  SlantRight,
2128  WidePlus,
2129  SolidWidePlus,
2130  WideTimes,
2131  SolidWideTimes,
2132  Pound,
2133  Sphere,
2134  };
2135 
2136 private:
2137  Glyph() {}
2138 };
2139 
2140 
2142 class HPS_API Bounding
2143 {
2144 public:
2145 
2148  enum class Type : uint32_t
2149  {
2150  None,
2151  Sphere,
2152  Cuboid
2153  };
2154 
2155 private:
2156  Bounding() {}
2157 };
2158 
2159 
2161 class HPS_API Condition
2162 {
2163 public:
2164 
2165  enum class Intrinsic : uint32_t
2166  {
2167  Extent,
2168  DrawPass,
2169  InnerPixelWidth,
2170  InnerPixelHeight,
2171  Selection,
2172  QuickMovesProbe,
2173  };
2174 
2175 private:
2176  Condition() {}
2177 };
2178 
2179 
2181 class HPS_API Grid
2182 {
2183 public:
2184 
2187  enum class Type : uint32_t
2188  {
2189  Quadrilateral,
2190  Radial
2191  };
2192 
2193 private:
2194  Grid() {}
2195 };
2196 
2197 
2199 {
2200 public:
2201 
2202  enum class UserData : uint32_t
2203  {
2204  None,
2205  Discard,
2206  Preserve,
2207  Merge,
2208  Localize,
2209  };
2210 
2211  enum class Scope : uint32_t
2212  {
2213  SubSegments,
2214  SubsegmentsAndIncludes,
2215  SegmentOnly,
2216  };
2217 
2218  enum class Expansion : uint32_t
2219  {
2220  None,
2221  Includes,
2222  References,
2223  IncludesAndReferences,
2224  };
2225 
2226  enum class Matrix : uint32_t
2227  {
2228  None,
2229  Localize,
2230  Collapse,
2231  };
2232 
2233  enum class Reorganization : uint32_t
2234  {
2235  None,
2236  Attribute,
2237  Spatial,
2238  AttributeSpatial,
2239  };
2240 
2241 private:
2243 };
2244 
2245 
2247 class HPS_API Coordinate
2248 {
2249 public:
2250 
2254  enum class Space : uint32_t
2255  {
2256  Object,
2257  World,
2258  Camera,
2259  Window,
2260  Pixel,
2261  InnerWindow,
2262  InnerPixel,
2263  NormalizedInnerWindow,
2264  NormalizedInnerPixel,
2265  NormalizedWindow,
2266  NormalizedPixel,
2267  };
2268 
2269 private:
2270  Coordinate() {}
2271 };
2272 
2274 class HPS_API Extent
2275 {
2276 public:
2277 
2278  enum class ClipRegion : uint32_t
2279  {
2280  Include,
2281  Ignore
2282  };
2283 
2284 private:
2285  Extent() {}
2286 };
2287 
2288 class HPS_API GPU
2289 {
2290 public:
2291 
2296  enum class Preference
2297  {
2298  HighPerformance,
2299  Integrated,
2300  Specific,
2301  Default,
2302  };
2303 
2304 private:
2305  GPU() {}
2306 };
2307 
2308  typedef double Time;
2309 
2310 #ifdef _MSC_VER
2311 # ifndef HPS_INLINE
2312 # define HPS_INLINE __forceinline
2313 # endif
2314 #else
2315 # define HPS_INLINE inline
2316 #endif
2317 
2318 #ifndef HPS_UNREFERENCED
2319 #define HPS_UNREFERENCED(param) ((void)(param))
2320 #endif
2321 
2322 
2323 const double PI = 3.141592653589793238462643383279502884197169399375105820974944592308;
2324 
2325 template<typename T>
2326 HPS_INLINE T Degrees_To_Radians(T const & degrees)
2327 {
2328  return degrees * (T)(PI / 180.0);
2329 }
2330 
2331 template<typename T>
2332 HPS_INLINE T Radians_To_Degrees(T const & radians)
2333 {
2334  return radians * (T)(180.0 / PI);
2335 }
2336 
2337 template<typename T>
2338 HPS_INLINE void SinCos(T const & angle, T & sine, T & cosine) {
2339  T a = Degrees_To_Radians(angle);
2340  cosine = cos(a);
2341  sine = sin(a);
2342 }
2343 
2344 template<typename T>
2345 HPS_INLINE T Cos(T const & angle) {
2346  return cos (Degrees_To_Radians(angle));
2347 }
2348 
2349 template<typename T>
2350 HPS_INLINE T Sin(T const & angle) {
2351  return sin (Degrees_To_Radians(angle));
2352 }
2353 
2354 template<typename T>
2355 HPS_INLINE T ACos(T const & x) {
2356  if (x > 1)
2357  return 0;
2358  if (x < -1)
2359  return 180;
2360  return Radians_To_Degrees(acos(x));
2361 }
2362 
2363 template<typename T>
2364 HPS_INLINE T ATan2(T const & y, T const & x) {
2365  if (x == 0 && y == 0)
2366  return 0;
2367  return Radians_To_Degrees(atan2(y, x));
2368 }
2369 
2370 
2371 template <typename F> struct Float_Traits {};
2372 template <> struct Float_Traits<float> {
2373  typedef double Alternative;
2374  static const int Type = 1;
2375  static float Epsilon () { return 1.0e-30f; }
2376 };
2377 template <> struct Float_Traits<double> {
2378  typedef float Alternative;
2379  static const int Type = 2;
2380  static double Epsilon () { return 1.0e-300; }
2381 };
2382 
2383 
2384 
2386 class HPS_API Float {
2387 private:
2388  enum Parts {
2389 # if HOOPS_BIGENDIAN
2390  High, Low
2391 # else
2392  Low, High
2393 # endif
2394  };
2395 
2396  // & functions for a float represented in an int, * version for a double in an array of 2 ints
2397  static HPS_INLINE bool is_infinite(int32_t const & v) { return (v & 0x7FFFFFFF) == 0x7F800000; }
2398  static HPS_INLINE bool is_infinite(uint32_t const & v) { return (v & 0x7FFFFFFF) == 0x7F800000; }
2399  static HPS_INLINE bool is_infinite(int32_t const * v) { return (v[High] & 0x7FFFFFFF) == 0x7FF00000 && v[Low] == 0; }
2400  static HPS_INLINE bool is_infinite(uint32_t const * v) { return (v[High] & 0x7FFFFFFF) == 0x7FF00000 && v[Low] == 0; }
2401 
2402  static HPS_INLINE bool is_nan(int32_t const & v) {
2403  uint32_t exp = v & 0x7F800000, mantissa = v & 0x007FFFFF;
2404  return exp == 0x7F800000 && mantissa != 0;
2405  }
2406  static HPS_INLINE bool is_nan(uint32_t const & v) {
2407  uint32_t exp = v & 0x7F800000, mantissa = v & 0x007FFFFF;
2408  return exp == 0x7F800000 && mantissa != 0;
2409  }
2410  static HPS_INLINE bool is_nan(int32_t const * v) {
2411  uint32_t exp = v[High] & 0x7FF00000, mantissa_high = v[High] & 0x000FFFFF;
2412  return exp == 0x7FF00000 && (mantissa_high | v[Low]) != 0;
2413  }
2414  static HPS_INLINE bool is_nan(uint32_t const * v) {
2415  uint32_t exp = v[High] & 0x7FF00000, mantissa_high = v[High] & 0x000FFFFF;
2416  return exp == 0x7FF00000 && (mantissa_high | v[Low]) != 0;
2417  }
2418 
2419  static HPS_INLINE bool is_special(int32_t const & v) { return (v & 0x7F800000) == 0x7F800000; }
2420  static HPS_INLINE bool is_special(uint32_t const & v) { return (v & 0x7F800000) == 0x7F800000; }
2421  static HPS_INLINE bool is_special(int32_t const * v) { return (v[High] & 0x7FF00000) == 0x7FF00000; }
2422  static HPS_INLINE bool is_special(uint32_t const * v) { return (v[High] & 0x7FF00000) == 0x7FF00000; }
2423 public:
2424 
2426  static const float Infinity;
2428  static const float NegativeInfinity;
2429 
2431  static HPS_INLINE bool IsInfinite(float const & a) { return is_infinite (extract_uint32_t(a)); }
2432  static HPS_INLINE bool IsInfinite(double const & a) {
2433  uint32_t v[2];
2434  memcpy (v, &a, sizeof(double));
2435  return is_infinite (v);
2436  }
2437 
2439  static HPS_INLINE bool IsNAN(float const & a) { return is_nan (extract_uint32_t(a)); }
2440  static HPS_INLINE bool IsNAN(double const & a) {
2441  uint32_t v[2];
2442  memcpy (v, &a, sizeof(double));
2443  return is_nan (v);
2444  }
2445 
2447  static HPS_INLINE bool IsAbnormal(float const & a) { return is_special (extract_uint32_t(a)); }
2448  static HPS_INLINE bool IsAbnormal(double const & a) {
2449  uint32_t v[2];
2450  memcpy (v, &a, sizeof(double));
2451  return is_special (v);
2452  }
2453 
2456  static HPS_INLINE bool Equals(float const & a, float const & b, int tolerance = 32);
2457  static HPS_INLINE bool Equals(double const & a, double const & b, int tolerance = 32);
2458 
2459 #ifndef HOOPS_DEFINED
2460  template <typename Alloc>
2461  static HPS_INLINE bool Equals(std::vector<float, Alloc> const & a, std::vector<float, Alloc> const & b, int tolerance = 32)
2462  {
2463  if (a.size() != b.size())
2464  return false;
2465 
2466  auto it1 = a.begin();
2467  auto it2 = b.begin();
2468  auto const end = a.end();
2469  for ( ; it1 != end; ++it1, ++it2)
2470  {
2471  if (!Equals(*it1, *it2, tolerance))
2472  return false;
2473  }
2474  return true;
2475  }
2476 #endif
2477 
2478  static HPS_INLINE uint32_t extract_sign_bit(float const & a) {
2479  return extract_uint32_t(a) & 0x80000000;
2480  }
2481  static HPS_INLINE uint32_t extract_sign_bit(double const & a) {
2482  uint32_t v[2];
2483  memcpy (v, &a, sizeof(double));
2484  return v[High] & 0x80000000;
2485  }
2486 
2487  static HPS_INLINE void apply_sign_bit(float & a, uint32_t const & sign_bit) {
2488  uint32_t v = extract_uint32_t(a);
2489  v &= 0x7FFFFFFF;
2490  v |= sign_bit;
2491  inject_uint32_t(a, v);
2492  }
2493  static HPS_INLINE void apply_sign_bit(double & a, uint32_t const & sign_bit) {
2494  uint32_t v[2];
2495  memcpy (v, &a, sizeof(double));
2496  v[High] &= 0x7FFFFFFF;
2497  v[High] |= sign_bit;
2498  memcpy (&a, v, sizeof(double));
2499  }
2500 
2501 
2502  static HPS_INLINE unsigned char unit_to_byte(float const & a) {
2503  uint32_t v = extract_uint32_t(a);
2504 
2505  v &= 0x7FFFFFFF;
2506  if (v < 0x3B800000)
2507  return 0;
2508 
2509  v--;
2510 
2511  uint32_t exp = v >> 23;
2512  uint32_t man = (v & 0x007FFFFF) | 0x00800000;
2513 
2514  return (unsigned char) (man >> (16 + 126 - exp));
2515  }
2516 
2517  static HPS_INLINE unsigned char unit_to_byte_scaled(float const & a, unsigned char mix) {
2518  uint32_t v = extract_uint32_t(a);
2519 
2520  v &= 0x7FFFFFFF;
2521  if (v < 0x3B800000)
2522  return 0;
2523 
2524  v--;
2525 
2526  uint32_t exp = v >> 23;
2527  uint32_t man = (v & 0x007FFFFF) | 0x00800000;
2528 
2529  uint32_t x = (man >> (16 + 126 - exp));
2530 
2531  return (unsigned char) ((x * (mix+1)) >> 8);
2532  }
2533 
2534 
2535  static HPS_INLINE bool match(float const & a, float const & b) {
2536  uint32_t va = extract_uint32_t(a);
2537  uint32_t vb = extract_uint32_t(b);
2538 
2539  if (((va | vb) & 0x7FFFFFFF) == 0)
2540  return true;
2541 
2542  return va == vb;
2543  }
2544  static HPS_INLINE bool match(double const & a, double const & b) {
2545  return a == b;
2546  }
2547 
2548 
2549  static HPS_INLINE void replace_if_smaller(float & a, float const & b) {
2550  if (b < a)
2551  a = b;
2552  }
2553  static HPS_INLINE void replace_if_smaller(double & a, double const & b) {
2554  if (b < a)
2555  a = b;
2556  }
2557 
2558  static HPS_INLINE void replace_if_larger(float & a, float const & b) {
2559  if (b > a)
2560  a = b;
2561  }
2562  static HPS_INLINE void replace_if_larger(double & a, double const & b) {
2563  if (b > a)
2564  a = b;
2565  }
2566 
2567 
2568  static HPS_INLINE uint32_t extract_uint32_t(float const & a) {
2569  uint32_t i;
2570  memcpy(&i, &a, sizeof(float));
2571  return i;
2572  }
2573 
2574  static HPS_INLINE void inject_uint32_t(float & a, uint32_t const & i) {
2575  memcpy(&a, &i, sizeof(float));
2576  }
2577 
2578  static HPS_INLINE float C2F(unsigned char x) {
2579  //return (float)x * (1.0f/255.0f);
2580  return char_to_float[x];
2581  }
2582 
2583 
2584  // SSE convenience functions
2585  static HPS_INLINE void pack_4(float const & f, float * m) {
2586  memcpy(&m[0], &f, sizeof(float));
2587  memcpy(&m[1], &f, sizeof(float));
2588  memcpy(&m[2], &f, sizeof(float));
2589  memcpy(&m[3], &f, sizeof(float));
2590  }
2591 
2592  static HPS_INLINE void pack_4(float const & f0, float const & f1, float const & f2, float const & f3, float * m) {
2593  memcpy(&m[0], &f0, sizeof(float));
2594  memcpy(&m[1], &f1, sizeof(float));
2595  memcpy(&m[2], &f2, sizeof(float));
2596  memcpy(&m[3], &f3, sizeof(float));
2597  }
2598 
2599  static HPS_INLINE void unpack_4(float * f0, float const * const m) {
2600  memcpy(f0, m, sizeof(float)*4);
2601  }
2602 
2603  static HPS_INLINE void unpack_4(float & f0, float & f1, float & f2, float & f3, float const * const m) {
2604  memcpy(&f0, &m[0], sizeof(float));
2605  memcpy(&f1, &m[1], sizeof(float));
2606  memcpy(&f2, &m[2], sizeof(float));
2607  memcpy(&f3, &m[3], sizeof(float));
2608  }
2609 
2610 private:
2611  static const float char_to_float[256];
2612 
2613  Float();
2614 };
2615 
2616 
2618 
2619 
2620 template <typename T> HPS_INLINE T * Alter (T const * a) { return const_cast<T *>(a); }
2621 template <typename T> HPS_INLINE T & Alter (T const & a) { return const_cast<T &>(a); }
2622 
2623 template <typename T> HPS_INLINE T Abs (T const & a) { return a < 0 ? -a : a; }
2624 template <typename T> HPS_INLINE int Compare (T const & a, T const & b) { return a == b ? 0 : a < b ? -1 : 1; }
2625 template <typename T> HPS_INLINE int Sign (T const & a) { return Compare(a,(T)0); }
2626 template <typename T> HPS_INLINE void Swap (T & a, T & b) { T temp = a; a = b; b = temp; }
2627 template <typename T> HPS_INLINE int Floor(T const & a) { return ((a > 0 || (T)(int)a == a) ? (int)a : ((int)a - 1)); }
2628 template <typename T> HPS_INLINE int Ceiling(T const & a) { return ((a < 0 || (T)(int)a == a) ? (int)a : ((int)a + 1)); }
2629 
2630 template <typename T> HPS_INLINE T const & Min (T const & a, T const & b) { return a < b ? a : b; }
2631 template <typename T> HPS_INLINE T const & Min (T const & a, T const & b, T const & c) { return Min(Min(a,b),c); }
2632 template <typename T> HPS_INLINE T const & Min (T const & a, T const & b, T const & c, T const & d) { return Min(Min(a, b, c),d); }
2633 template <typename T> HPS_INLINE T const & Min (T const & a, T const & b, T const & c, T const & d, T const & e) { return Min(Min(a,b,c,d),e); }
2634 template <typename T> HPS_INLINE T const & Min (T const & a, T const & b, T const & c, T const & d, T const & e, T const & f) { return Min(Min(a,b,c,d,e),f); }
2635 
2636 template <typename T> HPS_INLINE T const & Max (T const & a, T const & b) { return a > b ? a : b; }
2637 template <typename T> HPS_INLINE T const & Max (T const & a, T const & b, T const & c) { return Max(Max(a,b),c); }
2638 template <typename T> HPS_INLINE T const & Max (T const & a, T const & b, T const & c, T const & d) { return Max(Max(a, b, c),d); }
2639 template <typename T> HPS_INLINE T const & Max (T const & a, T const & b, T const & c, T const & d, T const & e) { return Max(Max(a,b,c,d),e); }
2640 template <typename T> HPS_INLINE T const & Max (T const & a, T const & b, T const & c, T const & d, T const & e, T const & f) { return Max(Max(a,b,c,d,e),f); }
2641 
2642 template <typename T> HPS_INLINE T const & Clamp(T const & x, T const & min, T const & max) { return x < min ? min : x > max ? max : x; }
2643 
2644 
2645 template <> HPS_INLINE float Abs<float> (float const & a) {
2646  uint32_t v = Float::extract_uint32_t(a);
2647  v &= 0x7FFFFFFF;
2648  float f;
2649  Float::inject_uint32_t(f,v);
2650  return f;
2651 }
2652 
2653 template <> HPS_INLINE int Sign<float> (float const & a) {
2654  uint32_t v = Float::extract_uint32_t(a);
2655 
2656  if ((v & 0x7FFFFFFF) == 0)
2657  return 0;
2658 
2659  return ((int32_t)(v & 0x80000000)>>31) | 0x01;
2660 }
2661 
2662 
2664 
2665 HPS_INLINE bool Float::Equals(float const & a, float const & b, int tolerance) {
2666  int32_t va = Float::extract_uint32_t(a);
2667  int32_t vb = Float::extract_uint32_t(b);
2668 
2669  if (is_special(va) || is_special(vb)) {
2670  if (is_infinite(va) || is_infinite(vb))
2671  return va == vb; // final check is for sign bits same
2672  if (is_nan(va) || is_nan(vb))
2673  return false;
2674  }
2675 
2676  int const close_to_zero = 0x36A00000; // (approx) 5.0e-6f;
2677  if ((va & 0x7FFFFFFF) == 0)
2678  return (vb & 0x7FFFFFFF) < close_to_zero;
2679  else if ((vb & 0x7FFFFFFF) == 0)
2680  return (va & 0x7FFFFFFF) < close_to_zero;
2681 
2682  uint32_t sign_mask = va ^ vb;
2683  (int32_t &)sign_mask >>= 31;
2684 
2685  int32_t diff = ((va + sign_mask) ^ (sign_mask & 0x7FFFFFFF)) -vb;
2686  int32_t v1 = tolerance + diff;
2687  int32_t v2 = tolerance - diff;
2688  return (v1|v2) >= 0;
2689 }
2690 
2691 HPS_INLINE bool Float::Equals(double const & a, double const & b, int tolerance) {
2692  int32_t va[2], vb[2];
2693  memcpy (va, &a, sizeof(double));
2694  memcpy (vb, &b, sizeof(double));
2695 
2696  if (is_special(va) || is_special(vb)) {
2697  if (is_infinite(va) || is_infinite(vb))
2698  return va[High] == vb[High] && va[Low] == vb[Low]; // final check is for sign bits same
2699  if (is_nan(va) || is_nan(vb))
2700  return false;
2701  }
2702 
2703  if ((va[High] == 0 && va[Low] == 0) || (vb[High] == 0 && vb[Low] == 0))
2704  return Abs(a - b) < 0.000000000000005;
2705 
2706  if (extract_sign_bit(a) != extract_sign_bit(b))
2707  return a == b; //-V550
2708 
2709  if (va[High] != vb[High])
2710  return false;
2711 
2712  return Abs(va[Low] - vb[Low]) <= tolerance;
2713 }
2714 
2716 
2717 
2718 HPS_INLINE bool Is_Abnormal (float const & f) { return Float::IsAbnormal (f); }
2719 HPS_INLINE bool Is_Abnormal (double const & d) { return Float::IsAbnormal (d); }
2720 
2721 template <typename T>
2722 HPS_INLINE bool Is_Abnormal (size_t count, T const * t) {
2723  while (count-- > 0)
2724  if (Is_Abnormal (*t++))
2725  return true;
2726  return false;
2727 }
2728 
2729 template <typename T>
2730 HPS_INLINE bool Is_Abnormal (int count, T const * t) {
2731  return count >= 0 && Is_Abnormal((size_t)count, t);
2732 }
2733 
2734 
2736 
2737 
2738 template <typename F> class HPS_TEMPLATE_API Vector_3D;
2739 template <typename F> class HPS_TEMPLATE_API Plane_3D;
2740 template <typename F> class HPS_TEMPLATE_API Vector_2D;
2741 template <typename F> class HPS_TEMPLATE_API Point_2D;
2742 
2743 
2744 template <typename F>
2745 class HPS_TEMPLATE_API Point_3D {
2746  public:
2747  F x;
2748  F y;
2749  F z;
2750 
2751  Point_3D () {}
2752  Point_3D (F v1, F v2, F v3) : x (v1), y (v2), z (v3) {}
2753 
2754  template <typename D>
2755  explicit Point_3D (Point_3D<D> const & that) : x ((F)that.x), y ((F)that.y), z ((F)that.z) {}
2756 
2757  explicit Point_3D (Vector_3D<F> const & v);
2758  explicit Point_3D (Vector_2D<F> const & v);
2759  explicit Point_3D (Point_2D<F> const & that);
2760 
2761  Point_3D const operator- () const { return Point_3D (-x, -y, -z); }
2762 
2763  bool operator== (Point_3D const & p) const { return x == p.x && y == p.y && z == p.z; }
2764  bool operator!= (Point_3D const & p) const { return !(*this == p); }
2765 
2766  bool Equals(Point_3D const & p, int in_tolerance = 32) const {
2767  return Float::Equals(x, p.x, in_tolerance) &&
2768  Float::Equals(y, p.y, in_tolerance) &&
2769  Float::Equals(z, p.z, in_tolerance);
2770  }
2771 
2772 
2773  Point_3D & operator*= (F s) { x *= s; y *= s; z *= s; return *this; }
2774  Point_3D & operator/= (F s) { return operator*= ((F)1 / s); }
2775  Point_3D const operator* (F s) const { return Point_3D (x * s, y * s, z * s); }
2776  Point_3D const operator/ (F s) const { return operator* ((F)1 / s); }
2777 
2778  F & operator[] (size_t i) { return (&x)[i]; }
2779  F const & operator[] (size_t i) const { return (&x)[i]; }
2780 
2781  Point_3D & operator+= (Vector_3D<F> const & v);
2782  Point_3D & operator-= (Vector_3D<F> const & v);
2783  Point_3D & operator*= (Vector_3D<F> const & v);
2784  Point_3D & operator/= (Vector_3D<F> const & v);
2785  Point_3D const operator* (Vector_3D<F> const & v) const;
2786  Point_3D const operator/ (Vector_3D<F> const & v) const;
2787 
2788  Point_3D & operator+= (Vector_2D<F> const & v);
2789  Point_3D & operator-= (Vector_2D<F> const & v);
2790  Point_3D & operator*= (Vector_2D<F> const & v);
2791  Point_3D & operator/= (Vector_2D<F> const & v);
2792  Point_3D const operator* (Vector_2D<F> const & v) const;
2793  Point_3D const operator/ (Vector_2D<F> const & v) const;
2794 
2795  Vector_3D<F> const operator- (Point_3D const & p) const;
2796 
2797  Point_3D const operator+ (Vector_3D<F> const & v) const;
2798  Point_3D const operator- (Vector_3D<F> const & v) const;
2799 
2800  Point_3D const operator+ (Vector_2D<F> const & v) const;
2801  Point_3D const operator- (Vector_2D<F> const & v) const;
2802 
2803  static HPS_INLINE Point_3D Origin() {return Point_3D (0, 0, 0);};
2804  static HPS_INLINE Point_3D Zero() {return Point_3D (0, 0, 0);}; //-V524
2805 };
2806 
2807 typedef Point_3D<float> Point;
2808 typedef Point_3D<double> DPoint;
2809 
2810 
2811 
2812 template <typename F, typename S>
2813 HPS_INLINE Point_3D<F> operator* (S s, Point_3D<F> const & a) { return Point_3D<F> (F(s * a.x), F(s * a.y), F(s * a.z)); }
2814 
2815 template <typename F>
2816 HPS_INLINE Point_3D<F> Midpoint (Point_3D<F> const & a, Point_3D<F> const & b) {
2817  return Point_3D<F> (a.x + b.x, a.y + b.y, a.z + b.z) * 0.5f;
2818 }
2819 
2820 template <typename F>
2821 HPS_INLINE Point_3D<F> Midpoint (Point_3D<F> const & a, Point_3D<F> const & b, Point_3D<F> const & c) {
2822  return Point_3D<F> (a.x + b.x + c.x, a.y + b.y + c.y, a.z + b.z + c.z) * (F)(1.0/3.0);
2823 }
2824 
2825 template <typename F>
2826 HPS_INLINE bool Is_Abnormal (Point_3D<F> const & p) {
2827  return Is_Abnormal (p.x) || Is_Abnormal (p.y) || Is_Abnormal (p.z);
2828 }
2829 
2830 
2831 template <typename F>
2832 class HPS_TEMPLATE_API Point_2D {
2833 public:
2834  F x;
2835  F y;
2836 
2837  Point_2D () {}
2838  Point_2D (F v1, F v2) : x (v1), y (v2) {}
2839 
2840  template <typename D>
2841  explicit Point_2D (Point_2D<D> const & that) : x ((F)that.x), y ((F)that.y) {}
2842 
2843  explicit Point_2D (Point_3D<F> const & that) : x ((F)that.x), y ((F)that.y) {}
2844  explicit Point_2D (Vector_2D<F> const & v);
2845 
2846  Point_2D const operator- () const { return Point_2D (-x, -y); }
2847 
2848  bool operator== (Point_2D const & p) const { return x == p.x && y == p.y; }
2849  bool operator!= (Point_2D const & p) const { return !(*this == p); }
2850 
2851  bool Equals(Point_2D const & p, int in_tolerance = 32) const {
2852  return Float::Equals(x, p.x, in_tolerance) && Float::Equals(y, p.y, in_tolerance);
2853  }
2854 
2855 
2856  Point_2D & operator*= (F s) { x *= s; y *= s; return *this; }
2857  Point_2D & operator/= (F s) { return operator*= ((F)1 / s); }
2858  Point_2D const operator* (F s) const { return Point_2D (x * s, y * s); }
2859  Point_2D const operator/ (F s) const { return operator* ((F)1 / s); }
2860 
2861  F & operator[] (size_t i) { return (&x)[i]; }
2862  F const & operator[] (size_t i) const { return (&x)[i]; }
2863 
2864  Point_2D & operator+= (Vector_2D<F> const & v);
2865  Point_2D & operator-= (Vector_2D<F> const & v);
2866  Point_2D & operator*= (Vector_2D<F> const & v);
2867  Point_2D & operator/= (Vector_2D<F> const & v);
2868  Point_2D const operator* (Vector_2D<F> const & v) const;
2869  Point_2D const operator/ (Vector_2D<F> const & v) const;
2870 
2871  Vector_2D<F> const operator- (Point_2D const & p) const;
2872 
2873  Point_2D const operator+ (Vector_2D<F> const & v) const;
2874  Point_2D const operator- (Vector_2D<F> const & v) const;
2875 
2876  static HPS_INLINE Point_2D Origin() {return Point_2D (0, 0);};
2877  static HPS_INLINE Point_2D Zero() {return Point_2D (0, 0);}; //-V524
2878 };
2879 
2880 typedef Point_2D<float> Point2D;
2881 typedef Point_2D<double> DPoint2D;
2882 
2883 template <typename F>
2884 HPS_INLINE Point_3D<F>::Point_3D (Point_2D<F> const & that) : x (that.x), y (that.y), z (0) {}
2885 
2886 template <typename F, typename S>
2887 HPS_INLINE Point_2D<F> operator* (S s, Point_2D<F> const & a) { return Point_2D<F> (F(s * a.x), F(s * a.y)); }
2888 
2889 template <typename F>
2890 HPS_INLINE Point_2D<F> Midpoint (Point_2D<F> const & a, Point_2D<F> const & b) {
2891  return Point_2D<F> (a.x + b.x, a.y + b.y) * 0.5f;
2892 }
2893 
2894 template <typename F>
2895 HPS_INLINE Point_2D<F> Midpoint (Point_2D<F> const & a, Point_2D<F> const & b, Point_2D<F> const & c) {
2896  return Point_2D<F> (a.x + b.x + c.x, a.y + b.y + c.y, a.z + b.z + c.z) * (F)(1.0/3.0);
2897 }
2898 
2899 template <typename F>
2900 HPS_INLINE bool Is_Abnormal (Point_2D<F> const & p) {
2901  return Is_Abnormal (p.x) || Is_Abnormal (p.y);
2902 }
2903 
2904 
2905 template <typename F>
2906 class HPS_TEMPLATE_API Vector_3D {
2907  public:
2908  F x;
2909  F y;
2910  F z;
2911 
2912  Vector_3D () {}
2913  Vector_3D (F v1, F v2, F v3) : x (v1), y (v2), z (v3) {}
2914  template <typename D>
2915  explicit Vector_3D (Vector_3D<D> const & that) : x ((F)that.x), y ((F)that.y), z ((F)that.z) {}
2916  explicit Vector_3D(Point_3D<F> const & p) : x(p.x), y(p.y), z(p.z) {}
2917  explicit Vector_3D(Plane_3D<F> const & p);
2918 
2919  explicit Vector_3D (Vector_2D<F> const & that);
2920 
2921  Vector_3D const operator- () const { return Vector_3D (-x, -y, -z); }
2922 
2923  bool operator== (Vector_3D const & v) const {
2924  return Float::match(x, v.x) && Float::match(y, v.y) && Float::match(z, v.z);
2925  }
2926  bool operator!= (Vector_3D const & v) const { return !(*this == v); }
2927 
2928  bool Equals(Vector_3D const & v, int in_tolerance = 32) const {
2929  return Float::Equals(x, v.x, in_tolerance) &&
2930  Float::Equals(y, v.y, in_tolerance) &&
2931  Float::Equals(z, v.z, in_tolerance);
2932  }
2933 
2934  Vector_3D & operator+= (Vector_3D const & v) { x += v.x; y += v.y; z += v.z; return *this; }
2935  Vector_3D & operator-= (Vector_3D const & v) { x -= v.x; y -= v.y; z -= v.z; return *this; }
2936  Vector_3D const operator+ (Vector_3D const & v) const { return Vector_3D (x + v.x, y + v.y, z + v.z); }
2937  Vector_3D const operator- (Vector_3D const & v) const { return Vector_3D (x - v.x, y - v.y, z - v.z); }
2938 
2939  Vector_3D & operator*= (F s) { x *= s; y *= s; z *= s; return *this; }
2940  Vector_3D & operator/= (F s) { return operator*= (1.0f / s); }
2941  Vector_3D const operator* (F s) const { return Vector_3D (x * s, y * s, z * s); }
2942  Vector_3D const operator/ (F s) const { return operator* (1.0f / s); }
2943 
2944  F & operator[] (size_t i) { return (&x)[i]; }
2945  F const & operator[] (size_t i) const { return (&x)[i]; }
2946 
2947  HPS_INLINE double Length () const { return sqrt (LengthSquared()); }
2948 
2949  HPS_INLINE double LengthSquared () const { return (double)x*(double)x + (double)y*(double)y + (double)z*(double)z; }
2950 
2951  HPS_INLINE double Length2D () const { return sqrt (LengthSquared2D()); }
2952 
2953  HPS_INLINE double LengthSquared2D () const { return (double)x*(double)x + (double)y*(double)y;}
2954 
2955  HPS_INLINE Vector_3D & Normalize (bool check_range = false, F epsilon = Float_Traits<F>::Epsilon()) {// not const &; allow V.normalize() *= S;
2956  if (check_range) {
2957  F range = Max (Abs (x), Abs (y), Abs (z));
2958  if (range > F(1.0e10))
2959  operator/= (range);
2960  }
2961 
2962  F len = (F)Length();
2963  if (len > epsilon)
2964  operator/= (len);
2965  else
2966  *this = Zero();
2967  return *this;
2968  }
2969  HPS_INLINE Vector_3D & Normalize (F epsilon) { return Normalize (false, epsilon); }
2970 
2971  HPS_INLINE Vector_3D & Clean_Zeroes (F epsilon = F(1.0e-4)) {
2972  if (Abs(x) < epsilon)
2973  x = 0;
2974  if (Abs(y) < epsilon)
2975  y = 0;
2976  if (Abs(z) < epsilon)
2977  z = 0;
2978  return *this;
2979  }
2980 
2981  HPS_INLINE F Magnitude () const { return Max (Abs(x), Abs(y), Abs(z)); }
2982  HPS_INLINE F Manhattan () const { return Abs(x)+Abs(y)+Abs(z); }
2983 
2984  HPS_INLINE F Dot (Vector_3D const & v) const { return x * v.x + y * v.y + z * v.z; }
2985 
2986  HPS_INLINE Vector_3D Cross (Vector_3D const & v) const {
2987  return Vector_3D (y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
2988  }
2989 
2990 
2991  HPS_INLINE Vector_3D Scale (Vector_3D const & v) const {
2992  return Vector_3D (x * v.x, y * v.y, z * v.z);
2993  }
2994 
2995  Vector_3D<F> different_vector () const {
2996  if (Abs (x) < Abs (y))
2997  return Vector_3D<F>::XAxis();
2998  else
2999  return Vector_3D<F>::YAxis();
3000  }
3001 
3002 
3003  static HPS_INLINE Vector_3D XAxis() {return Vector_3D (1, 0, 0);};
3004  static HPS_INLINE Vector_3D YAxis() {return Vector_3D (0, 1, 0);};
3005  static HPS_INLINE Vector_3D ZAxis() {return Vector_3D (0, 0, 1);};
3006  static HPS_INLINE Vector_3D Zero() {return Vector_3D (0, 0, 0);};
3007  static HPS_INLINE Vector_3D Unit() {return Vector_3D (1, 1, 1);};
3008 };
3009 
3010 typedef Vector_3D<float> Vector;
3011 typedef Vector_3D<double> DVector;
3012 
3013 
3014 template <typename F, typename S>
3015 HPS_INLINE Vector_3D<F> operator* (S s, Vector_3D<F> const & v) {return Vector_3D<F> (F(s * v.x), F(s * v.y), F(s * v.z)); }
3016 
3017 template <typename F>
3018 HPS_INLINE bool Is_Abnormal (Vector_3D<F> const & v) {
3019  return Is_Abnormal (v.x) || Is_Abnormal (v.y) || Is_Abnormal (v.z);
3020 }
3021 
3022 
3023 template <typename F>
3024 HPS_INLINE Point_3D<F>::Point_3D(Vector_3D<F> const & v) : x(v.x), y(v.y), z(v.z) {}
3025 
3026 template <typename F>
3027 HPS_INLINE Point_3D<F> & Point_3D<F>::operator+= (Vector_3D<F> const & v) { x += v.x; y += v.y; z += v.z; return *this; }
3028 template <typename F>
3029 HPS_INLINE Point_3D<F> & Point_3D<F>::operator-= (Vector_3D<F> const & v) { x -= v.x; y -= v.y; z -= v.z; return *this; }
3030 
3031 template <typename F>
3032 HPS_INLINE Vector_3D<F> const Point_3D<F>::operator- (Point_3D<F> const & p) const { return Vector_3D<F> (x - p.x, y - p.y, z - p.z); }
3033 
3034 template <typename F>
3035 HPS_INLINE Point_3D<F> const Point_3D<F>::operator+ (Vector_3D<F> const & v) const { return Point_3D<F> (x + v.x, y + v.y, z + v.z); }
3036 template <typename F>
3037 HPS_INLINE Point_3D<F> const Point_3D<F>::operator- (Vector_3D<F> const & v) const { return Point_3D<F> (x - v.x, y - v.y, z - v.z); }
3038 
3039 template <typename F>
3040 HPS_INLINE Point_3D<F> & Point_3D<F>::operator*= (Vector_3D<F> const & v) { x *= v.x; y *= v.y; z *= v.z; return *this; }
3041 template <typename F>
3042 HPS_INLINE Point_3D<F> & Point_3D<F>::operator/= (Vector_3D<F> const & v) { x /= v.x; y /= v.y; z /= v.z; return *this; }
3043 template <typename F>
3044 HPS_INLINE Point_3D<F> const Point_3D<F>::operator* (Vector_3D<F> const & v) const { return Point_3D<F> (x * v.x, y * v.y, z * v.z); }
3045 template <typename F>
3046 HPS_INLINE Point_3D<F> const Point_3D<F>::operator/ (Vector_3D<F> const & v) const { return Point_3D<F> (x / v.x, y / v.y, z / v.z); }
3047 
3048 
3049 
3050 template <typename F>
3051 HPS_INLINE Point_3D<F> Interpolate(Point_3D<F> const & a, Point_3D<F> const & b, float t) {
3052  return a + (b - a) * t;
3053 }
3054 
3055 template <typename F>
3056 HPS_INLINE Vector_3D<F> Interpolate(Vector_3D<F> const & a, Vector_3D<F> const & b, float t) {
3057  return Vector_3D<F>(a + (b - a) * t).Normalize();
3058 }
3059 
3060 
3061 
3062 template <typename F>
3063 HPS_INLINE double PointToPointDistance(Point_3D<F> const & p1, Point_3D<F> const & p2) {
3064  return (p2 - p1).Length();
3065 }
3066 
3067 template <typename F>
3068 HPS_INLINE double PointToPointDistanceSquared(Point_3D<F> const & p1, Point_3D<F> const & p2) {
3069  return (p2 - p1).LengthSquared();
3070 }
3071 
3072 template <typename F>
3073 HPS_INLINE Point_3D<F> Circumcenter(Point_3D<F> const & a, Point_3D<F> const & b, Point_3D<F> const & c) {
3074  F p = static_cast<F>((c - b).LengthSquared());
3075  F q = static_cast<F>((c - a).LengthSquared());
3076  F r = static_cast<F>((b - a).LengthSquared());
3077 
3078  return Point_3D<F>(
3079  (a * (p*(q+r-p)) + (Vector_3D<F>)b * (q*(r+p-q)) + (Vector_3D<F>)c * (r*(p+q-r)))
3080  / (2 * (p*q + p*r + q*r) - (p*p + q*q + r*r)) );
3081 }
3082 
3083 
3084 
3085 template <typename F>
3086 HPS_INLINE bool Normalize(size_t count, Vector_3D<F> * vectors) {
3087  bool success = true;
3088  for (size_t i = 0; i < count; ++i) {
3089  if (vectors->Normalize() == Vector_3D<F>::Zero())
3090  success = false;
3091  vectors++;
3092  }
3093  return success;
3094 }
3095 
3096 
3097 template <typename F> class HPS_TEMPLATE_API Plane_2D;
3098 
3099 template <typename F>
3100 class HPS_TEMPLATE_API Vector_2D {
3101 public:
3102  F x;
3103  F y;
3104 
3105  Vector_2D () {}
3106  Vector_2D (F v1, F v2) : x (v1), y (v2) {}
3107  template <typename D>
3108  explicit Vector_2D (Vector_2D<D> const & that) : x ((F)that.x), y ((F)that.y) {}
3109 
3110  explicit Vector_2D (Vector_3D<F> const & that) : x (that.x), y (that.y) {}
3111  explicit Vector_2D (Point_2D<F> const & p) : x(p.x), y(p.y) {}
3112  explicit Vector_2D (Plane_2D<F> const & p);
3113 
3114  Vector_2D const operator- () const { return Vector_2D (-x, -y); }
3115 
3116  bool operator== (Vector_2D const & v) const {
3117  return Float::match(x, v.x) && Float::match(y, v.y);
3118  }
3119  bool operator!= (Vector_2D const & v) const { return !(*this == v); }
3120 
3121  bool Equals(Vector_2D const & v, int in_tolerance = 32) const {
3122  return Float::Equals(x, v.x, in_tolerance) && Float::Equals(y, v.y, in_tolerance);
3123  }
3124 
3125  Vector_2D & operator+= (Vector_2D const & v) { x += v.x; y += v.y; return *this; }
3126  Vector_2D & operator-= (Vector_2D const & v) { x -= v.x; y -= v.y; return *this; }
3127  Vector_2D const operator+ (Vector_2D const & v) const { return Vector_2D (x + v.x, y + v.y); }
3128  Vector_2D const operator- (Vector_2D const & v) const { return Vector_2D (x - v.x, y - v.y); }
3129 
3130  Vector_2D & operator*= (F s) { x *= s; y *= s; return *this; }
3131  Vector_2D & operator/= (F s) { return operator*= (1.0f / s); }
3132  Vector_2D const operator* (F s) const { return Vector_2D (x * s, y * s); }
3133  Vector_2D const operator/ (F s) const { return operator* (1.0f / s); }
3134 
3135  F & operator[] (size_t i) { return (&x)[i]; }
3136  F const & operator[] (size_t i) const { return (&x)[i]; }
3137 
3138  HPS_INLINE double Length () const { return sqrt (LengthSquared()); }
3139 
3140  HPS_INLINE double LengthSquared () const { return (double)x*(double)x + (double)y*(double)y; }
3141 
3142  HPS_INLINE Vector_2D & Normalize (bool check_range = false, F epsilon = Float_Traits<F>::Epsilon()) {// not const &; allow V.normalize() *= S;
3143  if (check_range) {
3144  F range = Max (Abs (x), Abs (y));
3145  if (range > F(1.0e10))
3146  operator/= (range);
3147  }
3148 
3149  F len = (F)Length();
3150  if (len > epsilon)
3151  operator/= (len);
3152  else
3153  *this = Zero();
3154  return *this;
3155  }
3156  HPS_INLINE Vector_2D & Normalize (F epsilon) { return Normalize (false, epsilon); }
3157 
3158  HPS_INLINE F Magnitude () const { return Max (Abs(x), Abs(y)); }
3159  HPS_INLINE F Manhattan () const { return Abs(x)+Abs(y); }
3160 
3161  HPS_INLINE F Dot (Vector_2D const & v) const { return x * v.x + y * v.y; }
3162 
3163 
3164  HPS_INLINE F Cross (Vector_2D const & v) const {
3165  return x * v.y - y * v.x;
3166  }
3167 
3168  HPS_INLINE Vector_2D Scale (Vector_2D const & v) const {
3169  return Vector_2D (x * v.x, y * v.y);
3170  }
3171 
3172  static HPS_INLINE Vector_2D XAxis() {return Vector_2D (1, 0);};
3173  static HPS_INLINE Vector_2D YAxis() {return Vector_2D (0, 1);};
3174 
3175  static HPS_INLINE Vector_2D Zero() {return Vector_2D (0, 0);};
3176  static HPS_INLINE Vector_2D Unit() {return Vector_2D (1, 1);};
3177 };
3178 
3179 typedef Vector_2D<float> Vector2D;
3181 
3182 template <typename F, typename S>
3183 HPS_INLINE Vector_2D<F> operator* (S s, Vector_2D<F> const & v) {return Vector_2D<F> (F(s * v.x), F(s * v.y)); }
3184 
3185 template <typename F>
3186 HPS_INLINE bool Is_Abnormal (Vector_2D<F> const & v) {
3187  return Is_Abnormal (v.x) || Is_Abnormal (v.y);
3188 }
3189 
3190 
3191 template <typename F>
3192 HPS_INLINE Vector_3D<F>::Vector_3D (Vector_2D<F> const & that) : x (that.x), y (that.y), z(0) {}
3193 
3194 template <typename F>
3195 HPS_INLINE Point_3D<F>::Point_3D(Vector_2D<F> const & v) : x(v.x), y(v.y), z(0) {}
3196 
3197 template <typename F>
3198 HPS_INLINE Point_3D<F> & Point_3D<F>::operator+= (Vector_2D<F> const & v) { x += v.x; y += v.y; return *this; }
3199 template <typename F>
3200 HPS_INLINE Point_3D<F> & Point_3D<F>::operator-= (Vector_2D<F> const & v) { x -= v.x; y -= v.y; return *this; }
3201 
3202 template <typename F>
3203 HPS_INLINE Point_3D<F> const Point_3D<F>::operator+ (Vector_2D<F> const & v) const { return Point_3D<F> (x + v.x, y + v.y, z); }
3204 template <typename F>
3205 HPS_INLINE Point_3D<F> const Point_3D<F>::operator- (Vector_2D<F> const & v) const { return Point_3D<F> (x - v.x, y - v.y, z); }
3206 
3207 template <typename F>
3208 HPS_INLINE Point_3D<F> & Point_3D<F>::operator*= (Vector_2D<F> const & v) { x *= v.x; y *= v.y; return *this; }
3209 template <typename F>
3210 HPS_INLINE Point_3D<F> & Point_3D<F>::operator/= (Vector_2D<F> const & v) { x /= v.x; y /= v.y; return *this; }
3211 
3212 template <typename F>
3213 HPS_INLINE Point_3D<F> const Point_3D<F>::operator* (Vector_2D<F> const & v) const { return Point_3D<F> (x * v.x, y * v.y, z); }
3214 template <typename F>
3215 HPS_INLINE Point_3D<F> const Point_3D<F>::operator/ (Vector_2D<F> const & v) const { return Point_3D<F> (x / v.x, y / v.y, z); }
3216 
3217 
3218 template <typename F>
3219 HPS_INLINE Point_2D<F> & Point_2D<F>::operator+= (Vector_2D<F> const & v) { x += v.x; y += v.y; return *this; }
3220 template <typename F>
3221 HPS_INLINE Point_2D<F> & Point_2D<F>::operator-= (Vector_2D<F> const & v) { x -= v.x; y -= v.y; return *this; }
3222 
3223 template <typename F>
3224 HPS_INLINE Vector_2D<F> const Point_2D<F>::operator- (Point_2D<F> const & p) const { return Vector_2D<F> (x - p.x, y - p.y); }
3225 
3226 template <typename F>
3227 HPS_INLINE Point_2D<F> const Point_2D<F>::operator+ (Vector_2D<F> const & v) const { return Point_2D<F> (x + v.x, y + v.y); }
3228 template <typename F>
3229 HPS_INLINE Point_2D<F> const Point_2D<F>::operator- (Vector_2D<F> const & v) const { return Point_2D<F> (x - v.x, y - v.y); }
3230 
3231 template <typename F>
3232 HPS_INLINE Point_2D<F> & Point_2D<F>::operator*= (Vector_2D<F> const & v) { x *= v.x; y *= v.y; return *this; }
3233 template <typename F>
3234 HPS_INLINE Point_2D<F> & Point_2D<F>::operator/= (Vector_2D<F> const & v) { x /= v.x; y /= v.y; return *this; }
3235 template <typename F>
3236 HPS_INLINE Point_2D<F> const Point_2D<F>::operator* (Vector_2D<F> const & v) const { return Point_2D<F> (x * v.x, y * v.y); }
3237 template <typename F>
3238 HPS_INLINE Point_2D<F> const Point_2D<F>::operator/ (Vector_2D<F> const & v) const { return Point_2D<F> (x / v.x, y / v.y); }
3239 
3240 
3241 
3242 
3243 
3244 template <typename F>
3245 class HPS_TEMPLATE_API Plane_3D {
3246  public:
3247  F a;
3248  F b;
3249  F c;
3250  F d;
3251 
3252  Plane_3D () {}
3253  Plane_3D (F v1, F v2, F v3, F v4) : a (v1), b (v2), c (v3), d (v4) {}
3254  Plane_3D (Vector_3D<F> const & v, F f = 0) : a (v.x), b (v.y), c (v.z), d (f) {}
3255  Plane_3D (Vector_3D<F> const & v, Point_3D<F> const & p) : a (v.x), b (v.y), c (v.z), d (-(p.x * v.x + p.y * v.y + p.z * v.z)) {}
3256  Plane_3D (Point_3D<F> const & p, Vector_3D<F> const & v) : a (v.x), b (v.y), c (v.z), d (-(p.x * v.x + p.y * v.y + p.z * v.z)) {}
3257  template <typename D>
3258  explicit Plane_3D (Plane_3D<D> const & that) : a ((F)that.a), b ((F)that.b), c ((F)that.c), d ((F)that.d) {}
3259 
3260  Plane_3D (size_t count, Point_3D<F> const * points) {
3261  if (count >= 3) {
3262  // The 3 coefficients A, B, and C are proportional to the areas of the
3263  // projections of the polygon onto the yz, zx, and xy planes, respectively.
3264 
3265  // run around the polygon, collecting trapezoidal areas
3266  // a "center" point is also collected, to make the plane 'd' slightly more "valid" when the polygon is non-planar.
3267 
3268  // take care of the swing point first
3269  Point_3D<F> const * p0 = &points[count-1];
3270 
3272  Vector_3D<F> normal = Vector_3D<F>::Zero();
3273 
3274  for (size_t i=0; i<count; ++i) {
3275  Point_3D<F> const * p1 = &points[i];
3276 
3277  normal.x += (p0->y + p1->y) * (p1->z - p0->z);
3278  normal.y += (p0->z + p1->z) * (p1->x - p0->x);
3279  normal.z += (p0->x + p1->x) * (p1->y - p0->y);
3280 
3281  ctr += Vector_3D<double>(Vector_3D<F>(points[i]));
3282 
3283  p0 = p1;
3284  }
3285 
3286  // ("should" always be != 0)
3287  if (normal.Normalize() != Vector_3D<F>::Zero()) {
3288  /* finish finding the average */
3289  double inv_count = 1.0 / (double)count;
3290  ctr *= inv_count;
3291 
3292  *this = Plane_3D(normal, Point_3D<F>(ctr));
3293  return;
3294  }
3295  }
3296 
3297  *this = Plane_3D::Zero();
3298  }
3299 
3300 
3301  Plane_3D const operator- () const { return Plane_3D (-a, -b, -c, -d); }
3302 
3303  bool operator== (Plane_3D const & p) const { return a == p.a && b == p.b && c == p.c && d == p.d; }
3304  bool operator!= (Plane_3D const & p) const { return !(*this == p); }
3305 
3306  F & operator[] (size_t i) { return (&a)[i]; }
3307  F const & operator[] (size_t i) const { return (&a)[i]; }
3308 
3309  HPS_INLINE bool Equals(Plane_3D const & p, int in_tolerance = 32) const {
3310  return Float::Equals(a, p.a, in_tolerance) && Float::Equals(b, p.b, in_tolerance) &&
3311  Float::Equals(c, p.c, in_tolerance) && Float::Equals(d, p.d, in_tolerance);
3312  }
3313 
3314  Plane_3D & Normalize (F epsilon = Float_Traits<F>::Epsilon()) { // not const &; allow V.normalize() *= S;
3315  F len = (F)Vector_3D<F>(*this).Length();
3316  if (len > epsilon)
3317  operator/= (len);
3318  else
3319  *this = Zero();
3320  return *this;
3321  }
3322 
3323  Point_3D<F> IntersectLineSegment(Point_3D<F> const & p1, Point_3D<F> const & p2, float eps = 1e-5f) const {
3324  F val1 = Abs (a * p1.x + b * p1.y + c * p1.z + d);
3325  F val2 = Abs (a * p2.x + b * p2.y + c * p2.z + d);
3326 
3327  if (val1 >= eps) {
3328  return Point_3D<F> (((val1 * p2.x) + (val2 * p1.x)) / (val1 + val2),
3329  ((val1 * p2.y) + (val2 * p1.y)) / (val1 + val2),
3330  ((val1 * p2.z) + (val2 * p1.z)) / (val1 + val2));
3331  }
3332  else
3333  return p1;
3334  }
3335 
3336  Point_3D<F> IntersectLineSegment2(Point_3D<F> const & p1, Point_3D<F> const & p2) const {
3337  F u = (a * p1.x + b * p1.y + c * p1.z + d) /
3338  (a * (p1.x - p2.x) + b * (p1.y - p2.y) + c * (p1.z - p2.z));
3339 
3340  return Point_3D<F>(p1.x + u * (p2.x - p1.x), p1.y + u * (p2.y - p1.y), p1.z + u * (p2.z - p1.z));
3341  }
3342 
3343 
3344  bool parallel (Plane_3D const & p) const {
3345  return equivalent (a, p.a) &&
3346  equivalent (b, p.b) &&
3347  equivalent (c, p.c);
3348  }
3349 
3350  bool equivalent (Plane_3D const & p) const {
3351  return parallel (p) &&
3352  equivalent (d, p.d, (F)1.0e-6);
3353  }
3354 
3355 
3356  static HPS_INLINE Plane_3D Zero() {return Plane_3D (0.0f, 0.0f, 0.0f, 0.0f);};
3357 
3358 
3359  private:
3360  Plane_3D & operator*= (F s) { a *= s; b *= s; c *= s; d *= s; return *this; }
3361  Plane_3D & operator/= (F s) { return operator*= ((F)1.0 / s); }
3362  Plane_3D const operator* (F s) const { return Plane_3D (a * s, b * s, c * s, d * s); }
3363  Plane_3D const operator/ (F s) const { return operator* ((F)1.0 / s); }
3364 
3365  static bool equivalent (float a, float b) { // for vector components
3366  if (Abs(a) < 1.0e-4f && Abs(b) < 1.0e-4f)
3367  return true;
3368  return Float::Equals (a, b);
3369  }
3370 
3371  static bool equivalent (float a, float b, float cutoff) { // for distance
3372  if (Abs(a) < cutoff && Abs(b) < cutoff)
3373  return a == b;
3374  return Float::Equals (a, b);
3375  }
3376 };
3377 
3378 typedef Plane_3D<float> Plane;
3379 typedef Plane_3D<double> DPlane;
3380 
3381 
3382 template <typename F>
3383 HPS_INLINE bool Is_Abnormal (Plane_3D<F> const & p) {
3384  return Is_Abnormal (p.a) || Is_Abnormal (p.b) || Is_Abnormal (p.c) || Is_Abnormal (p.d);
3385 }
3386 
3387 
3388 template <typename F>
3389 HPS_INLINE F operator* (Plane_3D<F> const & plane, Point_3D<F> const & point) {
3390  return plane.a * point.x + plane.b * point.y + plane.c * point.z + plane.d;
3391 }
3392 template <typename F>
3393 HPS_INLINE F operator* (Point_3D<F> const & point, Plane_3D<F> const & plane) {
3394  return plane * point;
3395 }
3396 
3397 template <typename F>
3398 HPS_INLINE Plane_3D<F> Interpolate(Plane_3D<F> const & a, Plane_3D<F> const & b, float t) {
3399  return Plane_3D<F>(a.a + (b.a - a.a) * t, a.b + (b.b - a.b) * t, a.c + (b.c - a.c) * t, a.d + (b.d - a.d) * t);
3400 }
3401 
3402 template <typename F>
3403 Vector_3D<F>::Vector_3D(Plane_3D<F> const & p) : x(p.a), y(p.b), z(p.c) {}
3404 
3405 
3406 
3407 
3408 
3409 
3410 template <typename F>
3411 class HPS_TEMPLATE_API Plane_2D {
3412 public:
3413  F a;
3414  F b;
3415  F c;
3416 
3417  Plane_2D () {}
3418  Plane_2D (F v1, F v2, F v3) : a (v1), b (v2), c (v3) {}
3419  Plane_2D (Vector_2D<F> const & v, F f = 0) : a (v.x), b (v.y), c (f) {}
3420  Plane_2D (Vector_2D<F> const & v, Point_2D<F> const & p) : a (v.x), b (v.y), c (-(p.x * v.x + p.y * v.y)) {}
3421  Plane_2D (Point_2D<F> const & p, Vector_2D<F> const & v) : a (v.x), b (v.y), c (-(p.x * v.x + p.y * v.y)) {}
3422  template <typename D>
3423  explicit Plane_2D (Plane_2D<D> const & that) : a ((F)that.a), b ((F)that.b), c ((F)that.c) {}
3424 
3425  Plane_2D const operator- () const { return Plane_2D (-a, -b, -c); }
3426 
3427  bool operator== (Plane_2D const & p) const { return a == p.a && b == p.b && c == p.c; }
3428  bool operator!= (Plane_2D const & p) const { return !(*this == p); }
3429 
3430  F & operator[] (size_t i) { return (&a)[i]; }
3431  F const & operator[] (size_t i) const { return (&a)[i]; }
3432 
3433  HPS_INLINE bool Equals(Plane_2D const & p, int in_tolerance = 32) const {
3434  return Float::Equals(a, p.a, in_tolerance) && Float::Equals(b, p.b, in_tolerance) && Float::Equals(c, p.c, in_tolerance);
3435  }
3436 
3437  Plane_2D & Normalize (F epsilon = Float_Traits<F>::Epsilon()) { // not const &; allow V.Normalize() *= S;
3438  F len = (F)Vector_2D<F>(*this).Length();
3439  if (len > epsilon)
3440  operator/= (len);
3441  else
3442  *this = Zero();
3443  return *this;
3444  }
3445 
3446  static HPS_INLINE Plane_2D Zero() {return Plane_2D (0.0f, 0.0f, 0.0f);};
3447 
3448 
3449 private:
3450  Plane_2D & operator*= (F s) { a *= s; b *= s; c *= s; return *this; }
3451  Plane_2D & operator/= (F s) { return operator*= ((F)1.0 / s); }
3452  Plane_2D const operator* (F s) const { return Plane_2D (a * s, b * s, c * s); }
3453  Plane_2D const operator/ (F s) const { return operator* ((F)1.0 / s); }
3454 };
3455 
3456 typedef Plane_2D<float> Plane2D;
3457 typedef Plane_2D<double> DPlane2D;
3458 
3459 
3460 template <typename F>
3461 HPS_INLINE bool Is_Abnormal (Plane_2D<F> const & p) {
3462  return Is_Abnormal (p.a) || Is_Abnormal (p.b) || Is_Abnormal (p.c);
3463 }
3464 
3465 
3466 template <typename F>
3467 HPS_INLINE F operator* (Plane_2D<F> const & plane, Point_2D<F> const & point) {
3468  return plane.a * point.x + plane.b * point.y + plane.c;
3469 }
3470 template <typename F>
3471 HPS_INLINE F operator* (Point_3D<F> const & point, Plane_2D<F> const & plane) {
3472  return plane * point;
3473 }
3474 
3475 template <typename F>
3476 HPS_INLINE Plane_2D<F> Interpolate(Plane_2D<F> const & a, Plane_2D<F> const & b, float t) {
3477  return Plane_2D<F>(a.a + (b.a - a.a) * t, a.b + (b.b - a.b) * t, a.c + (b.c - a.c) * t);
3478 }
3479 
3480 template <typename F>
3481 Vector_2D<F>::Vector_2D(Plane_2D<F> const & p) : x(p.a), y(p.b) {}
3482 
3483 
3484 
3485 
3486 struct Rectangle;
3487 
3488 struct HPS_API IntRectangle {
3489  int left;
3490  int right;
3491  int bottom;
3492  int top;
3493 
3494  IntRectangle()
3495  : left(std::numeric_limits<int>::max()), right(std::numeric_limits<int>::min()),
3496  bottom(std::numeric_limits<int>::max()), top(std::numeric_limits<int>::min()) {}
3497 
3498  IntRectangle(int in_left, int in_right, int in_bottom, int in_top)
3499  : left(in_left), right(in_right), bottom(in_bottom), top(in_top) {}
3500 
3501  IntRectangle(IntRectangle const & that)
3502  : left(that.left), right(that.right), bottom(that.bottom), top(that.top) {}
3503 
3504  explicit IntRectangle(Rectangle const & that);
3505 
3506  bool operator==(IntRectangle const & rect) const {
3507  return (left == rect.left && right == rect.right && bottom == rect.bottom && top == rect.top);
3508  }
3509 
3510  bool operator!=(IntRectangle const & rect) const {
3511  return !(*this == rect);
3512  }
3513 
3514  HPS_INLINE int PixelWidth() const {
3515  return right - left + 1;
3516  }
3517 
3518  HPS_INLINE int PixelHeight() const {
3519  return top - bottom + 1;
3520  }
3521 
3522  HPS_INLINE int Width() const {
3523  return right - left;
3524  }
3525 
3526  HPS_INLINE int Height() const {
3527  return top - bottom;
3528  }
3529 
3530  HPS_INLINE int Area() const {
3531  return Width() * Height();
3532  }
3533 
3534  HPS_INLINE float Aspect() const {
3535  return (float)Height() / (float)Width();
3536  }
3537 
3538  HPS_INLINE Point2D Center() const {
3539  return Point2D((float)(left + right) * 0.5f, (float)(bottom + top) * 0.5f);
3540  }
3541 
3542  HPS_INLINE bool Intersecting(IntRectangle const & rect) const {
3543  return right >= rect.left && left <= rect.right && top >= rect.bottom && bottom <= rect.top;
3544  }
3545 
3546  HPS_INLINE bool Contains(IntRectangle const & rect) const {
3547  return (left <= rect.left && right >= rect.right && bottom <= rect.bottom && top >= rect.top);
3548  }
3549 
3550  HPS_INLINE IntRectangle & Expand(int border) {
3551  left -= border;
3552  right += border;
3553  bottom -= border;
3554  top += border;
3555  return *this;
3556  }
3557 
3558  HPS_INLINE IntRectangle & Expand(IntRectangle const & rect) {
3559  left -= rect.left;
3560  right += rect.right;
3561  bottom -= rect.bottom;
3562  top += rect.top;
3563  return *this;
3564  }
3565 
3566  HPS_INLINE IntRectangle & Contract(int border) {
3567  left += border;
3568  right -= border;
3569  bottom += border;
3570  top -= border;
3571  return *this;
3572  }
3573 
3574  HPS_INLINE IntRectangle & Contract(IntRectangle const & rect) {
3575  left += rect.left;
3576  right -= rect.right;
3577  bottom += rect.bottom;
3578  top -= rect.top;
3579  return *this;
3580  }
3581 
3582  HPS_INLINE IntRectangle & Intersect(IntRectangle const & rect) {
3583  left = Max(left, rect.left);
3584  right = Min(right, rect.right);
3585  bottom = Max(bottom, rect.bottom);
3586  top = Min(top, rect.top);
3587  return *this;
3588  }
3589 
3590  HPS_INLINE IntRectangle & Union(IntRectangle const & rect) {
3591  left = Min(left, rect.left);
3592  right = Max(right, rect.right);
3593  bottom = Min(bottom, rect.bottom);
3594  top = Max(top, rect.top);
3595  return *this;
3596  }
3597 
3598 
3599  static HPS_INLINE IntRectangle Invalid() {
3600  return IntRectangle();
3601  }
3602 
3603  static HPS_INLINE IntRectangle Zero() {
3604  return IntRectangle(0, 0, 0, 0);
3605  }
3606 
3607 };
3608 
3609 HPS_INLINE IntRectangle Expand(IntRectangle const & a, IntRectangle const & border) {
3610  IntRectangle temp = a;
3611  return temp.Expand(border);
3612 }
3613 
3614 HPS_INLINE IntRectangle Expand(IntRectangle const & a, int border) {
3615  IntRectangle temp = a;
3616  return temp.Expand(border);
3617 }
3618 
3619 HPS_INLINE IntRectangle Contract(IntRectangle const & a, int border) {
3620  IntRectangle temp = a;
3621  return temp.Contract(border);
3622 }
3623 
3624 HPS_INLINE IntRectangle Contract(IntRectangle const & a, IntRectangle const & border) {
3625  IntRectangle temp = a;
3626  return temp.Contract(border);
3627 }
3628 
3629 HPS_INLINE IntRectangle Intersect(IntRectangle const & a, IntRectangle const & b) {
3630  IntRectangle temp = a;
3631  return temp.Intersect(b);
3632 }
3633 
3634 HPS_INLINE IntRectangle Union(IntRectangle const & a, IntRectangle const & b) {
3635  IntRectangle temp = a;
3636  return temp.Union(b);
3637 }
3638 
3639 struct HPS_API Rectangle {
3640  float left;
3641  float right;
3642  float bottom;
3643  float top;
3644 
3645  Rectangle()
3646  : left(std::numeric_limits<float>::max()), right(-std::numeric_limits<float>::max()),
3647  bottom(std::numeric_limits<float>::max()), top(-std::numeric_limits<float>::max()) {}
3648 
3649  Rectangle(float in_left, float in_right, float in_bottom, float in_top)
3650  : left(in_left), right(in_right), bottom(in_bottom), top(in_top) {}
3651 
3652  Rectangle(Rectangle const & that)
3653  : left(that.left), right(that.right), bottom(that.bottom), top(that.top) {}
3654 
3655  explicit Rectangle(IntRectangle const & that)
3656  : left((float)that.left), right((float)that.right), bottom((float)that.bottom), top((float)that.top) {}
3657 
3658  HPS_INLINE Rectangle(size_t count, Point const * points) {
3659  left = points->x;
3660  right = points->x;
3661  top = points->y;
3662  bottom = points->y;
3663  --count;
3664  if (count > 0) {
3665  ++points;
3666  Merge(count, points);
3667  }
3668  }
3669 
3670  HPS_INLINE Rectangle(size_t count, Point2D const * points) {
3671  left = points->x;
3672  right = points->x;
3673  top = points->y;
3674  bottom = points->y;
3675  --count;
3676  if (count > 0) {
3677  ++points;
3678  Merge(count, points);
3679  }
3680  }
3681 
3682  HPS_INLINE float Width() const {
3683  return right - left;
3684  }
3685 
3686  HPS_INLINE float Height() const {
3687  return top - bottom;
3688  }
3689 
3690  HPS_INLINE float Area() const {
3691  return Width() * Height();
3692  }
3693 
3694  HPS_INLINE float Aspect() const {
3695  return Height() / Width();
3696  }
3697 
3698  HPS_INLINE Point2D Center() const {
3699  return Point2D((left + right) * 0.5f, (bottom + top) * 0.5f);
3700  }
3701 
3702  HPS_INLINE void Merge(size_t count, Point const * points) {
3703 
3704  while (count > 1) {
3705  if (points[0].x > points[1].x) {
3706  Float::replace_if_smaller(left, points[1].x);
3707  Float::replace_if_larger(right, points[0].x);
3708  }
3709  else {
3710  Float::replace_if_smaller(left, points[0].x);
3711  Float::replace_if_larger(right, points[1].x);
3712  }
3713 
3714  if (points[0].y > points[1].y) {
3715  Float::replace_if_smaller(bottom, points[1].y);
3716  Float::replace_if_larger(top, points[0].y);
3717  }
3718  else {
3719  Float::replace_if_smaller(bottom, points[0].y);
3720  Float::replace_if_larger(top, points[1].y);
3721  }
3722 
3723  points += 2;
3724  count -= 2;
3725  }
3726 
3727  if (count > 0)
3728  Merge(*points);
3729  }
3730 
3731  HPS_INLINE void Merge(Point const & point) {
3732  Float::replace_if_smaller(left, point.x);
3733  Float::replace_if_smaller(bottom, point.y);
3734  Float::replace_if_larger(right, point.x);
3735  Float::replace_if_larger(top, point.y);
3736  }
3737 
3738  HPS_INLINE void Merge(size_t count, Point2D const * points) {
3739 
3740  while (count > 1) {
3741  if (points[0].x > points[1].x) {
3742  Float::replace_if_smaller(left, points[1].x);
3743  Float::replace_if_larger(right, points[0].x);
3744  }
3745  else {
3746  Float::replace_if_smaller(left, points[0].x);
3747  Float::replace_if_larger(right, points[1].x);
3748  }
3749 
3750  if (points[0].y > points[1].y) {
3751  Float::replace_if_smaller(bottom, points[1].y);
3752  Float::replace_if_larger(top, points[0].y);
3753  }
3754  else {
3755  Float::replace_if_smaller(bottom, points[0].y);
3756  Float::replace_if_larger(top, points[1].y);
3757  }
3758 
3759  points += 2;
3760  count -= 2;
3761  }
3762 
3763  if (count > 0)
3764  Merge(*points);
3765  }
3766 
3767  HPS_INLINE void Merge(Point2D const & point) {
3768  Float::replace_if_smaller(left, point.x);
3769  Float::replace_if_smaller(bottom, point.y);
3770  Float::replace_if_larger(right, point.x);
3771  Float::replace_if_larger(top, point.y);
3772  }
3773 
3774  HPS_INLINE bool operator==(Rectangle const & rect) const {
3775  return (left == rect.left && right == rect.right && bottom == rect.bottom && top == rect.top);
3776  }
3777 
3778  HPS_INLINE bool operator!=(Rectangle const & rect) const {
3779  return !(*this == rect);
3780  }
3781 
3782  HPS_INLINE bool Equals(Rectangle const & rect, int in_tolerance = 32) const {
3783  return Float::Equals(left, rect.left, in_tolerance) &&
3784  Float::Equals(right, rect.right, in_tolerance) &&
3785  Float::Equals(top, rect.top, in_tolerance) &&
3786  Float::Equals(bottom, rect.bottom, in_tolerance);
3787  }
3788 
3789  HPS_INLINE bool Intersecting(Rectangle const & rect) const {
3790  return right >= rect.left && left <= rect.right && top >= rect.bottom && bottom <= rect.top;
3791  }
3792 
3793  HPS_INLINE bool Contains(Point const & contained) const {
3794  return !(contained.x < left || contained.x > right || contained.y < bottom || contained.y > top);
3795  }
3796 
3797  HPS_INLINE bool Contains(Point2D const & contained) const {
3798  return !(contained.x < left || contained.x > right || contained.y < bottom || contained.y > top);
3799  }
3800 
3801  HPS_INLINE bool Contains(Rectangle const & rect) {
3802  return (left <= rect.left && right >= rect.right && bottom <= rect.bottom && top >= rect.top);
3803  }
3804 
3805  HPS_INLINE bool Contains(Rectangle const & rect, float epsilon) {
3806  return (left <= rect.left + epsilon && right >= rect.right - epsilon &&
3807  bottom <= rect.bottom + epsilon && top >= rect.top - epsilon);
3808  }
3809 
3810  HPS_INLINE Rectangle & Expand(float border) {
3811  left -= border;
3812  right += border;
3813  bottom -= border;
3814  top += border;
3815  return *this;
3816  }
3817 
3818  HPS_INLINE Rectangle & Expand(int border) {
3819  Expand((float)border);
3820  return *this;
3821  }
3822 
3823  HPS_INLINE Rectangle & Expand(Rectangle const & rect) {
3824  left -= rect.left;
3825  right += rect.right;
3826  bottom -= rect.bottom;
3827  top += rect.top;
3828  return *this;
3829  }
3830 
3831  HPS_INLINE Rectangle & Contract(int border) {
3832  left += border;
3833  right -= border;
3834  bottom += border;
3835  top -= border;
3836  return *this;
3837  }
3838 
3839  HPS_INLINE Rectangle & Contract(Rectangle const & rect) {
3840  left += rect.left;
3841  right -= rect.right;
3842  bottom += rect.bottom;
3843  top -= rect.top;
3844  return *this;
3845  }
3846 
3847  HPS_INLINE Rectangle & Intersect(Rectangle const & rect) {
3848  left = Max(left, rect.left);
3849  right = Min(right, rect.right);
3850  bottom = Max(bottom, rect.bottom);
3851  top = Min(top, rect.top);
3852  return *this;
3853  }
3854 
3855  HPS_INLINE Rectangle & Union(Rectangle const & rect) {
3856  left = Min(left, rect.left);
3857  right = Max(right, rect.right);
3858  bottom = Min(bottom, rect.bottom);
3859  top = Max(top, rect.top);
3860  return *this;
3861  }
3862 
3863  HPS_INLINE Rectangle & Inscribe_Scope(Rectangle const & scope) {
3864  float scale = (scope.right - scope.left) * 0.5f;
3865  float trans = (scope.right + scope.left) * 0.5f;
3866 
3867  left = left * scale + trans;
3868  right = right * scale + trans;
3869 
3870  scale = (scope.top - scope.bottom) * 0.5f;
3871  trans = (scope.top + scope.bottom) * 0.5f;
3872 
3873  bottom = bottom * scale + trans;
3874  top = top * scale + trans;
3875  return *this;
3876  }
3877 
3878  HPS_INLINE Rectangle & Circumscribe_Scope(Rectangle const & scope) {
3879  float tmp = 2.0f/(scope.right - scope.left);
3880  right = (right - scope.left) * tmp - 1.0f;
3881  left = (left - scope.left) * tmp - 1.0f;
3882 
3883  tmp = 2.0f/(scope.top - scope.bottom);
3884  top = (top - scope.bottom) * tmp - 1.0f;
3885  bottom = (bottom - scope.bottom) * tmp - 1.0f;
3886  return *this;
3887  }
3888 
3889  static HPS_INLINE Rectangle FullScope() {
3890  return Rectangle(-1.0f, 1.0f, -1.0f, 1.0f);
3891  }
3892 
3893  static HPS_INLINE Rectangle InvalidScope() {
3894  return Rectangle(1.0f, -1.0f, 1.0f, -1.0f);
3895  }
3896 
3897  static HPS_INLINE Rectangle Zero() {
3898  return Rectangle(0, 0, 0, 0);
3899  }
3900 
3901 };
3902 
3903 
3904 HPS_INLINE IntRectangle Floor(Rectangle const & a) {
3905  IntRectangle temp;
3906  temp.left = Floor (a.left);
3907  temp.right = Floor (a.right);
3908  temp.bottom = Floor (a.bottom);
3909  temp.top = Floor (a.top);
3910  return temp;
3911 }
3912 
3913 HPS_INLINE Rectangle Expand(Rectangle const & a, Rectangle const & border) {
3914  Rectangle temp = a;
3915  return temp.Expand(border);
3916 }
3917 
3918 HPS_INLINE Rectangle Expand(Rectangle const & a, float border) {
3919  Rectangle temp = a;
3920  return temp.Expand(border);
3921 }
3922 
3923 HPS_INLINE Rectangle Contract(Rectangle const & a, int border) {
3924  Rectangle temp = a;
3925  return temp.Contract(border);
3926 }
3927 
3928 HPS_INLINE Rectangle Contract(Rectangle const & a, Rectangle const & border) {
3929  Rectangle temp = a;
3930  return temp.Contract(border);
3931 }
3932 
3933 HPS_INLINE Rectangle Intersect(Rectangle const & a, Rectangle const & b) {
3934  Rectangle temp = a;
3935  return temp.Intersect(b);
3936 }
3937 
3938 HPS_INLINE Rectangle Union(Rectangle const & a, Rectangle const & b) {
3939  Rectangle temp = a;
3940  return temp.Union(b);
3941 }
3942 
3943 HPS_INLINE Rectangle Inscribe_Scope(Rectangle const & a, Rectangle const & scope) {
3944  Rectangle temp = a;
3945  return temp.Inscribe_Scope(scope);
3946 }
3947 
3948 HPS_INLINE Rectangle Circumscribe_Scope(Rectangle const & a, Rectangle const & scope) {
3949  Rectangle temp = a;
3950  return temp.Circumscribe_Scope(scope);
3951 }
3952 
3953 HPS_INLINE IntRectangle::IntRectangle(Rectangle const & that)
3954  : left ((int)that.left), right ((int)that.right), bottom ((int)that.bottom), top ((int)that.top) {}
3955 
3956 
3957 
3958 
3959 template <typename F>
3960 struct Sphere_3D;
3961 
3962 template <typename F>
3963 struct HPS_TEMPLATE_API Cuboid_3D {
3968 
3969 
3973  Cuboid_3D () : min (Limit_Point()), max (-Limit_Point()) {}
3974 
3975 
3980  template <typename D>
3981  explicit Cuboid_3D (Cuboid_3D<D> const & that) : min (Point_3D<F>(that.min)), max (Point_3D<F>(that.max)) {}
3982 
3983 
3988  Cuboid_3D (Sphere_3D<F> const & that);
3989 
3995  Cuboid_3D (Point_3D<F> const & in_min, Point_3D<F> const & in_max) : min (in_min), max (in_max) {}
3996 
4002  Cuboid_3D (size_t count, Point_3D<F> const * points) {
4003  if (count == 0) {
4004  min = Limit_Point();
4005  max = -Limit_Point();
4006  return;
4007  }
4008  min = max = *points++;
4009  if (--count > 0)
4010  Merge(count, points);
4011  }
4012 
4019  template <typename T>
4020  Cuboid_3D (size_t count, T const * indices, Point_3D<F> const * points) {
4021  if (count == 0) {
4022  min = Limit_Point();
4023  max = -Limit_Point();
4024  return;
4025  }
4026  min = max = points[*indices++];
4027  if (--count > 0)
4028  Merge(count, indices, points);
4029  }
4030 
4035  Cuboid_3D (Rectangle const & that) : min (Point_3D<F>(that.left, that.bottom, 0)), max (Point_3D<F>(that.right, that.top, 0)) {}
4036 
4040  HPS_INLINE bool IsValid() const {
4041  return min.x <= max.x && min.y <= max.y && min.z <= max.z;
4042  }
4043 
4047  static HPS_INLINE Cuboid_3D Invalid() {return Cuboid_3D ();};
4048 
4052  void Invalidate() {min = Limit_Point(); max = -Limit_Point();}
4053 
4058  HPS_INLINE bool operator== (Cuboid_3D const & cuboid) const { return (min == cuboid.min && max == cuboid.max); }
4059 
4064  HPS_INLINE bool operator!= (Cuboid_3D const & cuboid) const { return !(*this == cuboid); }
4065 
4070  HPS_INLINE void Generate_Cuboid_Points (Point_3D<F> * points) const {
4071  points[0] = Point_3D<F> (min.x, min.y, min.z);
4072  points[1] = Point_3D<F> (min.x, min.y, max.z);
4073  points[2] = Point_3D<F> (min.x, max.y, min.z);
4074  points[3] = Point_3D<F> (min.x, max.y, max.z);
4075  points[4] = Point_3D<F> (max.x, min.y, min.z);
4076  points[5] = Point_3D<F> (max.x, min.y, max.z);
4077  points[6] = Point_3D<F> (max.x, max.y, min.z);
4078  points[7] = Point_3D<F> (max.x, max.y, max.z);
4079  }
4080 
4084  HPS_INLINE Vector_3D<F> Diagonal() const { return max - min; }
4085 
4089  HPS_INLINE F Volume () const { return (max.x - min.x) * (max.y - min.y) * (max.z - min.z); }
4090 
4096  HPS_INLINE bool Intersecting (Cuboid_3D const & cuboid) const {
4097  return max.x >= cuboid.min.x && min.x <= cuboid.max.x &&
4098  max.y >= cuboid.min.y && min.y <= cuboid.max.y &&
4099  max.z >= cuboid.min.z && min.z <= cuboid.max.z;
4100  }
4101 
4107  HPS_INLINE bool Intersecting (Cuboid_3D const & cuboid, F const allowance) const {
4108  return max.x + allowance >= cuboid.min.x && min.x - allowance <= cuboid.max.x &&
4109  max.y + allowance >= cuboid.min.y && min.y - allowance <= cuboid.max.y &&
4110  max.z + allowance >= cuboid.min.z && min.z - allowance <= cuboid.max.z;
4111  }
4112 
4119  HPS_INLINE bool Intersecting (int dimension, Cuboid_3D const & cuboid) const {
4120  //ASSERT (0 <= dimension && dimension <= 2);
4121  return max[dimension] >= cuboid.min[dimension] && min[dimension] <= cuboid.max[dimension];
4122  }
4123 
4131  HPS_INLINE bool Intersecting (int dimension, Cuboid_3D const & cuboid, F const allowance) const {
4132  //ASSERT (0 <= dimension && dimension <= 2);
4133  return max[dimension] + allowance >= cuboid.min[dimension] && min[dimension] - allowance <= cuboid.max[dimension];
4134  }
4135 
4142  HPS_INLINE bool Intersecting (Point_3D<F> const & start, Vector_3D<F> const & direction) const {
4143  return LineIntersecting(start, direction, true);
4144  }
4145 
4152  HPS_INLINE bool Intersecting (Point_3D<F> const & point1, Point_3D<F> const & point2) const {
4153  Vector_3D<F> const direction = point2 - point1;
4154  return LineIntersecting(point1, direction, false);
4155  }
4156 
4162  HPS_INLINE void Merge(Cuboid_3D const & cuboid) {
4163  Float::replace_if_smaller(min.x, cuboid.min.x);
4164  Float::replace_if_smaller(min.y, cuboid.min.y);
4165  Float::replace_if_smaller(min.z, cuboid.min.z);
4166  Float::replace_if_larger(max.x, cuboid.max.x);
4167  Float::replace_if_larger(max.y, cuboid.max.y);
4168  Float::replace_if_larger(max.z, cuboid.max.z);
4169  }
4170 
4176  HPS_INLINE void Merge(Sphere_3D<F> const & sphere) { Merge (Cuboid_3D (sphere)); }
4177 
4183  HPS_INLINE void Merge(Point_3D<F> const & point) {
4184  Float::replace_if_smaller(min.x, point.x);
4185  Float::replace_if_smaller(min.y, point.y);
4186  Float::replace_if_smaller(min.z, point.z);
4187  Float::replace_if_larger(max.x, point.x);
4188  Float::replace_if_larger(max.y, point.y);
4189  Float::replace_if_larger(max.z, point.z);
4190  }
4191 
4198  void Merge(size_t count, Point_3D<F> const * points) {
4199  while (count > 1) {
4200  merge2(points[0], points[1]);
4201  points += 2;
4202  count -= 2;
4203  }
4204 
4205  if (count > 0)
4206  Merge(*points);
4207  }
4208 
4216  template <typename T>
4217  void Merge(size_t count, T const * indices, Point_3D<F> const * points) {
4218  while (count > 1) {
4219  T i1 = *indices++;
4220  T i2 = *indices++;
4221  merge2(points[i1], points[i2]);
4222  count -= 2;
4223  }
4224 
4225  if (count > 0)
4226  Merge(points[*indices]);
4227  }
4228 
4234  HPS_INLINE bool Contains(Cuboid_3D const & contained) const {
4235  return (contained.min.x >= min.x &&
4236  contained.min.y >= min.y &&
4237  contained.min.z >= min.z &&
4238  contained.max.x <= max.x &&
4239  contained.max.y <= max.y &&
4240  contained.max.z <= max.z);
4241  }
4242 
4248  HPS_INLINE bool Contains(Point_3D<F> const & contained) const {
4249  return (contained.x >= min.x &&
4250  contained.y >= min.y &&
4251  contained.z >= min.z &&
4252  contained.x <= max.x &&
4253  contained.y <= max.y &&
4254  contained.z <= max.z);
4255  }
4256 
4263  HPS_INLINE bool Contains(Point_3D<F> const & contained, F epsilon) const {
4264  return (contained.x >= min.x - epsilon &&
4265  contained.y >= min.y - epsilon &&
4266  contained.z >= min.z - epsilon &&
4267  contained.x <= max.x + epsilon &&
4268  contained.y <= max.y + epsilon &&
4269  contained.z <= max.z + epsilon);
4270  }
4271 
4277  HPS_INLINE Cuboid_3D & Intersect(Cuboid_3D const & cuboid) {
4278  Float::replace_if_larger(min.x, cuboid.min.x);
4279  Float::replace_if_larger(min.y, cuboid.min.y);
4280  Float::replace_if_larger(min.z, cuboid.min.z);
4281  Float::replace_if_smaller(max.x, cuboid.max.x);
4282  Float::replace_if_smaller(max.y, cuboid.max.y);
4283  Float::replace_if_smaller(max.z, cuboid.max.z);
4284  return *this;
4285  }
4286 
4292  HPS_INLINE Cuboid_3D & Union(Cuboid_3D const & cuboid) {
4293  Float::replace_if_smaller(min.x, cuboid.min.x);
4294  Float::replace_if_smaller(min.y, cuboid.min.y);
4295  Float::replace_if_smaller(min.z, cuboid.min.z);
4296  Float::replace_if_larger(max.x, cuboid.max.x);
4297  Float::replace_if_larger(max.y, cuboid.max.y);
4298  Float::replace_if_larger(max.z, cuboid.max.z);
4299  return *this;
4300  }
4301 
4307  HPS_INLINE Cuboid_3D & Expand(F border) {
4308  Vector_3D<F> delta (border, border, border);
4309  min -= delta;
4310  max += delta;
4311  return *this;
4312  }
4313 
4319  HPS_INLINE Cuboid_3D & Contract(F border) {
4320  Vector_3D<F> delta (border, border, border);
4321  min += delta;
4322  max -= delta;
4323  return *this;
4324  }
4325 
4326 private:
4327  void merge2(Point_3D<F> const & p1, Point_3D<F> const & p2) {
4328  if (p1.x > p2.x) {
4329  Float::replace_if_smaller(min.x, p2.x);
4330  Float::replace_if_larger(max.x, p1.x);
4331  }
4332  else {
4333  Float::replace_if_smaller(min.x, p1.x);
4334  Float::replace_if_larger(max.x, p2.x);
4335  }
4336 
4337  if (p1.y > p2.y) {
4338  Float::replace_if_smaller(min.y, p2.y);
4339  Float::replace_if_larger(max.y, p1.y);
4340  }
4341  else {
4342  Float::replace_if_smaller(min.y, p1.y);
4343  Float::replace_if_larger(max.y, p2.y);
4344  }
4345 
4346  if (p1.z > p2.z) {
4347  Float::replace_if_smaller(min.z, p2.z);
4348  Float::replace_if_larger(max.z, p1.z);
4349  }
4350  else {
4351  Float::replace_if_smaller(min.z, p1.z);
4352  Float::replace_if_larger(max.z, p2.z);
4353  }
4354  }
4355 
4356  HPS_INLINE static Point_3D<F> Limit_Point () {
4357  F const x = std::numeric_limits<F>::max();
4358  return Point_3D<F> (x, x, x);
4359  }
4360 
4361  bool LineIntersecting (Point_3D<F> const & start, Vector_3D<F> const & direction, bool is_ray) const;
4362 };
4363 
4364 typedef Cuboid_3D<float> SimpleCuboid;
4365 typedef Cuboid_3D<double> DSimpleCuboid;
4366 
4367 
4368 template <typename F>
4369 HPS_INLINE Cuboid_3D<F> Intersect(Cuboid_3D<F> const & a, Cuboid_3D<F> const & b) {
4370  Cuboid_3D<F> temp = a;
4371  return temp.Intersect(b);
4372 }
4373 
4374 template <typename F>
4375 HPS_INLINE Cuboid_3D<F> Union(Cuboid_3D<F> const & a, Cuboid_3D<F> const & b) {
4376  Cuboid_3D<F> temp = a;
4377  return temp.Union(b);
4378 }
4379 
4380 template <typename F>
4381 HPS_INLINE Cuboid_3D<F> Expand(Cuboid_3D<F> const & a, F border) {
4382  Cuboid_3D<F> temp = a;
4383  return temp.Expand(border);
4384 }
4385 
4386 template <typename F>
4387 HPS_INLINE Cuboid_3D<F> Contract(Cuboid_3D<F> const & a, F border) {
4388  Cuboid_3D<F> temp = a;
4389  return temp.Contract(border);
4390 }
4391 
4392 
4393 
4394 template <typename F>
4395 struct HPS_TEMPLATE_API Sphere_3D {
4396  Point_3D<F> center;
4397  F radius;
4398 
4399  Sphere_3D () : center(Point_3D<F>(0, 0, 0)), radius(-1) {}
4400 
4401  template <typename D>
4402  explicit Sphere_3D (Sphere_3D<D> const & that) : center(Point_3D<F>(that.center)), radius(F(that.radius)) {}
4403 
4404  Sphere_3D (Cuboid_3D<F> const & cuboid) {
4405  if (cuboid.max.x < cuboid.min.x || cuboid.max.y < cuboid.min.y || cuboid.max.z < cuboid.min.z)
4406  *this = Invalid();
4407  else {
4408  center = Midpoint(cuboid.min, cuboid.max);
4409  radius = F(0.5 * cuboid.Diagonal().Length());
4410  }
4411  }
4412 
4413  Sphere_3D (Point_3D<F> const & starting_center, F in_radius = 0) : center(starting_center), radius(in_radius) {}
4414 
4415  Sphere_3D (size_t count, Point_3D<F> const * points) : radius(0.0f) {
4416  Cuboid_3D<F> cuboid(count, points);
4417  center = Midpoint(cuboid.min, cuboid.max);
4418  Engulf (count, points);
4419  }
4420 
4421  template <typename T>
4422  Sphere_3D (size_t count, T const * indices, Point_3D<F> const * points) : radius(0.0f) {
4423  Cuboid_3D<F> cuboid(count, indices, points);
4424  center = Midpoint(cuboid.min, cuboid.max);
4425  Engulf (count, indices, points);
4426  }
4427 
4428  Sphere_3D (size_t count, Point_3D<F> const * points, Point_3D<F> const & starting_center)
4429  : center(starting_center), radius(0) {
4430  Engulf (count, points);
4431  }
4432 
4433  template <typename T>
4434  Sphere_3D (size_t count, T const * indices, Point_3D<F> const * points, Point_3D<F> const & starting_center)
4435  : center(starting_center), radius(0) {
4436  Engulf (count, indices, points);
4437  }
4438 
4439  HPS_INLINE bool IsValid() const {
4440  return radius >= 0;
4441  }
4442 
4443  static HPS_INLINE Sphere_3D Invalid() {return Sphere_3D(Point_3D<F>(0,0,0), -1);};
4444 
4445  void Invalidate() {radius = -1;}
4446 
4447  HPS_INLINE bool operator== (Sphere_3D const & sphere) const { return (center == sphere.center && radius == sphere.radius); }
4448  HPS_INLINE bool operator!= (Sphere_3D const & sphere) const { return !(*this == sphere); }
4449 
4450  HPS_INLINE F Volume () const { return F((4.0 / 3.0 * PI) * radius * radius * radius); }
4451 
4452  HPS_INLINE void Merge(Point_3D<F> const & point) {
4453  Vector_3D<F> dir = point - center;
4454  F distance = (F)dir.Length();
4455 
4456  if (distance > radius) {
4457  F t = F(0.5) * (distance - radius);
4458  center += t * dir.Normalize();
4459  radius += t;
4460  }
4461  }
4462 
4463  HPS_INLINE void Merge(size_t count, Point_3D<F> const * points) {
4464  F radius_squared = radius * radius;
4465  for (size_t i = 0; i < count; ++i) {
4466  Vector_3D<F> dir = *points - center;
4467  F distance_squared = (F)dir.LengthSquared();
4468 
4469  if (distance_squared > radius_squared) {
4470  F distance = sqrt(distance_squared);
4471  F t = F(0.5) * ( distance - radius);
4472  center += t * (distance > Float_Traits<F>::Epsilon() ? dir / distance : Vector_3D<F>::Zero());
4473  radius += t;
4474  radius_squared = radius * radius;
4475  }
4476 
4477  ++points;
4478  }
4479  }
4480 
4481  HPS_INLINE void Merge (Sphere_3D const & sphere) {
4482  Vector_3D<F> dir = sphere.center - center;
4483  F distance = (F)dir.Length();
4484 
4485  if (distance + sphere.radius > radius) {
4486  if (distance + radius > sphere.radius) {
4487  F t = F(0.5 * (sphere.radius + distance - radius));
4488  center += t * dir.Normalize();
4489  radius += t;
4490  }
4491  else {
4492  center = sphere.center;
4493  radius = sphere.radius;
4494  }
4495  }
4496  }
4497 
4498  HPS_INLINE void Merge (Cuboid_3D<F> const & cuboid) { Merge (Sphere_3D (cuboid)); }
4499 
4500 private:
4501  // Engulf expands the sphere to include the points, but does not change the center as Merge does
4502  HPS_INLINE void Engulf (size_t count, Point_3D<F> const * points) {
4503  double rsq = radius * radius;
4504  for (size_t i = 0; i < count; ++i) {
4505  double dsq = (*points++ - center).LengthSquared();
4506  if (dsq > rsq)
4507  rsq = dsq;
4508  }
4509  radius = (F)sqrt(rsq);
4510  }
4511 
4512  template <typename T>
4513  HPS_INLINE void Engulf (size_t count, T const * indices, Point_3D<F> const * points) {
4514  double rsq = radius * radius;
4515  for (size_t i = 0; i < count; ++i) {
4516  double dsq = (points[*indices++] - center).LengthSquared();
4517  if (dsq > rsq)
4518  rsq = dsq;
4519  }
4520  radius = (F)sqrt(rsq);
4521  }
4522 };
4523 
4524 typedef Sphere_3D<float> SimpleSphere;
4525 typedef Sphere_3D<double> DSimpleSphere;
4526 
4527 
4528 template <typename F>
4529 HPS_INLINE Cuboid_3D<F>::Cuboid_3D(Sphere_3D<F> const & sphere) {
4530  if (sphere.radius < 0)
4531  *this = Invalid();
4532  else {
4533  min = Point_3D<F>(sphere.center.x - sphere.radius, sphere.center.y - sphere.radius, sphere.center.z - sphere.radius);
4534  max = Point_3D<F>(sphere.center.x + sphere.radius, sphere.center.y + sphere.radius, sphere.center.z + sphere.radius);
4535  }
4536 }
4537 
4538 
4539 
4540 
4541 class RGB24Color;
4542 class RGBA32Color;
4543 class RGBAS32Color;
4544 class RGBAColor;
4545 
4546 class HPS_API RGBColor {
4547 public:
4548  float red;
4549  float green;
4550  float blue;
4551 
4552  HPS_INLINE RGBColor () {}
4553  HPS_INLINE RGBColor (float r, float g, float b) : red (r), green (g), blue (b) {}
4554  explicit HPS_INLINE RGBColor (RGB24Color const & c24);
4555  explicit HPS_INLINE RGBColor (float gray) : red (gray), green (gray), blue (gray) {}
4556  explicit HPS_INLINE RGBColor (RGBAS32Color const & c32);
4557  explicit HPS_INLINE RGBColor (RGBA32Color const & c32);
4558  explicit HPS_INLINE RGBColor (RGBAColor const & c);
4559 
4560  HPS_INLINE bool IsGray() const {return (red == green && green == blue);}
4561  HPS_INLINE float Gray() const { return 0.3125f * red + 0.5000f * green + 0.1875f * blue; }
4562  float Distance(RGBColor const & other_color) const;
4563  HPS_INLINE bool IsValid() const {
4564  return (Float::extract_sign_bit(red) | Float::extract_sign_bit(green) | Float::extract_sign_bit(blue)) == 0;
4565  }
4566 
4567  HPS_INLINE bool operator== (RGBColor const & c) const { return red == c.red && green == c.green && blue == c.blue; }
4568  HPS_INLINE bool operator!= (RGBColor const & c) const { return !(*this == c); }
4569 
4570  HPS_INLINE bool Equals(RGBColor const & c, int in_tolerance = 32) const
4571  { return Float::Equals(red, c.red, in_tolerance) && Float::Equals(green, c.green, in_tolerance) && Float::Equals(blue, c.blue, in_tolerance); }
4572 
4573  HPS_INLINE RGBColor & operator*= (RGBColor const & c) { red *= c.red; green *= c.green; blue *= c.blue; return *this; }
4574  HPS_INLINE RGBColor & operator+= (RGBColor const & c) { red += c.red; green += c.green; blue += c.blue; return *this; }
4575  HPS_INLINE RGBColor & operator-= (RGBColor const & c) { red -= c.red; green -= c.green; blue -= c.blue; return *this; }
4576  HPS_INLINE RGBColor const operator* (RGBColor const & c) const { return RGBColor (red * c.red, green * c.green, blue * c.blue); }
4577  HPS_INLINE RGBColor const operator+ (RGBColor const & c) const { return RGBColor (red + c.red, green + c.green, blue + c.blue); }
4578  HPS_INLINE RGBColor const operator- (RGBColor const & c) const { return RGBColor (red - c.red, green - c.green, blue - c.blue); }
4579 
4580  HPS_INLINE RGBColor & operator*= (float s) { red *= s; green *= s; blue *= s; return *this; }
4581  HPS_INLINE RGBColor & operator/= (float s) { return operator*= (1.0f / s); }
4582  HPS_INLINE RGBColor & operator+= (float s) { red += s; green += s; blue += s; return *this; }
4583  HPS_INLINE RGBColor & operator-= (float s) { red -= s; green -= s; blue -= s; return *this; }
4584  HPS_INLINE RGBColor const operator* (float s) const { return RGBColor (red * s, green * s, blue * s); }
4585  HPS_INLINE RGBColor const operator/ (float s) const { return operator* (1.0f / s); }
4586  HPS_INLINE RGBColor const operator+ (float s) const { return RGBColor (red + s, green + s, blue + s); }
4587  HPS_INLINE RGBColor const operator- (float s) const { return RGBColor (red - s, green - s, blue - s); }
4588 
4589  static HPS_INLINE RGBColor Black() {return RGBColor (0, 0, 0);};
4590  static HPS_INLINE RGBColor White() {return RGBColor (1, 1, 1);};
4591  static HPS_INLINE RGBColor Invalid() {return RGBColor (-1, -1, -1);};
4592 
4593  void ShowHLS(float & out_hue, float & out_lightness, float & out_saturation) const;
4594  void ShowHSV(float & out_hue, float & out_saturation, float & out_value) const;
4595  void ShowHIC(float & out_hue, float & out_intensity, float & out_chromaticity) const;
4596 
4597  static RGBColor HLS(float in_hue, float in_lightness, float in_saturation);
4598  static RGBColor HSV(float in_hue, float in_saturation, float in_value);
4599  static RGBColor HIC(float in_hue, float in_intensity, float in_chromaticity);
4600 };
4601 
4602 HPS_INLINE RGBColor const operator* (float s, RGBColor const & v) { return RGBColor (s * v.red, s * v.green, s * v.blue); }
4603 HPS_INLINE RGBColor const operator+ (float s, RGBColor const & v) { return RGBColor (s + v.red, s + v.green, s + v.blue); }
4604 HPS_INLINE RGBColor const operator- (float s, RGBColor const & v) { return RGBColor (s - v.red, s - v.green, s - v.blue); }
4605 
4606 
4607 class HPS_API RGBAColor {
4608 public:
4609 
4610  float red;
4611  float green;
4612  float blue;
4613  float alpha;
4615  HPS_INLINE RGBAColor () {}
4616  explicit HPS_INLINE RGBAColor (float gray, float a = 1) : red (gray), green (gray), blue (gray), alpha (a) {}
4617  HPS_INLINE RGBAColor (float r, float g, float b, float a = 1) : red (r), green (g), blue (b), alpha (a) {}
4618 
4619  HPS_INLINE RGBAColor (RGBColor const & c) {
4620  memcpy(this, &c, sizeof(RGBColor)); //-V512
4621  alpha = 1.0f;
4622  Float::apply_sign_bit(alpha, Float::extract_sign_bit(c.red) | Float::extract_sign_bit(c.green) | Float::extract_sign_bit(c.blue));
4623  }
4624  HPS_INLINE RGBAColor (RGBColor const & c, float a) {
4625  memcpy(this, &c, sizeof(RGBColor));
4626  memcpy(&alpha, &a, sizeof(float));
4627  Float::apply_sign_bit(alpha, Float::extract_sign_bit(c.red) | Float::extract_sign_bit(c.green) | Float::extract_sign_bit(c.blue));
4628  }
4629  explicit HPS_INLINE RGBAColor (RGBA32Color const & c32);
4630  explicit HPS_INLINE RGBAColor (RGBAS32Color const & c32);
4631 
4632  HPS_INLINE bool IsGray() const {return (red == green && green == blue);}
4633  HPS_INLINE float Gray() const { return 0.3125f * red + 0.5000f * green + 0.1875f * blue; }
4634  HPS_INLINE bool IsValid() const {
4635  return (Float::extract_sign_bit(red) | Float::extract_sign_bit(green) | Float::extract_sign_bit(blue) | Float::extract_sign_bit(alpha)) == 0;
4636  }
4637 
4644  HPS_INLINE bool operator== (RGBAColor const & c) const { return red == c.red && green == c.green && blue == c.blue && alpha == c.alpha; }
4645 
4652  HPS_INLINE bool operator!= (RGBAColor const & c) const { return !(*this == c); }
4653 
4654  HPS_INLINE bool Equals(RGBAColor const & c, int in_tolerance = 32) const {
4655  return Float::Equals(red, c.red, in_tolerance) && Float::Equals(green, c.green, in_tolerance) &&
4656  Float::Equals(blue, c.blue, in_tolerance) && Float::Equals(alpha, c.alpha, in_tolerance);
4657  }
4658 
4659  HPS_INLINE RGBAColor & operator*= (RGBAColor const & c) { red *= c.red; green *= c.green; blue *= c.blue; alpha *= c.alpha; return *this; }
4660  HPS_INLINE RGBAColor & operator+= (RGBAColor const & c) { red += c.red; green += c.green; blue += c.blue; alpha += c.alpha; return *this; }
4661  HPS_INLINE RGBAColor & operator-= (RGBAColor const & c) { red -= c.red; green -= c.green; blue -= c.blue; alpha -= c.alpha; return *this; }
4662  HPS_INLINE RGBAColor const operator* (RGBAColor const & c) const { return RGBAColor (red * c.red, green * c.green, blue * c.blue, alpha * c.alpha); }
4663  HPS_INLINE RGBAColor const operator+ (RGBAColor const & c) const { return RGBAColor (red + c.red, green + c.green, blue + c.blue, alpha + c.alpha); }
4664  HPS_INLINE RGBAColor const operator- (RGBAColor const & c) const { return RGBAColor (red - c.red, green - c.green, blue - c.blue, alpha - c.alpha); }
4665 
4666  HPS_INLINE RGBAColor & operator*= (float s) { red *= s; green *= s; blue *= s; alpha *= s; return *this; }
4667  HPS_INLINE RGBAColor & operator/= (float s) { return operator*= (1.0f / s); }
4668  HPS_INLINE RGBAColor & operator+= (float s) { red += s; green += s; blue += s; alpha += s; return *this; }
4669  HPS_INLINE RGBAColor & operator-= (float s) { red -= s; green -= s; blue -= s; alpha -= s; return *this; }
4670  HPS_INLINE RGBAColor const operator* (float s) const { return RGBAColor (red * s, green * s, blue * s, alpha * s); }
4671  HPS_INLINE RGBAColor const operator/ (float s) const { return operator* (1.0f / s); }
4672  HPS_INLINE RGBAColor const operator+ (float s) const { return RGBAColor (red + s, green + s, blue + s, alpha + s); }
4673  HPS_INLINE RGBAColor const operator- (float s) const { return RGBAColor (red - s, green - s, blue - s, alpha - s); }
4674 
4675  HPS_INLINE RGBAColor & operator*= (RGBColor const & c) { red *= c.red; green *= c.green; blue *= c.blue; return *this; }
4676  HPS_INLINE RGBAColor & operator+= (RGBColor const & c) { red += c.red; green += c.green; blue += c.blue; return *this; }
4677  HPS_INLINE RGBAColor & operator-= (RGBColor const & c) { red -= c.red; green -= c.green; blue -= c.blue; return *this; }
4678  HPS_INLINE RGBAColor const operator* (RGBColor const & c) const { return RGBAColor (red * c.red, green * c.green, blue * c.blue, alpha); }
4679  HPS_INLINE RGBAColor const operator+ (RGBColor const & c) const { return RGBAColor (red + c.red, green + c.green, blue + c.blue, alpha); }
4680  HPS_INLINE RGBAColor const operator- (RGBColor const & c) const { return RGBAColor (red - c.red, green - c.green, blue - c.blue, alpha); }
4681 
4682  static HPS_INLINE RGBAColor Black() {return RGBAColor (0, 0, 0, 1);};
4683  static HPS_INLINE RGBAColor White() {return RGBAColor (1, 1, 1, 1);};
4684  static HPS_INLINE RGBAColor Nothing() {return RGBAColor (0, 0, 0, 0);};
4685  static HPS_INLINE RGBAColor Invalid() {return RGBAColor (-1, -1, -1, -1);};
4686 };
4687 
4688 HPS_INLINE RGBAColor const operator* (float s, RGBAColor const & v) { return RGBAColor (s * v.red, s * v.green, s * v.blue, s * v.alpha); }
4689 HPS_INLINE RGBAColor const operator+ (float s, RGBAColor const & v) { return RGBAColor (s + v.red, s + v.green, s + v.blue, s + v.alpha); }
4690 HPS_INLINE RGBAColor const operator- (float s, RGBAColor const & v) { return RGBAColor (s - v.red, s - v.green, s - v.blue, s - v.alpha); }
4691 
4692 
4693 
4695 public:
4696  enum Order {
4697  Order_ABGR,
4698  Order_RGBA,
4699  Order_BGRA
4700  };
4701 
4702 #ifdef _MSC_VER
4703  HPS_INLINE static Order Preferred_Order () {return Order_BGRA;}
4704  unsigned char b, g, r, a;
4705 #endif
4706 
4707 #ifdef __linux__
4708  HPS_INLINE static Order Preferred_Order () {return Order_RGBA;}
4709  unsigned char r, g, b, a;
4710 #endif
4711 
4712 #ifdef __APPLE_CC__
4713  HPS_INLINE static Order Preferred_Order () {return Order_RGBA;}
4714  unsigned char r, g, b, a;
4715 #endif
4716 };
4717 
4718 
4719 
4721 public:
4722 
4723  HPS_INLINE RGBAS32Color () /* : DirectRGBColor() */ {}
4724  explicit HPS_INLINE RGBAS32Color (unsigned char gray, unsigned char aa = 255) {
4725  r = gray;
4726  g = gray;
4727  b = gray;
4728  a = aa;
4729  }
4730  HPS_INLINE RGBAS32Color (unsigned char rr, unsigned char gg, unsigned char bb, unsigned char aa = 255) {
4731  r = rr;
4732  g = gg;
4733  b = bb;
4734  a = aa;
4735  }
4736  HPS_INLINE RGBAS32Color (DirectRGBColor const & c) : DirectRGBColor(c) {};
4737 
4738  explicit HPS_INLINE RGBAS32Color (RGBColor const & c)
4739  {
4740  r = Float::unit_to_byte(c.red);
4741  g = Float::unit_to_byte(c.green);
4742  b = Float::unit_to_byte(c.blue);
4743  a = 255;
4744  }
4745 
4746  HPS_INLINE RGBAS32Color (RGB24Color const & c);
4747 
4748  HPS_INLINE RGBAS32Color (RGBA32Color const & c);
4749 
4750  HPS_INLINE RGBAS32Color (RGBColor const & c, float alpha)
4751  {
4752  r = Float::unit_to_byte(c.red);
4753  g = Float::unit_to_byte(c.green);
4754  b = Float::unit_to_byte(c.blue);
4755  a = Float::unit_to_byte(alpha);
4756  }
4757  HPS_INLINE RGBAS32Color (RGBColor const & c, unsigned char aa)
4758  {
4759  r = Float::unit_to_byte(c.red);
4760  g = Float::unit_to_byte(c.green);
4761  b = Float::unit_to_byte(c.blue);
4762  a = aa;
4763  }
4764  explicit HPS_INLINE RGBAS32Color (RGBAColor const & c)
4765  {
4766  r = Float::unit_to_byte(c.red);
4767  g = Float::unit_to_byte(c.green);
4768  b = Float::unit_to_byte(c.blue);
4769  a = Float::unit_to_byte(c.alpha);
4770  }
4771  HPS_INLINE RGBAS32Color (RGBAColor const & c, unsigned char mix)
4772  {
4773  r = Float::unit_to_byte(c.red);
4774  g = Float::unit_to_byte(c.green);
4775  b = Float::unit_to_byte(c.blue);
4776  a = Float::unit_to_byte_scaled(c.alpha, mix);
4777  }
4778 
4779  HPS_INLINE bool IsGray() const {return (r == g && g == b);}
4780  HPS_INLINE unsigned char Gray() const { return (unsigned char)(0.3125f * (float)r + 0.5000f * (float)g + 0.1875f * (float)b); }
4781  HPS_INLINE bool IsValid() const { return ((r | g | b | a) != 0); }
4782 
4783  HPS_INLINE bool operator== (RGBAS32Color const & c) const { return (r == c.r && g == c.g && b == c.b && a == c.a); }
4784  HPS_INLINE bool operator!= (RGBAS32Color const & c) const { return !(*this == c); }
4785 
4786  static HPS_INLINE RGBAS32Color Black() {return RGBAS32Color (0, 0, 0, 255);};
4787  static HPS_INLINE RGBAS32Color White() {return RGBAS32Color (255, 255, 255, 255);};
4788  static HPS_INLINE RGBAS32Color Invalid() {return RGBAS32Color (0, 0, 0, 0);};
4789 
4790  static HPS_INLINE unsigned char Opaque_Alpha () {return 0xFF;}
4791 };
4792 
4794 public:
4795  unsigned char r;
4796  unsigned char g;
4797  unsigned char b;
4798  unsigned char a;
4799 
4800  HPS_INLINE RGBA32Color () {}
4801  explicit HPS_INLINE RGBA32Color (unsigned char gray, unsigned char aa = 255)
4802  : r (gray), g (gray), b (gray), a (aa) {}
4803  HPS_INLINE RGBA32Color (unsigned char rr, unsigned char gg, unsigned char bb, unsigned char aa = 255)
4804  : r (rr), g (gg), b (bb), a (aa) {}
4805  HPS_INLINE RGBA32Color (RGBAS32Color const & c32)
4806  : r (c32.r), g (c32.g), b (c32.b), a (c32.a) {}
4807  explicit HPS_INLINE RGBA32Color (RGBColor const & c) {
4808  r = Float::unit_to_byte(c.red);
4809  g = Float::unit_to_byte(c.green);
4810  b = Float::unit_to_byte(c.blue);
4811  a = 255;
4812  }
4813  HPS_INLINE RGBA32Color (RGBColor const & c, float alpha) {
4814  r = Float::unit_to_byte(c.red);
4815  g = Float::unit_to_byte(c.green);
4816  b = Float::unit_to_byte(c.blue);
4817  a = Float::unit_to_byte(alpha);
4818  }
4819  HPS_INLINE RGBA32Color (RGBColor const & c, unsigned char aa) {
4820  r = Float::unit_to_byte(c.red);
4821  g = Float::unit_to_byte(c.green);
4822  b = Float::unit_to_byte(c.blue);
4823  a = aa;
4824  }
4825  explicit HPS_INLINE RGBA32Color (RGBAColor const & c) {
4826  r = Float::unit_to_byte(c.red);
4827  g = Float::unit_to_byte(c.green);
4828  b = Float::unit_to_byte(c.blue);
4829  a = Float::unit_to_byte(c.alpha);
4830  }
4831  HPS_INLINE RGBA32Color (RGBAColor const & c, unsigned char mix) {
4832  r = Float::unit_to_byte(c.red);
4833  g = Float::unit_to_byte(c.green);
4834  b = Float::unit_to_byte(c.blue);
4835  a = Float::unit_to_byte_scaled(c.alpha, mix);
4836  }
4837 
4838  HPS_INLINE bool IsGray() const {return (r == g && g == b);}
4839  HPS_INLINE unsigned char Gray() const { return (unsigned char)(0.3125f * (float)r + 0.5000f * (float)g + 0.1875f * (float)b); }
4840 
4841  HPS_INLINE bool operator== (RGBA32Color const & c) const { return (r == c.r && g == c.g && b == c.b && a == c.a); }
4842  HPS_INLINE bool operator!= (RGBA32Color const & c) const { return !(*this == c); }
4843 
4844  static HPS_INLINE RGBA32Color Black() {return RGBA32Color (0, 0, 0, 255);};
4845  static HPS_INLINE RGBA32Color White() {return RGBA32Color (255, 255, 255, 255);};
4846 
4847  static HPS_INLINE unsigned char Opaque_Alpha () {return 0xFF;}
4848 };
4849 
4850 
4852 {
4853 public:
4854  unsigned char r;
4855  unsigned char g;
4856  unsigned char b;
4857 
4858  HPS_INLINE RGB24Color () {}
4859  explicit HPS_INLINE RGB24Color (unsigned char gray)
4860  : r (gray), g (gray), b (gray) {}
4861  HPS_INLINE RGB24Color (unsigned char rr, unsigned char gg, unsigned char bb)
4862  : r (rr), g (gg), b (bb) {}
4863  explicit HPS_INLINE RGB24Color (RGBColor const & c) {
4864  r = Float::unit_to_byte(c.red);
4865  g = Float::unit_to_byte(c.green);
4866  b = Float::unit_to_byte(c.blue);
4867  }
4868 
4869  HPS_INLINE bool IsGray() const {return (r == g && g == b);}
4870  HPS_INLINE unsigned char Gray() const { return (unsigned char)(0.3125f * (float)r + 0.5000f * (float)g + 0.1875f * (float)b); }
4871 
4872  HPS_INLINE bool operator== (RGB24Color const & c) const { return (r == c.r && g == c.g && b == c.b); }
4873  HPS_INLINE bool operator!= (RGB24Color const & c) const { return !(*this == c); }
4874 };
4875 
4876 HPS_INLINE RGBColor::RGBColor (RGBAS32Color const & c32) {
4877  red = Float::C2F(c32.r);
4878  green = Float::C2F(c32.g);
4879  blue = Float::C2F(c32.b);
4880 }
4881 
4882 HPS_INLINE RGBColor::RGBColor (RGBA32Color const & c32) {
4883  red = Float::C2F(c32.r);
4884  green = Float::C2F(c32.g);
4885  blue = Float::C2F(c32.b);
4886 }
4887 
4888 HPS_INLINE RGBColor::RGBColor (RGBAColor const & c) {
4889  red = c.red;
4890  green = c.green;
4891  blue = c.blue;
4892 }
4893 
4894 HPS_INLINE RGBColor::RGBColor (RGB24Color const & c24) {
4895  red = Float::C2F(c24.r);
4896  green = Float::C2F(c24.g);
4897  blue = Float::C2F(c24.b);
4898 }
4899 
4900 HPS_INLINE RGBAS32Color::RGBAS32Color (RGB24Color const & c)
4901 {
4902  r = c.r;
4903  g = c.g;
4904  b = c.b;
4905  a = 255;
4906 }
4907 
4908 HPS_INLINE RGBAS32Color::RGBAS32Color (RGBA32Color const & c)
4909 {
4910  r = c.r;
4911  g = c.g;
4912  b = c.b;
4913  a = c.a;
4914 }
4915 
4916 HPS_INLINE RGBAColor::RGBAColor (RGBAS32Color const & c32) {
4917  red = Float::C2F(c32.r);
4918  green = Float::C2F(c32.g);
4919  blue = Float::C2F(c32.b);
4920  alpha = Float::C2F(c32.a);
4921 }
4922 
4923 HPS_INLINE RGBAColor::RGBAColor (RGBA32Color const & c32) {
4924  red = Float::C2F(c32.r);
4925  green = Float::C2F(c32.g);
4926  blue = Float::C2F(c32.b);
4927  alpha = Float::C2F(c32.a);
4928 }
4929 
4930 HPS_INLINE RGBColor Modulate(RGBColor const & a, RGBColor const & b) {
4931  return RGBColor(a.red * b.red, a.green * b.green, a.blue * b.blue);
4932 }
4933 
4934 
4935 
4936 HPS_INLINE RGBColor Interpolate(RGBColor const & a, RGBColor const & b, float t) {
4937  return RGBColor(a.red + (b.red - a.red) * t, a.green + (b.green - a.green) * t, a.blue + (b.blue - a.blue) * t);
4938 }
4939 
4940 HPS_INLINE RGBAColor Interpolate(RGBAColor const & a, RGBAColor const & b, float t) {
4941  return RGBAColor(a.red + (b.red - a.red) * t, a.green + (b.green - a.green) * t, a.blue + (b.blue - a.blue) * t, a.alpha + (b.alpha - a.alpha) * t);
4942 }
4943 
4944 HPS_INLINE RGBAS32Color Interpolate(RGBAS32Color const & a, RGBAS32Color const & b, float t) {
4945  return RGBAS32Color(
4946  (unsigned char)(a.r + ((float)b.r - (float)a.r) * t),
4947  (unsigned char)(a.g + ((float)b.g - (float)a.g) * t),
4948  (unsigned char)(a.b + ((float)b.b - (float)a.b) * t),
4949  (unsigned char)(a.a + ((float)b.a - (float)a.a) * t));
4950 }
4951 
4952 HPS_INLINE RGBA32Color Interpolate(RGBA32Color const & a, RGBA32Color const & b, float t) {
4953  return RGBA32Color(
4954  (unsigned char)(a.r + ((float)b.r - (float)a.r) * t),
4955  (unsigned char)(a.g + ((float)b.g - (float)a.g) * t),
4956  (unsigned char)(a.b + ((float)b.b - (float)a.b) * t),
4957  (unsigned char)(a.a + ((float)b.a - (float)a.a) * t));
4958 }
4959 
4960 HPS_INLINE RGB24Color Interpolate(RGB24Color const & a, RGB24Color const & b, float t) {
4961  return RGB24Color(
4962  (unsigned char)(a.r + ((float)b.r - (float)a.r) * t),
4963  (unsigned char)(a.g + ((float)b.g - (float)a.g) * t),
4964  (unsigned char)(a.b + ((float)b.b - (float)a.b) * t));
4965 }
4966 
4967 
4968 
4969 class HPS_API Quaternion {
4970 public:
4971  float w;
4972  float x;
4973  float y;
4974  float z;
4975 
4976  Quaternion() : w(0.0f), x(0.0f), y(0.0f), z(0.0f) { }
4977 
4978  Quaternion(float in_w, float in_x, float in_y, float in_z) : w(in_w), x(in_x), y(in_y), z(in_z) { }
4979 
4980  Quaternion(Quaternion const & that) : w(that.w), x(that.x), y(that.y), z(that.z) { }
4981 
4982  Quaternion const & Normalize() {
4983  float mag = Norm();
4984 
4985  if (mag > 0) {
4986  w /= mag;
4987  x /= mag;
4988  y /= mag;
4989  z /= mag;
4990  }
4991  return *this;
4992  }
4993 
4994 
4995  Quaternion operator* (Quaternion const & in_right) const {
4996  return Quaternion(w*in_right.w - x*in_right.x - y*in_right.y - z*in_right.z,
4997  y*in_right.z - z*in_right.y + w*in_right.x + x*in_right.w,
4998  z*in_right.x - x*in_right.z + w*in_right.y + y*in_right.w,
4999  x*in_right.y - y*in_right.x + w*in_right.z + z*in_right.w);
5000  }
5001 
5002  Quaternion operator* (float in_right) const {
5003  return Quaternion(w*in_right, x*in_right, y*in_right, z*in_right);
5004  }
5005 
5006  friend Quaternion operator* (float in_left, Quaternion const & in_right) {
5007  return Quaternion(in_left*in_right.w, in_left*in_right.x, in_left*in_right.y, in_left*in_right.z);
5008  }
5009 
5010  Quaternion operator/ (float in_right) const {
5011  return Quaternion(w/in_right, x/in_right, y/in_right, z/in_right);
5012  }
5013 
5014  Quaternion operator- (Quaternion const & in_right) const {
5015  return Quaternion(w-in_right.w, x-in_right.x, y-in_right.y, z-in_right.z);
5016  }
5017 
5018  Quaternion operator+ (Quaternion const & in_right) const {
5019  return Quaternion(w+in_right.w, x+in_right.x, y+in_right.y, z+in_right.z);
5020  }
5021 
5022  inline float Norm() const {
5023  return static_cast<float>(sqrt(w*w + x*x + y*y + z*z));
5024  }
5025 
5026 
5027  Quaternion Log() const {
5028  Quaternion ret;
5029  float mag_q = Norm();
5030  float mag_V = static_cast<float>(sqrt(x*x + y*y + z*z));
5031 
5032  ret.w = static_cast<float>(log(mag_q));
5033 
5034  if (mag_V > 0) {
5035  float scale = static_cast<float>(acos(w / mag_q) / mag_V);
5036 
5037  ret.x = x * scale;
5038  ret.y = y * scale;
5039  ret.z = z * scale;
5040  }
5041  else
5042  ret.x = ret.y = ret.z = 0;
5043 
5044  return ret;
5045  }
5046 
5047  Quaternion Exp() const {
5048  Quaternion ret;
5049  float ea = static_cast<float>(exp(w));
5050  float mag_V = static_cast<float>(sqrt(x*x + y*y + z*z));
5051  float scale = ea * sin(mag_V) / mag_V;
5052 
5053  ret.w = ea * cos(mag_V);
5054  ret.x = scale * x;
5055  ret.y = scale * y;
5056  ret.z = scale * z;
5057 
5058  return ret;
5059  }
5060 
5061  Quaternion Lerp(Quaternion const & in_right, float in_fraction) const {
5062  Quaternion ret = *this + in_fraction * (in_right - *this);
5063  return ret.Normalize();
5064  }
5065 
5066 
5067  Quaternion Slerp(Quaternion const & in_right, float in_fraction, bool in_shortest_path_only = true) const {
5068  Quaternion q3;
5069  float dot = x*in_right.x + y*in_right.y + z*in_right.z + w*in_right.w;
5070 
5071  if (in_shortest_path_only && dot < 0) {
5072  dot = -dot;
5073  q3 = -1 * in_right;
5074  }
5075  else
5076  q3 = in_right;
5077 
5078  if (dot > -0.95f && dot < 0.95f) {
5079  float angle = static_cast<float>(acos(dot));
5080  float sina = static_cast<float>(sin(angle));
5081  float sinat = static_cast<float>(sin(angle*in_fraction));
5082  float sinaomt = static_cast<float>(sin(angle*(1-in_fraction)));
5083 
5084  return (*this * sinaomt + q3 * sinat) / sina;
5085  }
5086  else //if the angle is small, we use linear interpolation
5087  return Lerp(q3, in_fraction);
5088  }
5089 
5090 
5091  /*
5092  Spherical cubic interpolation between two Quaternions
5093  \param in_right The Quaternion for interpolation.
5094  \param in_control1 The first control point.
5095  \param in_control2 The second control point.
5096  \param in_fraction Interpolation distance (0 - 1).
5097  \return Result of interpolation.
5098  */
5099  Quaternion Squad(Quaternion const & in_right, Quaternion const & in_control1, Quaternion const & in_control2, float in_fraction) const {
5100  Quaternion q1 = Slerp(in_right , in_fraction, false);
5101  Quaternion q2 = in_control1.Slerp(in_control2, in_fraction, false);
5102 
5103  return q1.Slerp(q2, 2*in_fraction*(1-in_fraction), false);
5104  }
5105 
5112  Quaternion Spline(Quaternion const & in_previous, Quaternion const & in_next) const {
5113  Quaternion qni(w, -x, -y, -z);
5114 
5115  return *this * Quaternion(((qni*in_previous).Log() + (qni*in_next).Log()) / -4).Exp();
5116  }
5117 
5118 };
5119 
5121 {
5124  size_t dot_dc_count;
5125  size_t dot_3d_count;
5126  size_t line_dc_count;
5127  size_t line_3d_count;
5140  size_t raster_count;
5141  size_t segment_count;
5158 };
5159 
5160 typedef unsigned char byte;
5161 typedef signed char sbyte;
5162 typedef intptr_t WindowHandle;
5163 typedef int64_t TouchID;
5164 typedef intptr_t PlatformData;
5165 typedef intptr_t OpaqueHandle;
5166 
5167 /*
5168 HPS Lexicon:
5169 
5170 Concept Class -- A class that contains only enums and possibly static functions. The
5171  constructor is usually private because they are not intended to be instantiated.
5172 
5173 Database -- (1) The internal space that stores and manages all HOOPS objects. Access to
5174  database objects is subject to locking to prevent threading deadlocks. (2) The class
5175  of the same name, offering static functions to initiate operations that take place
5176  within the database.
5177 
5178 Key -- A reference counted smart pointer to an object in the database. The
5179 
5180 Kit -- A user space object that carries a complete specification for a geometry, attribute,
5181  option group, or other type. Modifying a kit has no effect on the database unless
5182  and until it is applied. Kits should generally be passed by reference because they
5183  are potentially very large and copying them can be arduous.
5184 
5185 Smart Pointer -- An encapsulated, reference counted pointer to an internal object. Smart
5186  pointers should generally be passed by value to ensure the reference count is
5187  correct.
5188 
5189 User Space -- The external space occupied by all user code. User space objects are not
5190  in the database and are not subject to locking.
5191 
5192 */
5193 
5197 class SegmentKey;
5198 class AttributesControl;
5199 class LineKit;
5200 class LineKey;
5201 class TextKey;
5202 class TextKit;
5203 class Key;
5204 class VisibilityControl;
5205 class CameraControl;
5206 class SelectabilityControl;
5207 class TransparencyKit;
5208 class TransparencyControl;
5209 class CullingKit;
5210 class CullingControl;
5211 class GlyphKit;
5212 class ShapeKit;
5214 class GlyphDefinition;
5215 class ShapeDefinition;
5216 class GeometryInsertControl;
5217 class GlyphElement;
5218 class ShapeElement;
5219 class TextAttributeControl;
5220 class TextAttributeKit;
5221 class LineAttributeKit;
5222 class LineAttributeControl;
5223 class EdgeAttributeKit;
5224 class EdgeAttributeControl;
5225 class CurveAttributeKit;
5226 class CurveAttributeControl;
5227 class GlyphPoint;
5228 class MatrixKit;
5230 class TextureMatrixControl;
5231 class TextureDefinition;
5232 class MaterialMappingKit;
5233 class PBRMaterialKit;
5235 class MaterialKit;
5236 class MarkerKit;
5237 class MarkerKey;
5238 class DistantLightKit;
5239 class DistantLightKey;
5240 class CuttingSectionKit;
5241 class CuttingSectionKey;
5244 class CylinderAttributeKit;
5246 class Cylinder;
5247 class CylinderKey;
5248 class CylinderKit;
5249 class SphereKey;
5250 class SphereKit;
5251 class SphereAttributeKit;
5253 class PolygonKit;
5254 class PolygonKey;
5255 class CircleKey;
5256 class CircleKit;
5257 class CircularArcKey;
5258 class CircularArcKit;
5259 class CircularWedgeKey;
5260 class CircularWedgeKit;
5261 class IncludeKey;
5262 class InfiniteLineKey;
5263 class InfiniteLineKit;
5264 class SpotlightKey;
5265 class SpotlightKit;
5266 class NURBSCurveKey;
5267 class NURBSCurveKit;
5268 class NURBSSurfaceKey;
5269 class NURBSSurfaceKit;
5270 class TrimKit;
5271 class TrimElement;
5272 class EllipseKey;
5273 class EllipseKit;
5274 class EllipticalArcKey;
5275 class EllipticalArcKit;
5276 class ShellKit;
5277 class ShellKey;
5278 class Shell;
5279 class MeshKit;
5280 class MeshKey;
5281 class WindowKey;
5282 class Database;
5285 class Driver;
5286 class Search;
5287 class PerformanceKit;
5288 class PerformanceControl;
5291 class DrawingAttributeKit;
5293 class PortfolioKey;
5294 class Selection;
5295 class SelectionOptionsKit;
5296 class SelectionResults;
5297 class SelectionItem;
5298 class SelectionControl;
5299 class HighlightControl;
5300 class HighlightOptionsKit;
5301 class ImageDefinition;
5302 class ImageKit;
5303 class TextureDefinition;
5304 class TextureOptionsKit;
5305 class NamedStyleDefinition;
5307 class GlyphDefinition;
5308 class LinePatternOptionsKit;
5309 class LinePatternDefinition;
5310 class LinePatternKit;
5311 class LinePatternElement;
5313 class CubeMapDefinition;
5314 class ShaderKit;
5315 class ShaderDefinition;
5316 class EmergencyHandler;
5317 class EventDispatcher;
5318 class EventHandler;
5319 class Event;
5320 #if TARGET_OS_ANDROID == 0 && !defined(__APPLE__)
5321 class StandAloneWindowKey;
5323 #endif
5324 class ApplicationWindowKey;
5326 class OffScreenWindowKey;
5329 class VisualEffectsControl;
5332 class ObjectPoint;
5333 class WorldPoint;
5334 class CameraPoint;
5335 class InnerWindowPoint;
5336 class InnerPixelPoint;
5337 class WindowPoint;
5338 class PixelPoint;
5339 class VisibilityKit;
5340 class CameraKit;
5341 class SelectabilityKit;
5342 class MarkerAttributeKit;
5343 class LightingAttributeKit;
5344 class VisualEffectsKit;
5345 class PostProcessEffectsKit;
5346 class Portfolio;
5347 class SubwindowControl;
5348 class SubwindowKit;
5349 class World;
5350 class DebuggingControl;
5351 class DebuggingKit;
5352 class KeyPath;
5353 class ContourLineKit;
5354 class ContourLineControl;
5355 class UTF8;
5356 class StyleControl;
5357 class PortfolioControl;
5358 class ConditionalExpression;
5359 class ConditionControl;
5360 class WindowInfoKit;
5361 class WindowInfoControl;
5362 class FontInfoState;
5363 class FontInfoControl;
5364 class SearchOptionsKit;
5365 class AttributeLockControl;
5366 class AttributeLockKit;
5367 class ReferenceKey;
5368 class StyleKey;
5369 class BoundingKit;
5370 class BoundingControl;
5371 class TransformMaskKit;
5372 class TransformMaskControl;
5373 class ColorInterpolationKit;
5375 class UpdateOptionsKit;
5376 class UpdateOptionsControl;
5377 class GeometryKey;
5378 class TreeContext;
5381 class GridKit;
5382 class GridKey;
5386 class HighlightState;
5391 
5395 
5396 
5399 class HPS_API GlyphPoint
5400 {
5401 public:
5402 
5404  GlyphPoint();
5405 
5410  GlyphPoint(sbyte in_x, sbyte in_y);
5411 
5416  bool Equals(GlyphPoint const & in_that) const { return (x==in_that.x && y==in_that.y); }
5417 
5422  bool operator==(GlyphPoint const & in_that) const { return Equals(in_that); }
5423 
5428  bool operator!=(GlyphPoint const & in_that) const { return !Equals(in_that); }
5429 
5430  sbyte x;
5431  sbyte y;
5432 };
5433 
5436 enum class Type : uint32_t
5437 {
5438  None = 0x00000000,
5439  GenericMask = 0xffffff00,
5440 
5441  World = 0x00000001,
5442  UTF8 = 0x00000002,
5443  EventDispatcher = 0x00000003,
5444  EventHandler = 0x00000004,
5445  EventNotifier = 0x00000005,
5446  UpdateNotifier = 0x00000006,
5447  SearchResults = 0x00000008,
5448  FontSearchResults = 0x00000009,
5449  SelectionResults = 0x0000000a,
5450  SelectionItem = 0x0000000b,
5451  TreeContext = 0x0000000c,
5452  StreamToolkit = 0x0000000d,
5453  DriverEventHandler = 0x0000000e,
5454  HighlightSearchResults = 0x0000000f,
5455  OptimizeMappingResults = 0x00000010,
5456 
5457  IONotifier = 0x04000100,
5458  StreamImportNotifier = 0x04000101,
5459  STLImportNotifier = 0x04000102,
5460  OBJImportNotifier = 0x04000103,
5461  ExchangeImportNotifier = 0x04000104,
5462  SketchupImportNotifier = 0x04000105,
5463  ParasolidImportNotifier = 0x04000106,
5464  ExchangeTranslationNotifier = 0x04000107,
5465  ExchangeExportNotifier = 0x04000108,
5466  StreamExportNotifier = 0x04000109,
5467  ExchangeReloadNotifier = 0x0400010a,
5468  DWGImportNotifier = 0x0400010b,
5469  ExchangeParasolidImportNotifier = 0x0400010c,
5470  PointCloudImportNotifier = 0x0400010d,
5471  OOCImportNotifier = 0x0400010e,
5472  OBJExportNotifier = 0x0400010f,
5473  HCAImportNotifier = 0x04000110,
5474 
5475  SearchResultsIterator = 0x01000001,
5476  FontSearchResultsIterator = 0x01000002,
5477  SelectionResultsIterator = 0x01000003,
5478  HighlightSearchResultsIterator = 0x01000004,
5479  OptimizeMappingResultsIterator = 0x01000005,
5480 
5481  Kit = 0x01000000,
5482  MarkerKit = 0x01000010,
5483  SphereAttributeKit = 0x01000011,
5484  TextAttributeKit = 0x01000012,
5485  TransparencyKit = 0x01000013,
5486  VisibilityKit = 0x01000014,
5487  VisualEffectsKit = 0x01000015,
5488  CuttingSectionAttributeKit = 0x01000016,
5489  CircleKit = 0x01000017,
5490  CircularArcKit = 0x01000018,
5491  CircularWedgeKit = 0x01000019,
5492  CuttingSectionKit = 0x0100001a,
5493  CylinderKit = 0x0100001b,
5494  DistantLightKit = 0x0100001c,
5495  EllipseKit = 0x0100001d,
5496  EllipticalArcKit = 0x0100001e,
5497  InfiniteLineKit = 0x0100001f,
5498  LineKit = 0x01000020,
5499  NURBSCurveKit = 0x01000021,
5500  MeshKit = 0x01000022,
5501  NURBSSurfaceKit = 0x01000023,
5502  PolygonKit = 0x01000024,
5503  SphereKit = 0x01000025,
5504  SpotlightKit = 0x01000026,
5505  ShellKit = 0x01000027,
5506  TextKit = 0x01000028,
5507  MaterialKit = 0x01000029,
5508  TrimKit = 0x0100002a,
5509  TextureOptionsKit = 0x0100002c,
5510  LinePatternKit = 0x0100002d,
5511  GlyphKit = 0x0100002e,
5512  ImageKit = 0x0100002f,
5513  LinePatternOptionsKit = 0x01000030,
5514  CameraKit = 0x01000031,
5515  BoundingKit = 0x01000032,
5516  CullingKit = 0x01000033,
5517  CurveAttributeKit = 0x01000034,
5518  CylinderAttributeKit = 0x01000035,
5519  EdgeAttributeKit = 0x01000036,
5520  LightingAttributeKit = 0x01000037,
5521  LineAttributeKit = 0x01000038,
5522  MarkerAttributeKit = 0x01000039,
5523  MaterialMappingKit = 0x0100003a,
5524  //MatrixKit = 0x0100003b,
5525  NURBSSurfaceAttributeKit = 0x0100003c,
5526  PostProcessEffectsKit = 0x0100003d,
5527  SelectabilityKit = 0x0100003e,
5528  SelectionOptionsKit = 0x0100003f,
5529  StandAloneWindowOptionsKit = 0x01000040,
5530  OffScreenWindowOptionsKit = 0x01000041,
5531  ApplicationWindowOptionsKit = 0x01000042,
5532  HighlightOptionsKit = 0x01000043,
5533  LinePatternParallelKit = 0x01000044,
5534  SubwindowKit = 0x01000045,
5535  PerformanceKit = 0x01000046,
5536  HiddenLineAttributeKit = 0x01000047,
5537  DrawingAttributeKit = 0x01000048,
5538  ShaderKit = 0x01000049,
5539  DebuggingKit = 0x0100004a,
5540  ContourLineKit = 0x0100004b,
5541  StreamImportOptionsKit = 0x0100004c,
5542  StreamImportResultsKit = 0x0100004d,
5543  StreamExportOptionsKit = 0x0100004e,
5544  StreamExportResultsKit = 0x0100004f,
5545  WindowInfoKit = 0x01000050,
5546  ImageImportOptionsKit = 0x01000051,
5547  SearchOptionsKit = 0x01000052,
5548  ShaderImportOptionsKit = 0x01000053,
5549  HardcopyExportOptionsKit = 0x01000055, // These two use the same Impl, so
5550  HardcopyGDIExportOptionsKit = 0x01001055, // we make sure their bits are compatible here
5551  AttributeLockKit = 0x01000056,
5552  TransformMaskKit = 0x01000057,
5553  ColorInterpolationKit = 0x01000058,
5554  UpdateOptionsKit = 0x01000059,
5555  ImageExportOptionsKit = 0x0100005a,
5556  OBJImportOptionsKit = 0x0100005b,
5557  OBJImportResultsKit = 0x0100005c,
5558  STLImportOptionsKit = 0x0100005d,
5559  STLImportResultsKit = 0x0100005e,
5560  ShellOptimizationOptionsKit = 0x0100005f,
5561  ShellRelationOptionsKit = 0x01000060,
5562  ShellRelationResultsKit = 0x01000061,
5563  GridKit = 0x01000062,
5564  CutGeometryGatheringOptionsKit = 0x01000063,
5565  SegmentOptimizationOptionsKit = 0x01000064,
5566  PointCloudImportOptionsKit = 0x01000065,
5567  PointCloudImportResultsKit = 0x01000066,
5568  ShapeKit = 0x01000067,
5569  HighlightSearchOptionsKit = 0x01000068,
5570  PBRMaterialKit = 0x01000069,
5571 
5572  LinePatternElement = 0x03000000,
5573  SolidLinePatternElement = 0x03000001,
5574  BlankLinePatternElement = 0x03000002,
5575  GlyphLinePatternElement = 0x03000003,
5576 
5577  GlyphElement = 0x05000000,
5578  DotGlyphElement = 0x05000001,
5579  LineGlyphElement = 0x05000002,
5580  EllipseGlyphElement = 0x05000003,
5581  CircularArcGlyphElement = 0x05000004,
5582  InfiniteLineGlyphElement = 0x05000005,
5583  SphereGlyphElement = 0x05000006,
5584  ImageGlyphElement = 0x05000007,
5585 
5586  TrimElement = 0x07000000,
5587 
5588  ConditionalExpression = 0x09000000,
5589  NOTCondition = 0x09000001,
5590  ANDCondition = 0x09000002,
5591  ORCondition = 0x09000003,
5592  XORCondition = 0x09000004,
5593  EQCondition = 0x09000005,
5594  NEQCondition = 0x09000006,
5595  GTCondition = 0x09000007,
5596  LTCondition = 0x09000008,
5597  GTEQCondition = 0x09000009,
5598  LTEQCondition = 0x0900000A,
5599 
5600  ShapeElement = 0x0B000000,
5601  PolygonShapeElement = 0x0B000001,
5602  EllipseShapeElement = 0x0B000002,
5603  CircleShapeElement = 0x0B000003,
5604  EllipticalArcShapeElement = 0x0B000004,
5605  AnchorShapeElement = 0x0B000005,
5606  LineShapeElement = 0x0B000006,
5607  CircularArcShapeElement = 0x0B000007,
5608  LeaderLineClippingElement = 0x0B000008,
5609 
5610  MouseState = 0x01001001,
5611  TouchState = 0x01001002,
5612  KeyboardState = 0x01001003,
5613  FontInfoState = 0x01001004,
5614  HighlightState = 0x01001005,
5615 
5616  KeyPath = 0x01000F01,
5617 
5618  Key = 0x10000000,
5619  IncludeKey = 0x10000001,
5620  PortfolioKey = 0x10000002,
5621  StyleKey = 0x10000003,
5622 
5623  SegmentKey = 0x10200000,
5624  WindowKey = 0x10600000,
5625  StandAloneWindowKey = 0x10600001,
5626  OffScreenWindowKey = 0x10600002,
5627  ApplicationWindowKey = 0x10600003,
5628 
5629  GeometryKey = 0x10100000,
5630  ReferenceKey = 0x10100001,
5631  CircleKey = 0x10100002,
5632  CircularArcKey = 0x10100003,
5633  CircularWedgeKey = 0x10100004,
5634  CuttingSectionKey = 0x10100005,
5635  CylinderKey = 0x10100006,
5636  EllipseKey = 0x10100007,
5637  EllipticalArcKey = 0x10100008,
5638  InfiniteLineKey = 0x10100009,
5639  LineKey = 0x1010000a,
5640  DistantLightKey = 0x1010000b,
5641  SpotlightKey = 0x1010000c,
5642  MarkerKey = 0x1010000d,
5643  MeshKey = 0x1010000e,
5644  NURBSCurveKey = 0x1010000f,
5645  NURBSSurfaceKey = 0x10100010,
5646  PolygonKey = 0x10100011,
5647  ShellKey = 0x10100012,
5648  SphereKey = 0x10100013,
5649  TextKey = 0x10100014,
5650  GridKey = 0x10100015,
5651 
5652  Definition = 0x20000000,
5653  NamedStyleDefinition = 0x20000001,
5654  TextureDefinition = 0x20000002,
5655  LinePatternDefinition = 0x20000003,
5656  GlyphDefinition = 0x20000004,
5657  CubeMapDefinition = 0x20000005,
5658  ImageDefinition = 0x20000006,
5659  MaterialPaletteDefinition = 0x20000007,
5660  ShaderDefinition = 0x20000008,
5661  ShapeDefinition = 0x20000009,
5662 
5663  Control = 0x50000000,
5664  CameraControl = 0x50000001,
5665  SelectabilityControl = 0x50000002,
5666  MarkerAttributeControl = 0x50000003,
5667  SphereAttributeControl = 0x50000004,
5668  LightingAttributeControl = 0x50000005,
5669  CylinderAttributeControl = 0x50000006,
5670  TextAttributeControl = 0x50000007,
5671  LineAttributeControl = 0x50000008,
5672  EdgeAttributeControl = 0x50000009,
5673  CurveAttributeControl = 0x5000000a,
5674  ModellingMatrixControl = 0x5000000b,
5675  TextureMatrixControl = 0x5000000c,
5676  CullingControl = 0x5000000d,
5677  TransparencyControl = 0x5000000e,
5678  MaterialMappingControl = 0x5000000f,
5679  NURBSSurfaceAttributeControl = 0x50000010,
5680  PostProcessEffectsControl = 0x50000011,
5681  BoundingControl = 0x50000012,
5682  VisualEffectsControl = 0x50000013,
5683  SelectionOptionsControl = 0x50000014,
5684  HighlightOptionsControl = 0x50000015,
5685  DefinitionControl = 0x50000016,
5686  SelectionControl = 0x50000017,
5687  HighlightControl = 0x50000018,
5688  StandAloneWindowOptionsControl = 0x50600019, //Is a Window Key
5689  OffScreenWindowOptionsControl = 0x5060001a, //Is a Window Key
5690  ApplicationWindowOptionsControl = 0x5060001b, //Is a Window Key
5691  VisibilityControl = 0x5000001c,
5692  SubwindowControl = 0x5000001d,
5693  PerformanceControl = 0x5000001e,
5694  HiddenLineAttributeControl = 0x5000001f,
5695  DrawingAttributeControl = 0x50000020,
5696  DebuggingControl = 0x50000021,
5697  ContourLineControl = 0x50000022,
5698  StyleControl = 0x50000023,
5699  ConditionControl = 0x50000024,
5700  PortfolioControl = 0x50000025,
5701  WindowInfoControl = 0x50000026,
5702  AttributeLockControl = 0x50000027,
5703  TransformMaskControl = 0x50000028,
5704  ColorInterpolationControl = 0x50000029,
5705  UpdateOptionsControl = 0x50600030, //Is a Window Key
5706  CuttingSectionAttributeControl = 0x50000031,
5707 
5708  LibraryMask = 0x80FF0000,
5709 
5710  Sprocket = 0x80000000,
5711  Canvas = 0x80000001,
5712  Layout = 0x80000002,
5713  View = 0x80000003,
5714  Model = 0x80000004,
5715  Operator = 0x80000005,
5716  SprocketPath = 0x80000007,
5717 
5718  SprocketControl = 0xD0000000,
5719  OperatorControl = 0xD0000008,
5720  NavigationCubeControl = 0xD0000009,
5721  AxisTriadControl = 0xD000000A,
5722 
5723  SprocketKit = 0x81000000,
5724 
5725  Metadata = 0x80001000,
5726  IntegerMetadata = 0x80001001,
5727  UnsignedIntegerMetadata = 0x80001002,
5728  DoubleMetadata = 0x80001003,
5729  StringMetadata = 0x80001004,
5730  TimeMetadata = 0x80001005,
5731  BooleanMetadata = 0x80001006,
5732 
5733  Component = 0x80000200,
5734  Filter = 0x80000600,
5735  Capture = 0x80000a00,
5736  CADModel = 0x80000300,
5737  ComponentPath = 0x81001000,
5738 
5739  ExchangeMask = 0x80020000,
5740  ExchangeComponent = 0x80021200,
5741  ExchangeSheet = 0x80021201,
5742  ExchangeProductOccurrence = 0x80021202,
5743  ExchangeFilter = 0x80020601,
5744  ExchangeCapture = 0x80020a01,
5745  ExchangeCADModel = 0x80020301,
5746  ExchangeConfiguration = 0x81020001,
5747  ExchangeImportOptionsKit = 0x81020002,
5748  ExchangeExportACISOptionsKit = 0x81020003,
5749  ExchangeExportIGESOptionsKit = 0x81020004,
5750  ExchangeExportJTOptionsKit = 0x81020005,
5751  ExchangeExportParasolidOptionsKit = 0x81020006,
5752  ExchangeExportPRCOptionsKit = 0x81020007,
5753  ExchangeExportSTEPOptionsKit = 0x81020008,
5754  ExchangeExportSTLOptionsKit = 0x81020009,
5755  ExchangeExportU3DOptionsKit = 0x8102000a,
5756  ExchangeExportXMLOptionsKit = 0x8102000b,
5757  ExchangeTessellationOptionsKit = 0x8102000c,
5758  ExchangeModelFileImportOptionsKit = 0x8102000d,
5759  ExchangeTranslationOptionsKit = 0x8102000e,
5760  ExchangeNURBSConversionOptionsKit = 0x8102000f,
5761  ExchangeExport3MFOptionsKit = 0x81020010,
5762  ExchangeExportFBXOptionsKit = 0x81020011,
5763  ExchangeExportOBJOptionsKit = 0x81020012,
5764 
5765  PublishMask = 0x80040000,
5766  PublishDocumentKit = 0x81040001,
5767  PublishPageKit = 0x81040002,
5768  PublishTemplateKit = 0x81040003,
5769  PublishAnnotationKit = 0x81040004,
5770  PublishArtworkKit = 0x81040005,
5771  PublishViewKit = 0x81040006,
5772  PublishTextKit = 0x81040007,
5773  PublishImageKit = 0x81040008,
5774  PublishTableKit = 0x81040009,
5775  PublishExportOptionsKit = 0x8104000a,
5776  PublishLinkKit = 0x8104000b,
5777  PublishButtonKit = 0x8104000c,
5778  PublishTextFieldKit = 0x8104000d,
5779  PublishSlideTableKit = 0x8104000e,
5780  PublishCheckBoxKit = 0x8104000f,
5781  PublishRadioButtonKit = 0x81040010,
5782  PublishListBoxKit = 0x81040011,
5783  PublishDropDownListKit = 0x81040012,
5784  PublishSignatureFieldKit = 0x81040013,
5785 
5786  PublishDocumentKey = 0x80040001,
5787  PublishPageControl = 0x80040002,
5788 
5789  ExchangeParasolidMask = 0x80080000,
5790 
5791  SceneTree = 0x80008001,
5792  SceneTreeItem = 0x80008002,
5793 
5794  ComponentTree = 0x80008003,
5795  ComponentTreeItem = 0x80008004,
5796 
5797  SketchupMask = 0x80100000,
5798  SketchupImportOptionsKit = 0x81100001,
5799  SketchupImportResultsKit = 0x81100002,
5800 
5801  ParasolidMask = 0x80200000,
5802  ParasolidComponent = 0x80201201,
5803  ParasolidCADModel = 0x80200302,
5804  ParasolidImportOptionsKit = 0x81200003,
5805  ParasolidFacetTessellationKit = 0x81200004,
5806  ParasolidLineTessellationKit = 0x81200005,
5807  ParasolidExportOptionsKit = 0x81200006,
5808 
5809  DWGMask = 0x80400000,
5810  DWGComponent = 0x80401201,
5811  DWGLayer = 0x80401202,
5812  DWGLayout = 0x80400a03,
5813  DWGCADModel = 0x80400304,
5814  DWGImportOptionsKit = 0x81400005,
5815 
5816  OOCMask = 0x80800000,
5817  OOCImportOptionsKit = 0x81800001,
5818  OOCImportResultsKit = 0x81800002,
5819 
5820  HCAMask = 0x80110000,
5821  HCAImportOptionsKit = 0x81110001,
5822  HCAImportResultsKit = 0x81110002,
5823  HCAModel = 0x80110003,
5824  HCAModelTree = 0x80110004,
5825  HCAModelTreeItem = 0x80110005,
5826  HCANetworkImportOptionsKit = 0x81110006,
5827 
5828  HTMLMask = 0x80010000,
5829 
5830 
5831  IONotifierData = 0x84000200,
5832  StreamImportNotifierData = 0x84000201,
5833  STLImportNotifierData = 0x84000202,
5834  OBJImportNotifierData = 0x84000203,
5835  ExchangeImportNotifierData = 0x84020204,
5836  SketchupImportNotifierData = 0x84100205,
5837  ParasolidImportNotifierData = 0x84200206,
5838  ExchangeTranslationNotifierData = 0x84020207,
5839  ExchangeExportNotifierData = 0x84020208,
5840  StreamExportNotifierData = 0x84000209,
5841  DWGImportNotifierData = 0x8440020a,
5842  ExchangeParasolidImportNotifierData = 0x8408020b,
5843  PointCloudImportNotifierData = 0x8400020c,
5844  OOCImportNotifierData = 0x8480020d,
5845  OBJExportNotifierData = 0x8400020e,
5846  HCAImportNotifierData = 0x8411020f,
5847 
5848 };
5849 
5851 class HPS_API Memory
5852 {
5853 public:
5859  static void * Allocate(size_t in_bytes, bool in_clear_memory = true);
5860 
5861 
5866  static void Free(void * in_pointer);
5867 
5868 private:
5870  Memory();
5871 };
5872 
5873 
5875 template <typename T>
5876 class NO_HPS_API Allocator
5877 {
5878 public:
5879  typedef T value_type;
5880  typedef value_type * pointer;
5881  typedef value_type const * const_pointer;
5882  typedef value_type & reference;
5883  typedef value_type const & const_reference;
5884  typedef size_t size_type;
5885  typedef ptrdiff_t difference_type;
5886 
5887 
5888  Allocator() {}
5889  Allocator(Allocator<T> const & in_that) { HPS_UNREFERENCED(in_that); }
5890  ~Allocator() {}
5891 
5892  template <typename U> Allocator(Allocator<U> const &) {}
5893 
5894  template <typename U>
5895  struct rebind
5896  {
5897  typedef Allocator<U> other;
5898  };
5899 
5900 
5901  pointer address(reference x) const { return &x; }
5902  const_pointer address(const_reference x) const { return &x; }
5903 
5904  pointer allocate(size_type n, void * v = 0) { HPS_UNREFERENCED(v); return static_cast<pointer>(Memory::Allocate(n * sizeof(T))); }
5905  void deallocate(pointer p, size_type n) { HPS_UNREFERENCED(n); Memory::Free(p); }
5906 
5907 #if defined(_MSC_VER) || defined (__APPLE__)
5908  void construct(pointer p, const_reference x) { new(p) T(x); }
5909  void construct(pointer p, value_type && x) { new(p) T(std::move(x)); }
5910 #else
5911  template<typename U, typename... Args>
5912  void construct(U * p, Args&&... args) { new(p) U(std::forward<Args>(args)...); }
5913 #endif
5914  void destroy(pointer p) { HPS_UNREFERENCED(p); p->~T(); }
5915 
5916  size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); }
5917 };
5918 
5919 template <typename T, typename U>
5920 bool operator==(const Allocator<T> &, const Allocator<U> &) { return true; }
5921 
5922 template <typename T, typename U>
5923 bool operator!=(const Allocator<T> &, const Allocator<U> &) { return false; }
5924 
5926 class Exception : public std::runtime_error
5927 {
5928 public:
5929  Exception(char const * in_info) : std::runtime_error(in_info) { }
5930 };
5931 
5932 
5935 {
5936 public:
5937  InvalidObjectException(char const * in_info = "Attempted to use a deleted, uninitialized, or otherwise invalid object.") :
5938  Exception(in_info) {}
5939 };
5940 
5941 
5945 {
5946 public:
5947  IndexOutOfRangeException(char const * in_info = "Attempted to access an element outside the bounds of the array.") :
5948  Exception(in_info) {}
5949 };
5950 
5951 
5954 {
5955 public:
5956  InvalidSpecificationException(char const * in_info = "Missing or invalid specification.") :
5957  Exception(in_info) {}
5958 };
5959 
5960 
5963 {
5964 public:
5965  InvalidLicenseException(char const * in_info) :
5966  Exception(in_info) {}
5967 };
5968 
5969 
5972 {
5973 public:
5974  InvalidOperationException(char const * in_info = "Operation not supported on this platform.") :
5975  Exception(in_info) {}
5976 };
5977 
5979 class IOException : public Exception
5980 {
5981 public:
5985  IOException(char const * in_info, IOResult in_result)
5986  : Exception(in_info), result(in_result) {}
5987 
5988  IOResult result;
5989 };
5990 
5991 
5993 class HPS_API Object
5994 {
5995 public:
5996 
5997  Object();
5998 
5999  Object(Object const & that);
6000 
6001  virtual ~Object();
6002 
6003  Object & operator=(Object const & other_object);
6004 
6008  Object(Object && in_that);
6009 
6010 
6014  Object & operator=(Object && in_that);
6015 
6022  virtual HPS::Type Type() const;
6023 
6025  static const HPS::Type staticType = HPS::Type::None;
6026 
6029  virtual HPS::Type ObjectType() const { return staticType; }
6030 
6035  virtual bool Empty() const {return (impl_ == 0);};
6036 
6038  virtual void Reset();
6039 
6046  bool HasType(HPS::Type in_mask) const;
6047 
6050  intptr_t GetClassID() const;
6051 
6057  intptr_t GetInstanceID() const;
6058 
6061  template <typename T>
6062  static intptr_t ClassID()
6063  {
6064  static const intptr_t ret = T().GetClassID();
6065  return ret;
6066  }
6067 private:
6068 
6069  friend class HPSI::Impl;
6070  friend class HPSI::KeyImpl;
6071  friend class HPSI::TicketImpl;
6072 
6073  HPSI::Impl * impl_;
6074 };
6075 
6076 
6078 class HPS_API Control : public Object
6079 {
6080 public:
6081  virtual HPS::Type Type() const { return ObjectType(); }
6082  static const HPS::Type staticType = HPS::Type::Control;
6083  HPS::Type ObjectType() const { return staticType; }
6084 
6085 #if !defined(_MSC_VER) || _MSC_VER >= 1900
6086  Control(Control const & in_that) = default;
6087 #endif
6088 
6089 protected:
6090  Control() {}
6091 
6095  Control(Control && in_that) : Object(std::move(in_that)) {}
6096 
6100  Control & operator=(Control && in_that)
6101  {
6102  this->Object::operator=(std::move(in_that));
6103  return *this;
6104  }
6105 };
6106 
6107 
6109 class HPS_API Kit : public Object
6110 {
6111 public:
6112  static const HPS::Type staticType = HPS::Type::Kit;
6113  HPS::Type ObjectType() const { return staticType; }
6114  virtual HPS::Type Type() const { return ObjectType(); }
6115 
6116 #if !defined(_MSC_VER) || _MSC_VER >= 1900
6117  Kit(Kit const & in_that) = default;
6118 #endif
6119 
6120 protected:
6121  Kit() {}
6122 
6126  Kit(Kit && in_that) : Object(std::move(in_that)) {}
6127 
6131  Kit & operator=(Kit && in_that)
6132  {
6133  this->Object::operator=(std::move(in_that));
6134  return *this;
6135  }
6136 };
6137 
6138 
6140 class HPS_API ObjectPoint : public Point
6141 {
6142 public:
6143 
6145  ObjectPoint(float px = 0.0f, float py = 0.0f, float pz = 0.0f) : Point(px, py, pz) {}
6146 
6148  ObjectPoint(Point const & in_point):Point(in_point){}
6149 
6151  ObjectPoint(WindowKey const & in_window, ObjectPoint const & in_point);
6152 
6154  ObjectPoint(WindowKey const & in_window, WorldPoint const & in_point);
6155 
6157  ObjectPoint(WindowKey const & in_window, CameraPoint const & in_point);
6158 
6160  ObjectPoint(WindowKey const & in_window, InnerWindowPoint const & in_point);
6161 
6163  ObjectPoint(WindowKey const & in_window, InnerPixelPoint const & in_point);
6164 
6166  ObjectPoint(WindowKey const & in_window, WindowPoint const & in_point);
6167 
6169  ObjectPoint(WindowKey const & in_window, PixelPoint const & in_point);
6170 
6171 private:
6172 
6173  ObjectPoint(WorldPoint const & in_point); // Prevent implicit conversion to other types of points
6174  ObjectPoint(CameraPoint const & in_point); // Prevent implicit conversion to other types of points
6175  ObjectPoint(InnerWindowPoint const & in_point); // Prevent implicit conversion to other types of points
6176  ObjectPoint(InnerPixelPoint const & in_point); // Prevent implicit conversion to other types of points
6177  ObjectPoint(WindowPoint const & in_point); // Prevent implicit conversion to other types of points
6178  ObjectPoint(PixelPoint const & in_point); // Prevent implicit conversion to other types of points
6179 
6180 };
6181 
6183 class HPS_API WorldPoint : public Point
6184 {
6185 public:
6187  WorldPoint(float px = 0.0f, float py = 0.0f, float pz = 0.0f) : Point(px, py, pz) {}
6188 
6190  WorldPoint(Point const & in_point):Point(in_point){}
6191 
6193  WorldPoint(WindowKey const & in_window, ObjectPoint const & in_point);
6194 
6196  WorldPoint(WindowKey const & in_window, WorldPoint const & in_point);
6197 
6199  WorldPoint(WindowKey const & in_window, CameraPoint const & in_point);
6200 
6202  WorldPoint(WindowKey const & in_window, InnerWindowPoint const & in_point);
6203 
6205  WorldPoint(WindowKey const & in_window, InnerPixelPoint const & in_point);
6206 
6208  WorldPoint(WindowKey const & in_window, WindowPoint const & in_point);
6209 
6211  WorldPoint(WindowKey const & in_window, PixelPoint const & in_point);
6212 
6213 private:
6214 
6215  WorldPoint(ObjectPoint const & in_point); // Prevents implicit conversion to other points
6216  WorldPoint(CameraPoint const & in_point); // Prevents implicit conversion to other points
6217  WorldPoint(InnerWindowPoint const & in_point); // Prevents implicit conversion to other points
6218  WorldPoint(InnerPixelPoint const & in_point); // Prevents implicit conversion to other points
6219  WorldPoint(WindowPoint const & in_point); // Prevents implicit conversion to other points
6220  WorldPoint(PixelPoint const & in_point); // Prevents implicit conversion to other points
6221 
6222 };
6223 
6225 class HPS_API CameraPoint : public Point
6226 {
6227 public:
6229  CameraPoint(float px = 0.0f, float py = 0.0f, float pz = 0.0f) : Point(px, py, pz) {}
6230 
6232  CameraPoint(Point const & in_point):Point(in_point){}
6233 
6235  CameraPoint(WindowKey const & in_window, ObjectPoint const & in_point);
6236 
6238  CameraPoint(WindowKey const & in_window, WorldPoint const & in_point);
6239 
6241  CameraPoint(WindowKey const & in_window, CameraPoint const & in_point);
6242 
6244  CameraPoint(WindowKey const & in_window, InnerWindowPoint const & in_point);
6245 
6247  CameraPoint(WindowKey const & in_window, InnerPixelPoint const & in_point);
6248 
6250  CameraPoint(WindowKey const & in_window, WindowPoint const & in_point);
6251 
6253  CameraPoint(WindowKey const & in_window, PixelPoint const & in_point);
6254 
6255 private:
6256  CameraPoint(ObjectPoint const & in_point); // Prevents implicit conversion to other points
6257  CameraPoint(WorldPoint const & in_point); // Prevents implicit conversion to other points
6258  CameraPoint(InnerWindowPoint const & in_point); // Prevents implicit conversion to other points
6259  CameraPoint(InnerPixelPoint const & in_point); // Prevents implicit conversion to other points
6260  CameraPoint(WindowPoint const & in_point); // Prevents implicit conversion to other points
6261  CameraPoint(PixelPoint const & in_point); // Prevents implicit conversion to other points
6262 
6263 };
6264 
6266 class HPS_API InnerWindowPoint : public Point
6267 {
6268 public:
6269 
6271  InnerWindowPoint(float px = 0.0f, float py = 0.0f, float pz = 0.0f) : Point(px, py, pz) {}
6272 
6274  InnerWindowPoint(Point const & in_point):Point(in_point){}
6275 
6277  InnerWindowPoint(WindowKey const & in_window, ObjectPoint const & in_point);
6278 
6280  InnerWindowPoint(WindowKey const & in_window, WorldPoint const & in_point);
6281 
6283  InnerWindowPoint(WindowKey const & in_window, CameraPoint const & in_point);
6284 
6286  InnerWindowPoint(WindowKey const & in_window, InnerWindowPoint const & in_point);
6287 
6289  InnerWindowPoint(WindowKey const & in_window, InnerPixelPoint const & in_point);
6290 
6292  InnerWindowPoint(WindowKey const & in_window, WindowPoint const & in_point);
6293 
6295  InnerWindowPoint(WindowKey const & in_window, PixelPoint const & in_point);
6296 
6297 private:
6298  InnerWindowPoint(ObjectPoint const & in_point); // Prevents implicit conversion to other points
6299  InnerWindowPoint(WorldPoint const & in_point); // Prevents implicit conversion to other points
6300  InnerWindowPoint(CameraPoint const & in_point); // Prevents implicit conversion to other points
6301  InnerWindowPoint(InnerPixelPoint const & in_point); // Prevents implicit conversion to other points
6302  InnerWindowPoint(WindowPoint const & in_point); // Prevents implicit conversion to other points
6303  InnerWindowPoint(PixelPoint const & in_point); // Prevents implicit conversion to other points
6304 };
6305 
6307 class HPS_API InnerPixelPoint : public Point
6308 {
6309 public:
6310 
6312  InnerPixelPoint(float px = 0.0f, float py = 0.0f, float pz = 0.0f) : Point(px, py, pz) {}
6313 
6315  InnerPixelPoint(Point const & in_point):Point(in_point){}
6316 
6318  InnerPixelPoint(WindowKey const & in_window, ObjectPoint const & in_point);
6319 
6321  InnerPixelPoint(WindowKey const & in_window, WorldPoint const & in_point);
6322 
6324  InnerPixelPoint(WindowKey const & in_window, CameraPoint const & in_point);
6325 
6327  InnerPixelPoint(WindowKey const & in_window, InnerWindowPoint const & in_point);
6328 
6330  InnerPixelPoint(WindowKey const & in_window, InnerPixelPoint const & in_point);
6331 
6333  InnerPixelPoint(WindowKey const & in_window, WindowPoint const & in_point);
6334 
6336  InnerPixelPoint(WindowKey const & in_window, PixelPoint const & in_point);
6337 
6338 private:
6339  InnerPixelPoint(ObjectPoint const & in_point); // Prevents implicit conversion to other points
6340  InnerPixelPoint(WorldPoint const & in_point); // Prevents implicit conversion to other points
6341  InnerPixelPoint(CameraPoint const & in_point); // Prevents implicit conversion to other points
6342  InnerPixelPoint(InnerWindowPoint const & in_point); // Prevents implicit conversion to other points
6343  InnerPixelPoint(WindowPoint const & in_point); // Prevents implicit conversion to other points
6344  InnerPixelPoint(PixelPoint const & in_point); // Prevents implicit conversion to other points
6345 
6346 };
6347 
6349 class HPS_API WindowPoint : public Point
6350 {
6351 public:
6352 
6354  WindowPoint(float px = 0.0f, float py = 0.0f, float pz = 0.0f) : Point(px, py, pz) {}
6355 
6357  WindowPoint(Point const & in_point):Point(in_point){}
6358 
6360  WindowPoint(WindowKey const & in_window, ObjectPoint const & in_point);
6361 
6363  WindowPoint(WindowKey const & in_window, WorldPoint const & in_point);
6364 
6366  WindowPoint(WindowKey const & in_window, CameraPoint const & in_point);
6367 
6369  WindowPoint(WindowKey const & in_window, InnerWindowPoint const & in_point);
6370 
6372  WindowPoint(WindowKey const & in_window, InnerPixelPoint const & in_point);
6373 
6375  WindowPoint(WindowKey const & in_window, WindowPoint const & in_point);
6376 
6378  WindowPoint(WindowKey const & in_window, PixelPoint const & in_point);
6379 
6380 private:
6381  WindowPoint(ObjectPoint const & in_point); // Prevents implicit conversion to other points
6382  WindowPoint(WorldPoint const & in_point); // Prevents implicit conversion to other points
6383  WindowPoint(CameraPoint const & in_point); // Prevents implicit conversion to other points
6384  WindowPoint(InnerWindowPoint const & in_point); // Prevents implicit conversion to other points
6385  WindowPoint(InnerPixelPoint const & in_point); // Prevents implicit conversion to other points
6386  WindowPoint(PixelPoint const & in_point); // Prevents implicit conversion to other points
6387 };
6388 
6389 
6391 class HPS_API PixelPoint : public Point
6392 {
6393 public:
6395  PixelPoint(float px = 0.0f, float py = 0.0f, float pz = 0.0f) : Point(px, py, pz) {}
6396 
6398  PixelPoint(Point const & in_point):Point(in_point){}
6399 
6401  PixelPoint(WindowKey const & in_window, ObjectPoint const & in_point);
6402 
6404  PixelPoint(WindowKey const & in_window, WorldPoint const & in_point);
6405 
6407  PixelPoint(WindowKey const & in_window, CameraPoint const & in_point);
6408 
6410  PixelPoint(WindowKey const & in_window, InnerWindowPoint const & in_point);
6411 
6413  PixelPoint(WindowKey const & in_window, InnerPixelPoint const & in_point);
6414 
6416  PixelPoint(WindowKey const & in_window, WindowPoint const & in_point);
6417 
6419  PixelPoint(WindowKey const & in_window, PixelPoint const & in_point);
6420 
6421 private:
6422  PixelPoint(ObjectPoint const & in_point); // Prevents implicit conversion to other points
6423  PixelPoint(WorldPoint const & in_point); // Prevents implicit conversion to other points
6424  PixelPoint(CameraPoint const & in_point); // Prevents implicit conversion to other points
6425  PixelPoint(InnerWindowPoint const & in_point); // Prevents implicit conversion to other points
6426  PixelPoint(InnerPixelPoint const & in_point); // Prevents implicit conversion to other points
6427  PixelPoint(WindowPoint const & in_point); // Prevents implicit conversion to other points
6428 
6429 };
6430 
6433 class HPS_API Event
6434 {
6435 public:
6439  enum class Status : uint32_t
6440  {
6441  InProgress,
6442  Completed,
6443  Failed
6444  };
6445 
6447  Event(intptr_t in_channel = 0): channel(in_channel), consumable(true), time_stamp(0) {}
6448 
6449  virtual ~Event();
6450 
6452  intptr_t GetClassID() const;
6453 
6456  virtual Event * Clone() const=0;
6457 
6459  virtual bool Drop(Event const * in_that_event) const { HPS_UNREFERENCED(in_that_event); return false; }
6460 
6463  virtual intptr_t Freshen() const { return 0; }
6464 
6466  intptr_t GetChannel() const { return channel; }
6467 
6469  Time GetTimeStamp() const { return time_stamp; }
6470 
6472  bool IsConsumable() const { return consumable; }
6473 
6474  static void * operator new (size_t in_size) { return Memory::Allocate(in_size); }
6475  static void operator delete (void * in_ptr, size_t in_size) throw () { HPS_UNREFERENCED(in_size); Memory::Free(in_ptr); }
6476 
6477 protected:
6478  intptr_t channel;
6479  bool consumable;
6480 
6481 private:
6482  friend class HPSI::EventDispatcherImpl;
6483  Time time_stamp;
6484 };
6485 
6486 
6489 class HPS_API EventNotifier : public Object
6490 {
6491 public:
6492 
6494  EventNotifier();
6495 
6498  EventNotifier(EventNotifier const & in_that);
6499 
6503  EventNotifier(EventNotifier && in_that);
6504 
6508  EventNotifier & operator=(EventNotifier && in_that);
6509 
6510  virtual ~EventNotifier();
6511 
6512  static const HPS::Type staticType = HPS::Type::EventNotifier;
6513  HPS::Type ObjectType() const {return staticType;};
6514 
6518  EventNotifier & operator=(EventNotifier const & in_that);
6519 
6522  virtual void Assign(EventNotifier const & in_that);
6523 
6526  EventNotifier const & Wait() const;
6527 
6530  Event::Status Status() const;
6531 };
6532 
6534 enum class KeyboardCode : uint32_t
6535 {
6536  None = 0,
6537 
6538  Backspace = 8,
6539  Tab = 9,
6540  Clear = 11,
6541  Return = 13,
6542  Shift = 16,
6543  Control = 17,
6544  Alt = 18,
6545  Pause = 19,
6546  Escape = 27,
6547 
6548  Space = 32,
6549  ExclamationMark,
6550  DoubleQuote,
6551  Number,
6552  Dollar,
6553  Percent,
6554  Ampersand,
6555  SingleQuote,
6556  OpenParen,
6557  CloseParen,
6558 
6559  Asterisk,
6560  Plus,
6561  Comma,
6562  Hyphen,
6563  Period,
6564  Slash,
6565 
6566  D0,
6567  D1,
6568  D2,
6569  D3,
6570  D4,
6571  D5,
6572  D6,
6573  D7,
6574  D8,
6575  D9,
6576 
6577  Colon,
6578  Semicolon,
6579  LessThan,
6580  Equal,
6581  GreaterThan,
6582  QuestionMark,
6583  AtSymbol,
6584 
6585  A,
6586  B,
6587  C,
6588  D,
6589  E,
6590  F,
6591  G,
6592  H,
6593  I,
6594  J,
6595  K,
6596  L,
6597  M,
6598  N,
6599  O,
6600  P,
6601  Q,
6602  R,
6603  S,
6604  T,
6605  U,
6606  V,
6607  W,
6608  X,
6609  Y,
6610  Z,
6611 
6612  OpenBrackets,
6613  Backslash,
6614  CloseBrackets,
6615  Caret,
6616  Underscore,
6617  Backtick,
6618 
6619  a,
6620  b,
6621  c,
6622  d,
6623  e,
6624  f,
6625  g,
6626  h,
6627  i,
6628  j,
6629  k,
6630  l,
6631  m,
6632  n,
6633  o,
6634  p,
6635  q,
6636  r,
6637  s,
6638  t,
6639  u,
6640  v,
6641  w,
6642  x,
6643  y,
6644  z,
6645 
6646  OpenBrace,
6647  VerticalBar,
6648  ClosingBrace,
6649  Tilde,
6650  Delete,
6651 
6652  Insert=1024,
6653  Home,
6654  End,
6655  PageUp,
6656  PageDown,
6657 
6658  Help,
6659 
6660  Left,
6661  Up,
6662  Right,
6663  Down,
6664 
6665  NumPad0,
6666  NumPad1,
6667  NumPad2,
6668  NumPad3,
6669  NumPad4,
6670  NumPad5,
6671  NumPad6,
6672  NumPad7,
6673  NumPad8,
6674  NumPad9,
6675 
6676  F1,
6677  F2,
6678  F3,
6679  F4,
6680  F5,
6681  F6,
6682  F7,
6683  F8,
6684  F9,
6685  F10,
6686  F11,
6687  F12,
6688  F13,
6689  F14,
6690  F15,
6691  F16,
6692  F17,
6693  F18,
6694  F19,
6695  F20,
6696  F21,
6697  F22,
6698  F23,
6699  F24,
6700 
6701  CapsLock,
6702  NumLock,
6703  ScrollLock,
6704  LeftShift,
6705  RightShift,
6706  LeftCtrl,
6707  RightCtrl,
6708  LeftAlt,
6709  RightAlt,
6710 
6711  Select,
6712  Print,
6713  Execute,
6714  PrintScreen,
6715 };
6716 
6717 
6719 class NO_HPS_API Touch
6720 {
6721 public:
6722 
6725  Touch() : ID(0), Location(Point(0,0,0)), TapCount(0) {}
6726 
6731  Touch(TouchID in_id, WindowPoint const & in_location, size_t in_tap_count = 1)
6732  : ID(in_id), Location(in_location), TapCount(in_tap_count) {}
6733 
6737  inline bool operator==(Touch const & in_that) const
6738  {
6739  return (ID == in_that.ID && Location == in_that.Location && TapCount == in_that.TapCount);
6740  }
6741 
6745  inline bool operator!=(Touch const & in_that) const
6746  {
6747  return !(*this == in_that);
6748  }
6749 
6750  TouchID ID;
6752  size_t TapCount;
6753 };
6760 typedef std::vector<Point, Allocator<Point> > PointArray;
6761 typedef std::vector<ObjectPoint, Allocator<ObjectPoint> > ObjectPointArray;
6762 typedef std::vector<WorldPoint, Allocator<WorldPoint> > WorldPointArray;
6763 typedef std::vector<CameraPoint, Allocator<CameraPoint> > CameraPointArray;
6764 typedef std::vector<InnerWindowPoint, Allocator<InnerWindowPoint> > InnerWindowPointArray;
6765 typedef std::vector<InnerPixelPoint, Allocator<InnerPixelPoint> > InnerPixelPointArray;
6766 typedef std::vector<WindowPoint, Allocator<WindowPoint> > WindowPointArray;
6767 typedef std::vector<PixelPoint, Allocator<PixelPoint> > PixelPointArray;
6768 typedef std::vector<Vector, Allocator<Vector> > VectorArray;
6769 typedef std::vector<DVector, Allocator<DVector> > DVectorArray;
6770 typedef std::vector<Plane, Allocator<Plane> > PlaneArray;
6771 typedef std::vector<int, Allocator<int> > IntArray;
6772 typedef std::vector<RGBColor, Allocator<RGBColor> > RGBColorArray;
6773 typedef std::vector<RGBAColor, Allocator<RGBAColor> > RGBAColorArray;
6774 typedef std::vector<unsigned int, Allocator<unsigned int> > UnsignedIntArray;
6775 typedef std::vector<size_t, Allocator<size_t> > SizeTArray;
6776 typedef std::vector<float, Allocator<float> > FloatArray;
6777 typedef std::vector<SegmentKey, Allocator<SegmentKey> > SegmentKeyArray;
6778 typedef std::vector<WindowKey, Allocator<WindowKey> > WindowKeyArray;
6779 typedef std::vector<EventHandler, Allocator<EventHandler> > EventHandlerArray;
6780 typedef std::vector<GlyphElement, Allocator<GlyphElement> > GlyphElementArray;
6781 typedef std::vector<ShapeElement, Allocator<ShapeElement> > ShapeElementArray;
6782 typedef std::vector<GlyphPoint, Allocator<GlyphPoint> > GlyphPointArray;
6783 typedef std::vector<UTF8, Allocator<UTF8> > UTF8Array;
6784 typedef std::vector<UTF8Array, Allocator<UTF8Array> > UTF8ArrayArray;
6785 typedef std::vector<bool, Allocator<bool> > BoolArray;
6786 typedef std::vector<TrimKit, Allocator<TrimKit> > TrimKitArray;
6787 typedef std::vector<Key, Allocator<Key> > KeyArray;
6788 typedef std::vector<PortfolioKey, Allocator<PortfolioKey> > PortfolioKeyArray;
6789 typedef std::vector<char, Allocator<char> > CharArray;
6790 typedef std::vector<wchar_t, Allocator<wchar_t> > WCharArray;
6791 typedef std::vector<byte, Allocator<byte> > ByteArray;
6792 typedef std::vector<ByteArray, Allocator<ByteArray> > ByteArrayArray;
6793 typedef std::vector<sbyte, Allocator<sbyte> > SByteArray;
6794 typedef std::vector<MaterialKit, Allocator<MaterialKit> > MaterialKitArray;
6795 typedef std::vector<LinePatternElement, Allocator<LinePatternElement> > LinePatternElementArray;
6796 typedef std::vector<LinePatternParallelKit, Allocator<LinePatternParallelKit> > LinePatternParallelKitArray;
6797 typedef std::vector<Material::Type, Allocator<Material::Type> > MaterialTypeArray;
6798 typedef std::vector<Search::Type, Allocator<Search::Type> > SearchTypeArray;
6799 typedef std::vector<Line::SizeUnits, Allocator<Line::SizeUnits> > LineSizeUnitsArray;
6800 typedef std::vector<CameraKit, Allocator<CameraKit> > CameraKitArray;
6801 typedef std::vector<ConditionalExpression, Allocator<ConditionalExpression> > ConditionalExpressionArray;
6802 typedef std::vector<TextureDefinition, Allocator<TextureDefinition> > TextureDefinitionArray;
6803 typedef std::vector<CubeMapDefinition, Allocator<CubeMapDefinition> > CubeMapDefinitionArray;
6804 typedef std::vector<ImageDefinition, Allocator<ImageDefinition> > ImageDefinitionArray;
6805 typedef std::vector<NamedStyleDefinition, Allocator<NamedStyleDefinition> > NamedStyleDefinitionArray;
6806 typedef std::vector<MaterialPaletteDefinition, Allocator<MaterialPaletteDefinition> > MaterialPaletteDefinitionArray;
6807 typedef std::vector<GlyphDefinition, Allocator<GlyphDefinition> > GlyphDefinitionArray;
6808 typedef std::vector<LinePatternDefinition, Allocator<LinePatternDefinition> > LinePatternDefinitionArray;
6809 typedef std::vector<ShaderDefinition, Allocator<ShaderDefinition> > ShaderDefinitionArray;
6810 typedef std::vector<ShapeDefinition, Allocator<ShapeDefinition> > ShapeDefinitionArray;
6811 typedef std::vector<IntRectangle, Allocator<IntRectangle> > IntRectangleArray;
6812 typedef std::vector<AttributeLock::Type, Allocator<AttributeLock::Type> > AttributeLockTypeArray;
6813 typedef std::vector<Style::Type, Allocator<Style::Type> > StyleTypeArray;
6814 typedef std::vector<TrimElement, Allocator<TrimElement> > TrimElementArray;
6815 typedef std::vector<KeyPath, Allocator<KeyPath> > KeyPathArray;
6816 typedef std::vector<IncludeKey, Allocator<IncludeKey> > IncludeKeyArray;
6817 typedef std::vector<KeyboardCode, Allocator<KeyboardCode> > KeyboardCodeArray;
6818 typedef std::vector<Touch, Allocator<Touch> > TouchArray;
6819 typedef std::vector<ReferenceKey, Allocator<ReferenceKey> > ReferenceKeyArray;
6820 typedef std::vector<intptr_t, Allocator<intptr_t> > IntPtrTArray;
6821 typedef std::vector<GeometryKey, Allocator<GeometryKey> > GeometryKeyArray;
6822 typedef std::vector<Shell::Relation, Allocator<Shell::Relation> > ShellRelationArray;
6823 typedef std::vector<StyleKey, Allocator<StyleKey> > StyleKeyArray;
6824 typedef std::vector<PointArray, Allocator<PointArray> > PointArrayArray;
6825 typedef std::vector<Text::MarginUnits, Allocator<Text::MarginUnits> > TextMarginUnitsArray;
6826 typedef std::vector<PointArrayArray, Allocator<PointArrayArray> > PointArrayArrayArray;
6827 typedef std::vector<Drawing::ClipSpace, Allocator<Drawing::ClipSpace> > ClipSpaceArray;
6828 typedef std::vector<Drawing::ClipOperation, Allocator<Drawing::ClipOperation> > ClipOperationArray;
6829 typedef std::vector<MatrixKit, Allocator<MatrixKit> > MatrixKitArray;
6830 typedef std::vector<int32_t, Allocator<int32_t>> Int32Array;
6831 typedef std::vector<int64_t, HPS::Allocator<int64_t>> Int64Array;
6832 typedef std::vector<Line::CoordinateSpace, Allocator<Line::CoordinateSpace>> LineCoordinateSpaceArray;
6833 typedef std::vector<Drawing::Overlay, Allocator<Drawing::Overlay>> DrawingOverlayArray;
6834 typedef std::vector<HighlightState, Allocator<HighlightState>> HighlightStateArray;
6835 typedef std::vector<ImageKit, Allocator<ImageKit>> ImageKitArray;
6836 
6841 class HPS_API ShapeCoordinate
6842 {
6843 public:
6845  ShapeCoordinate();
6846 
6850  ShapeCoordinate(float in_x, float in_y);
6851 
6856  ShapeCoordinate(float in_x, float in_y, FloatArray const & in_margins);
6857 
6863  ShapeCoordinate(float in_x, float in_y, size_t in_count, float const in_margins []);
6864 
6869  ShapeCoordinate(float in_x, float in_y, float in_radius);
6870 
6876  ShapeCoordinate(float in_x, float in_y, float in_radius, FloatArray const & in_margins);
6877 
6884  ShapeCoordinate(float in_x, float in_y, float in_radius, size_t in_count, float const in_margins []);
6885 
6889  bool Equals(ShapeCoordinate const & in_that) const;
6890 
6894  bool operator==(ShapeCoordinate const & in_that) const { return Equals(in_that); }
6895 
6899  bool operator!=(ShapeCoordinate const & in_that) const { return !Equals(in_that); }
6900 
6907  ShapeCoordinate & SetMargins(float in_margin_one, float in_margin_two = 0.0f, float in_margin_three = 0.0f, float in_margin_four = 0.0f);
6908 
6912  bool ShowMargins(FloatArray & out_margins) const;
6913 
6916  ShapeCoordinate & UnsetMargins();
6917 
6918  float x;
6919  float y;
6920  float radius;
6921  FloatArray margins;
6922 };
6923 
6926 class HPS_API ShapePoint
6927 {
6928 public:
6930  ShapePoint();
6931 
6935  ShapePoint(ShapeCoordinate const & in_x, ShapeCoordinate const & in_y);
6936 
6943  ShapePoint(float in_x, float in_y);
6944 
6948  bool Equals(ShapePoint const & in_that) const { return (x == in_that.x && y == in_that.y); }
6949 
6953  bool operator==(ShapePoint const & in_that) const { return Equals(in_that); }
6954 
6958  bool operator!=(ShapePoint const & in_that) const { return !Equals(in_that); }
6959 
6960  ShapeCoordinate x;
6961  ShapeCoordinate y;
6962 };
6963 
6964 typedef std::vector<ShapePoint, Allocator<ShapePoint> > ShapePointArray;
6965 
6967 class HPS_API SearchResultsIterator : public Object
6968 {
6969 public:
6970 
6973 
6977  SearchResultsIterator(SearchResultsIterator const & in_search_results_iterator);
6978 
6983 
6987  SearchResultsIterator & operator=(SearchResultsIterator && in_that);
6988 
6990 
6991  static const HPS::Type staticType = HPS::Type::SearchResultsIterator;
6992  HPS::Type ObjectType() const {return staticType;}
6993 
6998  SearchResultsIterator & operator=(SearchResultsIterator const & in_search_results_iterator);
6999 
7004  void Set(SearchResultsIterator const & in_search_results_iterator);
7005 
7007  void Next();
7008 
7011  SearchResultsIterator & operator++();
7012 
7015  SearchResultsIterator operator++(int in_val);
7016 
7019  bool operator==(SearchResultsIterator const & in_search_results_iterator);
7020 
7023  bool operator!=(SearchResultsIterator const & in_search_results_iterator);
7024 
7028  bool IsValid() const;
7029 
7031  void Reset();
7032 
7036  Key GetItem() const;
7037 
7040  Key operator*() const;
7041 
7044  SearchTypeArray GetResultTypes() const;
7045 };
7046 
7048 class HPS_API SearchResults : public Object
7049 {
7050 public:
7052  SearchResults();
7053 
7056  SearchResults(SearchResults const & in_search_results);
7057 
7061  SearchResults(SearchResults && in_that);
7062 
7066  SearchResults & operator=(SearchResults && in_that);
7067 
7069  virtual void Reset();
7070 
7072  ~SearchResults();
7073 
7074  static const HPS::Type staticType = HPS::Type::SearchResults;
7075  HPS::Type ObjectType() const {return staticType;}
7076 
7080  void Assign(SearchResults const & in_search_results);
7081 
7085  SearchResults & operator=(SearchResults const & in_search_results);
7086 
7089  size_t GetCount() const;
7090 
7093  SearchResultsIterator GetIterator() const;
7094 };
7095 
7097 class HPS_API FontSearchResultsIterator : public Object
7098 {
7099 public:
7100 
7103 
7107  FontSearchResultsIterator(FontSearchResultsIterator const & in_search_results_iterator);
7108 
7113 
7118  FontSearchResultsIterator & operator=(FontSearchResultsIterator const & in_search_results_iterator);
7119 
7120 
7124  FontSearchResultsIterator & operator=(FontSearchResultsIterator && in_that);
7125 
7127 
7128  static const HPS::Type staticType = HPS::Type::FontSearchResultsIterator;
7129  HPS::Type ObjectType() const {return staticType;}
7130 
7131 
7136  void Set(FontSearchResultsIterator const & in_search_results_iterator);
7137 
7139  void Next();
7140 
7143  FontSearchResultsIterator & operator++();
7144 
7147  FontSearchResultsIterator operator++(int in_val);
7148 
7151  bool operator==(FontSearchResultsIterator const & in_search_results_iterator);
7152 
7155  bool operator!=(FontSearchResultsIterator const & in_search_results_iterator);
7156 
7160  bool IsValid() const;
7161 
7163  void Reset();
7164 
7168  FontInfoState GetItem() const;
7169 
7172  FontInfoState operator*() const;
7173 
7174 };
7175 
7177 class HPS_API FontSearchResults : public Object
7178 {
7179 public:
7180 
7183 
7186  FontSearchResults(FontSearchResults const & in_search_results);
7187 
7192 
7196  FontSearchResults & operator=(FontSearchResults && in_that);
7197 
7199  virtual void Reset();
7200 
7202  ~FontSearchResults();
7203 
7204  static const HPS::Type staticType = HPS::Type::FontSearchResults;
7205  HPS::Type ObjectType() const {return staticType;}
7206 
7210  void Assign(FontSearchResults const & in_search_results);
7211 
7212 
7216  FontSearchResults & operator=(FontSearchResults const & in_search_results);
7217 
7220  size_t GetCount() const;
7221 
7224  FontSearchResultsIterator GetIterator() const;
7225 };
7226 
7228 class HPS_API UTF8
7229 {
7230 public:
7231 
7233  UTF8();
7234 
7236  ~UTF8();
7237 
7244  UTF8(char const * in_string, char const * in_locale = 0);
7245 
7248  UTF8(wchar_t const * in_string);
7249 
7252  UTF8(UTF8 const & in_that);
7253 
7256  UTF8(UTF8 && in_that);
7257 
7261  UTF8 & Assign(UTF8 && in_utf8);
7262 
7265  inline UTF8 & operator= (UTF8 && in_utf8)
7266  {
7267  return Assign(std::move(in_utf8));
7268  }
7269 
7274  size_t ToWStr(wchar_t * out_wide_string) const;
7275 
7279  size_t ToWStr(WCharArray & out_wide_string) const;
7280 
7283  inline bool IsValid() const
7284  {
7285  return (_length > 0);
7286  }
7287 
7290  inline bool Empty() const
7291  {
7292  return (_length == 0);
7293  }
7294 
7296  void Clear();
7297 
7299  void Reset() { Clear(); }
7300 
7304  inline size_t GetLength() const
7305  {
7306  return _length;
7307  }
7308 
7312  inline size_t GetWStrLength() const
7313  {
7314  return ToWStr(0);
7315  }
7316 
7319  inline char const * GetBytes() const
7320  {
7321  return _text;
7322  }
7323 
7326  inline operator char const * () const
7327  {
7328  return _text;
7329  }
7330 
7333  char At(size_t in_index) const
7334  {
7335  if(!IsValid())
7336  throw InvalidObjectException();
7337  else if(in_index >= _length)
7338  throw IndexOutOfRangeException();
7339  else
7340  return _text[in_index];
7341  }
7342 
7346  UTF8 & Assign(UTF8 const & in_utf8);
7347 
7351  inline UTF8 & operator= (UTF8 const & in_utf8)
7352  {
7353  return Assign(in_utf8);
7354  }
7355 
7359  UTF8 & operator+= (UTF8 const & in_utf8);
7360 
7364  UTF8 & operator+= (char const * in_utf8);
7365 
7369  UTF8 operator+ (UTF8 const & in_utf8) const;
7370 
7374  UTF8 operator+ (char const * in_utf8) const;
7375 
7379  bool operator== (UTF8 const & in_utf8) const;
7380 
7384  bool operator!= (UTF8 const & in_utf8) const
7385  {
7386  return !(*this == in_utf8);
7387  }
7388 
7392  bool operator== (char const * in_utf8) const;
7393 
7397  bool operator!= (char const * in_utf8) const
7398  {
7399  return !(*this == in_utf8);
7400  }
7401 
7406  friend inline bool operator==(char const * in_left, UTF8 const & in_right)
7407  {
7408  return in_right == in_left;
7409  }
7410 
7415  friend inline bool operator!=(char const * in_left, UTF8 const & in_right)
7416  {
7417  return in_right != in_left;
7418  }
7419 
7424  friend inline bool operator==(wchar_t const * in_left, UTF8 const & in_right)
7425  {
7426  return in_right == UTF8(in_left);
7427  }
7428 
7433  friend bool operator!=(wchar_t const * in_left, UTF8 const & in_right)
7434  {
7435  return in_right != UTF8(in_left);
7436  }
7437 
7442  friend inline UTF8 operator+ (char const * in_left, UTF8 const & in_right)
7443  {
7444  return UTF8(in_left, "utf8") + in_right;
7445  }
7446 
7451  friend inline UTF8 operator+ (wchar_t const * in_left, UTF8 const & in_right)
7452  {
7453  return UTF8(in_left) + in_right;
7454  }
7455 
7456 
7459  size_t GetHash() const;
7460 
7461  friend class HPSI::String;
7462 
7463 private:
7464 
7465  size_t internal_encode(wchar_t const * in_wide_string);
7466  static size_t internal_decode(size_t in_length, const char* in_utf8_string, wchar_t * out_wide_string);
7467  size_t internal_decode(wchar_t * out_wide_string) const;
7468 
7469  char * _text;
7470  size_t _length;
7471  mutable size_t _hash_key;
7472  static const size_t _buffer_size = 64 - sizeof(const char *) - 2 * sizeof(size_t);
7473  char _buffer[_buffer_size];
7474 };
7475 
7477 struct UTF8Hasher {
7478  inline size_t operator()(const HPS::UTF8 & in_utf8) const
7479  {
7480  return in_utf8.GetHash();
7481  }
7482 };
7483 
7486 class HPS_API ConditionalExpression : public Object
7487 {
7488 public:
7489 
7492 
7495  ConditionalExpression(char const * in_condition);
7496 
7499  ConditionalExpression(float in_number);
7500 
7503  ConditionalExpression(HPS::Condition::Intrinsic in_special);
7504 
7508 
7513 
7517  ConditionalExpression & operator=(ConditionalExpression && in_that);
7518 
7519  static const HPS::Type staticType = HPS::Type::ConditionalExpression;
7520  HPS::Type ObjectType() const { return staticType; }
7521 
7525  bool ShowCondition(UTF8 & out_condition) const;
7526 
7530  bool ShowNumber(float & out_number) const;
7531 
7535  bool ShowIntrinsic(Condition::Intrinsic & out_special) const;
7536 
7540  bool ShowOperands(ConditionalExpressionArray & out_operands) const;
7541 
7545  ConditionalExpression & operator=(ConditionalExpression const & in_that);
7546 
7550  bool Equals(ConditionalExpression const & in_that) const;
7551 
7555  bool operator==(ConditionalExpression const & in_that) const;
7556 
7560  bool operator!=(ConditionalExpression const & in_that) const;
7561 
7565  bool IsSatisfiedBy(UTF8Array const & in_conditions) const;
7566 
7570  bool IsSatisfiedBy(char const * in_condition) const;
7571 
7575  ConditionalExpression OR(ConditionalExpression const & in_operand2) const;
7576 
7580  ConditionalExpression XOR(ConditionalExpression const & in_operand2) const;
7581 
7585  ConditionalExpression AND(ConditionalExpression const & in_operand2) const;
7586 
7590  ConditionalExpression EQ(ConditionalExpression const & in_operand2)