ITK  5.4.0
Insight Toolkit
SphinxExamples/src/Filtering/FastMarching/ComputeGeodesicDistanceOnMesh/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.
*
*=========================================================================*/
int
main(int argc, char * argv[])
{
if (argc != 3)
{
std::cerr << "Usage: " << argv[0] << std::endl;
std::cerr << " <input filename> <output filename>" << std::endl;
return EXIT_FAILURE;
}
using PixelType = float;
using CoordType = double;
constexpr unsigned int Dimension = 3;
using Traits = itk::QuadEdgeMeshExtendedTraits<PixelType, // type of data for vertices
Dimension, // geometrical dimension of space
2, // Mac topological dimension of a cell
CoordType, // type for point coordinate
CoordType, // type for interpolation weight
PixelType, // type of data for cell
bool, // type of data for primal edges
bool // type of data for dual edges
>;
using ReaderType = itk::MeshFileReader<MeshType>;
auto reader = ReaderType::New();
reader->SetFileName(argv[1]);
MeshType::Pointer mesh = reader->GetOutput();
MeshType::PointsContainerConstPointer points = mesh->GetPoints();
MeshType::PointsContainerConstIterator pIt = points->Begin();
MeshType::PointsContainerConstIterator pEnd = points->End();
while (pIt != pEnd)
{
mesh->SetPointData(pIt->Index(), 1.);
++pIt;
}
using NodePairType = FastMarchingType::NodePairType;
using NodePairContainerType = FastMarchingType::NodePairContainerType;
NodePairType nodePair(0, 0.);
trial->push_back(nodePair);
auto criterion = CriterionType::New();
criterion->SetThreshold(100.);
auto fmmFilter = FastMarchingType::New();
fmmFilter->SetInput(mesh);
fmmFilter->SetTrialPoints(trial);
fmmFilter->SetStoppingCriterion(criterion);
using WriterType = itk::MeshFileWriter<MeshType>;
auto writer = WriterType::New();
writer->SetInput(fmmFilter->GetOutput());
writer->SetFileName(argv[2]);
try
{
writer->Update();
}
catch (const itk::ExceptionObject & error)
{
std::cerr << "Error: " << error << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itkRegularSphereMeshSource.h
itk::MeshFileWriter
Writes mesh data to a single file.
Definition: itkMeshFileWriter.h:52
itk::MeshFileReader
Mesh source that reads mesh data from a single file.
Definition: itkMeshFileReader.h:81
itkFastMarchingThresholdStoppingCriterion.h
itkFastMarchingQuadEdgeMeshFilterBase.h
itkQuadEdgeMeshExtendedTraits.h
itkMeshFileReader.h
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::FastMarchingThresholdStoppingCriterion
Stopping Criterion is verified when Current Value is equal to or greater than the provided threshold.
Definition: itkFastMarchingThresholdStoppingCriterion.h:35
itk::FastMarchingQuadEdgeMeshFilterBase
Fast Marching Method on QuadEdgeMesh.
Definition: itkFastMarchingQuadEdgeMeshFilterBase.h:45
New
static Pointer New()
itkMeshFileWriter.h
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44