MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/Imath / testHasVolume

Function testHasVolume

src/ImathTest/testBox.cpp:837–898  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

835
836template <class T>
837void
838testHasVolume (const char* type)
839{
840 cout << " hasVolume() for type " << type << endl;
841
842 //
843 // Empty box.
844 //
845 {
846 IMATH_INTERNAL_NAMESPACE::Box<T> b;
847 assert (!b.hasVolume ());
848 }
849
850 //
851 // Infinite box.
852 //
853 {
854 IMATH_INTERNAL_NAMESPACE::Box<T> b;
855 b.makeInfinite ();
856 assert (b.hasVolume ());
857 }
858
859 //
860 // Non-empty, has-volume box.
861 // 2D: [(-2, -4), ( 8, 2) ]
862 // 3D: [(-2, -4, -6), (12, 8, 2) ]
863 // 4D: [(-2, -4, -6, -8), (16, 12, 8, 4) ]
864 //
865 {
866 IMATH_INTERNAL_NAMESPACE::Box<T> b0 (T (-1), T (1));
867 assert (b0.hasVolume ());
868
869 T p0;
870 T p1;
871 for (unsigned int i = 0; i < T::dimensions (); i++)
872 {
873 int lo = 1 << (i + 1);
874 int hi = 1 << (T::dimensions () - i);
875 p0[i] = -static_cast<typename T::BaseType>(lo);
876 p1[i] = static_cast<typename T::BaseType>(hi);
877 }
878 IMATH_INTERNAL_NAMESPACE::Box<T> b1 (p0, p1);
879 assert (b1.hasVolume ());
880 }
881
882 //
883 // Non-empty, no-volume box.
884 // Boxes are:
885 // 2D: [(0, 0), (0, 2) ]
886 // 3D: [(0, 0, 0), (0, 0, 2) ]
887 // 4D: [(0, 0, 0, 0), (0, 0, 0, 2)]
888 //
889 {
890 T min (0);
891 T max = min;
892 max[T::dimensions () - 1] = 2;
893
894 IMATH_INTERNAL_NAMESPACE::Box<T> b (min, max);

Callers

nothing calls this directly

Calls 3

makeInfiniteMethod · 0.80
TClass · 0.50
dimensionsFunction · 0.50

Tested by

no test coverage detected