NanoShaper  0.3.1
NanoShaper is a tool able to triangulate and inspect an arbitray triangulated surface or several types of molecular surfaces such as the Gaussian, Skin and the SES
Surface Class Reference

Surface class is the general interface that a surface class should have to be plugged inside DelPhi. Some functions implementations are mandatory such as load, save, build, etc... Note that the surface is not necessarly a molecular surface. Build function computes an internal representation of the surface; getSurf translates that representation in the DelPhi compatible representation. Note that in order to put a new surface in DelPhi a surface must provide epsmap, idebmap, computations of the surface area inside a grid cube, identification and projections of boundary grid points and their surface normals; these computations must be done in getSurf while the surface construction must be performed in build.

. More...

#include <Surface.h>

Inheritance diagram for Surface:
ConnollySurface ExternalSurface MeshSurface SkinSurface BlobbySurface

List of all members.

Public Member Functions

virtual bool build ()=0
virtual bool save (char *fileName)=0
virtual bool load (char *fileName)=0
virtual void printSummary ()=0
virtual bool getProjection (double p[3], double *proj1, double *proj2, double *proj3, double *normal1, double *normal2, double *normal3)=0
virtual void getRayIntersection (double p1[3], double p2[3], vector< pair< double, double * > > &intersections, int thdID)=0
virtual bool getSurf (bool fill=false, double vol=0)
virtual double getVolume ()
virtual int getCavities ()
virtual void fillCavities (double vol=0)
virtual void filterCavities ()
virtual void triangulateSurface (double iso=0.0, const char *fileName="triangulatedSurf.off")
virtual void smoothSurface (const char *fn="triangulatedSurf.off")
virtual void preProcessPanel ()
virtual void postRayCasting ()
virtual bool preBoundaryProjection ()
void setProjBGP (bool flag)
bool getProjBGP ()
void setTriangulationFlag (bool flag)
bool getTriangulationFlag ()
void setCheckDuplicatedVertices (bool cd)
bool getCheckDuplicatedVertices ()
void setKeepWellShapedCavities (bool kwsc)
bool getKeepWellShapedCavities ()
virtual void setProbeRadius (double probeRadius)
virtual double getProbeRadius ()
virtual void setSmoothing (bool r)
virtual bool getSmoothing ()
virtual void updateSurf ()
virtual ~Surface ()

Public Attributes

int inside

Protected Member Functions

void floodFill (int ix, int iy, int iz, int idold, int idnew)
void intersector (double *volPanel, int nb, int start, int end, int *numIntersections, int thdID)
void projector (int start, int end)
char getInsidness (int i, int j, int k, int vertInd)
void vertexInterp (double isolevel, double *p1, double *p2, double valp1, double valp2, double *p)
int getTriangles (double *vertexValues, double **vertexPos, double isolevel, int **triangles, int ix, int iy, int iz, int NX, int NY, int NZ, int **xedge, int **yedge, int **zedge, int **xedge_down, int **yedge_down)

Protected Attributes

int panel
DelPhiShareddelphi
double totalSurfaceArea
double totalVolume
bool projBGP
bool accurateTriangulation
bool smoothing
int last_rows_ind
int last_cols_ind
double **** intersectionsMatrixAlongX
double **** intersectionsMatrixAlongY
double **** intersectionsMatrixAlongZ
bool *** verticesInsidenessMap
double *** scalarField
bool isAvailableScalarField
vector< int * > triList
vector< double * > vertList
double delta_accurate_triangulation
bool checkDuplicatedVertices
bool wellShaped
double probe_radius

Detailed Description

Surface class is the general interface that a surface class should have to be plugged inside DelPhi. Some functions implementations are mandatory such as load, save, build, etc... Note that the surface is not necessarly a molecular surface. Build function computes an internal representation of the surface; getSurf translates that representation in the DelPhi compatible representation. Note that in order to put a new surface in DelPhi a surface must provide epsmap, idebmap, computations of the surface area inside a grid cube, identification and projections of boundary grid points and their surface normals; these computations must be done in getSurf while the surface construction must be performed in build.

.

The global variables in the DelPhiShared object that must be filled are:
idebmap -> salt (in/out) map
epsmap -> dielectric map
ibgp -> indexes of the boundary grid points
scspos -> coordinates of the projected boundary grid points
scsnor -> coordinates of the outside pointing normal vector over the surface in correspondence of boundary grid points
scsarea -> value of the surface area in each cube of the grid where there is a boundary grid point (optional)

If a new surface is defined and it only provides the routines of ray intersection and projection then most information can be still built; in this case one should not overload the getSurf method that in its base implementation is able to use projections/intersections to build almost all info needed by DelPhi to work; however this mode of operating has restrictions in fact only two dielectrics can be used (in/out) and the Stern layer (idebmap) is only in/out; this mode is used in the MeshSurface class where an arbitrary shape is loaded or by the SkinSurface module. Note that there is no need for the surface (or surface patches) to answer in/out queries; indeed in/out is worked out by counting the number of times the ray intersects the surface starting from the outside.

To get a full implementation one has to derive the Surface class and re-implement the interface method load,save,build and getSurf (or ray/projections routine) thus providing all the necessary info to DelPhi solver.

Author:
Sergio Decherchi
Date:
31/12/2011

Constructor & Destructor Documentation

Surface::~Surface ( ) [virtual]

Destructor


Member Function Documentation

bool Surface::build ( ) [pure virtual]

Build the surface internal representation. Returns if the building process was succesful or not

Implemented in ConnollySurface, SkinSurface, MeshSurface, BlobbySurface, and ExternalSurface.

void Surface::fillCavities ( double  vol = 0) [virtual]

Fill the previously detected cavities if their volume is bigger that the passed var. In the baseline implementation the volume is approximated by the number of grid cubes volumes in that cavity. By default all cavities are filled

void Surface::filterCavities ( ) [virtual]

After the cavities are detected and marked this routine filter out the part or the entire cavities that are not able to fit the bounding box of a water molecule. That is we filter the bad shaped cavities

void Surface::floodFill ( int  ix,
int  iy,
int  iz,
int  idold,
int  idnew 
) [protected]

supports cavity detection

queue based implementation

int Surface::getCavities ( ) [virtual]

Compute the cavities of the surface by grid flooding. A list of cavities is returned where each list is a list of triplet of indexes. It is up to the caller to free the memory of the int* pointers

char Surface::getInsidness ( int  i,
int  j,
int  k,
int  vertInd 
) [protected]

return +1 if outside and -1 if inside for the vertex indexed by vertInd belonging to the grid cube given by i,j,k indexes

bool Surface::getProjection ( double  p[3],
double *  proj1,
double *  proj2,
double *  proj3,
double *  normal1,
double *  normal2,
double *  normal3 
) [pure virtual]

Get a projection of a point on the surface. Return projection and normal

Implemented in ConnollySurface, SkinSurface, MeshSurface, and ExternalSurface.

void Surface::getRayIntersection ( double  p1[3],
double  p2[3],
vector< pair< double, double * > > &  intersections,
int  thdID 
) [pure virtual]

Get all the intersections of a ray that goes from P1 to P2 over the surface. The interesctions are returned with increasing distance order. the double in the vector is the t parameter for the intersection of the parametric line and the surface, the double pointer is the normal vector. The management of the memory of the normal is up to the derived class from surface

Implemented in ConnollySurface, SkinSurface, MeshSurface, and ExternalSurface.

bool Surface::getSurf ( bool  fillCav = false,
double  vol = 0 
) [virtual]

Build DelPhi Surface by a specific method. If the defined surface provides at least projection and intersection routines then don't overload this function; it will already provide most of the information needed by DelPhi. The only restrictions are that only two dielectrics are allowed (in/out) and there is no Stern layer. Overload this method if the surface does not provide intersect or project or all information is needed. This mode of operation is used by the MeshSurface class which provides getRayIntersection and getProjection primitives. If requested one can fill cavities by fill flag. In order to use parallel execution ray-tracing is performed using the itersectionFunctor

build epsmap and compute boundary grid points by intersection and projection routines. The minimal number of projections is performed. The ray tracing part is parallelized with boost threading if enabled

Reimplemented in ExternalSurface.

int Surface::getTriangles ( double *  vertexValues,
double **  vertexPos,
double  isolevel,
int **  triangles,
int  ix,
int  iy,
int  iz,
int  NX,
int  NY,
int  NZ,
int **  xedge,
int **  yedge,
int **  zedge,
int **  xedge_down,
int **  yedge_down 
) [protected]

build triangles for marching cubes cell

Given a grid cell and an isolevel, calculate the triangular facets required to represent the isosurface through the cell. Return the number of triangular facets, the matrix triangles will be loaded up with the vertices at most 5 triangular facets. 0 will be returned if the grid cell is either totally above of totally below the isolevel. Can act using interpolation or querying the analytically computed intersection point. In this last case it is garanted that every point of the mesh belongs to the surface; ix,iy,iz are passed in order to query the intersection matrices

double Surface::getVolume ( ) [virtual]

Returns the volume computed during Surface::getSurf computations. This function can be overload to implement a custom volume computation method

Reimplemented in ExternalSurface.

void Surface::intersector ( double *  volPanel,
int  nb,
int  start,
int  end,
int *  numIntersections,
int  thdID 
) [protected]

intersector routine, used to perform partial or full intersections. Usefully used together with boost threading routines. In order to get a 'robust' ray tracer a particular strategy is adopted during ray-tracing. It can happen that, due to numerical imprecisions of the ray-intersection routine or due to problems of the surface (e.g. degenerate triangles, holes, non manifoldness in general) the number of detected intersections is odd. In this case the ray-tracer randomly perturbs the direction of the ray in order to escape from the singularity. If this strategy fails for a given number of trails, the trace of the previous ray is copied to the current one.
In some cases this strategy can also fill small holes in the surface.

bool Surface::load ( char *  fileName) [pure virtual]

Load the surface in a specific class dependent format. Return if loading was succesful or not

Implemented in ConnollySurface, SkinSurface, MeshSurface, and ExternalSurface.

virtual void Surface::postRayCasting ( ) [inline, virtual]

this function is called after ray casting to perform any post processing, such as memory clean-up, after ray casting

Reimplemented in ConnollySurface, SkinSurface, and MeshSurface.

virtual bool Surface::preBoundaryProjection ( ) [inline, virtual]

this function is called before boundary grid projection to perform any pre-processing, such as memory setup-up.

Reimplemented in ConnollySurface, SkinSurface, and MeshSurface.

virtual void Surface::preProcessPanel ( ) [inline, virtual]

this function is called before the ray tracing of the panel. It can be useful if a per panel pre-processing step is needed. By default this function does nothing

Reimplemented in ConnollySurface, SkinSurface, and MeshSurface.

void Surface::printSummary ( ) [pure virtual]

Print a summary of the surface type, status and other stuff

Implemented in ConnollySurface, SkinSurface, MeshSurface, BlobbySurface, and ExternalSurface.

void Surface::projector ( int  start,
int  end 
) [protected]

projector routine, used to perform partial or full intersections. Usefully used together with boost threading routines

bool Surface::save ( char *  fileName) [pure virtual]

Save the surface in a specific class dependent format. Return if saving was succesful or not

Implemented in ConnollySurface, SkinSurface, MeshSurface, and ExternalSurface.

void Surface::setProjBGP ( bool  flag) [inline]

Set if surface has to project bgp or not. During cavity detection/surface visualization/triangulation bgp projection can be skipped

void Surface::smoothSurface ( const char *  fn = "triangulatedSurf.off") [virtual]

smooth a given mesh and overwrites the given file name. The input/output mesh is in .off format

void Surface::triangulateSurface ( double  iso = 0.0,
const char *  fileName = "triangulatedSurf.off" 
) [virtual]

Triangulate the surface and save it in OFF format. In the Surface class the baseline method for triangulation is obtained by employing the marching cube method at each delphi grid cell. For each vertex in the grid cube its insidness is computed by voting of the insidness values of the incident cubes; thus the scalar field is given by the ensemble of the status map. The surface is saved in off format

void Surface::updateSurf ( ) [virtual]

Giving the list of changed atoms the surface gets updated and DelPhi information is updated accordingly. This function should be implemented only by molecular surfaces definitions

void Surface::vertexInterp ( double  isolevel,
double *  p1,
double *  p2,
double  valp1,
double  valp2,
double *  p 
) [protected]

marching cubes vertex interpolation


Member Data Documentation

if enabled loaded surface is checked for duplicated vertices

DelPhi code for inside.

double**** Surface::intersectionsMatrixAlongX [protected]

this 3D matrix is used if a precise triangulation is needed

double**** Surface::intersectionsMatrixAlongY [protected]

this 3D matrix is used if a precise triangulation is needed

double**** Surface::intersectionsMatrixAlongZ [protected]

this 3D matrix is used if a precise triangulation is needed

double Surface::probe_radius [protected]

Probe radius. Currently used in the cavity shape filter

vector<int*> Surface::triList [protected]

vector of vertex indices for the traingulation obtained by triangulateSurface function

vector<double*> Surface::vertList [protected]

vector of triangle vertices

bool Surface::wellShaped [protected]

if enabled the part of the cavities (or the entire cavities) that are not shaped as a water molecule are removed


The documentation for this class was generated from the following files: