source: trunk/packages/vizservers/vtkvis/Sphere.cpp @ 4026

Last change on this file since 4026 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.5 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 <vtkSphereSource.h>
17#include <vtkReverseSense.h>
18
19#include "Sphere.h"
20#include "Trace.h"
21
22using namespace VtkVis;
23
24Sphere::Sphere() :
25    Shape()
26{
27}
28
29Sphere::~Sphere()
30{
31    TRACE("Deleting Sphere");
32}
33
34void Sphere::update()
35{
36    if (_sphere == NULL) {
37        _sphere = vtkSmartPointer<vtkSphereSource>::New();
38    }
39
40    if (_pdMapper == NULL) {
41        _pdMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
42        _pdMapper->SetResolveCoincidentTopologyToPolygonOffset();
43        _pdMapper->ScalarVisibilityOff();
44    }
45
46    _pdMapper->SetInputConnection(_sphere->GetOutputPort());
47
48    initProp();
49
50    getActor()->SetMapper(_pdMapper);
51    _pdMapper->Update();
52}
53
54void Sphere::flipNormals(bool state)
55{
56    if (_sphere == 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(_sphere->GetOutputPort());
64
65        _pdMapper->SetInputConnection(filter->GetOutputPort());
66    } else {
67        _pdMapper->SetInputConnection(_sphere->GetOutputPort());
68    }
69}
Note: See TracBrowser for help on using the repository browser.