OptiX  3.9
NVIDIA OptiX Acceleration Engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
optixu_math_stream_namespace.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (c) 2008 - 2010 NVIDIA Corporation. All rights reserved.
4  *
5  * NVIDIA Corporation and its licensors retain all intellectual property and proprietary
6  * rights in and to this software, related documentation and any modifications thereto.
7  * Any use, reproduction, disclosure or distribution of this software and related
8  * documentation without an express license agreement from NVIDIA Corporation is strictly
9  * prohibited.
10  *
11  * TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS*
12  * AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED,
13  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
14  * PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY
15  * SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT
16  * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF
17  * BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
18  * INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF
19  * SUCH DAMAGES
20  */
21 
30 #ifndef __optixu_optixu_math_stream_namespace_h__
31 #define __optixu_optixu_math_stream_namespace_h__
32 
33 #include "optixu_math_namespace.h"
35 #include "optixu_aabb_namespace.h"
36 
37 #include <iostream>
38 
39 namespace optix {
40 
45  inline std::ostream& operator<<(std::ostream& os, const optix::float4& v) { os << '[' << v.x << ", " << v.y << ", " << v.z << ", " << v.w << ']'; return os; }
46  inline std::istream& operator>>(std::istream& is, optix::float4& v) { char st; is >> st >> v.x >> st >> v.y >> st >> v.z >> st >> v.w >> st; return is; }
47  inline std::ostream& operator<<(std::ostream& os, const optix::float3& v) { os << '[' << v.x << ", " << v.y << ", " << v.z << ']'; return os; }
48  inline std::istream& operator>>(std::istream& is, optix::float3& v) { char st; is >> st >> v.x >> st >> v.y >> st >> v.z >> st; return is; }
49  inline std::ostream& operator<<(std::ostream& os, const optix::float2& v) { os << '[' << v.x << ", " << v.y << ']'; return os; }
50  inline std::istream& operator>>(std::istream& is, optix::float2& v) { char st; is >> st >> v.x >> st >> v.y >> st; return is; }
57  inline std::ostream& operator<<(std::ostream& os, const optix::int4& v) { os << '[' << v.x << ", " << v.y << ", " << v.z << ", " << v.w << ']'; return os; }
58  inline std::istream& operator>>(std::istream& is, optix::int4& v) { char st; is >> st >> v.x >> st >> v.y >> st >> v.z >> st >> v.w >> st; return is; }
59  inline std::ostream& operator<<(std::ostream& os, const optix::int3& v) { os << '[' << v.x << ", " << v.y << ", " << v.z << ']'; return os; }
60  inline std::istream& operator>>(std::istream& is, optix::int3& v) { char st; is >> st >> v.x >> st >> v.y >> st >> v.z >> st; return is; }
61  inline std::ostream& operator<<(std::ostream& os, const optix::int2& v) { os << '[' << v.x << ", " << v.y << ']'; return os; }
62  inline std::istream& operator>>(std::istream& is, optix::int2& v) { char st; is >> st >> v.x >> st >> v.y >> st; return is; }
69  inline std::ostream& operator<<(std::ostream& os, const optix::uint4& v) { os << '[' << v.x << ", " << v.y << ", " << v.z << ", " << v.w << ']'; return os; }
70  inline std::istream& operator>>(std::istream& is, optix::uint4& v) { char st; is >> st >> v.x >> st >> v.y >> st >> v.z >> st >> v.w >> st; return is; }
71  inline std::ostream& operator<<(std::ostream& os, const optix::uint3& v) { os << '[' << v.x << ", " << v.y << ", " << v.z << ']'; return os; }
72  inline std::istream& operator>>(std::istream& is, optix::uint3& v) { char st; is >> st >> v.x >> st >> v.y >> st >> v.z >> st; return is; }
73  inline std::ostream& operator<<(std::ostream& os, const optix::uint2& v) { os << '[' << v.x << ", " << v.y << ']'; return os; }
74  inline std::istream& operator>>(std::istream& is, optix::uint2& v) { char st; is >> st >> v.x >> st >> v.y >> st; return is; }
80  inline std::ostream& operator<<( std::ostream& os, const optix::Aabb& aabb )
81  { os << aabb[0] << " | " << aabb[1]; return os; }
82 
87  template<unsigned int M, unsigned int N>
88  inline std::ostream& operator<<( std::ostream& os, const optix::Matrix<M,N>& m )
89  {
90  os << '[';
91  for (unsigned int i = 0; i < N; ++i) {
92  os << '[';
93  for (unsigned int j = 0; j < M; ++j) {
94  os << m[i*N+j];
95  if(j < M-1) os << ", ";
96  }
97  os << ']';
98  }
99  os << ']';
100  return os;
101  }
102 
103  template<unsigned int M, unsigned int N>
104  inline std::istream& operator>>( std::istream& is, optix::Matrix<M,N>& m )
105  {
106  char st;
107  is >> st;
108  for (unsigned int i = 0; i < N; ++i) {
109  is >> st;
110  for (unsigned int j = 0; j < M; ++j) {
111  is >> m[i*N+j];
112  if(j < M-1) is >> st;
113  }
114  is >> st;
115  }
116  is >> st;
117  return is;
118  }
120 }
121 
122 /*
123  * When looking for operators for a type, only the scope the type is defined in (plus the
124  * global scope) is searched. In order to make the operators behave properly we are
125  * pulling them into the global namespace.
126  */
127 #if defined(RT_PULL_IN_VECTOR_TYPES)
128 namespace {
129  using optix::operator<<;
130  using optix::operator>>;
131 }
132 #endif
133 
134 #endif // #ifndef __optixu_optixu_math_stream_namespace_h__
135 
Axis-aligned bounding box.
Definition: optixu_aabb_namespace.h:73
OptiX public API.
A matrix with M rows and N columns.
Definition: optixu_matrix_namespace.h:54
OptiX public API.
OptiX public API.