Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://www.mooseframework.org 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "CSGSurface.h" 11 : #include "CSGUtils.h" 12 : 13 : namespace CSG 14 : { 15 : 16 688 : CSGSurface::CSGSurface(const std::string & name, const std::string & surf_type) 17 688 : : _name(name), _surface_type(surf_type) 18 : { 19 688 : CSGUtils::checkValidCSGName(name); 20 712 : } 21 : 22 : CSGSurface::Halfspace 23 492 : CSGSurface::getHalfspaceFromPoint(const Point & p) const 24 : { 25 : // if transformations are present on the surface, apply them in reverse to the point and pass that 26 : // new point to the evaluation to ensure transformations are considered. 27 : 28 : // Create a local transformed copy - the original p in the calling scope is NOT modified 29 492 : const Point p_trans = getTransformations().size() ? applyReverseTransformsToPoint(p) : p; 30 : 31 492 : auto eval = evaluateSurfaceEquationAtPoint(p_trans); 32 492 : if (MooseUtils::absoluteFuzzyGreaterThan(eval, 0)) 33 248 : return Halfspace::POSITIVE; 34 244 : else if (MooseUtils::absoluteFuzzyLessThan(eval, 0)) 35 242 : return Halfspace::NEGATIVE; 36 : else 37 2 : mooseError("Point ", 38 : p, 39 : " used to determine halfspace evaluation lies on the surface ", 40 2 : _name, 41 : ", leading to an ambiguously defined halfspace."); 42 : } 43 : 44 : bool 45 242 : CSGSurface::operator==(const CSGSurface & other) const 46 : { 47 482 : return (this->getName() == other.getName()) && 48 240 : (this->getSurfaceType() == other.getSurfaceType()) && 49 1202 : (this->getCoeffs() == other.getCoeffs()) && 50 720 : (this->getTransformations() == other.getTransformations()); 51 : } 52 : 53 : bool 54 232 : CSGSurface::operator!=(const CSGSurface & other) const 55 : { 56 232 : return !(*this == other); 57 : } 58 : 59 : } // namespace CSG