This file is indexed.

/usr/share/vtk/Rendering/Cxx/MaterialObjects.cxx is in vtk-examples 5.8.0-17.5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    MaterialObjects.cxx

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
//
// This examples demonstrates the effect different materials.
//
#include "vtkTexturedSphereSource.h"
#include "vtkCubeSource.h"
#include "vtkCylinderSource.h"
#include "vtkPlaneSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkShaderProgram.h"
#include "vtkCamera.h"
#include "vtkLight.h"

#include <vtkstd/vector>



vtkActor* makeActor( const char* type, const char* material )
{
  if( !type && !material )
    {
    return NULL;
    }

  cout << "\t" << material << endl;
  vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();
  mapper->ImmediateModeRenderingOn();

  if( strcmp(type,"sphere")==0 )
    {
    vtkTexturedSphereSource *sphere = vtkTexturedSphereSource::New();
    sphere->SetThetaResolution(25);
    sphere->SetPhiResolution(25);
    mapper->SetInput(sphere->GetOutput());
    sphere->Delete();
    }
  else if( strcmp(type,"cube")==0 )
    {
    vtkCubeSource *cube= vtkCubeSource::New();
    mapper->SetInput(cube->GetOutput());
    cube->Delete();
    }
  else if( strcmp(type,"cylinder")==0 )
    {
    vtkCylinderSource *cylinder= vtkCylinderSource::New();
    mapper->SetInput(cylinder->GetOutput());
    cylinder->Delete();
    }
  else if( strcmp(type,"plane")==0 )
    {
    vtkPlaneSource *plane= vtkPlaneSource::New();
    mapper->SetInput(plane->GetOutput());
    plane->Delete();
    }


  vtkActor *actor = vtkActor::New();
  actor->GetProperty()->SetColor(1,0,0);
  actor->GetProperty()->SetAmbient(0.3);
  actor->GetProperty()->SetDiffuse(0.0);
  actor->GetProperty()->SetSpecular(1.0);
  actor->GetProperty()->SetSpecularPower(5.0);
  actor->GetProperty()->LoadMaterial( material );

  double appVar1[4] = {0.37714, 0.61465, 0.48399, 0.68252};
  double appVar2[4] = {0.03900, 0.15857, 0.57913, 0.54458};
  double appVar3[4] = {0.97061, 0.86053, 0.63583, 0.51058};
  double appVar4[4] = {0.12885, 0.91490, 0.86394, 0.58951};
  double appVar5[4] = {0.23403, 0.35340, 0.52559, 0.77830};
  double appVar6[4] = {0.19550, 0.17429, 0.89958, 0.15063};
  double appVar7[4] = {0.75796, 0.48072, 0.07728, 0.16434};

  actor->GetProperty()->AddShaderVariable("appVar1", 4, appVar1);
  actor->GetProperty()->AddShaderVariable("appVar2", 4, appVar2);
  actor->GetProperty()->AddShaderVariable("appVar3", 4, appVar3);
  actor->GetProperty()->AddShaderVariable("appVar4", 4, appVar4);
  actor->GetProperty()->AddShaderVariable("appVar5", 4, appVar5);
  actor->GetProperty()->AddShaderVariable("appVar6", 4, appVar6);
  actor->GetProperty()->AddShaderVariable("appVar7", 4, appVar7);

  actor->GetProperty()->ShadingOn();
  actor->SetMapper(mapper);

  mapper->Delete();

  return actor;

}

void gridLayoutActors( vtkstd::vector<vtkActor*> actors )
{
  if( (int)actors.size() <= 1 )
    {
    return;
    }

  double bounds[6] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};

  vtkstd::vector<vtkActor*>::iterator it = actors.begin();
  vtkstd::vector<vtkActor*>::iterator itEnd = actors.end();
  while( it != itEnd )
    {
    // move to the origin
    (*it)->SetPosition( 0.0, 0.0, 0.0 );
    double *b = (*it)->GetBounds();
    // X
    if( b[0]<bounds[0] ) bounds[0] = b[0];
    if( b[1]>bounds[1] ) bounds[1] = b[1];

    // Y
    if( b[2]<bounds[2] ) bounds[2] = b[2];
    if( b[3]>bounds[3] ) bounds[3] = b[3];

    // Z
    if( b[4]<bounds[4] ) bounds[4] = b[4];
    if( b[5]>bounds[5] ) bounds[5] = b[5];
    it++;
    }

  double step[3] = {1.25 * (bounds[1]-bounds[0]),
                    1.25 * (bounds[3]-bounds[2]),
                    1.25 * (bounds[5]-bounds[4])};


  double dim = ceil( pow( (double)actors.size(), 0.5 ) );
  for( int i=0; i<dim; i++ )
    {
    for( int j=0; j<dim; j++ )
      {
      int id = i*(int)dim+j;
      if( (id) < (int)actors.size() )
        {
#if 0
        if(i>0)
          {
          actors[id]->RotateX(15.0 * i );
          actors[id]->RotateY(15.0 * j);
          actors[id]->RotateZ(15.0);
          }
#endif
        actors[id]->AddPosition( i*step[0], j*step[1], 0.0 );
#if 0
        cout << id << " : ";
        cout << actors[id]->GetPosition()[0] << " , ";
        cout << actors[id]->GetPosition()[1] << " , "; 
        cout << actors[id]->GetPosition()[2] << endl;
#endif
        }
      }
#if 0
    cout << endl;
#endif
    }
}

int main(int argc, char* argv[])
{
#if 0
  if( argc == 1 )
    {
    cout << "Syntax: MaterialObjects obj0 material0 obj1 material1...objN materialN" << endl;
    cout << "\tobji may be one of : arrow - vtkArrowSource" << endl;
    cout << "                       cone - vtkConeSource" << endl;
    cout << "                       cube - vtkCubeSource" << endl;
    cout << "                       cylinder - vtkCylinderSource" << endl;
    cout << "                       disk - vtkDiskSource" << endl;
    cout << "                       line - vtkLineSource" << endl;
    cout << "                       plane - vtkPlaneSource" << endl;
    cout << "                       sphere - vtkSphereSource" << endl;
#if 0    cout << "                       superquadric - vtkSuperQuadricSource" << endl;
#endif
    cout << "                       plTetrahedron - vtkPlatonicSolidSource" << endl;
    cout << "                       plCube - vtkPlatonicSolidSource" << endl;
    cout << "                       plOctahedron - vtkPlatonicSolidSource" << endl;
    cout << "                       plIcosahedron - vtkPlatonicSolidSource" << endl;
    cout << "                       plDodecahedron - vtkPlatonicSolidSource" << endl;
    cout << "                       texturedSphere - vtkPlatonicSolidSource" << endl;
    cout << "                       superQuadratic - vtkPlatonicSolidSource" << endl;
    cout << "\tmateriali may be any material in VTK/Utilities/Materials." << endl;
    }
#endif

  cout << "Syntax: MaterialObjects material0 material1 ... materialn" << endl;
  cout << "Apply the nth material to the nth sphere, 0 <= n <= 7" << endl;

  vtkstd::vector<int> geom;
  vtkstd::vector<int> mat;
  int numActors = 0;
  int count=0;
  int i = 0;

  for( i=1; i<argc; i++ )
    {
    if( count==0 )
      {
      geom.push_back( i );
      numActors++;
      count++;
      }
    else if( count==1 )
      {
      mat.push_back( i );
      count = 0;
      }
    }

  vtkstd::vector<vtkActor*> actors;
  i = 0;
  for( i=0; i<numActors; i++ )
    {
    if( i < (int)geom.size() && i < (int)mat.size() )
      {
      if( geom[i] < argc && mat[i] < argc )
        {
        actors.push_back( makeActor(argv[geom[i]],argv[mat[i]]) );
        }
      }
    }

  // layout actore in a grid
  gridLayoutActors( actors );


  // Create the graphics structure. The renderer renders into the 
  // render window. The render window interactor captures mouse events
  // and will perform appropriate camera or actor manipulation
  // depending on the nature of the events.
  //
  vtkRenderer *ren1 = vtkRenderer::New();
  vtkRenderWindow *renWin = vtkRenderWindow::New();
  renWin->AddRenderer(ren1);
  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);

  // Add the actors to the renderer, set the background and size.
  vtkstd::vector<vtkActor*>::iterator it = actors.begin();
  vtkstd::vector<vtkActor*>::iterator itEnd = actors.end();
  while( it != itEnd )
    {
    ren1->AddActor(*it);
    it++;
    }

  ren1->SetBackground(0.1, 0.2, 0.4);
  renWin->SetSize(400, 200);

  // Set up the lighting.
  //
  vtkLight *light = vtkLight::New();
  light->SetFocalPoint(1.875,0.6125,0);
  light->SetPosition(0.875,1.6125,1);
  ren1->AddLight(light);

  vtkLight *light2 = vtkLight::New();
  light2->SetFocalPoint(1.875,0.6125,0);
  light2->SetPosition(0.875,1.6125,1);
  ren1->AddLight(light2);

  // We want to eliminate perspective effects on the apparent lighting.
  // Parallel camera projection will be used. To zoom in parallel projection
  // mode, the ParallelScale is set.
  //
  ren1->GetActiveCamera()->SetFocalPoint(0,0,0);
  ren1->GetActiveCamera()->SetPosition(0,0,1);
  ren1->GetActiveCamera()->SetViewUp(0,1,0);
  ren1->GetActiveCamera()->ParallelProjectionOff();
  ren1->ResetCamera();
#if 0
  ren1->GetActiveCamera()->SetParallelScale(1.5);
#endif
  
  // This starts the event loop and invokes an initial render.
  //
  iren->Initialize();
  iren->Start();

#if 0
  // Exiting from here, we have to delete all the instances that
  // have been created.
  //
  count = 0;
  it = actors.begin();
  while( it != itEnd )
    {
    cout << "Actor " << count << " : " << (*it)->GetPosition()[0] << ", "
                                       << (*it)->GetPosition()[1] << ", "
                                       << (*it)->GetPosition()[2] << endl;
    (*it)->Delete();
    it++;
    count++;
    }
#endif

  ren1->Delete();
  renWin->Delete();
  iren->Delete();
  light->Delete();

  return 0;
}