0029520: Visualization - drop deprecated V3d_View::Export() functionality and depende...
[occt.git] / src / OpenGl / OpenGl_Workspace.cxx
CommitLineData
b311480e 1// Created on: 2011-09-20
2// Created by: Sergey ZERCHANINOV
973c2be1 3// Copyright (c) 2011-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
c357e426 16#include <OpenGl_Workspace.hxx>
5f8b738e 17
c357e426 18#include <OpenGl_ArbFBO.hxx>
2166f0fa
SK
19#include <OpenGl_AspectLine.hxx>
20#include <OpenGl_AspectFace.hxx>
21#include <OpenGl_AspectMarker.hxx>
22#include <OpenGl_AspectText.hxx>
bf75be98 23#include <OpenGl_Context.hxx>
679ecdee 24#include <OpenGl_Element.hxx>
a174a3c5 25#include <OpenGl_FrameBuffer.hxx>
c357e426 26#include <OpenGl_GlCore15.hxx>
27#include <OpenGl_SceneGeometry.hxx>
679ecdee 28#include <OpenGl_Structure.hxx>
25ef750e 29#include <OpenGl_Sampler.hxx>
8613985b 30#include <OpenGl_ShaderManager.hxx>
bf75be98 31#include <OpenGl_Texture.hxx>
e276548b 32#include <OpenGl_View.hxx>
c357e426 33#include <OpenGl_Window.hxx>
2166f0fa 34
bf75be98 35#include <Graphic3d_TextureParams.hxx>
825aa485 36#include <Graphic3d_TransformUtils.hxx>
f9f740d6 37#include <NCollection_AlignedAllocator.hxx>
2166f0fa 38
92efcf78 39IMPLEMENT_STANDARD_RTTIEXT(OpenGl_Workspace,Standard_Transient)
40IMPLEMENT_STANDARD_RTTIEXT(OpenGl_RaytraceFilter,OpenGl_RenderFilter)
41
2166f0fa
SK
42namespace
43{
b6472664 44 static const OpenGl_Vec4 THE_WHITE_COLOR (1.0f, 1.0f, 1.0f, 1.0f);
45 static const OpenGl_Vec4 THE_BLACK_COLOR (0.0f, 0.0f, 0.0f, 1.0f);
2166f0fa
SK
46
47 static const OpenGl_AspectLine myDefaultAspectLine;
48 static const OpenGl_AspectFace myDefaultAspectFace;
49 static const OpenGl_AspectMarker myDefaultAspectMarker;
2831708b 50 static const OpenGl_AspectText myDefaultAspectText;
2166f0fa 51
2166f0fa
SK
52 static const OpenGl_Matrix myDefaultMatrix =
53 {
54 {{ 1.0F, 0.0F, 0.0F, 0.0F },
55 { 0.0F, 1.0F, 0.0F, 0.0F },
56 { 0.0F, 0.0F, 1.0F, 0.0F },
57 { 0.0F, 0.0F, 0.0F, 1.0F }}
58 };
bf75be98 59
a3f6f591 60}
2166f0fa
SK
61
62// =======================================================================
0adbd30f 63// function : Init
64// purpose :
65// =======================================================================
b6472664 66void OpenGl_Material::Init (const Graphic3d_MaterialAspect& theMat,
67 const Quantity_Color& theInteriorColor)
0adbd30f 68{
4e1bc39a 69 const bool isPhysic = theMat.MaterialType (Graphic3d_MATERIAL_PHYSIC);
a71a71de 70 ChangeShine() = 128.0f * theMat.Shininess();
71 ChangeTransparency() = theMat.Alpha();
b6472664 72
0adbd30f 73 // ambient component
b6472664 74 if (theMat.ReflectionMode (Graphic3d_TOR_AMBIENT))
0adbd30f 75 {
b6472664 76 const OpenGl_Vec3& aSrcAmb = isPhysic ? theMat.AmbientColor() : theInteriorColor;
4e1bc39a 77 Ambient = OpenGl_Vec4 (aSrcAmb * theMat.Ambient(), 1.0f);
0adbd30f 78 }
79 else
80 {
81 Ambient = THE_BLACK_COLOR;
82 }
83
84 // diffusion component
b6472664 85 if (theMat.ReflectionMode (Graphic3d_TOR_DIFFUSE))
0adbd30f 86 {
b6472664 87 const OpenGl_Vec3& aSrcDif = isPhysic ? theMat.DiffuseColor() : theInteriorColor;
4e1bc39a 88 Diffuse = OpenGl_Vec4 (aSrcDif * theMat.Diffuse(), 1.0f);
0adbd30f 89 }
90 else
91 {
92 Diffuse = THE_BLACK_COLOR;
93 }
94
95 // specular component
b6472664 96 if (theMat.ReflectionMode (Graphic3d_TOR_SPECULAR))
0adbd30f 97 {
b6472664 98 const OpenGl_Vec3& aSrcSpe = isPhysic ? (const OpenGl_Vec3& )theMat.SpecularColor() : THE_WHITE_COLOR.rgb();
4e1bc39a 99 Specular = OpenGl_Vec4 (aSrcSpe * theMat.Specular(), 1.0f);
0adbd30f 100 }
101 else
102 {
103 Specular = THE_BLACK_COLOR;
104 }
105
106 // emission component
b6472664 107 if (theMat.ReflectionMode (Graphic3d_TOR_EMISSION))
0adbd30f 108 {
b6472664 109 const OpenGl_Vec3& aSrcEms = isPhysic ? theMat.EmissiveColor() : theInteriorColor;
4e1bc39a 110 Emission = OpenGl_Vec4 (aSrcEms * theMat.Emissive(), 1.0f);
0adbd30f 111 }
112 else
113 {
114 Emission = THE_BLACK_COLOR;
115 }
0adbd30f 116}
117
118// =======================================================================
2166f0fa
SK
119// function : OpenGl_Workspace
120// purpose :
121// =======================================================================
c357e426 122OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Window)& theWindow)
1a0dfc1b 123: myView (theView),
c357e426 124 myWindow (theWindow),
125 myGlContext (!theWindow.IsNull() ? theWindow->GetGlContext() : NULL),
eae454e3 126 myUseZBuffer (Standard_True),
127 myUseDepthWrite (Standard_True),
2166f0fa 128 //
f9ba5c4d 129 myAspectLineSet (&myDefaultAspectLine),
130 myAspectFaceSet (&myDefaultAspectFace),
f9ba5c4d 131 myAspectMarkerSet (&myDefaultAspectMarker),
f9ba5c4d 132 myAspectTextSet (&myDefaultAspectText),
f9ba5c4d 133 //
2166f0fa
SK
134 ViewMatrix_applied (&myDefaultMatrix),
135 StructureMatrix_applied (&myDefaultMatrix),
b6472664 136 myToAllowFaceCulling (false),
b6472664 137 myModelViewMatrix (myDefaultMatrix)
2166f0fa 138{
c357e426 139 if (!myGlContext.IsNull() && myGlContext->MakeCurrent())
73192b37 140 {
c357e426 141 myGlContext->core11fwd->glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
2166f0fa 142
c357e426 143 // General initialization of the context
c357e426 144 #if !defined(GL_ES_VERSION_2_0)
145 if (myGlContext->core11 != NULL)
146 {
dd1ae9df 147 // enable two-side lighting by default
c357e426 148 glLightModeli ((GLenum )GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
dd1ae9df 149 glHint (GL_POINT_SMOOTH_HINT, GL_FASTEST);
150 if (myGlContext->caps->ffpEnable)
151 {
152 glHint (GL_FOG_HINT, GL_FASTEST);
153 }
c357e426 154 }
2166f0fa 155
c357e426 156 glHint (GL_LINE_SMOOTH_HINT, GL_FASTEST);
157 glHint (GL_POLYGON_SMOOTH_HINT, GL_FASTEST);
158 #endif
73192b37 159 }
f8ae3605 160
b6472664 161 myDefaultCappingAlgoFilter = new OpenGl_CappingAlgoFilter();
162
c40eb6b9 163 myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
164 myFontFaceAspect.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
165
b6472664 166 myNoneCulling .Aspect()->SetSuppressBackFaces (false);
167 myNoneCulling .Aspect()->SetDrawEdges (false);
c40eb6b9 168 myNoneCulling .Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
169
b6472664 170 myFrontCulling.Aspect()->SetSuppressBackFaces (true);
171 myFrontCulling.Aspect()->SetDrawEdges (false);
c40eb6b9 172 myFrontCulling.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
2166f0fa
SK
173}
174
175// =======================================================================
2166f0fa
SK
176// function : Activate
177// purpose :
178// =======================================================================
179Standard_Boolean OpenGl_Workspace::Activate()
180{
c357e426 181 if (myWindow.IsNull() || !myWindow->Activate())
182 {
2166f0fa 183 return Standard_False;
c357e426 184 }
2166f0fa 185
2166f0fa
SK
186 ViewMatrix_applied = &myDefaultMatrix;
187 StructureMatrix_applied = &myDefaultMatrix;
26395493 188
189 ResetAppliedAspect();
190
8613985b 191 // reset state for safety
192 myGlContext->BindProgram (Handle(OpenGl_ShaderProgram)());
193 if (myGlContext->core20fwd != NULL)
194 {
195 myGlContext->core20fwd->glUseProgram (OpenGl_ShaderProgram::NO_PROGRAM);
196 }
dd1ae9df 197 if (myGlContext->caps->ffpEnable)
198 {
199 myGlContext->ShaderManager()->PushState (Handle(OpenGl_ShaderProgram)());
200 }
26395493 201 return Standard_True;
2166f0fa
SK
202}
203
26395493 204//=======================================================================
205//function : ResetAppliedAspect
206//purpose : Sets default values of GL parameters in accordance with default aspects
207//=======================================================================
208void OpenGl_Workspace::ResetAppliedAspect()
209{
4e1523ef 210 myGlContext->BindDefaultVao();
211
f838dac4 212 myHighlightStyle.Nullify();
b6472664 213 myToAllowFaceCulling = false;
f9ba5c4d 214 myAspectLineSet = &myDefaultAspectLine;
215 myAspectFaceSet = &myDefaultAspectFace;
b6472664 216 myAspectFaceApplied.Nullify();
f9ba5c4d 217 myAspectMarkerSet = &myDefaultAspectMarker;
b6472664 218 myAspectMarkerApplied.Nullify();
f9ba5c4d 219 myAspectTextSet = &myDefaultAspectText;
8d1a539c 220 myGlContext->SetPolygonOffset (Graphic3d_PolygonOffset());
26395493 221
f9ba5c4d 222 ApplyAspectLine();
223 ApplyAspectFace();
224 ApplyAspectMarker();
225 ApplyAspectText();
ac116c22 226
b6472664 227 myGlContext->SetTypeOfLine (myDefaultAspectLine.Aspect()->Type());
228 myGlContext->SetLineWidth (myDefaultAspectLine.Aspect()->Width());
26395493 229}
bf75be98 230
231// =======================================================================
c357e426 232// function : SetAspectLine
38a0206f 233// purpose :
234// =======================================================================
f9ba5c4d 235const OpenGl_AspectLine* OpenGl_Workspace::SetAspectLine (const OpenGl_AspectLine* theAspect)
38a0206f 236{
f9ba5c4d 237 const OpenGl_AspectLine* aPrevAspectLine = myAspectLineSet;
238 myAspectLineSet = theAspect;
239 return aPrevAspectLine;
c357e426 240}
38a0206f 241
c357e426 242// =======================================================================
243// function : SetAspectFace
244// purpose :
245// =======================================================================
f9ba5c4d 246const OpenGl_AspectFace * OpenGl_Workspace::SetAspectFace (const OpenGl_AspectFace* theAspect)
c357e426 247{
f9ba5c4d 248 const OpenGl_AspectFace* aPrevAspectFace = myAspectFaceSet;
249 myAspectFaceSet = theAspect;
250 return aPrevAspectFace;
c357e426 251}
38a0206f 252
c357e426 253// =======================================================================
254// function : SetAspectMarker
255// purpose :
256// =======================================================================
f9ba5c4d 257const OpenGl_AspectMarker* OpenGl_Workspace::SetAspectMarker (const OpenGl_AspectMarker* theAspect)
c357e426 258{
f9ba5c4d 259 const OpenGl_AspectMarker* aPrevAspectMarker = myAspectMarkerSet;
260 myAspectMarkerSet = theAspect;
261 return aPrevAspectMarker;
c357e426 262}
f978241f 263
c357e426 264// =======================================================================
265// function : SetAspectText
266// purpose :
267// =======================================================================
f9ba5c4d 268const OpenGl_AspectText * OpenGl_Workspace::SetAspectText (const OpenGl_AspectText* theAspect)
c357e426 269{
f9ba5c4d 270 const OpenGl_AspectText* aPrevAspectText = myAspectTextSet;
271 myAspectTextSet = theAspect;
272 return aPrevAspectText;
c357e426 273}
38a0206f 274
c357e426 275// =======================================================================
f9ba5c4d 276// function : ApplyAspectFace
c357e426 277// purpose :
278// =======================================================================
f9ba5c4d 279const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
c357e426 280{
c357e426 281 if (myView->BackfacingModel() == Graphic3d_TOBM_AUTOMATIC)
38a0206f 282 {
c357e426 283 // manage back face culling mode, disable culling when clipping is enabled
b6472664 284 bool toSuppressBackFaces = myToAllowFaceCulling
285 && myAspectFaceSet->Aspect()->ToSuppressBackFaces();
286 if (toSuppressBackFaces)
f978241f 287 {
b6472664 288 if (myGlContext->Clipping().IsClippingOrCappingOn()
289 || myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HATCH)
f978241f 290 {
b6472664 291 toSuppressBackFaces = false;
c357e426 292 }
293 }
b6472664 294 if (toSuppressBackFaces)
c357e426 295 {
c40eb6b9 296 if (myAspectFaceSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Blend
297 || myAspectFaceSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_Mask
298 || (myAspectFaceSet->Aspect()->AlphaMode() == Graphic3d_AlphaMode_BlendAuto
299 && myAspectFaceSet->Aspect()->FrontMaterial().Transparency() != 0.0f))
c357e426 300 {
b6472664 301 // disable culling in case of translucent shading aspect
302 toSuppressBackFaces = false;
f978241f 303 }
f978241f 304 }
b6472664 305 myGlContext->SetCullBackFaces (toSuppressBackFaces);
f978241f 306 }
307
b6472664 308 if (myAspectFaceSet->Aspect() == myAspectFaceApplied
8613985b 309 && myHighlightStyle == myAspectFaceAppliedWithHL)
a2e4f780 310 {
f9ba5c4d 311 return myAspectFaceSet;
a2e4f780 312 }
8613985b 313 myAspectFaceAppliedWithHL = myHighlightStyle;
a2e4f780 314
c357e426 315#if !defined(GL_ES_VERSION_2_0)
b6472664 316 const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->Aspect()->InteriorStyle();
317 if (myAspectFaceApplied.IsNull()
f9ba5c4d 318 || myAspectFaceApplied->InteriorStyle() != anIntstyle)
b86bb3df 319 {
c357e426 320 switch (anIntstyle)
760c21c2 321 {
c357e426 322 case Aspect_IS_EMPTY:
323 case Aspect_IS_HOLLOW:
ee51a9fe 324 {
6d0e6be5 325 myGlContext->SetPolygonMode (GL_LINE);
c357e426 326 break;
ee51a9fe 327 }
c357e426 328 case Aspect_IS_HATCH:
62e1beed 329 {
6d0e6be5 330 myGlContext->SetPolygonMode (GL_FILL);
331 myGlContext->SetPolygonHatchEnabled (true);
c357e426 332 break;
62e1beed 333 }
c357e426 334 case Aspect_IS_SOLID:
335 case Aspect_IS_HIDDENLINE:
336 {
6d0e6be5 337 myGlContext->SetPolygonMode (GL_FILL);
338 myGlContext->SetPolygonHatchEnabled (false);
c357e426 339 break;
340 }
341 case Aspect_IS_POINT:
38a0206f 342 {
6d0e6be5 343 myGlContext->SetPolygonMode (GL_POINT);
c357e426 344 break;
38a0206f 345 }
38a0206f 346 }
91c60b57 347 }
e276548b 348
c357e426 349 if (anIntstyle == Aspect_IS_HATCH)
91c60b57 350 {
6d0e6be5 351 myGlContext->SetPolygonHatchStyle (myAspectFaceSet->Aspect()->HatchStyle());
c357e426 352 }
353#endif
38a0206f 354
c357e426 355 // Aspect_POM_None means: do not change current settings
b6472664 356 if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
c357e426 357 {
8d1a539c 358 myGlContext->SetPolygonOffset (myAspectFaceSet->Aspect()->PolygonOffset());
38a0206f 359 }
c357e426 360
8613985b 361 // Case of hidden line
362 if (myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
363 {
364 // copy all values including line edge aspect
dc89236f 365 *myAspectFaceHl.Aspect() = *myAspectFaceSet->Aspect();
8613985b 366 myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge());
dc89236f 367 myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
8613985b 368 myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
dc89236f 369 myAspectFaceHl.SetNoLighting();
8613985b 370 myAspectFaceSet = &myAspectFaceHl;
371 }
372 else
a174a3c5 373 {
a1073ae2 374 myGlContext->SetShadingMaterial (myAspectFaceSet, myHighlightStyle);
c357e426 375 }
62e1beed 376
b6472664 377 if (myAspectFaceSet->Aspect()->ToMapTexture())
c357e426 378 {
cc8cbabe 379 myGlContext->BindTextures (myAspectFaceSet->TextureSet (myGlContext));
83da37b1 380 }
381 else
382 {
cc8cbabe 383 myGlContext->BindTextures (myEnvironmentTexture);
a174a3c5 384 }
385
b6472664 386 myAspectFaceApplied = myAspectFaceSet->Aspect();
f9ba5c4d 387 return myAspectFaceSet;
c357e426 388}
a174a3c5 389
c357e426 390// =======================================================================
f9ba5c4d 391// function : ApplyAspectMarker
c357e426 392// purpose :
393// =======================================================================
f9ba5c4d 394const OpenGl_AspectMarker* OpenGl_Workspace::ApplyAspectMarker()
c357e426 395{
b6472664 396 if (myAspectMarkerSet->Aspect() != myAspectMarkerApplied)
ee51a9fe 397 {
b6472664 398 if (myAspectMarkerApplied.IsNull()
399 || (myAspectMarkerSet->Aspect()->Scale() != myAspectMarkerApplied->Scale()))
ee51a9fe 400 {
c357e426 401 #if !defined(GL_ES_VERSION_2_0)
b6472664 402 glPointSize (myAspectMarkerSet->Aspect()->Scale());
c357e426 403 #endif
ee51a9fe 404 }
b6472664 405 myAspectMarkerApplied = myAspectMarkerSet->Aspect();
38a0206f 406 }
f9ba5c4d 407 return myAspectMarkerSet;
679ecdee 408}
409
410// =======================================================================
c357e426 411// function : Width
679ecdee 412// purpose :
413// =======================================================================
c357e426 414Standard_Integer OpenGl_Workspace::Width() const
679ecdee 415{
c357e426 416 return !myView->GlWindow().IsNull() ? myView->GlWindow()->Width() : 0;
417}
679ecdee 418
c357e426 419// =======================================================================
420// function : Height
421// purpose :
422// =======================================================================
423Standard_Integer OpenGl_Workspace::Height() const
424{
425 return !myView->GlWindow().IsNull() ? myView->GlWindow()->Height() : 0;
426}
679ecdee 427
c357e426 428// =======================================================================
c357e426 429// function : IsCullingEnabled
430// purpose :
431// =======================================================================
432Standard_Boolean OpenGl_Workspace::IsCullingEnabled() const
433{
434 return myView->IsCullingEnabled();
679ecdee 435}
436
437// =======================================================================
c357e426 438// function : FBOCreate
679ecdee 439// purpose :
440// =======================================================================
b128c892 441Handle(OpenGl_FrameBuffer) OpenGl_Workspace::FBOCreate (const Standard_Integer theWidth,
442 const Standard_Integer theHeight)
679ecdee 443{
c357e426 444 // activate OpenGL context
445 if (!Activate())
b128c892 446 return Handle(OpenGl_FrameBuffer)();
c357e426 447
448 // create the FBO
449 const Handle(OpenGl_Context)& aCtx = GetGlContext();
cc8cbabe 450 aCtx->BindTextures (Handle(OpenGl_TextureSet)());
b128c892 451 Handle(OpenGl_FrameBuffer) aFrameBuffer = new OpenGl_FrameBuffer();
3c4b62a4 452 if (!aFrameBuffer->Init (aCtx, theWidth, theHeight, GL_RGBA8, GL_DEPTH24_STENCIL8, 0))
679ecdee 453 {
c357e426 454 aFrameBuffer->Release (aCtx.operator->());
b128c892 455 return Handle(OpenGl_FrameBuffer)();
679ecdee 456 }
b128c892 457 return aFrameBuffer;
679ecdee 458}
459
460// =======================================================================
c357e426 461// function : FBORelease
679ecdee 462// purpose :
463// =======================================================================
b128c892 464void OpenGl_Workspace::FBORelease (Handle(OpenGl_FrameBuffer)& theFbo)
679ecdee 465{
c357e426 466 // activate OpenGL context
467 if (!Activate()
b128c892 468 || theFbo.IsNull())
62e1beed 469 {
62e1beed 470 return;
471 }
c357e426 472
b128c892 473 theFbo->Release (GetGlContext().operator->());
474 theFbo.Nullify();
c357e426 475}
62e1beed 476
f9f740d6 477// =======================================================================
f9f740d6 478// function : BufferDump
479// purpose :
480// =======================================================================
481Standard_Boolean OpenGl_Workspace::BufferDump (const Handle(OpenGl_FrameBuffer)& theFbo,
482 Image_PixMap& theImage,
483 const Graphic3d_BufferType& theBufferType)
c357e426 484{
6cde53c4 485 return !theImage.IsEmpty()
486 && Activate()
487 && OpenGl_FrameBuffer::BufferDump (GetGlContext(), theFbo, theImage, theBufferType);
679ecdee 488}
91c60b57 489
91c60b57 490// =======================================================================
a1073ae2 491// function : ShouldRender
91c60b57 492// purpose :
493// =======================================================================
a1073ae2 494Standard_Boolean OpenGl_RaytraceFilter::ShouldRender (const Handle(OpenGl_Workspace)& theWorkspace,
495 const OpenGl_Element* theElement)
91c60b57 496{
497 Standard_Boolean aPrevFilterResult = Standard_True;
498 if (!myPrevRenderFilter.IsNull())
499 {
a1073ae2 500 aPrevFilterResult = myPrevRenderFilter->ShouldRender (theWorkspace, theElement);
91c60b57 501 }
502 return aPrevFilterResult &&
503 !OpenGl_Raytrace::IsRaytracedElement (theElement);
504}