Changes to the Cone+Cylinder Geometry; cutting off the
tip of the cone is now supported
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -41,14 +41,18 @@ std::shared_ptr<Geometry> 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<Geometry>(
|
||||
new HalfCylinderWithCone(radius, heightcylinder, heightcone));
|
||||
new HalfCylinderWithCone(radius, heightcylinder, heightcone, z_frustum));
|
||||
} else {
|
||||
ERROR("This geometry is not implemented.");
|
||||
return nullptr;
|
||||
|
||||
@@ -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<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(0) < localRadius(cylinder_position(2)));
|
||||
}
|
||||
|
||||
GeometryPositioning HalfCylinderWithCone::isWhere(const Coordinate& coordinate) const {
|
||||
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;
|
||||
} else if (cylinder_position(2) >= (cone_height_ + cylinder_height_)) {
|
||||
return GeometryPositioning::top;
|
||||
|
||||
Reference in New Issue
Block a user