Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLSphere.cxx
Go to the documentation of this file.
1// @(#)root/gl:$Id$
2// Author: Timur Pocheptsov 03/08/2004
3// NOTE: This code moved from obsoleted TGLSceneObject.h / .cxx - see these
4// attic files for previous CVS history
5
6/*************************************************************************
7 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13#include "TGLSphere.h"
14#include "TGLRnrCtx.h"
15#include "TGLQuadric.h"
16#include "TGLIncludes.h"
17
18#include "TBuffer3D.h"
19#include "TBuffer3DTypes.h"
20
21// For debug tracing
22#include "TClass.h"
23#include "TError.h"
24
25/** \class TGLSphere
26\ingroup opengl
27Implements a native ROOT-GL sphere that can be rendered at
28different levels of detail.
29*/
30
31
32////////////////////////////////////////////////////////////////////////////////
33/// Default ctor
34
36 TGLLogicalShape(buffer)
37{
38 fDLSize = 14;
39
40 fRadius = buffer.fRadiusOuter;
41
42 // TODO:
43 // Support hollow & cut spheres
44 // buffer.fRadiusInner;
45 // buffer.fThetaMin;
46 // buffer.fThetaMax;
47 // buffer.fPhiMin;
48 // buffer.fPhiMax;
49}
50
51////////////////////////////////////////////////////////////////////////////////
52/// Return display-list offset for given LOD.
53/// Calculation based on what is done in virtual QuantizeShapeLOD below.
54
56{
57 UInt_t off = 0;
58 if (lod >= 100) off = 0;
59 else if (lod < 10) off = lod / 2;
60 else off = lod / 10 + 4;
61 return off;
62}
63
64////////////////////////////////////////////////////////////////////////////////
65/// Factor in scene/viewer LOD and quantize.
66
68{
69 Int_t lod = ((Int_t)shapeLOD * (Int_t)combiLOD) / 100;
70
71 if (lod >= 100)
72 {
73 lod = 100;
74 }
75 else if (lod > 10)
76 { // Round LOD above 10 to nearest 10
77 Double_t quant = 0.1 * ((static_cast<Double_t>(lod)) + 0.5);
78 lod = 10 * static_cast<Int_t>(quant);
79 }
80 else
81 { // Round LOD below 10 to nearest 2
82 Double_t quant = 0.5 * ((static_cast<Double_t>(lod)) + 0.5);
83 lod = 2 * static_cast<Int_t>(quant);
84 }
85 return static_cast<Short_t>(lod);
86}
87
88////////////////////////////////////////////////////////////////////////////////
89/// Debug tracing
90
92{
93 if (gDebug > 4) {
94 Info("TGLSphere::DirectDraw", "this %zd (class %s) LOD %d", (size_t)this, IsA()->GetName(), rnrCtx.ShapeLOD());
95 }
96
97 // 4 stack/slice min for gluSphere to work
98 UInt_t divisions = rnrCtx.ShapeLOD();
99 if (divisions < 4) {
100 divisions = 4;
101 }
102 gluSphere(rnrCtx.GetGluQuadric(), fRadius, divisions, divisions);
103}
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Short_t
Signed Short integer 2 bytes (short)
Definition RtypesCore.h:53
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Info(const char *location, const char *msgfmt,...)
Use this function for informational messages.
Definition TError.cxx:241
Int_t gDebug
Global variable setting the debug level. Set to 0 to disable, increase it in steps of 1 to increase t...
Definition TROOT.cxx:627
Sphere description class - see TBuffer3DTypes for producer classes Supports hollow and cut spheres.
Definition TBuffer3D.h:130
Double_t fRadiusOuter
Definition TBuffer3D.h:145
Abstract logical shape - a GL 'drawable' - base for all shapes - faceset sphere etc.
Int_t fDLSize
display-list id base
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
Double_t fRadius
Definition TGLSphere.h:24
UInt_t DLOffset(Short_t lod) const override
Return display-list offset for given LOD.
Definition TGLSphere.cxx:55
TClass * IsA() const override
Definition TGLSphere.h:35
TGLSphere(const TBuffer3DSphere &buffer)
Default ctor.
Definition TGLSphere.cxx:35
Short_t QuantizeShapeLOD(Short_t shapeLOD, Short_t combiLOD) const override
Factor in scene/viewer LOD and quantize.
Definition TGLSphere.cxx:67
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Debug tracing.
Definition TGLSphere.cxx:91