Mantid
Loading...
Searching...
No Matches
RuleItems.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#include <algorithm>
8#include <cfloat>
9#include <cmath>
10#include <complex>
11#include <fstream>
12#include <iterator>
13#include <list>
14#include <map>
15#include <sstream>
16#include <stack>
17#include <string>
18#include <vector>
19
21
28#include "MantidKernel/Matrix.h"
29#include "MantidKernel/V3D.h"
30
31#ifdef ENABLE_OPENCASCADE
32// Opencascade defines _USE_MATH_DEFINES without checking whether it is already
33// used.
34// Undefine it here before we include the headers to avoid a warning
35#ifdef _MSC_VER
36#undef _USE_MATH_DEFINES
37#ifdef M_SQRT1_2
38#undef M_SQRT1_2
39#endif
40#endif
41
43GNU_DIAG_OFF("conversion")
44GNU_DIAG_OFF("cast-qual")
45#include <BRepAlgoAPI_Common.hxx>
46#include <BRepAlgoAPI_Fuse.hxx>
47#include <BRepPrimAPI_MakeBox.hxx>
48#include <TopoDS_Shape.hxx>
49GNU_DIAG_ON("conversion")
50GNU_DIAG_ON("cast-qual")
51#endif
52
53namespace Mantid::Geometry {
54using Kernel::V3D;
55
56Intersection::Intersection(std::unique_ptr<Rule> Ix, std::unique_ptr<Rule> Iy)
57 : Rule(), A(std::move(Ix)), B(std::move(Iy))
65{
66 if (A)
67 A->setParent(this);
68 if (B)
69 B->setParent(this);
70}
71
72Intersection::Intersection(Rule *Parent, std::unique_ptr<Rule> Ix, std::unique_ptr<Rule> Iy)
73 : Rule(Parent), A(std::move(Ix)), B(std::move(Iy))
81{
82 if (A)
83 A->setParent(this);
84 if (B)
85 B->setParent(this);
86}
87
89 : Rule(), A(), B()
95{
96 if (Iother.A) {
97 A = Iother.A->clone();
98 A->setParent(this);
99 }
100 if (Iother.B) {
101 B = Iother.B->clone();
102 B->setParent(this);
103 }
104}
105
113{
114 if (this != &Iother) {
115 Rule::operator=(Iother);
116 // first create new copy all fresh
117 if (Iother.A) {
118 A = Iother.A->clone();
119 A->setParent(this);
120 }
121 if (Iother.B) {
122 B = Iother.B->clone();
123 B->setParent(this);
124 }
125 }
126 return *this;
127}
128
134{
135 return new Intersection(*this);
136}
137
138std::unique_ptr<Intersection> Intersection::clone() const
143{
144 return std::unique_ptr<Intersection>(doClone());
145}
146
155{
156 if (A && A->isComplementary())
157 return 1;
158 if (B && B->isComplementary())
159 return -1;
160
161 return 0;
162}
163
164void Intersection::setLeaves(std::unique_ptr<Rule> aR, std::unique_ptr<Rule> bR)
171{
172 A = std::move(aR);
173 B = std::move(bR);
174 if (A)
175 A->setParent(this);
176 if (B)
177 B->setParent(this);
178}
179
180void Intersection::setLeaf(std::unique_ptr<Rule> nR, const int side)
189{
190 if (side) {
191 B = std::move(nR);
192 if (B)
193 B->setParent(this);
194 } else {
195 A = std::move(nR);
196 if (A)
197 A->setParent(this);
198 }
199}
200
201int Intersection::findLeaf(const Rule *R) const
209{
210 if (A.get() == R)
211 return 0;
212 if (B.get() == R)
213 return 1;
214 return -1;
215}
216
224{
225 Rule *PtrOut = (A) ? A->findKey(KeyN) : nullptr;
226 if (PtrOut)
227 return PtrOut;
228 return (B) ? B->findKey(KeyN) : nullptr;
229}
230
231std::string Intersection::display() const
236{
237 std::string out;
238 if (!A || !B)
239 throw std::runtime_error("Intersection::display incomplete type");
240 if (A->type() == -1)
241 out = "(" + A->display() + ")";
242 else
243 out = A->display();
244
245 out += " ";
246
247 if (B->type() == -1)
248 out += "(" + B->display() + ")";
249 else
250 out += B->display();
251 return out;
252}
253
261{
262 std::stringstream cx;
263 cx << " [ " << this;
264 if (A && B)
265 cx << " ] (" + A->displayAddress() + " " + B->displayAddress() + ") ";
266 else if (A)
267 cx << " ] (" + A->displayAddress() + " 0x0 ) ";
268 else if (B)
269 cx << " ] ( 0x0 " + B->displayAddress() + ") ";
270 else
271 cx << " ] ( 0x0 0x0 ) ";
272 return cx.str();
273}
274
275bool Intersection::isValid(const Kernel::V3D &Vec) const
282{
283 if (A && B) {
284 return (A->isValid(Vec) && B->isValid(Vec));
285 }
286 return false;
287}
288
289bool Intersection::isValid(const std::map<int, int> &MX) const
297{
298 if (!A || !B)
299 return false;
300 return A->isValid(MX) && B->isValid(MX);
301}
302
314{
315 return 0;
316}
317
327void Intersection::getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) {
328 double Axmax, Aymax, Azmax, Axmin, Aymin, Azmin;
329 double Bxmax, Bymax, Bzmax, Bxmin, Bymin, Bzmin;
330 Axmax = Bxmax = xmax;
331 Aymax = Bymax = ymax;
332 Azmax = Bzmax = zmax;
333 Axmin = Bxmin = xmin;
334 Aymin = Bymin = ymin;
335 Azmin = Bzmin = zmin;
336 A->getBoundingBox(Axmax, Aymax, Azmax, Axmin, Aymin, Azmin);
337 B->getBoundingBox(Bxmax, Bymax, Bzmax, Bxmin, Bymin, Bzmin);
338 xmax = (Axmax < Bxmax) ? Axmax : Bxmax;
339 xmin = (Axmin > Bxmin) ? Axmin : Bxmin;
340 ymax = (Aymax < Bymax) ? Aymax : Bymax;
341 ymin = (Aymin > Bymin) ? Aymin : Bymin;
342 zmax = (Azmax < Bzmax) ? Azmax : Bzmax;
343 zmin = (Azmin > Bzmin) ? Azmin : Bzmin;
344}
345
346#ifdef ENABLE_OPENCASCADE
351TopoDS_Shape Intersection::analyze() {
352 TopoDS_Shape left = A->analyze();
353 TopoDS_Shape right = B->analyze();
354 BRepAlgoAPI_Common comm(left, right);
355 return comm.Shape();
356}
357#endif
358
359// -------------------------------------------------------------
360// UNION
361//---------------------------------------------------------------
362
363Union::Union(Rule *Parent, std::unique_ptr<Rule> Ix, std::unique_ptr<Rule> Iy)
364 : Rule(Parent), A(std::move(Ix)), B(std::move(Iy))
373{
374 if (A)
375 A->setParent(this);
376 if (B)
377 B->setParent(this);
378}
379
380Union::Union(std::unique_ptr<Rule> Ix, std::unique_ptr<Rule> Iy)
381 : Rule(), A(std::move(Ix)), B(std::move(Iy))
389{
390 if (A)
391 A->setParent(this);
392 if (B)
393 B->setParent(this);
394}
395
396Union::Union(const Union &Iother)
397 : Rule(Iother), A(), B()
403{
404 if (Iother.A) {
405 A = Iother.A->clone();
406 A->setParent(this);
407 }
408 if (Iother.B) {
409 B = Iother.B->clone();
410 B->setParent(this);
411 }
412}
413
421{
422 if (this != &Iother) {
423 Rule::operator=(Iother);
424 // first create new copy all fresh
425 if (Iother.A) {
426 A = Iother.A->clone();
427 A->setParent(this);
428 }
429 if (Iother.B) {
430 B = Iother.B->clone();
431 B->setParent(this);
432 }
433 }
434 return *this;
435}
436
442{
443 return new Union(*this);
444}
445
446std::unique_ptr<Union> Union::clone() const
451{
452 return std::unique_ptr<Union>(doClone());
453}
454
455void Union::setLeaf(std::unique_ptr<Rule> nR, const int side)
464{
465 if (side) {
466 B = std::move(nR);
467 if (B)
468 B->setParent(this);
469 } else {
470 A = std::move(nR);
471 if (A)
472 A->setParent(this);
473 }
474 return;
475}
476
477void Union::setLeaves(std::unique_ptr<Rule> aR, std::unique_ptr<Rule> bR)
484{
485 A = std::move(aR);
486 B = std::move(bR);
487 if (A)
488 A->setParent(this);
489 if (B)
490 B->setParent(this);
491}
492
493int Union::findLeaf(const Rule *R) const
501{
502 if (A.get() == R)
503 return 0;
504 if (B.get() == R)
505 return 1;
506 return -1;
507}
508
509Rule *Union::findKey(const int KeyN)
516{
517
518 Rule *PtrOut = (A) ? A->findKey(KeyN) : nullptr;
519 if (PtrOut)
520 return PtrOut;
521 return (B) ? B->findKey(KeyN) : nullptr;
522}
523
532{
533 if (A && A->isComplementary())
534 return 1;
535 if (B && B->isComplementary())
536 return -1;
537
538 return 0;
539}
540
552{
553 return 0;
554}
555
556bool Union::isValid(const Kernel::V3D &Vec) const
563{
564 return (A && A->isValid(Vec)) || (B && B->isValid(Vec));
565}
566
567bool Union::isValid(const std::map<int, int> &MX) const
575{
576 return (A && A->isValid(MX)) || (B && B->isValid(MX));
577}
578
579std::string Union::display() const
586{
587 std::string out;
588 if (!A || !B)
589 throw std::runtime_error("Union::display incomplete type");
590 if (A->type() == 1)
591 out = "(" + A->display() + ")";
592 else
593 out = A->display();
594
595 out += " : ";
596
597 if (B->type() == 1)
598 out += "(" + B->display() + ")";
599 else
600 out += B->display();
601
602 return out;
603}
604
605std::string Union::displayAddress() const
611{
612 std::stringstream cx;
613 cx << " [ " << this;
614
615 if (A && B)
616 cx << " ] (" + A->displayAddress() + " : " + B->displayAddress() + ") ";
617 else if (A)
618 cx << " ] (" + A->displayAddress() + " : 0x0 ) ";
619 else if (B)
620 cx << " ] ( 0x0 : " + B->displayAddress() + ") ";
621 else
622 cx << " ] ( 0x0 : 0x0 ) ";
623 return cx.str();
624}
625
635void Union::getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) {
636 double Axmax, Aymax, Azmax, Axmin, Aymin, Azmin;
637 double Bxmax, Bymax, Bzmax, Bxmin, Bymin, Bzmin;
638 Axmax = Bxmax = xmax;
639 Aymax = Bymax = ymax;
640 Azmax = Bzmax = zmax;
641 Axmin = Bxmin = xmin;
642 Aymin = Bymin = ymin;
643 Azmin = Bzmin = zmin;
644 A->getBoundingBox(Axmax, Aymax, Azmax, Axmin, Aymin, Azmin);
645 B->getBoundingBox(Bxmax, Bymax, Bzmax, Bxmin, Bymin, Bzmin);
646 xmax = (Axmax > Bxmax) ? Axmax : Bxmax;
647 xmin = (Axmin < Bxmin) ? Axmin : Bxmin;
648 ymax = (Aymax > Bymax) ? Aymax : Bymax;
649 ymin = (Aymin < Bymin) ? Aymin : Bymin;
650 zmax = (Azmax > Bzmax) ? Azmax : Bzmax;
651 zmin = (Azmin < Bzmin) ? Azmin : Bzmin;
652}
653
654#ifdef ENABLE_OPENCASCADE
655TopoDS_Shape Union::analyze() {
656 TopoDS_Shape left = A->analyze();
657 TopoDS_Shape right = B->analyze();
658 BRepAlgoAPI_Fuse fuse(left, right);
659 return fuse.Shape();
660}
661#endif
662
663// -------------------------------------------------------------
664// SURF KEYS
665//---------------------------------------------------------------
666
668 : Rule(), m_key(), keyN(0), sign(1)
672{}
673
679{
680 return new SurfPoint(*this);
681}
682
683std::unique_ptr<SurfPoint> SurfPoint::clone() const
688{
689 return std::unique_ptr<SurfPoint>(doClone());
690}
691
692void SurfPoint::setLeaf(std::unique_ptr<Rule> nR, const int /*unused*/)
699{
700 // std::cerr<<"Calling SurfPoint setLeaf"<<'\n';
701
702 auto *newX = dynamic_cast<SurfPoint *>(nR.get());
703 if (newX)
704 *this = *newX;
705}
706
707void SurfPoint::setLeaves(std::unique_ptr<Rule> aR, std::unique_ptr<Rule> /*unused*/)
713{
714 // std::cerr<<"Calling SurfPoint setLeaf"<<'\n';
715 auto *newX = dynamic_cast<SurfPoint *>(aR.get());
716 if (newX)
717 *this = *newX;
718}
719
720int SurfPoint::findLeaf(const Rule *A) const
727{
728 return (this == A) ? 0 : -1;
729}
730
731Rule *SurfPoint::findKey(const int KeyNum)
738{
739 return (KeyNum == keyN) ? this : nullptr;
740}
741
742void SurfPoint::setKeyN(const int Ky)
747{
748 sign = (Ky < 0) ? -1 : 1;
749 keyN = sign * Ky;
750}
751
752void SurfPoint::setKey(const std::shared_ptr<Surface> &Spoint)
757{
758 m_key = Spoint;
759}
760
767{
768 return 0;
769}
770
771bool SurfPoint::isValid(const Kernel::V3D &Pt) const
779{
780 if (m_key) {
781 return (m_key->side(Pt) * sign) >= 0;
782 }
783 return false;
784}
785
786bool SurfPoint::isValid(const std::map<int, int> &MX) const
793{
794 auto lx = MX.find(keyN);
795 if (lx == MX.end())
796 return false;
797 const int rtype = (lx->second) ? 1 : -1;
798 return (rtype * sign) >= 0;
799}
800
801std::string SurfPoint::display() const
807{
808 std::stringstream cx;
809 cx << sign * keyN;
810 return cx.str();
811}
812
813std::string SurfPoint::displayAddress() const
819{
820 std::stringstream cx;
821 cx << this;
822 return cx.str();
823}
824
834void SurfPoint::getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) {
835 if (this->sign < 1) // If the object sign is positive then include
836 m_key->getBoundingBox(xmax, ymax, zmax, xmin, ymin, zmin);
837 else { // if the object sign is negative then get the complement
838 std::vector<V3D> listOfPoints;
839 double gXmax, gYmax, gZmax, gXmin, gYmin, gZmin;
840 gXmax = xmax;
841 gYmax = ymax;
842 gZmax = zmax;
843 gXmin = xmin;
844 gYmin = ymin;
845 gZmin = zmin;
846 m_key->getBoundingBox(gXmax, gYmax, gZmax, gXmin, gYmin, gZmin);
847 if (!((xmax <= gXmax && xmax >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
848 listOfPoints.emplace_back(xmax, ymax, zmax);
849 if (!((xmin <= gXmax && xmin >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
850 listOfPoints.emplace_back(xmin, ymax, zmax);
851 if (!((xmin <= gXmax && xmin >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
852 listOfPoints.emplace_back(xmin, ymax, zmin);
853 if (!((xmax <= gXmax && xmax >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
854 listOfPoints.emplace_back(xmax, ymax, zmin);
855 if (!((xmin <= gXmax && xmin >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
856 listOfPoints.emplace_back(xmin, ymin, zmin);
857 if (!((xmax <= gXmax && xmax >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
858 listOfPoints.emplace_back(xmax, ymin, zmin);
859 if (!((xmax <= gXmax && xmax >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
860 listOfPoints.emplace_back(xmax, ymin, zmax);
861 if (!((xmin <= gXmax && xmin >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
862 listOfPoints.emplace_back(xmin, ymin, zmax);
863
864 // group box inside input box
865 if (((gXmax <= xmax && gXmax >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
866 (gXmax != xmax || gYmax != ymax || gZmax != zmax))
867 listOfPoints.emplace_back(gXmax, gYmax, gZmax);
868 if (((gXmin <= xmax && gXmin >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
869 (gXmin != xmin || gYmax != ymax || gZmax != zmax))
870 listOfPoints.emplace_back(gXmin, gYmax, gZmax);
871 if (((gXmin <= xmax && gXmin >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
872 (gXmin != xmin || gYmax != ymax || gZmin != zmin))
873 listOfPoints.emplace_back(gXmin, gYmax, gZmin);
874 if (((gXmax <= xmax && gXmax >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
875 (gXmax != xmax || gYmax != ymax || gZmin != zmin))
876 listOfPoints.emplace_back(gXmax, gYmax, gZmin);
877 if (((gXmin <= xmax && gXmin >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
878 (gXmin != xmin || gYmin != ymin || gZmin != zmin))
879 listOfPoints.emplace_back(gXmin, gYmin, gZmin);
880 if (((gXmax <= xmax && gXmax >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
881 (gXmax != xmax || gYmin != ymin || gZmin != zmin))
882 listOfPoints.emplace_back(gXmax, gYmin, gZmin);
883 if (((gXmax <= xmax && gXmax >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
884 (gXmax != xmax || gYmin != ymin || gZmax != zmax))
885 listOfPoints.emplace_back(gXmax, gYmin, gZmax);
886 if (((gXmin <= xmax && gXmin >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
887 (gXmin != xmin || gYmin != ymin || gZmax != zmax))
888 listOfPoints.emplace_back(gXmin, gYmin, gZmax);
889
890 if (!listOfPoints.empty()) {
891 xmin = ymin = zmin = DBL_MAX;
892 xmax = ymax = zmax = -DBL_MAX;
893 for (std::vector<V3D>::const_iterator it = listOfPoints.begin(); it != listOfPoints.end(); ++it) {
894 // std::cout<<(*it)<<'\n';
895 if ((*it)[0] < xmin)
896 xmin = (*it)[0];
897 if ((*it)[1] < ymin)
898 ymin = (*it)[1];
899 if ((*it)[2] < zmin)
900 zmin = (*it)[2];
901 if ((*it)[0] > xmax)
902 xmax = (*it)[0];
903 if ((*it)[1] > ymax)
904 ymax = (*it)[1];
905 if ((*it)[2] > zmax)
906 zmax = (*it)[2];
907 }
908 }
909 }
910}
911
912#ifdef ENABLE_OPENCASCADE
913TopoDS_Shape SurfPoint::analyze() {
914 // Check for individual type of surfaces
915 TopoDS_Shape Result = m_key->createShape();
916 if (sign > 0)
917 Result.Complement();
918 if (m_key->className() == "Plane") {
919 // build a box
920 gp_Pnt p(-1000.0, -1000.0, -1000.0);
921 TopoDS_Shape world = BRepPrimAPI_MakeBox(p, 2000.0, 2000.0, 2000.0).Shape();
922 return BRepAlgoAPI_Common(world, Result);
923 }
924 return Result;
925}
926#endif
927//----------------------------------------
928// COMPOBJ
929//----------------------------------------
930
932 : Rule(), objN(0), key(nullptr)
936{}
937
943{
944 return new CompObj(*this);
945}
946
947std::unique_ptr<CompObj> CompObj::clone() const
952{
953 return std::unique_ptr<CompObj>(doClone());
954}
955
956void CompObj::setObjN(const int Ky)
961{
962 objN = Ky;
963}
964
970{
971 key = val;
972}
973
974void CompObj::setLeaf(std::unique_ptr<Rule> aR, const int /*unused*/)
981{
982 auto *newX = dynamic_cast<CompObj *>(aR.get());
983 // Make a copy
984 if (newX)
985 *this = *newX;
986}
987
988void CompObj::setLeaves(std::unique_ptr<Rule> aR, std::unique_ptr<Rule> oR)
995{
996 (void)oR; // Avoid compiler warning
997
998 auto *newX = dynamic_cast<CompObj *>(aR.get());
999 if (newX)
1000 *this = *newX;
1001}
1002
1011{
1012 (void)i; // Avoid compiler warning
1013 return nullptr;
1014}
1015
1016int CompObj::findLeaf(const Rule *A) const
1022{
1023 return (this == A) ? 0 : -1;
1024}
1025
1026bool CompObj::isValid(const Kernel::V3D &Pt) const
1035{
1036 if (key)
1037 return !(key->isValid(Pt));
1038 return true;
1039}
1040
1041bool CompObj::isValid(const std::map<int, int> &SMap) const
1047{
1048 return (key) ? !(key->isValid(SMap)) : true;
1049}
1050
1057{
1058 return 0;
1059}
1060
1061std::string CompObj::display() const
1066{
1067 std::stringstream cx;
1068 cx << "#" << objN;
1069 return cx.str();
1070}
1071
1072std::string CompObj::displayAddress() const
1078{
1079 std::stringstream cx;
1080 cx << this;
1081 return cx.str();
1082}
1083
1093void CompObj::getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) {
1097 std::vector<V3D> listOfPoints;
1098 double gXmax, gYmax, gZmax, gXmin, gYmin, gZmin;
1099 gXmax = xmax;
1100 gYmax = ymax;
1101 gZmax = zmax;
1102 gXmin = xmin;
1103 gYmin = ymin;
1104 gZmin = zmin;
1105 key->getBoundingBox(gXmax, gYmax, gZmax, gXmin, gYmin, gZmin);
1106 if (!((xmax <= gXmax && xmax >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
1107 listOfPoints.emplace_back(xmax, ymax, zmax);
1108 if (!((xmin <= gXmax && xmin >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
1109 listOfPoints.emplace_back(xmin, ymax, zmax);
1110 if (!((xmin <= gXmax && xmin >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
1111 listOfPoints.emplace_back(xmin, ymax, zmin);
1112 if (!((xmax <= gXmax && xmax >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
1113 listOfPoints.emplace_back(xmax, ymax, zmin);
1114 if (!((xmin <= gXmax && xmin >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
1115 listOfPoints.emplace_back(xmin, ymin, zmin);
1116 if (!((xmax <= gXmax && xmax >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
1117 listOfPoints.emplace_back(xmax, ymin, zmin);
1118 if (!((xmax <= gXmax && xmax >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
1119 listOfPoints.emplace_back(xmax, ymin, zmax);
1120 if (!((xmin <= gXmax && xmin >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
1121 listOfPoints.emplace_back(xmin, ymin, zmax);
1122
1123 // object box inside input box
1124 if (((gXmax <= xmax && gXmax >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
1125 (gXmax != xmax || gYmax != ymax || gZmax != zmax))
1126 listOfPoints.emplace_back(gXmax, gYmax, gZmax);
1127 if (((gXmin <= xmax && gXmin >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
1128 (gXmin != xmin || gYmax != ymax || gZmax != zmax))
1129 listOfPoints.emplace_back(gXmin, gYmax, gZmax);
1130 if (((gXmin <= xmax && gXmin >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
1131 (gXmin != xmin || gYmax != ymax || gZmin != zmin))
1132 listOfPoints.emplace_back(gXmin, gYmax, gZmin);
1133 if (((gXmax <= xmax && gXmax >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
1134 (gXmax != xmax || gYmax != ymax || gZmin != zmin))
1135 listOfPoints.emplace_back(gXmax, gYmax, gZmin);
1136 if (((gXmin <= xmax && gXmin >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
1137 (gXmin != xmin || gYmin != ymin || gZmin != zmin))
1138 listOfPoints.emplace_back(gXmin, gYmin, gZmin);
1139 if (((gXmax <= xmax && gXmax >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
1140 (gXmax != xmax || gYmin != ymin || gZmin != zmin))
1141 listOfPoints.emplace_back(gXmax, gYmin, gZmin);
1142 if (((gXmax <= xmax && gXmax >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
1143 (gXmax != xmax || gYmin != ymin || gZmax != zmax))
1144 listOfPoints.emplace_back(gXmax, gYmin, gZmax);
1145 if (((gXmin <= xmax && gXmin >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
1146 (gXmin != xmin || gYmin != ymin || gZmax != zmax))
1147 listOfPoints.emplace_back(gXmin, gYmin, gZmax);
1148
1149 if (!listOfPoints.empty()) {
1150 xmin = ymin = zmin = DBL_MAX;
1151 xmax = ymax = zmax = -DBL_MAX;
1152 for (std::vector<V3D>::const_iterator it = listOfPoints.begin(); it != listOfPoints.end(); ++it) {
1153 // std::cout<<(*it)<<'\n';
1154 if ((*it)[0] < xmin)
1155 xmin = (*it)[0];
1156 if ((*it)[1] < ymin)
1157 ymin = (*it)[1];
1158 if ((*it)[2] < zmin)
1159 zmin = (*it)[2];
1160 if ((*it)[0] > xmax)
1161 xmax = (*it)[0];
1162 if ((*it)[1] > ymax)
1163 ymax = (*it)[1];
1164 if ((*it)[2] > zmax)
1165 zmax = (*it)[2];
1166 }
1167 }
1168}
1169
1170#ifdef ENABLE_OPENCASCADE
1171TopoDS_Shape CompObj::analyze() {
1172 TopoDS_Shape Result = const_cast<Rule *>(key->topRule())->analyze();
1173 Result.Complement();
1174 return Result;
1175}
1176#endif
1177// -----------------------------------------------
1178// BOOLVALUE
1179// -----------------------------------------------
1180
1182 : Rule(), status(-1)
1186{}
1187
1194{
1195 if (this != &A) {
1196 Rule::operator=(A);
1197 status = A.status;
1198 }
1199 return *this;
1200}
1201
1207{
1208 return new BoolValue(*this);
1209}
1210
1211std::unique_ptr<BoolValue> BoolValue::clone() const
1216{
1217 return std::unique_ptr<BoolValue>(doClone());
1218}
1219
1220void BoolValue::setLeaf(std::unique_ptr<Rule> aR, const int /*unused*/)
1228{
1229 // std::cerr<<"Calling BoolValue setLeaf"<<'\n';
1230 auto *newX = dynamic_cast<BoolValue *>(aR.get());
1231 if (newX)
1232 *this = *newX;
1233}
1234
1235void BoolValue::setLeaves(std::unique_ptr<Rule> aR, std::unique_ptr<Rule> oR)
1242{
1243 (void)oR; // Avoid compiler warning
1244 // std::cerr<<"Calling BoolValue setLeaves"<<'\n';
1245 auto *newX = dynamic_cast<BoolValue *>(aR.get());
1246 if (newX)
1247 *this = *newX;
1248}
1249
1250int BoolValue::findLeaf(const Rule *A) const { return (this == A) ? 0 : -1; }
1251
1252bool BoolValue::isValid(const Kernel::V3D &pt) const
1258{
1259 (void)pt; // Avoid compiler warning
1260 return status > 0;
1261}
1262
1263bool BoolValue::isValid(const std::map<int, int> &map) const
1269{
1270 (void)map; // Avoid compiler warning
1271 return status > 0;
1272}
1273
1279{
1280 return 0;
1281}
1282
1283std::string BoolValue::display() const
1289{
1290 switch (status) {
1291 case 1:
1292 return " True ";
1293 case 0:
1294 return " False ";
1295 }
1296 return " Unknown ";
1297}
1298
1299std::string BoolValue::displayAddress() const
1305{
1306 std::stringstream cx;
1307 cx << this;
1308 return cx.str();
1309}
1310
1320void BoolValue::getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) {
1321 // Returns what ever bounding box it gets
1322 (void)xmax; // Avoid compiler warning
1323 (void)ymax; // Avoid compiler warning
1324 (void)zmax; // Avoid compiler warning
1325 (void)xmin; // Avoid compiler warning
1326 (void)ymin; // Avoid compiler warning
1327 (void)zmin; // Avoid compiler warning
1328}
1329
1330//----------------------------------------
1331// COMPGRP
1332//----------------------------------------
1333
1334CompGrp::CompGrp(Rule *Parent, std::unique_ptr<Rule> Cx)
1335 : Rule(Parent), A(std::move(Cx))
1341{
1342 if (A)
1343 A->setParent(this);
1344}
1345
1347 : Rule(Cother), A()
1352{
1353 if (Cother.A) {
1354 A = std::unique_ptr<Rule>(Cother.A->clone());
1355 A->setParent(this);
1356 }
1357}
1358
1365{
1366 if (this != &Cother) {
1367 Rule::operator=(Cother);
1368 if (Cother.A) {
1369 A = std::unique_ptr<Rule>(Cother.A->clone());
1370 A->setParent(this);
1371 }
1372 }
1373 return *this;
1374}
1375
1381{
1382 return new CompGrp(*this);
1383}
1384
1385std::unique_ptr<CompGrp> CompGrp::clone() const
1390{
1391 return std::unique_ptr<CompGrp>(doClone());
1392}
1393
1394void CompGrp::setLeaf(std::unique_ptr<Rule> nR, const int side)
1401{
1402 (void)side; // Avoid compiler warning
1403 A = std::move(nR);
1404 if (A)
1405 A->setParent(this);
1406}
1407
1408void CompGrp::setLeaves(std::unique_ptr<Rule> aR, std::unique_ptr<Rule> oR)
1415{
1416 (void)oR; // Avoid compiler warning
1417 A = std::move(aR);
1418 if (A)
1419 A->setParent(this);
1420}
1421
1430{
1431 (void)i; // Avoid compiler warning
1432 return nullptr;
1433}
1434
1435int CompGrp::findLeaf(const Rule *R) const
1441{
1442 return (A.get() == R) ? 0 : -1;
1443}
1444
1445bool CompGrp::isValid(const Kernel::V3D &Pt) const
1455{
1456 // Note:: if isValid is true then return 0:
1457 if (A)
1458 return !(A->isValid(Pt));
1459 return true;
1460}
1461
1462bool CompGrp::isValid(const std::map<int, int> &SMap) const
1468{
1469 // Note:: if isValid is true then return 0:
1470 if (A)
1471 return !A->isValid(SMap);
1472 return true;
1473}
1474
1481{
1482 return 0;
1483}
1484
1485std::string CompGrp::display() const
1490{
1491 std::stringstream cx;
1492 if (A)
1493 cx << "#( " << A->display() << " )";
1494 return cx.str();
1495}
1496
1497std::string CompGrp::displayAddress() const
1503{
1504 std::stringstream cx;
1505 cx << "#( [" << this << "] ";
1506 if (A)
1507 cx << A->displayAddress();
1508 else
1509 cx << "0x0";
1510 cx << " ) ";
1511 return cx.str();
1512}
1513
1523void CompGrp::getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) {
1527 std::vector<V3D> listOfPoints;
1528 double gXmax, gYmax, gZmax, gXmin, gYmin, gZmin;
1529 gXmax = xmax;
1530 gYmax = ymax;
1531 gZmax = zmax;
1532 gXmin = xmin;
1533 gYmin = ymin;
1534 gZmin = zmin;
1535 A->getBoundingBox(gXmax, gYmax, gZmax, gXmin, gYmin, gZmin);
1536 if (!((xmax <= gXmax && xmax >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
1537 listOfPoints.emplace_back(xmax, ymax, zmax);
1538 if (!((xmin <= gXmax && xmin >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
1539 listOfPoints.emplace_back(xmin, ymax, zmax);
1540 if (!((xmin <= gXmax && xmin >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
1541 listOfPoints.emplace_back(xmin, ymax, zmin);
1542 if (!((xmax <= gXmax && xmax >= gXmin) && (ymax <= gYmax && ymax >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
1543 listOfPoints.emplace_back(xmax, ymax, zmin);
1544 if (!((xmin <= gXmax && xmin >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
1545 listOfPoints.emplace_back(xmin, ymin, zmin);
1546 if (!((xmax <= gXmax && xmax >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmin <= gZmax && zmin >= gZmin)))
1547 listOfPoints.emplace_back(xmax, ymin, zmin);
1548 if (!((xmax <= gXmax && xmax >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
1549 listOfPoints.emplace_back(xmax, ymin, zmax);
1550 if (!((xmin <= gXmax && xmin >= gXmin) && (ymin <= gYmax && ymin >= gYmin) && (zmax <= gZmax && zmax >= gZmin)))
1551 listOfPoints.emplace_back(xmin, ymin, zmax);
1552
1553 // group box inside input box
1554 if (((gXmax <= xmax && gXmax >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
1555 (gXmax != xmax || gYmax != ymax || gZmax != zmax))
1556 listOfPoints.emplace_back(gXmax, gYmax, gZmax);
1557 if (((gXmin <= xmax && gXmin >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
1558 (gXmin != xmin || gYmax != ymax || gZmax != zmax))
1559 listOfPoints.emplace_back(gXmin, gYmax, gZmax);
1560 if (((gXmin <= xmax && gXmin >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
1561 (gXmin != xmin || gYmax != ymax || gZmin != zmin))
1562 listOfPoints.emplace_back(gXmin, gYmax, gZmin);
1563 if (((gXmax <= xmax && gXmax >= xmin) && (gYmax <= ymax && gYmax >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
1564 (gXmax != xmax || gYmax != ymax || gZmin != zmin))
1565 listOfPoints.emplace_back(gXmax, gYmax, gZmin);
1566 if (((gXmin <= xmax && gXmin >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
1567 (gXmin != xmin || gYmin != ymin || gZmin != zmin))
1568 listOfPoints.emplace_back(gXmin, gYmin, gZmin);
1569 if (((gXmax <= xmax && gXmax >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmin <= zmax && gZmin >= zmin)) &&
1570 (gXmax != xmax || gYmin != ymin || gZmin != zmin))
1571 listOfPoints.emplace_back(gXmax, gYmin, gZmin);
1572 if (((gXmax <= xmax && gXmax >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
1573 (gXmax != xmax || gYmin != ymin || gZmax != zmax))
1574 listOfPoints.emplace_back(gXmax, gYmin, gZmax);
1575 if (((gXmin <= xmax && gXmin >= xmin) && (gYmin <= ymax && gYmin >= ymin) && (gZmax <= zmax && gZmax >= zmin)) &&
1576 (gXmin != xmin || gYmin != ymin || gZmax != zmax))
1577 listOfPoints.emplace_back(gXmin, gYmin, gZmax);
1578
1579 if (!listOfPoints.empty()) {
1580 xmin = ymin = zmin = DBL_MAX;
1581 xmax = ymax = zmax = -DBL_MAX;
1582 for (std::vector<V3D>::const_iterator it = listOfPoints.begin(); it != listOfPoints.end(); ++it) {
1583 // std::cout<<(*it)<<'\n';
1584 if ((*it)[0] < xmin)
1585 xmin = (*it)[0];
1586 if ((*it)[1] < ymin)
1587 ymin = (*it)[1];
1588 if ((*it)[2] < zmin)
1589 zmin = (*it)[2];
1590 if ((*it)[0] > xmax)
1591 xmax = (*it)[0];
1592 if ((*it)[1] > ymax)
1593 ymax = (*it)[1];
1594 if ((*it)[2] > zmax)
1595 zmax = (*it)[2];
1596 }
1597 }
1598}
1599
1600#ifdef ENABLE_OPENCASCADE
1601TopoDS_Shape CompGrp::analyze() {
1602 TopoDS_Shape Result = A->analyze();
1603 Result.Complement();
1604 return Result;
1605}
1606
1607TopoDS_Shape BoolValue::analyze() { return TopoDS_Shape(); }
1608#endif
1609} // namespace Mantid::Geometry
double left
Definition: LineProfile.cpp:80
double right
Definition: LineProfile.cpp:81
std::string m_key
#define GNU_DIAG_ON(x)
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
Rule Status class.
Definition: Rules.h:363
void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) override
gets the bounding box for the BoolValue Rule
Definition: RuleItems.cpp:1320
std::string display() const override
Definition: RuleItems.cpp:1283
void setLeaves(std::unique_ptr< Rule >, std::unique_ptr< Rule >) override
Replaces a leaf with a rule.
Definition: RuleItems.cpp:1235
std::unique_ptr< BoolValue > clone() const
Clone constructor.
Definition: RuleItems.cpp:1211
bool isValid(const Kernel::V3D &) const override
Determines if a point is valid.
Definition: RuleItems.cpp:1252
BoolValue * doClone() const override
Clone constructor.
Definition: RuleItems.cpp:1202
int status
Three values 0 False : 1 True : -1 doesn't matter.
Definition: Rules.h:365
BoolValue & operator=(const BoolValue &)
Assignment operator.
Definition: RuleItems.cpp:1188
int findLeaf(const Rule *) const override
Abstract find.
Definition: RuleItems.cpp:1250
std::string displayAddress() const override
Returns the memory address as a string.
Definition: RuleItems.cpp:1299
int simplify() override
Bool value is always in simplest form.
Definition: RuleItems.cpp:1274
void setLeaf(std::unique_ptr< Rule >, const int=0) override
Replaces a leaf with a rule.
Definition: RuleItems.cpp:1220
Constructive Solid Geometry object.
Definition: CSGObject.h:51
const Rule * topRule() const
Return the top rule.
Definition: CSGObject.h:76
void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) const override
Calculate (or return cached value of) Axis Aligned Bounding box (DEPRECATED)
Definition: CSGObject.cpp:1900
Compemented Grup.
Definition: Rules.h:315
bool isValid(const Kernel::V3D &) const override
Determines if a point is valid.
Definition: RuleItems.cpp:1445
Rule * findKey(const int i) override
This is a complementary object and we dont search into CompGrps.
Definition: RuleItems.cpp:1422
std::string display() const override
Displays the object as #number.
Definition: RuleItems.cpp:1485
std::string displayAddress() const override
Returns the memory address as a string.
Definition: RuleItems.cpp:1497
std::unique_ptr< CompGrp > clone() const
Clone of this.
Definition: RuleItems.cpp:1385
CompGrp * doClone() const override
Clone of this.
Definition: RuleItems.cpp:1376
int findLeaf(const Rule *) const override
Check to see if this is a copy of a given Rule.
Definition: RuleItems.cpp:1435
void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) override
gets the bounding box for the complement of the group
Definition: RuleItems.cpp:1523
void setLeaves(std::unique_ptr< Rule >, std::unique_ptr< Rule >) override
Replaces a leaf with a rule.
Definition: RuleItems.cpp:1408
CompGrp & operator=(const CompGrp &)
Standard assignment operator.
Definition: RuleItems.cpp:1359
void setLeaf(std::unique_ptr< Rule > nR, const int side=0) override
Replaces a leaf with a rule.
Definition: RuleItems.cpp:1394
std::unique_ptr< Rule > A
The rule.
Definition: Rules.h:317
int simplify() override
Impossible to simplify a simple rule leaf.
Definition: RuleItems.cpp:1475
Compemented Object.
Definition: Rules.h:262
void setObj(CSGObject *)
Set a Object state.
Definition: RuleItems.cpp:965
bool isValid(const Kernel::V3D &) const override
Determines if a point is valid.
Definition: RuleItems.cpp:1026
int objN
Object number.
Definition: Rules.h:264
void setLeaves(std::unique_ptr< Rule >, std::unique_ptr< Rule >) override
Replaces a leaf with a rule.
Definition: RuleItems.cpp:988
CSGObject * key
Object Pointer.
Definition: Rules.h:265
std::string displayAddress() const override
Returns the memory address as a string.
Definition: RuleItems.cpp:1072
CompObj * doClone() const override
Clone of this.
Definition: RuleItems.cpp:938
Rule * findKey(const int i) override
This is a complementary object and we dont search into CompObjs.
Definition: RuleItems.cpp:1003
int simplify() override
Impossible to simplify a simple rule leaf.
Definition: RuleItems.cpp:1051
std::unique_ptr< CompObj > clone() const
Clone of this.
Definition: RuleItems.cpp:947
std::string display() const override
Displays the object as #number.
Definition: RuleItems.cpp:1061
void setLeaf(std::unique_ptr< Rule >, const int=0) override
Replaces a leaf with a rule.
Definition: RuleItems.cpp:974
void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) override
gets the bounding box for the Complementary of the object
Definition: RuleItems.cpp:1093
int findLeaf(const Rule *) const override
Check to see if this is a copy of a given Rule.
Definition: RuleItems.cpp:1016
void setObjN(const int Ky)
set object Number
Definition: RuleItems.cpp:956
Combines two Rule objects in an intersection.
Definition: Rules.h:109
std::unique_ptr< Intersection > clone() const
Makes a copy of the whole downward tree.
Definition: RuleItems.cpp:138
int simplify() override
apply general intersection simplification
Definition: RuleItems.cpp:303
Intersection & operator=(const Intersection &)
Assignment operator :: Does a deep copy of the leaves of Iother.
Definition: RuleItems.cpp:106
Intersection * doClone() const override
Makes a copy of the whole downward tree.
Definition: RuleItems.cpp:129
void setLeaves(std::unique_ptr< Rule >, std::unique_ptr< Rule >) override
set leaves
Definition: RuleItems.cpp:164
int findLeaf(const Rule *) const override
Finds out if the Rule is the same as the leaves.
Definition: RuleItems.cpp:201
void setLeaf(std::unique_ptr< Rule > nR, const int side=0) override
set one leaf.
Definition: RuleItems.cpp:180
std::string displayAddress() const override
Debug function that converts the the intersection ion space delimited unit to denote intersection.
Definition: RuleItems.cpp:254
bool isValid(const Kernel::V3D &) const override
Calculates if Vec is within the object.
Definition: RuleItems.cpp:275
std::unique_ptr< Rule > A
Rule 1.
Definition: Rules.h:112
std::string display() const override
Displaces a bracket wrapped object.
Definition: RuleItems.cpp:231
Rule * findKey(const int KeyN) override
Finds the leaf with the surface number KeyN.
Definition: RuleItems.cpp:217
int isComplementary() const override
Determine is the rule has complementary sub components.
Definition: RuleItems.cpp:147
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
Definition: RuleItems.cpp:327
std::unique_ptr< Rule > B
Rule 2.
Definition: Rules.h:113
Object generation rule tree.
Definition: Rules.h:33
Rule & operator=(const Rule &)
Assignment operator= does not set parent as Rules are cloned.
Definition: Rules.cpp:446
Surface leaf node.
Definition: Rules.h:213
std::shared_ptr< Surface > m_key
Actual Surface Base Object.
Definition: Rules.h:215
int sign
+/- in Object unit
Definition: Rules.h:218
std::string displayAddress() const override
Returns the memory address as a string.
Definition: RuleItems.cpp:813
void setLeaf(std::unique_ptr< Rule >, const int=0) override
Replaces a leaf with a rule.
Definition: RuleItems.cpp:692
Rule * findKey(const int KeyNum) override
Finds the leaf with the surface number KeyN.
Definition: RuleItems.cpp:731
void setKeyN(const int Ky)
set keyNumber
Definition: RuleItems.cpp:742
int keyN
Key Number (identifer)
Definition: Rules.h:217
void setLeaves(std::unique_ptr< Rule >, std::unique_ptr< Rule >) override
Replaces a leaf with a rule.
Definition: RuleItems.cpp:707
SurfPoint()
Constructor with null key/number.
Definition: RuleItems.cpp:667
std::string display() const override
Returns the signed surface number as a string.
Definition: RuleItems.cpp:801
std::unique_ptr< SurfPoint > clone() const
Clone constructor.
Definition: RuleItems.cpp:683
void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) override
gets the bounding box for the surface object held by SurfPoint
Definition: RuleItems.cpp:834
int simplify() override
Impossible to simplify a simple rule leaf.
Definition: RuleItems.cpp:761
int findLeaf(const Rule *) const override
Determines if this rule is a particular leaf value uses memory address to compare.
Definition: RuleItems.cpp:720
void setKey(const std::shared_ptr< Surface > &Spoint)
Sets the key pointer.
Definition: RuleItems.cpp:752
SurfPoint * doClone() const override
Clone constructor.
Definition: RuleItems.cpp:674
bool isValid(const Kernel::V3D &) const override
Determines if a point is valid.
Definition: RuleItems.cpp:771
Combines two Rule objects in an union.
Definition: Rules.h:160
void setLeaves(std::unique_ptr< Rule >, std::unique_ptr< Rule >) override
set leaves
Definition: RuleItems.cpp:477
int simplify() override
apply general intersection simplification
Definition: RuleItems.cpp:541
std::unique_ptr< Rule > A
Leaf rule A.
Definition: Rules.h:163
Rule * findKey(const int KeyN) override
Finds the leaf with the surface number KeyN.
Definition: RuleItems.cpp:509
bool isValid(const Kernel::V3D &) const override
Calculates if Vec is within the object.
Definition: RuleItems.cpp:556
std::string displayAddress() const override
Returns the memory address as a string.
Definition: RuleItems.cpp:605
std::unique_ptr< Union > clone() const
Clone allows deep virtual coping.
Definition: RuleItems.cpp:446
Union * doClone() const override
Clone allows deep virtual coping.
Definition: RuleItems.cpp:437
int isComplementary() const override
Determine is the rule has complementary sub components.
Definition: RuleItems.cpp:524
std::string display() const override
Display the union in the form (N:M) where N,M are the downward rules.
Definition: RuleItems.cpp:579
Union & operator=(const Union &)
Assignment operator :: Does a deep copy of the leaves of Iother.
Definition: RuleItems.cpp:414
void getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) override
gets the bounding box for the Union Rule
Definition: RuleItems.cpp:635
std::unique_ptr< Rule > B
Leaf rule B.
Definition: Rules.h:164
void setLeaf(std::unique_ptr< Rule >, const int side=0) override
Replaces a leaf with a rule.
Definition: RuleItems.cpp:455
int findLeaf(const Rule *) const override
Finds out if the Rule is the same as the leaves.
Definition: RuleItems.cpp:493
Class for 3D vectors.
Definition: V3D.h:34
STL namespace.