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

Object generation rule tree. More...

#include <Rules.h>

Inheritance diagram for Mantid::Geometry::Rule:
Mantid::Geometry::BoolValue Mantid::Geometry::CompGrp Mantid::Geometry::CompObj Mantid::Geometry::Intersection Mantid::Geometry::SurfPoint Mantid::Geometry::Union

Public Member Functions

int checkParents () const
 Debug test for parents. More...
 
virtual std::string className () const
 Returns class name as string. More...
 
std::unique_ptr< Ruleclone () const
 
int commonType () const
 Gets a common type. More...
 
virtual std::string display () const =0
 Abstract Display. More...
 
virtual std::string displayAddress () const =0
 Abstract Display Address. More...
 
int Eliminate ()
 elimination not written More...
 
virtual RulefindKey (const int)=0
 Abstract key find. More...
 
virtual int findLeaf (const Rule *) const =0
 Abstract find. More...
 
virtual void getBoundingBox (double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin)=0
 Abstract getBoundingBox. More...
 
int getKeyList (std::vector< int > &) const
 Generate the key list given an insertion type object. More...
 
RulegetParent () const
 Returns the parent object. More...
 
virtual int isComplementary () const
 Always returns false (0) More...
 
virtual bool isValid (const Kernel::V3D &) const =0
 Abstract: The point is within the object. More...
 
virtual bool isValid (const std::map< int, int > &) const =0
 Abstract Validity based on surface true/false map. More...
 
virtual Ruleleaf (const int=0) const
 No leaf for a base rule. More...
 
void makeParents ()
 This is initialisation code that populates all the parents in the rule tree. More...
 
 Rule ()
 Standard Constructor. More...
 
 Rule (Rule *)
 Constructor copies. More...
 
virtual void setLeaf (std::unique_ptr< Rule >, const int=0)=0
 Abstract set. More...
 
virtual void setLeaves (std::unique_ptr< Rule >, std::unique_ptr< Rule >)=0
 abstract set leaves More...
 
void setParent (Rule *)
 Sets the parent object (not check for A==this) More...
 
virtual int simplify ()=0
 Abstract: Can the rule be simplified. More...
 
int substituteSurf (const int SurfN, const int newSurfN, const std::shared_ptr< Surface > &SPtr)
 Substitues a surface item if within a rule. More...
 
virtual int type () const
 Null rule. More...
 
virtual ~Rule ()=default
 

Static Public Member Functions

static int makeCNF (std::unique_ptr< Rule > &)
 Make Rule into a CNF format. More...
 
static int makeCNFcopy (std::unique_ptr< Rule > &)
 Make Rule into a CNF format (slow) More...
 
static int makeFullDNF (std::unique_ptr< Rule > &)
 Make Rule into a full DNF format. More...
 
static int removeComplementary (std::unique_ptr< Rule > &)
 NOT WORKING. More...
 
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. More...
 

Protected Member Functions

Ruleoperator= (const Rule &)
 Assignment operator= does not set parent as Rules are cloned. More...
 
 Rule (const Rule &)
 Constructor copies. More...
 

Private Member Functions

virtual RuledoClone () const =0
 abstract clone object More...
 
int getBaseKeys (std::vector< int > &) const
 Fills the vector with the surfaces. More...
 

Static Private Member Functions

static int addToKey (std::vector< int > &AV, const int passN=-1)
 Static function :: Given a vector AV increase the number from lowest to highest in an iterative counting chain. More...
 

Private Attributes

RuleParent
 Parent object (for tree) More...
 

Detailed Description

Object generation rule tree.

Author
S.Ansell
Version
1.0
Date
April 2005

Base class for a rule item in the tree.

Definition at line 33 of file Rules.h.

Constructor & Destructor Documentation

◆ Rule() [1/3]

Mantid::Geometry::Rule::Rule ( const Rule )
protected

Constructor copies.

Parent set to 0

Definition at line 429 of file Rules.cpp.

◆ Rule() [2/3]

Mantid::Geometry::Rule::Rule ( )

Standard Constructor.

Definition at line 422 of file Rules.cpp.

◆ Rule() [3/3]

Mantid::Geometry::Rule::Rule ( Rule A)

Constructor copies.

Parent set to A

Parameters
A:: Parent value

Definition at line 437 of file Rules.cpp.

◆ ~Rule()

virtual Mantid::Geometry::Rule::~Rule ( )
virtualdefault

Member Function Documentation

◆ addToKey()

int Mantid::Geometry::Rule::addToKey ( std::vector< int > &  AV,
const int  passN = -1 
)
staticprivate

Static function :: Given a vector AV increase the number from lowest to highest in an iterative counting chain.

(effectively an N-bit binary number++)

Parameters
AV:: vector of the N-bit array
passN:: number that is to be skipped
Return values
bitnumber that was set from 0 to 1
-1if the a carry flag is set

Definition at line 35 of file Rules.cpp.

Referenced by Eliminate().

◆ checkParents()

int Mantid::Geometry::Rule::checkParents ( ) const

Debug test for parents.

This code checks if a parent tree is valid.

Return values
0on failure
1on success

Definition at line 499 of file Rules.cpp.

References getParent(), and leaf().

◆ className()

virtual std::string Mantid::Geometry::Rule::className ( ) const
inlinevirtual

◆ clone()

std::unique_ptr< Rule > Mantid::Geometry::Rule::clone ( ) const
inline

Definition at line 54 of file Rules.h.

Referenced by makeCNF(), makeCNFcopy(), and removeItem().

◆ commonType()

int Mantid::Geometry::Rule::commonType ( ) const

Gets a common type.

Function to return the common type of an rule.

Return values
1:: every rule is an intersection or component
-1:: every rule is an union or component
0:: mixed rule group or only component

Definition at line 526 of file Rules.cpp.

References leaf(), and type().

Referenced by removeComplementary().

◆ display()

virtual std::string Mantid::Geometry::Rule::display ( ) const
pure virtual

◆ displayAddress()

virtual std::string Mantid::Geometry::Rule::displayAddress ( ) const
pure virtual

◆ doClone()

virtual Rule * Mantid::Geometry::Rule::doClone ( ) const
privatepure virtual

◆ Eliminate()

int Mantid::Geometry::Rule::Eliminate ( )

elimination not written

This rule eliminates any unnecessary rules.

Todo:
Currently does not work since removeItem changes the top rule (so should this)
Returns
number of items eliminated

Definition at line 618 of file Rules.cpp.

References addToKey(), getKeyList(), and isValid().

◆ findKey()

virtual Rule * Mantid::Geometry::Rule::findKey ( const int  )
pure virtual

◆ findLeaf()

virtual int Mantid::Geometry::Rule::findLeaf ( const Rule ) const
pure virtual

◆ getBaseKeys()

int Mantid::Geometry::Rule::getBaseKeys ( std::vector< int > &  ) const
private

Fills the vector with the surfaces.

◆ getBoundingBox()

virtual void Mantid::Geometry::Rule::getBoundingBox ( double &  xmax,
double &  ymax,
double &  zmax,
double &  xmin,
double &  ymin,
double &  zmin 
)
pure virtual

◆ getKeyList()

int Mantid::Geometry::Rule::getKeyList ( std::vector< int > &  IList) const

Generate the key list given an insertion type object.

The list is a unique list.

Parameters
IList:: place to put keyList
Returns
number of object inserted

Definition at line 581 of file Rules.cpp.

References leaf().

Referenced by Eliminate().

◆ getParent()

Rule * Mantid::Geometry::Rule::getParent ( ) const

Returns the parent object.

Returns
Parent

Definition at line 466 of file Rules.cpp.

References Parent.

Referenced by checkParents(), makeCNF(), Mantid::Geometry::CSGObject::procComp(), removeComplementary(), and removeItem().

◆ isComplementary()

virtual int Mantid::Geometry::Rule::isComplementary ( ) const
inlinevirtual

Always returns false (0)

Reimplemented in Mantid::Geometry::Intersection, Mantid::Geometry::Union, Mantid::Geometry::CompObj, and Mantid::Geometry::CompGrp.

Definition at line 82 of file Rules.h.

◆ isValid() [1/2]

virtual bool Mantid::Geometry::Rule::isValid ( const Kernel::V3D ) const
pure virtual

◆ isValid() [2/2]

virtual bool Mantid::Geometry::Rule::isValid ( const std::map< int, int > &  ) const
pure virtual

◆ leaf()

virtual Rule * Mantid::Geometry::Rule::leaf ( const int  = 0) const
inlinevirtual

◆ makeCNF()

int Mantid::Geometry::Rule::makeCNF ( std::unique_ptr< Rule > &  TopRule)
static

Make Rule into a CNF format.

Static Function::

Function to make the tree into CNF (conditional normal form)

Parameters
TopRule:: Rule to simplify.

We do not use *this :: The reason is that we need to change the toprule type e.g. from an intersection to a union. Since the type of a class can't be changed it is necessary to have a static function, so that the place that TopRule points is changable

Return values
0on failure
1on success

Definition at line 264 of file Rules.cpp.

References clone(), count, findLeaf(), getParent(), leaf(), setLeaf(), and type().

◆ makeCNFcopy()

int Mantid::Geometry::Rule::makeCNFcopy ( std::unique_ptr< Rule > &  TopRule)
static

Make Rule into a CNF format (slow)

Static Function::

Function to make the tree into CNF (conditional normal form)

Parameters
TopRule:: Rule to simplify.

We do not use *this :: The reason is that we need to change the toprule type eg from an intersection to a union. Since the type of a class can't be changed it is necessary to have a static function, so that the place that TopRule points is changable

Returns
number of changes

Definition at line 135 of file Rules.cpp.

References clone(), count, Mantid::DTriple< F, S, T >::first, leaf(), Mantid::DTriple< F, S, T >::second, Mantid::DTriple< F, S, T >::third, and type().

◆ makeFullDNF()

static int Mantid::Geometry::Rule::makeFullDNF ( std::unique_ptr< Rule > &  )
static

Make Rule into a full DNF format.

◆ makeParents()

void Mantid::Geometry::Rule::makeParents ( )

This is initialisation code that populates all the parents in the rule tree.

Definition at line 475 of file Rules.cpp.

References leaf(), and setParent().

◆ operator=()

Rule & Mantid::Geometry::Rule::operator= ( const Rule )
protected

Assignment operator= does not set parent as Rules are cloned.

Returns
*this

Definition at line 446 of file Rules.cpp.

Referenced by Mantid::Geometry::BoolValue::operator=(), Mantid::Geometry::CompGrp::operator=(), Mantid::Geometry::Intersection::operator=(), and Mantid::Geometry::Union::operator=().

◆ removeComplementary()

int Mantid::Geometry::Rule::removeComplementary ( std::unique_ptr< Rule > &  TopRule)
static

NOT WORKING.

Given a rule tree remove any parts that are (-A B C D A) -> (B C D) and (A B C D A ) -> (A B C D) Code is borrowed from makeCNF.

See comments within that for a better howto. Currently it passes the line down

Return values
1:: some simplification
0:: no simplification

Definition at line 58 of file Rules.cpp.

References commonType(), findLeaf(), Mantid::DTriple< F, S, T >::first, getParent(), leaf(), setLeaf(), simplify(), and Mantid::DTriple< F, S, T >::third.

◆ removeItem()

int Mantid::Geometry::Rule::removeItem ( std::unique_ptr< Rule > &  TRule,
const int  SurfN 
)
static

Given an item as a surface name, remove the surface from the Rule tree.

  • If the found leaf is on a
    Parameters
    TRule:: Top rule to down search
    SurfN:: Surface key number to remove
    Returns
    Number of instances removed

Not the top level

New Top rule

Definition at line 376 of file Rules.cpp.

References clone(), findKey(), getParent(), leaf(), setLeaf(), and setParent().

Referenced by Mantid::Geometry::CSGObject::removeSurface().

◆ setLeaf()

virtual void Mantid::Geometry::Rule::setLeaf ( std::unique_ptr< Rule ,
const int  = 0 
)
pure virtual

◆ setLeaves()

virtual void Mantid::Geometry::Rule::setLeaves ( std::unique_ptr< Rule ,
std::unique_ptr< Rule  
)
pure virtual

◆ setParent()

void Mantid::Geometry::Rule::setParent ( Rule A)

Sets the parent object (not check for A==this)

Parameters
A:: Partent Object Ptr

Definition at line 457 of file Rules.cpp.

References Parent.

Referenced by makeParents(), and removeItem().

◆ simplify()

virtual int Mantid::Geometry::Rule::simplify ( )
pure virtual

◆ substituteSurf()

int Mantid::Geometry::Rule::substituteSurf ( const int  SurfN,
const int  newSurfN,
const std::shared_ptr< Surface > &  SPtr 
)

Substitues a surface item if within a rule.

Parameters
SurfN:: Number number to change
newSurfN:: New surface number (if -ve then the key is reversed)
SPtr:: New surface Pointer
Returns
number of substitutions

Definition at line 560 of file Rules.cpp.

References findKey(), and Mantid::Geometry::SurfPoint::setKeyN().

◆ type()

virtual int Mantid::Geometry::Rule::type ( ) const
inlinevirtual

Member Data Documentation

◆ Parent

Rule* Mantid::Geometry::Rule::Parent
private

Parent object (for tree)

Definition at line 35 of file Rules.h.

Referenced by getParent(), and setParent().


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