boustrophedon_decomp.cpp
Go to the documentation of this file.
1 //=============================================================================
2 // Copyright (C) 2021-2024 Wageningen University - All Rights Reserved
3 // Author: Gonzalo Mier
4 // BSD-3 License
5 //=============================================================================
6 
8 
9 namespace f2c::decomp
10 {
11 
13  const F2CLinearRing & ring,
14  const F2CLineString & line) const
15 {
16  if (ring.size() == 0 || line.size() == 0) {return false;}
17 
18  // Iterate over the edges (segments) of the ring
19  for (int i = 0; i < ring.size() - 1; ++i) { // Exclude the last point to avoid looping twice
20  auto ringPointStart = ring.getGeometry(i);
21  auto ringPointEnd = ring.getGeometry(i + 1);
22 
23  // Check if the line matches the current edge of the ring
24  if ((line.startPoint() == ringPointStart && line.endPoint() == ringPointEnd) ||
25  (line.startPoint() == ringPointEnd && line.endPoint() == ringPointStart))
26  {
27  // The line matches one of the ring edges
28  return true;
29  }
30  }
31 
32  // If the line doesn't match any edge of the ring, return false
33  return false;
34 }
35 
37  const F2CCells & cells, const obj::DecompObjective & obj)
38 {
39  F2CMultiLineString split_lines;
40  for (auto && cell : cells) {
41  for (auto && ring : cell) {
42  for (auto && p : ring) {
43  auto line1 = cell.createLineUntilBorder(p, split_angle);
45  line1 = cell.createLineUntilBorder(line1.endPoint(), split_angle);
46  }
47  auto line2 = cell.createLineUntilBorder(p, split_angle + M_PI);
49  line2 = cell.createLineUntilBorder(line2.endPoint(), split_angle + M_PI);
50  }
51 
52  if (line1.length() > 1e-5 && line2.length() > 1e-5) {
53  split_lines.addGeometry(line1);
54  split_lines.addGeometry(line2);
55  }
56  }
57  }
58  }
59  return split_lines;
60 }
61 
62 } // namespace f2c::decomp
1_basic_types.cells
cells
Definition: 1_basic_types.py:93
1_basic_types.line2
line2
Definition: 1_basic_types.py:61
boustrophedon_decomp.h
f2c::decomp::BoustrophedonDecomp::genSplitLines
F2CMultiLineString genSplitLines(const F2CCells &cells, const obj::DecompObjective &obj=obj::DecompObjective()) override
Definition: boustrophedon_decomp.cpp:36
1_basic_types.cell
cell
Definition: 1_basic_types.py:88
f2c::decomp
Decomposition algorithms' namespace.
Definition: boustrophedon_decomp.h:14
f2c::types::MultiLineString
Definition: MultiLineString.h:18
f2c::types::LinearRing
Definition: LinearRing.h:18
f2c::decomp::BoustrophedonDecomp::isLinePartOfLinearRing
bool isLinePartOfLinearRing(const F2CLinearRing &ring, const F2CLineString &line) const
Definition: boustrophedon_decomp.cpp:12
7_decomposition.obj
obj
Definition: 7_decomposition.py:32
1_basic_types.ring
ring
Definition: 1_basic_types.py:68
f2c::obj::DecompObjective
Base class for objective functions of cell decomposition.
Definition: decomp_objective.h:18
f2c::types::LineString::startPoint
const Point startPoint() const
Definition: LineString.cpp:114
f2c::types::LineString
Definition: LineString.h:19
f2c::types::Cells
Definition: Cells.h:21
f2c::types::LineString::endPoint
const Point endPoint() const
Definition: LineString.cpp:118
f2c::types::LineString::size
size_t size() const
Definition: LineString.cpp:49
f2c::decomp::TrapezoidalDecomp::split_angle
double split_angle
Definition: trapezoidal_decomp.h:35
f2c::types::MultiLineString::addGeometry
void addGeometry(const LineString &line)
Definition: MultiLineString.cpp:120
1_basic_types.line1
line1
Definition: 1_basic_types.py:56


fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31