Commit 7bb6aab7 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[python][geometry] add __repr__ fields

parent 3aac2be2
......@@ -69,6 +69,8 @@ void registerBox(py::module& module)
"point"_a, "returns true if the given point is within the box (default tolerance)");
cls.def("contains", py::overload_cast<const Point&, ctype>(&Box::contains, py::const_),
"point"_a, "eps"_a, "returns true if the given point is within the box (given tolerance)");
cls.def("__repr__", [&] (const Box& b) { return "Frackit::Box"; });
}
} // end namespace Frackit::Python
......
......@@ -68,6 +68,8 @@ namespace Detail {
"return the point on the circle for the given local coordinate (0.0 <= localCoordinate <= 1)");
cls.def("getPointFromAngle", &Circle::getPointFromAngle, "angle"_a,
"return the point on the circle for the given angle w.r.t. the circle-local coordinate system (angle >= 0.0)");
cls.def("__repr__", [&] (const Circle& c) { return "Frackit::Circle<" + std::to_string(worldDim) + ">"; });
}
} // end namespace detail
......
......@@ -70,6 +70,8 @@ void registerCylinder(py::module& module)
"point"_a, "returns true if the given point is within the cylinder (default tolerance)");
cls.def("contains", py::overload_cast<const Point&, ctype>(&Cylinder::contains, py::const_),
"point"_a, "eps"_a, "returns true if the given point is within the cylinder (given tolerance)");
cls.def("__repr__", [&] (const Cylinder& c) { return "Frackit::Cylinder"; });
}
} // end namespace Frackit::Python
......
......@@ -69,6 +69,8 @@ void registerCylinderSurface(py::module& module)
"point"_a, "returns true if the given point is on the cylinder surface (default tolerance)");
cls.def("contains", py::overload_cast<const Point&, ctype>(&CylinderSurface::contains, py::const_),
"point"_a, "eps"_a, "returns true if the given point is on the cylinder surface (given tolerance)");
cls.def("__repr__", [&] (const CylinderSurface& cs) { return "Frackit::CylinderSurface"; });
}
} // end namespace Frackit::Python
......
......@@ -61,6 +61,20 @@ namespace Detail {
cls.def("y", &Direction::y, "y-coordinate of the direction");
if constexpr (worldDim > 2)
cls.def("z", &Direction::z, "z-coordinate of the direction");
using std::to_string;
if constexpr (worldDim == 1)
cls.def("__repr__", [&] (const Direction& d)
{ return "Frackit::Direction<1> (" + to_string(d.x()) + ")"; });
else if constexpr (worldDim == 2)
cls.def("__repr__", [&] (const Direction& d)
{ return "Frackit::Direction<2> (" + to_string(d.x()) + ", "
+ to_string(d.y()) + ")"; });
else
cls.def("__repr__", [&] (const Direction& d)
{ return "Frackit::Direction<3> (" + to_string(d.x()) + ", "
+ to_string(d.y()) + ", "
+ to_string(d.z()) + ")"; });
}
} // end namespace detail
......
......@@ -62,6 +62,8 @@ void registerDisk(py::module& module)
// get a point from local coordinate or angle
cls.def("getPoint", &Disk::getPoint, "angularFraction"_a, "radialFraction"_a,
"return the point on the ellipse arc for the given angular and radial fractions (0.0 <= angular/radial fraction <= 1)");
cls.def("__repr__", [&] (const Disk& d) { return "Frackit::Disk"; });
}
} // end namespace Frackit::Python
......
......@@ -72,6 +72,8 @@ namespace Detail {
"returns the local coordinate of the given point on the ellipse");
cls.def("getAngle", &Ellipse::getAngle, "point"_a, "checkIfOnEllipse"_a = true,
"returns the angle w.r.t. the ellipse-local coordinate system of the given point");
cls.def("__repr__", [&] (const Ellipse& e) { return "Frackit::Ellipse<" + std::to_string(worldDim) + ">"; });
}
} // end namespace detail
......
......@@ -72,6 +72,8 @@ namespace Detail {
// get a point from local coordinate or angle
cls.def("getPoint", &EllipseArc::getPoint, "localCoordinate"_a,
"return the point on the ellipse arc for the given local coordinate (0.0 <= localCoordinate <= 1)");
cls.def("__repr__", [&] (const EllipseArc& ea) { return "Frackit::EllipseArc<" + std::to_string(worldDim) + ">"; });
}
} // end namespace detail
......
......@@ -58,6 +58,8 @@ namespace Detail {
"point"_a, "eps"_a, "returns true if the given point is on the line (given tolerance)");
cls.def("contains", py::overload_cast<const Point&>(&Line::contains, py::const_),
"point"_a, "returns true if the given point is on the line (default tolerance)");
cls.def("__repr__", [&] (const Line& l) { return "Frackit::Line<" + std::to_string(worldDim) + ">"; });
}
} // end namespace detail
......
......@@ -70,6 +70,8 @@ namespace Detail {
// contains query
cls.def("contains", &Plane::contains, "point"_a, "eps"_a = Precision<ctype>::confusion(),
"returns true if the given point is on the plane");
cls.def("__repr__", [&] (const Plane& p) { return "Frackit::Plane<" + std::to_string(worldDim) + ">"; });
}
} // end namespace detail
......
......@@ -68,6 +68,8 @@ namespace Detail {
cls.def("contains", py::overload_cast<const Point&, ctype, bool>(&Quad::contains, py::const_),
"point"_a, "eps"_a, "checkIfOnPlane"_a = true,
"returns true if the given point is on the quadrilateral (given tolerance)");
cls.def("__repr__", [&] (const Quad& q) { return "Frackit::Quadrilateral<" + std::to_string(worldDim) + ">"; });
}
} // end namespace detail
......
......@@ -67,6 +67,8 @@ namespace Detail {
cls.def("contains", py::overload_cast<const Point&, ctype, bool>(&Segment::contains, py::const_),
"point"_a, "eps"_a, "checkIfOnLine"_a = true,
"returns true if the given point is on the segment (given tolerance)");
cls.def("__repr__", [&] (const Segment& s) { return "Frackit::Segment<" + std::to_string(worldDim) + ">"; });
}
} // end namespace detail
......
......@@ -68,6 +68,8 @@ namespace Detail {
cls.def("contains", py::overload_cast<const Point&, ctype, bool>(&Triangle::contains, py::const_),
"point"_a, "eps"_a, "checkIfOnPlane"_a = true,
"returns true if the given point is on the triangle (given tolerance)");
cls.def("__repr__", [&] (const Triangle& t) { return "Frackit::Triangle<" + std::to_string(worldDim) + ">"; });
}
} // end namespace detail
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment