From 9e9c9ac174e450c84889a36504b4168fdb59b4b8 Mon Sep 17 00:00:00 2001 From: csendlinger Date: Tue, 9 Jun 2026 09:13:20 +0200 Subject: [PATCH] Changes to the Cone+Cylinder Geometry; cutting off the tip of the cone is now supported --- include/simulation/geometry.h | 5 +++-- src/generators/geometry_generator.cpp | 8 ++++++-- src/simulation/geometry.cpp | 9 +++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/simulation/geometry.h b/include/simulation/geometry.h index b6119c3..3cb6804 100755 --- a/include/simulation/geometry.h +++ b/include/simulation/geometry.h @@ -42,12 +42,12 @@ class Cylinder : public Geometry { */ /* - Geometry of a cylinder with a cone as the end at z=0. + Geometry of a cylinder with a cone as the end with its tip at z=0. */ class HalfCylinderWithCone : public Geometry { public: HalfCylinderWithCone(double radiusCylinder, double heightCylinder, - double heightCone); + double heightCone, double zfrustum); bool isInside(const Coordinate& position) const; GeometryPositioning isWhere(const Coordinate& position) const; @@ -55,6 +55,7 @@ class HalfCylinderWithCone : public Geometry { const double cylinder_radius_; const double cylinder_height_; const double cone_height_; + const double z_frustum_; double localRadius(double z) const; }; diff --git a/src/generators/geometry_generator.cpp b/src/generators/geometry_generator.cpp index 66c01d4..25b953b 100755 --- a/src/generators/geometry_generator.cpp +++ b/src/generators/geometry_generator.cpp @@ -41,14 +41,18 @@ std::shared_ptr buildGeometry(Parameter& parameter, json_read_length(parameter.jsonObjectFromBase(json_path_append( path_to_geometry, {"HalfCylinderWithCone", "HeightCone"})), "m"); + double z_frustum = + json_read_length(parameter.jsonObjectFromBase(json_path_append( + path_to_geometry, {"HalfCylinderWithCone", "FrustumStartZ"})), + "m"); #ifdef debug std::stringstream out; - out << "height cyl: " << heightcylinder << ", height cone: " << heightcone << ", radius: " << radius << "\n"; + out << "height cyl: " << heightcylinder << ", height cone: " << heightcone << ", radius: " << radius << ", zfrustum: " << z_frustum << "\n"; DEBUG(out.str()); #endif return std::shared_ptr( - new HalfCylinderWithCone(radius, heightcylinder, heightcone)); + new HalfCylinderWithCone(radius, heightcylinder, heightcone, z_frustum)); } else { ERROR("This geometry is not implemented."); return nullptr; diff --git a/src/simulation/geometry.cpp b/src/simulation/geometry.cpp index b140fb6..85bf1be 100755 --- a/src/simulation/geometry.cpp +++ b/src/simulation/geometry.cpp @@ -25,21 +25,22 @@ GeometryPositioning Cylinder::isWhere(const Coordinate& position) const { } HalfCylinderWithCone::HalfCylinderWithCone(double radiusCylinder, double heightCylinder, - double heightCone) : + double heightCone, double z_frustum) : cylinder_height_(heightCylinder), cylinder_radius_(radiusCylinder), - cone_height_(heightCone) {} + cone_height_(heightCone), + z_frustum_(z_frustum) {} bool HalfCylinderWithCone::isInside(const Coordinate& coordinate) const { const blitz::TinyVector cylinder_position = coordinate.cylinderEntries(); - return (cylinder_position(2) > 0) && + return (cylinder_position(2) > z_frustum_) && (cylinder_position(2) < (cylinder_height_ + cone_height_)) && (cylinder_position(0) < localRadius(cylinder_position(2))); } GeometryPositioning HalfCylinderWithCone::isWhere(const Coordinate& coordinate) const { const blitz::TinyVector cylinder_position = coordinate.cylinderEntries(); - if(cylinder_position(0) >= localRadius(cylinder_position(2))) { + if(cylinder_position(2) <= z_frustum_ || cylinder_position(0) >= localRadius(cylinder_position(2))) { return GeometryPositioning::hull; } else if (cylinder_position(2) >= (cone_height_ + cylinder_height_)) { return GeometryPositioning::top;