source: vtkvis/tags/1.8.1/Line.h @ 5080

Last change on this file since 5080 was 3696, checked in by ldelgass, 11 years ago

Use imroved Arc API (arc can only represent a circular section, and setting
two endpoints could cause problems with endpts and center colinear and radii
from center to two endpoints differing). New API uses a center, start point,
normal and sweep angle. Also change Line to support polylines: protocol is
changed to require a Tcl list for point coordinates instead of a fixed 2
endpoints.

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2004-2012  HUBzero Foundation, LLC
4 *
5 * Author: Leif Delgass <ldelgass@purdue.edu>
6 */
7
8#ifndef VTKVIS_LINE_H
9#define VTKVIS_LINE_H
10
11#include <vector>
12
13#include <vtkSmartPointer.h>
14#include <vtkPolyDataMapper.h>
15#include <vtkActor.h>
16#include <vtkLineSource.h>
17#include <vtkPoints.h>
18
19#include "Shape.h"
20#include "DataSet.h"
21
22namespace VtkVis {
23
24/**
25 * \brief VTK PolyData Line
26 *
27 * This class creates a polyline
28 */
29class Line : public Shape
30{
31public:
32    Line();
33    virtual ~Line();
34
35    virtual const char *getClassName() const
36    {
37        return "Line";
38    }
39
40    /**
41     * \brief This interface creates a single line
42     */
43    void setEndPoints(double pt1[3], double pt2[3])
44    {
45        if (_line != NULL) {
46            _line->SetPoint1(pt1);
47            _line->SetPoint2(pt2);
48            _line->SetPoints(NULL);
49        }
50    }
51
52    /**
53     * \brief This interface creates a polyline
54     */
55    void setPoints(std::vector<double> pts)
56    {
57        if (_line == NULL)
58            return;
59        vtkPoints *points = vtkPoints::New();
60        for (size_t i = 0; i < pts.size(); i+=3) {
61            points->InsertNextPoint(pts[i], pts[i+1], pts[i+2]);
62        }
63        _line->SetPoints(points);
64    }
65
66private:
67    virtual void update();
68
69    vtkSmartPointer<vtkLineSource> _line;
70};
71
72}
73
74#endif
Note: See TracBrowser for help on using the repository browser.