Moka libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
boolean-operations-2d.cc
Go to the documentation of this file.
1 /*
2  * lib-corefinement : Opérations de corafinement.
3  * Copyright (C) 2004, Moka Team, Université de Poitiers, Laboratoire SIC
4  * http://www.sic.sp2mi.univ-poitiers.fr/
5  * Copyright (C) 2009, Guillaume Damiand, CNRS, LIRIS,
6  * guillaume.damiand@liris.cnrs.fr, http://liris.cnrs.fr/
7  *
8  * This file is part of lib-corefinement
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #include "boolean-operations-2d.hh"
26 
27 //#define DEBUG_MESSAGES
28 #include "message-macros.hh"
29 
30 using namespace std;
31 using namespace GMap3d;
32 
33 //******************************************************************************
34 
35 CBooleanOperations2d::CBooleanOperations2d(CGMapVertex * AMap,
36  CDart * AObject1,
37  CDart * AObject2,
38  bool ACalculateOrientation,
39  int AVertexDI)
40  : CBooleanOperations(AMap, AObject1, AObject2,
41  ACalculateOrientation, AVertexDI)
42 {
43 }
44 
45 //******************************************************************************
46 
48 {
49 }
50 
51 //******************************************************************************
52 
53 bool CBooleanOperations2d::corefineObjects(bitset<NB_MARKS> ACopyMarks)
54 {
55  DEBUG_FUNCTION;
56 
57  CDart *d1 = getObject1(), *d2 = getObject2();
58  CPlane plane(getMap()->regionNormalVector(d1, 0),
59  *getMap()->findVertex(d1));
60  CCorefine2dPropagation cp(getMap(), plane,
62 
63  int nb = cp.corefine(d1, d2, ACopyMarks);
64 
65  setObject1(d1);
66  setObject2(d2);
67 
68  return (nb > 0);
69 }
70 
71 //******************************************************************************
72 #define a0(d) (getMap()->alpha0(d))
73 #define a1(d) (getMap()->alpha1(d))
74 #define a2(d) (getMap()->alpha2(d))
75 
77 {
78  DEBUG_FUNCTION;
79 
80 // getMap()->markIncidentCells(ORBIT_01, getObject1Mark());
81 // getMap()->markIncidentCells(ORBIT_01, getObject2Mark());
82 
83  list<CDart*> dart_list[2];
84  int mark[2] = {getObject1Mark(), getObject2Mark()};
85  CDart *d;
86 
87  for (CDynamicCoverageCC dcc(getMap(), getObject1()); dcc.cont(); ++dcc) {
88  for (int i = 0; i < 2; i++)
89  if (getMap()->isMarked(*dcc, mark[i]) &&
90  !getMap()->isMarked(a1(*dcc), mark[i]))
91  dart_list[i].push_back(a1(*dcc));
92  }
93 
94  for (int i = 0; i < 2; i++)
95  while (!dart_list[i].empty()) {
96  d = dart_list[i].front(), dart_list[i].pop_front();
97 
98  if (!getMap()->isMarked(d, mark[i])) {
99  getMap()->setMark(d, mark[i]);
100 
101  if (!getMap()->isMarked(a0(d), mark[i]))
102  dart_list[i].push_back(a0(d));
103 
104  if (!getMap()->isMarked(a1(d), mark[i]))
105  dart_list[i].push_back(a1(d));
106 
107  if ((!getMap()->isMarked(d, mark[(i + 1) % 2]) ||
108  getMap()->isMarked(a2(d), mark[(i + 1) % 2])) &&
109  !getMap()->isMarked(a2(d), mark[i]))
110  dart_list[i].push_back(a2(d));
111  }
112  }
113 }
114 
115 #undef a0
116 #undef a1
117 #undef a2
118 //******************************************************************************