36 const Foam::scalar zeroish = Foam::small;
37 const Foam::scalar positive = Foam::small * 1E3;
42 void Foam::cuttingPlane::calcCutCells
44 const primitiveMesh& mesh,
50 const edgeList& edges = mesh.edges();
52 label listSize = cellEdges.size();
55 listSize = cellIdLabels.size();
62 const bool isZoneEmpty
64 (
returnReduce(cellIdLabels.size(), sumOp<label>()) > 0) ?
false :
true 69 for (
label listI = 0; listI < listSize; ++listI)
75 celli = cellIdLabels[listI];
88 const labelList& cEdges = cellEdges[celli];
94 const edge& e = edges[cEdges[i]];
98 (dotProducts[e[0]] < zeroish && dotProducts[e[1]] > positive)
99 || (dotProducts[e[1]] < zeroish && dotProducts[e[0]] > positive)
106 cutCells_[cutcelli++] = celli;
119 void Foam::cuttingPlane::intersectEdges
121 const primitiveMesh& mesh,
123 List<label>& edgePoint
127 const edgeList& edges = mesh.edges();
131 edgePoint.
setSize(edges.size());
133 DynamicList<point> dynCuttingPoints(4*cutCells_.
size());
137 const edge& e = edges[edgeI];
141 (dotProducts[e[0]] < zeroish && dotProducts[e[1]] > positive)
142 || (dotProducts[e[1]] < zeroish && dotProducts[e[0]] > positive)
146 edgePoint[edgeI] = dynCuttingPoints.size();
148 const point& p0 = points[e[0]];
149 const point& p1 = points[e[1]];
155 dynCuttingPoints.append(p0);
157 else if (alpha >= 1.0)
159 dynCuttingPoints.append(p1);
163 dynCuttingPoints.append((1-alpha)*p0 + alpha*p1);
168 edgePoint[edgeI] = -1;
176 bool Foam::cuttingPlane::walkCell
178 const primitiveMesh& mesh,
181 const label startEdgeI,
182 DynamicList<label>& faceVerts
186 label edgeI = startEdgeI;
193 faceVerts.append(edgePoint[edgeI]);
199 const labelList& fEdges = mesh.faceEdges()[facei];
201 label nextEdgeI = -1;
210 label edge2I = fEdges[i];
212 if (edge2I != edgeI && edgePoint[edge2I] != -1)
223 <<
"Did not find closed walk along surface of cell " << celli
224 <<
" starting from edge " << startEdgeI
225 <<
" in " << nIter <<
" iterations." <<
nl 226 <<
"Collected cutPoints so far:" << faceVerts
239 <<
"Did not find closed walk along surface of cell " << celli
240 <<
" starting from edge " << startEdgeI
241 <<
" in " << nIter <<
" iterations." <<
nl 242 <<
"Collected cutPoints so far:" << faceVerts
247 }
while (edgeI != startEdgeI);
250 if (faceVerts.size() >= 3)
257 <<
"Did not find closed walk along surface of cell " << celli
258 <<
" starting from edge " << startEdgeI <<
nl 259 <<
"Collected cutPoints so far:" << faceVerts
267 void Foam::cuttingPlane::walkCellCuts
269 const primitiveMesh& mesh,
270 const bool triangulate,
277 DynamicList<face> dynCutFaces(cutCells_.
size());
278 DynamicList<label> dynCutCells(cutCells_.
size());
281 DynamicList<label> faceVerts(10);
285 label celli = cutCells_[i];
288 const labelList& cEdges = mesh.cellEdges()[celli];
290 label startEdgeI = -1;
294 label edgeI = cEdges[cEdgeI];
296 if (edgePoint[edgeI] != -1)
304 if (startEdgeI == -1)
307 <<
"Cannot find cut edge for cut cell " << celli
312 bool okCut = walkCell
326 if ((
f.area(cutPoints) &
normal()) < 0)
334 label nTri =
f.triangles(cutPoints, dynCutFaces);
337 dynCutCells.append(celli);
342 dynCutFaces.append(
f);
343 dynCutCells.append(celli);
358 const bool triangulate,
368 calcCutCells(mesh, dotProducts, cellIdLabels);
373 intersectEdges(mesh, dotProducts, edgePoint);
376 walkCellCuts(mesh, triangulate, edgePoint);
393 newCutCells[facei] = cutCells_[faceMap[facei]];
412 const bool triangulate,
418 reCut(mesh, triangulate, cellIdLabels);
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void reCut(const primitiveMesh &, const bool triangulate, const labelUList &cellIdLabels=labelUList::null())
Recut mesh with existing planeDesc, restricted to a list of cells.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Cell-face mesh analysis engine.
void size(const label)
Override size to be inconsistent with allocated storage.
virtual void clear()
Clear all storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const pointField & points() const =0
Return mesh points.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
UList< label > labelUList
plane(const vector &normalVector)
Construct from normal vector through the origin.
vectorField pointField
pointField is a vectorField.
line< point, const point & > linePointRef
Line using referred points.
List< face > & storedFaces()
Non-const access to the faces.
void clear()
Clear the list, i.e. set size to zero.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const point & refPoint() const
Return or return plane base point.
pointField & storedPoints()
Non-const access to global points.
virtual void remapFaces(const labelUList &faceMap)
Remap action on triangulation or cleanup.
const Field< PointType > & points() const
Return reference to global points.
List< label > labelList
A List of labels.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
volScalarField scalarField(fieldObject, mesh)
scalar lineIntersect(const line< Point, PointRef > &l) const
Return the cutting point between the plane and.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
void setSize(const label)
Reset size of List.
const vector & normal() const
Return plane normal.
virtual void remapFaces(const labelUList &faceMap)
Set new zones from faceMap.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
cuttingPlane(const plane &)
Construct plane description without cutting.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
label size() const
Return the number of elements in the UList.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.