Commit 7c67418a authored by 's avatar

remove ann from processinsertsurface, needs testing

parent 3104922e
......@@ -88,15 +88,11 @@ ADD_NEKTAR_LIBRARY(NekMeshUtils lib ${NEKTAR_LIBRARY_TYPE}
${NEKMESHUTILS_SOURCES} ${NEKMESHUTILS_HEADERS})
TARGET_LINK_LIBRARIES(NekMeshUtils LINK_PUBLIC LocalRegions)
IF(NEKTAR_USE_ANN)
TARGET_LINK_LIBRARIES(NekMeshUtils LINK_PUBLIC ${ANN_LIBRARY})
ENDIF()
IF(NEKTAR_USE_MESHGEN)
TARGET_LINK_LIBRARIES(NekMeshUtils LINK_PRIVATE ${TETGEN_LIBRARY})
TARGET_LINK_LIBRARIES(NekMeshUtils LINK_PUBLIC ${OCC_LIBRARIES})
ADD_DEPENDENCIES(NekMeshUtils oce-0.17 tetgen-1.5 ann-1.1.2)
ADD_DEPENDENCIES(NekMeshUtils oce-0.17 tetgen-1.5)
ENDIF()
IF(NEKTAR_USE_CFI)
......
......@@ -25,6 +25,7 @@ SET(NekMeshHeaders
ProcessModules/ProcessSpherigon.h
ProcessModules/ProcessTetSplit.h
ProcessModules/ProcessOptiExtract.h
ProcessModules/ProcessInsertSurface.h
)
SET(NekMeshSources
......@@ -55,6 +56,7 @@ SET(NekMeshSources
ProcessModules/ProcessSpherigon.cpp
ProcessModules/ProcessTetSplit.cpp
ProcessModules/ProcessOptiExtract.cpp
ProcessModules/ProcessInsertSurface.cpp
)
IF (NEKTAR_USE_CCM)
......@@ -72,11 +74,6 @@ IF (NEKTAR_USE_MESHGEN)
SET(NekMeshSources ${NekMeshSources} InputModules/InputCAD.cpp)
ENDIF (NEKTAR_USE_MESHGEN)
IF (NEKTAR_USE_ANN)
SET(NekMeshHeaders ${NekMeshHeaders} ProcessModules/ProcessInsertSurface.h)
SET(NekMeshSources ${NekMeshSources} ProcessModules/ProcessInsertSurface.cpp)
ENDIF (NEKTAR_USE_ANN)
# Don't use macro -- this way we can just link against NekMeshUtils and
# LocalRegions.
ADD_EXECUTABLE(NekMesh ${NekMeshSources})
......
......@@ -36,7 +36,13 @@
#include <NekMeshUtils/MeshElements/Element.h>
#include "ProcessInsertSurface.h"
#include <ANN/ANN.h>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/index/rtree.hpp>
namespace bg = boost::geometry;
namespace bgi = boost::geometry::index;
using namespace std;
using namespace Nektar::NekMeshUtils;
......@@ -65,6 +71,9 @@ ProcessInsertSurface::~ProcessInsertSurface()
void ProcessInsertSurface::Process()
{
typedef bg::model::point<NekDouble, 3, bg::cs::cartesian> Point;
typedef pair<Point, unsigned int> PointI;
if (m_mesh->m_verbose)
{
cout << "ProcessInsertSurface: Inserting mesh... " << endl;
......@@ -102,27 +111,17 @@ void ProcessInsertSurface::Process()
vector<NodeSharedPtr> inMshnodeList(surfaceNodes.begin(), surfaceNodes.end());
ANNpointArray dataPts;
ANNpoint queryPt;
ANNidxArray nnIdx;
ANNdistArray dists;
ANNkd_tree* kdTree;
queryPt = annAllocPt(3);
dataPts = annAllocPts(inMshnodeList.size(),3);
vector<PointI> dataPts;
for(int i = 0; i < inMshnodeList.size(); i++)
{
dataPts[i][0] = inMshnodeList[i]->m_x;
dataPts[i][1] = inMshnodeList[i]->m_y;
dataPts[i][2] = inMshnodeList[i]->m_z;
dataPts.push_back(make_pair(Point( inMshnodeList[i]->m_x,
inMshnodeList[i]->m_y,
inMshnodeList[i]->m_z), i));
}
kdTree = new ANNkd_tree(dataPts, inMshnodeList.size(), 3);
int sample = 1;
nnIdx = new ANNidx[sample];
dists = new ANNdist[sample];
//Build tree
bgi::rtree<PointI, bgi::rstar<16> > rtree;
rtree.insert(dataPts.begin(), dataPts.end());
surfaceNodes.clear();
for(int i = 0; i < m_mesh->m_element[2].size(); i++)
......@@ -154,36 +153,38 @@ void ProcessInsertSurface::Process()
EdgeSet::iterator it;
for(it = surfEdges.begin(); it != surfEdges.end(); it++)
{
queryPt[0] = (*it)->m_n1->m_x;
queryPt[1] = (*it)->m_n1->m_y;
queryPt[2] = (*it)->m_n1->m_z;
kdTree->annkSearch(queryPt,sample,nnIdx,dists);
Point queryPt1((*it)->m_n1->m_x, (*it)->m_n1->m_y, (*it)->m_n1->m_z);
vector<PointI> result;
rtree.query(bgi::nearest(queryPt1, 1), std::back_inserter(result));
NekDouble dist1 = bg::distance(result[0].first, queryPt1);
if(nonconform)
{
if(sqrt(dists[0]) > tol)
if(dist1 > tol)
continue;
}
else
{
ASSERTL0(sqrt(dists[0]) < tol, "cannot locate point accurately enough");
ASSERTL0(dist1 < tol, "cannot locate point accurately enough");
}
NodeSharedPtr inN1 = inMshnodeList[nnIdx[0]];
NodeSharedPtr inN1 = inMshnodeList[result[0].second];
Point queryPt2((*it)->m_n2->m_x, (*it)->m_n2->m_y, (*it)->m_n2->m_z);
result.clear();
rtree.query(bgi::nearest(queryPt2, 1), std::back_inserter(result));
queryPt[0] = (*it)->m_n2->m_x;
queryPt[1] = (*it)->m_n2->m_y;
queryPt[2] = (*it)->m_n2->m_z;
kdTree->annkSearch(queryPt,sample,nnIdx,dists);
NekDouble dist2 = bg::distance(result[0].first, queryPt2);
if(nonconform)
{
if(sqrt(dists[0]) > tol)
if(dist2 > tol)
continue;
}
else
{
ASSERTL0(sqrt(dists[0]) < tol, "cannot locate point accurately enough");
ASSERTL0(dist2 < tol, "cannot locate point accurately enough");
}
NodeSharedPtr inN2 = inMshnodeList[nnIdx[0]];
NodeSharedPtr inN2 = inMshnodeList[result[0].second];
EdgeSharedPtr tst = boost::shared_ptr<Edge>(new Edge(inN1,inN2));
......
Markdown is supported
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