source: vtkvis/branches/1.8/Disk.cpp @ 5073

Last change on this file since 5073 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 <vtkDiskSource.h>
11#include <vtkPolyDataNormals.h>
12#include <vtkReverseSense.h>
13
14#include "Disk.h"
15#include "Trace.h"
16
17using namespace VtkVis;
18
19Disk::Disk() :
20    Shape()
21{
22}
23
24Disk::~Disk()
25{
26    TRACE("Deleting Disk");
27}
28
29void Disk::update()
30{
31    if (_disk == NULL) {
32        _disk = vtkSmartPointer<vtkDiskSource>::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->SetInputConnection(_disk->GetOutputPort());
43
44    _pdMapper->SetInputConnection(normalFilter->GetOutputPort());
45
46    initProp();
47
48    getActor()->SetMapper(_pdMapper);
49    _pdMapper->Update();
50}
51
52void Disk::flipNormals(bool state)
53{
54    if (_disk == NULL || _pdMapper == NULL)
55        return;
56
57    if (state) {
58        vtkSmartPointer<vtkReverseSense> filter = vtkSmartPointer<vtkReverseSense>::New();
59        filter->ReverseCellsOn();
60        filter->ReverseNormalsOn();
61        filter->SetInputConnection(_disk->GetOutputPort());
62
63        _pdMapper->SetInputConnection(filter->GetOutputPort());
64    } else {
65        _pdMapper->SetInputConnection(_disk->GetOutputPort());
66    }
67    _pdMapper->Update();
68}
Note: See TracBrowser for help on using the repository browser.