33class MANTID_GEOMETRY_DLL
Rule {
38 static int addToKey(std::vector<int> &AV,
const int passN = -1);
46 static int makeCNFcopy(std::unique_ptr<Rule> &);
48 static int makeCNF(std::unique_ptr<Rule> &);
49 static int removeComplementary(std::unique_ptr<Rule> &);
50 static int removeItem(std::unique_ptr<Rule> &TRule,
const int SurfN);
54 std::unique_ptr<Rule>
clone()
const {
return std::unique_ptr<Rule>(doClone()); }
56 virtual std::string
className()
const {
return "Rule"; }
59 virtual Rule *
leaf(
const int = 0)
const {
return nullptr; }
60 void setParent(
Rule *);
61 Rule *getParent()
const;
63 int checkParents()
const;
64 int getKeyList(std::vector<int> &)
const;
65 int commonType()
const;
68 std::unique_ptr<Rule>) = 0;
69 virtual void setLeaf(std::unique_ptr<Rule>,
73 virtual int type()
const {
return 0; }
78 virtual bool isValid(
const std::map<int, int> &)
const = 0;
85 int substituteSurf(
const int SurfN,
const int newSurfN,
const std::shared_ptr<Surface> &SPtr);
92 virtual void getBoundingBox(
double &xmax,
double &ymax,
double &zmax,
double &xmin,
double &ymin,
double &zmin) = 0;
93#ifdef ENABLE_OPENCASCADE
94 virtual TopoDS_Shape analyze() = 0;
112 std::unique_ptr<Rule>
A;
113 std::unique_ptr<Rule>
B;
121 explicit Intersection(std::unique_ptr<Rule>, std::unique_ptr<Rule>);
122 explicit Intersection(
Rule *, std::unique_ptr<Rule>, std::unique_ptr<Rule>);
123 std::unique_ptr<Intersection> clone()
const;
124 std::string
className()
const override {
return "Intersection"; }
126 Rule *
leaf(
const int ipt = 0)
const override {
return ipt ? B.get() : A.get(); }
127 void setLeaves(std::unique_ptr<Rule>,
128 std::unique_ptr<Rule>)
override;
129 void setLeaf(std::unique_ptr<Rule> nR,
130 const int side = 0)
override;
131 int findLeaf(
const Rule *)
const override;
132 Rule *findKey(
const int KeyN)
override;
133 int isComplementary()
const override;
135 int type()
const override {
return 1; }
136 std::string display()
const override;
137 std::string displayAddress()
const override;
140 bool isValid(
const std::map<int, int> &)
const override;
141 int simplify()
override;
142 void getBoundingBox(
double &xmax,
double &ymax,
double &zmax,
double &xmin,
double &ymin,
143 double &zmin)
override;
144#ifdef ENABLE_OPENCASCADE
145 TopoDS_Shape analyze()
override;
163 std::unique_ptr<Rule>
A;
164 std::unique_ptr<Rule>
B;
165 Union *doClone()
const override;
173 explicit Union(std::unique_ptr<Rule>, std::unique_ptr<Rule>);
174 explicit Union(
Rule *, std::unique_ptr<Rule>, std::unique_ptr<Rule>);
176 std::unique_ptr<Union> clone()
const;
177 std::string
className()
const override {
return "Union"; }
179 Rule *
leaf(
const int ipt = 0)
const override {
return ipt ? B.get() : A.get(); }
180 void setLeaves(std::unique_ptr<Rule>,
181 std::unique_ptr<Rule>)
override;
182 void setLeaf(std::unique_ptr<Rule>,
const int side = 0)
override;
183 int findLeaf(
const Rule *)
const override;
184 Rule *findKey(
const int KeyN)
override;
186 int isComplementary()
const override;
187 int type()
const override {
return -1; }
190 bool isValid(
const std::map<int, int> &)
const override;
191 std::string display()
const override;
192 std::string displayAddress()
const override;
193 int simplify()
override;
194 void getBoundingBox(
double &xmax,
double &ymax,
double &zmax,
double &xmin,
double &ymin,
195 double &zmin)
override;
196#ifdef ENABLE_OPENCASCADE
197 TopoDS_Shape analyze()
override;
221 std::string
className()
const override {
return "SurfPoint"; }
222 std::unique_ptr<SurfPoint> clone()
const;
224 Rule *
leaf(
const int = 0)
const override {
return nullptr; }
225 void setLeaves(std::unique_ptr<Rule>, std::unique_ptr<Rule>)
override;
226 void setLeaf(std::unique_ptr<Rule>,
const int = 0)
override;
227 int findLeaf(
const Rule *)
const override;
228 Rule *findKey(
const int KeyNum)
override;
230 int type()
const override {
return 0; }
232 void setKeyN(
const int Ky);
233 void setKey(
const std::shared_ptr<Surface> &Spoint);
235 bool isValid(
const std::map<int, int> &)
const override;
238 int simplify()
override;
241 std::string display()
const override;
242 std::string displayAddress()
const override;
243 void getBoundingBox(
double &xmax,
double &ymax,
double &zmax,
double &xmin,
double &ymin,
244 double &zmin)
override;
245#ifdef ENABLE_OPENCASCADE
246 TopoDS_Shape analyze()
override;
266 CompObj *doClone()
const override;
274 std::unique_ptr<CompObj> clone()
const;
275 std::string
className()
const override {
return "CompObj"; }
277 void setLeaves(std::unique_ptr<Rule>, std::unique_ptr<Rule>)
override;
278 void setLeaf(std::unique_ptr<Rule>,
const int = 0)
override;
279 int findLeaf(
const Rule *)
const override;
280 Rule *findKey(
const int i)
override;
282 int type()
const override {
return 0; }
285 void setObjN(
const int Ky);
288 bool isValid(
const std::map<int, int> &)
const override;
291 int simplify()
override;
294 std::string display()
const override;
295 std::string displayAddress()
const override;
296 void getBoundingBox(
double &xmax,
double &ymax,
double &zmax,
double &xmin,
double &ymin,
297 double &zmin)
override;
298#ifdef ENABLE_OPENCASCADE
299 TopoDS_Shape analyze()
override;
317 std::unique_ptr<Rule>
A;
318 CompGrp *doClone()
const override;
327 std::unique_ptr<CompGrp> clone()
const;
328 std::string
className()
const override {
return "CompGrp"; }
330 Rule *
leaf(
const int)
const override {
return A.get(); }
331 void setLeaves(std::unique_ptr<Rule>, std::unique_ptr<Rule>)
override;
332 void setLeaf(std::unique_ptr<Rule> nR,
const int side = 0)
override;
333 int findLeaf(
const Rule *)
const override;
334 Rule *findKey(
const int i)
override;
336 int type()
const override {
return 0; }
340 bool isValid(
const std::map<int, int> &)
const override;
341 int simplify()
override;
343 std::string display()
const override;
344 std::string displayAddress()
const override;
345 void getBoundingBox(
double &xmax,
double &ymax,
double &zmax,
double &xmin,
double &ymin,
346 double &zmin)
override;
347#ifdef ENABLE_OPENCASCADE
348 TopoDS_Shape analyze()
override;
374 std::unique_ptr<BoolValue> clone()
const;
375 std::string
className()
const override {
return "BoolValue"; }
377 Rule *
leaf(
const int = 0)
const override {
return nullptr; }
378 void setLeaves(std::unique_ptr<Rule>, std::unique_ptr<Rule>)
override;
379 void setLeaf(std::unique_ptr<Rule>,
const int = 0)
override;
380 int findLeaf(
const Rule *)
const override;
383 int type()
const override {
return 0; }
387 if (val == 0 || val == 1 || val == -1)
391 bool isValid(
const std::map<int, int> &)
const override;
392 int simplify()
override;
394 std::string display()
const override;
395 std::string displayAddress()
const override;
396 void getBoundingBox(
double &xmax,
double &ymax,
double &zmax,
double &xmin,
double &ymin,
397 double &zmin)
override;
398#ifdef ENABLE_OPENCASCADE
399 TopoDS_Shape analyze()
override;
void removeItem(WorkspaceGroup &self, const std::string &name)
BoolValue(const BoolValue &)=default
std::string className() const override
Returns class name as string.
void setStatus(int val)
< write val into status, if in valid range
Rule * findKey(const int) override
Abstract key find.
int status
Three values 0 False : 1 True : -1 doesn't matter.
int type() const override
Null rule.
Rule * leaf(const int=0) const override
No leaves.
Constructive Solid Geometry object.
int type() const override
Is it a branched object.
std::string className() const override
Returns class name as string.
Rule * leaf(const int) const override
selects leaf component
std::unique_ptr< Rule > A
The rule.
int isComplementary() const override
Always returns true (1)
int type() const override
Is it a branched object.
std::string className() const override
Returns class name as string.
CSGObject * getObj() const
Get Object Ptr.
CSGObject * key
Object Pointer.
CompObj & operator=(const CompObj &)=default
int isComplementary() const override
Always returns true (1)
int getObjN() const
Get object number of component.
CompObj(const CompObj &)=default
Combines two Rule objects in an intersection.
int type() const override
Null rule.
std::string className() const override
Returns class name as string.
Rule * leaf(const int ipt=0) const override
selects leaf component
std::unique_ptr< Rule > A
Rule 1.
std::unique_ptr< Rule > B
Rule 2.
Object generation rule tree.
virtual Rule * leaf(const int=0) const
No leaf for a base rule.
std::unique_ptr< Rule > clone() const
virtual int isComplementary() const
Always returns false (0)
virtual Rule * doClone() const =0
abstract clone object
virtual std::string className() const
Returns class name as string.
virtual Rule * findKey(const int)=0
Abstract key find.
int getBaseKeys(std::vector< int > &) const
Fills the vector with the surfaces.
virtual int findLeaf(const Rule *) const =0
Abstract find.
virtual void setLeaf(std::unique_ptr< Rule >, const int=0)=0
Abstract set.
virtual bool isValid(const std::map< int, int > &) const =0
Abstract Validity based on surface true/false map.
virtual std::string displayAddress() const =0
Abstract Display Address.
virtual void setLeaves(std::unique_ptr< Rule >, std::unique_ptr< Rule >)=0
abstract set leaves
static int makeFullDNF(std::unique_ptr< Rule > &)
Make Rule into a full DNF format.
Rule * Parent
Parent object (for tree)
virtual bool isValid(const Kernel::V3D &) const =0
Abstract: The point is within the object.
virtual std::string display() const =0
Abstract Display.
virtual int simplify()=0
Abstract: Can the rule be simplified.
virtual void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin)=0
Abstract getBoundingBox.
virtual int type() const
Null rule.
std::shared_ptr< Surface > m_key
Actual Surface Base Object.
int sign
+/- in Object unit
std::string className() const override
Returns class name as string.
int keyN
Key Number (identifer)
int getKeyN() const
Get Key.
int getSign() const
Get Sign.
Rule * leaf(const int=0) const override
No Leaves.
Surface * getKey() const
Get Surface Ptr.
int type() const override
Effective name.
Holds a basic quadratic surface.
Combines two Rule objects in an union.
std::unique_ptr< Rule > A
Leaf rule A.
Rule * leaf(const int ipt=0) const override
Select a leaf component.
std::string className() const override
Returns class name as string.
std::unique_ptr< Rule > B
Leaf rule B.
int type() const override
effective name
Helper class which provides the Collimation Length for SANS instruments.