Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
44dbc2d
ENH: Initial commit
thewtex Feb 18, 2019
b711d29
ENH: Remove unused classes
thewtex Feb 19, 2019
784755b
ENH: Add cow.vtk test input
thewtex Feb 24, 2019
4154003
ENH: Filter inherits from ProcessObject
thewtex Feb 24, 2019
41cd9bd
ENH: Add SetInput
thewtex Feb 25, 2019
6eae1ab
BUG: Fix wrapping template types
thewtex Feb 25, 2019
2e05008
Merge pull request #2 from thewtex/to-polydata
thewtex Feb 25, 2019
16388cd
ENH: Start PolyData class
thewtex Mar 25, 2019
bcc0374
ENH: Start PolyData::PrintSelf
thewtex Mar 25, 2019
869498f
ENH: Add PolyData Point and PointData
thewtex Mar 25, 2019
5f57a54
ENH: Add PolyData wrapping
thewtex Mar 26, 2019
772825a
Merge pull request #4 from thewtex/to-polydata
thewtex Mar 26, 2019
28a0da5
ENH: Add CellData to PolyData
thewtex Mar 26, 2019
4df109b
Merge pull request #5 from thewtex/celldata
thewtex Mar 26, 2019
b081904
ENH: Add PolyData cell members
thewtex Mar 29, 2019
ccc8951
Merge pull request #6 from thewtex/polydata-cells
thewtex Mar 29, 2019
4ebe3ab
ENH: Add MeshToPolyDataFilter::GetOutput
thewtex Mar 31, 2019
08027c2
Merge pull request #7 from thewtex/polydata-output
thewtex Mar 31, 2019
7d2df65
ENH: MeshToPolyData points and point data
thewtex May 26, 2019
93eb251
ENH: MeshToPolyData transform cells and cell data
thewtex Jun 25, 2019
5c962c9
Merge pull request #8 from thewtex/mesh-to-polydata
thewtex Jun 26, 2019
471dee5
STYLE: Move Python tests into wrapping/test/CMakeLists.txt
thewtex Jul 6, 2019
d475dc1
ENH: Convert itk.VectorContainer's to NumPy array's
thewtex Jul 6, 2019
43cda60
Merge pull request #10 from thewtex/py-vectorcontainer-buffer
thewtex Jul 6, 2019
5e17f72
ENH: Convert VectorContainer of itk.Point to NumPy Array
thewtex Jul 8, 2019
3852e36
Merge pull request #13 from thewtex/vectorcontainer-point-numpy
thewtex Jul 8, 2019
ebc5f14
BUG: Retain Points shape when converting to NumPy array
thewtex Jul 8, 2019
e940078
Merge pull request #14 from thewtex/Points-shape
thewtex Jul 8, 2019
46ad8ac
BUG: Only process mesh cells when present
thewtex Jul 8, 2019
0922c62
Merge pull request #15 from thewtex/accept-mesh-cells
thewtex Jul 8, 2019
0370ad9
BUG: Check inputCellData Size
thewtex Jul 9, 2019
89843ca
Merge pull request #16 from thewtex/accept-mesh-cells
thewtex Jul 9, 2019
aeeabc1
BUG: Wrap PyVectorContainer for unsigned int
thewtex Jul 9, 2019
a4a1fd9
Merge pull request #17 from thewtex/wrap-unsigned-int
thewtex Jul 9, 2019
de1e82a
ENH: Import ImageToPointSetFilter from ITKBSplineGradient module
thewtex Sep 10, 2019
14a7a7a
Merge pull request #19 from thewtex/image-to-pointset
thewtex Sep 10, 2019
2b6411e
ENH: Wrap MeshToPolyDataFilter for PointSet's
thewtex Sep 10, 2019
cad21e1
Merge pull request #21 from thewtex/point-set-to-polydata
thewtex Sep 11, 2019
f09b94c
COMP: build with legacy off
dzenanz Mar 6, 2020
3634a23
DOC: Copyright assignment to NumFOCUS
thewtex Mar 10, 2020
590d116
Merge pull request #26 from thewtex/itk-5.1rc02-ci
thewtex Mar 11, 2020
51da24e
ENH: Remove PyVectorContainer classes due to ITK integration
tbirdso Mar 16, 2021
5afb325
Merge pull request #35 from tbirdso/update-ci
thewtex Mar 17, 2021
868026a
ENH: Add itkPolyDataToMeshFilter
tbirdso Mar 15, 2021
1d6d9df
Merge pull request #37 from tbirdso/itkpolytomesh
thewtex Apr 6, 2021
a017028
ENH: Support distinct CellData pixel type
thewtex Dec 1, 2021
269bafa
BUG: Do not access PolyData components wehn not available
thewtex Dec 1, 2021
c121ad1
Merge pull request #40 from thewtex/cell-data-type
thewtex Dec 2, 2021
6371ff3
COMP: Remove shadowing numPoints
thewtex Jan 6, 2022
6f9c1b7
COMP: Address unused outputPolyDataFileName
thewtex Jan 6, 2022
7b15ca6
Merge pull request #42 from thewtex/shadow-variables
thewtex Jan 6, 2022
f2fc081
COMP: Remove unused variables
thewtex Mar 8, 2022
c144b25
Merge pull request #43 from thewtex/unused-variables
thewtex Mar 8, 2022
3a7952e
ENH: Bump ITK and replace http with https using script
tbirdso May 31, 2022
cb90409
ENH: Adding changes for itk::PolyLineCell
PranjalSahu Apr 22, 2022
189be74
ENH: Adding test for itk::PolyLineCell
PranjalSahu Apr 22, 2022
e83fc56
ENH: Adding Python test for itk::PolyLineCell conversion
PranjalSahu May 10, 2022
49a06b1
Merge pull request #44 from PranjalSahu/pranjal
thewtex Sep 12, 2022
138c0ef
ENH: Move wasm/ to top level
thewtex Feb 14, 2023
ea0a662
Merge pull request #55 from PaulHax/wasm
thewtex Feb 14, 2023
d1c3436
DOC: Lines to Vertices in method description
thewtex May 19, 2024
d88ebee
COMP: ITK_DISALLOW_COPY_AND_ASSIGN -> ITK_DISALLOW_COPY_AND_MOVE
dzenanz Aug 20, 2024
b8ee47c
Merge pull request #70 from InsightSoftwareConsortium/copyMoveDisable
thewtex Aug 20, 2024
200888d
STYLE: Add itkVirtualGetNameOfClassMacro + itkOverrideGetNameOfClassM…
hjmjohnson Jan 26, 2025
ae54dc9
STYLE: Replace itkStaticConstMacro with static constexpr
hjmjohnson Jan 26, 2025
53d1724
STYLE: CoordRepType -> CoordinateType code readability
hjmjohnson Jan 26, 2025
746c40a
STYLE: Update to match clang-format-19 from ITK
hjmjohnson Jan 27, 2025
020e434
STYLE: Fix KWStyleError
hjmjohnson Mar 9, 2025
5872a98
COMP: Provide backwards compatible CoordRepType in itk::PolyData
thewtex Mar 11, 2025
a648b2c
Merge pull request #78 from InsightSoftwareConsortium/version-0.11.1
thewtex Mar 11, 2025
0ceb0ae
COMP: Bump to minimum CMake 3.16.3
jhlegarreta Mar 11, 2025
3982675
STYLE: Update clang-format to match ITK 2025-11-10
hjmjohnson Nov 10, 2025
6111bb3
ENH: Convert from md5 to .cid tags.
hjmjohnson Apr 22, 2026
4414194
ENH: Ingest ITKMeshToPolyData into Modules/Filtering
hjmjohnson May 26, 2026
13a553b
COMP: Adapt MeshToPolyData itk-module.cmake for in-tree build
hjmjohnson May 26, 2026
de79456
COMP: Remove MeshToPolyData.remote.cmake; now in-tree
hjmjohnson May 26, 2026
6ac982a
ENH: Enable MeshToPolyData in CI via configure-ci
hjmjohnson May 26, 2026
71206d4
STYLE: Apply ITK pre-commit formatting to ingested MeshToPolyData
hjmjohnson May 26, 2026
70aa39c
BUG: Write itkMeshToPolyDataFilterTest output to argv[2]
hjmjohnson May 26, 2026
1d7d59f
BUG: Guard against triangle-strip point-count underflow
hjmjohnson May 26, 2026
9c63063
BUG: Stop cell point-copy loops at the cell container end
hjmjohnson May 26, 2026
8dcd52b
BUG: Reset all cell containers in PolyData::Initialize
hjmjohnson May 26, 2026
7932342
BUG: Initialize VisitCellsClass cell-container pointers
hjmjohnson May 26, 2026
fdf3a40
BUG: Guard cell-data copy against sparse input cell data
hjmjohnson May 26, 2026
868f6cc
BUG: Use SizeValueType for ImageToPointSetFilter pixel count
hjmjohnson May 26, 2026
f3fae5d
STYLE: Use unsigned point count in PolyLine Visit
hjmjohnson May 26, 2026
bcb48b9
STYLE: Default ImageToPointSetFilter special members
hjmjohnson May 26, 2026
e43b8e9
COMP: Gate itkPolyLineCellTest on numpy availability
hjmjohnson May 26, 2026
7017bc7
COMP: Drop dead wasm subdirectory from MeshToPolyData build
hjmjohnson May 26, 2026
035bb59
STYLE: Modernize HasCellTraits with std::void_t
hjmjohnson May 26, 2026
c2c78fc
BUG: Size cell-id containers with reserve, not Reserve
hjmjohnson May 26, 2026
cb28438
ENH: Add cell-data round-trip regression test
hjmjohnson May 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Modules/Filtering/MeshToPolyData/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.16.3)
project(MeshToPolyData)

if(NOT ITK_SOURCE_DIR)
find_package(ITK REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR})
include(ITKModuleExternal)
else()
set(ITK_DIR ${CMAKE_BINARY_DIR})
itk_module_impl()
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*=========================================================================
*
* 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.
*
*=========================================================================*/
#ifndef itkImageToPointSetFilter_h
#define itkImageToPointSetFilter_h

#include "itkImageToMeshFilter.h"

namespace itk
{
/** \class ImageToPointSetFilter
*
* \brief Convert an Image to a PointSet.
*
* This class provides default where every pixel in an Image is converted to a
* point in the output PointSet.
*
* This class inherits from ImageToMeshFilter, but no topological information is
* added to the mesh.
*
* \ingroup MeshToPolyData
*/
template <typename TInputImage, typename TOutputMesh>
class ITK_TEMPLATE_EXPORT ImageToPointSetFilter : public ImageToMeshFilter<TInputImage, TOutputMesh>
{
public:
ITK_DISALLOW_COPY_AND_MOVE(ImageToPointSetFilter);

/** Standard class type alias. */
using Self = ImageToPointSetFilter;
using Superclass = ImageToMeshFilter<TInputImage, TOutputMesh>;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;

/** Method for creation through the object factory. */
itkNewMacro(Self);

/** Run-time type information (and related methods). */
itkOverrideGetNameOfClassMacro(ImageToPointSetFilter);

/** Some convenient type alias. */
using InputImageType = TInputImage;
using InputImageConstPointer = typename InputImageType::ConstPointer;
using InputImageRegionType = typename InputImageType::RegionType;
using InputImagePixelType = typename InputImageType::PixelType;

/** Some type alias associated with the output mesh. */
using OutputMeshType = TOutputMesh;
using PointType = typename OutputMeshType::PointType;
using OutputMeshPointer = typename OutputMeshType::Pointer;
using PointsContainer = typename OutputMeshType::PointsContainer;
using PointIdentifier = typename OutputMeshType::PointIdentifier;
using PointsContainerPointer = typename PointsContainer::Pointer;
using PointsContainerIterator = typename PointsContainer::Iterator;
using PointDataContainer = typename OutputMeshType::PointDataContainer;
using PointDataContainerPointer = typename PointDataContainer::Pointer;
using PointDataContainerIterator = typename PointDataContainer::Iterator;

/** The dimension of the output mesh. */
static constexpr unsigned int PointDimension = TOutputMesh::PointDimension;

/** ImageDimension constant */
static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;

protected:
ImageToPointSetFilter() = default;
~ImageToPointSetFilter() override = default;

void
GenerateData() override;
};

} // end namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
# include "itkImageToPointSetFilter.hxx"
#endif

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*=========================================================================
*
* 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.
*
*=========================================================================*/
#ifndef itkImageToPointSetFilter_hxx
#define itkImageToPointSetFilter_hxx

#include "itkImageToPointSetFilter.h"

#include "itkImageRegionConstIteratorWithIndex.h"
#include "itkProgressReporter.h"

namespace itk
{

template <typename TInputImage, typename TOutputMesh>
void
ImageToPointSetFilter<TInputImage, TOutputMesh>::GenerateData()
{
// " from itkBinaryMask3DMeshSource:
// This indicates that the current BufferedRegion is equal to the
// requested region. This action prevents useless rexecutions of
// the pipeline.
this->GetOutput()->SetBufferedRegion(this->GetOutput()->GetRequestedRegion());

OutputMeshPointer mesh = this->GetOutput();
PointsContainerPointer points = mesh->GetPoints();
InputImageConstPointer image = this->GetInput(0);

PointDataContainerPointer pointData;
if (mesh->GetPointData())
{
pointData = mesh->GetPointData();
}
else
{ // Create
pointData = PointDataContainer::New();
}

const SizeValueType numberOfPixels = image->GetRequestedRegion().GetNumberOfPixels();
ProgressReporter progress(this, 0, numberOfPixels);
points->Reserve(numberOfPixels);
pointData->Reserve(numberOfPixels);
mesh->SetPointData(pointData.GetPointer());

typename itk::ImageRegionConstIteratorWithIndex<InputImageType> imageIt(image, image->GetRequestedRegion());
imageIt.GoToBegin();
PointsContainerIterator pointsIt = points->Begin();
PointDataContainerIterator pointDataIt = pointData->Begin();
while (!imageIt.IsAtEnd())
{
image->TransformIndexToPhysicalPoint(imageIt.GetIndex(), pointsIt.Value());
(pointDataIt.Value()) = imageIt.Get();
++pointsIt;
++pointDataIt;
++imageIt;
progress.CompletedPixel();
}
}

} // end namespace itk

#endif
132 changes: 132 additions & 0 deletions Modules/Filtering/MeshToPolyData/include/itkMeshToPolyDataFilter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*=========================================================================
*
* 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.
*
*=========================================================================*/
#ifndef itkMeshToPolyDataFilter_h
#define itkMeshToPolyDataFilter_h

#include "itkProcessObject.h"
#include "itkPolyData.h"

#include <type_traits>

namespace itk
{

template <typename TInputType, typename = void>
struct HasCellTraits : std::false_type
{};

template <typename TInputType>
struct HasCellTraits<TInputType, std::void_t<typename TInputType::CellTraits>> : std::true_type
{};

/** \class MeshToPolyDataFilter
*
* \brief Convert a PointSet or Mesh to PolyData
*
* Convert an itk::PointSet or itk::Mesh to an itk::PolyData for visualization
* with vtk.js.
*
* Currently support ITK cell types:
*
* - itk::VertexCell
* - itk::LineCell
* - itk::TriangleCell
* - itk::QuadrilateralCell
* - itk::PolygonCell
*
* \ingroup MeshToPolyData
*
*/
template <typename TInputMesh>
class MeshToPolyDataFilter : public ProcessObject
{
public:
ITK_DISALLOW_COPY_AND_MOVE(MeshToPolyDataFilter);

static constexpr unsigned int PointDimension = TInputMesh::PointDimension;

using InputMeshType = TInputMesh;

/** Standard class typedefs. */
using Self = MeshToPolyDataFilter<InputMeshType>;
using Superclass = ProcessObject;
using Pointer = SmartPointer<Self>;
using ConstPointer = SmartPointer<const Self>;

using PolyDataType = PolyData<typename InputMeshType::PixelType>;

/** Run-time type information. */
itkOverrideGetNameOfClassMacro(MeshToPolyDataFilter);

/** Standard New macro. */
itkNewMacro(Self);

/** Set the mesh input of this process object. */
using Superclass::SetInput;
void
SetInput(const InputMeshType * input);

/** Get the mesh input of this process object. */
const InputMeshType *
GetInput() const;

const InputMeshType *
GetInput(unsigned int idx) const;

PolyDataType *
GetOutput();
const PolyDataType *
GetOutput() const;

PolyDataType *
GetOutput(unsigned int idx);

protected:
MeshToPolyDataFilter();
~MeshToPolyDataFilter() override = default;

void
PrintSelf(std::ostream & os, Indent indent) const override;

void
GenerateData() override;

template <typename TInputMeshDispatch,
typename std::enable_if<!HasCellTraits<TInputMeshDispatch>::value, int>::type = 0>
void
GenerateDataDispatch();

template <typename TInputMeshDispatch,
typename std::enable_if<HasCellTraits<TInputMeshDispatch>::value, int>::type = 0>
void
GenerateDataDispatch();

ProcessObject::DataObjectPointer
MakeOutput(ProcessObject::DataObjectPointerArraySizeType idx) override;
ProcessObject::DataObjectPointer
MakeOutput(const ProcessObject::DataObjectIdentifierType &) override;

private:
};
} // namespace itk

#ifndef ITK_MANUAL_INSTANTIATION
# include "itkMeshToPolyDataFilter.hxx"
#endif

#endif // itkMeshToPolyDataFilter
Loading
Loading