00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "message-macros.hh"
00026
00027 #include "boolean-operations-3d.hh"
00028 #include "corefine-3d-face-face.hh"
00029
00030 using namespace std;
00031 using namespace GMap3d;
00032
00033
00034
00035 CBooleanOperations3d::CBooleanOperations3d(CGMapVertex * AMap,
00036 CDart * AObject1,
00037 CDart * AObject2,
00038 bool ACalculateOrientation,
00039 int AVertexDI)
00040 : CBooleanOperations(AMap, AObject1, AObject2,
00041 ACalculateOrientation, AVertexDI),
00042 FDisplayMessages(2)
00043 {
00044 }
00045
00046
00047
00048 CBooleanOperations3d::~CBooleanOperations3d()
00049 {
00050 }
00051
00052
00053
00054 bool CBooleanOperations3d::corefineObjects(bitset<NB_MARKS> ACopyMarks)
00055 {
00056 DEBUG_FUNCTION;
00057
00058 CDart *d1 = getObject1(), *d2 = getObject2();
00059 CCorefine3dFF c(getMap(), calculateOrientation(), 1E-4, getVertexDI());
00060
00061 c.setDisplayMessagesLevel(FDisplayMessages);
00062 int nb = c.corefine(d1, d2, ACopyMarks);
00063 if (!nb) c.linkCompounds(d1, d2, ACopyMarks);
00064
00065 setObject1(d1);
00066 setObject2(d2);
00067
00068 return (nb > 0);
00069 }
00070
00071
00072 #define a0(d) (getMap()->alpha0(d))
00073 #define a1(d) (getMap()->alpha1(d))
00074 #define a2(d) (getMap()->alpha2(d))
00075 #define a3(d) (getMap()->alpha3(d))
00076
00077 void CBooleanOperations3d::extendMarks()
00078 {
00079 DEBUG_FUNCTION;
00080
00081
00082
00083
00084 list<CDart*> dart_list[2];
00085 int mark[2] = {getObject1Mark(), getObject2Mark()};
00086 CDart *d;
00087
00088 for (CDynamicCoverageCC dcc(getMap(), getObject1()); dcc.cont(); ++dcc) {
00089 for (int i = 0; i < 2; i++)
00090 if (getMap()->isMarked(*dcc, mark[i]) &&
00091 !getMap()->isMarked(a2(*dcc), mark[i]))
00092 dart_list[i].push_back(a2(*dcc));
00093 }
00094
00095 for (int i = 0; i < 2; i++)
00096 while (!dart_list[i].empty()) {
00097 d = dart_list[i].front(), dart_list[i].pop_front();
00098
00099 if (!getMap()->isMarked(d, mark[i])) {
00100 getMap()->setMark(d, mark[i]);
00101
00102 if (!getMap()->isMarked(a0(d), mark[i]))
00103 dart_list[i].push_back(a0(d));
00104
00105 if (!getMap()->isMarked(a1(d), mark[i]))
00106 dart_list[i].push_back(a1(d));
00107
00108 if (!getMap()->isMarked(a2(d), mark[i]))
00109 dart_list[i].push_back(a2(d));
00110
00111 if ((!getMap()->isMarked(d, mark[(i + 1) % 2]) ||
00112 getMap()->isMarked(a3(d), mark[(i + 1) % 2])) &&
00113 !getMap()->isMarked(a3(d), mark[i]))
00114 dart_list[i].push_back(a3(d));
00115 }
00116 }
00117 }
00118
00119 #undef a0
00120 #undef a1
00121 #undef a2
00122 #undef a3
00123