This file is indexed.

/usr/include/ITK-4.5/itkSphereMeshSource.hxx is in libinsighttoolkit4-dev 4.5.0-3.

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
/*=========================================================================
 *
 *  Copyright Insight Software Consortium
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0.txt
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *=========================================================================*/
#ifndef __itkSphereMeshSource_hxx
#define __itkSphereMeshSource_hxx

#include "itkIntTypes.h"
#include "itkSphereMeshSource.h"

namespace itk
{
/**
 *
 */
template< typename TOutputMesh >
SphereMeshSource< TOutputMesh >
::SphereMeshSource()
{
  /**
   * Create the output
   */
  typename TOutputMesh::Pointer output = TOutputMesh::New();
  this->ProcessObject::SetNumberOfRequiredOutputs(1);
  this->ProcessObject::SetNthOutput( 0, output.GetPointer() );
  m_Squareness1 = 1.0;
  m_Squareness2 = 1.0;
  m_Center.Fill(0);
  m_Scale.Fill(1);
  m_ResolutionX = 4;
  m_ResolutionY = 4;
}

/*
 *
 */
template< typename TOutputMesh >
void
SphereMeshSource< TOutputMesh >
::GenerateData()
{
  IdentifierType i, j, jn, p, numpts;
  double        ustep, vstep, ubeg, vbeg, u, v;
  int           signu, signv;

  // calculate the number os cells and points
  numpts = m_ResolutionX * m_ResolutionY + 2;

  // calculate the steps using resolution
  ustep = vnl_math::pi / ( m_ResolutionX + 1 );
  vstep = 2.0 * vnl_math::pi / m_ResolutionY;
  ubeg = ( -vnl_math::pi / 2.0 ) + ustep;
  vbeg = -vnl_math::pi;

  ///////////////////////////////////////////////////////////////////////////
  // nodes allocation

  // the temporary container of nodes' connectness
  typename OutputMeshType::PointIdentifier tripoints[3] = { 0, 1, 2 };

  // memory allocation for nodes
  typename OutputMeshType::Pointer outputMesh = this->GetOutput();

  outputMesh->GetPoints()->Reserve(numpts);

  outputMesh->SetCellsAllocationMethod(OutputMeshType::CellsAllocatedDynamicallyCellByCell);

  PointsContainerPointer myPoints = outputMesh->GetPoints();
  typename PointsContainer::Iterator point = myPoints->Begin();

  OPointType p1;

  // calculate all regular nodes
  while ( point != myPoints->End() )
    {
    for ( u = ubeg, i = 0; i < m_ResolutionX; u += ustep, i++ )
      {
      for ( v = vbeg, j = 0; j < m_ResolutionY; v += vstep, j++ )
        {
        if ( vcl_cos(u) > 0 )
          {
          signu = 1;
          }
        else
          {
          signu = -1;
          }
        if ( vcl_cos(v) > 0 )
          {
          signv = 1;
          }
        else
          {
          signv = -1;
          }

        p1[0] = m_Scale[0] * signu * ( vcl_pow( (float)( vcl_fabs( vcl_cos(u) ) ), (float)m_Squareness1 ) ) * signv
                * ( vcl_pow( (float)( vcl_fabs( vcl_cos(v) ) ), (float)m_Squareness2 ) ) + m_Center[0];

        if ( vcl_sin(v) > 0 )
          {
          signv = 1;
          }
        else
          {
          signv = -1;
          }

        p1[1] = m_Scale[1] * signu * ( vcl_pow( (float)( vcl_fabs( vcl_cos(u) ) ), (float)m_Squareness1 ) ) * signv
                * ( vcl_pow( (float)( vcl_fabs( vcl_sin(v) ) ), (float)m_Squareness2 ) ) + m_Center[1];

        if ( vcl_sin(u) > 0 )
          {
          signu = 1;
          }
        else
          {
          signu = -1;
          }

        p1[2] = m_Scale[2] * signu * ( vcl_pow( (float)( vcl_fabs( vcl_sin(u) ) ), (float)m_Squareness1 ) )
                + m_Center[2];

        point.Value() = p1;
        ++point;
        }
      }

    // calculate the south pole node
    p1[0] = ( m_Scale[0] * ( vcl_pow( (float)( vcl_fabs( vcl_cos(-vnl_math::pi / 2) ) ), 1.0f ) )
              * ( vcl_pow( (float)( vcl_fabs( vcl_cos(0.0) ) ), 1.0f ) ) + m_Center[0] );
    p1[1] = ( m_Scale[1] * ( vcl_pow( (float)( vcl_fabs( vcl_cos(-vnl_math::pi / 2) ) ), 1.0f ) )
              * ( vcl_pow( (float)( vcl_fabs( vcl_sin(0.0) ) ), 1.0f ) ) + m_Center[1] );
    p1[2] = ( m_Scale[2] * -1 * ( vcl_pow( (float)( vcl_fabs( vcl_sin(-vnl_math::pi / 2) ) ), 1.0f ) )
              + m_Center[2] );
    point.Value() = p1;
    ++point;

    // calculate the north pole node
    p1[0] = ( m_Scale[0] * ( vcl_pow( (float)( vcl_fabs( vcl_cos(vnl_math::pi / 2) ) ), 1.0f ) )
              * ( vcl_pow(vcl_fabs( vcl_cos(0.0) ), 1.0) ) + m_Center[0] );
    p1[1] = ( m_Scale[1] * ( vcl_pow( (float)( vcl_fabs( vcl_cos(vnl_math::pi / 2) ) ), 1.0f ) )
              * ( vcl_pow(vcl_fabs( vcl_sin(0.0) ), 1.0) ) + m_Center[1] );
    p1[2] = ( m_Scale[2] * ( vcl_pow( (float)( vcl_fabs( vcl_sin(vnl_math::pi / 2) ) ), 1.0f ) )
              + m_Center[2] );
    point.Value() = p1;
    ++point;
    }

  ///////////////////////////////////////////////////////////////////////////
  // cells allocation
  p = 0;

  // store all regular cells
  CellAutoPointer testCell;
  for ( unsigned int ii = 0; ii + 1 < m_ResolutionX; ii++ )
    {
    for ( unsigned int jj = 0; jj < m_ResolutionY; jj++ )
      {
      jn = ( jj + 1 ) % m_ResolutionY;
      tripoints[0] = ii * m_ResolutionY + jj;
      tripoints[1] = tripoints[0] - jj + jn;
      tripoints[2] = tripoints[0] + m_ResolutionY;
      testCell.TakeOwnership(new TriCellType);
      testCell->SetPointIds(tripoints);
      outputMesh->SetCell(p, testCell);
      outputMesh->SetCellData(p, (OPixelType)3.0);
      p++;
      testCell.TakeOwnership(new TriCellType);
      tripoints[0] = tripoints[1];
      tripoints[1] = tripoints[0] + m_ResolutionY;
      testCell->SetPointIds(tripoints);
      outputMesh->SetCell(p, testCell);
      outputMesh->SetCellData(p, (OPixelType)3.0);
      p++;
      }
    }

  // store cells containing the south pole nodes
  for ( unsigned int jj = 0; jj < m_ResolutionY; jj++ )
    {
    jn = ( jj + 1 ) % m_ResolutionY;
    tripoints[0] = numpts - 2;
    tripoints[1] = jn;
    tripoints[2] = jj;
    testCell.TakeOwnership(new TriCellType);
    testCell->SetPointIds(tripoints);
    outputMesh->SetCell(p, testCell);
    outputMesh->SetCellData(p, (OPixelType)1.0);
    p++;
    }

  // store cells containing the north pole nodes
  for ( unsigned int jj = 0; jj < m_ResolutionY; jj++ )
    {
    jn = ( jj + 1 ) % m_ResolutionY;
    tripoints[2] = ( m_ResolutionX - 1 ) * m_ResolutionY + jj;
    tripoints[1] = numpts - 1;
    tripoints[0] = tripoints[2] - jj + jn;
    testCell.TakeOwnership(new TriCellType);
    testCell->SetPointIds(tripoints);
    outputMesh->SetCell(p, testCell);
    outputMesh->SetCellData(p, (OPixelType)2.0);
    p++;
    }
}

template< typename TOutputMesh >
void
SphereMeshSource< TOutputMesh >
::PrintSelf(std::ostream & os, Indent indent) const
{
  Superclass::PrintSelf(os, indent);

  os << indent << "Center: " << m_Center << std::endl;
  os << indent << "Scale: " << m_Scale << std::endl;
  os << indent << "ResolutionX: " << m_ResolutionX << std::endl;
  os << indent << "ResolutionX: " << m_ResolutionY << std::endl;
  os << indent << "Squareness1: " << m_Squareness1 << std::endl;
  os << indent << "Squareness2: " << m_Squareness2 << std::endl;
}
} // end namespace itk

#endif