fw4spl
core/fwDataTools/include/fwDataTools/helper/Mesh.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
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 #pragma once
8 
9 #include "fwDataTools/config.hpp"
10 #include "fwDataTools/helper/Array.hpp"
11 
12 #include <fwData/Mesh.hpp>
13 
14 #include <fwMemory/BufferObject.hpp>
15 
16 #include <fwTools/Type.hpp>
17 
18 namespace fwDataTools
19 {
20 
21 namespace helper
22 {
23 
27 class FWDATATOOLS_CLASS_API Mesh
28 {
29 public:
30  fwCoreClassFactoryMacro((Mesh), (((::fwData::Mesh::sptr))), new Mesh )
31 
32  FWDATATOOLS_API Mesh( ::fwData::Mesh::sptr mesh );
33 
34  FWDATATOOLS_API virtual ~Mesh();
35 
37  FWDATATOOLS_API void updateLock();
38 
49  FWDATATOOLS_API ::fwData::Mesh::Id insertNextPoint(const ::fwData::Mesh::PointValueType p[3]);
50 
55  FWDATATOOLS_API ::fwData::Mesh::Id insertNextPoint(::fwData::Mesh::PointValueType x,
56  ::fwData::Mesh::PointValueType y,
57  ::fwData::Mesh::PointValueType z);
58 
68  FWDATATOOLS_API void setPoint(::fwData::Mesh::Id id, const ::fwData::Mesh::PointValueType p[3]);
69 
74  FWDATATOOLS_API void setPoint(::fwData::Mesh::Id id,
75  ::fwData::Mesh::PointValueType x,
76  ::fwData::Mesh::PointValueType y,
77  ::fwData::Mesh::PointValueType z);
78 
91  FWDATATOOLS_API void setPointColor(::fwData::Mesh::Id id, const ::fwData::Mesh::ColorValueType c[4]);
92 
105  FWDATATOOLS_API void setCellColor(::fwData::Mesh::Id id, const ::fwData::Mesh::ColorValueType c[4]);
106 
117  FWDATATOOLS_API void setPointNormal(::fwData::Mesh::Id id, const ::fwData::Mesh::NormalValueType n[3]);
118 
129  FWDATATOOLS_API void setCellNormal(::fwData::Mesh::Id id, const ::fwData::Mesh::NormalValueType n[3]);
130 
141  FWDATATOOLS_API void setPointTexCoord(::fwData::Mesh::Id id, const ::fwData::Mesh::TexCoordValueType t[2]);
142 
153  FWDATATOOLS_API void setCellTexCoord(::fwData::Mesh::Id id, const ::fwData::Mesh::TexCoordValueType t[2]);
154 
164  FWDATATOOLS_API ::fwData::Mesh::Id insertNextCell(::fwData::Mesh::CellTypesEnum type,
165  const ::fwData::Mesh::CellValueType* cell,
166  size_t nb );
171  FWDATATOOLS_API ::fwData::Mesh::Id insertNextCell(::fwData::Mesh::CellValueType p);
176  FWDATATOOLS_API ::fwData::Mesh::Id insertNextCell(::fwData::Mesh::CellValueType p1,
177  ::fwData::Mesh::CellValueType p2 );
182  FWDATATOOLS_API ::fwData::Mesh::Id insertNextCell(::fwData::Mesh::CellValueType p1,
183  ::fwData::Mesh::CellValueType p2,
184  ::fwData::Mesh::CellValueType p3 );
189  FWDATATOOLS_API ::fwData::Mesh::Id insertNextCell(::fwData::Mesh::CellValueType p1,
190  ::fwData::Mesh::CellValueType p2,
191  ::fwData::Mesh::CellValueType p3,
192  ::fwData::Mesh::CellValueType p4,
193  ::fwData::Mesh::CellTypesEnum type = ::fwData::Mesh::QUAD);
198  template <typename T> ::fwData::Mesh::Id insertNextCell(::fwData::Mesh::CellTypesEnum type,
199  const T& pointsBegin,
200  const T& pointsEnd );
201 
203  FWDATATOOLS_API ::fwData::Mesh::PointsMultiArrayType getPoints() const;
205  FWDATATOOLS_API ::fwData::Mesh::CellTypesMultiArrayType getCellTypes() const;
207  FWDATATOOLS_API ::fwData::Mesh::CellDataMultiArrayType getCellData() const;
209  FWDATATOOLS_API ::fwData::Mesh::CellDataOffsetsMultiArrayType getCellDataOffsets() const;
211  FWDATATOOLS_API ::fwData::Mesh::PointColorsMultiArrayType getPointColors() const;
213  FWDATATOOLS_API ::fwData::Mesh::CellColorsMultiArrayType getCellColors() const;
215  FWDATATOOLS_API ::fwData::Mesh::PointNormalsMultiArrayType getPointNormals() const;
217  FWDATATOOLS_API ::fwData::Mesh::CellNormalsMultiArrayType getCellNormals() const;
219  FWDATATOOLS_API ::fwData::Mesh::PointTexCoordsMultiArrayType getPointTexCoords() const;
221  FWDATATOOLS_API ::fwData::Mesh::CellTexCoordsMultiArrayType getCellTexCoords() const;
222 
224  FWDATATOOLS_API ::fwData::Mesh::csptr getMesh() const;
225 
230  FWDATATOOLS_API bool isClosed();
231 
232 protected:
233 
234  ::fwData::Mesh::sptr m_mesh;
235 
236  ::fwDataTools::helper::Array::sptr m_helperPoints;
237  ::fwDataTools::helper::Array::sptr m_helperCellTypes;
238  ::fwDataTools::helper::Array::sptr m_helperCellData;
239  ::fwDataTools::helper::Array::sptr m_helperCellDataOffsets;
240  ::fwDataTools::helper::Array::sptr m_helperPointColors;
241  ::fwDataTools::helper::Array::sptr m_helperCellColors;
242  ::fwDataTools::helper::Array::sptr m_helperPointNormals;
243  ::fwDataTools::helper::Array::sptr m_helperCellNormals;
244  ::fwDataTools::helper::Array::sptr m_helperPointTexCoords;
245  ::fwDataTools::helper::Array::sptr m_helperCellTexCoords;
246 
247 };
248 
249 } // namespace helper
250 
251 } // namespace fwData
The namespace fwDataTools contains classes which provide helpers to manipulate fwData::Object. *.
#define fwCoreClassFactoryMacro(_classinfo_, _parameters_, _factory_)
Generate methods for classes with one factory.
Helper to manage Mesh. Lock the mesh buffer before to modify it.