14#ifdef ENABLE_OPENCASCADE
19#undef _USE_MATH_DEFINES
28#include <BRepPrimAPI_MakeCylinder.hxx>
35Kernel::Logger logger(
"Cylinder");
41 :
Quadratic(), m_centre(), m_normal(1, 0, 0), m_normVec(0), m_radius(0.0)
66 return std::unique_ptr<Cylinder>(
doClone());
80 enum { errDesc = -1, errAxis = -2, errCent = -3, errRadius = -4 };
82 std::string
Line = Pstr;
89 const std::size_t itemPt((item[1] ==
'/' && item.length() == 3) ? 2 : 1);
90 const auto ptype =
static_cast<std::size_t
>(tolower(item[itemPt]) -
'x');
93 std::vector<double> norm(3, 0.0);
94 std::vector<double> cent(3, 0.0);
99 std::size_t
index((!ptype) ? 1 : 0);
133 if (m_radius > 0.0) {
134 double x = Pt[m_normVec % 3] - m_centre[m_normVec % 3];
136 double y = Pt[(m_normVec + 1) % 3] - m_centre[(m_normVec + 1) % 3];
138 double displace =
x +
y - m_radius * m_radius;
141 return (displace > 0.0) ? 1 : -1;
157 double x = Pt[m_normVec % 3] - m_centre[m_normVec % 3];
159 double y = Pt[(m_normVec + 1) % 3] - m_centre[(m_normVec + 1) % 3];
161 return (std::abs((
x +
y) - m_radius * m_radius) <=
Tolerance);
174 for (std::size_t i = 0; i < 3; i++) {
277 const char Tailends[] =
"zyx xyz";
278 const int Ndir = m_normal.masterDir(
Tolerance);
285 const int Cdir = m_centre.masterDir(
Tolerance);
286 std::ostringstream cx;
292 if (Cdir * Cdir == Ndir * Ndir || m_centre.nullVector(
Tolerance)) {
294 cx << Tailends[Ndir + 3] <<
" ";
298 cx << Tailends[Ndir + 3] <<
" ";
300 if (Ndir == 1 || Ndir == -1)
301 cx << m_centre[1] <<
" " << m_centre[2] <<
" ";
302 else if (Ndir == 2 || Ndir == -2)
303 cx << m_centre[0] <<
" " << m_centre[2] <<
" ";
305 cx << m_centre[0] <<
" " << m_centre[1] <<
" ";
334 logger.debug() <<
"Axis ==" <<
m_normal <<
" ";
335 logger.debug() <<
"Centre == " <<
m_centre <<
" ";
336 logger.debug() <<
"Radius == " <<
m_radius <<
'\n';
355 std::vector<V3D> listOfPoints;
356 double txmax, tymax, tzmax, txmin, tymin, tzmin;
363 V3D xminPoint, xmaxPoint, yminPoint, ymaxPoint, zminPoint, zmaxPoint;
368 listOfPoints.emplace_back(xminPoint);
369 listOfPoints.emplace_back(xmaxPoint);
377 listOfPoints.emplace_back(yminPoint);
378 listOfPoints.emplace_back(ymaxPoint);
385 listOfPoints.emplace_back(zminPoint);
386 listOfPoints.emplace_back(zmaxPoint);
388 if (!listOfPoints.empty()) {
389 xmin = ymin = zmin = std::numeric_limits<double>::max();
390 xmax = ymax = zmax = std::numeric_limits<double>::lowest();
391 for (std::vector<V3D>::const_iterator it = listOfPoints.begin(); it != listOfPoints.end(); ++it) {
427#ifdef ENABLE_OPENCASCADE
428TopoDS_Shape Cylinder::createShape() {
434 return BRepPrimAPI_MakeCylinder(gpA,
m_radius, 1000.0, 2.0 * M_PI).Solid();
const std::vector< double > * lambda
std::map< DeltaEMode::Type, std::string > index
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
Holds a cylinder as a vector form.
bool onSurface(const Kernel::V3D &) const override
Calculate if the point PT on the cylinder.
void setNormVec()
check to obtain orientation
int side(const Kernel::V3D &) const override
Calculate if the point PT within the middle of the cylinder.
void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) override
bounding box for the surface
std::unique_ptr< Cylinder > clone() const
Makes a clone (implicit virtual copy constructor)
Cylinder * doClone() const override
Makes a clone (implicit virtual copy constructor)
void print() const override
Debug routine to print out basic information.
double m_radius
Radius of cylinder.
void setRadiusInternal(const double &r)
void displace(const Kernel::V3D &) override
Apply a displacement Pt.
void setCentre(const Kernel::V3D &)
Sets the centre Kernel::V3D.
int setSurface(const std::string &) override
Processes a standard MCNPX cone string Recall that cones can only be specified on an axis Valid input...
void setNorm(const Kernel::V3D &)
Sets the centre line unit vector A does not need to be a unit vector.
Kernel::V3D m_normal
Direction of centre line.
double distance(const Kernel::V3D &) const override
Calculates the distance of point A from the surface of the cylinder.
std::size_t m_normVec
Normal vector is x,y or z :: (1-3) (0 if general)
void rotate(const Kernel::Matrix< double > &) override
Apply a rotation to the cylinder and re-check the status of the main axis.
virtual double lineIntersect(const Kernel::V3D &, const Kernel::V3D &) const
Given a track starting from Pt and traveling along uVec determine the intersection point (distance)
Kernel::V3D m_centre
Kernel::V3D for centre.
Cylinder()
Standard Constructor creats a cylinder (radius 0) along the x axis.
void setBaseEqn() override
Sets an equation of type (cylinder)
void write(std::ostream &) const override
Write out the cylinder for MCNPX.
Holds a basic quadratic surface.
bool onSurface(const Kernel::V3D &) const override
is point valid on surface
std::vector< double > BaseEqn
Base equation (as a 10 point vector)
void displace(const Kernel::V3D &) override
Apply a general displacement to the surface.
void rotate(const Kernel::Matrix< double > &) override
Rotate the surface by matrix MX.
void print() const override
Print out the genreal equation for debugging.
void write(std::ostream &) const override
Writes out an MCNPX surface description Note : Swap since base equation is swapped in gq output (mcnp...
int side(const Kernel::V3D &) const override
Determine if the the Point is true to the surface or on the other side.
static const int Nprecision
Precision of the output.
double distance(const V3D &v) const noexcept
Calculates the distance between two vectors.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
double normalize()
Make a normalized vector (return norm value)
void rotate(const Matrix< double > &) noexcept
Rotate a point by a matrix.
int section(std::string &A, T &out)
Convert and cut a string.
MANTID_KERNEL_DLL void writeMCNPX(const std::string &Line, std::ostream &OX)
Write file in standard MCNPX input form.
constexpr double Tolerance
Standard tolerance value.
MANTID_KERNEL_DLL V3D normalize(V3D v)
Normalizes a V3D.