Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4957 - Some copy constructors aren't declared in SWIG #4960

Merged
merged 5 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/utilities/geometry/Geometry.i
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@
}
}

%extend openstudio::Surface3d {
std::string __str__() const {
std::ostringstream os;
os << *self;
return os.str();
}
}
Comment on lines +172 to +178
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the new Surface3d::operator<< in the swig interface file


%extend openstudio::Transformation {

std::string __str__() const {
Expand Down
10 changes: 5 additions & 5 deletions src/utilities/geometry/Plane.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ class UTILITIES_API Plane
/// throws openstudio::Exception if cannot compute plane for these points.
Plane(const std::vector<Point3d>& points);

// Copy and move operators are implicitly declared (Rule of 1)
// Copy and move operators are implicitly declared (Rule of 1), but we want the copy ctor for SWIG so we have to define all of them
// There's no need to check if the length of the normal is zero since we never allow another plane to not satisfy this condition
// Plane(const Plane& other) = default;
// Plane(Plane&& other) = default;
// Plane& operator=(const Plane&) = default;
// Plane& operator=(Plane&&) = default;
Plane(const Plane& other) = default;
Plane(Plane&& other) noexcept = default;
Plane& operator=(const Plane&) = default;
Plane& operator=(Plane&&) noexcept = default;
// ~Plane() noexcept = default;

/// get the outward normal of this plane
Expand Down
10 changes: 5 additions & 5 deletions src/utilities/geometry/Point3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class UTILITIES_API Point3d
/// constructor with x, y, z
Point3d(double x, double y, double z);

// Copy and move operators are implicitly declared
// Point3d(const Point3d& other) = default;
// Point3d(Point3d&& other) = default;
// Point3d& operator=(const Point3d&) = default;
// Point3d& operator=(Point3d&&) = default;
// Copy and move operators are implicitly declared, but we want the copy ctor for SWIG so we have to define all of them
Point3d(const Point3d& other) = default;
Point3d(Point3d&& other) noexcept = default;
Point3d& operator=(const Point3d&) = default;
Point3d& operator=(Point3d&&) noexcept = default;
Comment on lines +30 to +34
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put back the copy ctor for swig. Have to declare all of them or the move operations are implicitly deleted

// ~Point3d() noexcept = default;

/// get x
Expand Down
10 changes: 5 additions & 5 deletions src/utilities/geometry/Polygon3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class UTILITIES_API Polygon3d
// Constructs a polygon with an outer path and one or more inner paths
Polygon3d(const Point3dVector& outerPath, const Point3dVectorVector& innerPaths);

// Copy and move operators are implicitly declared (Rule of 1)
// Polygon3d(const Polygon3d& other) = default;
// Polygon3d(Polygon3d&& other) = default;
// Polygon3d& operator=(const Polygon3d&) = default;
// Polygon3d& operator=(Polygon3d&&) = default;
// Copy and move operators are implicitly declared (Rule of 1), but we want the copy ctor for SWIG so we have to define all of them
Polygon3d(const Polygon3d& other) = default;
Polygon3d(Polygon3d&& other) noexcept = default;
Polygon3d& operator=(const Polygon3d&) = default;
Polygon3d& operator=(Polygon3d&&) noexcept = default;
// ~Polygon3d() noexcept = default;

// Assigns an outer path for the polygon
Expand Down
23 changes: 20 additions & 3 deletions src/utilities/geometry/Polyhedron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ Vector3d Surface3dEdge::asVector() const {
}

std::ostream& operator<<(std::ostream& os, const Surface3dEdge& edge) {
os << "Surface3dEdge: start=" << edge.start() << ", end=" << edge.end() << ", count=" << edge.count()
<< ", firstSurface=" << edge.firstSurfaceName();
os << "Surface3dEdge: start=" << edge.start() << ", end=" << edge.end() << ", count=" << edge.count() << ", firstSurface='"
<< edge.firstSurfaceName() << "'";
return os;
}

Expand All @@ -118,10 +118,23 @@ Surface3d::Surface3d(std::vector<Point3d> t_vertices, std::string t_name, size_t
itnext = std::begin(vertices);
}

edges.emplace_back(*it, *itnext, t_name, t_surfNum);
edges.emplace_back(*it, *itnext, name, surfNum);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix an unrelated issue, t_name (the parameter) was moved from, so it's generally an empty string.

}
}

std::ostream& operator<<(std::ostream& os, const Surface3d& surface3d) {
os << "Surface3d ";
if (!surface3d.name.empty()) {
os << "'" << surface3d.name << "' ";
}
os << "= [\n";
for (const auto& pt : surface3d.vertices) {
os << " " << pt << ",\n";
}
os << "]";
return os;
}

bool Surface3d::operator<(const Surface3d& rhs) const {
return this->name < rhs.name;
}
Expand Down Expand Up @@ -492,4 +505,8 @@ double Polyhedron::calcDivergenceTheoremVolume() const {
return volume;
}

std::vector<Surface3d> Polyhedron::surface3ds() const {
return m_surfaces;
}

} // namespace openstudio
3 changes: 3 additions & 0 deletions src/utilities/geometry/Polyhedron.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ class UTILITIES_API Polyhedron
* proportion of conflicted edges / total number of edges */
std::vector<Surface3d> findSurfacesWithIncorrectOrientation() const;

std::vector<Surface3d> surface3ds() const;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convenience getter for inspection / debugging in Polyhedron


protected:
void performEdgeMatching();
void resetEdgeMatching();
Expand All @@ -164,6 +166,7 @@ using PolyhedronVector = std::vector<Polyhedron>;

/// ostream operator
UTILITIES_API std::ostream& operator<<(std::ostream& os, const Surface3dEdge& edge);
UTILITIES_API std::ostream& operator<<(std::ostream& os, const Surface3d& surface3d);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an ostream operator<< for convenience


} // namespace openstudio

Expand Down
10 changes: 5 additions & 5 deletions src/utilities/geometry/Transformation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class UTILITIES_API Transformation
/// constructor from storage, asserts vector is size 16
Transformation(const Vector& vector);

// Copy and move operators are implicitly declared (Rule of 1)
// Transformation(const Transformation& other) = default;
// Transformation(Transformation&& other) = default;
// Transformation& operator=(const Transformation&) = default;
// Transformation& operator=(Transformation&&) = default;
// Copy and move operators are implicitly declared (Rule of 1), but we want the copy ctor for SWIG so we have to define all of them
Transformation(const Transformation& other) = default;
Transformation(Transformation&& other) noexcept = default;
Transformation& operator=(const Transformation&) = default;
Transformation& operator=(Transformation&&) noexcept = default;
// ~Transformation() noexcept = default;

/// rotation about origin defined by axis and angle (radians)
Expand Down
10 changes: 5 additions & 5 deletions src/utilities/geometry/Vector3d.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class UTILITIES_API Vector3d
/// constructor with x, y, z
Vector3d(double x, double y, double z);

// Copy and move operators are implicitly declared (Rule of 1)
// Vector3d(const Vector3d& other) = default;
// Vector3d(Vector3d&& other) = default;
// Vector3d& operator=(const Vector3d&) = default;
// Vector3d& operator=(Vector3d&&) = default;
// Copy and move operators are implicitly declared (Rule of 1), but we want the copy ctor for SWIG so we have to define all of them
Vector3d(const Vector3d& other) = default;
Vector3d(Vector3d&& other) noexcept = default;
Vector3d& operator=(const Vector3d&) = default;
Vector3d& operator=(Vector3d&&) noexcept = default;
// ~Vector3d() noexcept = default;

/// get x
Expand Down