15 # ifdef HPS_CORE_BUILD 16 # define HPS_API __declspec (dllexport) 17 # define EXPIMP_TEMPLATE 19 # define HPS_API __declspec (dllimport) 20 # define EXPIMP_TEMPLATE extern 22 # define HPS_TEMPLATE_API __declspec (dllexport) 32 # pragma warning(push) 33 # pragma warning(disable: 4251) //Not an issue as long as debug and release libraries aren't mixed 39 # ifdef HPS_CORE_BUILD 40 # define HPS_API __attribute__ ((visibility ("default"))) 41 # define EXPIMP_TEMPLATE 43 # define EXPIMP_TEMPLATE extern 45 # define HPS_TEMPLATE_API __attribute__ ((visibility ("default"))) 52 #ifndef HPS_TEMPLATE_API 53 # define HPS_TEMPLATE_API 55 #ifndef EXPIMP_TEMPLATE 56 # define EXPIMP_TEMPLATE 59 # define ENUM_CLASS enum class 80 class EventDispatcherImpl;
260 GradientTopLeftToBottomRight,
261 GradientTopRightToBottomLeft,
262 GradientBottomLeftToTopRight,
263 GradientBottomRightToTopLeft,
373 FeatureSizePercentage
585 SubsegmentsAndIncludes
601 Everything = 0x00ffffff,
603 Include = 0x00000042,
604 Segment = 0x00000043,
606 Includer = 0x00000100,
609 Geometry = 0x10000000,
615 NURBSSurface = 0x1000002b,
618 Polygon = 0x1000002f,
621 CircularWedge = 0x10000032,
622 Ellipse = 0x10000033,
624 NURBSCurve = 0x10000037,
625 CircularArc = 0x10000038,
626 EllipticalArc = 0x10000039,
631 Reference = 0x10000041,
633 DistantLight = 0x10000100,
635 InfiniteRay = 0x10000102,
638 Attribute = 0x20000000,
640 Priority = 0x20000001,
644 PBRMaterial = 0x2000000c,
646 ModellingMatrix = 0x20000011,
647 UserData = 0x20000022,
648 TextureMatrix = 0x20000024,
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,
661 CurveAttribute = 0x20002000,
662 CurveAttributeBudget = 0x20002001,
663 CurveAttributeContinuedBudget = 0x20002002,
664 CurveAttributeViewDependent = 0x20002003,
665 CurveAttributeMaximumDeviation = 0x20002004,
666 CurveAttributeMaximumAngle = 0x20002005,
667 CurveAttributeMaximumLength = 0x20002006,
669 CylinderAttribute = 0x20003000,
670 CylinderAttributeTessellation = 0x20003001,
671 CylinderAttributeOrientation = 0x20003002,
673 EdgeAttribute = 0x20004000,
674 EdgeAttributePattern = 0x20004016,
675 EdgeAttributeWeight = 0x20004017,
676 EdgeAttributeHardAngle = 0x20004018,
678 LightingAttribute = 0x20005000,
679 LightingAttributeInterpolation = 0x20005001,
681 LineAttribute = 0x20006000,
682 LineAttributePattern = 0x2000601a,
683 LineAttributeWeight = 0x2000601b,
685 MarkerAttribute = 0x20007000,
686 MarkerAttributeGlyphRotation = 0x2000701a,
687 MarkerAttributeSize = 0x2000701c,
688 MarkerAttributeSymbol = 0x2000701d,
689 MarkerAttributePreference = 0x2000701e,
691 SurfaceAttribute = 0x20008000,
692 SurfaceAttributeBudget = 0x20008001,
693 SurfaceAttributeMaximumFacetDeviation = 0x20008002,
694 SurfaceAttributeMaximumFacetAngle = 0x20008003,
695 SurfaceAttributeMaximumFacetWidth = 0x20008004,
696 SurfaceAttributeTrimCurveBudget = 0x20008005,
697 SurfaceAttributeMaximumTrimCurveDeviation = 0x20008006,
700 SelectabilityWindows = 0x20009001,
701 SelectabilityEdges = 0x20009002,
702 SelectabilityFaces = 0x20009003,
703 SelectabilityLights = 0x20009004,
704 SelectabilityLines = 0x20009005,
705 SelectabilityMarkers = 0x20009006,
706 SelectabilityVertices = 0x20009007,
707 SelectabilityText = 0x20009008,
709 SphereAttribute = 0x2000a000,
710 SphereAttributeTessellation = 0x2000a001,
713 SubwindowEitherType = 0x2000b001,
714 SubwindowStandard = 0x2000b00e,
715 SubwindowLightweight = 0x2000b002,
716 SubwindowBackground = 0x2000b003,
717 SubwindowBorder = 0x2000b004,
718 SubwindowRenderingAlgorithm = 0x2000b005,
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,
746 TransparencyMethod = 0x2000d001,
747 TransparencyAlgorithm = 0x2000d002,
748 TransparencyDepthPeelingLayers = 0x2000d004,
749 TransparencyDepthPeelingMinimumArea = 0x2000d005,
750 TransparencyDepthWriting = 0x2000d006,
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,
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,
792 PerformanceDisplayLists = 0x20010001,
793 PerformanceStaticModel = 0x20010002,
794 StaticModelSegment = 0x40000043,
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,
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,
826 SegmentStyle = 0x20013001,
827 NamedStyle = 0x20013002,
828 MaterialPalette = 0x20013003,
829 Portfolio = 0x20013004,
832 ContourLineVisibility = 0x20014001,
833 ContourLinePosition = 0x20014002,
834 ContourLineColor = 0x20014003,
835 ContourLinePattern = 0x20014004,
836 ContourLineWeight = 0x20014005,
837 ContourLineLighting = 0x20014006,
842 BoundingVolume = 0x20016001,
843 BoundingExclusion = 0x20016002,
846 AttributeLockSetting = 0x20017001,
847 AttributeLockSubsegmentOverride = 0x20017002,
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,
863 ColorInterpolation = 0x20019000,
864 ColorInterpolationFaceColor = 0x20019001,
865 ColorInterpolationEdgeColor = 0x20019002,
866 ColorInterpolationMarkerColor = 0x20019003,
867 ColorInterpolationFaceIndex = 0x20019004,
868 ColorInterpolationEdgeIndex = 0x20019005,
869 ColorInterpolationMarkerIndex = 0x20019006,
871 CuttingSectionAttribute = 0x2001a000,
872 CuttingSectionAttributeCuttingLevel = 0x2001a001,
873 CuttingSectionAttributeCappingLevel = 0x2001a002,
874 CuttingSectionAttributeMaterialPreference = 0x2001a003,
875 CuttingSectionAttributeEdgeWeight = 0x2001a004,
876 CuttingSectionAttributeTolerance = 0x2001a005,
877 CuttingSectionAttributeCappingUsage = 0x2001a006,
919 EnvironmentTexture = 8,
920 EnvironmentCubeMap = 9,
959 EnvironmentTexture = 8,
960 EnvironmentCubeMap = 9
1104 PostProcessEffects() {}
1180 Everything = 0x01000000,
1182 Visibility = 0x02000000,
1184 VisibilityCuttingSections,
1190 VisibilityEdgeLights,
1191 VisibilityMarkerLights,
1192 VisibilityFaceLights,
1193 VisibilityGenericEdges,
1194 VisibilityHardEdges,
1195 VisibilityAdjacentEdges,
1196 VisibilityInteriorSilhouetteEdges,
1197 VisibilityShadowEmitting,
1198 VisibilityShadowReceiving,
1199 VisibilityShadowCasting,
1203 VisibilityPerimeterEdges,
1204 VisibilityNonCulledEdges,
1205 VisibilityMeshQuadEdges,
1206 VisibilityCutGeometry,
1215 MaterialCutGeometry,
1217 MaterialAmbientLightUpColor,
1218 MaterialAmbientLightDownColor,
1219 MaterialAmbientLightColor,
1221 MaterialWindowColor,
1222 MaterialWindowContrastColor,
1226 MaterialMarkerColor,
1228 MaterialCutEdgeColor,
1231 MaterialVertexDiffuse,
1232 MaterialVertexDiffuseColor,
1233 MaterialVertexDiffuseAlpha,
1234 MaterialVertexDiffuseTexture,
1235 MaterialVertexSpecular,
1236 MaterialVertexMirror,
1237 MaterialVertexTransmission,
1238 MaterialVertexEmission,
1239 MaterialVertexEnvironment,
1241 MaterialVertexGloss,
1244 MaterialEdgeDiffuse,
1245 MaterialEdgeDiffuseColor,
1246 MaterialEdgeDiffuseAlpha,
1247 MaterialEdgeDiffuseTexture,
1248 MaterialEdgeSpecular,
1250 MaterialEdgeTransmission,
1251 MaterialEdgeEmission,
1252 MaterialEdgeEnvironment,
1257 MaterialFaceDiffuse,
1258 MaterialFaceDiffuseColor,
1259 MaterialFaceDiffuseAlpha,
1260 MaterialFaceDiffuseTexture,
1261 MaterialFaceSpecular,
1263 MaterialFaceTransmission,
1264 MaterialFaceEmission,
1265 MaterialFaceEnvironment,
1270 MaterialBackFaceDiffuse,
1271 MaterialBackFaceDiffuseColor,
1272 MaterialBackFaceDiffuseAlpha,
1273 MaterialBackFaceDiffuseTexture,
1274 MaterialBackFaceSpecular,
1275 MaterialBackFaceMirror,
1276 MaterialBackFaceTransmission,
1277 MaterialBackFaceEmission,
1278 MaterialBackFaceEnvironment,
1279 MaterialBackFaceBump,
1280 MaterialBackFaceGloss,
1283 MaterialFrontFaceDiffuse,
1284 MaterialFrontFaceDiffuseColor,
1285 MaterialFrontFaceDiffuseAlpha,
1286 MaterialFrontFaceDiffuseTexture,
1287 MaterialFrontFaceSpecular,
1288 MaterialFrontFaceMirror,
1289 MaterialFrontFaceTransmission,
1290 MaterialFrontFaceEmission,
1291 MaterialFrontFaceEnvironment,
1292 MaterialFrontFaceBump,
1293 MaterialFrontFaceGloss,
1296 MaterialCutFaceDiffuse,
1297 MaterialCutFaceDiffuseColor,
1298 MaterialCutFaceDiffuseAlpha,
1299 MaterialCutFaceDiffuseTexture,
1300 MaterialCutFaceSpecular,
1301 MaterialCutFaceMirror,
1302 MaterialCutFaceTransmission,
1303 MaterialCutFaceEmission,
1304 MaterialCutFaceEnvironment,
1305 MaterialCutFaceBump,
1306 MaterialCutFaceGloss,
1636 CharacterPositionOnly,
1639 CharacterPositionAdjusted,
1641 NonScalingTransformable
1777 NormalizedInnerWindow,
1778 NormalizedInnerPixel
1912 enum class IOResult : uint32_t
1922 UnableToLoadLibraries,
1923 VersionIncompatibility,
1924 InitializationFailed,
2104 TriangleDownWithDot,
2107 TriangleRightWithDot,
2110 TriangleLeftWithDot,
2117 SolidTriangleRightV,
2165 enum class Intrinsic : uint32_t
2202 enum class UserData : uint32_t
2211 enum class Scope : uint32_t
2214 SubsegmentsAndIncludes,
2218 enum class Expansion : uint32_t
2223 IncludesAndReferences,
2226 enum class Matrix : uint32_t
2233 enum class Reorganization : uint32_t
2263 NormalizedInnerWindow,
2264 NormalizedInnerPixel,
2278 enum class ClipRegion : uint32_t
2308 typedef double Time;
2312 # define HPS_INLINE __forceinline 2315 # define HPS_INLINE inline 2318 #ifndef HPS_UNREFERENCED 2319 #define HPS_UNREFERENCED(param) ((void)(param)) 2323 const double PI = 3.141592653589793238462643383279502884197169399375105820974944592308;
2325 template<
typename T>
2326 HPS_INLINE T Degrees_To_Radians(T
const & degrees)
2328 return degrees * (T)(PI / 180.0);
2331 template<
typename T>
2332 HPS_INLINE T Radians_To_Degrees(T
const & radians)
2334 return radians * (T)(180.0 / PI);
2337 template<
typename T>
2338 HPS_INLINE
void SinCos(T
const & angle, T & sine, T & cosine) {
2339 T a = Degrees_To_Radians(angle);
2344 template<
typename T>
2345 HPS_INLINE T Cos(T
const & angle) {
2346 return cos (Degrees_To_Radians(angle));
2349 template<
typename T>
2350 HPS_INLINE T Sin(T
const & angle) {
2351 return sin (Degrees_To_Radians(angle));
2354 template<
typename T>
2355 HPS_INLINE T ACos(T
const & x) {
2360 return Radians_To_Degrees(acos(x));
2363 template<
typename T>
2364 HPS_INLINE T ATan2(T
const & y, T
const & x) {
2365 if (x == 0 && y == 0)
2367 return Radians_To_Degrees(atan2(y, x));
2373 typedef double Alternative;
2374 static const int Type = 1;
2375 static float Epsilon () {
return 1.0e-30f; }
2378 typedef float Alternative;
2379 static const int Type = 2;
2380 static double Epsilon () {
return 1.0e-300; }
2389 # if HOOPS_BIGENDIAN 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; }
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;
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;
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;
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;
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; }
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) {
2434 memcpy (v, &a,
sizeof(
double));
2435 return is_infinite (v);
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) {
2442 memcpy (v, &a,
sizeof(
double));
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) {
2450 memcpy (v, &a,
sizeof(
double));
2451 return is_special (v);
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);
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)
2463 if (a.size() != b.size())
2466 auto it1 = a.begin();
2467 auto it2 = b.begin();
2468 auto const end = a.end();
2469 for ( ; it1 != end; ++it1, ++it2)
2471 if (!Equals(*it1, *it2, tolerance))
2478 static HPS_INLINE uint32_t extract_sign_bit(
float const & a) {
2479 return extract_uint32_t(a) & 0x80000000;
2481 static HPS_INLINE uint32_t extract_sign_bit(
double const & a) {
2483 memcpy (v, &a,
sizeof(
double));
2484 return v[High] & 0x80000000;
2487 static HPS_INLINE
void apply_sign_bit(
float & a, uint32_t
const & sign_bit) {
2488 uint32_t v = extract_uint32_t(a);
2491 inject_uint32_t(a, v);
2493 static HPS_INLINE
void apply_sign_bit(
double & a, uint32_t
const & sign_bit) {
2495 memcpy (v, &a,
sizeof(
double));
2496 v[High] &= 0x7FFFFFFF;
2497 v[High] |= sign_bit;
2498 memcpy (&a, v,
sizeof(
double));
2502 static HPS_INLINE
unsigned char unit_to_byte(
float const & a) {
2503 uint32_t v = extract_uint32_t(a);
2511 uint32_t exp = v >> 23;
2512 uint32_t man = (v & 0x007FFFFF) | 0x00800000;
2514 return (
unsigned char) (man >> (16 + 126 - exp));
2517 static HPS_INLINE
unsigned char unit_to_byte_scaled(
float const & a,
unsigned char mix) {
2518 uint32_t v = extract_uint32_t(a);
2526 uint32_t exp = v >> 23;
2527 uint32_t man = (v & 0x007FFFFF) | 0x00800000;
2529 uint32_t x = (man >> (16 + 126 - exp));
2531 return (
unsigned char) ((x * (mix+1)) >> 8);
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);
2539 if (((va | vb) & 0x7FFFFFFF) == 0)
2544 static HPS_INLINE
bool match(
double const & a,
double const & b) {
2549 static HPS_INLINE
void replace_if_smaller(
float & a,
float const & b) {
2553 static HPS_INLINE
void replace_if_smaller(
double & a,
double const & b) {
2558 static HPS_INLINE
void replace_if_larger(
float & a,
float const & b) {
2562 static HPS_INLINE
void replace_if_larger(
double & a,
double const & b) {
2568 static HPS_INLINE uint32_t extract_uint32_t(
float const & a) {
2570 memcpy(&i, &a,
sizeof(
float));
2574 static HPS_INLINE
void inject_uint32_t(
float & a, uint32_t
const & i) {
2575 memcpy(&a, &i,
sizeof(
float));
2578 static HPS_INLINE
float C2F(
unsigned char x) {
2580 return char_to_float[x];
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));
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));
2599 static HPS_INLINE
void unpack_4(
float * f0,
float const *
const m) {
2600 memcpy(f0, m,
sizeof(
float)*4);
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));
2611 static const float char_to_float[256];
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); }
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)); }
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); }
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); }
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; }
2645 template <> HPS_INLINE
float Abs<float> (
float const & a) {
2646 uint32_t v = Float::extract_uint32_t(a);
2649 Float::inject_uint32_t(f,v);
2653 template <> HPS_INLINE
int Sign<float> (
float const & a) {
2654 uint32_t v = Float::extract_uint32_t(a);
2656 if ((v & 0x7FFFFFFF) == 0)
2659 return ((int32_t)(v & 0x80000000)>>31) | 0x01;
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);
2669 if (is_special(va) || is_special(vb)) {
2670 if (is_infinite(va) || is_infinite(vb))
2672 if (is_nan(va) || is_nan(vb))
2676 int const close_to_zero = 0x36A00000;
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;
2682 uint32_t sign_mask = va ^ vb;
2683 (int32_t &)sign_mask >>= 31;
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;
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));
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];
2699 if (is_nan(va) || is_nan(vb))
2703 if ((va[High] == 0 && va[Low] == 0) || (vb[High] == 0 && vb[Low] == 0))
2704 return Abs(a - b) < 0.000000000000005;
2706 if (extract_sign_bit(a) != extract_sign_bit(b))
2709 if (va[High] != vb[High])
2712 return Abs(va[Low] - vb[Low]) <= tolerance;
2719 HPS_INLINE
bool Is_Abnormal (
double const & d) {
return Float::IsAbnormal (d); }
2721 template <
typename T>
2722 HPS_INLINE
bool Is_Abnormal (
size_t count, T
const * t) {
2724 if (Is_Abnormal (*t++))
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);
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;
2744 template <
typename F>
2752 Point_3D (F v1, F v2, F v3) : x (v1), y (v2), z (v3) {}
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) {}
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); }
2766 bool Equals(
Point_3D const & p,
int in_tolerance = 32)
const {
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); }
2778 F & operator[] (
size_t i) {
return (&x)[i]; }
2779 F
const & operator[] (
size_t i)
const {
return (&x)[i]; }
2812 template <
typename F,
typename S>
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;
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);
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);
2831 template <
typename F>
2838 Point_2D (F v1, F v2) : x (v1), y (v2) {}
2840 template <
typename D>
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); }
2851 bool Equals(
Point_2D const & p,
int in_tolerance = 32)
const {
2856 Point_2D & operator*= (F s) { x *= s; y *= s;
return *
this; }
2857 Point_2D & operator/= (F s) {
return operator*= ((F)1 / s); }
2859 Point_2D const operator/ (F s)
const {
return operator* ((F)1 / s); }
2861 F & operator[] (
size_t i) {
return (&x)[i]; }
2862 F
const & operator[] (
size_t i)
const {
return (&x)[i]; }
2883 template <
typename F>
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)); }
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;
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);
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);
2905 template <
typename F>
2913 Vector_3D (F v1, F v2, F v3) : x (v1), y (v2), z (v3) {}
2914 template <
typename D>
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);
2926 bool operator!= (
Vector_3D const & v)
const {
return !(*
this == v); }
2928 bool Equals(
Vector_3D const & v,
int in_tolerance = 32)
const {
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; }
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); }
2942 Vector_3D const operator/ (F s)
const {
return operator* (1.0f / s); }
2944 F & operator[] (
size_t i) {
return (&x)[i]; }
2945 F
const & operator[] (
size_t i)
const {
return (&x)[i]; }
2947 HPS_INLINE
double Length ()
const {
return sqrt (LengthSquared()); }
2949 HPS_INLINE
double LengthSquared ()
const {
return (
double)x*(double)x + (
double)y*(double)y + (
double)z*(double)z; }
2951 HPS_INLINE
double Length2D ()
const {
return sqrt (LengthSquared2D()); }
2953 HPS_INLINE
double LengthSquared2D ()
const {
return (
double)x*(double)x + (
double)y*(double)y;}
2957 F range = Max (Abs (x), Abs (y), Abs (z));
2958 if (range > F(1.0e10))
2962 F len = (F)Length();
2969 HPS_INLINE
Vector_3D & Normalize (F epsilon) {
return Normalize (
false, epsilon); }
2971 HPS_INLINE
Vector_3D & Clean_Zeroes (F epsilon = F(1.0e-4)) {
2972 if (Abs(x) < epsilon)
2974 if (Abs(y) < epsilon)
2976 if (Abs(z) < epsilon)
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); }
2984 HPS_INLINE F Dot (
Vector_3D const & v)
const {
return x * v.x + y * v.y + z * v.z; }
2987 return Vector_3D (y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x);
2992 return Vector_3D (x * v.x, y * v.y, z * v.z);
2996 if (Abs (x) < Abs (y))
3014 template <
typename F,
typename S>
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);
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) {}
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; }
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); }
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); }
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); }
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;
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();
3062 template <
typename F>
3063 HPS_INLINE
double PointToPointDistance(Point_3D<F>
const & p1, Point_3D<F>
const & p2) {
3064 return (p2 - p1).Length();
3067 template <
typename F>
3068 HPS_INLINE
double PointToPointDistanceSquared(Point_3D<F>
const & p1, Point_3D<F>
const & p2) {
3069 return (p2 - p1).LengthSquared();
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());
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)) );
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())
3097 template <
typename F>
class HPS_TEMPLATE_API Plane_2D;
3099 template <
typename F>
3106 Vector_2D (F v1, F v2) : x (v1), y (v2) {}
3107 template <
typename D>
3116 bool operator== (
Vector_2D const & v)
const {
3117 return Float::match(x, v.x) && Float::match(y, v.y);
3119 bool operator!= (
Vector_2D const & v)
const {
return !(*
this == v); }
3121 bool Equals(
Vector_2D const & v,
int in_tolerance = 32)
const {
3130 Vector_2D & operator*= (F s) { x *= s; y *= s;
return *
this; }
3131 Vector_2D & operator/= (F s) {
return operator*= (1.0f / s); }
3133 Vector_2D const operator/ (F s)
const {
return operator* (1.0f / s); }
3135 F & operator[] (
size_t i) {
return (&x)[i]; }
3136 F
const & operator[] (
size_t i)
const {
return (&x)[i]; }
3138 HPS_INLINE
double Length ()
const {
return sqrt (LengthSquared()); }
3140 HPS_INLINE
double LengthSquared ()
const {
return (
double)x*(double)x + (
double)y*(double)y; }
3144 F range = Max (Abs (x), Abs (y));
3145 if (range > F(1.0e10))
3149 F len = (F)Length();
3156 HPS_INLINE
Vector_2D & Normalize (F epsilon) {
return Normalize (
false, epsilon); }
3158 HPS_INLINE F Magnitude ()
const {
return Max (Abs(x), Abs(y)); }
3159 HPS_INLINE F Manhattan ()
const {
return Abs(x)+Abs(y); }
3161 HPS_INLINE F Dot (
Vector_2D const & v)
const {
return x * v.x + y * v.y; }
3164 HPS_INLINE F Cross (
Vector_2D const & v)
const {
3165 return x * v.y - y * v.x;
3182 template <
typename F,
typename S>
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);
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) {}
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) {}
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; }
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); }
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; }
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); }
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; }
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); }
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); }
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); }
3244 template <
typename F>
3253 Plane_3D (F v1, F v2, F v3, F v4) : a (v1), b (v2), c (v3), d (v4) {}
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) {}
3274 for (
size_t i=0; i<count; ++i) {
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);
3289 double inv_count = 1.0 / (double)count;
3297 *
this = Plane_3D::Zero();
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); }
3306 F & operator[] (
size_t i) {
return (&a)[i]; }
3307 F
const & operator[] (
size_t i)
const {
return (&a)[i]; }
3309 HPS_INLINE
bool Equals(
Plane_3D const & p,
int in_tolerance = 32)
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);
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));
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));
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));
3344 bool parallel (
Plane_3D const & p)
const {
3345 return equivalent (a, p.a) &&
3346 equivalent (b, p.b) &&
3347 equivalent (c, p.c);
3350 bool equivalent (
Plane_3D const & p)
const {
3351 return parallel (p) &&
3352 equivalent (d, p.d, (F)1.0e-6);
3356 static HPS_INLINE
Plane_3D Zero() {
return Plane_3D (0.0f, 0.0f, 0.0f, 0.0f);};
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); }
3365 static bool equivalent (
float a,
float b) {
3366 if (Abs(a) < 1.0e-4f && Abs(b) < 1.0e-4f)
3371 static bool equivalent (
float a,
float b,
float cutoff) {
3372 if (Abs(a) < cutoff && Abs(b) < cutoff)
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);
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;
3392 template <
typename F>
3393 HPS_INLINE F operator* (Point_3D<F>
const & point, Plane_3D<F>
const & plane) {
3394 return plane * point;
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);
3402 template <
typename F>
3403 Vector_3D<F>::Vector_3D(Plane_3D<F>
const & p) : x(p.a), y(p.b), z(p.c) {}
3410 template <
typename F>
3418 Plane_2D (F v1, F v2, F v3) : a (v1), b (v2), c (v3) {}
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) {}
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); }
3430 F & operator[] (
size_t i) {
return (&a)[i]; }
3431 F
const & operator[] (
size_t i)
const {
return (&a)[i]; }
3433 HPS_INLINE
bool Equals(
Plane_2D const & p,
int in_tolerance = 32)
const {
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); }
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);
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;
3470 template <
typename F>
3471 HPS_INLINE F operator* (Point_3D<F>
const & point, Plane_2D<F>
const & plane) {
3472 return plane * point;
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);
3480 template <
typename F>
3481 Vector_2D<F>::Vector_2D(Plane_2D<F>
const & p) : x(p.a), y(p.b) {}
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()) {}
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) {}
3502 : left(that.left), right(that.right), bottom(that.bottom), top(that.top) {}
3507 return (left == rect.left && right == rect.right && bottom == rect.bottom && top == rect.top);
3511 return !(*
this == rect);
3514 HPS_INLINE
int PixelWidth()
const {
3515 return right - left + 1;
3518 HPS_INLINE
int PixelHeight()
const {
3519 return top - bottom + 1;
3522 HPS_INLINE
int Width()
const {
3523 return right - left;
3526 HPS_INLINE
int Height()
const {
3527 return top - bottom;
3530 HPS_INLINE
int Area()
const {
3531 return Width() * Height();
3534 HPS_INLINE
float Aspect()
const {
3535 return (
float)Height() / (float)Width();
3538 HPS_INLINE
Point2D Center()
const {
3539 return Point2D((
float)(left + right) * 0.5f, (
float)(bottom + top) * 0.5f);
3542 HPS_INLINE
bool Intersecting(
IntRectangle const & rect)
const {
3543 return right >= rect.left && left <= rect.right && top >= rect.bottom && bottom <= rect.top;
3546 HPS_INLINE
bool Contains(
IntRectangle const & rect)
const {
3547 return (left <= rect.left && right >= rect.right && bottom <= rect.bottom && top >= rect.top);
3560 right += rect.right;
3561 bottom -= rect.bottom;
3576 right -= rect.right;
3577 bottom += rect.bottom;
3583 left = Max(left, rect.left);
3584 right = Min(right, rect.right);
3585 bottom = Max(bottom, rect.bottom);
3586 top = Min(top, rect.top);
3591 left = Min(left, rect.left);
3592 right = Max(right, rect.right);
3593 bottom = Min(bottom, rect.bottom);
3594 top = Max(top, rect.top);
3611 return temp.Expand(border);
3614 HPS_INLINE IntRectangle Expand(IntRectangle
const & a,
int border) {
3615 IntRectangle temp = a;
3616 return temp.Expand(border);
3619 HPS_INLINE IntRectangle Contract(IntRectangle
const & a,
int border) {
3620 IntRectangle temp = a;
3621 return temp.Contract(border);
3624 HPS_INLINE IntRectangle Contract(IntRectangle
const & a, IntRectangle
const & border) {
3625 IntRectangle temp = a;
3626 return temp.Contract(border);
3629 HPS_INLINE IntRectangle Intersect(IntRectangle
const & a, IntRectangle
const & b) {
3630 IntRectangle temp = a;
3631 return temp.Intersect(b);
3634 HPS_INLINE IntRectangle Union(IntRectangle
const & a, IntRectangle
const & b) {
3635 IntRectangle temp = a;
3636 return temp.Union(b);
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()) {}
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) {}
3653 : left(that.left), right(that.right), bottom(that.bottom), top(that.top) {}
3656 : left((
float)that.left), right((
float)that.right), bottom((
float)that.bottom), top((
float)that.top) {}
3666 Merge(count, points);
3678 Merge(count, points);
3682 HPS_INLINE
float Width()
const {
3683 return right - left;
3686 HPS_INLINE
float Height()
const {
3687 return top - bottom;
3690 HPS_INLINE
float Area()
const {
3691 return Width() * Height();
3694 HPS_INLINE
float Aspect()
const {
3695 return Height() / Width();
3698 HPS_INLINE
Point2D Center()
const {
3699 return Point2D((left + right) * 0.5f, (bottom + top) * 0.5f);
3702 HPS_INLINE
void Merge(
size_t count,
Point const * points) {
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);
3710 Float::replace_if_smaller(left, points[0].x);
3711 Float::replace_if_larger(right, points[1].x);
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);
3719 Float::replace_if_smaller(bottom, points[0].y);
3720 Float::replace_if_larger(top, points[1].y);
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);
3738 HPS_INLINE
void Merge(
size_t count,
Point2D const * points) {
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);
3746 Float::replace_if_smaller(left, points[0].x);
3747 Float::replace_if_larger(right, points[1].x);
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);
3755 Float::replace_if_smaller(bottom, points[0].y);
3756 Float::replace_if_larger(top, points[1].y);
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);
3774 HPS_INLINE
bool operator==(
Rectangle const & rect)
const {
3775 return (left == rect.left && right == rect.right && bottom == rect.bottom && top == rect.top);
3778 HPS_INLINE
bool operator!=(
Rectangle const & rect)
const {
3779 return !(*
this == rect);
3782 HPS_INLINE
bool Equals(
Rectangle const & rect,
int in_tolerance = 32)
const {
3789 HPS_INLINE
bool Intersecting(
Rectangle const & rect)
const {
3790 return right >= rect.left && left <= rect.right && top >= rect.bottom && bottom <= rect.top;
3793 HPS_INLINE
bool Contains(
Point const & contained)
const {
3794 return !(contained.x < left || contained.x > right || contained.y < bottom || contained.y > top);
3797 HPS_INLINE
bool Contains(
Point2D const & contained)
const {
3798 return !(contained.x < left || contained.x > right || contained.y < bottom || contained.y > top);
3801 HPS_INLINE
bool Contains(
Rectangle const & rect) {
3802 return (left <= rect.left && right >= rect.right && bottom <= rect.bottom && top >= rect.top);
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);
3810 HPS_INLINE
Rectangle & Expand(
float border) {
3818 HPS_INLINE
Rectangle & Expand(
int border) {
3819 Expand((
float)border);
3825 right += rect.right;
3826 bottom -= rect.bottom;
3831 HPS_INLINE
Rectangle & Contract(
int border) {
3841 right -= rect.right;
3842 bottom += rect.bottom;
3848 left = Max(left, rect.left);
3849 right = Min(right, rect.right);
3850 bottom = Max(bottom, rect.bottom);
3851 top = Min(top, rect.top);
3856 left = Min(left, rect.left);
3857 right = Max(right, rect.right);
3858 bottom = Min(bottom, rect.bottom);
3859 top = Max(top, rect.top);
3864 float scale = (scope.right - scope.left) * 0.5f;
3865 float trans = (scope.right + scope.left) * 0.5f;
3867 left = left * scale + trans;
3868 right = right * scale + trans;
3870 scale = (scope.top - scope.bottom) * 0.5f;
3871 trans = (scope.top + scope.bottom) * 0.5f;
3873 bottom = bottom * scale + trans;
3874 top = top * scale + trans;
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;
3883 tmp = 2.0f/(scope.top - scope.bottom);
3884 top = (top - scope.bottom) * tmp - 1.0f;
3885 bottom = (bottom - scope.bottom) * tmp - 1.0f;
3889 static HPS_INLINE
Rectangle FullScope() {
3890 return Rectangle(-1.0f, 1.0f, -1.0f, 1.0f);
3893 static HPS_INLINE
Rectangle InvalidScope() {
3894 return Rectangle(1.0f, -1.0f, 1.0f, -1.0f);
3906 temp.left = Floor (a.left);
3907 temp.right = Floor (a.right);
3908 temp.bottom = Floor (a.bottom);
3909 temp.top = Floor (a.top);
3913 HPS_INLINE Rectangle Expand(Rectangle
const & a, Rectangle
const & border) {
3915 return temp.Expand(border);
3918 HPS_INLINE Rectangle Expand(Rectangle
const & a,
float border) {
3920 return temp.Expand(border);
3923 HPS_INLINE Rectangle Contract(Rectangle
const & a,
int border) {
3925 return temp.Contract(border);
3928 HPS_INLINE Rectangle Contract(Rectangle
const & a, Rectangle
const & border) {
3930 return temp.Contract(border);
3933 HPS_INLINE Rectangle Intersect(Rectangle
const & a, Rectangle
const & b) {
3935 return temp.Intersect(b);
3938 HPS_INLINE Rectangle Union(Rectangle
const & a, Rectangle
const & b) {
3940 return temp.Union(b);
3943 HPS_INLINE Rectangle Inscribe_Scope(Rectangle
const & a, Rectangle
const & scope) {
3945 return temp.Inscribe_Scope(scope);
3948 HPS_INLINE Rectangle Circumscribe_Scope(Rectangle
const & a, Rectangle
const & scope) {
3950 return temp.Circumscribe_Scope(scope);
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) {}
3959 template <
typename F>
3962 template <
typename F>
3980 template <
typename D>
4004 min = Limit_Point();
4005 max = -Limit_Point();
4008 min = max = *points++;
4010 Merge(count, points);
4019 template <
typename T>
4022 min = Limit_Point();
4023 max = -Limit_Point();
4026 min = max = points[*indices++];
4028 Merge(count, indices, points);
4041 return min.x <= max.x && min.y <= max.y && min.z <= max.z;
4058 HPS_INLINE
bool operator== (
Cuboid_3D const & cuboid)
const {
return (min == cuboid.
min && max == cuboid.
max); }
4064 HPS_INLINE
bool operator!= (
Cuboid_3D const & cuboid)
const {
return !(*
this == cuboid); }
4089 HPS_INLINE F Volume ()
const {
return (max.x - min.x) * (max.y - min.y) * (max.z - min.z); }
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;
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;
4121 return max[dimension] >= cuboid.
min[dimension] && min[dimension] <= cuboid.
max[dimension];
4133 return max[dimension] + allowance >= cuboid.
min[dimension] && min[dimension] - allowance <= cuboid.
max[dimension];
4143 return LineIntersecting(start, direction,
true);
4154 return LineIntersecting(point1, direction,
false);
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);
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);
4200 merge2(points[0], points[1]);
4216 template <
typename T>
4221 merge2(points[i1], points[i2]);
4226 Merge(points[*indices]);
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);
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);
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);
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);
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);
4329 Float::replace_if_smaller(min.x, p2.x);
4330 Float::replace_if_larger(max.x, p1.x);
4333 Float::replace_if_smaller(min.x, p1.x);
4334 Float::replace_if_larger(max.x, p2.x);
4338 Float::replace_if_smaller(min.y, p2.y);
4339 Float::replace_if_larger(max.y, p1.y);
4342 Float::replace_if_smaller(min.y, p1.y);
4343 Float::replace_if_larger(max.y, p2.y);
4347 Float::replace_if_smaller(min.z, p2.z);
4348 Float::replace_if_larger(max.z, p1.z);
4351 Float::replace_if_smaller(min.z, p1.z);
4352 Float::replace_if_larger(max.z, p2.z);
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);
4361 bool LineIntersecting (Point_3D<F>
const & start, Vector_3D<F>
const & direction,
bool is_ray)
const;
4364 typedef Cuboid_3D<float> SimpleCuboid;
4365 typedef Cuboid_3D<double> DSimpleCuboid;
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);
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);
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);
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);
4394 template <
typename F>
4395 struct HPS_TEMPLATE_API Sphere_3D {
4399 Sphere_3D () : center(Point_3D<F>(0, 0, 0)), radius(-1) {}
4401 template <
typename D>
4402 explicit Sphere_3D (Sphere_3D<D>
const & that) : center(Point_3D<F>(that.center)), radius(F(that.radius)) {}
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)
4408 center = Midpoint(cuboid.min, cuboid.max);
4409 radius = F(0.5 * cuboid.Diagonal().Length());
4413 Sphere_3D (Point_3D<F>
const & starting_center, F in_radius = 0) : center(starting_center), radius(in_radius) {}
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);
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);
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);
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);
4439 HPS_INLINE
bool IsValid()
const {
4443 static HPS_INLINE Sphere_3D Invalid() {
return Sphere_3D(Point_3D<F>(0,0,0), -1);};
4445 void Invalidate() {radius = -1;}
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); }
4450 HPS_INLINE F Volume ()
const {
return F((4.0 / 3.0 * PI) * radius * radius * radius); }
4452 HPS_INLINE
void Merge(Point_3D<F>
const & point) {
4453 Vector_3D<F> dir = point - center;
4454 F distance = (F)dir.Length();
4456 if (distance > radius) {
4457 F t = F(0.5) * (distance - radius);
4458 center += t * dir.Normalize();
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();
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());
4474 radius_squared = radius * radius;
4481 HPS_INLINE
void Merge (Sphere_3D
const & sphere) {
4482 Vector_3D<F> dir = sphere.center - center;
4483 F distance = (F)dir.Length();
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();
4492 center = sphere.center;
4493 radius = sphere.radius;
4498 HPS_INLINE
void Merge (Cuboid_3D<F>
const & cuboid) { Merge (Sphere_3D (cuboid)); }
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();
4509 radius = (F)sqrt(rsq);
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();
4520 radius = (F)sqrt(rsq);
4524 typedef Sphere_3D<float> SimpleSphere;
4525 typedef Sphere_3D<double> DSimpleSphere;
4528 template <
typename F>
4530 if (sphere.radius < 0)
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);
4553 HPS_INLINE
RGBColor (
float r,
float g,
float b) : red (r), green (g), blue (b) {}
4555 explicit HPS_INLINE
RGBColor (
float gray) : red (gray), green (gray), blue (gray) {}
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;
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); }
4570 HPS_INLINE
bool Equals(
RGBColor const & c,
int in_tolerance = 32)
const 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); }
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); }
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;
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);
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); }
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) {}
4619 HPS_INLINE RGBAColor (RGBColor
const & c) {
4620 memcpy(
this, &c,
sizeof(RGBColor));
4622 Float::apply_sign_bit(alpha, Float::extract_sign_bit(c.red) | Float::extract_sign_bit(c.green) | Float::extract_sign_bit(c.blue));
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));
4629 explicit HPS_INLINE RGBAColor (RGBA32Color
const & c32);
4630 explicit HPS_INLINE RGBAColor (RGBAS32Color
const & c32);
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;
4644 HPS_INLINE
bool operator== (
RGBAColor const & c)
const {
return red == c.red && green == c.green && blue == c.blue && alpha == c.alpha; }
4652 HPS_INLINE
bool operator!= (
RGBAColor const & c)
const {
return !(*
this == c); }
4654 HPS_INLINE
bool Equals(
RGBAColor const & c,
int in_tolerance = 32)
const {
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); }
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); }
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); }
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);};
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); }
4703 HPS_INLINE
static Order Preferred_Order () {
return Order_BGRA;}
4704 unsigned char b, g, r, a;
4708 HPS_INLINE
static Order Preferred_Order () {
return Order_RGBA;}
4709 unsigned char r, g, b, a;
4713 HPS_INLINE
static Order Preferred_Order () {
return Order_RGBA;}
4714 unsigned char r, g, b, a;
4724 explicit HPS_INLINE
RGBAS32Color (
unsigned char gray,
unsigned char aa = 255) {
4730 HPS_INLINE
RGBAS32Color (
unsigned char rr,
unsigned char gg,
unsigned char bb,
unsigned char aa = 255) {
4740 r = Float::unit_to_byte(c.red);
4741 g = Float::unit_to_byte(c.green);
4742 b = Float::unit_to_byte(c.blue);
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);
4759 r = Float::unit_to_byte(c.red);
4760 g = Float::unit_to_byte(c.green);
4761 b = Float::unit_to_byte(c.blue);
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);
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);
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); }
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); }
4790 static HPS_INLINE
unsigned char Opaque_Alpha () {
return 0xFF;}
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) {}
4806 : r (c32.r), g (c32.g), b (c32.b), a (c32.a) {}
4808 r = Float::unit_to_byte(c.red);
4809 g = Float::unit_to_byte(c.green);
4810 b = Float::unit_to_byte(c.blue);
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);
4820 r = Float::unit_to_byte(c.red);
4821 g = Float::unit_to_byte(c.green);
4822 b = Float::unit_to_byte(c.blue);
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);
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);
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); }
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); }
4847 static HPS_INLINE
unsigned char Opaque_Alpha () {
return 0xFF;}
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) {}
4864 r = Float::unit_to_byte(c.red);
4865 g = Float::unit_to_byte(c.green);
4866 b = Float::unit_to_byte(c.blue);
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); }
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); }
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);
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);
4888 HPS_INLINE RGBColor::RGBColor (RGBAColor
const & c) {
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);
4900 HPS_INLINE RGBAS32Color::RGBAS32Color (RGB24Color
const & c)
4908 HPS_INLINE RGBAS32Color::RGBAS32Color (RGBA32Color
const & c)
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);
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);
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);
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);
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);
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));
4952 HPS_INLINE RGBA32Color Interpolate(RGBA32Color
const & a, RGBA32Color
const & b,
float t) {
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));
4960 HPS_INLINE RGB24Color Interpolate(RGB24Color
const & a, RGB24Color
const & b,
float t) {
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));
4976 Quaternion() : w(0.0f), x(0.0f), y(0.0f), z(0.0f) { }
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) { }
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);
5002 Quaternion operator* (
float in_right)
const {
5003 return Quaternion(w*in_right, x*in_right, y*in_right, z*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);
5010 Quaternion operator/ (
float in_right)
const {
5011 return Quaternion(w/in_right, x/in_right, y/in_right, z/in_right);
5015 return Quaternion(w-in_right.w, x-in_right.x, y-in_right.y, z-in_right.z);
5019 return Quaternion(w+in_right.w, x+in_right.x, y+in_right.y, z+in_right.z);
5022 inline float Norm()
const {
5023 return static_cast<float>(sqrt(w*w + x*x + y*y + z*z));
5029 float mag_q = Norm();
5030 float mag_V =
static_cast<float>(sqrt(x*x + y*y + z*z));
5032 ret.w =
static_cast<float>(log(mag_q));
5035 float scale =
static_cast<float>(acos(w / mag_q) / mag_V);
5042 ret.x = ret.y = ret.z = 0;
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;
5053 ret.w = ea * cos(mag_V);
5062 Quaternion ret = *
this + in_fraction * (in_right - *
this);
5063 return ret.Normalize();
5067 Quaternion Slerp(
Quaternion const & in_right,
float in_fraction,
bool in_shortest_path_only =
true)
const {
5069 float dot = x*in_right.x + y*in_right.y + z*in_right.z + w*in_right.w;
5071 if (in_shortest_path_only && dot < 0) {
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)));
5084 return (*
this * sinaomt + q3 * sinat) / sina;
5087 return Lerp(q3, in_fraction);
5100 Quaternion q1 = Slerp(in_right , in_fraction,
false);
5101 Quaternion q2 = in_control1.Slerp(in_control2, in_fraction,
false);
5103 return q1.Slerp(q2, 2*in_fraction*(1-in_fraction),
false);
5115 return *
this *
Quaternion(((qni*in_previous).Log() + (qni*in_next).Log()) / -4).Exp();
5163 typedef unsigned char byte;
5164 typedef signed char sbyte;
5165 typedef intptr_t WindowHandle;
5166 typedef int64_t TouchID;
5167 typedef intptr_t PlatformData;
5168 typedef intptr_t OpaqueHandle;
5201 class AttributesControl;
5219 class GeometryInsertControl;
5318 class ShaderDefinition;
5323 #if TARGET_OS_ANDROID == 0 && !defined(__APPLE__) 5366 class FontInfoControl;
5439 enum class Type : uint32_t
5442 GenericMask = 0xffffff00,
5446 EventDispatcher = 0x00000003,
5447 EventHandler = 0x00000004,
5448 EventNotifier = 0x00000005,
5449 UpdateNotifier = 0x00000006,
5450 SearchResults = 0x00000008,
5451 FontSearchResults = 0x00000009,
5452 SelectionResults = 0x0000000a,
5453 SelectionItem = 0x0000000b,
5454 TreeContext = 0x0000000c,
5455 StreamToolkit = 0x0000000d,
5456 DriverEventHandler = 0x0000000e,
5457 HighlightSearchResults = 0x0000000f,
5458 OptimizeMappingResults = 0x00000010,
5460 IONotifier = 0x04000100,
5461 StreamImportNotifier = 0x04000101,
5462 STLImportNotifier = 0x04000102,
5463 OBJImportNotifier = 0x04000103,
5464 ExchangeImportNotifier = 0x04000104,
5465 SketchupImportNotifier = 0x04000105,
5466 ParasolidImportNotifier = 0x04000106,
5467 ExchangeTranslationNotifier = 0x04000107,
5468 ExchangeExportNotifier = 0x04000108,
5469 StreamExportNotifier = 0x04000109,
5470 ExchangeReloadNotifier = 0x0400010a,
5471 DWGImportNotifier = 0x0400010b,
5472 ExchangeParasolidImportNotifier = 0x0400010c,
5473 PointCloudImportNotifier = 0x0400010d,
5474 OOCImportNotifier = 0x0400010e,
5475 OBJExportNotifier = 0x0400010f,
5476 HCAImportNotifier = 0x04000110,
5478 SearchResultsIterator = 0x01000001,
5479 FontSearchResultsIterator = 0x01000002,
5480 SelectionResultsIterator = 0x01000003,
5481 HighlightSearchResultsIterator = 0x01000004,
5482 OptimizeMappingResultsIterator = 0x01000005,
5485 MarkerKit = 0x01000010,
5486 SphereAttributeKit = 0x01000011,
5487 TextAttributeKit = 0x01000012,
5488 TransparencyKit = 0x01000013,
5489 VisibilityKit = 0x01000014,
5490 VisualEffectsKit = 0x01000015,
5491 CuttingSectionAttributeKit = 0x01000016,
5492 CircleKit = 0x01000017,
5493 CircularArcKit = 0x01000018,
5494 CircularWedgeKit = 0x01000019,
5495 CuttingSectionKit = 0x0100001a,
5496 CylinderKit = 0x0100001b,
5497 DistantLightKit = 0x0100001c,
5498 EllipseKit = 0x0100001d,
5499 EllipticalArcKit = 0x0100001e,
5500 InfiniteLineKit = 0x0100001f,
5501 LineKit = 0x01000020,
5502 NURBSCurveKit = 0x01000021,
5503 MeshKit = 0x01000022,
5504 NURBSSurfaceKit = 0x01000023,
5505 PolygonKit = 0x01000024,
5506 SphereKit = 0x01000025,
5507 SpotlightKit = 0x01000026,
5508 ShellKit = 0x01000027,
5509 TextKit = 0x01000028,
5510 MaterialKit = 0x01000029,
5511 TrimKit = 0x0100002a,
5512 TextureOptionsKit = 0x0100002c,
5513 LinePatternKit = 0x0100002d,
5514 GlyphKit = 0x0100002e,
5515 ImageKit = 0x0100002f,
5516 LinePatternOptionsKit = 0x01000030,
5517 CameraKit = 0x01000031,
5518 BoundingKit = 0x01000032,
5519 CullingKit = 0x01000033,
5520 CurveAttributeKit = 0x01000034,
5521 CylinderAttributeKit = 0x01000035,
5522 EdgeAttributeKit = 0x01000036,
5523 LightingAttributeKit = 0x01000037,
5524 LineAttributeKit = 0x01000038,
5525 MarkerAttributeKit = 0x01000039,
5526 MaterialMappingKit = 0x0100003a,
5528 NURBSSurfaceAttributeKit = 0x0100003c,
5529 PostProcessEffectsKit = 0x0100003d,
5530 SelectabilityKit = 0x0100003e,
5531 SelectionOptionsKit = 0x0100003f,
5532 StandAloneWindowOptionsKit = 0x01000040,
5533 OffScreenWindowOptionsKit = 0x01000041,
5534 ApplicationWindowOptionsKit = 0x01000042,
5535 HighlightOptionsKit = 0x01000043,
5536 LinePatternParallelKit = 0x01000044,
5537 SubwindowKit = 0x01000045,
5538 PerformanceKit = 0x01000046,
5539 HiddenLineAttributeKit = 0x01000047,
5540 DrawingAttributeKit = 0x01000048,
5541 ShaderKit = 0x01000049,
5542 DebuggingKit = 0x0100004a,
5543 ContourLineKit = 0x0100004b,
5544 StreamImportOptionsKit = 0x0100004c,
5545 StreamImportResultsKit = 0x0100004d,
5546 StreamExportOptionsKit = 0x0100004e,
5547 StreamExportResultsKit = 0x0100004f,
5548 WindowInfoKit = 0x01000050,
5549 ImageImportOptionsKit = 0x01000051,
5550 SearchOptionsKit = 0x01000052,
5551 ShaderImportOptionsKit = 0x01000053,
5552 HardcopyExportOptionsKit = 0x01000055,
5553 HardcopyGDIExportOptionsKit = 0x01001055,
5554 AttributeLockKit = 0x01000056,
5555 TransformMaskKit = 0x01000057,
5556 ColorInterpolationKit = 0x01000058,
5557 UpdateOptionsKit = 0x01000059,
5558 ImageExportOptionsKit = 0x0100005a,
5559 OBJImportOptionsKit = 0x0100005b,
5560 OBJImportResultsKit = 0x0100005c,
5561 STLImportOptionsKit = 0x0100005d,
5562 STLImportResultsKit = 0x0100005e,
5563 ShellOptimizationOptionsKit = 0x0100005f,
5564 ShellRelationOptionsKit = 0x01000060,
5565 ShellRelationResultsKit = 0x01000061,
5566 GridKit = 0x01000062,
5567 CutGeometryGatheringOptionsKit = 0x01000063,
5568 SegmentOptimizationOptionsKit = 0x01000064,
5569 PointCloudImportOptionsKit = 0x01000065,
5570 PointCloudImportResultsKit = 0x01000066,
5571 ShapeKit = 0x01000067,
5572 HighlightSearchOptionsKit = 0x01000068,
5573 PBRMaterialKit = 0x01000069,
5575 LinePatternElement = 0x03000000,
5576 SolidLinePatternElement = 0x03000001,
5577 BlankLinePatternElement = 0x03000002,
5578 GlyphLinePatternElement = 0x03000003,
5580 GlyphElement = 0x05000000,
5581 DotGlyphElement = 0x05000001,
5582 LineGlyphElement = 0x05000002,
5583 EllipseGlyphElement = 0x05000003,
5584 CircularArcGlyphElement = 0x05000004,
5585 InfiniteLineGlyphElement = 0x05000005,
5586 SphereGlyphElement = 0x05000006,
5587 ImageGlyphElement = 0x05000007,
5589 TrimElement = 0x07000000,
5591 ConditionalExpression = 0x09000000,
5592 NOTCondition = 0x09000001,
5593 ANDCondition = 0x09000002,
5594 ORCondition = 0x09000003,
5595 XORCondition = 0x09000004,
5596 EQCondition = 0x09000005,
5597 NEQCondition = 0x09000006,
5598 GTCondition = 0x09000007,
5599 LTCondition = 0x09000008,
5600 GTEQCondition = 0x09000009,
5601 LTEQCondition = 0x0900000A,
5603 ShapeElement = 0x0B000000,
5604 PolygonShapeElement = 0x0B000001,
5605 EllipseShapeElement = 0x0B000002,
5606 CircleShapeElement = 0x0B000003,
5607 EllipticalArcShapeElement = 0x0B000004,
5608 AnchorShapeElement = 0x0B000005,
5609 LineShapeElement = 0x0B000006,
5610 CircularArcShapeElement = 0x0B000007,
5611 LeaderLineClippingElement = 0x0B000008,
5613 MouseState = 0x01001001,
5614 TouchState = 0x01001002,
5615 KeyboardState = 0x01001003,
5616 FontInfoState = 0x01001004,
5617 HighlightState = 0x01001005,
5619 KeyPath = 0x01000F01,
5622 IncludeKey = 0x10000001,
5623 PortfolioKey = 0x10000002,
5624 StyleKey = 0x10000003,
5626 SegmentKey = 0x10200000,
5627 WindowKey = 0x10600000,
5628 StandAloneWindowKey = 0x10600001,
5629 OffScreenWindowKey = 0x10600002,
5630 ApplicationWindowKey = 0x10600003,
5632 GeometryKey = 0x10100000,
5633 ReferenceKey = 0x10100001,
5634 CircleKey = 0x10100002,
5635 CircularArcKey = 0x10100003,
5636 CircularWedgeKey = 0x10100004,
5637 CuttingSectionKey = 0x10100005,
5638 CylinderKey = 0x10100006,
5639 EllipseKey = 0x10100007,
5640 EllipticalArcKey = 0x10100008,
5641 InfiniteLineKey = 0x10100009,
5642 LineKey = 0x1010000a,
5643 DistantLightKey = 0x1010000b,
5644 SpotlightKey = 0x1010000c,
5645 MarkerKey = 0x1010000d,
5646 MeshKey = 0x1010000e,
5647 NURBSCurveKey = 0x1010000f,
5648 NURBSSurfaceKey = 0x10100010,
5649 PolygonKey = 0x10100011,
5650 ShellKey = 0x10100012,
5651 SphereKey = 0x10100013,
5652 TextKey = 0x10100014,
5653 GridKey = 0x10100015,
5655 Definition = 0x20000000,
5656 NamedStyleDefinition = 0x20000001,
5657 TextureDefinition = 0x20000002,
5658 LinePatternDefinition = 0x20000003,
5659 GlyphDefinition = 0x20000004,
5660 CubeMapDefinition = 0x20000005,
5661 ImageDefinition = 0x20000006,
5662 MaterialPaletteDefinition = 0x20000007,
5663 ShaderDefinition = 0x20000008,
5664 ShapeDefinition = 0x20000009,
5666 Control = 0x50000000,
5667 CameraControl = 0x50000001,
5668 SelectabilityControl = 0x50000002,
5669 MarkerAttributeControl = 0x50000003,
5670 SphereAttributeControl = 0x50000004,
5671 LightingAttributeControl = 0x50000005,
5672 CylinderAttributeControl = 0x50000006,
5673 TextAttributeControl = 0x50000007,
5674 LineAttributeControl = 0x50000008,
5675 EdgeAttributeControl = 0x50000009,
5676 CurveAttributeControl = 0x5000000a,
5677 ModellingMatrixControl = 0x5000000b,
5678 TextureMatrixControl = 0x5000000c,
5679 CullingControl = 0x5000000d,
5680 TransparencyControl = 0x5000000e,
5681 MaterialMappingControl = 0x5000000f,
5682 NURBSSurfaceAttributeControl = 0x50000010,
5683 PostProcessEffectsControl = 0x50000011,
5684 BoundingControl = 0x50000012,
5685 VisualEffectsControl = 0x50000013,
5686 SelectionOptionsControl = 0x50000014,
5687 HighlightOptionsControl = 0x50000015,
5688 DefinitionControl = 0x50000016,
5689 SelectionControl = 0x50000017,
5690 HighlightControl = 0x50000018,
5691 StandAloneWindowOptionsControl = 0x50600019,
5692 OffScreenWindowOptionsControl = 0x5060001a,
5693 ApplicationWindowOptionsControl = 0x5060001b,
5694 VisibilityControl = 0x5000001c,
5695 SubwindowControl = 0x5000001d,
5696 PerformanceControl = 0x5000001e,
5697 HiddenLineAttributeControl = 0x5000001f,
5698 DrawingAttributeControl = 0x50000020,
5699 DebuggingControl = 0x50000021,
5700 ContourLineControl = 0x50000022,
5701 StyleControl = 0x50000023,
5702 ConditionControl = 0x50000024,
5703 PortfolioControl = 0x50000025,
5704 WindowInfoControl = 0x50000026,
5705 AttributeLockControl = 0x50000027,
5706 TransformMaskControl = 0x50000028,
5707 ColorInterpolationControl = 0x50000029,
5708 UpdateOptionsControl = 0x50600030,
5709 CuttingSectionAttributeControl = 0x50000031,
5711 LibraryMask = 0x80FF0000,
5713 Sprocket = 0x80000000,
5714 Canvas = 0x80000001,
5715 Layout = 0x80000002,
5718 Operator = 0x80000005,
5719 SprocketPath = 0x80000007,
5721 SprocketControl = 0xD0000000,
5722 OperatorControl = 0xD0000008,
5723 NavigationCubeControl = 0xD0000009,
5724 AxisTriadControl = 0xD000000A,
5726 SprocketKit = 0x81000000,
5728 Metadata = 0x80001000,
5729 IntegerMetadata = 0x80001001,
5730 UnsignedIntegerMetadata = 0x80001002,
5731 DoubleMetadata = 0x80001003,
5732 StringMetadata = 0x80001004,
5733 TimeMetadata = 0x80001005,
5734 BooleanMetadata = 0x80001006,
5736 Component = 0x80000200,
5737 Filter = 0x80000600,
5738 Capture = 0x80000a00,
5739 CADModel = 0x80000300,
5740 ComponentPath = 0x81001000,
5742 ExchangeMask = 0x80020000,
5743 ExchangeComponent = 0x80021200,
5744 ExchangeSheet = 0x80021201,
5745 ExchangeProductOccurrence = 0x80021202,
5746 ExchangeFilter = 0x80020601,
5747 ExchangeCapture = 0x80020a01,
5748 ExchangeCADModel = 0x80020301,
5749 ExchangeConfiguration = 0x81020001,
5750 ExchangeImportOptionsKit = 0x81020002,
5751 ExchangeExportACISOptionsKit = 0x81020003,
5752 ExchangeExportIGESOptionsKit = 0x81020004,
5753 ExchangeExportJTOptionsKit = 0x81020005,
5754 ExchangeExportParasolidOptionsKit = 0x81020006,
5755 ExchangeExportPRCOptionsKit = 0x81020007,
5756 ExchangeExportSTEPOptionsKit = 0x81020008,
5757 ExchangeExportSTLOptionsKit = 0x81020009,
5758 ExchangeExportU3DOptionsKit = 0x8102000a,
5759 ExchangeExportXMLOptionsKit = 0x8102000b,
5760 ExchangeTessellationOptionsKit = 0x8102000c,
5761 ExchangeModelFileImportOptionsKit = 0x8102000d,
5762 ExchangeTranslationOptionsKit = 0x8102000e,
5763 ExchangeNURBSConversionOptionsKit = 0x8102000f,
5764 ExchangeExport3MFOptionsKit = 0x81020010,
5765 ExchangeExportFBXOptionsKit = 0x81020011,
5766 ExchangeExportOBJOptionsKit = 0x81020012,
5768 PublishMask = 0x80040000,
5769 PublishDocumentKit = 0x81040001,
5770 PublishPageKit = 0x81040002,
5771 PublishTemplateKit = 0x81040003,
5772 PublishAnnotationKit = 0x81040004,
5773 PublishArtworkKit = 0x81040005,
5774 PublishViewKit = 0x81040006,
5775 PublishTextKit = 0x81040007,
5776 PublishImageKit = 0x81040008,
5777 PublishTableKit = 0x81040009,
5778 PublishExportOptionsKit = 0x8104000a,
5779 PublishLinkKit = 0x8104000b,
5780 PublishButtonKit = 0x8104000c,
5781 PublishTextFieldKit = 0x8104000d,
5782 PublishSlideTableKit = 0x8104000e,
5783 PublishCheckBoxKit = 0x8104000f,
5784 PublishRadioButtonKit = 0x81040010,
5785 PublishListBoxKit = 0x81040011,
5786 PublishDropDownListKit = 0x81040012,
5787 PublishSignatureFieldKit = 0x81040013,
5789 PublishDocumentKey = 0x80040001,
5790 PublishPageControl = 0x80040002,
5792 ExchangeParasolidMask = 0x80080000,
5794 SceneTree = 0x80008001,
5795 SceneTreeItem = 0x80008002,
5797 ComponentTree = 0x80008003,
5798 ComponentTreeItem = 0x80008004,
5800 SketchupMask = 0x80100000,
5801 SketchupImportOptionsKit = 0x81100001,
5802 SketchupImportResultsKit = 0x81100002,
5804 ParasolidMask = 0x80200000,
5805 ParasolidComponent = 0x80201201,
5806 ParasolidCADModel = 0x80200302,
5807 ParasolidImportOptionsKit = 0x81200003,
5808 ParasolidFacetTessellationKit = 0x81200004,
5809 ParasolidLineTessellationKit = 0x81200005,
5810 ParasolidExportOptionsKit = 0x81200006,
5812 DWGMask = 0x80400000,
5813 DWGComponent = 0x80401201,
5814 DWGLayer = 0x80401202,
5815 DWGLayout = 0x80400a03,
5816 DWGCADModel = 0x80400304,
5817 DWGImportOptionsKit = 0x81400005,
5819 OOCMask = 0x80800000,
5820 OOCImportOptionsKit = 0x81800001,
5821 OOCImportResultsKit = 0x81800002,
5823 HCAMask = 0x80110000,
5824 HCAImportOptionsKit = 0x81110001,
5825 HCAImportResultsKit = 0x81110002,
5826 HCAModel = 0x80110003,
5827 HCAModelTree = 0x80110004,
5828 HCAModelTreeItem = 0x80110005,
5829 HCANetworkImportOptionsKit = 0x81110006,
5831 HTMLMask = 0x80010000,
5834 IONotifierData = 0x84000200,
5835 StreamImportNotifierData = 0x84000201,
5836 STLImportNotifierData = 0x84000202,
5837 OBJImportNotifierData = 0x84000203,
5838 ExchangeImportNotifierData = 0x84020204,
5839 SketchupImportNotifierData = 0x84100205,
5840 ParasolidImportNotifierData = 0x84200206,
5841 ExchangeTranslationNotifierData = 0x84020207,
5842 ExchangeExportNotifierData = 0x84020208,
5843 StreamExportNotifierData = 0x84000209,
5844 DWGImportNotifierData = 0x8440020a,
5845 ExchangeParasolidImportNotifierData = 0x8408020b,
5846 PointCloudImportNotifierData = 0x8400020c,
5847 OOCImportNotifierData = 0x8480020d,
5848 OBJExportNotifierData = 0x8400020e,
5849 HCAImportNotifierData = 0x8411020f,
5862 static void * Allocate(
size_t in_bytes,
bool in_clear_memory =
true);
5869 static void Free(
void * in_pointer);
5878 template <
typename T>
5879 class NO_HPS_API Allocator
5882 typedef T value_type;
5883 typedef value_type * pointer;
5884 typedef value_type
const * const_pointer;
5885 typedef value_type & reference;
5886 typedef value_type
const & const_reference;
5887 typedef size_t size_type;
5888 typedef ptrdiff_t difference_type;
5892 Allocator(Allocator<T>
const & in_that) { HPS_UNREFERENCED(in_that); }
5895 template <
typename U> Allocator(Allocator<U>
const &) {}
5897 template <
typename U>
5900 typedef Allocator<U> other;
5904 pointer address(reference x)
const {
return &x; }
5905 const_pointer address(const_reference x)
const {
return &x; }
5907 pointer allocate(size_type n,
void * v = 0) { HPS_UNREFERENCED(v);
return static_cast<pointer
>(
Memory::Allocate(n *
sizeof(T))); }
5908 void deallocate(pointer p, size_type n) { HPS_UNREFERENCED(n);
Memory::Free(p); }
5910 #if defined(_MSC_VER) || defined (__APPLE__) 5911 void construct(pointer p, const_reference x) {
new(p) T(x); }
5912 void construct(pointer p, value_type && x) {
new(p) T(std::move(x)); }
5914 template<
typename U,
typename... Args>
5915 void construct(U * p, Args&&... args) {
new(p) U(std::forward<Args>(args)...); }
5917 void destroy(pointer p) { HPS_UNREFERENCED(p); p->~T(); }
5919 size_type max_size()
const {
return static_cast<size_type
>(-1) /
sizeof(T); }
5922 template <
typename T,
typename U>
5923 bool operator==(
const Allocator<T> &,
const Allocator<U> &) {
return true; }
5925 template <
typename T,
typename U>
5926 bool operator!=(
const Allocator<T> &,
const Allocator<U> &) {
return false; }
5932 Exception(
char const * in_info) : std::runtime_error(in_info) { }
5940 InvalidObjectException(
char const * in_info =
"Attempted to use a deleted, uninitialized, or otherwise invalid object.") :
5950 IndexOutOfRangeException(
char const * in_info =
"Attempted to access an element outside the bounds of the array.") :
6025 virtual HPS::Type Type()
const;
6028 static const HPS::Type staticType = HPS::Type::None;
6038 virtual bool Empty()
const {
return (impl_ == 0);};
6041 virtual void Reset();
6049 bool HasType(HPS::Type in_mask)
const;
6053 intptr_t GetClassID()
const;
6060 intptr_t GetInstanceID()
const;
6064 template <
typename T>
6067 static const intptr_t ret = T().GetClassID();
6072 friend class HPSI::Impl;
6073 friend class HPSI::KeyImpl;
6074 friend class HPSI::TicketImpl;
6084 virtual HPS::Type
Type()
const {
return ObjectType(); }
6085 static const HPS::Type staticType = HPS::Type::Control;
6088 #if !defined(_MSC_VER) || _MSC_VER >= 1900 6105 this->Object::operator=(std::move(in_that));
6115 static const HPS::Type staticType = HPS::Type::Kit;
6117 virtual HPS::Type
Type()
const {
return ObjectType(); }
6119 #if !defined(_MSC_VER) || _MSC_VER >= 1900 6120 Kit(
Kit const & in_that) =
default;
6136 this->Object::operator=(std::move(in_that));
6450 Event(intptr_t in_channel = 0): channel(in_channel), consumable(true), time_stamp(0) {}
6455 intptr_t GetClassID()
const;
6459 virtual Event * Clone()
const=0;
6462 virtual bool Drop(
Event const * in_that_event)
const { HPS_UNREFERENCED(in_that_event);
return false; }
6477 static void *
operator new (
size_t in_size) {
return Memory::Allocate(in_size); }
6478 static void operator delete (
void * in_ptr,
size_t in_size)
throw () { HPS_UNREFERENCED(in_size);
Memory::Free(in_ptr); }
6485 friend class HPSI::EventDispatcherImpl;
6515 static const HPS::Type staticType = HPS::Type::EventNotifier;
6537 enum class KeyboardCode : uint32_t
6735 : ID(in_id), Location(in_location), TapCount(in_tap_count) {}
6742 return (ID == in_that.
ID && Location == in_that.
Location && TapCount == in_that.
TapCount);
6750 return !(*
this == in_that);
6830 typedef std::vector<Drawing::ClipSpace, Allocator<Drawing::ClipSpace> >
ClipSpaceArray;
6834 typedef std::vector<int64_t, HPS::Allocator<int64_t>>
Int64Array;
6839 typedef std::vector<HPS::Type, Allocator<HPS::Type> >
TypeArray;
6869 ShapeCoordinate(
float in_x,
float in_y,
size_t in_count,
float const in_margins []);
6890 ShapeCoordinate(
float in_x,
float in_y,
float in_radius,
size_t in_count,
float const in_margins []);
6913 ShapeCoordinate & SetMargins(
float in_margin_one,
float in_margin_two = 0.0f,
float in_margin_three = 0.0f,
float in_margin_four = 0.0f);
6918 bool ShowMargins(
FloatArray & out_margins)
const;
6970 typedef std::vector<ShapePoint, Allocator<ShapePoint> > ShapePointArray;
6997 static const HPS::Type staticType = HPS::Type::SearchResultsIterator;
7034 bool IsValid()
const;
7042 Key GetItem()
const;
7046 Key operator*()
const;
7075 virtual void Reset();
7080 static const HPS::Type staticType = HPS::Type::SearchResults;
7095 size_t GetCount()
const;
7134 static const HPS::Type staticType = HPS::Type::FontSearchResultsIterator;
7166 bool IsValid()
const;
7205 virtual void Reset();
7210 static const HPS::Type staticType = HPS::Type::FontSearchResults;
7226 size_t GetCount()
const;
7250 UTF8(
char const * in_string,
char const * in_locale = 0);
7254 UTF8(
wchar_t const * in_string);
7273 return Assign(std::move(in_utf8));
7280 size_t ToWStr(
wchar_t * out_wide_string)
const;
7285 size_t ToWStr(
WCharArray & out_wide_string)
const;
7291 return (_length > 0);
7298 return (_length == 0);
7332 inline operator char const * ()
const 7339 char At(
size_t in_index)
const 7343 else if(in_index >= _length)
7346 return _text[in_index];
7352 UTF8 & Assign(
UTF8 const & in_utf8);
7359 return Assign(in_utf8);
7365 UTF8 & operator+= (
UTF8 const & in_utf8);
7370 UTF8 & operator+= (
char const * in_utf8);
7375 UTF8 operator+ (
UTF8 const & in_utf8)
const;
7380 UTF8 operator+ (
char const * in_utf8)
const;
7385 bool operator== (
UTF8 const & in_utf8)
const;
7390 bool operator!= (
UTF8 const & in_utf8)
const 7392 return !(*
this == in_utf8);
7398 bool operator== (
char const * in_utf8)
const;
7403 bool operator!= (
char const * in_utf8)
const 7405 return !(*
this == in_utf8);
7414 return in_right == in_left;
7423 return in_right != in_left;
7432 return in_right ==
UTF8(in_left);
7441 return in_right !=
UTF8(in_left);
7448 friend inline UTF8 operator+ (
char const * in_left,
UTF8 const & in_right)
7450 return UTF8(in_left,
"utf8") + in_right;
7457 friend inline UTF8 operator+ (
wchar_t const * in_left,
UTF8 const & in_right)
7459 return UTF8(in_left) + in_right;
7465 size_t GetHash()
const;
7467 friend class HPSI::String;
7471 size_t internal_encode(
wchar_t const * in_wide_string);
7472 static size_t internal_decode(
size_t in_length,
const char* in_utf8_string,
wchar_t * out_wide_string);
7473 size_t internal_decode(
wchar_t * out_wide_string)
const;
7477 mutable size_t _hash_key;
7478 static const size_t _buffer_size = 64 -
sizeof(
const char *) - 2 *
sizeof(
size_t);
7479 char _buffer[_buffer_size];
7484 inline size_t operator()(
const HPS::UTF8 & in_utf8)
const 7525 static const HPS::Type staticType = HPS::Type::ConditionalExpression;
7531 bool ShowCondition(
UTF8 & out_condition)
const;
7536 bool ShowNumber(
float & out_number)
const;
7541 bool ShowIntrinsic(Condition::Intrinsic & out_special)
const;
7571 bool IsSatisfiedBy(
UTF8Array const & in_conditions)
const;
7576 bool IsSatisfiedBy(
char const * in_condition)
const;