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();
63 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;
103 void Foam::cuttingPlane::intersectEdges
105 const primitiveMesh& mesh,
107 List<label>& edgePoint
111 const edgeList& edges = mesh.edges();
115 edgePoint.
setSize(edges.size());
117 DynamicList<point> dynCuttingPoints(4*cutCells_.
size());
121 const edge& e = edges[edgeI];
125 (dotProducts[e[0]] < zeroish && dotProducts[e[1]] > positive)
126 || (dotProducts[e[1]] < zeroish && dotProducts[e[0]] > positive)
130 edgePoint[edgeI] = dynCuttingPoints.size();
132 const point& p0 = points[e[0]];
133 const point& p1 = points[e[1]];
139 dynCuttingPoints.append(p0);
141 else if (alpha >= 1.0)
143 dynCuttingPoints.append(p1);
147 dynCuttingPoints.append((1-alpha)*p0 + alpha*p1);
152 edgePoint[edgeI] = -1;
160 bool Foam::cuttingPlane::walkCell
162 const primitiveMesh& mesh,
165 const label startEdgeI,
166 DynamicList<label>& faceVerts
170 label edgeI = startEdgeI;
177 faceVerts.append(edgePoint[edgeI]);
183 const labelList& fEdges = mesh.faceEdges()[facei];
185 label nextEdgeI = -1;
194 label edge2I = fEdges[i];
196 if (edge2I != edgeI && edgePoint[edge2I] != -1)
207 <<
"Did not find closed walk along surface of cell " << celli
208 <<
" starting from edge " << startEdgeI
209 <<
" in " << nIter <<
" iterations." <<
nl 210 <<
"Collected cutPoints so far:" << faceVerts
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
231 }
while (edgeI != startEdgeI);
234 if (faceVerts.size() >= 3)
241 <<
"Did not find closed walk along surface of cell " << celli
242 <<
" starting from edge " << startEdgeI <<
nl 243 <<
"Collected cutPoints so far:" << faceVerts
251 void Foam::cuttingPlane::walkCellCuts
253 const primitiveMesh& mesh,
254 const bool triangulate,
261 DynamicList<face> dynCutFaces(cutCells_.
size());
262 DynamicList<label> dynCutCells(cutCells_.
size());
265 DynamicList<label> faceVerts(10);
269 label celli = cutCells_[i];
272 const labelList& cEdges = mesh.cellEdges()[celli];
274 label startEdgeI = -1;
278 label edgeI = cEdges[cEdgeI];
280 if (edgePoint[edgeI] != -1)
288 if (startEdgeI == -1)
291 <<
"Cannot find cut edge for cut cell " << celli
296 bool okCut = walkCell
310 if ((
f.normal(cutPoints) &
normal()) < 0)
318 label nTri =
f.triangles(cutPoints, dynCutFaces);
321 dynCutCells.append(celli);
326 dynCutFaces.append(
f);
327 dynCutCells.append(celli);
351 const bool triangulate,
357 reCut(mesh, triangulate, cellIdLabels);
367 const bool triangulate,
377 calcCutCells(mesh, dotProducts, cellIdLabels);
382 intersectEdges(mesh, dotProducts, edgePoint);
385 walkCellCuts(mesh, triangulate, edgePoint);
402 newCutCells[facei] = cutCells_[faceMap[facei]];
417 <<
"Attempted assignment to self" 422 static_cast<plane&
>(*this) = rhs;
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.
const labelList & cutCells() const
Return List of cells cut by the plane.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const point & refPoint() const
Return or return plane base point.
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.
const Field< PointType > & points() const
Return reference to global points.
virtual const pointField & points() const =0
Return mesh points.
void operator=(const cuttingPlane &)
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
const vector & normal() const
Return plane normal.
UList< label > labelUList
plane(const vector &normalVector)
Construct from normal vector through the origin.
vectorField pointField
pointField is a vectorField.
Constructs plane through mesh.
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.
pointField & storedPoints()
Non-const access to global points.
virtual void remapFaces(const labelUList &faceMap)
Remap action on triangulation or cleanup.
List< label > labelList
A List of labels.
scalar lineIntersect(const line< Point, PointRef > &l) const
Return the cutting point between the plane and.
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)
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
label size() const
Return the number of elements in the UList.
void setSize(const label)
Reset size of List.
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.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.