53 :
GbObject3D(), lowerThreshold(lowerThreshold), upperThreshold(upperThreshold), nodesX1(nx1), nodesX2(nx2),
62 :
GbObject3D(), nodesX1((
int)voxelMatrix.getNX1()), nodesX2((
int)voxelMatrix.getNX2()),
63 nodesX3((
int)voxelMatrix.getNX3()), lowerThreshold(lowerThreshold), upperThreshold(upperThreshold),
64 voxelMatrix(voxelMatrix)
95 for (
int x3 = 0; x3 <
nodesX3; x3++) {
96 for (
int x2 = 0; x2 <
nodesX2; x2++) {
97 for (
int x1 = 0; x1 <
nodesX1; x1++) {
105 for (
int i = 0;
i < size;
i++) {
129 for (
int k3 = -1;
k3 <= 1;
k3++) {
130 for (
int k2 = -1;
k2 <= 1;
k2++) {
131 for (
int k1 = -1;
k1 <= 1;
k1++) {
155 for (
int x3 = 0; x3 <
nodesX3; x3++)
156 for (
int x2 = 0; x2 <
nodesX2; x2++)
157 for (
int x1 = 0; x1 <
nodesX1; x1++) {
171 const double &
rx1,
const double &
rx2,
const double &
rx3)
237 const double & ,
const double & ,
const double & )
273 const double &
x1b,
const double &
x2b,
const double &
x3b)
292 const double &
x1b,
const double &
x2b,
const double &
x3b)
324 <<
"vector<GbTriangle3D*> GbVoxelMatrix3D::getSurfaceTriangleSet() - benoetigt MARCHING_CUBE paket aus 3rdParty"
331 UBLOG(
logINFO,
" GbVoxelMatrix3D addSurfaceTriangleSet start")
333 UBLOG(
logINFO,
" GbVoxelMatrix3D addSurfaceTriangleSet end without TriangleSetCreation")
337 cerr <<
"void GbVoxelMatrix3D.addSurfaceTriangleSet - benoetigt MARCHING_CUBE paket aus 3rdParty" <<
endl;
339 UBLOG(
logINFO,
" GbVoxelMatrix3D addSurfaceTriangleSet end")
387 std::ostringstream
ss;
395 if (
pos != std::string::npos) {
408 if (
pos != std::string::npos) {
422 if (
pos != std::string::npos) {
439 size_t dataPos = std::string::npos;
444 if (tag == std::string::npos)
break;
446 if (
tagEnd == std::string::npos)
break;
448 if (
header.find(
"format=\"ascii\"") != std::string::npos) {
457 if (
dataPos == std::string::npos) {
463 if (
endTag == std::string::npos) {
471 std::vector<double> values;
491 double val = values[
idx++];
517 std::ostringstream
ss;
525 if (
pos != std::string::npos) {
538 if (
pos != std::string::npos) {
552 if (
pos != std::string::npos) {
585 unsigned long long offset;
590 std::vector<DataArrayInfo>
arrays;
595 if (tag == std::string::npos || tag >
appendedTag)
break;
597 if (
tagEnd == std::string::npos)
break;
601 if (
offPos != std::string::npos) {
604 if (
offEnd != std::string::npos) {
609 std::string
dtype =
"Float32";
611 if (
tpos != std::string::npos) {
614 if (tend != std::string::npos)
619 size_t cpos =
header.find(
"NumberOfComponents=\"");
620 if (
cpos != std::string::npos) {
623 if (
cend != std::string::npos) {
643 std::vector<double> values;
648 in.seekg(0, ios::beg);
655 if (!
in.good())
continue;
669 if (
info.type ==
"Float32" ||
info.type ==
"float") {
683 std::memcpy(&v,
buffer.data() + (
i *
comp + 0) *
sizeof(
float),
sizeof(
float));
684 values.push_back((
double)v);
687 }
else if (
info.type ==
"Float64" ||
info.type ==
"double") {
695 std::memcpy(&v,
buffer.data() + (
i *
comp + 0) *
sizeof(
double),
sizeof(
double));
699 }
else if (
info.type ==
"Int32" ||
info.type ==
"int" ||
info.type ==
"Int") {
708 values.push_back((
double)
vi);
711 }
else if (
info.type ==
"UInt8" ||
info.type ==
"unsigned_char" ||
info.type ==
"unsigned_char") {
720 values.push_back((
double)
vi);
752 double val = values[
idx++];
798 for (
int x3 = 0; x3 < nx3; x3++) {
799 for (
int x2 = 0; x2 < nx2; x2++) {
800 for (
int x1 = 0; x1 < nx1; x1++) {
848 for (
int x3 = 0; x3 < nx3; x3++) {
849 for (
int x2 = 0; x2 < nx2; x2++) {
850 for (
int x1 = 0; x1 < nx1; x1++) {
898 for (
int x3 = 0; x3 < nx3; x3++) {
899 for (
int x2 = 0; x2 < nx2; x2++) {
900 for (
int x1 = 0; x1 < nx1; x1++) {
925 for (
int x3 = 0; x3 < nx3; x3++) {
926 for (
int x2 = 0; x2 < nx2; x2++) {
927 for (
int x1 = 0; x1 < nx1; x1++) {
943 for (
int x3 = 0; x3 < nx3; x3++) {
944 for (
int x2 = 0; x2 < nx2; x2++) {
945 for (
int x1 = 0; x1 < nx1; x1++) {
961 for (
int x3 = 0; x3 < nx3; x3++) {
962 for (
int x2 = 0; x2 < nx2; x2++) {
963 for (
int x1 = 0; x1 < nx1; x1++) {
979 for (
int x3 = 0; x3 < nx3; x3++) {
980 for (
int x2 = 0; x2 < nx2; x2++) {
981 for (
int x1 = 0; x1 < nx1; x1++) {
1015 for (
int x3 = 0; x3 < nx3; x3++)
1016 for (
int x2 = 0; x2 < nx2; x2++)
1017 for (
int x1 = 0; x1 < nx1; x1++) {
1019 for (
int k3 = -1;
k3 <= 1;
k3++)
1020 for (
int k1 = -1;
k1 <= 1;
k1++) {
1023 if (
j1 >= 0 &&
j3 >= 0 &&
j1 < nx1 &&
j3 < nx3) {
1037 string fn = fileName +
".ascii.vtk";
1040 file =
fopen(
fn.c_str(),
"w");
1044 if (
fn.size() > 0) {
1046 file =
fopen(
fn.c_str(),
"w");
1059 int nn = nx1 * nx2 * nx3;
1061 fprintf(file,
"# vtk DataFile Version 2.0\n");
1062 fprintf(file,
"vtk output\n");
1064 fprintf(file,
"DATASET STRUCTURED_POINTS\n");
1065 fprintf(file,
"DIMENSIONS %d %d %d\n", nx1, nx2, nx3);
1069 fprintf(file,
"SCALARS Geo float\n");
1070 fprintf(file,
"LOOKUP_TABLE default\n");
1072 for (
int k = 0; k < nx3; k++) {
1073 for (
int j = 0;
j < nx2;
j++) {
1074 for (
int i = 0;
i < nx1;
i++) {
1087 string fn = fileName +
".binary.vtk";
1090 file =
fopen(
fn.c_str(),
"w");
1094 if (
fn.size() > 0) {
1096 file =
fopen(
fn.c_str(),
"w");
1106 int nn = nx1 * nx2 * nx3;
1110 fprintf(file,
"# vtk DataFile Version 3.0\n");
1111 fprintf(file,
"vtk output\n");
1113 fprintf(file,
"DATASET STRUCTURED_POINTS\n");
1114 fprintf(file,
"DIMENSIONS %d %d %d\n", nx1, nx2, nx3);
1118 fprintf(file,
"SCALARS Geo float\n");
1119 fprintf(file,
"LOOKUP_TABLE default");
1125 for (
int x3 = 0; x3 < nx3; x3++) {
1126 for (
int x2 = 0; x2 < nx2; x2++) {
1127 for (
int x1 = 0; x1 < nx1; x1++) {
1136 file =
fopen(
fn.c_str(),
"ab");
1138 fwrite(&
LF,
sizeof(
char), 1, file);
1141 fwrite(&
LF,
sizeof(
char), 1, file);
1151 string fn = fileName +
".ascii.vti";
1154 file =
fopen(
fn.c_str(),
"w");
1158 if (
fn.size() > 0) {
1160 file =
fopen(
fn.c_str(),
"w");
1167 "<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n");
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 ");
1177 for (
int k = 0; k < nx3; k++) {
1178 for (
int j = 0;
j < nx2;
j++) {
1179 for (
int i = 0;
i < nx1;
i++) {
1185 fprintf(file,
"\n </DataArray>\n");
1186 fprintf(file,
" </PointData>\n");
1187 fprintf(file,
" <CellData>\n");
1188 fprintf(file,
" </CellData>\n");
1190 fprintf(file,
" </ImageData>\n");
1191 fprintf(file,
"</VTKFile>\n");
1202 string fn = fileName +
".appended.vti";
1205 file =
fopen(
fn.c_str(),
"w");
1209 if (
fn.size() > 0) {
1211 file =
fopen(
fn.c_str(),
"w");
1218 "<VTKFile type=\"ImageData\" version=\"1.0\" byte_order=\"LittleEndian\" header_type=\"UInt64\">\n");
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");
1230 fprintf(file,
" </ImageData>\n");
1231 fprintf(file,
" <AppendedData encoding=\"raw\">\n");
1235 file =
fopen(
fn.c_str(),
"ab");
1237 fwrite(&size,
sizeof(
unsigned long long), 1, file);
1241 file =
fopen(
fn.c_str(),
"a");
1243 fprintf(file,
" </AppendedData>\n");
1244 fprintf(file,
"</VTKFile>\n");
std::vector< value_type > & getDataVector()
pointer getStartAdressOfSortedArray(const size_type &x1, const size_type &x2, const size_type &x3)
This Interface provides basic 3D geometry objects methods.
CbArray3D< char > flagMatrix
double getX3Centroid() override
bool addSurfaceTriangleSetFlag
CbArray3D< float > Matrix3D
double getX2Centroid() override
double getX1Maximum() override
double getX3Maximum() override
std::vector< int > x2NbrTemp
double getX2Maximum() override
double getX1Centroid() override
std::vector< int > x1NbrTemp
std::vector< int > x3NbrTemp
void setName(std::string name)
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
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
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
UbTypeOp< typenameUbDuoT< N, UbDuo< A, B > >::ResultT >::RefT val(UbDuo< A, B > &d)
#define UBLOG(level, logtext)
int integerRounding(const T &value)
bool lessEqual(const T1 &value, const T2 &reference)
bool equal(const T1 &value, const T2 &reference)
bool greater(const T1 &value, const T2 &reference)
bool less(const T1 &value, const T2 &reference)
bool makeDirectory(const std::string &dir)
std::string toString(const T &x, int precision=15)
std::string getPathFromString(const std::string &fileStringWithPath)
void swapByteOrder(unsigned char *toSwap, int length)