V-ART
polyline.cpp
Go to the documentation of this file.
1 
5 #include "vart/polyline.h"
6 
7 using namespace std;
8 //using namespace VART;
9 
11  : width(1), organization(LINES)
12 {
13 }
14 
16 {
17  this->operator =(polyLine);
18 }
19 
21 {
22  Clear();
23 }
24 
26 {
27  width = polyLine.width;
28  vertexVec = polyLine.vertexVec;
29  material = polyLine.material;
30  return *this;
31 }
32 
34 {
35  return new VART::PolyLine(*this);
36 }
37 
39 {
40  vertexVec.clear();
41 }
42 
44 {
45  if (vertexVec.size() > 1)
46  {
47  bBox.SetBoundingBox(vertexVec[0].GetX(), vertexVec[0].GetY(), vertexVec[0].GetZ(),
48  vertexVec[1].GetX(), vertexVec[1].GetY(), vertexVec[1].GetZ());
49  // Check against the others
50  for (unsigned int i=2; i < vertexVec.size(); i++)
51  bBox.ConditionalUpdate(vertexVec[i].GetX(), vertexVec[i].GetY(), vertexVec[i].GetZ());
52  }
53 }
54 
56 {
57 #ifdef VART_OGL
58  bool result = true;
59  if (show)
60  {
61  glPushAttrib( GL_LINE_BIT );
62  glLineWidth( width );
63  result = material.DrawOGL();
64  glBegin(GLOrganizationType());
65  for(unsigned int i = 0; i < vertexVec.size(); ++i)
66  {
67  glVertex3dv( vertexVec[i].VetXYZW() );
68  }
69  glEnd();
70  glPopAttrib();
71  }
72  if (bBox.visible)
73  bBox.DrawInstanceOGL();
74  return result;
75 #else
76  return false;
77 #endif
78 }
79 
80 #ifdef VART_OGL
81 GLenum VART::PolyLine::GLOrganizationType() const
82 // protected
83 {
84  if (organization == LINES)
85  return GL_LINES;
86  if (organization == LINE_STRIP)
87  return GL_LINE_STRIP;
88  return GL_LINE_LOOP;
89 }
90 #endif
Base class for objects that compose a scene graph.
Definition: scenenode.h:25
PolyLine()
Creates a empty PolyLine.
Definition: polyline.cpp:10
A PolyLine is a sequence of lines, defined by a list of points.
Definition: polyline.h:18
virtual bool DrawOGL() const
Recursive drawing using OpenGL commands.
Definition: polyline.cpp:55
~PolyLine()
Destroy all PolyLine data.
Definition: polyline.cpp:20
virtual VART::SceneNode * Copy()
Return a copy of the PolyLine.
Definition: polyline.cpp:33
VART::PolyLine & operator=(const VART::PolyLine &polyLine)
Copies all polyLine data to another PolyLine.
Definition: polyline.cpp:25
virtual void ComputeBoundingBox()
Computes the bounding box of the PolyLine.
Definition: polyline.cpp:43
void Clear()
Clear all vertices in the PolyLine.
Definition: polyline.cpp:38