ITK  5.4.0
Insight Toolkit
SphinxExamples/src/Filtering/QuadEdgeMeshFiltering/ComputeNormalsOfAMesh/Code.cxx
/*=========================================================================
*
* Copyright NumFOCUS
*
* 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
*
* https://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.
*
*=========================================================================*/
#include "itkVector.h"
int
main(int argc, char * argv[])
{
if (argc < 2)
{
std::cerr << "Usage:" << std::endl;
std::cerr << argv[0] << "<InputFileName> <WeightType>" << std::endl;
std::cerr << "Weight type: " << std::endl;
std::cerr << " * 0: GOURAUD" << std::endl;
std::cerr << " * 1: THURMER" << std::endl;
std::cerr << " * 2: AREA" << std::endl;
return EXIT_FAILURE;
}
constexpr unsigned int Dimension = 3;
using CoordType = double;
using Traits =
auto reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
NormalFilterType::WeightEnum weight_type;
int param = std::stoi(argv[2]);
if ((param < 0) || (param > 2))
{
std::cerr << "Weight type must be either: " << std::endl;
std::cerr << " * 0: GOURAUD" << std::endl;
std::cerr << " * 1: THURMER" << std::endl;
std::cerr << " * 2: AREA" << std::endl;
return EXIT_FAILURE;
}
else
{
switch (param)
{
default:
case 0:
break;
case 1:
break;
case 2:
break;
}
}
auto normals = NormalFilterType::New();
normals->SetInput(reader->GetOutput());
normals->SetWeight(weight_type);
normals->Update();
OutputMeshType::Pointer output = normals->GetOutput();
OutputMeshType::PointsContainerPointer points = output->GetPoints();
OutputMeshType::PointsContainerIterator p_it = points->Begin();
OutputMeshType::PointDataContainerPointer container = output->GetPointData();
OutputMeshType::PointDataContainerIterator d_it = container->Begin();
std::cout << "Index * Point * Normal" << std::endl;
while (p_it != points->End())
{
std::cout << p_it.Index() << " * ";
std::cout << p_it.Value() << " * ";
std::cout << d_it.Value() << std::endl;
++p_it;
++d_it;
}
return EXIT_SUCCESS;
}
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::MeshFileReader
Mesh source that reads mesh data from a single file.
Definition: itkMeshFileReader.h:81
itk::GTest::TypedefsAndConstructors::Dimension2::VectorType
ImageBaseType::SpacingType VectorType
Definition: itkGTestTypedefsAndConstructors.h:53
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::NormalQuadEdgeMeshFilter
Filter which computes normals to faces and vertices and store it in the output mesh....
Definition: itkNormalQuadEdgeMeshFilter.h:93
itkQuadEdgeMeshExtendedTraits.h
itkMeshFileReader.h
itk::NormalQuadEdgeMeshFilterEnums::Weight::GOURAUD
itk::QuadEdgeMesh
Mesh class for 2D manifolds embedded in ND space.
Definition: itkQuadEdgeMesh.h:53
itk::QuadEdgeMeshExtendedTraits
Extended traits for a QuadEdgeMesh.
Definition: itkQuadEdgeMeshExtendedTraits.h:68
itk::NormalQuadEdgeMeshFilterEnums::Weight::AREA
itkQuadEdgeMesh.h
itkNormalQuadEdgeMeshFilter.h
itk::NormalQuadEdgeMeshFilterEnums::Weight::THURMER
itkVector.h
New
static Pointer New()
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44