36 const Foam::scalar zeroish = Foam::SMALL;
37 const Foam::scalar positive = Foam::SMALL * 1E3;
43 void Foam::cuttingPlane::calcCutCells
45 const primitiveMesh&
mesh,
47 const UList<label>& cellIdLabels
53 label listSize = cellEdges.
size();
56 listSize = cellIdLabels.size();
64 for (label listI = 0; listI < listSize; ++listI)
69 cellI = cellIdLabels[listI];
72 const labelList& cEdges = cellEdges[cellI];
78 const edge&
e = edges[cEdges[i]];
82 (dotProducts[e[0]] < zeroish && dotProducts[e[1]] > positive)
83 || (dotProducts[e[1]] < zeroish && dotProducts[e[0]] > positive)
90 cutCells_[cutcellI++] = cellI;
106 void Foam::cuttingPlane::intersectEdges
108 const primitiveMesh& mesh,
110 List<label>& edgePoint
114 const edgeList& edges = mesh.edges();
118 edgePoint.
setSize(edges.size());
120 DynamicList<point> dynCuttingPoints(4*cutCells_.size());
124 const edge& e = edges[edgeI];
128 (dotProducts[e[0]] < zeroish && dotProducts[e[1]] > positive)
129 || (dotProducts[e[1]] < zeroish && dotProducts[e[0]] > positive)
133 edgePoint[edgeI] = dynCuttingPoints.size();
135 const point& p0 = points[e[0]];
136 const point& p1 = points[e[1]];
142 dynCuttingPoints.append(p0);
144 else if (alpha >= 1.0)
146 dynCuttingPoints.append(p1);
150 dynCuttingPoints.append((1-alpha)*p0 + alpha*p1);
155 edgePoint[edgeI] = -1;
159 this->storedPoints().transfer(dynCuttingPoints);
165 bool Foam::cuttingPlane::walkCell
167 const primitiveMesh& mesh,
168 const UList<label>& edgePoint,
170 const label startEdgeI,
171 DynamicList<label>& faceVerts
175 label edgeI = startEdgeI;
182 faceVerts.append(edgePoint[edgeI]);
188 const labelList& fEdges = mesh.faceEdges()[faceI];
190 label nextEdgeI = -1;
199 label edge2I = fEdges[i];
201 if (edge2I != edgeI && edgePoint[edge2I] != -1)
211 WarningIn(
"Foam::cuttingPlane::walkCell")
212 <<
"Did not find closed walk along surface of cell " << cellI
213 <<
" starting from edge " << startEdgeI
214 <<
" in " << nIter <<
" iterations." <<
nl
215 <<
"Collected cutPoints so far:" << faceVerts
227 WarningIn(
"Foam::cuttingPlane::walkCell")
228 <<
"Did not find closed walk along surface of cell " << cellI
229 <<
" starting from edge " << startEdgeI
230 <<
" in " << nIter <<
" iterations." <<
nl
231 <<
"Collected cutPoints so far:" << faceVerts
236 }
while (edgeI != startEdgeI);
239 if (faceVerts.size() >= 3)
245 WarningIn(
"Foam::cuttingPlane::walkCell")
246 <<
"Did not find closed walk along surface of cell " << cellI
247 <<
" starting from edge " << startEdgeI <<
nl
248 <<
"Collected cutPoints so far:" << faceVerts
257 void Foam::cuttingPlane::walkCellCuts
259 const primitiveMesh& mesh,
260 const UList<label>& edgePoint
266 DynamicList<face> dynCutFaces(cutCells_.size());
267 DynamicList<label> dynCutCells(cutCells_.size());
270 DynamicList<label> faceVerts(10);
274 label cellI = cutCells_[i];
277 const labelList& cEdges = mesh.cellEdges()[cellI];
279 label startEdgeI = -1;
283 label edgeI = cEdges[cEdgeI];
285 if (edgePoint[edgeI] != -1)
293 if (startEdgeI == -1)
296 <<
"Cannot find cut edge for cut cell " << cellI
301 bool okCut = walkCell
315 if ((
f.normal(cutPoints) & normal()) < 0)
321 label nTri =
f.triangles(cutPoints, dynCutFaces);
324 dynCutCells.
append(cellI);
329 this->storedFaces().transfer(dynCutFaces);
330 cutCells_.transfer(dynCutCells);
353 reCut(mesh, cellIdLabels);
373 calcCutCells(mesh, dotProducts, cellIdLabels);
378 intersectEdges(mesh, dotProducts, edgePoint);
381 walkCellCuts(mesh, edgePoint);
392 if (&faceMap && faceMap.
size())
394 MeshStorage::remapFaces(faceMap);
399 newCutCells[faceI] = cutCells_[faceMap[faceI]];
401 cutCells_.transfer(newCutCells);
412 FatalErrorIn (
"Foam::cuttingPlane::operator=(const cuttingPlane&)")
413 <<
"Attempted assignment to self"
418 static_cast<plane&
>(*this) = rhs;