7 #include "Tuto14MeshGenerator/AlgoMeshDeformation.hpp" 9 #include <fwDataTools/helper/Array.hpp> 10 #include <fwDataTools/Mesh.hpp> 12 #include <fwTools/NumericRoundCast.hxx> 39 ::fwData::Mesh::sptr _mesh,
40 const unsigned int _nbStep,
41 const unsigned int _amplitude)
45 m_amplitude = _amplitude;
48 m_nbPoints = _mesh->getNumberOfPoints();
49 m_nbCells = _mesh->getNumberOfCells();
55 const unsigned int _nbStep,
56 const unsigned int _amplitude )
58 if ( m_mesh.expired() ||
59 m_nbPoints != _mesh->getNumberOfPoints() ||
60 m_nbCells != _mesh->getNumberOfCells() ||
61 !_mesh->getPointColorsArray())
63 this->
setParam( _mesh, _nbStep, _amplitude );
80 if ( !m_mesh.lock()->getPointColorsArray() )
85 m_meshHelper = ::fwDataTools::helper::Mesh::New(m_mesh.lock());
87 float max = std::numeric_limits<float>::min();
88 float min = std::numeric_limits<float>::max();
90 ::fwData::Mesh::PointsMultiArrayType points = m_meshHelper->getPoints();
92 for(
unsigned int i = 0; i < m_nbPoints; ++i)
105 m_yCenter = (max - min) / 2 + min;
113 m_step += m_direction;
114 if ( m_step == m_nbStep )
118 else if ( m_step == 0 )
123 const float scale = m_step / (float) m_nbStep;
127 ::fwData::Mesh::PointsMultiArrayType points = m_meshHelper->getPoints();
128 ::fwData::Mesh::PointColorsMultiArrayType colors = m_meshHelper->getPointColors();
130 ::fwData::Mesh::PointsMultiArrayType opoints =
131 ::fwData::Mesh::PointsMultiArrayType(
132 static_cast< ::fwData::Mesh::PointsMultiArrayType::element* >(originPointsHelper.
getBuffer()),
133 ::boost::extents[m_nbPoints][3] );
135 for(
unsigned int i = 0; i < m_nbPoints; ++i)
137 points[i][0] = opoints[i][0];
138 OSLM_TRACE(
"opoints[i][1] - m_yCenter = " << opoints[i][1] - m_yCenter);
139 if( opoints[i][1] - m_yCenter > 0 )
141 points[i][1] = opoints[i][1] + (opoints[i][1] - m_yCenter) * scale;
142 colors[i][0] = ::fwTools::numericRoundCast< ::fwData::Mesh::ColorValueType >(255 * scale);
148 points[i][2] = opoints[i][2];
#define SLM_TRACE_FUNC()
Trace contextual function signature.
#define OSLM_TRACE(message)
static FWDATA_API::fwData::Object::sptr copy(const ::fwData::Object::csptr &source)
return a copy of the source. if source is a null pointer, return a null pointer.