7 #include "fwTest/generator/Mesh.hpp" 9 #include <fwDataTools/Mesh.hpp> 11 #include <fwTools/NumericRoundCast.hxx> 26 return ((rand()%101-50.f))/500.f;
34 std::srand(::fwTools::numericRoundCast<unsigned int>(std::time(NULL)));
48 mesh->adjustAllocatedMemory();
55 size_t nbPointsByEdge = 10;
57 Mesh::PointsMapType points;
68 size_t nbPointsByEdge = 10;
70 Mesh::PointsMapType points;
80 size_t nbPointsByEdge = 10;
82 Mesh::PointsMapType points;
89 void Mesh::addQuadMesh(::fwData::Mesh::sptr mesh, PointsMapType& points,
size_t nbPointsByEdge,
float edgeDim)
91 ::fwDataTools::helper::Mesh::sptr meshHelper;
92 meshHelper = ::fwDataTools::helper::Mesh::New(mesh);
94 ::fwData::Mesh::PointValueType pt1[3], pt2[3], pt3[3], pt4[3];
95 ::fwData::Mesh::Id idx1, idx2, idx3, idx4;
96 float step = edgeDim / nbPointsByEdge;
99 for(
size_t x = 0;
x < nbPointsByEdge;
x++)
101 for(
size_t z = 0; z < nbPointsByEdge; z++)
119 idx1 = Mesh::addPoint(pt1, meshHelper, points);
120 idx2 = Mesh::addPoint(pt2, meshHelper, points);
121 idx3 = Mesh::addPoint(pt3, meshHelper, points);
122 idx4 = Mesh::addPoint(pt4, meshHelper, points);
124 meshHelper->insertNextCell(idx1, idx3, idx4, idx2);
129 for(
size_t y = 0; y < nbPointsByEdge; y++)
131 for(
size_t z = 0; z < nbPointsByEdge; z++)
149 idx1 = Mesh::addPoint(pt1, meshHelper, points);
150 idx2 = Mesh::addPoint(pt2, meshHelper, points);
151 idx3 = Mesh::addPoint(pt3, meshHelper, points);
152 idx4 = Mesh::addPoint(pt4, meshHelper, points);
154 meshHelper->insertNextCell(idx1, idx3, idx4, idx2);
163 ::fwDataTools::helper::Mesh::sptr meshHelper;
164 meshHelper = ::fwDataTools::helper::Mesh::New(mesh);
166 ::fwData::Mesh::PointValueType pt1[3], pt2[3], pt3[3], pt4[3];
167 ::fwData::Mesh::Id idx1, idx2, idx3, idx4;
168 float step = edgeDim / nbPointsByEdge;
171 for(
size_t x = 0;
x < nbPointsByEdge;
x++)
173 for(
size_t y = 0; y < nbPointsByEdge; y++)
191 idx1 = Mesh::addPoint(pt1, meshHelper, points);
192 idx2 = Mesh::addPoint(pt2, meshHelper, points);
193 idx3 = Mesh::addPoint(pt3, meshHelper, points);
194 idx4 = Mesh::addPoint(pt4, meshHelper, points);
196 meshHelper->insertNextCell(idx1, idx4, idx2);
197 meshHelper->insertNextCell(idx1, idx3, idx4);
202 for(
size_t y = 0; y < nbPointsByEdge; y++)
204 for(
size_t z = 0; z < nbPointsByEdge; z++)
222 idx1 = Mesh::addPoint(pt1, meshHelper, points);
223 idx2 = Mesh::addPoint(pt2, meshHelper, points);
224 idx3 = Mesh::addPoint(pt3, meshHelper, points);
225 idx4 = Mesh::addPoint(pt4, meshHelper, points);
227 meshHelper->insertNextCell(idx2, idx4, idx3);
228 meshHelper->insertNextCell(idx1, idx2, idx3);
235 ::fwData::Mesh::Id Mesh::addPoint(::fwData::Mesh::PointValueType* pt,
236 ::fwDataTools::helper::Mesh::sptr meshHelper,
237 PointsMapType& points)
241 PointsMapType::iterator it = points.find(myPoint);
242 if(it != points.end())
246 ::fwData::Mesh::Id idx = meshHelper->insertNextPoint(pt[0], pt[1], pt[2]);
247 points[myPoint] = idx;
static FWTEST_API void addQuadMesh(::fwData::Mesh::sptr mesh, PointsMapType &points, size_t nbPointsByEdge=10, float edgeDim=100.)
Add quad cells in mesh, this method generates synthetic data (two face of a cube).
static FWTEST_API void initRand()
Initialize 'rand' seed.
static FWTEST_API void addTriangleMesh(::fwData::Mesh::sptr mesh, PointsMapType &points, size_t nbPointsByEdge=10, float edgeDim=100.)
Add triangle cells in mesh, this method generates synthetic data (two face of a cube).
static FWTEST_API void generateQuadMesh(::fwData::Mesh::sptr mesh)
Generate a quad mesh.
static FWTEST_API void generateTriangleQuadMesh(::fwData::Mesh::sptr mesh)
Generate a mesh with quad and triangle cells.
static FWTEST_API void generateMesh(::fwData::Mesh::sptr mesh)
Generate a mesh.
static FWTEST_API void generateTriangleMesh(::fwData::Mesh::sptr mesh)
Generate a triangle mesh.