MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / sampleObject

Function sampleObject

Tools/VolumeSampling/main.cpp:290–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290 void sampleObject(TriangleMesh &mesh)
291 {
292 int surface = 0;
293
294 // sample object
295 const unsigned int numberOfSamplePoints = (((unsigned int)((1.0f / diameter) * (bbmax[2] - bbmin[2]))) + 1) *
296 (((unsigned int)((1.0f / diameter) * (bbmax[1] - bbmin[1]))) + 1) *
297 (((unsigned int)((1.0f / diameter) * (bbmax[0] - bbmin[0]))) + 1);
298 unsigned int currentSample = 0;
299 Real currentPercent = 0.01;
300 int counter_x = 0;
301 int counter_y = 0;
302 Real xshift = diameter;
303 Real yshift = diameter;
304
305 if ((mode == 1) || (mode == 4))
306 yshift = sqrt(static_cast<Real>(3.0)) * radius;
307 else if (mode == 2)
308 {
309 xshift = sqrt(static_cast<Real>(3.0)) * radius;
310 yshift = sqrt(static_cast<Real>(6.0)) * diameter / static_cast<Real>(3.0);
311 }
312 for (Real z = bbmin[2]; z <= bbmax[2]; z += diameter)
313 {
314 for (Real y = bbmin[1]; y <= bbmax[1]; y += yshift)
315 {
316 for (Real x = bbmin[0]; x <= bbmax[0]; x += xshift)
317 {
318 Vector3r particlePosition;
319 if ((mode == 1) || (mode == 4))
320 {
321 if (counter_y % 2 == 0)
322 particlePosition = Vector3r(x, y + radius, z + radius);
323 else
324 particlePosition = Vector3r(x + radius, y + radius, z);
325 }
326 else if (mode == 2)
327 {
328 particlePosition = Vector3r(x, y + radius, z + radius);
329
330 Vector3r shift_vec(0, 0, 0);
331 if (counter_x % 2)
332 {
333 shift_vec[2] += diameter / (static_cast<Real>(2.0) * (counter_y % 2 ? -1 : 1));
334 }
335 if (counter_y % 2)
336 {
337 shift_vec[0] += xshift / static_cast<Real>(2.0);
338 shift_vec[2] += diameter / static_cast<Real>(2.0);
339 }
340 particlePosition += shift_vec;
341 }
342 else
343 {
344 // Use center of voxel
345 particlePosition = Vector3r(x + radius, y + radius, z + radius);
346 }
347

Callers 3

generateSamplesMethod · 0.85
generateSamplesMethod · 0.85
mainFunction · 0.85

Calls 4

distanceFunction · 0.85
maxFunction · 0.85
sqrtFunction · 0.50
push_backMethod · 0.45

Tested by

no test coverage detected