VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
GbVoxelMatrix3D.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
33//=======================================================================================
35
41
44
45using namespace std;
46
47const float GbVoxelMatrix3D::SOLID = 1.0f;
48const float GbVoxelMatrix3D::FLUID = 0.0f;
49
50/*=======================================================*/
51// Konstruktor
52GbVoxelMatrix3D::GbVoxelMatrix3D(int nx1, int nx2, int nx3, float initVal, double lowerThreshold, double upperThreshold)
53 : GbObject3D(), lowerThreshold(lowerThreshold), upperThreshold(upperThreshold), nodesX1(nx1), nodesX2(nx2),
54 nodesX3(nx3), voxelMatrix(Matrix3D(nx1, nx2, nx3, initVal))
55{
56 this->setName("VoxelMatrix3D");
57}
58/*=======================================================*/
59GbVoxelMatrix3D::GbVoxelMatrix3D() : GbObject3D() { this->setName("VoxelMatrix3D"); }
60/*=======================================================*/
61GbVoxelMatrix3D::GbVoxelMatrix3D(const Matrix3D &voxelMatrix, double lowerThreshold, double upperThreshold)
62 : GbObject3D(), nodesX1((int)voxelMatrix.getNX1()), nodesX2((int)voxelMatrix.getNX2()),
63 nodesX3((int)voxelMatrix.getNX3()), lowerThreshold(lowerThreshold), upperThreshold(upperThreshold),
64 voxelMatrix(voxelMatrix)
65{
66 this->setName("VoxelMatrix3D");
67}
68/*=======================================================*/
70{
72 vm->setVoxelMatrixMininum(minX1, minX2, minX3);
73 vm->setVoxelMatrixDelta(deltaX1, deltaX2, deltaX3);
74 return vm;
75}
76/*=======================================================*/
77void GbVoxelMatrix3D::setCenterCoordinates(const double &x1, const double &x2, const double &x3)
78{
79 this->translate(x1 - getX1Centroid(), x2 - getX2Centroid(), x3 - getX3Centroid());
80}
81/*=======================================================*/
82void GbVoxelMatrix3D::translate(const double &tx1, const double &tx2, const double &tx3)
83{
84 this->minX1 += tx1;
85 this->minX2 += tx2;
86 this->minX3 += tx3;
88}
89/*=======================================================*/
91{
94
95 for (int x3 = 0; x3 < nodesX3; x3++) {
96 for (int x2 = 0; x2 < nodesX2; x2++) {
97 for (int x1 = 0; x1 < nodesX1; x1++) {
98 if (voxelMatrix(x1, x2, x3) == FLUID) {
99 UBLOG(logINFO, "setClosedVoidSpaceToSolid:start");
100 x1Nbr.push_back(x1);
101 x2Nbr.push_back(x2);
102 x3Nbr.push_back(x3);
103 int size = (int)x1Nbr.size();
104 while (size > 0) {
105 for (int i = 0; i < size; i++) {
107 }
108
109 swap(x1Nbr, x1NbrTemp);
110 swap(x2Nbr, x2NbrTemp);
111 swap(x3Nbr, x3NbrTemp);
112
113 x1NbrTemp.clear();
114 x2NbrTemp.clear();
115 x3NbrTemp.clear();
116 size = (int)x1Nbr.size();
117 }
118 UBLOG(logINFO, "setClosedVoidSpaceToSolid:end");
120 return;
121 }
122 }
123 }
124 }
125}
126/*=======================================================*/
127void GbVoxelMatrix3D::findFluidNeighbor(int x1, int x2, int x3)
128{
129 for (int k3 = -1; k3 <= 1; k3++) {
130 for (int k2 = -1; k2 <= 1; k2++) {
131 for (int k1 = -1; k1 <= 1; k1++) {
132 int j1 = x1 + k1;
133 int j2 = x2 + k2;
134 int j3 = x3 + k3;
135 if (j1 >= 0 && j1 < nodesX1 && j2 >= 0 && j2 < nodesX2 && j3 >= 0 && j3 < nodesX3) {
136 if (voxelMatrix(j1, j2, j3) == FLUID) {
137 if (flagMatrix(j1, j2, j3) == 0) {
139 flagMatrix(j1, j2, j3) = 1;
140 x1NbrTemp.push_back(j1);
141 x2NbrTemp.push_back(j2);
142 x3NbrTemp.push_back(j3);
143 }
144 }
145 }
146 }
147 }
148 }
149}
150/*=======================================================*/
152{
153 numberOfSolid = 0;
154
155 for (int x3 = 0; x3 < nodesX3; x3++)
156 for (int x2 = 0; x2 < nodesX2; x2++)
157 for (int x1 = 0; x1 < nodesX1; x1++) {
158 if (voxelMatrix(x1, x2, x3) == GbVoxelMatrix3D::SOLID) {
160 }
161 }
162
164}
165/*=======================================================*/
167/*=======================================================*/
169/*=======================================================*/
170double GbVoxelMatrix3D::getIntersectionRaytraceFactor(const double &x1, const double &x2, const double &x3,
171 const double &rx1, const double &rx2, const double &rx3)
172{
173 if (!((ub_math::equal(rx1, 0.0) || ub_math::equal(fabs(rx1), 1.0) ||
174 ub_math::equal(fabs(rx1), vf::basics::constant::c1oSqrt2) || ub_math::equal(fabs(rx1), vf::basics::constant::c1oSqrt3)) &&
175 (ub_math::equal(rx2, 0.0) || ub_math::equal(fabs(rx2), 1.0) ||
176 ub_math::equal(fabs(rx2), vf::basics::constant::c1oSqrt2) || ub_math::equal(fabs(rx2), vf::basics::constant::c1oSqrt3)) &&
177 (ub_math::equal(rx3, 0.0) || ub_math::equal(fabs(rx3), 1.0) ||
178 ub_math::equal(fabs(rx3), vf::basics::constant::c1oSqrt2) || ub_math::equal(fabs(rx3), vf::basics::constant::c1oSqrt3)))) {
179 throw UbException(UB_EXARGS, "nur fuer diskrete Boltzmannrichungen implementiert!!!");
180 }
181
182 // nachbarindex ermitteln
183 int ndx1 = 0, ndx2 = 0, ndx3 = 0;
184 if (ub_math::greater(rx1, 0.0))
185 ndx1 = 1;
186 else if (ub_math::less(rx1, 0.0))
187 ndx1 = -1;
188 if (ub_math::greater(rx2, 0.0))
189 ndx2 = 1;
190 else if (ub_math::less(rx2, 0.0))
191 ndx2 = -1;
192 if (ub_math::greater(rx3, 0.0))
193 ndx3 = 1;
194 else if (ub_math::less(rx3, 0.0))
195 ndx3 = -1;
196
200
201 // test ob nachbar solid
202 if (nix1 >= 0 && nix2 >= 0 && nix3 >= 0 && nix1 < (int)voxelMatrix.getNX1() && nix2 < (int)voxelMatrix.getNX2() &&
203 nix3 < (int)voxelMatrix.getNX3()) {
205 // return halber abstand der beiden knoten
206 return 0.5 * sqrt((ndx1 * deltaX1) * (ndx1 * deltaX1) + (ndx2 * deltaX2) * (ndx2 * deltaX2) +
207 (ndx3 * deltaX3) * (ndx3 * deltaX3));
208 }
209 }
210
211 return 0.0;
212}
213/*=======================================================*/
214bool GbVoxelMatrix3D::isPointInGbObject3D(const double &x1p, const double &x2p, const double &x3p)
215{
216 int ix1 = ub_math::integerRounding((x1p - minX1) / deltaX1);
217 int ix2 = ub_math::integerRounding((x2p - minX2) / deltaX2);
218 int ix3 = ub_math::integerRounding((x3p - minX3) / deltaX3);
219
220 if (ix1 >= 0 && ix2 >= 0 && ix3 >= 0 && ix1 < (int)voxelMatrix.getNX1() && ix2 < (int)voxelMatrix.getNX2() &&
221 ix3 < (int)voxelMatrix.getNX3()) {
222 if (ub_math::equal(voxelMatrix(ix1, ix2, ix3), SOLID))
223 return true;
224 }
225 return false;
226}
227/*=======================================================*/
228bool GbVoxelMatrix3D::isPointInGbObject3D(const double &x1p, const double &x2p, const double &x3p,
229 bool &pointIsOnBoundary)
230{
231 pointIsOnBoundary = false;
232
233 return isPointInGbObject3D(x1p, x2p, x3p);
234}
235/*=======================================================*/
236bool GbVoxelMatrix3D::isCellInsideGbObject3D(const double & /*x1p1*/, const double & /*x2p1*/, const double & /*x3p1*/,
237 const double & /*x1p2*/, const double & /*x2p2*/, const double & /*x3p2*/)
238{
239 return false;
240 // FIXME: unreachable cide
242
243 // //indizes ermitteln
244 // int startix1 = (int)std::floor((x1p1-minX1)/deltaX1+1E-13);
245 // int startix2 = (int)std::floor((x2p1-minX2)/deltaX2+1E-13);
246 // int startix3 = (int)std::floor((x3p1-minX3)/deltaX3+1E-13);
247
248 // if (startix1<0) return false;
249 // if (startix2<0) return false;
250 // if (startix3<0) return false;
251
252 // int maxiX1 = (int)voxelMatrix.getNX1()-1;
253 // int maxiX2 = (int)voxelMatrix.getNX2()-1;
254 // int maxiX3 = (int)voxelMatrix.getNX3()-1;
255
256 // int endix1 = (int)std::ceil((x1p2-minX1)/deltaX1-1E-13);
257 // int endix2 = (int)std::ceil((x2p2-minX2)/deltaX2-1E-13);
258 // int endix3 = (int)std::ceil((x3p2-minX3)/deltaX3-1E-13);
259
260 // if (endix1>maxiX1) return false;
261 // if (endix2>maxiX2) return false;
262 // if (endix3>maxiX3) return false;
263
264 // for (int ix3 = startix3; ix3<=endix3; ix3++)
265 // for (int ix2 = startix2; ix2<=endix2; ix2++)
266 // for (int ix1 = startix1; ix1<=endix1; ix1++)
267 // if (ub_math::equal(voxelMatrix(ix1, ix2, ix3), FLUID))
268 // return false;
269 // return true;
270}
271/*=======================================================*/
272bool GbVoxelMatrix3D::isCellCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a,
273 const double &x1b, const double &x2b, const double &x3b)
274// Merksatz: cell oder deren Volumen schneidet oder beinhaltet komplette oder Teile der CuboidUmrandung
275// returns true:
276// - cell cuts GbVoxelMatrix3D
277// - cell boxes GbVoxelMatrix3D
278// returns false:
279// - cell completely inside GbVoxelMatrix3D
280// - cell und cuboid3D haben kein gemeinsames Volumen
281{
282 // erstmal die dumm Loesung
283 if (!(this->isCellInsideGbObject3D(x1a, x2a, x3a, x1b, x2b, x3b)) &&
285 return true;
286 }
287
288 return false;
289}
290/*=======================================================*/
291bool GbVoxelMatrix3D::isCellInsideOrCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a,
292 const double &x1b, const double &x2b, const double &x3b)
293// returns true:
294// - cell completely inside cuboid3D ( = cuboid3D boxes cell)
295// - cell cuts cuboid3D
296// - cell boxes cuboid3D
297// returns false:
298// - cell und cuboid3D haben kein gemeinsames Volumen
299{
300 // simpler check, da unser GbCuboid3D ein AABB is:
301 // anfA midA endA anfB midB endB
302 // | x<-- dxA -->| |<-dxB->x |
303 // |<----------------- T --------------->|
304 // ist |T| <= dxA + dxB -> overlap!
305
306 if (ub_math::lessEqual(std::fabs(this->getX1Centroid() - 0.5 * (x1b + x1a) /*Tx1*/),
307 0.5 * (this->getLengthX1() + std::fabs(x1b - x1a) /*dx1A+dx1B*/))
308
309 && ub_math::lessEqual(std::fabs(this->getX2Centroid() - 0.5 * (x2b + x2a) /*Tx2*/),
310 0.5 * (this->getLengthX2() + std::fabs(x2b - x2a) /*dx2A+dx2B*/))
311
312 && ub_math::lessEqual(std::fabs(this->getX3Centroid() - 0.5 * (x3b + x3a) /*Tx3*/),
313 0.5 * (this->getLengthX3() + std::fabs(x3b - x3a) /*dx3A+dx3B*/))) {
314 return true;
315 }
316
317 return false;
318}
319/*=======================================================*/
321{
322 vector<GbTriangle3D *> triangles;
323 cerr
324 << "vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet() - benoetigt MARCHING_CUBE paket aus 3rdParty"
325 << endl;
326 return triangles;
327}
328/*=======================================================*/
330{
331 UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet start")
332 if (!this->addSurfaceTriangleSetFlag) {
333 UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet end without TriangleSetCreation")
334 return;
335 }
336
337 cerr << "void GbVoxelMatrix3D.addSurfaceTriangleSet - benoetigt MARCHING_CUBE paket aus 3rdParty" << endl;
338
339 UBLOG(logINFO, " GbVoxelMatrix3D addSurfaceTriangleSet end")
340}
341/*=======================================================*/
342string GbVoxelMatrix3D::toString() { return "GbVoxelMatrix3D"; }
343/*=======================================================*/
344// void GbVoxelMatrix3D::readMatrixFromVtiASCIIFile(std::string filename)
345
346// {
347// // UBLOG(logINFO," - create GbVoxelMatrix3D");
348// UbFileInputASCII in(filename);
349// // ifstream in(filename.c_str(), ios::binary);
350// if (!in)
351// throw UbException(UB_EXARGS, "could not open file " + filename);
352// in.readLine();
353// in.readLine();
354// in.readLine();
355// in.readLine();
356// in.readLine();
357
358// voxelMatrix = Matrix3D(nodesX1, nodesX2, nodesX3, GbVoxelMatrix3D::FLUID);
359
360// // UBLOG(logINFO," - init values");
361// int val;
362// for (int x3 = 0; x3 < nodesX3; x3++)
363// for (int x2 = 0; x2 < nodesX2; x2++)
364// for (int x1 = 0; x1 < nodesX1; x1++) {
365// val = in.readInteger();
366// // if( !ub_math::equal(val, 0.0f) )
367// // if( ub_math::greater(val, threshold) )
368// if ((double)val >= lowerThreshold && (double)val <= upperThreshold) {
369// (voxelMatrix)(x1, x2, x3) = GbVoxelMatrix3D::SOLID;
370// }
371// }
372// // UBLOG(logINFO," - create GbVoxelMatrix3D done");
373// }
375
378{
379 using namespace std;
380
381 ifstream in(filename.c_str());
382 if (!in) {
383 throw UbException(UB_EXARGS, "could not open file " + filename);
384 }
385
386 // read whole file into string
387 std::ostringstream ss;
388 ss << in.rdbuf();
389 std::string content = ss.str();
390
391 // parse WholeExtent="xmin xmax ymin ymax zmin zmax"
392 int xmin = 0, xmax = -1, ymin = 0, ymax = -1, zmin = 0, zmax = -1;
393 {
394 size_t pos = content.find("WholeExtent=\"");
395 if (pos != std::string::npos) {
396 pos += strlen("WholeExtent=\"");
397 std::istringstream is(content.substr(pos));
398 is >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax;
399 nodesX1 = xmax - xmin + 1;
400 nodesX2 = ymax - ymin + 1;
401 nodesX3 = zmax - zmin + 1;
402 }
403 }
404
405 // parse Origin="ox oy oz"
406 {
407 size_t pos = content.find("Origin=\"");
408 if (pos != std::string::npos) {
409 pos += strlen("Origin=\"");
410 std::istringstream is(content.substr(pos));
411 double ox, oy, oz;
412 is >> ox >> oy >> oz;
413 minX1 = ox;
414 minX2 = oy;
415 minX3 = oz;
416 }
417 }
418
419 // parse Spacing="sx sy sz"
420 {
421 size_t pos = content.find("Spacing=\"");
422 if (pos != std::string::npos) {
423 pos += strlen("Spacing=\"");
424 std::istringstream is(content.substr(pos));
425 double sx, sy, sz;
426 is >> sx >> sy >> sz;
427 deltaX1 = sx;
428 deltaX2 = sy;
429 deltaX3 = sz;
430 }
431 }
432
433 // fallback: if extent not found but nodesX* already set, keep them
434 if (nodesX1 <= 0 || nodesX2 <= 0 || nodesX3 <= 0) {
435 throw UbException(UB_EXARGS, "invalid or missing WholeExtent in VTI and nodes not set");
436 }
437
438 // find the first DataArray with format="ascii"
439 size_t dataPos = std::string::npos;
440 {
441 size_t searchPos = 0;
442 while (true) {
443 size_t tag = content.find("<DataArray", searchPos);
444 if (tag == std::string::npos) break;
445 size_t tagEnd = content.find('>', tag);
446 if (tagEnd == std::string::npos) break;
447 std::string header = content.substr(tag, tagEnd - tag + 1);
448 if (header.find("format=\"ascii\"") != std::string::npos) {
449 // found the ascii DataArray header; data begins after tagEnd+1
450 dataPos = tagEnd + 1;
451 break;
452 }
453 searchPos = tagEnd + 1;
454 }
455 }
456
457 if (dataPos == std::string::npos) {
458 throw UbException(UB_EXARGS, "no ASCII DataArray found in VTI file " + filename);
459 }
460
461 // find end of that DataArray
462 size_t endTag = content.find("</DataArray>", dataPos);
463 if (endTag == std::string::npos) {
464 throw UbException(UB_EXARGS, "malformed VTI: missing </DataArray> in " + filename);
465 }
466
467 std::string dataText = content.substr(dataPos, endTag - dataPos);
468
469 // read numeric values
470 std::istringstream dataStream(dataText);
471 std::vector<double> values;
472 values.reserve((size_t)nodesX1 * nodesX2 * nodesX3);
473 double v;
474 while (dataStream >> v) values.push_back(v);
475
476 unsigned long long expected = (unsigned long long)nodesX1 * (unsigned long long)nodesX2 * (unsigned long long)nodesX3;
477 if (values.size() < expected) {
478 throw UbException(UB_EXARGS, "insufficient data values in VTI (got " + ub_system::toString(values.size()) +
479 ", expected " + ub_system::toString(expected) + ")");
480 }
481
482 // create voxel matrix and fill applying thresholds
484
485 long solidCount = 0;
486 size_t idx = 0;
487 // VTK imagedata: x fastest, then y, then z
488 for (int z = 0; z < nodesX3; ++z) {
489 for (int y = 0; y < nodesX2; ++y) {
490 for (int x = 0; x < nodesX1; ++x) {
491 double val = values[idx++];
492 if (val >= lowerThreshold && val <= upperThreshold) {
494 ++solidCount;
495 } else {
497 }
498 }
499 }
500 }
501
504}
508{
509 using namespace std;
510
511 ifstream in(filename.c_str(), ios::binary);
512 if (!in) {
513 throw UbException(UB_EXARGS, "could not open file " + filename);
514 }
515
516 // read whole file into string (binary-safe)
517 std::ostringstream ss;
518 ss << in.rdbuf();
519 std::string content = ss.str();
520
521 // parse WholeExtent (same as ASCII reader)
522 int xmin = 0, xmax = -1, ymin = 0, ymax = -1, zmin = 0, zmax = -1;
523 {
524 size_t pos = content.find("WholeExtent=\"");
525 if (pos != std::string::npos) {
526 pos += strlen("WholeExtent=\"");
527 std::istringstream is(content.substr(pos));
528 is >> xmin >> xmax >> ymin >> ymax >> zmin >> zmax;
529 nodesX1 = xmax - xmin + 1;
530 nodesX2 = ymax - ymin + 1;
531 nodesX3 = zmax - zmin + 1;
532 }
533 }
534
535 // parse Origin
536 {
537 size_t pos = content.find("Origin=\"");
538 if (pos != std::string::npos) {
539 pos += strlen("Origin=\"");
540 std::istringstream is(content.substr(pos));
541 double ox, oy, oz;
542 is >> ox >> oy >> oz;
543 minX1 = ox;
544 minX2 = oy;
545 minX3 = oz;
546 }
547 }
548
549 // parse Spacing
550 {
551 size_t pos = content.find("Spacing=\"");
552 if (pos != std::string::npos) {
553 pos += strlen("Spacing=\"");
554 std::istringstream is(content.substr(pos));
555 double sx, sy, sz;
556 is >> sx >> sy >> sz;
557 deltaX1 = sx;
558 deltaX2 = sy;
559 deltaX3 = sz;
560 }
561 }
562
563 if (nodesX1 <= 0 || nodesX2 <= 0 || nodesX3 <= 0) {
564 throw UbException(UB_EXARGS, "invalid or missing WholeExtent in VTI and nodes not set");
565 }
566
567 // find <AppendedData ...> tag
568 size_t appendedTag = content.find("<AppendedData");
569 if (appendedTag == std::string::npos) {
570 throw UbException(UB_EXARGS, "no <AppendedData> found in VTI file " + filename);
571 }
572 size_t appendedTagEnd = content.find('>', appendedTag);
573 if (appendedTagEnd == std::string::npos) {
574 throw UbException(UB_EXARGS, "malformed <AppendedData> tag in " + filename);
575 }
576
577 // find the '_' that precedes binary appended data (per VTK standard)
578 size_t underscorePos = content.find('_', appendedTagEnd);
579 if (underscorePos == std::string::npos) {
580 throw UbException(UB_EXARGS, "could not find '_' start of appended data in " + filename);
581 }
582
583 // scan DataArray headers before AppendedData, collect those with offset attributes
584 struct DataArrayInfo {
585 unsigned long long offset;
586 std::string type;
587 int numComp;
588 size_t headerPos;
589 };
590 std::vector<DataArrayInfo> arrays;
591
592 size_t searchPos = 0;
593 while (true) {
594 size_t tag = content.find("<DataArray", searchPos);
595 if (tag == std::string::npos || tag > appendedTag) break; // only header area
596 size_t tagEnd = content.find('>', tag);
597 if (tagEnd == std::string::npos) break;
598 std::string header = content.substr(tag, tagEnd - tag + 1);
599
600 size_t offPos = header.find("offset=\"");
601 if (offPos != std::string::npos) {
602 offPos += strlen("offset=\"");
603 size_t offEnd = header.find('"', offPos);
604 if (offEnd != std::string::npos) {
605 std::string offStr = header.substr(offPos, offEnd - offPos);
606 unsigned long long offset = stoull(offStr);
607
608 // parse type (e.g. Float32, Float64, Int32)
609 std::string dtype = "Float32";
610 size_t tpos = header.find("type=\"");
611 if (tpos != std::string::npos) {
612 tpos += strlen("type=\"");
613 size_t tend = header.find('"', tpos);
614 if (tend != std::string::npos)
615 dtype = header.substr(tpos, tend - tpos);
616 }
617
618 int numComp = 1;
619 size_t cpos = header.find("NumberOfComponents=\"");
620 if (cpos != std::string::npos) {
621 cpos += strlen("NumberOfComponents=\"");
622 size_t cend = header.find('"', cpos);
623 if (cend != std::string::npos) {
624 numComp = stoi(header.substr(cpos, cend - cpos));
625 }
626 }
627
628 arrays.push_back({offset, dtype, numComp, tag});
629 }
630 }
631
632 searchPos = tagEnd + 1;
633 }
634
635 if (arrays.empty()) {
636 throw UbException(UB_EXARGS, "no DataArray with offset found in VTI header for " + filename);
637 }
638
639 // We'll pick the first DataArray whose block size matches expected size,
640 // or fall back to the first one.
641 unsigned long long expectedTuples = (unsigned long long)nodesX1 * nodesX2 * nodesX3;
642 bool foundBlock = false;
643 std::vector<double> values;
644 values.reserve((size_t)expectedTuples);
645
646 // reopen file as binary stream (we already have content but we'll use file IO for seeking)
647 in.clear();
648 in.seekg(0, ios::beg);
649
650 for (auto &info : arrays) {
651 // offset is relative to the first byte after underscore
652 unsigned long long dataPosInFile = underscorePos + 1 + info.offset;
653 // read 4-byte block size (VTK writes uint32 block size before each block)
654 in.seekg((std::streamoff)dataPosInFile, ios::beg);
655 if (!in.good()) continue;
656
658 in.read(reinterpret_cast<char *>(&blockSize), sizeof(uint32_t));
659 if (!in) continue;
660
661 // read block
662 std::vector<char> buffer(blockSize);
663 in.read(buffer.data(), blockSize);
664 if ((unsigned)in.gcount() != blockSize) continue;
665
666 // interpret buffer according to info.type
667 size_t comp = (info.numComp > 0 ? info.numComp : 1);
668 try {
669 if (info.type == "Float32" || info.type == "float") {
670 size_t nvals = blockSize / sizeof(float);
671 if (nvals % comp != 0) continue;
672 size_t tuples = nvals / comp;
673 if (tuples != expectedTuples) {
674 // continue searching; not the data array we want
675 // but still allow if nothing matches later
676 }
677 values.clear();
678 values.reserve(tuples);
679 for (size_t i = 0; i < tuples; ++i) {
680 // assume single-component or treat first component
681 float v = 0.0f;
682 // if multiple components, pick first component per tuple
683 std::memcpy(&v, buffer.data() + (i * comp + 0) * sizeof(float), sizeof(float));
684 values.push_back((double)v);
685 }
686 foundBlock = true;
687 } else if (info.type == "Float64" || info.type == "double") {
688 size_t nvals = blockSize / sizeof(double);
689 if (nvals % comp != 0) continue;
690 size_t tuples = nvals / comp;
691 values.clear();
692 values.reserve(tuples);
693 for (size_t i = 0; i < tuples; ++i) {
694 double v = 0.0;
695 std::memcpy(&v, buffer.data() + (i * comp + 0) * sizeof(double), sizeof(double));
696 values.push_back(v);
697 }
698 foundBlock = true;
699 } else if (info.type == "Int32" || info.type == "int" || info.type == "Int") {
700 size_t nvals = blockSize / sizeof(int32_t);
701 if (nvals % comp != 0) continue;
702 size_t tuples = nvals / comp;
703 values.clear();
704 values.reserve(tuples);
705 for (size_t i = 0; i < tuples; ++i) {
706 int32_t vi = 0;
707 std::memcpy(&vi, buffer.data() + (i * comp + 0) * sizeof(int32_t), sizeof(int32_t));
708 values.push_back((double)vi);
709 }
710 foundBlock = true;
711 } else if (info.type == "UInt8" || info.type == "unsigned_char" || info.type == "unsigned_char") {
712 size_t nvals = blockSize / sizeof(uint8_t);
713 if (nvals % comp != 0) continue;
714 size_t tuples = nvals / comp;
715 values.clear();
716 values.reserve(tuples);
717 for (size_t i = 0; i < tuples; ++i) {
718 uint8_t vi = 0;
719 std::memcpy(&vi, buffer.data() + (i * comp + 0) * sizeof(uint8_t), sizeof(uint8_t));
720 values.push_back((double)vi);
721 }
722 foundBlock = true;
723 } else {
724 // unsupported type - skip
725 continue;
726 }
727 } catch (...) {
728 continue;
729 }
730
731 if (foundBlock) break;
732 }
733
734 if (!foundBlock || values.empty()) {
735 throw UbException(UB_EXARGS, "could not extract appended data from VTI " + filename);
736 }
737
738 unsigned long long expected = expectedTuples;
739 if (values.size() < expected) {
740 throw UbException(UB_EXARGS, "insufficient data values in appended VTI (got " + ub_system::toString(values.size()) +
741 ", expected " + ub_system::toString(expected) + ")");
742 }
743
744 // create voxel matrix and fill applying thresholds (VTK ImageData ordering: x fastest, then y, then z)
746
747 long solidCount = 0;
748 size_t idx = 0;
749 for (int z = 0; z < nodesX3; ++z) {
750 for (int y = 0; y < nodesX2; ++y) {
751 for (int x = 0; x < nodesX1; ++x) {
752 double val = values[idx++];
753 if (val >= lowerThreshold && val <= upperThreshold) {
755 ++solidCount;
756 } else {
758 }
759 }
760 }
761 }
762
765}
767void GbVoxelMatrix3D::rotate90aroundX(double /*cX1*/, double cX2, double cX3)
768{
769 // double tempMinPunktX1 = minX1-cX1;
770 double tempMinPunktX2 = minX2 - cX2;
771 double tempMinPunktX3 = getX3Maximum() - cX3;
772
773 // double tempMinPunktX1tf = tempMinPunktX1;
776
777 // double minX1_temp = tempMinPunktX1tf+cX1;
780
783
784 int nx1 = (int)voxelMatrix.getNX1();
785 int nx2 = (int)voxelMatrix.getNX2();
786 int nx3 = (int)voxelMatrix.getNX3();
787
788 int nx1_new = nx1;
789 int nx2_new = nx3;
790 int nx3_new = nx2;
791
792 double delta_temp = deltaX2;
795
797
798 for (int x3 = 0; x3 < nx3; x3++) {
799 for (int x2 = 0; x2 < nx2; x2++) {
800 for (int x1 = 0; x1 < nx1; x1++) {
801 voxelMatrix_temp(x1, nx3 - x3 - 1, x2) = this->voxelMatrix(x1, x2, x3);
802 }
803 }
804 }
805 std::swap(this->voxelMatrix, voxelMatrix_temp);
806}
809{
810 double cX1 = this->getX1Centroid();
811 double cX2 = this->getX2Centroid();
812 double cX3 = this->getX3Centroid();
813
814 rotate90aroundX(cX1, cX2, cX3);
815}
817void GbVoxelMatrix3D::rotate90aroundY(double cX1, double /*cX2*/, double cX3)
818{
819 double tempMinPunktX1 = getX1Maximum() - cX1;
820 // double tempMinPunktX2 = minX2-cX2;
821 double tempMinPunktX3 = minX3 - cX3;
822
824 // double tempMinPunktX2tf = tempMinPunktX2;
826
828 // double minX2_temp = tempMinPunktX2tf+cX2;
830
833
834 int nx1 = (int)voxelMatrix.getNX1();
835 int nx2 = (int)voxelMatrix.getNX2();
836 int nx3 = (int)voxelMatrix.getNX3();
837
838 int nx1_new = nx3;
839 int nx2_new = nx2;
840 int nx3_new = nx1;
841
842 double delta_temp = deltaX1;
845
847
848 for (int x3 = 0; x3 < nx3; x3++) {
849 for (int x2 = 0; x2 < nx2; x2++) {
850 for (int x1 = 0; x1 < nx1; x1++) {
851 voxelMatrix_temp(x3, x2, nx1 - x1 - 1) = this->voxelMatrix(x1, x2, x3);
852 }
853 }
854 }
855 std::swap(this->voxelMatrix, voxelMatrix_temp);
856}
859{
860 double cX1 = this->getX1Centroid();
861 double cX2 = this->getX2Centroid();
862 double cX3 = this->getX3Centroid();
863
864 rotate90aroundY(cX1, cX2, cX3);
865}
867void GbVoxelMatrix3D::rotate90aroundZ(double cX1, double cX2, double /*cX3*/)
868{
869 double tempMinPunktX1 = minX1 - cX1;
870 double tempMinPunktX2 = getX2Maximum() - cX2;
871 // double tempMinPunktX3 = minX3-cX3;
872
875 // double tempMinPunktX3tf = tempMinPunktX3;
876
879 // double minX3_temp = tempMinPunktX3tf+cX3;
880
883
884 int nx1 = (int)voxelMatrix.getNX1();
885 int nx2 = (int)voxelMatrix.getNX2();
886 int nx3 = (int)voxelMatrix.getNX3();
887
888 int nx1_new = nx2;
889 int nx2_new = nx1;
890 int nx3_new = nx3;
891
892 double delta_temp = deltaX1;
895
897
898 for (int x3 = 0; x3 < nx3; x3++) {
899 for (int x2 = 0; x2 < nx2; x2++) {
900 for (int x1 = 0; x1 < nx1; x1++) {
901 voxelMatrix_temp(nx2 - x2 - 1, x1, x3) = this->voxelMatrix(x1, x2, x3);
902 }
903 }
904 }
905 std::swap(this->voxelMatrix, voxelMatrix_temp);
906}
909{
910 double cX1 = this->getX1Centroid();
911 double cX2 = this->getX2Centroid();
912 double cX3 = this->getX3Centroid();
913
914 rotate90aroundZ(cX1, cX2, cX3);
915}
918{
919 int nx1 = (int)voxelMatrix.getNX1();
920 int nx2 = (int)voxelMatrix.getNX2();
921 int nx3 = (int)voxelMatrix.getNX3();
922
924
925 for (int x3 = 0; x3 < nx3; x3++) {
926 for (int x2 = 0; x2 < nx2; x2++) {
927 for (int x1 = 0; x1 < nx1; x1++) {
928 voxelMatrix_temp(nx1 - x1 - 1, x2, x3) = this->voxelMatrix(x1, x2, x3);
929 }
930 }
931 }
932 std::swap(this->voxelMatrix, voxelMatrix_temp);
933}
936{
937 int nx1 = (int)voxelMatrix.getNX1();
938 int nx2 = (int)voxelMatrix.getNX2();
939 int nx3 = (int)voxelMatrix.getNX3();
940
942
943 for (int x3 = 0; x3 < nx3; x3++) {
944 for (int x2 = 0; x2 < nx2; x2++) {
945 for (int x1 = 0; x1 < nx1; x1++) {
946 voxelMatrix_temp(x1, nx2 - x2 - 1, x3) = this->voxelMatrix(x1, x2, x3);
947 }
948 }
949 }
950 std::swap(this->voxelMatrix, voxelMatrix_temp);
951}
954{
955 int nx1 = (int)voxelMatrix.getNX1();
956 int nx2 = (int)voxelMatrix.getNX2();
957 int nx3 = (int)voxelMatrix.getNX3();
958
960
961 for (int x3 = 0; x3 < nx3; x3++) {
962 for (int x2 = 0; x2 < nx2; x2++) {
963 for (int x1 = 0; x1 < nx1; x1++) {
964 voxelMatrix_temp(x1, x2, nx3 - x3 - 1) = this->voxelMatrix(x1, x2, x3);
965 }
966 }
967 }
968 std::swap(this->voxelMatrix, voxelMatrix_temp);
969}
972{
973 int nx1 = (int)voxelMatrix.getNX1();
974 int nx2 = (int)voxelMatrix.getNX2();
975 int nx3 = (int)voxelMatrix.getNX3();
976
978
979 for (int x3 = 0; x3 < nx3; x3++) {
980 for (int x2 = 0; x2 < nx2; x2++) {
981 for (int x1 = 0; x1 < nx1; x1++) {
982 if (voxelMatrix(x1, x2, x3) == SOLID) {
983 double rcX1 = minX1 + deltaX1 * x1;
984 double rcX3 = minX3 + deltaX3 * x3;
985
986 double nrcX1 = cos(theta) * rcX1 + sin(theta) * rcX3;
987 double nrcX3 = -sin(theta) * rcX1 + cos(theta) * rcX3;
988
990 int newX2 = x2;
992
993 if (newX1 > 0 && newX3 > 0 && newX1 < nx1 && newX3 < nx3) {
995 }
996
997 // int ix1, ix2, ix3;
998 // double ixx1 = (abs(nrcX1-minX1)/deltaX1);
999 // ix2 = x2;
1000 // double ixx3 = (abs(nrcX3-minX3)/deltaX3);
1001 // if (ixx1-(int)ixx1>.9999999999) ix1 = (int)ixx1+1; else ix1 = (int)ixx1;
1003 // if (ixx3-(int)ixx3>.9999999999) ix3 = (int)ixx3+1; else ix3 = (int)ixx3;
1004
1005 // if (ix1>=0 && ix3>=0 && ix1<nx1 && ix3<nx3)
1006 //{
1007 // voxelMatrix_temp(ix1, ix2, ix3) = voxelMatrix(x1, x2, x3);
1008 //}
1009 }
1010 }
1011 }
1012 }
1013 std::swap(voxelMatrix, voxelMatrix_temp);
1014
1015 for (int x3 = 0; x3 < nx3; x3++)
1016 for (int x2 = 0; x2 < nx2; x2++)
1017 for (int x1 = 0; x1 < nx1; x1++) {
1018 int count = 0;
1019 for (int k3 = -1; k3 <= 1; k3++)
1020 for (int k1 = -1; k1 <= 1; k1++) {
1021 int j1 = x1 + k1;
1022 int j3 = x3 + k3;
1023 if (j1 >= 0 && j3 >= 0 && j1 < nx1 && j3 < nx3) {
1024 if (voxelMatrix(j1, x2, j3) == SOLID) {
1025 count++;
1026 }
1027 }
1028 }
1029 if (count == 8) {
1030 voxelMatrix(x1, x2, x3) = SOLID;
1031 }
1032 }
1033}
1035void GbVoxelMatrix3D::writeToLegacyVTKASCII(const std::string &fileName)
1036{
1037 string fn = fileName + ".ascii.vtk";
1038
1039 FILE *file;
1040 file = fopen(fn.c_str(), "w");
1041
1042 if (file == NULL) {
1043 std::string pathf = ub_system::getPathFromString(fn);
1044 if (fn.size() > 0) {
1046 file = fopen(fn.c_str(), "w");
1047 }
1048 if (file == NULL)
1049 throw UbException(UB_EXARGS, "can not open " + fn);
1050 }
1051
1052 if (file == NULL)
1053 throw UbException(UB_EXARGS, "can not open " + fn);
1054
1055 int nx1 = (int)voxelMatrix.getNX1();
1056 int nx2 = (int)voxelMatrix.getNX2();
1057 int nx3 = (int)voxelMatrix.getNX3();
1058
1059 int nn = nx1 * nx2 * nx3;
1060
1061 fprintf(file, "# vtk DataFile Version 2.0\n");
1062 fprintf(file, "vtk output\n");
1063 fprintf(file, "ASCII\n");
1064 fprintf(file, "DATASET STRUCTURED_POINTS\n");
1065 fprintf(file, "DIMENSIONS %d %d %d\n", nx1, nx2, nx3);
1066 fprintf(file, "ORIGIN %g %g %g\n", minX1, minX2, minX3);
1067 fprintf(file, "SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3);
1068 fprintf(file, "POINT_DATA %d\n", nn);
1069 fprintf(file, "SCALARS Geo float\n");
1070 fprintf(file, "LOOKUP_TABLE default\n");
1071
1072 for (int k = 0; k < nx3; k++) {
1073 for (int j = 0; j < nx2; j++) {
1074 for (int i = 0; i < nx1; i++) {
1075 fprintf(file, "%g ", voxelMatrix(i, j, k));
1076 }
1077 }
1078 }
1079
1080 fprintf(file, "\n");
1081
1082 fclose(file);
1083}
1085void GbVoxelMatrix3D::writeToLegacyVTKBinary(const std::string &fileName)
1086{
1087 string fn = fileName + ".binary.vtk";
1088
1089 FILE *file;
1090 file = fopen(fn.c_str(), "w");
1091
1092 if (file == NULL) {
1093 std::string pathf = ub_system::getPathFromString(fn);
1094 if (fn.size() > 0) {
1096 file = fopen(fn.c_str(), "w");
1097 }
1098 if (file == NULL)
1099 throw UbException(UB_EXARGS, "can not open " + fn);
1100 }
1101
1102 int nx1 = (int)voxelMatrix.getNX1();
1103 int nx2 = (int)voxelMatrix.getNX2();
1104 int nx3 = (int)voxelMatrix.getNX3();
1105
1106 int nn = nx1 * nx2 * nx3;
1107
1108 char LF = 0x0A;
1109
1110 fprintf(file, "# vtk DataFile Version 3.0\n");
1111 fprintf(file, "vtk output\n");
1112 fprintf(file, "BINARY\n");
1113 fprintf(file, "DATASET STRUCTURED_POINTS\n");
1114 fprintf(file, "DIMENSIONS %d %d %d\n", nx1, nx2, nx3);
1115 fprintf(file, "ORIGIN %g %g %g\n", minX1, minX2, minX3);
1116 fprintf(file, "SPACING %g %g %g\n", deltaX1, deltaX2, deltaX3);
1117 fprintf(file, "POINT_DATA %d\n", nn);
1118 fprintf(file, "SCALARS Geo float\n");
1119 fprintf(file, "LOOKUP_TABLE default");
1120 fclose(file);
1121
1123
1125 for (int x3 = 0; x3 < nx3; x3++) {
1126 for (int x2 = 0; x2 < nx2; x2++) {
1127 for (int x1 = 0; x1 < nx1; x1++) {
1128 float tmp = this->voxelMatrix(x1, x2, x3);
1129 ub_system::swapByteOrder((unsigned char *)(&(tmp)), sizeof(float));
1130 voxelMatrix_temp(x1, x2, x3) = tmp;
1131 }
1132 }
1133 }
1134 }
1135
1136 file = fopen(fn.c_str(), "ab");
1137
1138 fwrite(&LF, sizeof(char), 1, file);
1139 fwrite(voxelMatrix_temp.getStartAdressOfSortedArray(0, 0, 0), sizeof(float),
1140 voxelMatrix_temp.getDataVector().size(), file);
1141 fwrite(&LF, sizeof(char), 1, file);
1142 fclose(file);
1143}
1145void GbVoxelMatrix3D::writeToVTKImageDataASCII(const std::string &fileName)
1146{
1147 int nx1 = (int)voxelMatrix.getNX1();
1148 int nx2 = (int)voxelMatrix.getNX2();
1149 int nx3 = (int)voxelMatrix.getNX3();
1150
1151 string fn = fileName + ".ascii.vti";
1152
1153 FILE *file;
1154 file = fopen(fn.c_str(), "w");
1155
1156 if (file == NULL) {
1157 std::string pathf = ub_system::getPathFromString(fn);
1158 if (fn.size() > 0) {
1160 file = fopen(fn.c_str(), "w");
1161 }
1162 if (file == NULL)
1163 throw UbException(UB_EXARGS, "can not open " + fn);
1164 }
1165
1166 fprintf(file,
1167 "<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); // paraview
1168 // 4.1
1169 // fprintf(file,"<VTKFile type=\"ImageData\" version=\"0.1\" byte_order=\"LittleEndian\">\n"); //paraview 3.1
1170 fprintf(file, " <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0,
1171 nx1 - 1, 0, nx2 - 1, 0, nx3 - 1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3);
1172 fprintf(file, " <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1 - 1, 0, nx2 - 1, 0, nx3 - 1);
1173 fprintf(file, " <PointData Scalars=\"VoxelMatrix\">\n");
1174 fprintf(file, " <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"ascii\" RangeMin=\"0\" "
1175 "RangeMax=\"1\">\n ");
1176
1177 for (int k = 0; k < nx3; k++) {
1178 for (int j = 0; j < nx2; j++) {
1179 for (int i = 0; i < nx1; i++) {
1180 fprintf(file, "%g ", voxelMatrix(i, j, k));
1181 }
1182 }
1183 }
1184
1185 fprintf(file, "\n </DataArray>\n");
1186 fprintf(file, " </PointData>\n");
1187 fprintf(file, " <CellData>\n");
1188 fprintf(file, " </CellData>\n");
1189 fprintf(file, " </Piece>\n");
1190 fprintf(file, " </ImageData>\n");
1191 fprintf(file, "</VTKFile>\n");
1192
1193 fclose(file);
1194}
1196void GbVoxelMatrix3D::writeToVTKImageDataAppended(const std::string &fileName)
1197{
1198 int nx1 = (int)voxelMatrix.getNX1();
1199 int nx2 = (int)voxelMatrix.getNX2();
1200 int nx3 = (int)voxelMatrix.getNX3();
1201
1202 string fn = fileName + ".appended.vti";
1203
1204 FILE *file;
1205 file = fopen(fn.c_str(), "w");
1206
1207 if (file == NULL) {
1208 std::string pathf = ub_system::getPathFromString(fn);
1209 if (fn.size() > 0) {
1211 file = fopen(fn.c_str(), "w");
1212 }
1213 if (file == NULL)
1214 throw UbException(UB_EXARGS, "can not open " + fn);
1215 }
1216
1217 fprintf(file,
1218 "<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n"); // paraview
1219 // 4.1
1220 fprintf(file, " <ImageData WholeExtent=\"%d %d %d %d %d %d\" Origin=\"%g %g %g\" Spacing=\"%g %g %g\">\n", 0,
1221 nx1 - 1, 0, nx2 - 1, 0, nx3 - 1, minX1, minX2, minX3, deltaX1, deltaX2, deltaX3);
1222 fprintf(file, " <Piece Extent=\"%d %d %d %d %d %d\">\n", 0, nx1 - 1, 0, nx2 - 1, 0, nx3 - 1);
1223 fprintf(file, " <PointData Scalars=\"VoxelMatrix\">\n");
1224 fprintf(file, " <DataArray type=\"Float32\" Name=\"VoxelMatrix\" format=\"appended\" RangeMin=\"0\" "
1225 "RangeMax=\"1\" offset=\"0\" />\n");
1226 fprintf(file, " </PointData>\n");
1227 fprintf(file, " <CellData>\n");
1228 fprintf(file, " </CellData>\n");
1229 fprintf(file, " </Piece>\n");
1230 fprintf(file, " </ImageData>\n");
1231 fprintf(file, " <AppendedData encoding=\"raw\">\n");
1232 fprintf(file, " _");
1233 fclose(file);
1234
1235 file = fopen(fn.c_str(), "ab");
1236 unsigned long long size = (unsigned long long)voxelMatrix.getDataVector().size() * sizeof(float);
1237 fwrite(&size, sizeof(unsigned long long), 1, file);
1238 fwrite(voxelMatrix.getStartAdressOfSortedArray(0, 0, 0), sizeof(float), voxelMatrix.getDataVector().size(), file);
1239 fclose(file);
1240
1241 file = fopen(fn.c_str(), "a");
1242 fprintf(file, "\n");
1243 fprintf(file, " </AppendedData>\n");
1244 fprintf(file, "</VTKFile>\n");
1245 fclose(file);
1246}
1247
size_type getNX3() const
Definition CbArray3D.h:346
std::vector< value_type > & getDataVector()
Definition CbArray3D.h:403
size_type getNX2() const
Definition CbArray3D.h:345
size_type getNX1() const
Definition CbArray3D.h:344
pointer getStartAdressOfSortedArray(const size_type &x1, const size_type &x2, const size_type &x3)
Definition CbArray3D.h:298
This Interface provides basic 3D geometry objects methods.
Definition GbObject3D.h:64
CbArray3D< char > flagMatrix
double getX3Centroid() override
std::vector< int > x1Nbr
CbArray3D< float > Matrix3D
double getX2Centroid() override
double getX1Maximum() override
double getX3Maximum() override
std::vector< int > x2NbrTemp
double getX2Maximum() override
std::vector< int > x2Nbr
std::vector< int > x3Nbr
double getX1Centroid() override
std::vector< int > x1NbrTemp
std::vector< int > x3NbrTemp
std::string filename
void setName(std::string name)
Definition ObObject.h:52
virtual void notifyObserversObjectChanged()
std::shared_ptr< T > SPtr
void calculateNumberOfSolidAndFluid()
std::string toString() override
void addSurfaceTriangleSet(std::vector< UbTupleFloat3 > &nodes, std::vector< UbTupleInt3 > &triangles) override
void findFluidNeighbor(int cx1, int cx2, int cx3)
std::vector< GbTriangle3D * > getSurfaceTriangleSet() override
bool isCellInsideGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b) override
static const float FLUID
void rotateAroundY(double theta)
void readMatrixFromVtiASCIIFile(std::string filename)
Reads a VTI file in ASCII format and fills the voxel matrix applying the thresholds....
void setClosedVoidSpaceToSolid()
bool isCellInsideOrCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b) override
void writeToLegacyVTKBinary(const std::string &fileName)
bool isPointInGbObject3D(const double &x1p, const double &x2p, const double &x3p, bool &pointIsOnBoundary) override
void translate(const double &tx1, const double &tx2, const double &tx3) override
double getIntersectionRaytraceFactor(const double &x1, const double &x2, const double &x3, const double &rx1, const double &rx2, const double &rx3) override
static const float SOLID
void writeToVTKImageDataAppended(const std::string &fileName)
void writeToVTKImageDataASCII(const std::string &fileName)
void writeToLegacyVTKASCII(const std::string &fileName)
bool isCellCuttingGbObject3D(const double &x1a, const double &x2a, const double &x3a, const double &x1b, const double &x2b, const double &x3b) override
void readMatrixFromVtiAppendedFile(std::string filename)
Reads a VTI file in appended binary format and fills the voxel matrix applying the thresholds....
void setCenterCoordinates(const double &x1, const double &x2, const double &x3) override
GbVoxelMatrix3D * clone() override
@ z
Definition Axis.h:44
@ x
Definition Axis.h:42
@ y
Definition Axis.h:43
UbTypeOp< typenameUbDuoT< N, UbDuo< A, B > >::ResultT >::RefT val(UbDuo< A, B > &d)
Definition UbTuple.h:393
#define UBLOG(level, logtext)
Definition UbLogger.h:327
#define UB_EXARGS
Definition UbException.h:73
@ logINFO
Definition UbLogger.h:54
int integerRounding(const T &value)
Definition UbMath.h:236
bool lessEqual(const T1 &value, const T2 &reference)
Definition UbMath.h:209
bool equal(const T1 &value, const T2 &reference)
Definition UbMath.h:189
bool greater(const T1 &value, const T2 &reference)
Definition UbMath.h:216
bool less(const T1 &value, const T2 &reference)
Definition UbMath.h:202
bool makeDirectory(const std::string &dir)
Definition UbSystem.h:280
std::string toString(const T &x, int precision=15)
Definition UbSystem.h:199
std::string getPathFromString(const std::string &fileStringWithPath)
Definition UbSystem.h:345
void swapByteOrder(unsigned char *toSwap, int length)
Definition UbSystem.h:439
bool isLittleEndian()
Definition UbSystem.h:418