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