OpenFOAM: API Guide
v2112
The open source CFD toolbox
STLCore.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | www.openfoam.com
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
Copyright (C) 2016-2020 OpenCFD Ltd.
9
-------------------------------------------------------------------------------
10
License
11
This file is part of OpenFOAM.
12
13
OpenFOAM is free software: you can redistribute it and/or modify it
14
under the terms of the GNU General Public License as published by
15
the Free Software Foundation, either version 3 of the License, or
16
(at your option) any later version.
17
18
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21
for more details.
22
23
You should have received a copy of the GNU General Public License
24
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26
Class
27
Foam::fileFormats::STLCore
28
29
Description
30
Core routines used when reading/writing STL files.
31
32
SourceFiles
33
STLCore.C
34
35
\*---------------------------------------------------------------------------*/
36
37
#ifndef STLCore_H
38
#define STLCore_H
39
40
#include "
STLpoint.H
"
41
#include "
STLtriangle.H
"
42
#include <memory>
43
44
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46
namespace
Foam
47
{
48
namespace
fileFormats
49
{
50
51
/*---------------------------------------------------------------------------*\
52
Class fileFormats::STLCore Declaration
53
\*---------------------------------------------------------------------------*/
54
55
class
STLCore
56
{
57
public
:
58
59
// Public Data Types
60
61
//- Enumeration for the format of data in the stream
62
enum
STLFormat
63
{
64
ASCII
,
65
BINARY
,
66
UNKNOWN
67
};
68
69
70
protected
:
71
72
// Protected Member Functions
73
74
//- Detect 'stlb' extension as binary when format = UNKNOWN.
75
// Otherwise test if format == BINARY.
76
static
bool
isBinaryName
77
(
78
const
fileName
& filename,
79
const
STLFormat
format
80
);
81
82
83
//- Check contents to detect if the file is a binary STL.
84
// Return the estimated number of triangles or 0 on error.
85
static
int
detectBinaryHeader
(
const
fileName
& filename);
86
87
88
//- Read STL binary file header.
89
// Return the opened file stream and estimated number of triangles.
90
// The stream is invalid and number of triangles is 0 on error.
91
static
std::unique_ptr<std::istream>
92
readBinaryHeader
93
(
94
const
fileName
& filename,
95
label& nTrisEstimated
96
);
97
98
//- Write STL binary file and number of triangles to stream
99
static
void
writeBinaryHeader
(ostream&
os
, uint32_t nTris);
100
101
102
// Constructors
103
104
//- Default construct
105
STLCore
() =
default
;
106
};
107
108
109
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110
111
}
// End namespace fileFormats
112
}
// End namespace Foam
113
114
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115
116
#endif
117
118
// ************************************************************************* //
STLpoint.H
STLtriangle.H
Foam::fileFormats::STLCore
Core routines used when reading/writing STL files.
Definition:
STLCore.H:55
Foam::fileFormats::STLCore::isBinaryName
static bool isBinaryName(const fileName &filename, const STLFormat format)
Detect 'stlb' extension as binary when format = UNKNOWN.
Definition:
STLCore.C:67
Foam::fileFormats::STLCore::STLCore
STLCore()=default
Default construct.
Foam::fileFormats::STLCore::detectBinaryHeader
static int detectBinaryHeader(const fileName &filename)
Check contents to detect if the file is a binary STL.
Definition:
STLCore.C:88
Foam::fileFormats::STLCore::writeBinaryHeader
static void writeBinaryHeader(ostream &os, uint32_t nTris)
Write STL binary file and number of triangles to stream.
Definition:
STLCore.C:227
Foam::fileFormats::STLCore::readBinaryHeader
static std::unique_ptr< std::istream > readBinaryHeader(const fileName &filename, label &nTrisEstimated)
Read STL binary file header.
Definition:
STLCore.C:148
Foam::fileFormats::STLCore::STLFormat
STLFormat
Enumeration for the format of data in the stream.
Definition:
STLCore.H:62
Foam::fileFormats::STLCore::UNKNOWN
@ UNKNOWN
Detect based on (input) content or (output) extension.
Definition:
STLCore.H:65
Foam::fileFormats::STLCore::BINARY
@ BINARY
BINARY.
Definition:
STLCore.H:64
Foam::fileFormats::STLCore::ASCII
@ ASCII
ASCII.
Definition:
STLCore.H:63
Foam::fileName
A class for handling file names.
Definition:
fileName.H:76
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition:
atmBoundaryLayer.C:34
format
word format(conversionProperties.get< word >("format"))
src
fileFormats
stl
STLCore.H
Generated by
1.9.5
OPENFOAM® is a registered
trademark
of OpenCFD Ltd.