source: vtkvis/trunk/Outline.cpp

Last change on this file was 5835, checked in by ldelgass, 9 years ago

Require VTK >= 6.0.0

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Copyright (C) 2004-2013  HUBzero Foundation, LLC
4 *
5 * Author: Leif Delgass <ldelgass@purdue.edu>
6 */
7
8#include <cassert>
9
10#include <vtkDataSet.h>
11#include <vtkStructuredGrid.h>
12#include <vtkPolyData.h>
13#include <vtkOutlineFilter.h>
14#include <vtkStructuredGridOutlineFilter.h>
15
16#include "Outline.h"
17#include "Trace.h"
18
19using namespace VtkVis;
20
21Outline::Outline() :
22    GraphicsObject()
23{
24}
25
26Outline::~Outline()
27{
28#ifdef WANT_TRACE
29    if (_dataSet != NULL)
30        TRACE("Deleting Outline for %s", _dataSet->getName().c_str());
31    else
32        TRACE("Deleting Outline with NULL DataSet");
33#endif
34}
35
36/**
37 * \brief Create and initialize a VTK Prop to render a mesh
38 */
39void Outline::initProp()
40{
41    GraphicsObject::initProp();
42}
43
44/**
45 * \brief Internal method to set up pipeline after a state change
46 */
47void Outline::update()
48{
49    if (_dataSet == NULL) {
50        return;
51    }
52
53    if (_pdMapper == NULL) {
54        _pdMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
55        _pdMapper->SetResolveCoincidentTopologyToPolygonOffset();
56        _pdMapper->ScalarVisibilityOff();
57    }
58
59    vtkDataSet *ds = _dataSet->getVtkDataSet();
60    vtkStructuredGrid *sg = vtkStructuredGrid::SafeDownCast(ds);
61    if (sg != NULL) {
62        vtkSmartPointer<vtkStructuredGridOutlineFilter> ofilter = vtkSmartPointer<vtkStructuredGridOutlineFilter>::New();
63        ofilter->SetInputData(ds);
64        ofilter->ReleaseDataFlagOn();
65        _pdMapper->SetInputConnection(ofilter->GetOutputPort());
66    } else {
67        vtkSmartPointer<vtkOutlineFilter> ofilter = vtkSmartPointer<vtkOutlineFilter>::New();
68        ofilter->SetInputData(ds);
69        ofilter->ReleaseDataFlagOn();
70        _pdMapper->SetInputConnection(ofilter->GetOutputPort());
71    }
72
73    initProp();
74
75    setVisibility(_dataSet->getVisibility());
76
77    getActor()->SetMapper(_pdMapper);
78    _pdMapper->Update();
79
80#ifdef WANT_TRACE
81    double *b = getBounds();
82    TRACE("bounds: %g %g %g %g %g %g", b[0], b[1], b[2], b[3], b[4], b[5]);
83#endif
84}
85
86/**
87 * \brief Set a group of world coordinate planes to clip rendering
88 *
89 * Passing NULL for planes will remove all cliping planes
90 */
91void Outline::setClippingPlanes(vtkPlaneCollection *planes)
92{
93    if (_pdMapper != NULL) {
94        _pdMapper->SetClippingPlanes(planes);
95    }
96}
Note: See TracBrowser for help on using the repository browser.