7 #include "fwDataTools/helper/MeshGetter.hpp" 9 #include <fwMath/MeshFunctions.hpp> 11 #include <boost/assign/list_of.hpp> 21 #define POINT_REALLOC_STEP 1000 22 #define CELL_REALLOC_STEP 1000 23 #define CELLDATA_REALLOC_STEP 1000 25 MeshGetter::MeshGetter( ::fwData::Mesh::csptr mesh ) : m_mesh (mesh)
27 typedef::fwDataTools::helper::ArrayGetter ArrayGetter;
31 m_helperPoints = ArrayGetter::uptr(
new ArrayGetter(m_mesh->getPointsArray()));
32 m_helperCellTypes = ArrayGetter::uptr(
new ArrayGetter(m_mesh->getCellTypesArray()));
33 m_helperCellData = ArrayGetter::uptr(
new ArrayGetter(m_mesh->getCellDataArray()));
34 m_helperCellDataOffsets = ArrayGetter::uptr(
new ArrayGetter(m_mesh->getCellDataOffsetsArray()));
36 ::fwData::Array::sptr pointColors = m_mesh->getPointColorsArray();
37 ::fwData::Array::sptr cellColors = m_mesh->getCellColorsArray();
38 ::fwData::Array::sptr pointNormals = m_mesh->getPointNormalsArray();
39 ::fwData::Array::sptr cellNormals = m_mesh->getCellNormalsArray();
40 ::fwData::Array::sptr pointTexCoords = m_mesh->getPointTexCoordsArray();
41 ::fwData::Array::sptr cellTexCoords = m_mesh->getCellTexCoordsArray();
45 m_helperPointColors = ArrayGetter::uptr(
new ArrayGetter(pointColors));
49 m_helperCellColors = ArrayGetter::uptr(
new ArrayGetter(cellColors));
53 m_helperPointNormals = ArrayGetter::uptr(
new ArrayGetter(pointNormals));
57 m_helperCellNormals = ArrayGetter::uptr(
new ArrayGetter(cellNormals));
61 m_helperPointTexCoords = ArrayGetter::uptr(
new ArrayGetter(pointTexCoords));
65 m_helperCellTexCoords = ArrayGetter::uptr(
new ArrayGetter(cellTexCoords));
71 MeshGetter::~MeshGetter()
77 ::fwData::Mesh::ConstPointsMultiArrayType MeshGetter::getPoints()
const 79 return ::fwData::Mesh::ConstPointsMultiArrayType(
80 static_cast< const ::fwData::Mesh::PointsMultiArrayType::element* >(m_helperPoints->getBuffer()),
81 ::boost::extents[m_mesh->getNumberOfPoints()][3]
87 ::fwData::Mesh::ConstCellTypesMultiArrayType MeshGetter::getCellTypes()
const 89 return ::fwData::Mesh::ConstCellTypesMultiArrayType(
90 static_cast< const ::fwData::Mesh::CellTypesMultiArrayType::element*> (m_helperCellTypes->getBuffer()),
91 boost::extents[m_mesh->getNumberOfCells()]
97 ::fwData::Mesh::ConstCellDataMultiArrayType MeshGetter::getCellData()
const 99 return ::fwData::Mesh::ConstCellDataMultiArrayType(
100 static_cast< const ::fwData::Mesh::CellDataMultiArrayType::element* >(m_helperCellData->getBuffer()),
101 ::boost::extents[m_mesh->getCellDataSize()]
107 ::fwData::Mesh::ConstCellDataOffsetsMultiArrayType MeshGetter::getCellDataOffsets()
const 109 return ::fwData::Mesh::ConstCellDataOffsetsMultiArrayType(
110 static_cast< const ::fwData::Mesh::CellDataOffsetsMultiArrayType::element*>(m_helperCellDataOffsets->getBuffer()),
111 ::boost::extents[m_mesh->getNumberOfCells()]
117 ::fwData::Mesh::ConstPointColorsMultiArrayType MeshGetter::getPointColors()
const 119 ::fwData::Array::sptr pointColors = m_mesh->getPointColorsArray();
120 return ::fwData::Mesh::ConstPointColorsMultiArrayType(
121 static_cast< const ::fwData::Mesh::PointColorsMultiArrayType::element*>(m_helperPointColors->getBuffer()),
122 ::boost::extents[m_mesh->getNumberOfPoints()][pointColors->getNumberOfComponents()]
128 ::fwData::Mesh::ConstCellColorsMultiArrayType MeshGetter::getCellColors()
const 130 ::fwData::Array::sptr cellColors = m_mesh->getCellColorsArray();
131 return ::fwData::Mesh::ConstCellColorsMultiArrayType(
132 static_cast< const ::fwData::Mesh::CellColorsMultiArrayType::element*>(m_helperCellColors->getBuffer()),
133 ::boost::extents[m_mesh->getNumberOfCells()][cellColors->getNumberOfComponents()]
139 ::fwData::Mesh::ConstPointNormalsMultiArrayType MeshGetter::getPointNormals()
const 141 ::fwData::Array::sptr pointNormals = m_mesh->getPointNormalsArray();
142 return ::fwData::Mesh::ConstPointNormalsMultiArrayType(
143 static_cast< const ::fwData::Mesh::PointNormalsMultiArrayType::element*>(m_helperPointNormals->getBuffer()),
144 ::boost::extents[m_mesh->getNumberOfPoints()][pointNormals->getNumberOfComponents()]
150 ::fwData::Mesh::ConstCellNormalsMultiArrayType MeshGetter::getCellNormals()
const 152 ::fwData::Array::sptr cellNormals = m_mesh->getCellNormalsArray();
153 return ::fwData::Mesh::ConstCellNormalsMultiArrayType(
154 static_cast< const ::fwData::Mesh::CellNormalsMultiArrayType::element*>(m_helperCellNormals->getBuffer()),
155 ::boost::extents[m_mesh->getNumberOfCells()][cellNormals->getNumberOfComponents()]
161 ::fwData::Mesh::ConstPointTexCoordsMultiArrayType MeshGetter::getPointTexCoords()
const 163 ::fwData::Array::sptr pointTexCoords = m_mesh->getPointTexCoordsArray();
164 return ::fwData::Mesh::ConstPointTexCoordsMultiArrayType(
165 static_cast< const ::fwData::Mesh::PointTexCoordsMultiArrayType::element*>(m_helperPointTexCoords->getBuffer()),
166 ::boost::extents[m_mesh->getNumberOfPoints()][pointTexCoords->getNumberOfComponents()]
172 ::fwData::Mesh::ConstCellTexCoordsMultiArrayType MeshGetter::getCellTexCoords()
const 174 ::fwData::Array::sptr cellTexCoords = m_mesh->getCellTexCoordsArray();
175 return ::fwData::Mesh::ConstCellTexCoordsMultiArrayType(
176 static_cast< const ::fwData::Mesh::CellTexCoordsMultiArrayType::element*>(m_helperCellTexCoords->getBuffer()),
177 ::boost::extents[m_mesh->getNumberOfCells()][cellTexCoords->getNumberOfComponents()]
183 ::fwData::Mesh::csptr MeshGetter::getMesh()
const 190 bool MeshGetter::isClosed()
192 bool isClosed =
false;
194 ::fwData::Mesh::Id cellDataSize = m_mesh->getCellDataSize();
195 ::fwData::Mesh::Id nbOfCells = m_mesh->getNumberOfCells();
197 auto cellDataBegin = m_helperCellData->begin< ::fwData::Mesh::CellValueType >();
198 auto cellDataEnd = cellDataBegin + cellDataSize;
199 auto cellDataOffsetsBegin = m_helperCellDataOffsets->begin< ::fwData::Mesh::CellDataOffsetType >();
200 auto cellDataOffsetsEnd = cellDataOffsetsBegin + nbOfCells;
201 auto cellTypesBegin = m_helperCellTypes->begin< ::fwData::Mesh::CellTypes >();
203 isClosed = ::fwMath::isBorderlessSurface(cellDataBegin,
204 cellDataEnd, cellDataOffsetsBegin,
205 cellDataOffsetsEnd, cellTypesBegin );
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...