7 #include "fwData/Mesh.hpp" 9 #include <fwCom/Signal.hxx> 11 #include "fwData/registry/macros.hpp" 12 #include "fwData/Exception.hpp" 22 #define POINT_REALLOC_STEP 1000 23 #define CELL_REALLOC_STEP 1000 24 #define CELLDATA_REALLOC_STEP 1000 83 m_points->setType(::fwTools::Type::create<PointValueType>());
86 m_cellTypes->setType(::fwTools::Type::create<CellTypes>());
89 m_cellData->setType(::fwTools::Type::create<CellValueType>());
100 Mesh::csptr other = Mesh::dynamicConstCast(_source);
102 "Unable to copy" + (_source ? _source->getClassname() : std::string(
"<NULL>"))
129 Mesh::csptr other = Mesh::dynamicConstCast(_source);
131 "Unable to copy" + (_source ? _source->getClassname() : std::string(
"<NULL>"))
155 for(
const ArrayMapType::value_type& element : other->m_arrayMap)
166 if (nbCellsData == 0)
168 nbCellsData = 3 * nbCells;
171 size_t allocatedSize = 0;
173 allocatedSize +=
m_points->resize( {nbPts}, true );
174 allocatedSize +=
m_cellTypes->resize( {nbCells}, true );
175 allocatedSize +=
m_cellData->resize( {nbCellsData}, true );
178 return allocatedSize;
185 size_t allocatedSize = 0;
190 allocatedSize +=
m_pointNormals->resize( ::fwTools::Type::create<NormalValueType>(), {size_t(
m_nbPoints)}, 3,
true);
191 return allocatedSize;
198 OSLM_ASSERT(
"Bad ColorArrayTypes : " << t, t == RGB || t == RGBA);
199 size_t allocatedSize = 0;
204 allocatedSize +=
m_pointColors->resize( ::fwTools::Type::create<ColorValueType>(), {size_t(
m_nbPoints)}, t,
true);
205 return allocatedSize;
212 size_t allocatedSize = 0;
217 allocatedSize +=
m_pointTexCoords->resize( ::fwTools::Type::create<TexCoordValueType>(), {size_t(
220 return allocatedSize;
227 size_t allocatedSize = 0;
232 allocatedSize +=
m_cellNormals->resize( ::fwTools::Type::create<NormalValueType>(), {size_t(
m_nbCells)}, 3,
true);
233 return allocatedSize;
240 OSLM_ASSERT(
"Bad ColorArrayTypes : " << t, t == RGB || t == RGBA);
241 size_t allocatedSize = 0;
246 allocatedSize +=
m_cellColors->resize( ::fwTools::Type::create<ColorValueType>(), {size_t(
m_nbCells)}, t,
true);
247 return allocatedSize;
254 size_t allocatedSize = 0;
261 return allocatedSize;
289 SLM_ASSERT(
"Error adjusting memory : allocated size: " << newAllocatedSize
292 return oldAllocatedSize != newAllocatedSize;
607 ::fwData::Array::sptr res;
608 ArrayMapType::const_iterator iter =
m_arrayMap.find(name);
620 std::vector<std::string> vectNames;
622 std::back_inserter(vectNames),
623 std::bind(&ArrayMapType::value_type::first, std::placeholders::_1) );
FWDATA_API::fwData::Array::sptr getDataArray(const std::string &name) const
Get an array in the mesh array-map.
FWDATA_API size_t allocateCellColors(ColorArrayTypes t)
Allocates colors array according to the number of cells of the mesh.
FWDATA_API void clearPointTexCoords()
Remove corresponding array, memory is freed.
Id m_cellsDataSize
Number of point index defined for mesh (size of m_cellData)
FWDATA_API::fwData::Array::sptr getCellTexCoordsArray() const
Returns the internal corresponding array.
::fwData::Array::sptr m_pointNormals
Mesh point array : 3-components 1-dimension uint8_t array, size = m_nbPoints.
FWDATA_API::fwData::Array::sptr getCellColorsArray() const
Returns the internal corresponding array.
#define OSLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
FWDATA_API size_t allocatePointTexCoords()
Allocates texCoords array according to the number of points of the mesh.
FWDATA_API Id getCellDataSize() const
Get cell data size.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_NORMALS_MODIFIED_SIG
Key in m_signals map of signal m_sigPointNormalsModified.
FWDATA_API bool adjustAllocatedMemory()
Adjust mesh memory usage.
FWDATA_API void clearPointColors()
Remove corresponding array, memory is freed.
FWDATA_API void clearCells()
Clear mesh cells. Calling this method don't impact memory allocation.
FWDATA_API Mesh(::fwData::Object::Key key)
Constructor.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Implements data exception class.
FWDATA_API void addDataArray(const std::string &name,::fwData::Array::sptr array)
Add an array in the mesh array-map.
FWDATA_API void setCellColorsArray(const ::fwData::Array::sptr &array)
Sets the internal corresponding array.
FWDATA_API::fwData::Array::sptr getCellNormalsArray() const
Returns the internal corresponding array.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_CELL_COLORS_MODIFIED_SIG
Key in m_signals map of signal m_sigCellColorsModified.
FWDATA_API Id getNumberOfPoints() const
Get number of points.
FWDATA_API void clear()
Remove all data contained in the mesh. Memory is freed.
FWDATA_API size_t allocate(size_t nbPts, size_t nbCells, size_t nbCellsData=0)
Allocate Mesh memory.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_CELL_NORMALS_MODIFIED_SIG
Key in m_signals map of signal m_sigCellNormalsModified.
::fwData::Array::sptr m_cellDataOffsets
Cell data offsets array : 1-components 1-dimension uint64 array, size = m_nbCells.
::fwData::Array::sptr m_cellTexCoords
Mesh texCoord array : 2-components 1-dimension float array, size = m_nbCells.
FWDATA_API void setCellTypesArray(const ::fwData::Array::sptr &array)
Sets the internal corresponding array.
FWDATA_API::fwData::Array::sptr getCellDataArray() const
Returns the internal corresponding array.
FWDATA_API size_t allocatePointColors(ColorArrayTypes t)
Allocates colors array according to the number of points of the mesh.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_TEX_COORDS_MODIFIED_SIG
Key in m_signals map of signal m_sigPointTexCoorddModified.
FWDATA_API::fwData::Array::sptr getPointTexCoordsArray() const
Returns the internal corresponding array.
FWDATA_API void setPointsArray(const ::fwData::Array::sptr &array)
Sets the internal corresponding array.
Id m_nbCells
Number of cells defined for the mesh.
FWDATA_API size_t allocateCellTexCoords()
Allocates texCoords array according to the number of cells of the mesh.
FWDATA_API void setCellDataArray(const ::fwData::Array::sptr &array)
Sets the internal corresponding array.
FWDATA_API void initArrays()
Initializes points, cell-types, cell-data, and cell-data-offsets arrays.
FWDATA_API size_t allocateCellNormals()
Allocates normals array according to the number of cells of the mesh.
FWDATA_API void fieldDeepCopy(const ::fwData::Object::csptr &source)
A deep copy of fields (objects in m_children)
FWDATA_API::fwData::Array::sptr getPointsArray() const
Returns the internal corresponding array.
virtual FWDATA_API ~Mesh()
Destructor.
FWDATA_API void setPointColorsArray(const ::fwData::Array::sptr &array)
Sets the internal corresponding array.
::fwData::Array::sptr m_pointColors
point colors array : 3 or 4-components 1-dimension float array, size = m_nbPoints.
FWDATA_API void setCellDataOffsetsArray(const ::fwData::Array::sptr &array)
Sets the internal corresponding array.
FWDATA_API void clearPoints()
Clear mesh points. Calling this method don't impact memory allocation.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
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.
FWDATA_API Id getNumberOfCells() const
Get number of cells.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_CELL_TEX_COORDS_MODIFIED_SIG
Key in m_signals map of signal m_sigCellTexCoorddModified.
FWDATA_API::fwData::Array::sptr getCellDataOffsetsArray() const
Returns the internal corresponding array.
FWDATA_API size_t getAllocatedSizeInBytes() const
Get the amount of memory allocated in this mesh. Mey be bigger than getDataSizeInBytes().
FWDATA_API void clearCellColors()
Remove corresponding array, memory is freed.
FWDATA_API void cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache) override
Defines deep copy.
FWDATA_API void setNumberOfPoints(Id nb)
Set number of points.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_VERTEX_MODIFIED_SIG
Key in m_signals map of signal m_sigVertexModified.
FWDATA_API void clearCellNormals()
Remove corresponding array, memory is freed.
FWDATA_API size_t getDataSizeInBytes() const
Get the mesh data size in bytes.
FWDATA_API void setCellTexCoordsArray(const ::fwData::Array::sptr &array)
Sets the internal corresponding array.
FWDATA_API std::vector< std::string > getDataArrayNames() const
Return all array names stock in the mesh array-map.
::fwData::Array::sptr m_pointTexCoords
Mesh texCoord array : 2-components 1-dimension float array, size = m_nbPoints.
FWDATA_API::fwData::Array::sptr getPointColorsArray() const
Returns the internal corresponding array.
Id m_nbPoints
Number of points defined for the mesh.
::fwData::Array::sptr m_cellData
Cell data array : 1-components 1-dimension uint64 array, size = m_cellsDataSize.
FWDATA_API void setCellDataSize(Id nb)
Set cell data size.
ArrayMapType m_arrayMap
Array map where you can add few additional arrays registered thanks to a key to perform/conserve some...
FWDATA_API void setCellNormalsArray(const ::fwData::Array::sptr &array)
Sets the internal corresponding array.
Contains the representation of the data objects used in the framework.
virtual const std::string & getClassname() const override
return full object's classname with its namespace, i.e. fwCore::BaseObject
FWDATA_API void fieldShallowCopy(const ::fwData::Object::csptr &source)
A shallow copy of fields (objects in m_children)
FWDATA_API::fwData::Array::sptr getPointNormalsArray() const
Returns the internal corresponding array.
FWDATA_API void setNumberOfCells(Id nb)
Set number of cells.
::fwData::Array::sptr m_points
Mesh point array : 3-components 1-dimension float array, size = m_nbPoints x 3.
::fwData::Array::sptr m_cellNormals
Mesh point array : 3-components 1-dimension float array, size = m_nbCells.
FWDATA_API void removeDataArray(const std::string &name)
Remove an array in the mesh array-map.
FWDATA_API void shallowCopy(const Object::csptr &_source) override
Defines shallow copy.
FWDATA_API void clearPointNormals()
Remove corresponding array, memory is freed.
FWDATA_API void setPointNormalsArray(const ::fwData::Array::sptr &array)
Sets the internal corresponding array.
FWDATA_API void clearCellTexCoords()
Remove corresponding array, memory is freed.
Data holding a geometric structure composed of points, lines, triangles, quads or polygons...
::fwData::Array::sptr m_cellColors
Mesh point array : 3 or 4-components 1-dimension uint8_t array, size = m_nbCells. ...
FWDATA_API size_t allocatePointNormals()
Allocates normals array according to the number of points of the mesh.
::fwData::Array::sptr m_cellTypes
Cell types array : 1-components 1-dimension uint8 array, size = m_nbCells.
static FWDATA_APIconst::fwCom::Signals::SignalKeyType s_POINT_COLORS_MODIFIED_SIG
Key in m_signals map of signal m_sigPointColorsModified.
FWDATA_API::fwData::Array::sptr getCellTypesArray() const
Returns the internal corresponding array.
FWDATA_API void setPointTexCoordsArray(const ::fwData::Array::sptr &array)
Sets the internal corresponding array.