<commit_before>/*=========================================================================
 *
 *  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 __itkMeshSpatialObject_hxx
#define __itkMeshSpatialObject_hxx

#include "itkMeshSpatialObject.h"
#include "itkSize.h"

namespace itk
{
/** Constructor */
template< class TMesh >
MeshSpatialObject< TMesh >
::MeshSpatialObject()
{
  this->SetTypeName("MeshSpatialObject");
  m_Mesh = MeshType::New();
  this->ComputeBoundingBox();
  m_PixelType = typeid( typename TMesh::PixelType ).name();
  m_IsInsidePrecision = 1;
}

/** Destructor */
template< class TMesh >
MeshSpatialObject< TMesh >
::~MeshSpatialObject()
{}

/** Return true if the given point is inside the Mesh */
template< class TMesh >
bool
MeshSpatialObject< TMesh >
::IsEvaluableAt(const PointType & point,
                unsigned int depth, char *name) const
{
  return IsInside(point, depth, name);
}

/** Test whether a point is inside or outside the object
 *  For computational speed purposes, it is faster if the method does not
 *  check the name of the class and the current depth */
template< class TMesh >
bool
MeshSpatialObject< TMesh >
::IsInside(const PointType & point) const
{
  if ( !this->SetInternalInverseTransformToWorldToIndexTransform() )
    {
    return false;
    }

  PointType transformedPoint =
    this->GetInternalInverseTransform()->TransformPoint(point);

  if ( this->GetBounds()->IsInside(transformedPoint) )
    {
    typename MeshType::CellsContainerPointer cells =  m_Mesh->GetCells();
    typename MeshType::CellsContainer::ConstIterator it = cells->Begin();
    while ( it != cells->End() )
      {
      typename MeshType::CoordRepType
      position[itkGetStaticConstMacro(Dimension)];
      for ( unsigned int i = 0; i < itkGetStaticConstMacro(Dimension); i++ )
        {
        position[i] = transformedPoint[i];
        }

      // If this is a triangle cell we need to check the distance
      if ( it.Value()->GetNumberOfPoints() == 3 )
        {
        double minDist;
        if ( it.Value()->EvaluatePosition(position, m_Mesh->GetPoints(),
                                          NULL, NULL, &minDist, NULL)  &&
             minDist <= m_IsInsidePrecision )
          {
          return true;
          }
        }
      else
        {
        if ( it.Value()->EvaluatePosition(position, m_Mesh->GetPoints(),
                                          NULL, NULL, NULL, NULL) )
          {
          return true;
          }
        }
      ++it;
      }
    }
  return false;
}

/** Return true if the given point is inside the Mesh */
template< class TMesh >
bool<commit_msg>BUG: Uninitialized variable.<commit_after>/*=========================================================================
 *
 *  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 __itkMeshSpatialObject_hxx
#define __itkMeshSpatialObject_hxx

#include "itkMeshSpatialObject.h"
#include "itkSize.h"

namespace itk
{
/** Constructor */
template< class TMesh >
MeshSpatialObject< TMesh >
::MeshSpatialObject()
{
  this->SetTypeName("MeshSpatialObject");
  m_Mesh = MeshType::New();
  this->ComputeBoundingBox();
  m_PixelType = typeid( typename TMesh::PixelType ).name();
  m_IsInsidePrecision = 1;
}

/** Destructor */
template< class TMesh >
MeshSpatialObject< TMesh >
::~MeshSpatialObject()
{}

/** Return true if the given point is inside the Mesh */
template< class TMesh >
bool
MeshSpatialObject< TMesh >
::IsEvaluableAt(const PointType & point,
                unsigned int depth, char *name) const
{
  return IsInside(point, depth, name);
}

/** Test whether a point is inside or outside the object
 *  For computational speed purposes, it is faster if the method does not
 *  check the name of the class and the current depth */
template< class TMesh >
bool
MeshSpatialObject< TMesh >
::IsInside(const PointType & point) const
{
  if ( !this->SetInternalInverseTransformToWorldToIndexTransform() )
    {
    return false;
    }

  PointType transformedPoint =
    this->GetInternalInverseTransform()->TransformPoint(point);

  if ( this->GetBounds()->IsInside(transformedPoint) )
    {
    typename MeshType::CellsContainerPointer cells =  m_Mesh->GetCells();
    typename MeshType::CellsContainer::ConstIterator it = cells->Begin();
    while ( it != cells->End() )
      {
      typedef typename MeshType::CoordRepType CoordRepType;
      CoordRepType position[Dimension];
      for ( unsigned int i = 0; i < Dimension; i++ )
        {
        position[i] = transformedPoint[i];
        }

      // If this is a triangle cell we need to check the distance
      if ( it.Value()->GetNumberOfPoints() == 3 )
        {
        double minDist = 0.0;
        const bool pointIsInside = it.Value()->EvaluatePosition(
          position, m_Mesh->GetPoints(), NULL, NULL, &minDist, NULL);

        if ( pointIsInside  && minDist <= this->m_IsInsidePrecision )
          {
          return true;
          }
        }
      else
        {
        if ( it.Value()->EvaluatePosition(position, m_Mesh->GetPoints(),
                                          NULL, NULL, NULL, NULL) )
          {
          return true;
          }
        }
      ++it;
      }
    }
  return false;
}

/** Return true if the given point is inside the Mesh */
template< class TMesh >
bool
{'fraction_non_alphanumeric': 0.14281387248220506, 'fraction_numerical': 0.002423140996516735, 'mean_word_length': 3.0440906307409676, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 52, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2558720', 'n_tokens_mistral': 1875, 'n_tokens_neox': 1813, 'n_words': 564}