OGS
GMSHLineLoop.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "GMSHLineLoop.h"
5
6#include <ostream>
7
8#include "GMSHLine.h"
9
10namespace FileIO
11{
12namespace GMSH
13{
14GMSHLineLoop::GMSHLineLoop(bool is_sfc) : _is_sfc(is_sfc) {}
15
17{
18 const std::size_t n_lines(_lines.size());
19 for (std::size_t k(0); k < n_lines; k++)
20 {
21 delete _lines[k];
22 }
23}
24
25void GMSHLineLoop::write(std::ostream& os, std::size_t line_offset,
26 std::size_t sfc_offset) const
27{
28 const std::size_t n_lines(_lines.size());
29 for (std::size_t k(0); k < n_lines; k++)
30 {
31 (_lines[k])->write(os, line_offset + k);
32 }
33 os << "Line Loop(" << line_offset + n_lines << ") = {";
34 for (std::size_t k(0); k < n_lines - 1; k++)
35 {
36 os << line_offset + k << ",";
37 }
38 os << line_offset + n_lines - 1 << "};\n";
39
40 if (_is_sfc)
41 {
42 // write plane surface
43 os << "Plane Surface (" << sfc_offset << ") = {"
44 << line_offset + n_lines << "};\n";
45 }
46}
47
48} // end namespace GMSH
49} // end namespace FileIO
std::vector< GMSHLine * > _lines
void write(std::ostream &os, std::size_t line_offset, std::size_t sfc_offset=0) const
GMSHLineLoop(bool is_sfc=false)