//! file="amma/Surf3d/SurfNear/SurfNear.hh" //! lib=surfnear //! userlevel=Default //! author="Adrian Hilton" //! rcsid="$Id: SurfNear.hh,v 1.8 1999/03/29 11:17:34 ees1cg Exp $" //! date="10/06/96" //! docentry="default.Adrian Hilton" // // Nearest Node/Point Correspondence for Surface to any Point in 3D Space #ifndef SURFACE_NEAR #define SURFACE_NEAR #define SURFACE_NEAR_INLINE inline #include "amma/Vector3d.hh" #include "amma/Plan3PVV.hh" #include "amma/MeanCo3d.hh" //#include "amma/Nearest.hh" #include "amma/BuckList.hh" #include "amma/Surface.hh" //#include "amma/SurfElem.hh" class ElementC; //class SurfaceC; //----------------------------------------------------- class SurfaceNearestPointC { public: SurfaceNearestPointC(); SurfaceNearestPointC(const SurfaceNearestPointC& p); SurfaceNearestPointC(const SurfaceNearestPointT& p); const SurfaceNearestPointC operator=(const SurfaceNearestPointC p); IntT Valid() const; IntT& Valid(); IntT Node() const; IntT& Node(); IntT Bound() const; IntT& Bound(); Vector3dC Vector() const; Vector3dC& Vector(); Vector3dC Normal() const; Vector3dC& Normal(); RealT Distance() const; RealT& Distance(); RealT SignedDistance() const; RealT& SignedDistance(); SurfaceNearestPointT NearestPoint() const; private: SurfaceNearestPointT np; }; //----------------------------------------------------- class SurfaceNearestC { public: SurfaceNearestC(); // empty SurfaceNearestC(SurfaceC& s); // Construct a structure for Nearest Point Computation // Default parameters: // plane = (x,y) // du = minimum edge length // n = sqrt(no. of elements) SurfaceNearestC(SurfaceC& s, const OrthoProjection3to2dC plane, const Point2dC du,const Index2dC n); // Construct a structure for Nearest Point Computation // 2D reference plane 'plane' // grid size 'n' in 2D plane // grid resolution 'du' in 2D plane SurfaceNearestC(const SurfaceNearestC& nn); // copy const SurfaceNearestC operator=(const SurfaceNearestC& nn); // assignment SurfaceNearestPointC NearestPoint(const Vector3dC v); // Nearest point on surface to v SurfaceNearestPointC NearestPoint(const Vector3dC v,const RealT dmax); // Local nearest point up to distnace dmax from v SurfaceNearestPointC NearestPoint(const Vector3dC v,const IntT nmax); // Local nearest point up to nmax buckets from v private: Bucket3to2dC bucket; // lookup table for element based nn SurfaceC temp_surface; // reqd for default const SurfaceC& surface; //SurfaceC surface; // reference to this surface (not & for default constructor( #if defined(VISUAL_CPP) || defined(__sgi__) || defined(NEWGCC) static const IntT mark; #else const IntT mark = 1; #endif // Use element once only in nearest point calculation // mark/unmark elements 1/0 // void SetupNodeBased(); // Nearest Neighbours based on surface nodes // NearestC nearest_node; void SetupElementBased(); // Nearest Neighbours based on surface elements // Default parameters: // plane = best fit plane to node positions // du = minimum edge length // n = sqrt(no. of elements) void SetupElementBased(const OrthoProjection3to2dC plane, const Point2dC du,const Index2dC n); // Setup with specified parameters PlanePVV3dC FitPlane(); // Best fit plane to element nodes (1st 2 eigenvectors of cov.) void InsertElements(); // insert pointers to elem in all overlapped buckets in ref plane void MinMaxElement(ElementC& elem,Index2dC& imin,Index2dC& imax); // bounding box of element in 2D ref. plane void FillBuckets(ElementC& elem,Index2dC& imin,Index2dC& imax); // insert pointer to elem in all buckets in square imin-> imax (inclusive) //SurfaceNearestPointT NearestPoint(const Index2dC i); // nearest point in bucket i SurfaceNearestPointC NearestPoint(const Vector3dC v, const Index2dC ind,const IntT i); // nearest point in bucket i +/- i void UnmarkElements(const Index2dC i, const IntT n); // unmark all elements in bucket i +/- n-1 }; #ifdef SURFACE_NEAR_INLINE #include "amma/SurfNear.icc" #endif #endif