Moka libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
boolean-operations-3d.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 // #define DEBUG_MESSAGES
25 #include "message-macros.hh"
26 
27 #include "boolean-operations-3d.hh"
28 #include "corefine-3d-face-face.hh"
29 
30 using namespace std;
31 using namespace GMap3d;
32 
33 //******************************************************************************
34 
35 CBooleanOperations3d::CBooleanOperations3d(CGMapVertex * AMap,
36  CDart * AObject1,
37  CDart * AObject2,
38  bool ACalculateOrientation,
39  int AVertexDI)
40  : CBooleanOperations(AMap, AObject1, AObject2,
41  ACalculateOrientation, AVertexDI),
42  FDisplayMessages(2)
43 {
44 }
45 
46 //******************************************************************************
47 
49 {
50 }
51 
52 //******************************************************************************
53 
54 bool CBooleanOperations3d::corefineObjects(bitset<NB_MARKS> ACopyMarks)
55 {
56  DEBUG_FUNCTION;
57 
58  CDart *d1 = getObject1(), *d2 = getObject2();
60 
61  c.setDisplayMessagesLevel(FDisplayMessages);
62  int nb = c.corefine(d1, d2, ACopyMarks);
63  if (!nb) c.linkCompounds(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 #define a3(d) (getMap()->alpha3(d))
76 
78 {
79  DEBUG_FUNCTION;
80 
81 // getMap()->markIncidentCells(ORBIT_012, getObject1Mark());
82 // getMap()->markIncidentCells(ORBIT_012, getObject2Mark());
83 
84  list<CDart*> dart_list[2];
85  int mark[2] = {getObject1Mark(), getObject2Mark()};
86  CDart *d;
87 
88  for (CDynamicCoverageCC dcc(getMap(), getObject1()); dcc.cont(); ++dcc) {
89  for (int i = 0; i < 2; i++)
90  if (getMap()->isMarked(*dcc, mark[i]) &&
91  !getMap()->isMarked(a2(*dcc), mark[i]))
92  dart_list[i].push_back(a2(*dcc));
93  }
94 
95  for (int i = 0; i < 2; i++)
96  while (!dart_list[i].empty()) {
97  d = dart_list[i].front(), dart_list[i].pop_front();
98 
99  if (!getMap()->isMarked(d, mark[i])) {
100  getMap()->setMark(d, mark[i]);
101 
102  if (!getMap()->isMarked(a0(d), mark[i]))
103  dart_list[i].push_back(a0(d));
104 
105  if (!getMap()->isMarked(a1(d), mark[i]))
106  dart_list[i].push_back(a1(d));
107 
108  if (!getMap()->isMarked(a2(d), mark[i]))
109  dart_list[i].push_back(a2(d));
110 
111  if ((!getMap()->isMarked(d, mark[(i + 1) % 2]) ||
112  getMap()->isMarked(a3(d), mark[(i + 1) % 2])) &&
113  !getMap()->isMarked(a3(d), mark[i]))
114  dart_list[i].push_back(a3(d));
115  }
116  }
117 }
118 
119 #undef a0
120 #undef a1
121 #undef a2
122 #undef a3
123 //******************************************************************************