Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::Geometry::Intersection Class Reference

Combines two Rule objects in an intersection. More...

#include <Rules.h>

Inheritance diagram for Mantid::Geometry::Intersection:
Mantid::Geometry::Rule

Public Member Functions

std::string className () const override
 Returns class name as string.
 
std::unique_ptr< Intersection > clone () const
 Makes a copy of the whole downward tree.
 
std::string display () const override
 Displaces a bracket wrapped object.
 
std::string displayAddress () const override
 Debug function that converts the the intersection ion space delimited unit to denote intersection.
 
Rule * findKey (const int KeyN) override
 Finds the leaf with the surface number KeyN.
 
int findLeaf (const Rule *) const override
 Finds out if the Rule is the same as the leaves.
 
void getBoundingBox (double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) override
 find the common bounding box with the two childs of intersection
 
 Intersection ()=default
 
 Intersection (Rule *, std::unique_ptr< Rule >, std::unique_ptr< Rule >)
 Intersection constructor from two Rule ptrs.
 
 Intersection (std::unique_ptr< Rule >, std::unique_ptr< Rule >)
 Intersection constructor from two Rule ptrs.
 
int isComplementary () const override
 Determine is the rule has complementary sub components.
 
bool isValid (const Kernel::V3D &) const override
 Calculates if Vec is within the object.
 
bool isValid (const std::map< int, int > &) const override
 Use MX to determine if the surface truth etc is valie.
 
Rule * leaf (const int ipt=0) const override
 selects leaf component
 
void setLeaf (std::unique_ptr< Rule > nR, const int side=0) override
 set one leaf.
 
void setLeaves (std::unique_ptr< Rule >, std::unique_ptr< Rule >) override
 set leaves
 
int simplify () override
 apply general intersection simplification
 
int type () const override
 Null rule.
 
- Public Member Functions inherited from Mantid::Geometry::Rule
int checkParents () const
 Debug test for parents.
 
std::unique_ptr< Rule > clone () const
 
int commonType () const
 Gets a common type.
 
int Eliminate ()
 elimination not written
 
int getKeyList (std::vector< int > &) const
 Generate the key list given an insertion type object.
 
Rule * getParent () const
 Returns the parent object.
 
void makeParents ()
 This is initialisation code that populates all the parents in the rule tree.
 
 Rule ()
 Standard Constructor.
 
 Rule (Rule *)
 Constructor copies.
 
void setParent (Rule *)
 Sets the parent object (not check for A==this)
 
int substituteSurf (const int SurfN, const int newSurfN, const std::shared_ptr< Surface > &SPtr)
 Substitues a surface item if within a rule.
 
virtual ~Rule ()=default
 

Protected Member Functions

 Intersection (const Intersection &)
 Copy constructor: Does a clone on the sub-tree below.
 
Intersection & operator= (const Intersection &)
 Assignment operator :: Does a deep copy of the leaves of Iother.
 
- Protected Member Functions inherited from Mantid::Geometry::Rule
Rule & operator= (const Rule &)
 Assignment operator= does not set parent as Rules are cloned.
 
 Rule (const Rule &)
 Constructor copies.
 

Private Member Functions

Intersection * doClone () const override
 Makes a copy of the whole downward tree.
 

Private Attributes

std::unique_ptr< Rule > A
 Rule 1.
 
std::unique_ptr< Rule > B
 Rule 2.
 

Additional Inherited Members

- Static Public Member Functions inherited from Mantid::Geometry::Rule
static int makeCNF (std::unique_ptr< Rule > &)
 Make Rule into a CNF format.
 
static int makeCNFcopy (std::unique_ptr< Rule > &)
 Make Rule into a CNF format (slow)
 
static int makeFullDNF (std::unique_ptr< Rule > &)
 Make Rule into a full DNF format.
 
static int removeComplementary (std::unique_ptr< Rule > &)
 NOT WORKING.
 
static int removeItem (std::unique_ptr< Rule > &TRule, const int SurfN)
 Given an item as a surface name, remove the surface from the Rule tree.
 

Detailed Description

Combines two Rule objects in an intersection.

Author
S. Ansell
Version
1.0
Date
August 2005

Intersection is defined as a valid Rule A and valid rule B

Definition at line 109 of file Rules.h.

Constructor & Destructor Documentation

◆ Intersection() [1/4]

Mantid::Geometry::Intersection::Intersection ( const Intersection &  Iother)
protected

Copy constructor: Does a clone on the sub-tree below.

Parameters
Iother:: Intersection to copy

Definition at line 88 of file RuleItems.cpp.

References A, and B.

◆ Intersection() [2/4]

Mantid::Geometry::Intersection::Intersection ( )
default

Referenced by doClone().

◆ Intersection() [3/4]

Mantid::Geometry::Intersection::Intersection ( std::unique_ptr< Rule >  Ix,
std::unique_ptr< Rule >  Iy 
)
explicit

Intersection constructor from two Rule ptrs.

  • Sets A,B's parents to *this
  • Allowed to control Ix and Iy
    Parameters
    Ix:: Rule A
    Iy:: Rule B

Definition at line 56 of file RuleItems.cpp.

References A, B, and Mantid::Geometry::Rule::setParent().

◆ Intersection() [4/4]

Mantid::Geometry::Intersection::Intersection ( Rule *  Parent,
std::unique_ptr< Rule >  Ix,
std::unique_ptr< Rule >  Iy 
)
explicit

Intersection constructor from two Rule ptrs.

  • Sets A,B's parents to *this.
    Parameters
    Parent:: Set the Rule::Parent pointer
    Ix:: Rule A
    Iy:: Rule B

Definition at line 72 of file RuleItems.cpp.

References A, B, and Mantid::Geometry::Rule::setParent().

Member Function Documentation

◆ className()

std::string Mantid::Geometry::Intersection::className ( ) const
inlineoverridevirtual

Returns class name as string.

Reimplemented from Mantid::Geometry::Rule.

Definition at line 124 of file Rules.h.

◆ clone()

std::unique_ptr< Intersection > Mantid::Geometry::Intersection::clone ( ) const

Makes a copy of the whole downward tree.

Virtual copy constructor.

Returns
new Intersection(this)

Definition at line 138 of file RuleItems.cpp.

References doClone().

◆ display()

std::string Mantid::Geometry::Intersection::display ( ) const
overridevirtual

Displaces a bracket wrapped object.

Returns
Bracketed string

Implements Mantid::Geometry::Rule.

Definition at line 231 of file RuleItems.cpp.

References A, and B.

◆ displayAddress()

std::string Mantid::Geometry::Intersection::displayAddress ( ) const
overridevirtual

Debug function that converts the the intersection ion space delimited unit to denote intersection.

Returns
( leaf leaf )

Implements Mantid::Geometry::Rule.

Definition at line 254 of file RuleItems.cpp.

References A, and B.

◆ doClone()

Intersection * Mantid::Geometry::Intersection::doClone ( ) const
overrideprivatevirtual

Makes a copy of the whole downward tree.

Virtual copy constructor.

Returns
new Intersection(this)

Implements Mantid::Geometry::Rule.

Definition at line 129 of file RuleItems.cpp.

References Intersection().

Referenced by clone().

◆ findKey()

Rule * Mantid::Geometry::Intersection::findKey ( const int  KeyN)
overridevirtual

Finds the leaf with the surface number KeyN.

Parameters
KeyN:: Number to search for
Return values
0:: no leaf with that key number availiable
Rule*if an appropiate leaf is found

Implements Mantid::Geometry::Rule.

Definition at line 217 of file RuleItems.cpp.

References A, B, and Mantid::Geometry::Rule::findKey().

◆ findLeaf()

int Mantid::Geometry::Intersection::findLeaf ( const Rule *  R) const
overridevirtual

Finds out if the Rule is the same as the leaves.

Parameters
R:: Rule pointer to compare
Return values
0/ 1 for LHS / RHS leaf
-1:: neither leaf

Implements Mantid::Geometry::Rule.

Definition at line 201 of file RuleItems.cpp.

◆ getBoundingBox()

void Mantid::Geometry::Intersection::getBoundingBox ( double &  xmax,
double &  ymax,
double &  zmax,
double &  xmin,
double &  ymin,
double &  zmin 
)
overridevirtual

find the common bounding box with the two childs of intersection

Parameters
xmax:: Maximum value for the bounding box in x direction
ymax:: Maximum value for the bounding box in y direction
zmax:: Maximum value for the bounding box in z direction
xmin:: Minimum value for the bounding box in x direction
ymin:: Minimum value for the bounding box in y direction
zmin:: Minimum value for the bounding box in z direction

Implements Mantid::Geometry::Rule.

Definition at line 327 of file RuleItems.cpp.

References A, and B.

◆ isComplementary()

int Mantid::Geometry::Intersection::isComplementary ( ) const
overridevirtual

Determine is the rule has complementary sub components.

Return values
1:: A side
-1:: B side
0:: no complement

Reimplemented from Mantid::Geometry::Rule.

Definition at line 147 of file RuleItems.cpp.

References A, and B.

◆ isValid() [1/2]

bool Mantid::Geometry::Intersection::isValid ( const Kernel::V3D &  Vec) const
overridevirtual

Calculates if Vec is within the object.

Parameters
Vec:: Point to test
Return values
1:: Vec is within object
0:: Vec is outside object.

Implements Mantid::Geometry::Rule.

Definition at line 275 of file RuleItems.cpp.

◆ isValid() [2/2]

bool Mantid::Geometry::Intersection::isValid ( const std::map< int, int > &  MX) const
overridevirtual

Use MX to determine if the surface truth etc is valie.

Parameters
MX:: map of key + logical value XOR sign
Return values
1:: Both sides are valid
0:: Either side is invalid.

Implements Mantid::Geometry::Rule.

Definition at line 289 of file RuleItems.cpp.

◆ leaf()

Rule * Mantid::Geometry::Intersection::leaf ( const int  ipt = 0) const
inlineoverridevirtual

selects leaf component

Reimplemented from Mantid::Geometry::Rule.

Definition at line 126 of file Rules.h.

◆ operator=()

Intersection & Mantid::Geometry::Intersection::operator= ( const Intersection &  Iother)
protected

Assignment operator :: Does a deep copy of the leaves of Iother.

Parameters
Iother:: object to copy
Returns
*this

Definition at line 106 of file RuleItems.cpp.

References A, B, and Mantid::Geometry::Rule::operator=().

◆ setLeaf()

void Mantid::Geometry::Intersection::setLeaf ( std::unique_ptr< Rule >  nR,
const int  side = 0 
)
overridevirtual

set one leaf.

Replaces a leaf with a rule.

Calls delete on previous leaf.

Parameters
nR:: new rule
side:: side to use
  • 0 == LHS
  • 1 == RHS

Implements Mantid::Geometry::Rule.

Definition at line 180 of file RuleItems.cpp.

References A, and B.

◆ setLeaves()

void Mantid::Geometry::Intersection::setLeaves ( std::unique_ptr< Rule >  aR,
std::unique_ptr< Rule >  bR 
)
overridevirtual

set leaves

Replaces a both with a rule.

No deletion is carried out but sets the parents.

Parameters
aR:: Rule on the left
bR:: Rule on the right

Implements Mantid::Geometry::Rule.

Definition at line 164 of file RuleItems.cpp.

References A, and B.

◆ simplify()

int Mantid::Geometry::Intersection::simplify ( )
overridevirtual

apply general intersection simplification

Union simplification::

  • -S S simplify to True.
  • S S simplify to S
  • -S -S simplifies to -S
    Return values
    1if clauses removed (not top)
    -1replacement of this intersection is required by leaf 0
    0if no work to do.

Implements Mantid::Geometry::Rule.

Definition at line 303 of file RuleItems.cpp.

◆ type()

int Mantid::Geometry::Intersection::type ( ) const
inlineoverridevirtual

Null rule.

Reimplemented from Mantid::Geometry::Rule.

Definition at line 135 of file Rules.h.

Member Data Documentation

◆ A

std::unique_ptr<Rule> Mantid::Geometry::Intersection::A
private

◆ B

std::unique_ptr<Rule> Mantid::Geometry::Intersection::B
private

The documentation for this class was generated from the following files: