source: vtkvis/trunk/Arrow.cpp @ 4650

Last change on this file since 4650 was 3695, checked in by ldelgass, 11 years ago

Add protocol for setting glyphs tesselation quality

  • Property svn:eol-style set to native
File size: 1.6 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#include <vtkPolyDataMapper.h>
9#include <vtkActor.h>
10#include <vtkArrowSource.h>
11#include <vtkPolyDataNormals.h>
12#include <vtkReverseSense.h>
13
14#include "Arrow.h"
15#include "Trace.h"
16
17using namespace VtkVis;
18
19Arrow::Arrow() :
20    Shape()
21{
22}
23
24Arrow::~Arrow()
25{
26    TRACE("Deleting Arrow");
27}
28
29void Arrow::update()
30{
31    if (_arrow == NULL) {
32        _arrow = vtkSmartPointer<vtkArrowSource>::New();
33    }
34
35    if (_pdMapper == NULL) {
36        _pdMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
37        _pdMapper->SetResolveCoincidentTopologyToPolygonOffset();
38        _pdMapper->ScalarVisibilityOff();
39    }
40
41    vtkSmartPointer<vtkPolyDataNormals> normalFilter = vtkSmartPointer<vtkPolyDataNormals>::New();
42    normalFilter->SetFeatureAngle(90.);
43    normalFilter->SetInputConnection(_arrow->GetOutputPort());
44
45    _pdMapper->SetInputConnection(_arrow->GetOutputPort());
46
47    initProp();
48
49    getActor()->SetMapper(_pdMapper);
50    _pdMapper->Update();
51}
52
53void Arrow::flipNormals(bool state)
54{
55    if (_arrow == NULL || _pdMapper == NULL)
56        return;
57
58    if (state) {
59        vtkSmartPointer<vtkReverseSense> filter = vtkSmartPointer<vtkReverseSense>::New();
60        filter->ReverseCellsOn();
61        filter->ReverseNormalsOn();
62        filter->SetInputConnection(_arrow->GetOutputPort());
63
64        _pdMapper->SetInputConnection(filter->GetOutputPort());
65    } else {
66        _pdMapper->SetInputConnection(_arrow->GetOutputPort());
67    }
68}
Note: See TracBrowser for help on using the repository browser.