From 40fda4f99d938d88a7b0f097ce5c4c6630404222 Mon Sep 17 00:00:00 2001 From: laurence <laurence> Date: Mon, 12 Dec 2011 14:37:38 +0000 Subject: [PATCH] STYLE: cv2DMesh: Moved inline function definitions into separate header files. --- .../mesh/generation/cv2DMesh/indexedFace.H | 86 +++--- .../mesh/generation/cv2DMesh/indexedFaceI.H | 108 ++++++++ .../mesh/generation/cv2DMesh/indexedVertex.H | 251 +++++++----------- .../mesh/generation/cv2DMesh/indexedVertexI.H | 230 ++++++++++++++++ 4 files changed, 472 insertions(+), 203 deletions(-) create mode 100644 applications/utilities/mesh/generation/cv2DMesh/indexedFaceI.H create mode 100644 applications/utilities/mesh/generation/cv2DMesh/indexedVertexI.H diff --git a/applications/utilities/mesh/generation/cv2DMesh/indexedFace.H b/applications/utilities/mesh/generation/cv2DMesh/indexedFace.H index 6ebc154e3f4..ab26ac71349 100644 --- a/applications/utilities/mesh/generation/cv2DMesh/indexedFace.H +++ b/applications/utilities/mesh/generation/cv2DMesh/indexedFace.H @@ -46,7 +46,7 @@ namespace CGAL \*---------------------------------------------------------------------------*/ template<class Gt, class Fb=CGAL::Triangulation_face_base_2<Gt> > -class indexedFace +class indexedFace : public Fb { @@ -78,61 +78,45 @@ public: }; - indexedFace() - : - Fb(), - index_(CHANGED) - {} + // Constructors - indexedFace(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2) - : - Fb(v0, v1, v2), - index_(CHANGED) - {} + inline indexedFace(); - indexedFace - ( - Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2, - Face_handle n0, - Face_handle n1, - Face_handle n2 - ) - : - Fb(v0, v1, v2, n0, n1, n2), - index_(CHANGED) - {} - - - void set_vertex(int i, Vertex_handle v) - { - index_ = CHANGED; - Fb::set_vertex(i, v); - } + inline indexedFace + ( + Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2 + ); - void set_vertices() - { - index_ = CHANGED; - Fb::set_vertices(); - } + inline indexedFace + ( + Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2 + ); - void set_vertices(Vertex_handle v0, Vertex_handle v1, Vertex_handle v2) - { - index_ = CHANGED; - Fb::set_vertices(v0, v1, v2); - } + // Member Functions - int& faceIndex() - { - return index_; - } + inline void set_vertex(int i, Vertex_handle v); + + inline void set_vertices(); + + inline void set_vertices + ( + Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2 + ); + + inline int& faceIndex(); + + inline int faceIndex() const; - int faceIndex() const - { - return index_; - } }; @@ -142,6 +126,10 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "indexedFaceI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/applications/utilities/mesh/generation/cv2DMesh/indexedFaceI.H b/applications/utilities/mesh/generation/cv2DMesh/indexedFaceI.H new file mode 100644 index 00000000000..89bdf686918 --- /dev/null +++ b/applications/utilities/mesh/generation/cv2DMesh/indexedFaceI.H @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ 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 3 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, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Gt, class Fb> +inline CGAL::indexedFace<Gt, Fb>::indexedFace() +: + Fb(), + index_(CHANGED) +{} + + +template<class Gt, class Fb> +inline CGAL::indexedFace<Gt, Fb>::indexedFace +( + Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2 +) +: + Fb(v0, v1, v2), + index_(CHANGED) +{} + + +template<class Gt, class Fb> +inline CGAL::indexedFace<Gt, Fb>::indexedFace +( + Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Face_handle n0, + Face_handle n1, + Face_handle n2 +) +: + Fb(v0, v1, v2, n0, n1, n2), + index_(CHANGED) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Gt, class Fb> +inline void CGAL::indexedFace<Gt, Fb>::set_vertex(int i, Vertex_handle v) +{ + index_ = CHANGED; + Fb::set_vertex(i, v); +} + + +template<class Gt, class Fb> +inline void CGAL::indexedFace<Gt, Fb>::set_vertices() +{ + index_ = CHANGED; + Fb::set_vertices(); +} + + +template<class Gt, class Fb> +inline void CGAL::indexedFace<Gt, Fb>::set_vertices +( + Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2 +) +{ + index_ = CHANGED; + Fb::set_vertices(v0, v1, v2); +} + + +template<class Gt, class Fb> +inline int& CGAL::indexedFace<Gt, Fb>::faceIndex() +{ + return index_; +} + + +template<class Gt, class Fb> +inline int CGAL::indexedFace<Gt, Fb>::faceIndex() const +{ + return index_; +} + diff --git a/applications/utilities/mesh/generation/cv2DMesh/indexedVertex.H b/applications/utilities/mesh/generation/cv2DMesh/indexedVertex.H index 8efb22c735c..fca82d936b1 100644 --- a/applications/utilities/mesh/generation/cv2DMesh/indexedVertex.H +++ b/applications/utilities/mesh/generation/cv2DMesh/indexedVertex.H @@ -40,6 +40,34 @@ Description namespace CGAL { +// Forward declaration of friend functions and operators + +template<class Gt, class Vb> +class indexedVertex; + +template<class Gt, class Vb> +bool pointPair +( + const indexedVertex<Gt, Vb>& v0, + const indexedVertex<Gt, Vb>& v1 +); + +template<class Gt, class Vb> +bool boundaryTriangle +( + const indexedVertex<Gt, Vb>& v0, + const indexedVertex<Gt, Vb>& v1, + const indexedVertex<Gt, Vb>& v2 +); + +template<class Gt, class Vb> +bool outsideTriangle +( + const indexedVertex<Gt, Vb>& v0, + const indexedVertex<Gt, Vb>& v1, + const indexedVertex<Gt, Vb>& v2 +); + /*---------------------------------------------------------------------------*\ Class indexedVertex Declaration \*---------------------------------------------------------------------------*/ @@ -85,173 +113,85 @@ public: }; - indexedVertex() - : - Vb(), - index_(INTERNAL_POINT), - type_(INTERNAL_POINT) - {} - - indexedVertex(const Point& p) - : - Vb(p), - index_(INTERNAL_POINT), - type_(INTERNAL_POINT) - {} - - indexedVertex(const Point& p, const int index, const int& type) - : - Vb(p), - index_(index), - type_(type) - {} - - indexedVertex(const Point& p, Face_handle f) - : - Vb(f, p), - index_(INTERNAL_POINT), - type_(INTERNAL_POINT) - {} - - indexedVertex(Face_handle f) - : - Vb(f), - index_(INTERNAL_POINT), - type_(INTERNAL_POINT) - {} - - - int& index() - { - return index_; - } + // Constructors - int index() const - { - return index_; - } + inline indexedVertex(); + inline indexedVertex(const Point& p); - int& type() - { - return type_; - } + inline indexedVertex(const Point& p, const int index, const int& type); - int type() const - { - return type_; - } + inline indexedVertex(const Point& p, Face_handle f); + inline indexedVertex(Face_handle f); - //- Is point a far-point - inline bool farPoint() const - { - return type_ == FAR_POINT; - } - //- Is point internal, i.e. not on boundary - inline bool internalPoint() const - { - return type_ <= INTERNAL_POINT; - } + // Member Functions - //- Is point internal and near the boundary - inline bool nearBoundary() const - { - return type_ == NEAR_BOUNDARY_POINT; - } + inline int& index(); - //- Set the point to be near the boundary - inline void setNearBoundary() - { - type_ = NEAR_BOUNDARY_POINT; - } + inline int index() const; - //- Is point a mirror point - inline bool mirrorPoint() const - { - return type_ == MIRROR_POINT; - } + inline int& type(); - //- Either master or slave of pointPair. - inline bool pairPoint() const - { - return type_ >= 0; - } + inline int type() const; - //- Master of a pointPair is the lowest numbered one. - inline bool ppMaster() const - { - if (type_ > index_) - { - return true; - } - else - { - return false; - } - } - - //- Slave of a pointPair is the highest numbered one. - inline bool ppSlave() const - { - if (type_ >= 0 && type_ < index_) - { - return true; - } - else - { - return false; - } - } - - //- Either original internal point or master of pointPair. - inline bool internalOrBoundaryPoint() const - { - return internalPoint() || ppMaster(); - } + //- Is point a far-point + inline bool farPoint() const; + + //- Is point internal, i.e. not on boundary + inline bool internalPoint() const; + + //- Is point internal and near the boundary + inline bool nearBoundary() const; + + //- Set the point to be near the boundary + inline void setNearBoundary(); + + //- Is point a mirror point + inline bool mirrorPoint() const; + + //- Either master or slave of pointPair. + inline bool pairPoint() const; + + //- Master of a pointPair is the lowest numbered one. + inline bool ppMaster() const; + + //- Slave of a pointPair is the highest numbered one. + inline bool ppSlave() const; + + //- Either original internal point or master of pointPair. + inline bool internalOrBoundaryPoint() const; + + //- Is point near the boundary or part of the boundary definition + inline bool nearOrOnBoundary() const; + + + // Friend Functions + + //- Do the two given vertices consitute a boundary point-pair + friend bool pointPair <Gt, Vb> + ( + const indexedVertex<Gt, Vb>& v0, + const indexedVertex<Gt, Vb>& v1 + ); + + //- Do the three given vertices consitute a boundary triangle + friend bool boundaryTriangle <Gt, Vb> + ( + const indexedVertex<Gt, Vb>& v0, + const indexedVertex<Gt, Vb>& v1, + const indexedVertex<Gt, Vb>& v2 + ); + + //- Do the three given vertices consitute an outside triangle + friend bool outsideTriangle <Gt, Vb> + ( + const indexedVertex<Gt, Vb>& v0, + const indexedVertex<Gt, Vb>& v1, + const indexedVertex<Gt, Vb>& v2 + ); - //- Is point near the boundary or part of the boundary definition - inline bool nearOrOnBoundary() const - { - return pairPoint() || mirrorPoint() || nearBoundary(); - } - - //- Do the two given vertices consitute a boundary point-pair - inline friend bool pointPair - ( - const indexedVertex& v0, - const indexedVertex& v1 - ) - { - return v0.index_ == v1.type_ || v1.index_ == v0.type_; - } - - //- Do the three given vertices consitute a boundary triangle - inline friend bool boundaryTriangle - ( - const indexedVertex& v0, - const indexedVertex& v1, - const indexedVertex& v2 - ) - { - return (v0.pairPoint() && pointPair(v1, v2)) - || (v1.pairPoint() && pointPair(v2, v0)) - || (v2.pairPoint() && pointPair(v0, v1)); - } - - //- Do the three given vertices consitute an outside triangle - inline friend bool outsideTriangle - ( - const indexedVertex& v0, - const indexedVertex& v1, - const indexedVertex& v2 - ) - { - return (v0.farPoint() || v0.ppSlave()) - || (v1.farPoint() || v1.ppSlave()) - || (v2.farPoint() || v2.ppSlave()); - } }; @@ -259,6 +199,9 @@ public: } // End namespace CGAL +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "indexedVertexI.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/generation/cv2DMesh/indexedVertexI.H b/applications/utilities/mesh/generation/cv2DMesh/indexedVertexI.H new file mode 100644 index 00000000000..6fef3fc7d4b --- /dev/null +++ b/applications/utilities/mesh/generation/cv2DMesh/indexedVertexI.H @@ -0,0 +1,230 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ 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 3 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, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Gt, class Vb> +inline CGAL::indexedVertex<Gt, Vb>::indexedVertex() +: + Vb(), + index_(INTERNAL_POINT), + type_(INTERNAL_POINT) +{} + + +template<class Gt, class Vb> +inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(const Point& p) +: + Vb(p), + index_(INTERNAL_POINT), + type_(INTERNAL_POINT) +{} + + +template<class Gt, class Vb> +inline CGAL::indexedVertex<Gt, Vb>::indexedVertex +( + const Point& p, + const int index, + const int& type +) +: + Vb(p), + index_(index), + type_(type) +{} + + +template<class Gt, class Vb> +inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(const Point& p, Face_handle f) +: + Vb(f, p), + index_(INTERNAL_POINT), + type_(INTERNAL_POINT) +{} + + +template<class Gt, class Vb> +inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(Face_handle f) +: + Vb(f), + index_(INTERNAL_POINT), + type_(INTERNAL_POINT) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Gt, class Vb> +inline int& CGAL::indexedVertex<Gt, Vb>::index() +{ + return index_; +} + + +template<class Gt, class Vb> +inline int CGAL::indexedVertex<Gt, Vb>::index() const +{ + return index_; +} + + +template<class Gt, class Vb> +inline int& CGAL::indexedVertex<Gt, Vb>::type() +{ + return type_; +} + + +template<class Gt, class Vb> +inline int CGAL::indexedVertex<Gt, Vb>::type() const +{ + return type_; +} + + +template<class Gt, class Vb> +inline bool CGAL::indexedVertex<Gt, Vb>::farPoint() const +{ + return type_ == FAR_POINT; +} + + +template<class Gt, class Vb> +inline bool CGAL::indexedVertex<Gt, Vb>::internalPoint() const +{ + return type_ <= INTERNAL_POINT; +} + + +template<class Gt, class Vb> +inline bool CGAL::indexedVertex<Gt, Vb>::nearBoundary() const +{ + return type_ == NEAR_BOUNDARY_POINT; +} + + +template<class Gt, class Vb> +inline void CGAL::indexedVertex<Gt, Vb>::setNearBoundary() +{ + type_ = NEAR_BOUNDARY_POINT; +} + + +template<class Gt, class Vb> +inline bool CGAL::indexedVertex<Gt, Vb>::mirrorPoint() const +{ + return type_ == MIRROR_POINT; +} + + +template<class Gt, class Vb> +inline bool CGAL::indexedVertex<Gt, Vb>::pairPoint() const +{ + return type_ >= 0; +} + + +template<class Gt, class Vb> +inline bool CGAL::indexedVertex<Gt, Vb>::ppMaster() const +{ + if (type_ > index_) + { + return true; + } + else + { + return false; + } +} + + +template<class Gt, class Vb> +inline bool CGAL::indexedVertex<Gt, Vb>::ppSlave() const +{ + if (type_ >= 0 && type_ < index_) + { + return true; + } + else + { + return false; + } +} + + +template<class Gt, class Vb> +inline bool CGAL::indexedVertex<Gt, Vb>::internalOrBoundaryPoint() const +{ + return internalPoint() || ppMaster(); +} + + +template<class Gt, class Vb> +inline bool CGAL::indexedVertex<Gt, Vb>::nearOrOnBoundary() const +{ + return pairPoint() || mirrorPoint() || nearBoundary(); +} + + +// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * // + +template<class Gt, class Vb> +bool CGAL::pointPair +( + const indexedVertex<Gt, Vb>& v0, + const indexedVertex<Gt, Vb>& v1 +) +{ + return v0.index_ == v1.type_ || v1.index_ == v0.type_; +} + + +template<class Gt, class Vb> +bool CGAL::boundaryTriangle +( + const indexedVertex<Gt, Vb>& v0, + const indexedVertex<Gt, Vb>& v1, + const indexedVertex<Gt, Vb>& v2 +) +{ + return (v0.pairPoint() && pointPair(v1, v2)) + || (v1.pairPoint() && pointPair(v2, v0)) + || (v2.pairPoint() && pointPair(v0, v1)); +} + + +template<class Gt, class Vb> +bool CGAL::outsideTriangle +( + const indexedVertex<Gt, Vb>& v0, + const indexedVertex<Gt, Vb>& v1, + const indexedVertex<Gt, Vb>& v2 +) +{ + return (v0.farPoint() || v0.ppSlave()) + || (v1.farPoint() || v1.ppSlave()) + || (v2.farPoint() || v2.ppSlave()); +} -- GitLab