mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: simplify treeBoundBox::calcExtremities
STYLE: avoid shadow variable names, add more doxygen markup STYLE: cull some unused code from triangleFuncs
This commit is contained in:
@ -128,13 +128,15 @@ class face
|
||||
|
||||
public:
|
||||
|
||||
//- Return types for classify
|
||||
enum proxType
|
||||
{
|
||||
NONE,
|
||||
POINT, // Close to point
|
||||
EDGE // Close to edge
|
||||
};
|
||||
// Public Typedefs
|
||||
|
||||
//- The proximity classifications
|
||||
enum proxType
|
||||
{
|
||||
NONE = 0, //!< Unknown proximity
|
||||
POINT, //!< Close to point
|
||||
EDGE //!< Close to edge
|
||||
};
|
||||
|
||||
|
||||
// Static Data Members
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -80,13 +81,19 @@ class pyramid
|
||||
|
||||
public:
|
||||
|
||||
// Public Typedefs
|
||||
|
||||
//- The point type
|
||||
typedef Point point_type;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from base polygon and apex point
|
||||
inline pyramid(polygonRef base, const Point& apex);
|
||||
|
||||
//- Construct from Istream
|
||||
inline pyramid(Istream& is);
|
||||
inline explicit pyramid(Istream& is);
|
||||
|
||||
|
||||
// Member Functions
|
||||
@ -112,7 +119,7 @@ public:
|
||||
inline scalar mag(const UList<point>& points) const;
|
||||
|
||||
|
||||
// IOstream operators
|
||||
// IOstream Operators
|
||||
|
||||
friend Istream& operator>> <Point, PointRef, polygonRef>
|
||||
(
|
||||
|
||||
@ -53,29 +53,24 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
|
||||
// Forward Declarations
|
||||
class Istream;
|
||||
class Ostream;
|
||||
class triPoints;
|
||||
class plane;
|
||||
class triPoints;
|
||||
|
||||
template<class Point, class PointRef> class triangle;
|
||||
|
||||
template<class Point, class PointRef>
|
||||
inline Istream& operator>>
|
||||
(
|
||||
Istream&,
|
||||
triangle<Point, PointRef>&
|
||||
);
|
||||
inline Istream& operator>>(Istream&, triangle<Point, PointRef>&);
|
||||
|
||||
template<class Point, class PointRef>
|
||||
inline Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const triangle<Point, PointRef>&
|
||||
);
|
||||
inline Ostream& operator<<(Ostream&, const triangle<Point, PointRef>&);
|
||||
|
||||
|
||||
// Common Typedefs
|
||||
|
||||
//- A triangle using referred points
|
||||
typedef triangle<point, const point&> triPointRef;
|
||||
|
||||
|
||||
@ -88,18 +83,21 @@ class triangle
|
||||
{
|
||||
public:
|
||||
|
||||
// Public typedefs
|
||||
// Public Typedefs
|
||||
|
||||
//- The point type
|
||||
typedef Point point_type;
|
||||
|
||||
//- Storage type for triangles originating from intersecting triangle
|
||||
// with another triangle
|
||||
//- with another triangle
|
||||
typedef FixedList<triPoints, 27> triIntersectionList;
|
||||
|
||||
//- Return types for classify
|
||||
//- The proximity classifications
|
||||
enum proxType
|
||||
{
|
||||
NONE,
|
||||
POINT, // Close to point
|
||||
EDGE // Close to edge
|
||||
NONE = 0, //!< Unknown proximity
|
||||
POINT, //!< Close to point
|
||||
EDGE //!< Close to edge
|
||||
};
|
||||
|
||||
|
||||
@ -141,7 +139,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
PointRef a_, b_, c_;
|
||||
|
||||
@ -187,7 +185,7 @@ public:
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
inline triangle(Istream& is);
|
||||
inline explicit triangle(Istream& is);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -321,7 +321,7 @@ bool Foam::treeBoundBox::contains(const vector& dir, const point& pt) const
|
||||
{
|
||||
// Compare all components against min and max of bb
|
||||
|
||||
for (direction cmpt=0; cmpt<3; ++cmpt)
|
||||
for (direction cmpt=0; cmpt < point::nComponents; ++cmpt)
|
||||
{
|
||||
if (pt[cmpt] < min()[cmpt])
|
||||
{
|
||||
@ -357,68 +357,71 @@ bool Foam::treeBoundBox::contains(const vector& dir, const point& pt) const
|
||||
|
||||
Foam::direction Foam::treeBoundBox::faceBits(const point& pt) const
|
||||
{
|
||||
direction faceBits = 0;
|
||||
direction octant = 0;
|
||||
|
||||
if (pt.x() == min().x())
|
||||
{
|
||||
faceBits |= LEFTBIT;
|
||||
octant |= LEFTBIT;
|
||||
}
|
||||
else if (pt.x() == max().x())
|
||||
{
|
||||
faceBits |= RIGHTBIT;
|
||||
octant |= RIGHTBIT;
|
||||
}
|
||||
|
||||
if (pt.y() == min().y())
|
||||
{
|
||||
faceBits |= BOTTOMBIT;
|
||||
octant |= BOTTOMBIT;
|
||||
}
|
||||
else if (pt.y() == max().y())
|
||||
{
|
||||
faceBits |= TOPBIT;
|
||||
octant |= TOPBIT;
|
||||
}
|
||||
|
||||
if (pt.z() == min().z())
|
||||
{
|
||||
faceBits |= BACKBIT;
|
||||
octant |= BACKBIT;
|
||||
}
|
||||
else if (pt.z() == max().z())
|
||||
{
|
||||
faceBits |= FRONTBIT;
|
||||
octant |= FRONTBIT;
|
||||
}
|
||||
return faceBits;
|
||||
|
||||
return octant;
|
||||
}
|
||||
|
||||
|
||||
Foam::direction Foam::treeBoundBox::posBits(const point& pt) const
|
||||
{
|
||||
direction posBits = 0;
|
||||
direction octant = 0;
|
||||
|
||||
if (pt.x() < min().x())
|
||||
{
|
||||
posBits |= LEFTBIT;
|
||||
octant |= LEFTBIT;
|
||||
}
|
||||
else if (pt.x() > max().x())
|
||||
{
|
||||
posBits |= RIGHTBIT;
|
||||
octant |= RIGHTBIT;
|
||||
}
|
||||
|
||||
if (pt.y() < min().y())
|
||||
{
|
||||
posBits |= BOTTOMBIT;
|
||||
octant |= BOTTOMBIT;
|
||||
}
|
||||
else if (pt.y() > max().y())
|
||||
{
|
||||
posBits |= TOPBIT;
|
||||
octant |= TOPBIT;
|
||||
}
|
||||
|
||||
if (pt.z() < min().z())
|
||||
{
|
||||
posBits |= BACKBIT;
|
||||
octant |= BACKBIT;
|
||||
}
|
||||
else if (pt.z() > max().z())
|
||||
{
|
||||
posBits |= FRONTBIT;
|
||||
octant |= FRONTBIT;
|
||||
}
|
||||
return posBits;
|
||||
|
||||
return octant;
|
||||
}
|
||||
|
||||
|
||||
@ -429,44 +432,23 @@ void Foam::treeBoundBox::calcExtremities
|
||||
point& furthest
|
||||
) const
|
||||
{
|
||||
scalar nearX, nearY, nearZ;
|
||||
scalar farX, farY, farZ;
|
||||
|
||||
if (Foam::mag(min().x() - pt.x()) < Foam::mag(max().x() - pt.x()))
|
||||
for (direction cmpt=0; cmpt < point::nComponents; ++cmpt)
|
||||
{
|
||||
nearX = min().x();
|
||||
farX = max().x();
|
||||
if
|
||||
(
|
||||
Foam::mag(min()[cmpt] - pt[cmpt])
|
||||
< Foam::mag(max()[cmpt] - pt[cmpt])
|
||||
)
|
||||
{
|
||||
nearest[cmpt] = min()[cmpt];
|
||||
furthest[cmpt] = max()[cmpt];
|
||||
}
|
||||
else
|
||||
{
|
||||
nearest[cmpt] = max()[cmpt];
|
||||
furthest[cmpt] = min()[cmpt];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nearX = max().x();
|
||||
farX = min().x();
|
||||
}
|
||||
|
||||
if (Foam::mag(min().y() - pt.y()) < Foam::mag(max().y() - pt.y()))
|
||||
{
|
||||
nearY = min().y();
|
||||
farY = max().y();
|
||||
}
|
||||
else
|
||||
{
|
||||
nearY = max().y();
|
||||
farY = min().y();
|
||||
}
|
||||
|
||||
if (Foam::mag(min().z() - pt.z()) < Foam::mag(max().z() - pt.z()))
|
||||
{
|
||||
nearZ = min().z();
|
||||
farZ = max().z();
|
||||
}
|
||||
else
|
||||
{
|
||||
nearZ = max().z();
|
||||
farZ = min().z();
|
||||
}
|
||||
|
||||
nearest = point(nearX, nearY, nearZ);
|
||||
furthest = point(farX, farY, farZ);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -80,7 +80,6 @@ class treeBoundBox;
|
||||
Istream& operator>>(Istream& is, treeBoundBox& bb);
|
||||
Ostream& operator<<(Ostream& os, const treeBoundBox& bb);
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class treeBoundBox Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -89,18 +88,17 @@ class treeBoundBox
|
||||
:
|
||||
public boundBox
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Static Data Members
|
||||
// Enumerations
|
||||
|
||||
//- Bits used for octant/point encoding.
|
||||
// Every octant/corner point is the combination of three faces.
|
||||
// Every octant/corner point is the combination of three directions.
|
||||
enum octantBit : direction
|
||||
{
|
||||
RIGHTHALF = 0x1,
|
||||
TOPHALF = 0x2,
|
||||
FRONTHALF = 0x4
|
||||
RIGHTHALF = 0x1, //!< 1: positive x-direction
|
||||
TOPHALF = 0x2, //!< 2: positive y-direction
|
||||
FRONTHALF = 0x4 //!< 4: positive z-direction
|
||||
};
|
||||
|
||||
//- Face codes. Identical order and meaning as per hex cellmodel
|
||||
@ -147,6 +145,9 @@ public:
|
||||
E26 = 11
|
||||
};
|
||||
|
||||
|
||||
// Static Data Members
|
||||
|
||||
//- Face to point addressing
|
||||
static const faceList faces;
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ void Foam::triangleFuncs::setIntersection
|
||||
point& pt
|
||||
)
|
||||
{
|
||||
scalar denom = oppositeSign - thisSign;
|
||||
const scalar denom = oppositeSign - thisSign;
|
||||
|
||||
if (mag(denom) < tol)
|
||||
{
|
||||
@ -62,29 +62,8 @@ void Foam::triangleFuncs::setIntersection
|
||||
}
|
||||
|
||||
|
||||
void Foam::triangleFuncs::selectPt
|
||||
(
|
||||
const bool select0,
|
||||
const point& p0,
|
||||
const point& p1,
|
||||
point& min
|
||||
)
|
||||
{
|
||||
if (select0)
|
||||
{
|
||||
min = p0;
|
||||
}
|
||||
else
|
||||
{
|
||||
min = p1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// Intersect triangle with parallel edges aligned with axis i0.
|
||||
// Returns true (and intersection in pInter) if any of them intersects triangle.
|
||||
bool Foam::triangleFuncs::intersectAxesBundle
|
||||
(
|
||||
const point& V0,
|
||||
@ -169,9 +148,6 @@ bool Foam::triangleFuncs::intersectAxesBundle
|
||||
}
|
||||
|
||||
|
||||
// Intersect triangle with bounding box. Return true if
|
||||
// any of the faces of bb intersect triangle.
|
||||
// Note: so returns false if triangle inside bb.
|
||||
bool Foam::triangleFuncs::intersectBb
|
||||
(
|
||||
const point& p0,
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,7 +28,7 @@ Class
|
||||
Foam::triangleFuncs
|
||||
|
||||
Description
|
||||
Various triangle functions.
|
||||
Contains various triangle static functions.
|
||||
|
||||
SourceFiles
|
||||
triangleFuncs.C
|
||||
@ -37,9 +38,6 @@ SourceFiles
|
||||
#ifndef triangleFuncs_H
|
||||
#define triangleFuncs_H
|
||||
|
||||
#include "point.H"
|
||||
#include "label.H"
|
||||
#include "scalar.H"
|
||||
#include "pointField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -47,7 +45,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declaration of classes
|
||||
// Forward Declarations
|
||||
class treeBoundBox;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -56,26 +54,11 @@ class treeBoundBox;
|
||||
|
||||
class triangleFuncs
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration defining nearness classification
|
||||
enum proxType
|
||||
{
|
||||
NONE,
|
||||
POINT,
|
||||
EDGE
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Helper function for intersect. Sets pt to be anywhere on the edge
|
||||
// between oppositeSidePt and thisSidePt depending on both signs.
|
||||
//- Sets pt to be anywhere on the edge between oppositeSidePt
|
||||
//- and thisSidePt depending on both signs.
|
||||
// \note Helper function for intersect()
|
||||
static void setIntersection
|
||||
(
|
||||
const point& oppositeSidePt,
|
||||
@ -86,17 +69,10 @@ private:
|
||||
point& pt
|
||||
);
|
||||
|
||||
//- Helper function.
|
||||
static void selectPt
|
||||
(
|
||||
const bool select0,
|
||||
const point& p0,
|
||||
const point& p1,
|
||||
point& min
|
||||
);
|
||||
|
||||
public:
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Intersect triangle with parallel edges aligned with axis i0.
|
||||
// Returns true (and intersection in pInter) if any of them intersects
|
||||
// triangle. Used in intersectBb.
|
||||
@ -111,7 +87,9 @@ public:
|
||||
point& pInter
|
||||
);
|
||||
|
||||
//- Does triangle intersect bounding box.
|
||||
//- Intersect triangle with bounding box.
|
||||
// \return true if any bounding box faces intersect the triangle,
|
||||
// returns false if the triangle is inside the bounding box
|
||||
static bool intersectBb
|
||||
(
|
||||
const point& p0,
|
||||
@ -120,7 +98,8 @@ public:
|
||||
const treeBoundBox& cubeBb
|
||||
);
|
||||
|
||||
//- Does triangle intersect plane. Return bool and set intersection segment.
|
||||
//- Intersect triangle with plane.
|
||||
// \return bool and set intersection segment.
|
||||
static bool intersect
|
||||
(
|
||||
const point& va0,
|
||||
@ -134,7 +113,8 @@ public:
|
||||
point& pInter1
|
||||
);
|
||||
|
||||
//- Do triangles intersect. Return bool and set intersection segment.
|
||||
//- Intersection of two triangles intersect.
|
||||
// \return bool and set intersection segment.
|
||||
static bool intersect
|
||||
(
|
||||
const point& va0,
|
||||
|
||||
Reference in New Issue
Block a user