Changes to the Cone+Cylinder Geometry; cutting off the

tip of the cone is now supported
This commit is contained in:
2026-06-09 09:13:20 +02:00
parent a6a9ac388c
commit 9e9c9ac174
3 changed files with 14 additions and 8 deletions
+3 -2
View File
@@ -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 { class HalfCylinderWithCone : public Geometry {
public: public:
HalfCylinderWithCone(double radiusCylinder, double heightCylinder, HalfCylinderWithCone(double radiusCylinder, double heightCylinder,
double heightCone); double heightCone, double zfrustum);
bool isInside(const Coordinate& position) const; bool isInside(const Coordinate& position) const;
GeometryPositioning isWhere(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_radius_;
const double cylinder_height_; const double cylinder_height_;
const double cone_height_; const double cone_height_;
const double z_frustum_;
double localRadius(double z) const; double localRadius(double z) const;
}; };
+6 -2
View File
@@ -41,14 +41,18 @@ std::shared_ptr<Geometry> buildGeometry(Parameter& parameter,
json_read_length(parameter.jsonObjectFromBase(json_path_append( json_read_length(parameter.jsonObjectFromBase(json_path_append(
path_to_geometry, {"HalfCylinderWithCone", "HeightCone"})), path_to_geometry, {"HalfCylinderWithCone", "HeightCone"})),
"m"); "m");
double z_frustum =
json_read_length(parameter.jsonObjectFromBase(json_path_append(
path_to_geometry, {"HalfCylinderWithCone", "FrustumStartZ"})),
"m");
#ifdef debug #ifdef debug
std::stringstream out; 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()); DEBUG(out.str());
#endif #endif
return std::shared_ptr<Geometry>( return std::shared_ptr<Geometry>(
new HalfCylinderWithCone(radius, heightcylinder, heightcone)); new HalfCylinderWithCone(radius, heightcylinder, heightcone, z_frustum));
} else { } else {
ERROR("This geometry is not implemented."); ERROR("This geometry is not implemented.");
return nullptr; return nullptr;
+5 -4
View File
@@ -25,21 +25,22 @@ GeometryPositioning Cylinder::isWhere(const Coordinate& position) const {
} }
HalfCylinderWithCone::HalfCylinderWithCone(double radiusCylinder, double heightCylinder, HalfCylinderWithCone::HalfCylinderWithCone(double radiusCylinder, double heightCylinder,
double heightCone) : double heightCone, double z_frustum) :
cylinder_height_(heightCylinder), cylinder_height_(heightCylinder),
cylinder_radius_(radiusCylinder), cylinder_radius_(radiusCylinder),
cone_height_(heightCone) {} cone_height_(heightCone),
z_frustum_(z_frustum) {}
bool HalfCylinderWithCone::isInside(const Coordinate& coordinate) const { bool HalfCylinderWithCone::isInside(const Coordinate& coordinate) const {
const blitz::TinyVector<double, 3> cylinder_position = coordinate.cylinderEntries(); const blitz::TinyVector<double, 3> cylinder_position = coordinate.cylinderEntries();
return (cylinder_position(2) > 0) && return (cylinder_position(2) > z_frustum_) &&
(cylinder_position(2) < (cylinder_height_ + cone_height_)) && (cylinder_position(2) < (cylinder_height_ + cone_height_)) &&
(cylinder_position(0) < localRadius(cylinder_position(2))); (cylinder_position(0) < localRadius(cylinder_position(2)));
} }
GeometryPositioning HalfCylinderWithCone::isWhere(const Coordinate& coordinate) const { GeometryPositioning HalfCylinderWithCone::isWhere(const Coordinate& coordinate) const {
const blitz::TinyVector<double, 3> cylinder_position = coordinate.cylinderEntries(); const blitz::TinyVector<double, 3> 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; return GeometryPositioning::hull;
} else if (cylinder_position(2) >= (cone_height_ + cylinder_height_)) { } else if (cylinder_position(2) >= (cone_height_ + cylinder_height_)) {
return GeometryPositioning::top; return GeometryPositioning::top;