NanoShaper  0.7.2
NanoShaper is a tool able to triangulate and inspect an arbitray triangulated surface or several types of molecular surfaces
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 ExampleSurface ExternalSurface FVanDerWaalsSurface MeshSurface SkinSurface BlobbySurface CoulombicSurface

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, bool computeNormals)=0
virtual void init ()=0
virtual void init (ConfigFile *cf)=0
virtual void clear ()=0
virtual bool getSurf (bool fill=false, double vol=0)
virtual double getVolume ()
virtual double getArea ()
virtual int getCavities (int idStart=STATUS_POINT_TEMPORARY_OUT)
virtual void fillCavities (double vol=0, bool silent=false)
virtual void filterCavities (bool modStatus=false)
virtual void cav2out ()
virtual double triangulateSurface (double iso=0.0, const char *fileName="triangulatedSurf", bool revert=false)
virtual bool saveMesh (int format, bool revert, const char *fileName)
virtual void smoothSurface (const char *fn="triangulatedSurf", bool revert=false)
virtual void preProcessPanel ()
virtual void postRayCasting ()
virtual bool preBoundaryProjection ()
void tri2Balls ()
void backupStatus ()
void removeBackupStatus ()
int linkCavities (short *st1, short *st2)
bool difference (Surface *)
Surfaceoperator-= (Surface &surf2)
void getCavitiesAtoms ()
void setProjBGP (bool flag)
bool getProjBGP ()
double getSternLayer ()
void setSternLayer (double l)
void setSaveMSMS (bool m)
bool getSaveMSMS ()
void setTriangulationFlag (bool flag)
bool getTriangulationFlag ()
void setVertexAtomsMap (bool f)
bool getVertexAtomsMap ()
void setComputeNormals (bool cn)
bool getComputeNormals ()
void setCheckDuplicatedVertices (bool cd)
bool getCheckDuplicatedVertices ()
void setKeepWellShapedCavities (bool kwsc)
bool getKeepWellShapedCavities ()
virtual void setProbeRadius (double probeRadius)
virtual double getProbeRadius ()
virtual double getRandDisplacement ()
virtual void setRandDisplacement (const double r)
virtual void setLoadBalancing (bool doLoadBalancing)
virtual bool getLoadBalancing ()
virtual int getNumTriangles ()
virtual int getNumVertices ()
virtual void setInsideCode (int i)
virtual int getInsideCode ()
virtual ~Surface ()

Protected Member Functions

void floodFill (int ix, int iy, int iz, int idold, int idnew)
void floodFill2 (int ix, int iy, int iz, int idold, int idnew)
void floodFill4 (int ix, int iy, int iz, int idold, int idnew)
void floodFill3 (pair< pair< int, int >, int > ind, pair< int, int > z_limits, pair< int, int > old_new, pair< queue< pair< pair< int, int >, int > > *, queue< pair< pair< int, int >, int > > * > queues, queue< pair< pair< int, int >, int > > *in_queue)
bool innerFloodFill (int *start, int *target, short *status1, short *status2, int &maxMoves, bool debug)
bool vdwAccessible (double *p, int &nearest)
void intersector (double *volPanel, int nb, int start, int end, int jump, int *numIntersections, packet pack)
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)
void getVertices (double isolevel, int start_z, int end_z, int jump, vector< coordVec > *, vector< double * > *)
int classifyCube (double *vertexValues, double isolevel)
void approximateNormals (vector< int > &appNormals, bool doOnlyList)
double triangulationKernel (double isolevel, bool revert, int start_z, int end_z, int jump, vector< int * > *localTriList, double *localArea)
void buildAtomsMap ()
void disposeAtomsMap ()
void applyMultidielectric ()
void swap2multi (double gxmin, double gymin, double gzmin, double gside, unsigned int ggrid, int *gridMultiMap, int i, int j, int k, int l)
void buildSternLayer ()
void allocIntersectionsMatrices ()
void allocNormalsMatrices ()
int deduceFormat ()
 Surface (ConfigFile *cf)

Protected Attributes

int surfType
bool isRCbased
bool providesAnalyticalNormals
bool projBGP
double sternLayer
bool accurateTriangulation
bool fillCavitiesFlag
bool computeNormals
bool checkDuplicatedVertices
bool wellShaped
double probe_radius
bool useLoadBalancing
bool vertexAtomsMapFlag
bool saveMSMS
int panel
DelPhiShareddelphi
double totalSurfaceArea
double totalVolume
int last_rows_ind
int last_cols_ind
double randDisplacement
int last_nx
int last_ny
int last_nz
Octree< int > * intersectionsMatrixAlongX
Octree< int > * intersectionsMatrixAlongY
Octree< int > * intersectionsMatrixAlongZ
Octree< int > * normalsMatrixAlongX
Octree< int > * normalsMatrixAlongY
Octree< int > * normalsMatrixAlongZ
bool * activeCubes
bool *** verticesInsidenessMap
double *** scalarField
bool isAvailableScalarField
vector< int * > triList
vector< double * > vertList
vector< double * > normalsList
double delta_accurate_triangulation
int * bgp_type
int * gridMultiMap
double gxmin
double gymin
double gzmin
double gside
double gscale
unsigned int ggrid
int * gridLoad
int totalLoad
int * vertexAtomsMap
int inside

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:
29/06/2013

Constructor & Destructor Documentation

Surface::~Surface ( ) [virtual]

Destructor


Member Function Documentation

void Surface::allocIntersectionsMatrices ( ) [protected]

clean and alloc intersections

void Surface::allocNormalsMatrices ( ) [protected]

clean and alloc normals

void Surface::applyMultidielectric ( ) [protected]

apply multidielectric correction after grid building. For each internal grid point detect the nearest atom and apply its dielectric constant.

void Surface::approximateNormals ( vector< int > &  appNormals,
bool  doOnlyList 
) [protected]

approximate normals based on the surrounding triangle planes normals

void Surface::backupStatus ( )

save current status map in a temporary map

bool Surface::build ( ) [pure virtual]

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

Implemented in ConnollySurface, SkinSurface, MeshSurface, ExampleSurface, FVanDerWaalsSurface, CoulombicSurface, BlobbySurface, and ExternalSurface.

void Surface::buildAtomsMap ( ) [protected]

build a 3D grid for acellerating nearest atom queries

void Surface::buildSternLayer ( ) [protected]

build stern layer.

void Surface::cav2out ( ) [virtual]

swap cavity status to temporary out

int Surface::classifyCube ( double *  vertexValues,
double  isolevel 
) [inline, protected]

gives MC cube index. If !=-1 then that cube contains triangles

void Surface::clear ( ) [pure virtual]
int Surface::deduceFormat ( ) [protected]

based on provided info decides the best format to save the mesh

bool Surface::difference ( Surface surf)

difference operator: said S1 the first surface (big probe), S2 (small probe) the second surface and S3 the output surface then the difference rule is the following rule: if S1 is not OUT and and S2 is OUT then that's the pocket

void Surface::disposeAtomsMap ( ) [protected]

deallocate memory of the 3D nearest atom query

void Surface::fillCavities ( double  vol = 0,
bool  silent = false 
) [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 ( bool  modStatus = false) [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]

3d cavity detection

queue based implementation

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

scan line version

void Surface::floodFill3 ( pair< pair< int, int >, int >  ind,
pair< int, int >  z_limits,
pair< int, int >  old_new,
pair< queue< pair< pair< int, int >, int > > *, queue< pair< pair< int, int >, int > > * >  queues,
queue< pair< pair< int, int >, int > > *  in_queue 
) [protected]

inner routine for scanline

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

parallel version with scaline

double Surface::getArea ( ) [virtual]

Return the total surface area

int Surface::getCavities ( int  idStart = STATUS_POINT_TEMPORARY_OUT) [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. The input decide wich is the first STATUS code to be checked.

void Surface::getCavitiesAtoms ( )

for each cavity/pocket detect the atoms that compose the cavity

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, ExampleSurface, FVanDerWaalsSurface, and ExternalSurface.

void Surface::getRayIntersection ( double  p1[3],
double  p2[3],
vector< pair< double, double * > > &  intersections,
int  thdID,
bool  computeNormals 
) [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, ExampleSurface, FVanDerWaalsSurface, 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 
) [inline, 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

void Surface::getVertices ( double  isolevel,
int  start_z,
int  end_z,
int  jump,
vector< coordVec > *  vertList,
vector< double * > *  normalsList 
) [inline, protected]

returns the vertices for a given section on z of the grid

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::init ( ) [pure virtual]

function for the constructor without arguments

Implemented in ConnollySurface, SkinSurface, MeshSurface, ExampleSurface, FVanDerWaalsSurface, ExternalSurface, CoulombicSurface, and BlobbySurface.

void Surface::init ( ConfigFile *  cf) [pure virtual]

functions for the constructor with config file argument

Implemented in ConnollySurface, SkinSurface, MeshSurface, ExampleSurface, FVanDerWaalsSurface, ExternalSurface, CoulombicSurface, and BlobbySurface.

bool Surface::innerFloodFill ( int *  start,
int *  target,
short *  status1,
short *  status2,
int &  maxMoves,
bool  debug 
) [protected]

supports inner floodfill inside the 1.4 surface (given status1) to understand if two cavities/pockets are status2-linked (check external communication between two points by looking at status2 map). Gives true if the cavities/pockets comunicate and uses as input two random indices of two cavities/pockets. It stops if a maximal number of moves have been reached. A 'move' means moving from one grid point to another one. In max moves is returned the number of moves done to get the target.

void Surface::intersector ( double *  volPanel,
int  nb,
int  start,
int  end,
int  jump,
int *  numIntersections,
packet  pack 
) [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.

int Surface::linkCavities ( short *  st1,
short *  st2 
)

If between two any cavities there is communication in map st2 and this communication is all internal in map st1 these cavities are merged logically.

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, ExampleSurface, FVanDerWaalsSurface, and ExternalSurface.

Surface & Surface::operator-= ( Surface surf2)

This is a Connolly regularized difference operator. Difference function is called and then Connolly filter is applied such that the noise can be filtered out.

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, MeshSurface, ExampleSurface, and FVanDerWaalsSurface.

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, MeshSurface, ExampleSurface, and FVanDerWaalsSurface.

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, MeshSurface, ExampleSurface, and FVanDerWaalsSurface.

void Surface::printSummary ( ) [pure virtual]

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

Implemented in ConnollySurface, SkinSurface, MeshSurface, ExampleSurface, FVanDerWaalsSurface, CoulombicSurface, 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

void Surface::removeBackupStatus ( )

remove temporary status

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, ExampleSurface, FVanDerWaalsSurface, and ExternalSurface.

bool Surface::saveMesh ( int  format,
bool  revert,
const char *  fileName 
) [virtual]

save mesh in a prescribed format, revert triangles (change plane sign) if requested

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",
bool  revert = false 
) [virtual]

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

void Surface::swap2multi ( double  gxmin,
double  gymin,
double  gzmin,
double  gside,
unsigned int  ggrid,
int *  gridMultiMap,
int  i,
int  j,
int  k,
int  l 
) [protected]

swap the state of a point in the epsmap from internal to the nearest atom dielectric

void Surface::tri2Balls ( )

translate a triangulation (a set of samples) into a set of balls (ray-casting sampling + power crust)

double Surface::triangulateSurface ( double  iso = 0.0,
const char *  fileName = "triangulatedSurf",
bool  revert = false 
) [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 insideness 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

check atoms flag

double Surface::triangulationKernel ( double  isolevel,
bool  revert,
int  start_z,
int  end_z,
int  jump,
vector< int * > *  localTriList,
double *  localArea 
) [inline, protected]

triangulator thread

bool Surface::vdwAccessible ( double *  p,
int &  nearest 
) [protected]

gives true if the point is outside vdw surface

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

marching cubes vertex interpolation


Member Data Documentation

bool* Surface::activeCubes [protected]

mark wich MC cubes contain triangles to allow fast reject in the second pass

int* Surface::bgp_type [protected]

type of bgp for each detected bgp

if enabled loaded surface is checked for duplicated vertices

int* Surface::gridLoad [protected]

pointer to a vector which holds the information about the load for each grid slice

int* Surface::gridMultiMap [protected]

grid multi-dielectric map

int Surface::inside [protected]

DelPhi code for inside.

Octree<int>* Surface::intersectionsMatrixAlongX [protected]

3d matrix of intersections along x rays

Octree<int>* Surface::intersectionsMatrixAlongY [protected]

3d matrix of intersections along y rays

Octree<int>* Surface::intersectionsMatrixAlongZ [protected]

3d matrix of intersections along z rays

bool Surface::isRCbased [protected]

every class at Constructor time must say if it is Ray Casting based or not If it is ray casting based than getSurf will derive the grid based on ray casting if not RC based getSurf will assume that build method has already coloured the grid

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

vector of normal to vertices

Octree<int>* Surface::normalsMatrixAlongX [protected]

3d matrix of normals along x rays

Octree<int>* Surface::normalsMatrixAlongY [protected]

3d matrix of normals along y rays

Octree<int>* Surface::normalsMatrixAlongZ [protected]

3d matrix of normals along z rays

double Surface::probe_radius [protected]

Probe radius. Currently used in the cavity shape filter

every surface at constructor time must say if it will provide analytical normals during ray tracing or not

double Surface::randDisplacement [protected]

how big is the random initial displacement of atoms

int Surface::surfType [protected]

says if the surface represents a molecule, an hybrid system or an object

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: