diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/CGALTriangulation3Ddefs.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/CGALTriangulation3Ddefs.H index 8efb9ec711..3176e4dec4 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/CGALTriangulation3Ddefs.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/CGALTriangulation3Ddefs.H @@ -72,6 +72,48 @@ typedef Delaunay::Cell_handle Cell_handle; typedef Delaunay::Point Point; +//- Spatial sort traits to use with a pair of point pointers and an integer. +// Taken from a post on the CGAL lists: 2010-01/msg00004.html by +// Sebastien Loriot (Geometry Factory). +template +struct Traits_for_spatial_sort +: + public Triangulation::Geom_traits +{ + typedef typename Triangulation::Geom_traits Gt; + + typedef std::pair Point_3; + + struct Less_x_3 + { + bool operator()(const Point_3& p, const Point_3& q) const + { + return typename Gt::Less_x_3()(*(p.first), *(q.first)); + } + }; + + struct Less_y_3 + { + bool operator()(const Point_3& p, const Point_3& q) const + { + return typename Gt::Less_y_3()(*(p.first), *(q.first)); + } + }; + + struct Less_z_3 + { + bool operator()(const Point_3& p, const Point_3& q) const + { + return typename Gt::Less_z_3()(*(p.first), *(q.first)); + } + }; + + Less_x_3 less_x_3_object () const {return Less_x_3();} + Less_y_3 less_y_3_object () const {return Less_y_3();} + Less_z_3 less_z_3_object () const {return Less_z_3();} +}; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 58d061b8f7..f9516c09a7 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -316,16 +316,16 @@ void Foam::conformalVoronoiMesh::insertPoints // using the range insert (faster than inserting points one by one) insert(points.begin(), points.end()); - // Info<< "USING INDIVIDUAL INSERTION TO DETECT FAILURE" << endl; - // for - // ( - //List:list::iterator pit=points.begin(); - // pit != points.end(); - // ++pit - // ) - // { - // insertPoint(topoint(*pit), Vb::vtInternal); - // } +// Info<< "USING INDIVIDUAL INSERTION TO DETECT FAILURE" << endl; +// for +// ( +// List::iterator pit=points.begin(); +// pit != points.end(); +// ++pit +// ) +// { +// insertPoint(topoint(*pit), Vb::vtInternal); +// } label nInserted(number_of_vertices() - preInsertionSize); @@ -395,31 +395,14 @@ void Foam::conformalVoronoiMesh::insertPoints // << " points in total" << endl; } - // Using index is actually pointless, it is always zero. Keep for clarity - // of code. - - forAll(pts, pI) - { - // creation of points and indices is done assuming that it will be - // relative to the instantaneous number_of_vertices() at insertion. - - label type = types[pI]; - - if (type > Vb::vtFar) - { - // This is a member of a point pair, don't use the type directly - // (note that this routine never gets called for referredPoints - // so type will never be -procI) - type += number_of_vertices(); - } - - insertPoint - ( - pts[pI], - indices[pI] + number_of_vertices(), - type - ); - } + rangeInsertWithInfo + ( + pts.begin(), + pts.end(), + *this, + indices, + types + ); } @@ -1202,6 +1185,8 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh featureVertices_(), featurePointLocations_(), featurePointTreePtr_(), + edgeLocationTreePtr_(), + surfacePtLocationTreePtr_(), sizeAndAlignmentLocations_(), storedSizes_(), storedAlignments_(), diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index 2e38a504e1..a51e5a595f 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -48,6 +48,7 @@ SourceFiles #define CGAL_INEXACT #include "CGALTriangulation3Ddefs.H" +#include #include "uint.H" #include "ulong.H" #include "searchableSurfaces.H" @@ -164,6 +165,14 @@ private: //- Search tree for feature point locations mutable autoPtr > featurePointTreePtr_; + //- Search tree for edge point locations + mutable autoPtr > + edgeLocationTreePtr_; + + //- Search tree for surface point locations + mutable autoPtr > + surfacePtLocationTreePtr_; + //- Store locations where the cell size and alignments will be // pre-calculated and looked up pointField sizeAndAlignmentLocations_; @@ -244,6 +253,12 @@ private: const Foam::point& pt ) const; + //- Return the square of the local surface point exclusion distance + inline scalar surfacePtExclusionDistanceSqr + ( + const Foam::point& pt + ) const; + //- Return the square of the local surface search distance inline scalar surfaceSearchDistanceSqr(const Foam::point& pt) const; @@ -664,9 +679,41 @@ private: //- Check if a surface point is near another. bool nearSurfacePoint ( - const pointIndexHit& pHit, - DynamicList& existingSurfacePtLocations, - dynamicIndexedOctree& surfacePtLocationTree + pointIndexHit& pHit, + label& surfaceHit, + DynamicList& existingSurfacePtLocations + ) const; + + //- Append a point to the surface point tree and the existing list + bool appendToSurfacePtTree + ( + const Foam::point& pt, + DynamicList& existingSurfacePtLocations + ) const; + + //- Append a point to the edge location tree and the existing list + bool appendToEdgeLocationTree + ( + const Foam::point& pt, + DynamicList& existingEdgeLocations + ) const; + + //- Check if a point is near any feature edge points. + bool pointIsNearFeatureEdge(const Foam::point& pt) const; + + bool pointIsNearFeatureEdge + ( + const Foam::point& pt, + pointIndexHit& info + ) const; + + //- Check if a point is near any surface conformation points. + bool pointIsNearSurfaceLocation(const Foam::point& pt) const; + + bool pointIsNearSurfaceLocation + ( + const Foam::point& pt, + pointIndexHit& info ) const; //- Check if a location is in the exclusion range of an existing feature @@ -674,17 +721,20 @@ private: bool nearFeatureEdgeLocation ( pointIndexHit& pHit, - DynamicList& newEdgeLocations, - DynamicList& existingEdgeLocations, - dynamicIndexedOctree& edgeLocationTree + DynamicList& existingEdgeLocations ) const; - //- Build or rebuild the edgeLocationTree -// void buildEdgeLocationTree -// ( -// autoPtr >& edgeLocationTree, -// const pointField& existingEdgeLocations -// ) const; + //- Build or rebuild the edge location tree + void buildEdgeLocationTree + ( + const DynamicList& existingEdgeLocations + ) const; + + //- Build or rebuild the surface point location tree + void buildSurfacePtLocationTree + ( + const DynamicList& existingSurfacePtLocations + ) const; //- Build or rebuild the sizeAndAlignmentTree void buildSizeAndAlignmentTree() const; @@ -705,9 +755,7 @@ private: DynamicList