![]() |
rtVTK
0.6.0
|
00001 00002 /****************************************************************************** 00003 * Copyright (c) 2012, Grove City College 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are 00008 * met: 00009 * 00010 * * Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 00013 * * Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in 00015 * the documentation and/or other materials provided with the 00016 * distribution. 00017 * 00018 * * Neither the name of Grove City College nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00025 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00026 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 */ 00035 00036 00037 #ifndef RL_rl_h 00038 #define RL_rl_h 00039 00040 #include <iosfwd> 00041 using std::ostream; 00042 00043 #include <vector> 00044 using std::vector; 00045 00046 #include <Core/Types.h> 00047 00048 #include <Math/Math.h> 00049 00050 00051 namespace rl 00052 { 00053 00055 // Using declarations 00056 00057 using MathF::Point; 00058 using MathF::Vector; 00059 00060 00062 // Ray type enumeration 00063 00064 enum RayType 00065 { 00066 InvalidRay = -1, 00067 EyeRay = 0, 00068 ShadowRay, 00069 ReflectionRay, 00070 TransmissionRay, 00071 DiffuseRay, 00072 NRayTypes 00073 }; 00074 00075 istream& operator>>(istream&, RayType&); 00076 ostream& operator<<(ostream&, const RayType&); 00077 00078 bool read(istream&, RayType&); 00079 bool write(ostream&, const RayType&); 00080 00081 00083 // Ray structure 00084 00086 struct Ray 00087 { 00088 Ray(); 00089 Ray(const Ray&); 00090 00091 ~Ray(); 00092 00093 Ray& operator=(const Ray&); 00094 00096 Point origin; 00097 00099 Vector dir; 00100 00102 float tval; 00103 00105 RayType type; 00106 00108 void* data; 00109 00111 size_t nbytes; 00112 00114 uint depth; 00115 00117 uint parent; 00118 00120 uint child; 00121 00123 uint next; 00124 00126 uint prev; 00127 }; 00128 00129 ostream& operator<<(ostream&, const Ray& ); 00130 00131 00133 // Ray tree structure 00134 00136 struct Tree 00137 { 00139 uint px; 00140 00142 uint py; 00143 00145 Point origin; 00146 00148 00149 vector<Ray> rays; 00150 00152 size_t record_offset; 00153 }; 00154 00155 ostream& operator<<(ostream&, const Tree&); 00156 00157 00159 // rl Error enumeration 00160 00162 enum Error 00163 { 00164 00166 // Success 00167 00168 NoError = 0, 00169 00170 00172 // Initialization errors 00173 00174 Init_NoRLClose = 100, 00175 Init_InvalidFName, 00176 Init_FileOpenFailed, 00177 Init_InvalidFile, 00178 Init_NoTrees, 00179 00181 // Next ray errors 00182 00183 NextRay_InvalidState = 200, 00184 NextRay_InvalidMode, 00185 NextRay_InvalidContext, 00186 NextRay_NoTrees, 00187 NextRay_InvalidTree, 00188 NextRay_TreeEnded, 00189 NextRay_EmptyTree, 00190 NextRay_NoMoreRays, 00191 00192 00194 // Descend tree errors 00195 00196 DescendTree_InvalidState = 300, 00197 DescendTree_InvalidMode, 00198 DescendTree_InvalidContext, 00199 DescendTree_NoTrees, 00200 DescendTree_InvalidTree, 00201 DescendTree_TreeEnded, 00202 DescendTree_EmptyTree, 00203 DescendTree_NoChild, 00204 00206 // Ascend tree errors 00207 00208 AscendTree_InvalidState = 400, 00209 AscendTree_InvalidMode, 00210 AscendTree_InvalidContext, 00211 AscendTree_NoTrees, 00212 AscendTree_InvalidTree, 00213 AscendTree_TreeEnded, 00214 AscendTree_EmptyTree, 00215 AscendTree_TopLevel, 00216 00218 // Next tree errors 00219 00220 NextTree_InvalidMode = 500, 00221 NextTree_InvalidContext, 00222 NextTree_NoMoreTrees, 00223 00224 00226 // Previous tree errors 00227 00228 PrevTree_InvalidMode = 600, 00229 PrevTree_NoMoreTrees, 00230 00231 00233 // Read tree errors 00234 00235 ReadTree_InvalidMode = 700, 00236 ReadTree_InvalidContext, 00237 ReadTree_Uninitialized, 00238 00239 00241 // Read rays errors 00242 00243 ReadRays_InvalidMode = 800, 00244 ReadRays_Uninitialized, 00245 00246 00248 // Populate tree errors 00249 00250 PopulateTree_InvalidMode = 900, 00251 PopulateTree_InvalidContext, 00252 PopulateTree_Uninitialized, 00253 00254 00256 // Read ray errors 00257 00258 ReadRay_InvalidMode = 1000, 00259 ReadRay_InvalidContext, 00260 ReadRay_Uninitialized, 00261 ReadRay_NoMoreRays, 00262 00263 00265 // Start rays errors 00266 00267 StartRays_InvalidMode = 1100, 00268 StartRays_InvalidContext, 00269 StartRays_Uninitialized, 00270 00271 00273 // Begin forest errors 00274 00275 BeginForest_InvalidMode = 1200, 00276 BeginForest_NoEndForest, 00277 00278 00280 // End forest errors 00281 00282 EndForest_InvalidMode = 1300, 00283 EndForest_NoBeginForest, 00284 EndForest_OpenTrees, 00285 00286 00288 // Begin tree errors 00289 00290 BeginTree_InvalidMode = 1400, 00291 BeginTree_InvalidContext, 00292 00293 00295 // End tree errors 00296 00297 EndTree_InvalidMode = 1500, 00298 EndTree_InvalidContext, 00299 EndTree_NoTrees, 00300 EndTree_InvalidTree, 00301 EndTree_AlreadyEnded, 00302 00303 00305 // Add ray errors 00306 00307 AddRay_InvalidMode = 1600, 00308 AddRay_InvalidContext, 00309 AddRay_NoTrees, 00310 AddRay_InvalidTree, 00311 AddRay_TreeEnded, 00312 AddRay_OneHeadRay 00313 00314 }; 00315 00316 } // namespace rl 00317 00318 #endif // RL_rl_h