ENH: treDataPrimitivePatch: added self intersection operator

This commit is contained in:
mattijs
2013-06-07 14:36:04 +01:00
parent 745ca39fbe
commit 6e857fc8dc
2 changed files with 85 additions and 4 deletions

View File

@ -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 * * * * * * * * * * * * * //
template<class PatchType>
@ -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;
}
}
// ************************************************************************* //

View File

@ -141,8 +141,8 @@ public:
findIntersectOp(const indexedOctree<treeDataPrimitivePatch>& tree);
//- Calculate intersection of triangle with ray. Sets result
// accordingly
//- Calculate intersection of any face with ray. Sets result
// accordingly. Used to find first intersection.
bool operator()
(
const label index,
@ -167,8 +167,34 @@ public:
DynamicList<label>& shapeMask
);
//- Calculate intersection of triangle with ray. Sets result
// accordingly
//- Calculate intersection of unique face with ray. Sets result
// 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()
(
const label index,