From 9fc91675b3399eb47ce3e55ba972c9ded4cbd37d Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 21 Jun 2013 12:34:25 +0100 Subject: [PATCH] ENH: surfaceCheck: do self-intersection more efficiently --- .../surface/surfaceCheck/Make/options | 2 + .../surface/surfaceCheck/surfaceCheck.C | 111 ++++++++++-------- 2 files changed, 64 insertions(+), 49 deletions(-) diff --git a/applications/utilities/surface/surfaceCheck/Make/options b/applications/utilities/surface/surfaceCheck/Make/options index 9c7d907888..27e7740a94 100644 --- a/applications/utilities/surface/surfaceCheck/Make/options +++ b/applications/utilities/surface/surfaceCheck/Make/options @@ -1,7 +1,9 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude EXE_LIBS = \ -ltriSurface \ + -lsurfMesh \ -lmeshTools diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index 29707e303c..0e28f5c6c5 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -35,6 +35,7 @@ Description #include "triSurfaceSearch.H" #include "argList.H" #include "OFstream.H" +#include "OBJstream.H" #include "surfaceIntersection.H" #include "SortableList.H" #include "PatchTools.H" @@ -615,8 +616,6 @@ int main(int argc, char *argv[]) subSurf.write(subFileName); } - - return 0; } @@ -654,61 +653,75 @@ int main(int argc, char *argv[]) triSurfaceSearch querySurf(surf); - //{ - // OBJstream intStream("selfInter2.obj"); - // const indexedOctree& tree = querySurf.tree(); - // forAll(surf.edges(), edgeI) - // { - // const edge& e = surf.edges()[edgeI]; - // - // pointIndexHit hitInfo - // ( - // tree.findLine - // ( - // surf.points()[surf.meshPoints()[e[0]]], - // surf.points()[surf.meshPoints()[e[1]]], - // treeDataTriSurface::findSelfIntersectOp - // ( - // tree, - // edgeI - // ) - // ) - // ); - // - // if (hitInfo.hit()) - // { - // Pout<< "Found hit:" << hitInfo.hitPoint() << endl; - // intStream.write(hitInfo.hitPoint()); - // } - // } - //} + const indexedOctree& tree = querySurf.tree(); - surfaceIntersection inter(querySurf); + OBJstream intStream("selfInterPoints.obj"); - if (inter.cutEdges().empty() && inter.cutPoints().empty()) + label nInt = 0; + + forAll(surf.edges(), edgeI) + { + const edge& e = surf.edges()[edgeI]; + + pointIndexHit hitInfo + ( + tree.findLine + ( + surf.points()[surf.meshPoints()[e[0]]], + surf.points()[surf.meshPoints()[e[1]]], + treeDataTriSurface::findSelfIntersectOp + ( + tree, + edgeI + ) + ) + ); + + if (hitInfo.hit()) + { + intStream.write(hitInfo.hitPoint()); + nInt++; + } + } + + if (nInt == 0) { Info<< "Surface is not self-intersecting" << endl; } else { - Info<< "Surface is self-intersecting" << endl; - Info<< "Writing edges of intersection to selfInter.obj" << endl; - - OFstream intStream("selfInter.obj"); - forAll(inter.cutPoints(), cutPointI) - { - const point& pt = inter.cutPoints()[cutPointI]; - - intStream << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() - << endl; - } - forAll(inter.cutEdges(), cutEdgeI) - { - const edge& e = inter.cutEdges()[cutEdgeI]; - - intStream << "l " << e.start()+1 << ' ' << e.end()+1 << endl; - } + Info<< "Surface is self-intersecting at " << nInt + << " locations." << endl; + Info<< "Writing intersection points to " << intStream.name() + << endl; } + + //surfaceIntersection inter(querySurf); + // + //if (inter.cutEdges().empty() && inter.cutPoints().empty()) + //{ + // Info<< "Surface is not self-intersecting" << endl; + //} + //else + //{ + // Info<< "Surface is self-intersecting" << endl; + // Info<< "Writing edges of intersection to selfInter.obj" << endl; + // + // OFstream intStream("selfInter.obj"); + // forAll(inter.cutPoints(), cutPointI) + // { + // const point& pt = inter.cutPoints()[cutPointI]; + // + // intStream << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() + // << endl; + // } + // forAll(inter.cutEdges(), cutEdgeI) + // { + // const edge& e = inter.cutEdges()[cutEdgeI]; + // + // intStream << "l " << e.start()+1 << ' ' << e.end()+1 << endl; + // } + //} Info<< endl; }