fw4spl
core/fwData/src/fwData/Mesh.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2015.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwData/Mesh.hpp"
8 
9 #include <fwCom/Signal.hxx>
10 
11 #include "fwData/registry/macros.hpp"
12 #include "fwData/Exception.hpp"
13 
14 #include <functional>
15 #include <cstdlib>
16 #include <functional>
17 #include <numeric>
18 
19 namespace fwData
20 {
21 
22 #define POINT_REALLOC_STEP 1000
23 #define CELL_REALLOC_STEP 1000
24 #define CELLDATA_REALLOC_STEP 1000
25 
26 
27 fwDataRegisterMacro( ::fwData::Mesh );
28 
29 //------------------------------------------------------------------------------
30 
31 const ::fwCom::Signals::SignalKeyType Mesh::s_VERTEX_MODIFIED_SIG = "vertexModified";
32 const ::fwCom::Signals::SignalKeyType Mesh::s_POINT_COLORS_MODIFIED_SIG = "pointColorsModified";
33 const ::fwCom::Signals::SignalKeyType Mesh::s_CELL_COLORS_MODIFIED_SIG = "cellColorsModified";
34 const ::fwCom::Signals::SignalKeyType Mesh::s_POINT_NORMALS_MODIFIED_SIG = "pointNormalsModified";
35 const ::fwCom::Signals::SignalKeyType Mesh::s_CELL_NORMALS_MODIFIED_SIG = "cellNormalsModified";
36 const ::fwCom::Signals::SignalKeyType Mesh::s_POINT_TEX_COORDS_MODIFIED_SIG = "pointTexCoordsModified";
37 const ::fwCom::Signals::SignalKeyType Mesh::s_CELL_TEX_COORDS_MODIFIED_SIG = "cellTexCoordsModified";
38 
39 //------------------------------------------------------------------------------
40 
41 Mesh::Mesh(::fwData::Object::Key key) : m_nbPoints(0),
42  m_nbCells(0),
43  m_cellsDataSize(0)
44 {
45  newSignal<VertexModifiedSignalType>(s_VERTEX_MODIFIED_SIG);
46  newSignal<PointColorsModifiedSignalType>(s_POINT_COLORS_MODIFIED_SIG);
47  newSignal<CellColorsModifiedSignalType>(s_CELL_COLORS_MODIFIED_SIG);
48  newSignal<PointNormalsModifiedSignalType>(s_POINT_NORMALS_MODIFIED_SIG);
49  newSignal<CellNormalsModifiedSignalType>(s_CELL_NORMALS_MODIFIED_SIG);
50  newSignal<PointTexCoordsModifiedSignalType>(s_POINT_TEX_COORDS_MODIFIED_SIG);
51  newSignal<CellTexCoordsModifiedSignalType>(s_CELL_TEX_COORDS_MODIFIED_SIG);
52 
53  this->initArrays();
54 }
55 
56 //------------------------------------------------------------------------------
57 
59 {
60 }
61 
62 //------------------------------------------------------------------------------
63 
65 {
66  if (!m_points)
67  {
68  m_points = ::fwData::Array::New();
69  }
70  if (!m_cellTypes)
71  {
72  m_cellTypes = ::fwData::Array::New();
73  }
74  if (!m_cellData)
75  {
76  m_cellData = ::fwData::Array::New();
77  }
78  if (!m_cellDataOffsets)
79  {
80  m_cellDataOffsets = ::fwData::Array::New();
81  }
82 
83  m_points->setType(::fwTools::Type::create<PointValueType>());
84  m_points->setNumberOfComponents(3);
85 
86  m_cellTypes->setType(::fwTools::Type::create<CellTypes>());
87  m_cellTypes->setNumberOfComponents(1);
88 
89  m_cellData->setType(::fwTools::Type::create<CellValueType>());
90  m_cellData->setNumberOfComponents(1);
91 
92  m_cellDataOffsets->setType(::fwTools::Type::create<CellDataOffsetType>());
93  m_cellDataOffsets->setNumberOfComponents(1);
94 }
95 
96 //------------------------------------------------------------------------------
97 
98 void Mesh::shallowCopy(const Object::csptr &_source )
99 {
100  Mesh::csptr other = Mesh::dynamicConstCast(_source);
101  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
102  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
103  + " to " + this->getClassname()), !bool(other) );
104  this->fieldShallowCopy( _source );
105 
106  m_nbPoints = other->m_nbPoints;
107  m_nbCells = other->m_nbCells;
108  m_cellsDataSize = other->m_cellsDataSize;
109 
110  m_points = other->m_points;
111  m_cellTypes = other->m_cellTypes;
112  m_cellData = other->m_cellData;
113  m_cellDataOffsets = other->m_cellDataOffsets;
114 
115  m_pointColors = other->m_pointColors;
116  m_cellColors = other->m_cellColors;
117  m_pointNormals = other->m_pointNormals;
118  m_cellNormals = other->m_cellNormals;
119  m_cellTexCoords = other->m_cellTexCoords;
120  m_pointTexCoords = other->m_pointTexCoords;
121 
122  m_arrayMap = other->m_arrayMap;
123 }
124 
125 //------------------------------------------------------------------------------
126 
127 void Mesh::cachedDeepCopy(const Object::csptr &_source, DeepCopyCacheType &cache)
128 {
129  Mesh::csptr other = Mesh::dynamicConstCast(_source);
130  FW_RAISE_EXCEPTION_IF( ::fwData::Exception(
131  "Unable to copy" + (_source ? _source->getClassname() : std::string("<NULL>"))
132  + " to " + this->getClassname()), !other );
133  this->fieldDeepCopy( _source, cache );
134 
135  m_nbPoints = other->m_nbPoints;
136  m_nbCells = other->m_nbCells;
137  m_cellsDataSize = other->m_cellsDataSize;
138 
139  this->initArrays();
140 
141  m_points = ::fwData::Object::copy( other->m_points, cache );
142  m_cellTypes = ::fwData::Object::copy( other->m_cellTypes, cache );
143  m_cellData = ::fwData::Object::copy( other->m_cellData, cache );
144  m_cellDataOffsets = ::fwData::Object::copy( other->m_cellDataOffsets, cache );
145 
146  //Object::copy returns a null object if source object is null
147  m_pointColors = ::fwData::Object::copy( other->m_pointColors, cache );
148  m_cellColors = ::fwData::Object::copy( other->m_cellColors, cache );
149  m_pointNormals = ::fwData::Object::copy( other->m_pointNormals, cache );
150  m_cellNormals = ::fwData::Object::copy( other->m_cellNormals, cache );
151  m_cellTexCoords = ::fwData::Object::copy( other->m_cellTexCoords, cache );
152  m_pointTexCoords = ::fwData::Object::copy( other->m_pointTexCoords, cache );
153 
154  m_arrayMap.clear();
155  for(const ArrayMapType::value_type& element : other->m_arrayMap)
156  {
157  m_arrayMap[element.first] = ::fwData::Object::copy(element.second, cache);
158  }
159 
160 }
161 
162 //------------------------------------------------------------------------------
163 
164 size_t Mesh::allocate(size_t nbPts, size_t nbCells, size_t nbCellsData)
165 {
166  if (nbCellsData == 0)
167  {
168  nbCellsData = 3 * nbCells;
169  }
170 
171  size_t allocatedSize = 0;
172 
173  allocatedSize += m_points->resize( {nbPts}, true );
174  allocatedSize += m_cellTypes->resize( {nbCells}, true );
175  allocatedSize += m_cellData->resize( {nbCellsData}, true );
176  allocatedSize += m_cellDataOffsets->resize( {nbCells}, true );
177 
178  return allocatedSize;
179 }
180 
181 //------------------------------------------------------------------------------
182 
184 {
185  size_t allocatedSize = 0;
186  if (!m_pointNormals )
187  {
188  m_pointNormals = ::fwData::Array::New();
189  }
190  allocatedSize += m_pointNormals->resize( ::fwTools::Type::create<NormalValueType>(), {size_t(m_nbPoints)}, 3, true);
191  return allocatedSize;
192 }
193 
194 //------------------------------------------------------------------------------
195 
196 size_t Mesh::allocatePointColors(ColorArrayTypes t)
197 {
198  OSLM_ASSERT("Bad ColorArrayTypes : " << t, t == RGB || t == RGBA);
199  size_t allocatedSize = 0;
200  if (!m_pointColors )
201  {
202  m_pointColors = ::fwData::Array::New();
203  }
204  allocatedSize += m_pointColors->resize( ::fwTools::Type::create<ColorValueType>(), {size_t(m_nbPoints)}, t, true);
205  return allocatedSize;
206 }
207 
208 //------------------------------------------------------------------------------
209 
211 {
212  size_t allocatedSize = 0;
213  if (!m_pointTexCoords )
214  {
215  m_pointTexCoords = ::fwData::Array::New();
216  }
217  allocatedSize += m_pointTexCoords->resize( ::fwTools::Type::create<TexCoordValueType>(), {size_t(
218  m_nbPoints)}, 2,
219  true);
220  return allocatedSize;
221 }
222 
223 //------------------------------------------------------------------------------
224 
226 {
227  size_t allocatedSize = 0;
228  if (!m_cellNormals )
229  {
230  m_cellNormals = ::fwData::Array::New();
231  }
232  allocatedSize += m_cellNormals->resize( ::fwTools::Type::create<NormalValueType>(), {size_t(m_nbCells)}, 3, true);
233  return allocatedSize;
234 }
235 
236 //------------------------------------------------------------------------------
237 
238 size_t Mesh::allocateCellColors(ColorArrayTypes t)
239 {
240  OSLM_ASSERT("Bad ColorArrayTypes : " << t, t == RGB || t == RGBA);
241  size_t allocatedSize = 0;
242  if (!m_cellColors )
243  {
244  m_cellColors = ::fwData::Array::New();
245  }
246  allocatedSize += m_cellColors->resize( ::fwTools::Type::create<ColorValueType>(), {size_t(m_nbCells)}, t, true);
247  return allocatedSize;
248 }
249 
250 //------------------------------------------------------------------------------
251 
253 {
254  size_t allocatedSize = 0;
255  if (!m_cellTexCoords )
256  {
257  m_cellTexCoords = ::fwData::Array::New();
258  }
259  allocatedSize +=
260  m_cellTexCoords->resize( ::fwTools::Type::create<TexCoordValueType>(), {size_t(m_nbCells)}, 2, true);
261  return allocatedSize;
262 }
263 
264 //------------------------------------------------------------------------------
265 
267 {
268  size_t oldAllocatedSize = this->getAllocatedSizeInBytes();
269 
270  if(!m_points)
271  {
272  this->initArrays();
273  }
274 
275  m_points->resize({size_t(m_nbPoints)}, true);
276  m_cellTypes->resize({size_t(m_nbCells)}, true);
277  m_cellData->resize({size_t(m_cellsDataSize)}, true);
278  m_cellDataOffsets->resize({size_t(m_nbCells)}, true);
279 
280  m_pointColors && (m_pointColors->resize({size_t(m_nbPoints)}, true));
281  m_cellColors && (m_cellColors->resize({size_t(m_nbCells)}, true));
282  m_pointNormals && (m_pointNormals->resize({size_t(m_nbPoints)}, true));
283  m_cellNormals && (m_cellNormals->resize({size_t(m_nbCells)}, true));
284  m_pointTexCoords && (m_pointTexCoords->resize({size_t(m_nbPoints)}, true));
285  m_cellTexCoords && (m_cellTexCoords->resize({size_t(m_nbCells)}, true));
286 
287 
288  size_t newAllocatedSize = this->getAllocatedSizeInBytes();
289  SLM_ASSERT("Error adjusting memory : allocated size: " << newAllocatedSize
290  << " != data size : " << this->getDataSizeInBytes(),
291  newAllocatedSize == this->getDataSizeInBytes());
292  return oldAllocatedSize != newAllocatedSize;
293 }
294 
295 //------------------------------------------------------------------------------
296 
297 void Mesh::setPointsArray(const ::fwData::Array::sptr& array)
298 {
299  m_points = array;
300 }
301 
302 //------------------------------------------------------------------------------
303 
304 void Mesh::setCellTypesArray(const ::fwData::Array::sptr& array)
305 {
306  m_cellTypes = array;
307 }
308 
309 //------------------------------------------------------------------------------
310 
311 void Mesh::setCellDataArray (const ::fwData::Array::sptr& array)
312 {
313  m_cellData = array;
314 }
315 
316 //------------------------------------------------------------------------------
317 
318 void Mesh::setCellDataOffsetsArray(const ::fwData::Array::sptr& array)
319 {
320  m_cellDataOffsets = array;
321 }
322 
323 //------------------------------------------------------------------------------
324 
325 void Mesh::setPointColorsArray(const ::fwData::Array::sptr& array)
326 {
327  m_pointColors = array;
328 }
329 
330 //------------------------------------------------------------------------------
331 
332 void Mesh::setCellColorsArray(const ::fwData::Array::sptr& array)
333 {
334  m_cellColors = array;
335 }
336 
337 //------------------------------------------------------------------------------
338 
339 void Mesh::setPointNormalsArray(const ::fwData::Array::sptr& array)
340 {
341  m_pointNormals = array;
342 }
343 
344 //------------------------------------------------------------------------------
345 
346 void Mesh::setCellNormalsArray(const ::fwData::Array::sptr& array)
347 {
348  m_cellNormals = array;
349 }
350 
351 //------------------------------------------------------------------------------
352 
353 void Mesh::setPointTexCoordsArray(const ::fwData::Array::sptr& array)
354 {
355  m_pointTexCoords = array;
356 }
357 
358 //------------------------------------------------------------------------------
359 
360 void Mesh::setCellTexCoordsArray(const ::fwData::Array::sptr& array)
361 {
362  m_cellTexCoords = array;
363 }
364 
365 //------------------------------------------------------------------------------
366 
367 ::fwData::Array::sptr Mesh::getPointsArray() const
368 {
369  return m_points;
370 }
371 
372 //------------------------------------------------------------------------------
373 
374 ::fwData::Array::sptr Mesh::getCellTypesArray() const
375 {
376  return m_cellTypes;
377 }
378 
379 //------------------------------------------------------------------------------
380 
381 ::fwData::Array::sptr Mesh::getCellDataArray() const
382 {
383  return m_cellData;
384 }
385 
386 //------------------------------------------------------------------------------
387 
388 ::fwData::Array::sptr Mesh::getCellDataOffsetsArray() const
389 {
390  return m_cellDataOffsets;
391 }
392 
393 //------------------------------------------------------------------------------
394 
395 ::fwData::Array::sptr Mesh::getPointColorsArray() const
396 {
397  return m_pointColors;
398 }
399 
400 //------------------------------------------------------------------------------
401 
402 ::fwData::Array::sptr Mesh::getCellColorsArray() const
403 {
404  return m_cellColors;
405 }
406 
407 //------------------------------------------------------------------------------
408 
409 ::fwData::Array::sptr Mesh::getPointNormalsArray() const
410 {
411  return m_pointNormals;
412 }
413 
414 //------------------------------------------------------------------------------
415 
416 ::fwData::Array::sptr Mesh::getCellNormalsArray() const
417 {
418  return m_cellNormals;
419 }
420 
421 //------------------------------------------------------------------------------
422 
423 ::fwData::Array::sptr Mesh::getPointTexCoordsArray() const
424 {
425  return m_pointTexCoords;
426 }
427 
428 //------------------------------------------------------------------------------
429 
430 ::fwData::Array::sptr Mesh::getCellTexCoordsArray() const
431 {
432  return m_cellTexCoords;
433 }
434 
435 //------------------------------------------------------------------------------
436 
438 {
439  m_nbPoints = 0;
440 }
441 
442 //------------------------------------------------------------------------------
443 
445 {
446  m_nbCells = 0;
447  m_cellsDataSize = 0;
448 }
449 
450 //------------------------------------------------------------------------------
451 
453 {
454  this->clearPointNormals();
455  this->clearPointColors();
456  this->clearPointTexCoords();
457  this->clearCellNormals();
458  this->clearCellColors();
459  this->clearCellTexCoords();
460 
461  m_points->clear();
462  m_cellData->clear();
463  m_cellDataOffsets->clear();
464  m_cellTypes->clear();
465  this->initArrays();
466 
467  this->clearPoints();
468  this->clearCells();
469 }
470 
471 //------------------------------------------------------------------------------
472 
474 {
475  m_pointNormals.reset();
476 }
477 
478 //------------------------------------------------------------------------------
479 
481 {
482  m_pointColors.reset();
483 }
484 
485 //------------------------------------------------------------------------------
486 
488 {
489  m_pointTexCoords.reset();
490 }
491 
492 //------------------------------------------------------------------------------
493 
495 {
496  m_cellNormals.reset();
497 }
498 
499 //------------------------------------------------------------------------------
500 
502 {
503  m_cellColors.reset();
504 }
505 
506 //------------------------------------------------------------------------------
507 
509 {
510  m_cellTexCoords.reset();
511 }
512 
513 //------------------------------------------------------------------------------
514 
515 void Mesh::setNumberOfPoints(Mesh::Id nb)
516 {
517  m_nbPoints = nb;
518 }
519 
520 //------------------------------------------------------------------------------
521 
522 Mesh::Id Mesh::getNumberOfPoints() const
523 {
524  return m_nbPoints;
525 }
526 
527 //------------------------------------------------------------------------------
528 
529 void Mesh::setNumberOfCells(Mesh::Id nb)
530 {
531  m_nbCells = nb;
532 }
533 
534 //------------------------------------------------------------------------------
535 
536 Mesh::Id Mesh::getNumberOfCells() const
537 {
538  return m_nbCells;
539 }
540 
541 
542 //------------------------------------------------------------------------------
543 
544 void Mesh::setCellDataSize(Mesh::Id size)
545 {
546  m_cellsDataSize = size;
547 }
548 
549 //------------------------------------------------------------------------------
550 
551 Mesh::Id Mesh::getCellDataSize() const
552 {
553  return m_cellsDataSize;
554 }
555 
556 //------------------------------------------------------------------------------
557 
559 {
560  size_t size = 0;
561 
562  m_points && (size += m_points->getElementSizeInBytes() * m_nbPoints);
563  m_cellTypes && (size += m_cellTypes->getElementSizeInBytes() * m_nbCells );
564  m_cellData && (size += m_cellData->getElementSizeInBytes() * m_cellsDataSize);
565  m_cellDataOffsets && (size += m_cellDataOffsets->getElementSizeInBytes() * m_nbCells);
566  m_pointColors && (size += m_pointColors->getElementSizeInBytes() * m_nbPoints);
567  m_cellColors && (size += m_cellColors->getElementSizeInBytes() * m_nbCells);
568  m_pointNormals && (size += m_pointNormals->getElementSizeInBytes() * m_nbPoints);
569  m_cellNormals && (size += m_cellNormals->getElementSizeInBytes() * m_nbCells);
570  m_pointTexCoords && (size += m_pointTexCoords->getElementSizeInBytes() * m_nbPoints);
571  m_cellTexCoords && (size += m_cellTexCoords->getElementSizeInBytes() * m_nbCells);
572 
573  return size;
574 }
575 
576 //------------------------------------------------------------------------------
577 
579 {
580  size_t size = 0;
581 
582  m_points && (size += m_points->getSizeInBytes());
583  m_cellTypes && (size += m_cellTypes->getSizeInBytes() );
584  m_cellData && (size += m_cellData->getSizeInBytes());
585  m_cellDataOffsets && (size += m_cellDataOffsets->getSizeInBytes());
586  m_pointColors && (size += m_pointColors->getSizeInBytes());
587  m_cellColors && (size += m_cellColors->getSizeInBytes());
588  m_pointNormals && (size += m_pointNormals->getSizeInBytes());
589  m_cellNormals && (size += m_cellNormals->getSizeInBytes());
590  m_pointTexCoords && (size += m_pointTexCoords->getSizeInBytes());
591  m_cellTexCoords && (size += m_cellTexCoords->getSizeInBytes());
592 
593  return size;
594 }
595 
596 //------------------------------------------------------------------------------
597 
598 void Mesh::addDataArray(const std::string &name, ::fwData::Array::sptr array)
599 {
600  m_arrayMap[name] = array;
601 }
602 
603 //------------------------------------------------------------------------------
604 
605 ::fwData::Array::sptr Mesh::getDataArray(const std::string &name) const
606 {
607  ::fwData::Array::sptr res;
608  ArrayMapType::const_iterator iter = m_arrayMap.find(name);
609  if( iter != m_arrayMap.end())
610  {
611  res = iter->second;
612  }
613  return res;
614 }
615 
616 //------------------------------------------------------------------------------
617 
618 std::vector<std::string> Mesh::getDataArrayNames() const
619 {
620  std::vector<std::string> vectNames;
621  std::transform( m_arrayMap.begin(), m_arrayMap.end(),
622  std::back_inserter(vectNames),
623  std::bind(&ArrayMapType::value_type::first, std::placeholders::_1) );
624  return vectNames;
625 }
626 
627 //------------------------------------------------------------------------------
628 
629 void Mesh::removeDataArray(const std::string &name)
630 {
631  m_arrayMap.erase(name);
632 }
633 
634 //------------------------------------------------------------------------------
635 
636 } //namespace fwData
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 &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:310
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&#39;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&#39;t impact memory allocation.
#define SLM_ASSERT(message, cond)
work like &#39;assert&#39; from &#39;cassert&#39;, with in addition a message logged by spylog (with FATAL loglevel) ...
Definition: spyLog.hpp:308
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&#39;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.