VirtualFluids
0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
WbWriterBOBJ.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
//=======================================================================================
34
#ifdef CAB_ZLIB
35
#include <
basics/utilities/UbLogger.h
>
36
#include <
basics/writer/WbWriterBOBJ.h
>
37
#include <cstring>
38
39
#include <zlib.h>
40
41
using namespace
std;
42
/*===============================================================================*/
43
std::string WbWriterBOBJ::writeTriangles(
const
std::string &filename, std::vector<UbTupleFloat3> &nodes,
44
std::vector<UbTupleInt3> &triangles)
45
{
46
string
bobjFilename
= filename + getFileExtension();
47
UBLOG
(
logDEBUG1
,
"WbWriterBOBJ::writeTriangles to "
<<
bobjFilename
<<
" - start"
);
48
49
gzFile
gzf
=
gzopen
(
bobjFilename
.c_str(),
"wb1"
);
50
51
size_t
nofNodes
= nodes.size();
52
size_t
nofTriangles
= triangles.size();
53
54
// write to file
55
size_t
numVerts
;
56
// double v[3];
57
if
(
sizeof
(
numVerts
) != 4) {
58
throw
UbException
(
UB_EXARGS
,
"danger..."
);
59
}
60
numVerts
=
nofNodes
;
61
gzwrite
(
gzf
, &
numVerts
,
sizeof
(
numVerts
));
62
63
for
(
size_t
k = 0; k <
nofNodes
; k++) {
64
float
vertp
=
val<1>
(nodes[k]);
65
gzwrite
(
gzf
, &
vertp
,
sizeof
(
vertp
));
66
vertp
=
val<2>
(nodes[k]);
67
gzwrite
(
gzf
, &
vertp
,
sizeof
(
vertp
));
68
vertp
=
val<3>
(nodes[k]);
69
gzwrite
(
gzf
, &
vertp
,
sizeof
(
vertp
));
70
}
71
72
// NORMAL VECTOR
73
// double n[3];
74
gzwrite
(
gzf
, &
numVerts
,
sizeof
(
numVerts
));
75
for
(
size_t
k = 0; k <
nofNodes
; k++) {
76
// poly->GetPointData()->GetNormals()->GetTuple(k, n);
77
float
normp
= 0.0;
// n[0];
78
gzwrite
(
gzf
, &
normp
,
sizeof
(
normp
));
79
normp
= 0.0;
// n[1];
80
gzwrite
(
gzf
, &
normp
,
sizeof
(
normp
));
81
normp
= 0.0;
// n[2];
82
gzwrite
(
gzf
, &
normp
,
sizeof
(
normp
));
83
}
84
85
// vtkIdType npts = 3;
86
// vtkIdType* pts;
87
size_t
numTris
=
nofTriangles
;
88
gzwrite
(
gzf
, &
numTris
,
sizeof
(
numTris
));
89
for
(
size_t
k = 0; k <
nofTriangles
/*(size_t)poly->GetNumberOfPolys()*/
; k++) {
90
// poly->GetPolys()->GetNextCell(npts, pts);
91
// int triIndex = *pts;
92
// gzwrite(gzf, &triIndex, sizeof(triIndex));
93
// triIndex = *(pts+1);
94
// gzwrite(gzf, &triIndex, sizeof(triIndex));
95
// triIndex = *(pts+2);
96
// gzwrite(gzf, &triIndex, sizeof(triIndex));
97
// poly->GetPolys()->GetNextCell(npts, pts);
98
int
triIndex
=
val<1>
(triangles[k]);
//*pts;
99
gzwrite
(
gzf
, &
triIndex
,
sizeof
(
triIndex
));
100
triIndex
=
val<2>
(triangles[k]);
//*(pts+1);
101
gzwrite
(
gzf
, &
triIndex
,
sizeof
(
triIndex
));
102
triIndex
=
val<3>
(triangles[k]);
//*(pts+2);
103
gzwrite
(
gzf
, &
triIndex
,
sizeof
(
triIndex
));
104
}
105
106
gzclose
(
gzf
);
107
108
UBLOG
(
logDEBUG1
,
"WbWriterBOBJ::writeTriangles to "
<<
bobjFilename
<<
" - end"
);
109
110
return
bobjFilename
;
111
}
112
/*===============================================================================*/
113
114
#endif
// CAB_ZLIB
115
UbLogger.h
WbWriterBOBJ.h
UbException
Definition
UbException.h:82
SPtr
std::shared_ptr< T > SPtr
Definition
PointerDefinitions.h:39
UBLOG
#define UBLOG(level, logtext)
Definition
UbLogger.h:327
UB_EXARGS
#define UB_EXARGS
Definition
UbException.h:73
logDEBUG1
@ logDEBUG1
Definition
UbLogger.h:54
src
basics
writer
WbWriterBOBJ.cpp
Generated on Mon Nov 9 2026 00:03:24 for VirtualFluids by
1.9.8