/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA \*---------------------------------------------------------------------------*/ #include "surfaceFeatures.H" #include "triSurface.H" #include "octree.H" #include "octreeDataEdges.H" #include "octreeDataPoint.H" #include "meshTools.H" #include "linePointRef.H" #include "OFstream.H" #include "IFstream.H" #include "unitConversion.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(Foam::surfaceFeatures, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // //- Get nearest point on edge and classify position on edge. Foam::pointIndexHit Foam::surfaceFeatures::edgeNearest ( const point& start, const point& end, const point& sample ) { pointHit eHit = linePointRef(start, end).nearestDist(sample); // Classification of position on edge. label endPoint; if (eHit.hit()) { // Nearest point is on edge itself. // Note: might be at or very close to endpoint. We should use tolerance // here. endPoint = -1; } else { // Nearest point has to be one of the end points. Find out // which one. if ( mag(eHit.rawPoint() - start) < mag(eHit.rawPoint() - end) ) { endPoint = 0; } else { endPoint = 1; } } return pointIndexHit(eHit.hit(), eHit.rawPoint(), endPoint); } // Go from selected edges only to a value for every edge Foam::List Foam::surfaceFeatures::toStatus() const { List edgeStat(surf_.nEdges(), NONE); // Region edges first for (label i = 0; i < externalStart_; i++) { edgeStat[featureEdges_[i]] = REGION; } // External edges for (label i = externalStart_; i < internalStart_; i++) { edgeStat[featureEdges_[i]] = EXTERNAL; } // Internal edges for (label i = internalStart_; i < featureEdges_.size(); i++) { edgeStat[featureEdges_[i]] = INTERNAL; } return edgeStat; } // Set from value for every edge void Foam::surfaceFeatures::setFromStatus(const List& edgeStat) { // Count label nRegion = 0; label nExternal = 0; label nInternal = 0; forAll(edgeStat, edgeI) { if (edgeStat[edgeI] == REGION) { nRegion++; } else if (edgeStat[edgeI] == EXTERNAL) { nExternal++; } else if (edgeStat[edgeI] == INTERNAL) { nInternal++; } } externalStart_ = nRegion; internalStart_ = externalStart_ + nExternal; // Copy featureEdges_.setSize(internalStart_ + nInternal); label regionI = 0; label externalI = externalStart_; label internalI = internalStart_; forAll(edgeStat, edgeI) { if (edgeStat[edgeI] == REGION) { featureEdges_[regionI++] = edgeI; } else if (edgeStat[edgeI] == EXTERNAL) { featureEdges_[externalI++] = edgeI; } else if (edgeStat[edgeI] == INTERNAL) { featureEdges_[internalI++] = edgeI; } } // Calculate consistent feature points calcFeatPoints(edgeStat); } //construct feature points where more than 2 feature edges meet void Foam::surfaceFeatures::calcFeatPoints(const List& edgeStat) { DynamicList