MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / writeOBJ

Function writeOBJ

src/triSurface/triSurface/interfaces/OBJ/writeOBJ.C:40–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
39
40void triSurface::writeOBJ(const bool writeSorted, Ostream& os) const
41{
42 // Write header
43 os << "# Wavefront OBJ file" << nl
44 << "# Regions:" << nl;
45
46 labelList faceMap;
47
48 surfacePatchList patches(calcPatches(faceMap));
49
50 const pointField& ps = points();
51
52 // Print patch names as comment
53 forAll(patches, patchi)
54 {
55 os << "# " << patchi << " "
56 << patches[patchi].name() << nl;
57 }
58 os << "#" << nl;
59
60 os << "# points : " << ps.size() << nl
61 << "# triangles : " << size() << nl
62 << "#" << nl;
63
64
65 // Write vertex coords
66 forAll(ps, pointi)
67 {
68 os << "v "
69 << ps[pointi].x() << ' '
70 << ps[pointi].y() << ' '
71 << ps[pointi].z() << nl;
72 }
73
74 if (writeSorted)
75 {
76 label faceIndex = 0;
77
78 forAll(patches, patchi)
79 {
80 // Print all faces belonging to this patch
81
82 os << "g " << patches[patchi].name() << nl;
83
84 for
85 (
86 label patchFacei = 0;
87 patchFacei < patches[patchi].size();
88 patchFacei++
89 )
90 {
91 const label facei = faceMap[faceIndex++];
92
93 os << "f "
94 << operator[](facei)[0] + 1 << ' '
95 << operator[](facei)[1] + 1 << ' '
96 << operator[](facei)[2] + 1
97 //<< " # " << operator[](facei).region()

Callers 1

writeFunction · 0.50

Calls 9

pointsFunction · 0.85
sizeFunction · 0.85
forAllFunction · 0.50
nameMethod · 0.45
sizeMethod · 0.45
xMethod · 0.45
yMethod · 0.45
zMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected