source: vtkvis/tags/1.7.2/Cone.cpp @ 4952

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