TridSketchTube Class Reference

#include <TridSketches.h>

Inheritance diagram for TridSketchTube:
TridSketch

List of all members.

Public Member Functions

 TridSketchTube (void)
 TridSketchTube (const TVector3 &end1, const TVector3 &end2, Double_t radius, Int_t nfaces=6, Bool_t closed=true)
virtual ~TridSketchTube ()
void DrawSelf (void)

Public Attributes

TVector3 * p
Bool_t fClosed
Int_t fNfaces

Detailed Description

Definition at line 210 of file TridSketches.h.


Constructor & Destructor Documentation

TridSketchTube::TridSketchTube ( void   ) 

Definition at line 456 of file TridSketches.cxx.

00457   : TridSketch(kTube, TVector3() )
00458 {
00459   //
00460   // Default constructor for a box.
00461   //
00462   p = new TVector3[6];
00463   cout << "TridSketchTube:: Wrong constructor!" << endl;
00464   for(int i=0;i<8;i++) {
00465     cout << "Tube " << fId << "\t" << i << "\t" << p[i].x() << "\t" << p[i].y() << "\t" << p[i].z() << endl;
00466   }
00467 }

TridSketchTube::TridSketchTube ( const TVector3 &  end1,
const TVector3 &  end2,
Double_t  radius,
Int_t  nfaces = 6,
Bool_t  closed = true 
)

Definition at line 470 of file TridSketches.cxx.

References Anp::angle(), fClosed, fNfaces, and p.

00472   : TridSketch(kTube, (end1+end2)*0.5 )
00473 {
00474   //
00475   // Defines the center of the faces, the
00476   //
00477   fNfaces = nfaces;
00478   fClosed = closed;
00479   p = new TVector3[nfaces*2];
00480 
00481   // Find the 2 vectors normal to the length of the tube.
00482   TVector3 v = end2-end1;
00483   TVector3 n1=v.Orthogonal();
00484   TVector3 n2=v.Cross(n1);
00485 
00486   n1.SetMag(1.0);
00487   n2.SetMag(1.0);
00488 
00489   // Find the points around the ends.
00490   for(int i=0;i<fNfaces;i++) {
00491     double angle = (double)i/(double)fNfaces * 2.0*TMath::Pi();
00492     p[i]         = end1 + n1*cos(angle)*radius + n2*sin(angle)*radius;
00493     p[i+fNfaces] = end2 + n1*cos(angle)*radius + n2*sin(angle)*radius;
00494   }
00495 }

virtual TridSketchTube::~TridSketchTube (  )  [inline, virtual]

Definition at line 221 of file TridSketches.h.

References TridSketchLine::p.

00221 { delete [] p; };


Member Function Documentation

void TridSketchTube::DrawSelf ( void   )  [virtual]

Reimplemented from TridSketch.

Definition at line 498 of file TridSketches.cxx.

References fClosed, fNfaces, TridSketch::GlVertexTVector(), Msg::kError, MSG, and p.

00499 {
00500   //
00501   // Draws a box in the current context.
00502   //
00503   if(fClosed) {
00504     // Top Face  
00505     glBegin(GL_POLYGON);
00506     for(int i=0;i<fNfaces;i++) 
00507       GlVertexTVector(p[i]); 
00508     glEnd();
00509     
00510     // Bottom face
00511     glBegin(GL_POLYGON);
00512     for(int i=fNfaces;i<fNfaces*2;i++) 
00513       GlVertexTVector(p[i]); 
00514     glEnd();
00515   }
00516 
00517   // Now do each face.
00518   glBegin(GL_QUAD_STRIP);
00519     for(int i=0;i<fNfaces+1;i++) { // Add an extra so we go all the way around.
00520       // Even and odd faces get get treated seperately.
00521       int iv1 = i%fNfaces;
00522       int iv2 = i%fNfaces + fNfaces;
00523       if((i%2)==0) {
00524         GlVertexTVector(p[iv1]);
00525         GlVertexTVector(p[iv2]);
00526       } else {
00527         GlVertexTVector(p[iv1]);
00528         GlVertexTVector(p[iv2]);
00529       }
00530     }
00531   glEnd();
00532   
00533   int error;
00534   while ((error = glGetError()) != GL_NO_ERROR)  
00535     MSG("TriD",Msg::kError) << "TridSketchTube::DrawSelf.  GL error: "
00536                             << "(" << error << ")"
00537                             <<  gluErrorString(error)
00538                             << endl;
00539 }


Member Data Documentation

Definition at line 214 of file TridSketches.h.

Referenced by DrawSelf(), and TridSketchTube().

Definition at line 215 of file TridSketches.h.

Referenced by DrawSelf(), and TridSketchTube().

TVector3* TridSketchTube::p

Definition at line 213 of file TridSketches.h.

Referenced by DrawSelf(), and TridSketchTube().


The documentation for this class was generated from the following files:

Generated on 19 Jan 2018 for loon by  doxygen 1.6.1