diff --git a/applications/utilities/postProcessing/sampling/sample/sampleDict b/applications/utilities/postProcessing/sampling/sample/sampleDict index 86ba1b4849..60e1d7d0ee 100644 --- a/applications/utilities/postProcessing/sampling/sample/sampleDict +++ b/applications/utilities/postProcessing/sampling/sample/sampleDict @@ -165,6 +165,10 @@ surfaces //- Optional: restrict to a particular zone // zone zone1; + + //- Optional: do not triangulate (only for surfaceFormats that support + // polygons) + //triangulate false; } interpolatedPlane diff --git a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C index 3873962cca..87167b572c 100644 --- a/src/sampling/sampledSurface/sampledPlane/sampledPlane.C +++ b/src/sampling/sampledSurface/sampledPlane/sampledPlane.C @@ -45,12 +45,14 @@ Foam::sampledPlane::sampledPlane const word& name, const polyMesh& mesh, const plane& planeDesc, - const keyType& zoneKey + const keyType& zoneKey, + const bool triangulate ) : sampledSurface(name, mesh), cuttingPlane(planeDesc), zoneKey_(zoneKey), + triangulate_(triangulate), needsUpdate_(true) { if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0) @@ -71,6 +73,7 @@ Foam::sampledPlane::sampledPlane sampledSurface(name, mesh, dict), cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))), zoneKey_(keyType::null), + triangulate_(dict.lookupOrDefault("triangulate", true)), needsUpdate_(true) { // make plane relative to the coordinateSystem (Cartesian) @@ -138,11 +141,11 @@ bool Foam::sampledPlane::update() if (selectedCells.empty()) { - reCut(mesh(), true); // always triangulate. Note:Make option? + reCut(mesh(), triangulate_); } else { - reCut(mesh(), true, selectedCells); + reCut(mesh(), triangulate_, selectedCells); } if (debug) @@ -250,6 +253,7 @@ void Foam::sampledPlane::print(Ostream& os) const os << "sampledPlane: " << name() << " :" << " base:" << refPoint() << " normal:" << normal() + << " triangulate:" << triangulate_ << " faces:" << faces().size() << " points:" << points().size(); } diff --git a/src/sampling/sampledSurface/sampledPlane/sampledPlane.H b/src/sampling/sampledSurface/sampledPlane/sampledPlane.H index 1c6a1b8058..3b24a09e52 100644 --- a/src/sampling/sampledSurface/sampledPlane/sampledPlane.H +++ b/src/sampling/sampledSurface/sampledPlane/sampledPlane.H @@ -25,7 +25,7 @@ Class Foam::sampledPlane Description - A sampledSurface defined by a cuttingPlane. Always triangulated. + A sampledSurface defined by a cuttingPlane. Triangulated by default. Note Does not actually cut until update() called. @@ -60,6 +60,9 @@ class sampledPlane //- If restricted to zones, name of this zone or a regular expression keyType zoneKey_; + //- Triangulated faces or keep faces as is + const bool triangulate_; + //- Track if the surface needs an update mutable bool needsUpdate_; @@ -92,7 +95,8 @@ public: const word& name, const polyMesh& mesh, const plane& planeDesc, - const keyType& zoneKey = word::null + const keyType& zoneKey = word::null, + const bool triangulate = true ); //- Construct from dictionary