1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    ZsweepConcavities.cxx
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 /*
17  * Copyright 2006 Sandia Corporation.
18  * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
19  * license for use of this work by or on behalf of the
20  * U.S. Government. Redistribution and use in source and binary forms, with
21  * or without modification, are permitted provided that this Notice and any
22  * statement of authorship are reproduced on all copies.
23  */
24 
25 #include "vtkProjectedTetrahedraMapper.h"
26 
27 #include "vtkCamera.h"
28 #include "vtkColorTransferFunction.h"
29 #include "vtkDataSetTriangleFilter.h"
30 #include "vtkPiecewiseFunction.h"
31 #include "vtkRenderer.h"
32 #include "vtkRenderWindow.h"
33 #include "vtkRenderWindowInteractor.h"
34 #include "vtkRTAnalyticSource.h"
35 #include "vtkThreshold.h"
36 #include "vtkUnstructuredGridVolumeZSweepMapper.h"
37 #include "vtkVolume.h"
38 #include "vtkVolumeProperty.h"
39 
40 #include "vtkRegressionTestImage.h"
41 
42 #include "vtkSmartPointer.h"
43 #define VTK_CREATE(type, name) \
44   vtkSmartPointer<type> name = vtkSmartPointer<type>::New();
45 
ZsweepConcavities(int argc,char * argv[])46 int ZsweepConcavities(int argc, char *argv[])
47 {
48   VTK_CREATE(vtkRTAnalyticSource, input);
49   input->SetWholeExtent(-10, 10, -10, 10, -10, 10);
50   input->SetCenter(0.0, 0.0, 0.0);
51   input->SetMaximum(255.0);
52   input->SetXFreq(60.0);
53   input->SetYFreq(30.0);
54   input->SetZFreq(40.0);
55   input->SetXMag(10.0);
56   input->SetYMag(18.0);
57   input->SetZMag(5.0);
58   input->SetStandardDeviation(0.5);
59   input->SetSubsampleRate(1);
60 
61   VTK_CREATE(vtkThreshold, threshold);
62   threshold->SetInputConnection(input->GetOutputPort());
63   threshold->ThresholdByLower(130.0);
64 
65   VTK_CREATE(vtkDataSetTriangleFilter, tetra);
66   tetra->SetInputConnection(threshold->GetOutputPort());
67 
68   VTK_CREATE(vtkUnstructuredGridVolumeZSweepMapper, zsweep);
69   zsweep->SetInputConnection(tetra->GetOutputPort());
70 
71   VTK_CREATE(vtkVolume, volume);
72   volume->SetMapper(zsweep);
73 
74   VTK_CREATE(vtkColorTransferFunction, color);
75   color->SetColorSpaceToHSV();
76   color->HSVWrapOn();
77   color->AddHSVPoint(0.0, 0.0, 0.0, 0.0);
78   VTK_CREATE(vtkPiecewiseFunction, opacity);
79   opacity->AddPoint(0.0, 0.25);
80   volume->GetProperty()->SetColor(color);
81   volume->GetProperty()->SetScalarOpacity(opacity);
82 
83   VTK_CREATE(vtkRenderer, renderer);
84   renderer->AddVolume(volume);
85   renderer->SetBackground(1, 1, 1);
86 
87   renderer->ResetCamera();
88   vtkCamera *camera = renderer->GetActiveCamera();
89   camera->Azimuth(40.0);
90   camera->Elevation(40.0);
91 
92   VTK_CREATE(vtkRenderWindow, renwin);
93   renwin->SetSize(300, 300);
94   renwin->AddRenderer(renderer);
95 
96   VTK_CREATE(vtkRenderWindowInteractor, iren);
97   iren->SetRenderWindow(renwin);
98   renwin->Render();
99 
100   int retVal = vtkRegressionTestImage(renwin);
101   if (retVal == vtkRegressionTester::DO_INTERACTOR)
102     {
103     iren->Start();
104     retVal = vtkRegressionTester::PASSED;
105     }
106 
107   return (retVal != vtkRegressionTester::PASSED);
108 }
109