MCPcopy Create free account
hub / github.com/Kitware/VTK / Subtract

Method Subtract

Common/DataModel/vtkPixelExtent.cxx:148–198  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

146
147//------------------------------------------------------------------------------
148void vtkPixelExtent::Subtract(
149 const vtkPixelExtent& A, const vtkPixelExtent& B, deque<vtkPixelExtent>& C)
150{
151 // split method requires split point inside the extent
152 vtkPixelExtent I(A);
153 I &= B;
154
155 if (I.Empty())
156 {
157 // do nothing if disjoint
158 C.push_back(A);
159 return;
160 }
161 if (B.Contains(A))
162 {
163 // if A is covered by B then remove A
164 return;
165 }
166
167 // split left and below this cells
168 I.CellToNode();
169
170 deque<vtkPixelExtent> tmpA0;
171 tmpA0.push_back(A);
172 for (int q = 0; q < 4; ++q)
173 {
174 constexpr int ids[8] = { 0, 2, 1, 2, 1, 3, 0, 3 };
175 int qq = 2 * q;
176 int i = I[ids[qq]];
177 int j = I[ids[qq + 1]];
178 deque<vtkPixelExtent> tmpA1;
179 while (!tmpA0.empty())
180 {
181 vtkPixelExtent ext = tmpA0.back();
182 tmpA0.pop_back();
183 vtkPixelExtent::Split(i, j, ext, tmpA1);
184 }
185 tmpA0 = tmpA1;
186 }
187
188 // remove anything covered by B
189 size_t n = tmpA0.size();
190 for (size_t q = 0; q < n; ++q)
191 {
192 const vtkPixelExtent& ext = tmpA0[q];
193 if (!B.Contains(ext))
194 {
195 C.push_back(ext);
196 }
197 }
198}
199
200//------------------------------------------------------------------------------
201void vtkPixelExtent::Merge(deque<vtkPixelExtent>& exts)

Callers

nothing calls this directly

Calls 9

backMethod · 0.80
pop_backMethod · 0.80
CellToNodeMethod · 0.60
SplitFunction · 0.50
EmptyMethod · 0.45
push_backMethod · 0.45
ContainsMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected