source: vtkvis/trunk/Cylinder.cpp @ 4952

Last change on this file since 4952 was 3683, checked in by ldelgass, 11 years ago

Improvements to 3D shapes in vtkvis. Add preliminary, experimental grouping.

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