43 namespace searchableSurfaceModifiers
52 void Foam::searchableSurfaceModifiers::cut::triangulate
62 nTris += fcs[i].size()-2;
65 DynamicList<labelledTri> tris(nTris);
69 const face&
f = fcs[i];
71 for (label fp = 1; fp <
f.size()-1; fp++)
73 tris.append(labelledTri(
f[0],
f[fp],
f[
f.fcIndex(fp)], i));
79 patches[patchi] = geometricSurfacePatch
85 cutSurf = triSurface(tris,
patches, pts,
true);
91 const searchableSurface& cutter,
95 if (isA<searchableBox>(cutter))
97 const searchableBox& bb = refCast<const searchableBox>(cutter);
104 else if (isA<searchableRotatedBox>(cutter))
106 const searchableRotatedBox& bb =
107 refCast<const searchableRotatedBox>(cutter);
114 else if (isA<triSurfaceMesh>(cutter))
116 return const_cast<triSurfaceMesh&
>
118 refCast<const triSurfaceMesh>(cutter)
124 <<
"Triangulation only supported for triSurfaceMesh, searchableBox"
125 <<
", not for surface " << cutter.name()
126 <<
" of type " << cutter.type()
128 return const_cast<triSurfaceMesh&
>
130 refCast<const triSurfaceMesh>(cutter)
138 bool Foam::searchableSurfaceModifiers::cut::intersectSurfaces
141 edgeIntersections& edgeCuts1,
143 edgeIntersections& edgeCuts2
146 bool hasMoved1 =
false;
147 bool hasMoved2 =
false;
149 for (label iter = 0; iter < 10; iter++)
151 Info<<
"Determining intersections of surf1 edges with surf2"
159 triSurfaceSearch querySurf2(surf2);
167 edgeCuts1 = edgeIntersections
179 edgeCuts1.removeDegenerates
191 surf1.movePoints(points1);
197 Info<<
"Determining intersections of surf2 edges with surf1"
202 triSurfaceSearch querySurf1(surf1);
210 edgeCuts2 = edgeIntersections
222 edgeCuts2.removeDegenerates
234 surf2.movePoints(points2);
241 if (nIters1 == 0 && nIters2 == 0)
265 return hasMoved1 || hasMoved2;
273 const searchableSurfaces& geometry,
274 const dictionary&
dict
277 searchableSurfaceModifier(geometry,
dict),
278 cutterNames_(dict_.
get<wordRes>(
"cutters"))
287 searchableSurface& geom
290 triSurface& surf = refCast<triSurfaceMesh>(geom);
292 bool changed =
false;
295 for (
const wordRe& cutterName : cutterNames_)
299 for (
const label geomI : geomIDs)
301 const searchableSurface& cutter = geometry_[geomI];
305 triSurface& cutSurf = triangulate(cutter, work);
308 edgeIntersections edge1Cuts;
309 edgeIntersections edge2Cuts;
320 surfaceIntersection inter(surf, edge1Cuts, cutSurf, edge2Cuts);
324 intersectedSurface surf3(surf,
true, inter);
328 List<volumeType> volTypes;
329 cutter.getVolumeType(surf3.faceCentres(), volTypes);
341 if (nInside && surf3.patches().size() > 0)
344 label sz = newPatches.size();
345 newPatches.setSize(sz+1);
346 newPatches[sz] = geometricSurfacePatch
348 newPatches[sz-1].
name() +
"_inside",
349 newPatches[sz-1].index(),
350 newPatches[sz-1].geometricType()
353 Info<<
"Moving " << nInside <<
" out of " << surf3.size()
354 <<
" triangles to region "
355 << newPatches[sz].name() <<
endl;
358 List<labelledTri> newTris(surf3);
363 newTris[i].region() = sz;
367 surf = triSurface(newTris, newPatches, newPoints,
true);