source: vtkvis/trunk/Polygon.cpp @ 6226

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