source: vtkvis/tags/1.7.2/Box.cpp @ 4832

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