Be precise

This commit is contained in:
Andreas Fabri 2023-10-17 14:08:33 +01:00
parent 950ed67a9b
commit d760c408a7
10 changed files with 66 additions and 66 deletions

View File

@ -19,13 +19,13 @@ public:
//! the polygon type used to represent each polygon with holes of the multipolygon.
typedef unspecified_type Polygon_with_holes_2;
/*! a bidirectional iterator over the polygons.
/*! a bidirectional iterator over the polygons with holes.
* Its value type is `Polygon_with_holes_2`.
*/
typedef unspecified_type Polygon_const_iterator;
typedef unspecified_type Polygon_with_holes_const_iterator;
//! range type for iterating over the polygons.
typedef unspecified_type Polygons_container;
//! range type for iterating over polygons with holes.
typedef unspecified_type Polygon_with_holes_container;
//! size type
typedef unsigned int Size;
@ -35,7 +35,7 @@ typedef unsigned int Size;
/// \name Creation
/// @{
/*! constructs a multipolygon using a range of polygons.
/*! constructs a multipolygon using a range of polygons with holes.
*/
template <typename InputIterator>
MultipolygonWithHoles_2(InputIterator begin, InputIterator end);
@ -45,41 +45,41 @@ MultipolygonWithHoles_2(InputIterator begin, InputIterator end);
/// \name Predicates
/// @{
/*! returns the number of polygons.
/*! returns the number of polygons with holes.
*/
Size number_of_polygons();
Size number_of_polygons_wih_holes();
/// @}
/// \name Access Functions
/// @{
/*! returns the begin iterator of the polygons.
/*! returns the begin iterator of the polygons with holes.
*/
Polygon_const_iterator polygons_begin() const;
Polygon_with_holes_const_iterator polygons_with_holes_begin() const;
/*! returns the past-the-end iterator of the polygons.
/*! returns the past-the-end iterator of the polygons with holes.
*/
Polygon_const_iterator polygons_end() const;
Polygon_with_holes_const_iterator polygons_with_holes_end() const;
/*! returns the range of polygons.
/*! returns the range of polygons with holes.
*/
const Polygons_container& polygons() const;
const Polygon_with_holes_container& polygons_with_holes() const;
/// @}
/// \name Modifiers
/// @{
/*! adds a given polygon to the multipolygon.
/*! adds a given polygon with holes to the multipolygon.
*/
void add_polygon(const Polygon_with_holes_2& polygon);
void add_polygon_with_holes(const Polygon_with_holes_2& polygon);
/*! erases the specified polygon.
*/
void erase_polygon(Polygon_iterator pit);
void erase_polygon_with_holes(Polygon_iterator pit);
/*! removes all the polygons.
/*! removes all the polygons with holes.
*/
void clear();

View File

@ -28,8 +28,8 @@ namespace CGAL {
*
* The class `General_polygon_with_holes_2` models the concept
* `GeneralPolygonWithHoles_2`. It represents a general polygon with holes.
* It is parameterized with a type `Polygon` used to define the exposed
* type `Polygon_2`. This type represents the outer boundary of the general
* It is parameterized with a type `Polygon_` used to define the exposed
* type `%Polygon_2`. This type represents the outer boundary of the general
* polygon and each hole.
*
* \tparam Polygon_ must have input and output operators.

View File

@ -46,10 +46,10 @@ public:
/// @}
using Polygons_container = std::deque<Polygon_with_holes_2>;
using Polygon_with_holes_container = std::deque<Polygon_with_holes_2>;
using Polygon_iterator = typename Polygons_container::iterator;
using Polygon_const_iterator = typename Polygons_container::const_iterator;
using Polygon_with_holes_iterator = typename Polygon_with_holes_container::iterator;
using Polygon_with_holes_const_iterator = typename Polygon_with_holes_container::const_iterator;
/// the size type
using Size = unsigned int;
@ -64,32 +64,32 @@ public:
m_polygons(p_begin, p_end)
{}
Polygons_container& polygons() { return m_polygons; }
Polygon_with_holes_container& polygons_with_holes() { return m_polygons; }
const Polygons_container& polygons() const { return m_polygons; }
const Polygon_with_holes_container& polygons_with_holes() const { return m_polygons; }
Polygon_iterator polygons_begin() { return m_polygons.begin(); }
Polygon_with_holes_iterator polygons_with_holes_begin() { return m_polygons.begin(); }
Polygon_iterator polygons_end() { return m_polygons.end(); }
Polygon_with_holes_iterator polygons_with_holes_end() { return m_polygons.end(); }
Polygon_const_iterator polygons_begin() const { return m_polygons.begin(); }
Polygon_with_holes_const_iterator polygons_with_holes_begin() const { return m_polygons.begin(); }
Polygon_const_iterator polygons_end() const { return m_polygons.end(); }
Polygon_with_holes_const_iterator polygons_with_holes_end() const { return m_polygons.end(); }
void add_polygon(const Polygon_2& pgn) { m_polygons.push_back(Polygon_with_holes_2(pgn)); }
void add_polygon(const Polygon_with_holes_2& pgn) { m_polygons.push_back(pgn); }
void add_polygon_with_holes(const Polygon_with_holes_2& pgn) { m_polygons.push_back(pgn); }
void add_polygon(Polygon_with_holes_2&& pgn) { m_polygons.emplace_back(std::move(pgn)); }
void add_polygon_with_holes(Polygon_with_holes_2&& pgn) { m_polygons.emplace_back(std::move(pgn)); }
void erase_polygon(Polygon_iterator pit) { m_polygons.erase(pit); }
void erase_polygon_with_holes(Polygon_with_holes_iterator pit) { m_polygons.erase(pit); }
void clear() { m_polygons.clear(); }
Size number_of_polygons() const { return static_cast<Size>(m_polygons.size()); }
Size number_of_polygons_with_holes() const { return static_cast<Size>(m_polygons.size()); }
protected:
Polygons_container m_polygons;
Polygon_with_holes_container m_polygons;
};
/*!
@ -113,26 +113,26 @@ order.
template <class Kernel, class Container>
std::ostream& operator<<(std::ostream& os,
const Multipolygon_with_holes_2<Kernel, Container>& mp) {
typename Multipolygon_with_holes_2<Kernel, Container>::Polygon_const_iterator i;
typename Multipolygon_with_holes_2<Kernel, Container>::Polygon_with_holes_const_iterator i;
switch(IO::get_mode(os)) {
case IO::ASCII :
os << mp.number_of_polygons() << ' ';
for (i = mp.polygons_begin(); i != mp.polygons_end(); ++i) {
for (i = mp.polygon_with_holes_begin(); i != mp.polygon_with_holes_end(); ++i) {
os << *i << ' ';
}
return os;
case IO::BINARY :
os << mp.number_of_polygons();
for (i = mp.polygons_begin(); i != mp.polygons_end(); ++i) {
os << mp.number_of_polygons_with_holes();
for (i = mp.polygons_with_holes_begin(); i != mp.polygons_with_holes_end(); ++i) {
os << *i ;
}
return os;
default:
os << "Multipolygon_with_holes_2(" << std::endl;
for (i = mp.polygons_begin(); i != mp.polygons_end(); ++i) {
for (i = mp.polygons_with_holes_begin(); i != mp.polygons_with_holes_end(); ++i) {
os << " " << *i << std::endl;
}

View File

@ -69,7 +69,7 @@ public:
const char* title = "Basic Multipolygon_with_holes_2 Viewer") :
Base(parent, title, true, true, true, false, false),
m_mpwh(mpwh) {
if (mpwh.number_of_polygons() == 0) return;
if (mpwh.number_of_polygons_with_holes() == 0) return;
// mimic the computation of Camera::pixelGLRatio()
auto bbox = bounding_box();
@ -99,8 +99,8 @@ public:
*/
CGAL::Bbox_2 bounding_box() {
Bbox_2 bbox;
if (m_mpwh.number_of_polygons() > 0) bbox = m_mpwh.polygons().front().outer_boundary().bbox();
for (auto const& pwh: m_mpwh.polygons()) {
if (m_mpwh.number_of_polygons_with_holes() > 0) bbox = m_mpwh.polygons_with_holes().front().outer_boundary().bbox();
for (auto const& pwh: m_mpwh.polygons_with_holes()) {
bbox += pwh.outer_boundary().bbox();
}
return bbox;
@ -111,7 +111,7 @@ public:
void add_elements() {
clear();
for (auto const& p: m_mpwh.polygons()) {
for (auto const& p: m_mpwh.polygons_with_holes()) {
CGAL::IO::Color c(rand()%255,rand()%255,rand()%255);
face_begin(c);

View File

@ -17,10 +17,10 @@ int main(int argc, char* argv[]) {
CGAL::IO::read_polygon_WKT(in, pin);
Multipolygon_with_holes_2 mp = CGAL::Polygon_repair::repair_odd_even(pin);
if (mp.number_of_polygons() > 1) {
if (mp.number_of_polygons_with_holes() > 1) {
CGAL::IO::write_multi_polygon_WKT(std::cout, mp);
} else {
CGAL::IO::write_polygon_WKT(std::cout, mp.polygons()[0]);
CGAL::IO::write_polygon_WKT(std::cout, mp.polygons_with_holes()[0]);
}
return 0;

View File

@ -427,7 +427,7 @@ public:
void add_to_triangulation_odd_even(const Multipolygon_with_holes_2<Kernel, Container>& multipolygon) {
// Get unique edges
for (auto const& polygon: multipolygon.polygons()) {
for (auto const& polygon: multipolygon.polygons_with_holes()) {
for (auto const& edge: polygon.outer_boundary().edges()) {
if (edge.source() == edge.target()) continue;
std::pair<typename Kernel::Point_2, typename Kernel::Point_2> pair = (edge.source() < edge.target())?
@ -637,7 +637,7 @@ public:
}
for (auto const& polygon: ordered_polygons) {
// std::cout << "Adding polygon " << polygon << std::endl;
mp.add_polygon(polygon);
mp.add_polygon_with_holes(polygon);
}
}

View File

@ -82,9 +82,9 @@ int main(int argc, char* argv[]) {
pr.reconstruct_multipolygon();
} Multipolygon_with_holes_2 mp = pr.multipolygon();
if (mp.number_of_polygons() > 0) {
CGAL::Bbox_2 bbox = mp.polygons().front().bbox();
for (auto const& polygon: mp.polygons()) {
if (mp.number_of_polygons_with_holes() > 0) {
CGAL::Bbox_2 bbox = mp.polygons_with_holes().front().bbox();
for (auto const& polygon: mp.polygons_with_holes()) {
bbox += polygon.outer_boundary().bbox();
} Kernel::Vector_2 translate(-bbox.xmin(), -bbox.ymin());
double scale = desired_width/(bbox.xmax()-bbox.xmin());
@ -93,7 +93,7 @@ int main(int argc, char* argv[]) {
std::ofstream ofs(folder_out + "/" + std::string(file.path().stem()) + ".svg");
ofs << "<svg viewBox=\"0 0 " << desired_width << " " << scale*(bbox.ymax()-bbox.ymin()) << "\" xmlns=\"http://www.w3.org/2000/svg\">" << std::endl;
for (auto const& polygon: mp.polygons()) {
for (auto const& polygon: mp.polygons_with_holes()) {
// std::cout << polygon << std::endl;
ofs << "\t<polygon points=\"";
for (auto const& vertex: polygon.outer_boundary()) {

View File

@ -64,7 +64,7 @@ int main(int argc, char* argv[]) {
} CGAL_assertion(ref == out);
// Test orientations
for (auto const& polygon: rmp.polygons()) {
for (auto const& polygon: rmp.polygons_with_holes()) {
CGAL_assertion(polygon.outer_boundary().orientation() == CGAL::COUNTERCLOCKWISE);
for (auto const &hole: polygon.holes()) {
CGAL_assertion(hole.orientation() == CGAL::CLOCKWISE);

View File

@ -42,34 +42,34 @@ int main(int argc, char* argv[]) {
ofs << "{" << std::endl;
ofs << "\t\"type\": \"MultiPolygon\"," << std::endl;
ofs << "\t\"coordinates\": [" << std::endl;
for (int i = 0; i < rmp.polygons().size(); ++i) {
for (int i = 0; i < rmp.polygons_with_holes().size(); ++i) {
ofs << "\t\t[" << std::endl;
ofs << "\t\t\t[" << std::endl;
for (int j = 0; j < rmp.polygons()[i].outer_boundary().size(); ++j) {
ofs << "\t\t\t\t[" << rmp.polygons()[i].outer_boundary()[j].x() <<
", " << rmp.polygons()[i].outer_boundary()[j].y() << "]";
if (j < rmp.polygons()[i].outer_boundary().size()-1) ofs << ",";
for (int j = 0; j < rmp.polygons_with_holes()[i].outer_boundary().size(); ++j) {
ofs << "\t\t\t\t[" << rmp.polygons_with_holes()[i].outer_boundary()[j].x() <<
", " << rmp.polygons_with_holes()[i].outer_boundary()[j].y() << "]";
if (j < rmp.polygons_with_holes()[i].outer_boundary().size()-1) ofs << ",";
ofs << std::endl;
} ofs << "\t\t\t]";
if (rmp.polygons()[i].number_of_holes() > 0) ofs << ",";
if (rmp.polygons_with_holes()[i].number_of_holes() > 0) ofs << ",";
ofs << std::endl;
for (int j = 0; j < rmp.polygons()[i].holes().size(); ++j) {
for (int j = 0; j < rmp.polygons_with_holes()[i].holes().size(); ++j) {
ofs << "\t\t\t[" << std::endl;
for (int k = 0; k < rmp.polygons()[i].holes()[j].size(); ++k) {
ofs << "\t\t\t\t[" << rmp.polygons()[i].holes()[j][k].x() <<
", " << rmp.polygons()[i].holes()[j][k].y() << "]";
if (k < rmp.polygons()[i].holes()[j].size()-1) ofs << ",";
for (int k = 0; k < rmp.polygons_with_holes()[i].holes()[j].size(); ++k) {
ofs << "\t\t\t\t[" << rmp.polygons_with_holes()[i].holes()[j][k].x() <<
", " << rmp.polygons_with_holes()[i].holes()[j][k].y() << "]";
if (k < rmp.polygons_with_holes()[i].holes()[j].size()-1) ofs << ",";
ofs << std::endl;
}
ofs << "\t\t\t]";
if (j < rmp.polygons()[i].holes().size()-1) ofs << ",";
if (j < rmp.polygons_with_holes()[i].holes().size()-1) ofs << ",";
ofs << std::endl;
}
ofs << "\t\t]";
if (i < rmp.polygons().size()-1) ofs << ",";
if (i < rmp.polygons_with_holes().size()-1) ofs << ",";
ofs << std::endl;
} ofs << "\t]" << std::endl;
ofs << "}" << std::endl;

View File

@ -351,7 +351,7 @@ template<typename Kernel, typename Container>
bool read_multi_polygon_WKT(std::istream& in,
Multipolygon_with_holes_2<Kernel,Container>& mp)
{
return read_multi_polygon_WKT(in, mp.polygons());
return read_multi_polygon_WKT(in, mp.polygons_with_holes());
}
@ -359,7 +359,7 @@ template<typename Kernel, typename Container>
std::ostream& write_multi_polygon_WKT(std::ostream& out,
Multipolygon_with_holes_2<Kernel,Container>& mp)
{
return write_multi_polygon_WKT(out, mp.polygons());
return write_multi_polygon_WKT(out, mp.polygons_with_holes());
}
//! \ingroup PkgStreamSupportIoFuncsWKT