58 if (orient && area_ < 0)
120 const triangle2D& triB,
125 const triangle2D& triA = *
this;
138 static int nInter = 0;
139 OFstream
os(
"intersection-tris-"+
Foam::name(nInter++)+
".obj");
151 static FixedList<vector2D, 7> work2;
164 for (
int i0 = 0; i0 <= 2; ++i0)
168 Info<<
"\nstarting points:";
169 for (
int i = 0; i < nPoint2; ++i)
177 const label i1 = (i0 + 1) % 3;
184 for (
int j = 0; j < nPoint2; ++j)
187 const vector2D& p1 = work2[(j+1) % nPoint2];
189 if (triangle2D(c0,
c1,
p0).order() == 1)
191 if (triangle2D(c0,
c1, p1).order() == 1)
193 work_[nPoint++] = p1;
197 if (lineIntersectionPoint(
p0, p1, c0,
c1, intersection))
199 work_[nPoint++] = intersection;
205 if (triangle2D(c0,
c1, p1).order() == 1)
207 if (lineIntersectionPoint(
p0, p1, c0,
c1, intersection))
209 work_[nPoint++] = intersection;
211 work_[nPoint++] = p1;
224 for (
int i = 0; i < nPoint; ++i)
226 os <<
"v " << work_[i].x() <<
" " << work_[i].y() <<
" 0" <<
nl;
229 for (
int i = 0; i < nPoint; ++i)
231 os <<
" " << (i + 1);
236 Info<<
"Intersection points:" <<
endl;
237 for (
int i = 0; i < nPoint; ++i)
248 for (
int i = 0; i < nPoint - 1; ++i)
250 twoArea += work_[i].
x()*work_[i+1].y();
251 twoArea -= work_[i].y()*work_[i+1].x();
254 twoArea += work_[nPoint-1].x()*work_[0].y();
255 twoArea -= work_[nPoint-1].y()*work_[0].x();
257 centre += work_[nPoint - 1];
258 centre /= scalar(nPoint);
270 interArea(triB, dummyCentre,
area);
281 for (
int i = 0; i < 3; ++i)
283 int i1 = (i + 1) % 3;
285 for (
int j = 0; j < 3; ++j)
287 int j1 = (j + 1) % 3;
289 if (lineIntersects(triA[i], triA[i1], triB[j], triB[
j1]))
297 (nClosePoints(triA, triB) == 3)
bool match(const UList< wordRe > &patterns, const std::string &text)
Return true if text matches one of the regular expressions.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A 1D vector of objects of type <T> with a fixed length <N>.
constexpr char nl
The newline '\n' character (0x0a)
Vector2D< scalar > vector2D
A 2D vector of scalars obtained from the generic Vector2D.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static scalar absTol
Absolute tolerance.
dimensionedScalar j1(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
void interArea(const triangle2D &triB, vector2D ¢re, scalar &area) const
Return the intersection centre and area.
const dimensionedScalar e
Elementary charge.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
const wordList area
Standard area field types (scalar, vector, tensor, etc)
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
const Cmpt & x() const noexcept
Access to the vector x component.
virtual const fileName & name() const
Read/write access to the name of the stream.
bool overlaps(const triangle2D &triB) const
Return true if triB overlaps.
triangle2D(const vector2D &a, const vector2D &b, const vector2D &c, const bool orient=false)
Construct from 3 2-D points.
bool isClose(const Vector2D< Cmpt > &b, const scalar tol=1e-10) const
Return true if vector is within tol.
const dimensionedScalar c
Speed of light in a vacuum.
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
static scalar relTol
Relative tolerance.
messageStream Info
Information stream (stdout output on master, null elsewhere)
bool contains(const triangle2D &tri) const
Return true if tri is within this triangle.
label snapClosePoints(const triangle2D &triB)
Snap [this] triangle's points to those of triB if they are within absTol.
A class for managing temporary objects.
const volScalarField & p0
static const Vector2D< scalar > zero
static constexpr const zero Zero
Global zero (0)