27#ifdef ENABLE_OPENCASCADE
32#undef _USE_MATH_DEFINES
41#include <BRepPrimAPI_MakeCone.hxx>
51 :
Quadratic(), Centre(), Normal(1, 0, 0), alpha(0.0), cangle(1.0)
66 return new Cone(*
this);
81 std::string
Line = Pstr;
88 const std::size_t itemPt((item[1] ==
'/' && item.length() == 3) ? 2 : 1);
89 const auto ptype =
static_cast<std::size_t
>(tolower(item[itemPt]) -
'x');
92 std::vector<double> norm(3, 0.0);
93 std::vector<double> cent(3, 0.0);
131 if (Centre.distance(A.Centre) >
Tolerance)
133 if (Normal.distance(A.Normal) >
Tolerance)
197 const double norm = A.
norm();
223 cangle = 1.0 / sqrt(A * A + 1.0);
246 Pangle = acos(-Pangle);
248 Pangle = acos(Pangle);
250 Pangle -= M_PI * alpha / 180.0;
251 return Px.
norm() * sin(Pangle);
269 const double eqn(sqrt(rptAngle));
272 return (eqn >
cangle) ? 1 : -1;
287 const double eqn(sqrt(rptAngle));
300 const char Tailends[] =
"zyx xyz";
301 const int Ndir = Normal.masterDir(
Tolerance);
306 std::ostringstream cx;
309 const int Cdir = Centre.masterDir(
Tolerance);
313 if (Cdir || Centre.nullVector(
Tolerance)) {
315 cx << Tailends[Ndir + 3] <<
" ";
316 cx << ((Cdir > 0) ? Centre[
static_cast<std::size_t
>(Cdir - 1)] : Centre[
static_cast<std::size_t
>(-Cdir - 1)]);
320 cx << Tailends[Ndir + 3] <<
" ";
321 for (std::size_t i = 0; i < 3; i++)
322 cx << Centre[i] <<
" ";
324 const double TA = tan((M_PI * alpha) / 180.0);
347 xmin = std::max(
Centre.
X(), ymin);
349 xmax = std::min(
Centre.
X(), ymax);
358 ymin = std::max(
Centre.
Y(), ymin);
360 ymax = std::min(
Centre.
Y(), ymax);
369 zmin = std::max(
Centre.
Z(), ymin);
371 zmax = std::min(
Centre.
Z(), ymax);
381#ifdef ENABLE_OPENCASCADE
382TopoDS_Shape Cone::createShape() {
384 return BRepPrimAPI_MakeCone(gpA, 0.0, 1000.0 / tan(acos(
cangle * M_PI / 180.0)), 1000.0, 2.0 * M_PI).Shape();
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 cone in vector form.
int setSurface(const std::string &) override
This method sets the cone surface using the input string in MCNPx format.
Kernel::V3D Normal
Normal.
int side(const Kernel::V3D &R) const override
Calculate if the point R is within the cone (return -1) or outside (return 1)
Kernel::V3D Centre
Kernel::V3D for centre.
bool onSurface(const Kernel::V3D &R) const override
Calculate if the point R is on the cone.
std::unique_ptr< Cone > clone() const
void write(std::ostream &) const override
This method will write the cone equation in MCNP geometry format.
void setNorm(const Kernel::V3D &)
This method sets the cone normal.
void setAngle(double const)
This method sets the angle of the cone.
double alpha
Angle (degrees)
void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) override
This will get the bounding box for the cone.
void setTanAngle(double const)
This method sets the tan angle which will be converted to cos used for MCNPX format.
void setBaseEqn() override
This method generates the quadratic equation for cone.
int operator==(const Cone &) const
Equality operator.
Cone()
Constructor with centre line along X axis and centre on origin.
void rotate(const Kernel::Matrix< double > &) override
Rotate both the centre and the normal direction.
void setCentre(const Kernel::V3D &)
This method sets the centre of the cone.
void displace(const Kernel::V3D &) override
Displace the centre Only need to update the centre position.
double distance(const Kernel::V3D &) const override
This method returns the distance of the point from the cone.
Cone * doClone() const override
Makes a clone (implicit virtual copy constructor)
Holds a basic quadratic surface.
std::vector< double > BaseEqn
Base equation (as a 10 point vector)
void write(std::ostream &) const override
Writes out an MCNPX surface description Note : Swap since base equation is swapped in gq output (mcnp...
void writeHeader(std::ostream &) const
Writes out the start of an MCNPX surface description .
static const int Nprecision
Precision of the output.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
constexpr double X() const noexcept
Get x.
constexpr double Y() const noexcept
Get y.
void rotate(const Matrix< double > &) noexcept
Rotate a point by a matrix.
double norm() const noexcept
constexpr double Z() const noexcept
Get z.
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.