Newer
Older
#include <fstream>
#include <iomanip>
#include <iostream>
#include <complex>
#include <cmath>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <cfloat>
#include "MantidKernel/Exception.h"
#include "MantidGeometry/Math/Triple.h"
Gigg, Martyn Anthony
committed
#include "MantidKernel/Matrix.h"
#include "MantidKernel/V3D.h"
#include "MantidGeometry/Surfaces/Line.h"
#include "MantidGeometry/Surfaces/BaseVisit.h"
#include "MantidGeometry/Surfaces/Surface.h"
#include "MantidGeometry/Objects/Rules.h"
#include "MantidGeometry/Objects/Object.h"
namespace Mantid
{
namespace Geometry
{
Gigg, Martyn Anthony
committed
using Kernel::V3D;
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Intersection::Intersection() : Rule(),
A(0),B(0)
/**
Standard Constructor with null leaves
*/
{}
Intersection::Intersection(Rule* Ix,Rule* Iy) : Rule(),
A(Iy),B(Ix)
/**
Intersection constructor from two Rule ptrs.
- Sets A,B's parents to *this
- Allowed to control Ix and Iy
@param Ix :: Rule A
@param Iy :: Rule B
*/
{
if (A)
A->setParent(this);
if (B)
B->setParent(this);
}
Intersection::Intersection(Rule* Parent,Rule* Ix,Rule* Iy) :
Rule(Parent),A(Ix),B(Iy)
/**
Intersection constructor from two Rule ptrs
- Sets A,B's parents to *this.
@param Parent :: Set the Rule::Parent pointer
@param Ix :: Rule A
@param Iy :: Rule B
*/
{
if (A)
A->setParent(this);
if (B)
B->setParent(this);
}
Intersection::Intersection(const Intersection& Iother) :
Rule(),A(0),B(0)
/**
Copy constructor:
Does a clone on the sub-tree below
@param Iother :: Intersection to copy
*/
{
if (Iother.A)
{
A=Iother.A->clone();
A->setParent(this);
}
if (Iother.B)
{
B=Iother.B->clone();
B->setParent(this);
}
}
Intersection&
Intersection::operator=(const Intersection& Iother)
/**
Assignment operator :: Does a deep copy
of the leaves of Iother.
@param Iother :: object to copy
@return *this
*/
{
if (this!=&Iother)
{
Rule::operator=(Iother);
// first create new copy all fresh
if (Iother.A)
{
Rule* Xa=Iother.A->clone();
delete A;
A=Xa;
A->setParent(this);
}
Rule* Xb=Iother.B->clone();
delete B;
B=Xb;
B->setParent(this);
}
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
}
return *this;
}
Intersection::~Intersection()
/**
Destructor :: responsible for the two
leaf intersections.
*/
{
delete A;
delete B;
}
Intersection*
Intersection::clone() const
/**
Virtual copy constructor
@return new Intersection(this)
*/
{
return new Intersection(*this);
}
int
Intersection::isComplementary() const
/**
Determine is the rule has complementary
sub components
@retval 1 :: A side
@retval -1 :: B side
@retval 0 :: no complement
*/
{
if (A && A->isComplementary())
return 1;
if (B && B->isComplementary())
return -1;
return 0;
}
void
Intersection::setLeaves(Rule* aR,Rule* bR)
/**
Replaces a both with a rule.
No deletion is carried out but sets the parents.
@param aR :: Rule on the left
@param bR :: Rule on the right
*/
{
A=aR;
B=bR;
if (A)
A->setParent(this);
if (B)
B->setParent(this);
return;
}
void
Intersection::setLeaf(Rule* nR,const int side)
/**
Replaces a leaf with a rule.
Calls delete on previous leaf.
@param nR :: new rule
@param side :: side to use
- 0 == LHS
- 1 == RHS
*/
{
if (side)
{
delete B;
B=nR;
if (B)
B->setParent(this);
}
else
{
delete A;
A=nR;
if (A)
A->setParent(this);
}
return;
}
int
Intersection::findLeaf(const Rule* R) const
/**
Finds out if the Rule is the
same as the leaves
@param R :: Rule pointer to compare
@retval 0 / 1 for LHS / RHS leaf
@retval -1 :: neither leaf
*/
{
if (A==R)
return 0;
if (B==R)
return 1;
return -1;
}
Rule*
Intersection::findKey(const int KeyN)
/**
Finds the leaf with the surface number KeyN
@param KeyN :: Number to search for
@retval 0 :: no leaf with that key number availiable
@retval Rule* if an appropiate leaf is found
*/
{
Rule* PtrOut=(A) ? A->findKey(KeyN) : 0;
if (PtrOut)
return PtrOut;
return (B) ? B->findKey(KeyN) : 0;
}
std::string
Intersection::display() const
/**
Displaces a bracket wrapped object
@return Bracketed string
*/
{
std::string out;
if (!A || !B)
throw std::runtime_error("Intersection::display incomplete type");
if (A->type()==-1)
out="("+A->display()+")";
else
out=A->display();
out+=" ";
if (B->type()==-1)
out+="("+B->display()+")";
else
out+=B->display();
return out;
}
std::string
Intersection::displayAddress() const
/**
Debug function that converts the
the intersection ion space delimited unit
to denote intersection.
@return ( leaf leaf )
*/
{
std::stringstream cx;
cx<<" [ "<<reinterpret_cast<long>(this);
if (A && B)
cx<<" ] ("+A->displayAddress()+" "+B->displayAddress()+") ";
else if (A)
cx<<" ] ("+A->displayAddress()+" 0x0 ) ";
else if (B)
cx<<" ] ( 0x0 "+B->displayAddress()+") ";
else
cx<<" ] ( 0x0 0x0 ) ";
return cx.str();
}
bool
Gigg, Martyn Anthony
committed
Intersection::isValid(const Kernel::V3D& Vec) const
/**
Calculates if Vec is within the object
@param Vec :: Point to test
@retval 1 :: Vec is within object
@retval 0 :: Vec is outside object.
*/
{
if(A && B)
{
return (A->isValid(Vec) && B->isValid(Vec));
}
return false;
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
}
bool
Intersection::isValid(const std::map<int,int>& MX) const
/**
Use MX to determine if the surface truth etc is
valie
@param MX :: map of key + logical value XOR sign
@retval 1 :: Both sides are valid
@retval 0 :: Either side is invalid.
*/
{
if (!A || !B)
return false;
return (A->isValid(MX) && B->isValid(MX)) ? true : false;
}
int
Intersection::simplify()
/**
Union simplification::
- -S S simplify to True.
- S S simplify to S
- -S -S simplifies to -S
@retval 1 if clauses removed (not top)
@retval -1 replacement of this intersection is required
by leaf 0
@retval 0 if no work to do.
*/
{
return 0;
}
/**
* find the common bounding box with the two childs of intersection
* @param xmax :: Maximum value for the bounding box in x direction
* @param ymax :: Maximum value for the bounding box in y direction
* @param zmax :: Maximum value for the bounding box in z direction
* @param xmin :: Minimum value for the bounding box in x direction
* @param ymin :: Minimum value for the bounding box in y direction
* @param zmin :: Minimum value for the bounding box in z direction
*/
void Intersection::getBoundingBox(double &xmax,double &ymax,double &zmax,double &xmin,double &ymin,double &zmin)
{
double Axmax,Aymax,Azmax,Axmin,Aymin,Azmin;
double Bxmax,Bymax,Bzmax,Bxmin,Bymin,Bzmin;
Axmax=Bxmax=xmax;
Aymax=Bymax=ymax;
Azmax=Bzmax=zmax;
Axmin=Bxmin=xmin;
Aymin=Bymin=ymin;
Azmin=Bzmin=zmin;
A->getBoundingBox(Axmax,Aymax,Azmax,Axmin,Aymin,Azmin);
B->getBoundingBox(Bxmax,Bymax,Bzmax,Bxmin,Bymin,Bzmin);
xmax=(Axmax<Bxmax)? Axmax:Bxmax;
xmin=(Axmin>Bxmin)? Axmin:Bxmin;
ymax=(Aymax<Bymax)? Aymax:Bymax;
ymin=(Aymin>Bymin)? Aymin:Bymin;
zmax=(Azmax<Bzmax)? Azmax:Bzmax;
zmin=(Azmin>Bzmin)? Azmin:Bzmin;
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
}
// -------------------------------------------------------------
// UNION
//---------------------------------------------------------------
Union::Union() :
Rule(),A(0),B(0)
/**
Standard Constructor with null leaves
*/
{}
Union::Union(Rule* Parent,Rule* Ix,Rule* Iy) : Rule(Parent),
A(Ix),B(Iy)
/**
Union constructor from two Rule ptrs.
- Sets A,B's parents to *this
- Allowed to control Ix and Iy
@param Parent :: Rule that is the parent to this
@param Ix :: Rule A
@param Iy :: Rule B
*/
{
if (A)
A->setParent(this);
if (B)
B->setParent(this);
}
Union::Union(Rule* Ix,Rule* Iy) : Rule(),
A(Ix),B(Iy)
/**
Union constructor from two Rule ptrs
- Sets A,B's parents to *this.
- Allowed to control Ix and Iy
@param Ix :: Rule A
@param Iy :: Rule B
*/
{
if (A)
A->setParent(this);
if (B)
B->setParent(this);
}
Union::Union(const Union& Iother) : Rule(Iother),
A(0),B(0)
/**
Copy constructor:
Does a clone on the sub-tree below
@param Iother :: Union to copy
*/
{
if (Iother.A)
{
A=Iother.A->clone();
A->setParent(this);
}
if (Iother.B)
{
B=Iother.B->clone();
B->setParent(this);
}
}
Union&
Union::operator=(const Union& Iother)
/**
Assignment operator :: Does a deep copy
of the leaves of Iother.
@param Iother :: Union to assign to it.
@return this union (copy).
*/
{
if (this!=&Iother)
{
Rule::operator=(Iother);
// first create new copy all fresh
if (Iother.A)
{
Rule* Xa=Iother.A->clone();
delete A;
A=Xa;
A->setParent(this);
}
Rule* Xb=Iother.B->clone();
delete B;
B=Xb;
B->setParent(this);
}
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
}
return *this;
}
Union::~Union()
/**
Delete operator : deletes both leaves
*/
{
delete A;
delete B;
}
Union*
Union::clone() const
/**
Clone allows deep virtual coping
@return new Union copy.
*/
{
return new Union(*this);
}
void
Union::setLeaf(Rule* nR,const int side)
/**
Replaces a leaf with a rule.
Calls delete on previous leaf.
@param nR :: new rule
@param side :: side to use
- 0 == LHS
- 1 == RHS
*/
{
if (side)
{
delete B;
B=nR;
if (B)
B->setParent(this);
}
else
{
delete A;
A=nR;
if (A)
A->setParent(this);
}
return;
}
void
Union::setLeaves(Rule* aR,Rule* bR)
/**
Replaces a both with a rule.
No deletion is carried out but sets the parents.
@param aR :: Rule on the left
@param bR :: Rule on the right
*/
{
A=aR;
B=bR;
if (A)
A->setParent(this);
if (B)
B->setParent(this);
return;
}
int
Union::findLeaf(const Rule* R) const
/**
Finds out if the Rule is the
same as the leaves
@param R :: Rule pointer to compare
@retval 0 / 1 for LHS / RHS leaf
@retval -1 :: neither leaf
*/
{
if (A==R)
return 0;
if (B==R)
return 1;
return -1;
}
Rule*
Union::findKey(const int KeyN)
/**
Finds the leaf with the surface number KeyN
@param KeyN :: Number to search for
@retval 0 :: no leaf with that key number availiable
@retval Rule* if an appropiate leaf is found
*/
{
Rule* PtrOut=(A) ? A->findKey(KeyN) : 0;
if (PtrOut)
return PtrOut;
return (B) ? B->findKey(KeyN) : 0;
}
int
Union::isComplementary() const
/**
Determine is the rule has complementary
sub components
@retval 1 :: A side
@retval -1 :: B side
@retval 0 :: no complement
*/
{
if (A && A->isComplementary())
return 1;
if (B && B->isComplementary())
return -1;
return 0;
}
int
Union::simplify()
/**
Union simplification::
- -S S simplify to True.
- S S simplify to S
- -S -S simplifies to -S
@retval 1 if clauses removed (not top)
@retval -1 replacement of this intersection is required
by leaf 0
@retval 0 if no work to do.
*/
{
if (!commonType())
return 0;
return 0;
}
bool
Gigg, Martyn Anthony
committed
Union::isValid(const Kernel::V3D& Vec) const
/**
Calculates if Vec is within the object
@param Vec :: Point to test
@retval 1 :: Vec is within object
@retval 0 :: Vec is outside object.
*/
{
return ((A && A->isValid(Vec)) ||
(B && B->isValid(Vec))) ? true : false;
}
bool
Union::isValid(const std::map<int,int>& MX) const
/**
Use MX to determine if the surface truth etc is
valie
@param MX :: map of key + logical value XOR sign
@retval 1 :: if either side is valid
@retval 0 :: Neither side is valid
*/
{
return ((A && A->isValid(MX)) ||
(B && B->isValid(MX))) ? true : false;
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
}
std::string
Union::display() const
/**
Display the union in the form
(N:M) where N,M are the downward
rules
@return bracket string
*/
{
std::string out;
if (!A || !B)
throw std::runtime_error("Union::display incomplete type");
if (A->type()==1)
out="("+A->display()+")";
else
out=A->display();
out+=" : ";
if (B->type()==1)
out+="("+B->display()+")";
else
out+=B->display();
return out;
}
std::string
Union::displayAddress() const
/**
Returns the memory address as
a string. Displays addresses of leaves
@return String of address
*/
{
std::stringstream cx;
cx<<" [ "<<reinterpret_cast<long int>(this);
if (A && B)
cx<<" ] ("+A->displayAddress()+" : "+B->displayAddress()+") ";
else if (A)
cx<<" ] ("+A->displayAddress()+" : 0x0 ) ";
else if (B)
cx<<" ] ( 0x0 : "+B->displayAddress()+") ";
else
cx<<" ] ( 0x0 : 0x0 ) ";
return cx.str();
}
/**
* gets the bounding box for the Union Rule
* @param xmax :: Maximum value for the bounding box in x direction
* @param ymax :: Maximum value for the bounding box in y direction
* @param zmax :: Maximum value for the bounding box in z direction
* @param xmin :: Minimum value for the bounding box in x direction
* @param ymin :: Minimum value for the bounding box in y direction
* @param zmin :: Minimum value for the bounding box in z direction
*/
void Union::getBoundingBox(double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin)
{
double Axmax,Aymax,Azmax,Axmin,Aymin,Azmin;
double Bxmax,Bymax,Bzmax,Bxmin,Bymin,Bzmin;
Axmax=Bxmax=xmax;
Aymax=Bymax=ymax;
Azmax=Bzmax=zmax;
Axmin=Bxmin=xmin;
Aymin=Bymin=ymin;
Azmin=Bzmin=zmin;
A->getBoundingBox(Axmax,Aymax,Azmax,Axmin,Aymin,Azmin);
B->getBoundingBox(Bxmax,Bymax,Bzmax,Bxmin,Bymin,Bzmin);
xmax=(Axmax>Bxmax)? Axmax:Bxmax;
xmin=(Axmin<Bxmin)? Axmin:Bxmin;
ymax=(Aymax>Bymax)? Aymax:Bymax;
ymin=(Aymin<Bymin)? Aymin:Bymin;
zmax=(Azmax>Bzmax)? Azmax:Bzmax;
zmin=(Azmin<Bzmin)? Azmin:Bzmin;
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
}
// -------------------------------------------------------------
// SURF KEYS
//---------------------------------------------------------------
SurfPoint::SurfPoint() : Rule(),
key(0),keyN(0),sign(1)
/**
Constructor with null key/number
*/
{}
SurfPoint::SurfPoint(const SurfPoint& A) : Rule(),
key(A.key->clone()),keyN(A.keyN),sign(A.sign)
/**
Copy constructor
@param A :: SurfPoint to copy
*/
{}
SurfPoint*
SurfPoint::clone() const
/**
Clone constructor
@return new(*this)
*/
{
return new SurfPoint(*this);
}
SurfPoint&
SurfPoint::operator=(const SurfPoint& A)
/**
Assigment operator
@param A :: Object to copy
@return *this
*/
{
if (&A!=this)
{
delete key;
key=A.key->clone();
keyN=A.keyN;
sign=A.sign;
}
return *this;
}
SurfPoint::~SurfPoint()
/**
Destructor
*/
{
delete key;
}
void
SurfPoint::setLeaf(Rule* nR,const int)
/**
Replaces a leaf with a rule.
This REQUIRES that nR is of type SurfPoint
@param nR :: new rule
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
*/
{
// std::cerr<<"Calling SurfPoint setLeaf"<<std::endl;
SurfPoint* newX = dynamic_cast<SurfPoint*>(nR);
if (newX)
*this = *newX;
return;
}
void
SurfPoint::setLeaves(Rule* aR,Rule*)
/**
Replaces a leaf with a rule.
This REQUIRES that nR is of type SurfPoint
@param aR :: new rule
*/
{
//std::cerr<<"Calling SurfPoint setLeaf"<<std::endl;
SurfPoint* newX = dynamic_cast<SurfPoint*>(aR);
if (newX)
*this = *newX;
return;
}
int
SurfPoint::findLeaf(const Rule* A) const
/**
Determines if this rule is a particular leaf value
uses memory address to compare.
@param A :: Rule to check
@return 0 if true and -1 if false.
*/
{
return (this==A) ? 0 : -1;
}
Rule*
SurfPoint::findKey(const int KeyNum)
/**
Finds the leaf with the surface number KeyN
@param KeyNum :: Number to search for
@retval 0 :: no leaf with that key number availiable
@retval Rule* if an appropiate leaf is found
*/
{
return (KeyNum==keyN) ? this : 0;
}
void
SurfPoint::setKeyN(const int Ky)
/**
Sets the key and the sign
@param Ky :: key value (+/- is used for sign)
*/
{
sign= (Ky<0) ? -1 : 1;
keyN= sign*Ky;
return;
}
void
SurfPoint::setKey(Surface* Spoint)
/**
Sets the key pointer. The class takes ownership.
@param Spoint :: new key values
*/
{
if (key!=Spoint) delete key;
key=Spoint;
return;
}
int
SurfPoint::simplify()
/**
Impossible to simplify a simple
rule leaf. Therefore returns 0
@return 0
*/
{
return 0;
}
bool
Gigg, Martyn Anthony
committed
SurfPoint::isValid(const Kernel::V3D& Pt) const
/**
Determines if a point is valid.
@param Pt :: Point to test
@retval 1 :: Pt is the +ve side of the
surface or on the surface
@retval 0 :: Pt is on the -ve side of the surface
*/
{
if (key)
{
return (key->side(Pt)*sign)>=0;
}
return false;
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
}
bool
SurfPoint::isValid(const std::map<int,int>& MX) const
/**
Use MX to determine if the surface truth etc is
valid
@param MX :: map of key + logical value XOR sign
@return MX.second if key found or 0
*/
{
std::map<int,int>::const_iterator lx=MX.find(keyN);
if (lx==MX.end())
return false;
const int rtype=(lx->second) ? 1 : -1;
return (rtype*sign)>=0 ? true : false;
}
std::string
SurfPoint::display() const
/**
Returns the signed surface number as
a string.
@return string of the value
*/
{
std::stringstream cx;
cx<<sign*keyN;
return cx.str();
}
std::string
SurfPoint::displayAddress() const
/**
Returns the memory address as
a string.
@return memory address as string
*/
{
std::stringstream cx;
cx<<reinterpret_cast<long int>(this);
return cx.str();
}
/**
* gets the bounding box for the surface object held by SurfPoint
* @param xmax :: Maximum value for the bounding box in x direction
* @param ymax :: Maximum value for the bounding box in y direction
* @param zmax :: Maximum value for the bounding box in z direction
* @param xmin :: Minimum value for the bounding box in x direction
* @param ymin :: Minimum value for the bounding box in y direction
* @param zmin :: Minimum value for the bounding box in z direction
*/
void SurfPoint::getBoundingBox(double &xmax,double &ymax,double &zmax,double &xmin,double &ymin,double &zmin)
{
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
if(this->sign<1) //If the object sign is positive then include
key->getBoundingBox(xmax,ymax,zmax,xmin,ymin,zmin);
else{ //if the object sign is negative then get the complement
std::vector<V3D> listOfPoints;
double gXmax,gYmax,gZmax,gXmin,gYmin,gZmin;
gXmax=xmax; gYmax=ymax; gZmax=zmax; gXmin=xmin; gYmin=ymin; gZmin=zmin;
key->getBoundingBox(gXmax,gYmax,gZmax,gXmin,gYmin,gZmin);
if(!((xmax<=gXmax && xmax>=gXmin)&&(ymax<=gYmax && ymax>=gYmin)&&(zmax<=gZmax && zmax>=gZmin))) listOfPoints.push_back(V3D(xmax,ymax,zmax));
if(!((xmin<=gXmax && xmin>=gXmin)&&(ymax<=gYmax && ymax>=gYmin)&&(zmax<=gZmax && zmax>=gZmin))) listOfPoints.push_back(V3D(xmin,ymax,zmax));
if(!((xmin<=gXmax && xmin>=gXmin)&&(ymax<=gYmax && ymax>=gYmin)&&(zmin<=gZmax && zmin>=gZmin))) listOfPoints.push_back(V3D(xmin,ymax,zmin));
if(!((xmax<=gXmax && xmax>=gXmin)&&(ymax<=gYmax && ymax>=gYmin)&&(zmin<=gZmax && zmin>=gZmin))) listOfPoints.push_back(V3D(xmax,ymax,zmin));
if(!((xmin<=gXmax && xmin>=gXmin)&&(ymin<=gYmax && ymin>=gYmin)&&(zmin<=gZmax && zmin>=gZmin))) listOfPoints.push_back(V3D(xmin,ymin,zmin));
if(!((xmax<=gXmax && xmax>=gXmin)&&(ymin<=gYmax && ymin>=gYmin)&&(zmin<=gZmax && zmin>=gZmin))) listOfPoints.push_back(V3D(xmax,ymin,zmin));
if(!((xmax<=gXmax && xmax>=gXmin)&&(ymin<=gYmax && ymin>=gYmin)&&(zmax<=gZmax && zmax>=gZmin))) listOfPoints.push_back(V3D(xmax,ymin,zmax));
if(!((xmin<=gXmax && xmin>=gXmin)&&(ymin<=gYmax && ymin>=gYmin)&&(zmax<=gZmax && zmax>=gZmin))) listOfPoints.push_back(V3D(xmin,ymin,zmax));
//group box inside input box
if(((gXmax<=xmax && gXmax>=xmin)&&(gYmax<=ymax && gYmax>=ymin)&&(gZmax<=zmax && gZmax>=zmin))&&(gXmax!=xmax||gYmax!=ymax||gZmax!=zmax)) listOfPoints.push_back(V3D(gXmax,gYmax,gZmax));
if(((gXmin<=xmax && gXmin>=xmin)&&(gYmax<=ymax && gYmax>=ymin)&&(gZmax<=zmax && gZmax>=zmin))&&(gXmin!=xmin||gYmax!=ymax||gZmax!=zmax)) listOfPoints.push_back(V3D(gXmin,gYmax,gZmax));
if(((gXmin<=xmax && gXmin>=xmin)&&(gYmax<=ymax && gYmax>=ymin)&&(gZmin<=zmax && gZmin>=zmin))&&(gXmin!=xmin||gYmax!=ymax||gZmin!=zmin)) listOfPoints.push_back(V3D(gXmin,gYmax,gZmin));
if(((gXmax<=xmax && gXmax>=xmin)&&(gYmax<=ymax && gYmax>=ymin)&&(gZmin<=zmax && gZmin>=zmin))&&(gXmax!=xmax||gYmax!=ymax||gZmin!=zmin)) listOfPoints.push_back(V3D(gXmax,gYmax,gZmin));
if(((gXmin<=xmax && gXmin>=xmin)&&(gYmin<=ymax && gYmin>=ymin)&&(gZmin<=zmax && gZmin>=zmin))&&(gXmin!=xmin||gYmin!=ymin||gZmin!=zmin)) listOfPoints.push_back(V3D(gXmin,gYmin,gZmin));
if(((gXmax<=xmax && gXmax>=xmin)&&(gYmin<=ymax && gYmin>=ymin)&&(gZmin<=zmax && gZmin>=zmin))&&(gXmax!=xmax||gYmin!=ymin||gZmin!=zmin)) listOfPoints.push_back(V3D(gXmax,gYmin,gZmin));
if(((gXmax<=xmax && gXmax>=xmin)&&(gYmin<=ymax && gYmin>=ymin)&&(gZmax<=zmax && gZmax>=zmin))&&(gXmax!=xmax||gYmin!=ymin||gZmax!=zmax)) listOfPoints.push_back(V3D(gXmax,gYmin,gZmax));
if(((gXmin<=xmax && gXmin>=xmin)&&(gYmin<=ymax && gYmin>=ymin)&&(gZmax<=zmax && gZmax>=zmin))&&(gXmin!=xmin||gYmin!=ymin||gZmax!=zmax)) listOfPoints.push_back(V3D(gXmin,gYmin,gZmax));
if(!listOfPoints.empty()){
xmin=ymin=zmin=DBL_MAX;
xmax=ymax=zmax=-DBL_MAX;
for(std::vector<V3D>::const_iterator it=listOfPoints.begin();it!=listOfPoints.end();++it){
// std::cout<<(*it)<<std::endl;
if((*it)[0]<xmin)xmin=(*it)[0];
if((*it)[1]<ymin)ymin=(*it)[1];
if((*it)[2]<zmin)zmin=(*it)[2];
if((*it)[0]>xmax)xmax=(*it)[0];
if((*it)[1]>ymax)ymax=(*it)[1];
if((*it)[2]>zmax)zmax=(*it)[2];
}
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
}
//----------------------------------------
// COMPOBJ
//----------------------------------------
CompObj::CompObj() : Rule(),
objN(0),key(0)
/**
Constructor
*/
{}
CompObj::CompObj(const CompObj& A) :
Rule(A),
objN(A.objN),key(A.key)
/**
Standard copy constructor
@param A :: CompObj to copy
*/
{}
CompObj&
CompObj::operator=(const CompObj& A)
/**
Standard assignment operator
@param A :: CompObj to copy
@return *this
*/
{
if (this!=&A)
{
Rule::operator=(A);
objN=A.objN;
key=A.key;
}
return *this;
}
CompObj::~CompObj()
/**
Destructor
*/
{}
CompObj*
CompObj::clone() const
/**