Skip to content
Snippets Groups Projects
Commit 6e857fc8 authored by mattijs's avatar mattijs
Browse files

ENH: treDataPrimitivePatch: added self intersection operator

parent 745ca39f
Branches
Tags
No related merge requests found
...@@ -187,6 +187,19 @@ Foam::treeDataPrimitivePatch<PatchType>::findAllIntersectOp::findAllIntersectOp ...@@ -187,6 +187,19 @@ Foam::treeDataPrimitivePatch<PatchType>::findAllIntersectOp::findAllIntersectOp
{} {}
template<class PatchType>
Foam::treeDataPrimitivePatch<PatchType>::
findSelfIntersectOp::findSelfIntersectOp
(
const indexedOctree<treeDataPrimitivePatch<PatchType> >& tree,
const label edgeID
)
:
tree_(tree),
edgeID_(edgeID)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class PatchType> template<class PatchType>
...@@ -645,4 +658,46 @@ bool Foam::treeDataPrimitivePatch<PatchType>::findAllIntersectOp::operator() ...@@ -645,4 +658,46 @@ bool Foam::treeDataPrimitivePatch<PatchType>::findAllIntersectOp::operator()
} }
template<class PatchType>
bool Foam::treeDataPrimitivePatch<PatchType>::findSelfIntersectOp::operator()
(
const label index,
const point& start,
const point& end,
point& intersectionPoint
) const
{
if (edgeID_ == -1)
{
FatalErrorIn
(
"findSelfIntersectOp::operator()\n"
"(\n"
" const label index,\n"
" const point& start,\n"
" const point& end,\n"
" point& intersectionPoint\n"
") const"
) << "EdgeID not set. Please set edgeID to the index of"
<< " the edge you are testing"
<< exit(FatalError);
}
const treeDataPrimitivePatch<PatchType>& shape = tree_.shapes();
const PatchType& patch = shape.patch();
const typename PatchType::FaceType& f = patch.localFaces()[index];
const edge& e = patch.edges()[edgeID_];
if (findIndex(f, e[0]) == -1 && findIndex(f, e[1]) == -1)
{
return findIntersection(tree_, index, start, end, intersectionPoint);
}
else
{
return false;
}
}
// ************************************************************************* // // ************************************************************************* //
...@@ -141,8 +141,8 @@ public: ...@@ -141,8 +141,8 @@ public:
findIntersectOp(const indexedOctree<treeDataPrimitivePatch>& tree); findIntersectOp(const indexedOctree<treeDataPrimitivePatch>& tree);
//- Calculate intersection of triangle with ray. Sets result //- Calculate intersection of any face with ray. Sets result
// accordingly // accordingly. Used to find first intersection.
bool operator() bool operator()
( (
const label index, const label index,
...@@ -167,8 +167,34 @@ public: ...@@ -167,8 +167,34 @@ public:
DynamicList<label>& shapeMask DynamicList<label>& shapeMask
); );
//- Calculate intersection of triangle with ray. Sets result //- Calculate intersection of unique face with ray. Sets result
// accordingly // accordingly. Used to find all faces.
bool operator()
(
const label index,
const point& start,
const point& end,
point& intersectionPoint
) const;
};
class findSelfIntersectOp
{
const indexedOctree<treeDataPrimitivePatch>& tree_;
const label edgeID_;
public:
findSelfIntersectOp
(
const indexedOctree<treeDataPrimitivePatch>& tree,
const label edgeID
);
//- Calculate intersection of face with edge of patch. Excludes
// faces that use edgeID. Used to find self intersection.
bool operator() bool operator()
( (
const label index, const label index,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment