7 #include "fwGdcmIO/container/DicomSurface.hpp" 9 #include "fwGdcmIO/exception/Failed.hpp" 11 #include <fwDataTools/helper/Array.hpp> 12 #include <fwDataTools/Mesh.hpp> 23 ::fwData::Mesh::CellDataOffsetType current;
31 ::fwData::Mesh::CellDataOffsetType operator()()
33 ::fwData::Mesh::CellDataOffsetType res = current;
43 ::fwData::Mesh::csptr mesh = reconstruction->getMesh();
51 m_pointBuffer.reserve(mesh->getNumberOfPoints() * 3);
52 m_pointBuffer.assign(pointsArrayHelper.begin< ::fwData::Mesh::PointValueType >(),
53 pointsArrayHelper.end< ::fwData::Mesh::PointValueType >());
60 m_cellBuffer.resize(mesh->getNumberOfCells() * 3);
62 std::size_t index = 0;
63 for(
auto cellIt = cellDataHelper.begin< ::fwData::Mesh::CellValueType >();
64 cellIt != cellDataHelper.end< ::fwData::Mesh::CellValueType >();
73 if (mesh->getPointNormalsArray())
77 m_normalBuffer.reserve(mesh->getNumberOfPoints() * 3);
78 m_normalBuffer.assign(normalsArrayHelper.begin< ::fwData::Mesh::NormalValueType >(),
79 normalsArrayHelper.end< ::fwData::Mesh::NormalValueType >());
87 const ::fwData::Mesh::Id pointBufferSize,
89 const ::fwData::Mesh::Id cellBufferSize,
90 const ::fwData::Mesh::NormalValueType* normalBuffer)
93 m_pointBuffer.reserve(pointBufferSize);
94 m_pointBuffer.assign(pointBuffer, pointBuffer + pointBufferSize);
97 m_cellBuffer.reserve(cellBufferSize);
98 m_cellBuffer.assign(cellBuffer, cellBuffer + cellBufferSize);
103 m_normalBuffer.reserve(pointBufferSize);
104 m_normalBuffer.assign(normalBuffer, normalBuffer + pointBufferSize);
119 ::fwData::Mesh::sptr mesh = ::fwData::Mesh::New();
122 mesh->setNumberOfPoints(m_pointBuffer.size() / 3);
123 mesh->setNumberOfCells(m_cellBuffer.size() / 3);
124 mesh->setCellDataSize(m_cellBuffer.size());
125 mesh->adjustAllocatedMemory();
130 std::copy(m_pointBuffer.begin(),
132 pointsArrayHelper.begin< ::fwData::Mesh::PointValueType >());
139 std::size_t index = 0;
140 for(
auto cellIt = cellDataHelper.begin< ::fwData::Mesh::CellValueType >();
141 cellIt != cellDataHelper.end< ::fwData::Mesh::CellValueType >();
145 *cellIt =
static_cast< ::fwData::Mesh::CellValueType
>(m_cellBuffer[index++]) - 1;
150 if(!m_normalBuffer.empty())
152 mesh->allocatePointNormals();
154 std::copy(m_normalBuffer.begin(),
155 m_normalBuffer.end(),
156 normalsArrayHelper.begin< ::fwData::Mesh::NormalValueType >());
161 std::fill(cellTypesHelper.begin< ::fwData::Mesh::CellTypes >(),
162 cellTypesHelper.end< ::fwData::Mesh::CellTypes >(),
163 static_cast< ::fwData::Mesh::CellTypes >(::fwData::Mesh::TRIANGLE));
168 std::generate(cellDataOffsetsHelper.begin< ::fwData::Mesh::CellDataOffsetType >(),
169 cellDataOffsetsHelper.end< ::fwData::Mesh::CellDataOffsetType >(),
170 cellDataOffsetGenerator);
180 return m_pointBuffer;
194 return m_normalBuffer;
201 return m_pointBuffer.size();
208 return m_cellBuffer.size();
215 return m_normalBuffer.size();
FWGDCMIO_API DicomSurface(const ::fwData::Reconstruction::csptr &reconstruction)
Constructor.
#define SLM_TRACE_FUNC()
Trace contextual function signature.
FWGDCMIO_API std::size_t getCellBufferSize() const
Return cell buffer size.
FWGDCMIO_API ~DicomSurface()
Destructor.
std::uint32_t DicomCellValueType
The namespace fwGdcmIO contains reader, writer and helper for dicom data.
FWGDCMIO_API const DicomNormalBufferType & getNormalBuffer() const
Return normal buffer.
FWGDCMIO_API const DicomCellBufferType & getCellBuffer() const
Return cell buffer.
Implements a failed exception class for fwGdcmIO.
std::vector< float > DicomNormalBufferType
Container types to store points, cells and normals.
std::vector< DicomCellValueType > DicomCellBufferType
Container types to store points, cells and normals.
FWGDCMIO_API const DicomPointBufferType & getPointBuffer() const
Return point coordinates buffer.
std::vector< float > DicomPointBufferType
Container types to store points, cells and normals.
FWGDCMIO_API::fwData::Mesh::sptr convertToData()
Convert DicomSurface container to FW4SPL Mesh.
FWGDCMIO_API std::size_t getNormalBufferSize() const
Return normal buffer size.
FWGDCMIO_API std::size_t getPointBufferSize() const
Return point coordinates buffer size.