OGS
GeoLib::DuplicateGeometry Class Referencefinal

Detailed Description

Creates a copy of a geometry within GEOObjects

Definition at line 27 of file DuplicateGeometry.h.

#include <DuplicateGeometry.h>

Collaboration diagram for GeoLib::DuplicateGeometry:
[legend]

Public Member Functions

 DuplicateGeometry (GeoLib::GEOObjects &geo_objects, std::string const &input_name, std::string output_name)
 
std::string const & getFinalizedOutputName () const
 
std::vector< GeoLib::Point * > & getPointVectorCopy ()
 
std::vector< GeoLib::Polyline * > & getPolylineVectorCopy ()
 
std::vector< GeoLib::Surface * > & getSurfaceVectorCopy ()
 

Private Member Functions

void duplicate (std::string const &input_name)
 
std::vector< GeoLib::Polyline * > copyPolylinesVector (std::vector< GeoLib::Polyline * > const &polylines) const
 
std::vector< Surface * > copySurfacesVector (std::vector< Surface * > const &surfaces) const
 

Private Attributes

std::string _output_name
 
GeoLib::GEOObjects_geo_objects
 

Constructor & Destructor Documentation

◆ DuplicateGeometry()

GeoLib::DuplicateGeometry::DuplicateGeometry ( GeoLib::GEOObjects & geo_objects,
std::string const & input_name,
std::string output_name )

Creates a copy of a geometry within GEOObjects

Parameters
geo_objectsThe container for geometries
input_nameThe geometry to be copied
output_nameThe name of the copy (note: this might be modified by GEOObjects)

Definition at line 25 of file DuplicateGeometry.cpp.

28 : _output_name(std::move(output_name)), _geo_objects(geo_objects)
29{
30 duplicate(input_name);
31}
void duplicate(std::string const &input_name)
GeoLib::GEOObjects & _geo_objects

References duplicate().

Member Function Documentation

◆ copyPolylinesVector()

std::vector< GeoLib::Polyline * > GeoLib::DuplicateGeometry::copyPolylinesVector ( std::vector< GeoLib::Polyline * > const & polylines) const
private

Definition at line 79 of file DuplicateGeometry.cpp.

81{
82 std::size_t const n_plys = polylines.size();
83 std::vector<GeoLib::Polyline*> new_lines{n_plys, nullptr};
84
85 for (std::size_t i = 0; i < n_plys; ++i)
86 {
87 if (polylines[i] == nullptr)
88 {
89 continue;
90 }
91 new_lines[i] =
93 std::size_t const nLinePnts(polylines[i]->getNumberOfPoints());
94 for (std::size_t j = 0; j < nLinePnts; ++j)
95 {
96 new_lines[i]->addPoint(polylines[i]->getPointID(j));
97 }
98 }
99 return new_lines;
100}
const std::vector< Point * > * getPointVec(const std::string &name) const
Class Polyline consists mainly of a reference to a point vector and a vector that stores the indices ...
Definition Polyline.h:40

References _geo_objects, _output_name, and GeoLib::GEOObjects::getPointVec().

Referenced by duplicate().

◆ copySurfacesVector()

std::vector< Surface * > GeoLib::DuplicateGeometry::copySurfacesVector ( std::vector< Surface * > const & surfaces) const
private

Definition at line 102 of file DuplicateGeometry.cpp.

104{
105 std::size_t const n_sfc = surfaces.size();
106 std::vector<GeoLib::Surface*> new_surfaces{n_sfc, nullptr};
107
108 for (std::size_t i = 0; i < n_sfc; ++i)
109 {
110 if (surfaces[i] == nullptr)
111 {
112 continue;
113 }
114 new_surfaces[i] =
116
117 std::size_t const n_tris(surfaces[i]->getNumberOfTriangles());
118 for (std::size_t j = 0; j < n_tris; ++j)
119 {
120 GeoLib::Triangle const* t = (*surfaces[i])[j];
121 new_surfaces[i]->addTriangle(t->getPoint(0)->getID(),
122 t->getPoint(1)->getID(),
123 t->getPoint(2)->getID());
124 }
125 }
126 return new_surfaces;
127}
A Surface is represented by Triangles. It consists of a reference to a vector of (pointers to) points...
Definition Surface.h:33
Class Triangle consists of a reference to a point vector and a vector that stores the indices in the ...
Definition Triangle.h:27
const Point * getPoint(std::size_t i) const
const access operator to access the i-th triangle Point
Definition Triangle.h:50
std::size_t getID() const

References _geo_objects, _output_name, MathLib::Point3dWithID::getID(), GeoLib::Triangle::getPoint(), and GeoLib::GEOObjects::getPointVec().

Referenced by duplicate().

◆ duplicate()

void GeoLib::DuplicateGeometry::duplicate ( std::string const & input_name)
private

Definition at line 33 of file DuplicateGeometry.cpp.

34{
35 std::vector<GeoLib::Point*> const* const pnts(
36 _geo_objects.getPointVec(input_name));
37 if (pnts == nullptr)
38 {
39 ERR("Geometry '{:s}' not found.", input_name);
40 return;
41 }
42
43 std::vector<GeoLib::Point*> new_pnts{};
44 new_pnts.reserve(pnts->size());
45 std::transform(pnts->cbegin(), pnts->cend(), std::back_inserter(new_pnts),
46 [](GeoLib::Point* point)
47 { return new GeoLib::Point(*point); });
48 PointVec::NameIdMap pnt_name_id_map(
51 _geo_objects.addPointVec(std::move(new_pnts), _output_name,
52 std::move(pnt_name_id_map));
53
54 std::vector<GeoLib::Polyline*> const* plys(
55 _geo_objects.getPolylineVec(input_name));
56 if (plys)
57 {
58 auto new_plys = copyPolylinesVector(*plys);
59 PolylineVec::NameIdMap ply_name_id_map{
62 _geo_objects.addPolylineVec(std::move(new_plys), _output_name,
63 std::move(ply_name_id_map));
64 }
65
66 std::vector<GeoLib::Surface*> const* sfcs(
67 _geo_objects.getSurfaceVec(input_name));
68 if (sfcs)
69 {
70 auto new_sfcs = copySurfacesVector(*sfcs);
71 GeoLib::SurfaceVec::NameIdMap sfc_name_id_map{
74 _geo_objects.addSurfaceVec(std::move(new_sfcs), _output_name,
75 std::move(sfc_name_id_map));
76 }
77}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45
std::vector< Surface * > copySurfacesVector(std::vector< Surface * > const &surfaces) const
std::vector< GeoLib::Polyline * > copyPolylinesVector(std::vector< GeoLib::Polyline * > const &polylines) const
void addPolylineVec(std::vector< Polyline * > &&lines, std::string const &name, PolylineVec::NameIdMap &&ply_names)
void addPointVec(std::vector< Point * > &&points, std::string &name, PointVec::NameIdMap &&pnt_id_name_map, double const eps=std::sqrt(std::numeric_limits< double >::epsilon()))
const PointVec * getPointVecObj(const std::string &name) const
SurfaceVec * getSurfaceVecObj(const std::string &name)
Returns the surface vector with the given name.
Definition GEOObjects.h:208
const std::vector< Surface * > * getSurfaceVec(const std::string &name) const
Returns the surface vector with the given name as a const.
void addSurfaceVec(std::vector< Surface * > &&sfc, const std::string &name, SurfaceVec::NameIdMap &&sfc_names)
const PolylineVec * getPolylineVecObj(const std::string &name) const
const std::vector< Polyline * > * getPolylineVec(const std::string &name) const
std::map< std::string, std::size_t > NameIdMap
Definition TemplateVec.h:41
NameIdMap::const_iterator getNameIDMapBegin() const
Returns the begin of the name id mapping structure.
Definition TemplateVec.h:85
NameIdMap::const_iterator getNameIDMapEnd() const
Returns the end of the name id mapping structure.
Definition TemplateVec.h:91

References _geo_objects, _output_name, GeoLib::GEOObjects::addPointVec(), GeoLib::GEOObjects::addPolylineVec(), GeoLib::GEOObjects::addSurfaceVec(), copyPolylinesVector(), copySurfacesVector(), ERR(), GeoLib::TemplateVec< T >::getNameIDMapBegin(), GeoLib::TemplateVec< T >::getNameIDMapEnd(), GeoLib::GEOObjects::getPointVec(), GeoLib::GEOObjects::getPointVecObj(), GeoLib::GEOObjects::getPolylineVec(), GeoLib::GEOObjects::getPolylineVecObj(), GeoLib::GEOObjects::getSurfaceVec(), and GeoLib::GEOObjects::getSurfaceVecObj().

Referenced by DuplicateGeometry().

◆ getFinalizedOutputName()

std::string const & GeoLib::DuplicateGeometry::getFinalizedOutputName ( ) const
inline

Definition at line 42 of file DuplicateGeometry.h.

42{ return _output_name; }

References _output_name.

Referenced by MainWindow::mapGeometry().

◆ getPointVectorCopy()

std::vector< GeoLib::Point * > & GeoLib::DuplicateGeometry::getPointVectorCopy ( )

Definition at line 129 of file DuplicateGeometry.cpp.

130{
131 return const_cast<std::vector<GeoLib::Point*>&>(
133}

References _geo_objects, _output_name, and GeoLib::GEOObjects::getPointVec().

◆ getPolylineVectorCopy()

std::vector< GeoLib::Polyline * > & GeoLib::DuplicateGeometry::getPolylineVectorCopy ( )

Definition at line 135 of file DuplicateGeometry.cpp.

136{
137 return const_cast<std::vector<GeoLib::Polyline*>&>(
139}

References _geo_objects, _output_name, and GeoLib::GEOObjects::getPolylineVec().

◆ getSurfaceVectorCopy()

std::vector< GeoLib::Surface * > & GeoLib::DuplicateGeometry::getSurfaceVectorCopy ( )

Definition at line 141 of file DuplicateGeometry.cpp.

142{
143 return const_cast<std::vector<GeoLib::Surface*>&>(
145}

References _geo_objects, _output_name, and GeoLib::GEOObjects::getSurfaceVec().

Member Data Documentation

◆ _geo_objects

GeoLib::GEOObjects& GeoLib::DuplicateGeometry::_geo_objects
private

◆ _output_name

std::string GeoLib::DuplicateGeometry::_output_name
private

The documentation for this class was generated from the following files: