ENH: plane sampling: make triangulation optional

This commit is contained in:
mattijs
2013-09-02 11:12:17 +01:00
parent 31446daab0
commit 491e4821d0
3 changed files with 17 additions and 5 deletions

View File

@ -165,6 +165,10 @@ surfaces
//- Optional: restrict to a particular zone //- Optional: restrict to a particular zone
// zone zone1; // zone zone1;
//- Optional: do not triangulate (only for surfaceFormats that support
// polygons)
//triangulate false;
} }
interpolatedPlane interpolatedPlane

View File

@ -45,12 +45,14 @@ Foam::sampledPlane::sampledPlane
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
const plane& planeDesc, const plane& planeDesc,
const keyType& zoneKey const keyType& zoneKey,
const bool triangulate
) )
: :
sampledSurface(name, mesh), sampledSurface(name, mesh),
cuttingPlane(planeDesc), cuttingPlane(planeDesc),
zoneKey_(zoneKey), zoneKey_(zoneKey),
triangulate_(triangulate),
needsUpdate_(true) needsUpdate_(true)
{ {
if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0) if (debug && zoneKey_.size() && mesh.cellZones().findIndex(zoneKey_) < 0)
@ -71,6 +73,7 @@ Foam::sampledPlane::sampledPlane
sampledSurface(name, mesh, dict), sampledSurface(name, mesh, dict),
cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))), cuttingPlane(plane(dict.lookup("basePoint"), dict.lookup("normalVector"))),
zoneKey_(keyType::null), zoneKey_(keyType::null),
triangulate_(dict.lookupOrDefault("triangulate", true)),
needsUpdate_(true) needsUpdate_(true)
{ {
// make plane relative to the coordinateSystem (Cartesian) // make plane relative to the coordinateSystem (Cartesian)
@ -138,11 +141,11 @@ bool Foam::sampledPlane::update()
if (selectedCells.empty()) if (selectedCells.empty())
{ {
reCut(mesh(), true); // always triangulate. Note:Make option? reCut(mesh(), triangulate_);
} }
else else
{ {
reCut(mesh(), true, selectedCells); reCut(mesh(), triangulate_, selectedCells);
} }
if (debug) if (debug)
@ -250,6 +253,7 @@ void Foam::sampledPlane::print(Ostream& os) const
os << "sampledPlane: " << name() << " :" os << "sampledPlane: " << name() << " :"
<< " base:" << refPoint() << " base:" << refPoint()
<< " normal:" << normal() << " normal:" << normal()
<< " triangulate:" << triangulate_
<< " faces:" << faces().size() << " faces:" << faces().size()
<< " points:" << points().size(); << " points:" << points().size();
} }

View File

@ -25,7 +25,7 @@ Class
Foam::sampledPlane Foam::sampledPlane
Description Description
A sampledSurface defined by a cuttingPlane. Always triangulated. A sampledSurface defined by a cuttingPlane. Triangulated by default.
Note Note
Does not actually cut until update() called. 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 //- If restricted to zones, name of this zone or a regular expression
keyType zoneKey_; keyType zoneKey_;
//- Triangulated faces or keep faces as is
const bool triangulate_;
//- Track if the surface needs an update //- Track if the surface needs an update
mutable bool needsUpdate_; mutable bool needsUpdate_;
@ -92,7 +95,8 @@ public:
const word& name, const word& name,
const polyMesh& mesh, const polyMesh& mesh,
const plane& planeDesc, const plane& planeDesc,
const keyType& zoneKey = word::null const keyType& zoneKey = word::null,
const bool triangulate = true
); );
//- Construct from dictionary //- Construct from dictionary