Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

MSMSInterface.h

Go to the documentation of this file.
00001 #ifndef MSMSINTERFACE_H
00002 #define MSMSINTERFACE_H
00003 
00004 /***************************************************************************
00005  *cr                                                                       
00006  *cr            (C) Copyright 1995-2008 The Board of Trustees of the           
00007  *cr                        University of Illinois                       
00008  *cr                         All Rights Reserved                        
00009  *cr                                                                   
00010  ***************************************************************************/
00011 
00012 /***************************************************************************
00013  * RCS INFORMATION:
00014  *
00015  *      $RCSfile: MSMSInterface.h,v $
00016  *      $Author: johns $        $Locker:  $             $State: Exp $
00017  *      $Revision: 1.23 $       $Date: 2008/03/27 19:36:40 $
00018  *
00019  ***************************************************************************
00020  * DESCRIPTION:
00021  *  Communicate with the MSMS surface generation program.  For more
00022  * information about MSMS, please see:
00023  * http://www.scripps.edu/pub/olson-web/people/sanner/html/msms_home.html
00024  *
00025  ***************************************************************************/
00026 
00027 // MSMS surface generation process:
00028 //   Find a free port.
00029 //   Start off MSMS server at that port (run process in background)
00030 //   Connect to MSMS server
00031 //   Send coords and get back surface information
00032 //   Pass this data to MSMS server:
00033 //     index, x, y, z, radius, use_atom
00034 //   MSMS server returns this data:
00035 //     face list containing 3 vertex points each
00036 //     atomid, as mapped to input values
00037 //     position list containing x, y, z
00038 //     norm list containing normx, normy, normz
00039 
00040 #include "ResizeArray.h"
00041 
00043 struct MSMSCoord {
00044   float x[3];       
00045   int operator==(const MSMSCoord& c) {return !memcmp(x,c.x,3*sizeof(float));}
00046 };
00047 
00049 struct MSMSFace {
00050   int vertex[3];    
00051 
00052   int surface_type; 
00053 
00054 
00055 
00056   int anaface;      
00057 
00058 
00059   int component;    
00060 
00061   int operator==(const MSMSFace &f) {
00062     return (!memcmp(vertex,f.vertex,3*sizeof(float)) &&
00063                   surface_type==f.surface_type && anaface==f.anaface &&
00064                   component==f.component);}
00065 };
00066 
00069 class MSMSInterface {
00070 private:
00071   void *msms_server;               
00072   static int find_free_port(void); 
00073 
00075   static const char *server_name(void);
00076 
00077   static int start_msms(int port); 
00078 
00080   static void *conn_to_service_port(int portnum);
00081 
00084   int check_for_input(int timeout_in_seconds, int num_reps, int stage);
00085 
00087   int call_msms(float probe_radius, float density,
00088                 int n, float *xyzr, int *flgs);
00089 
00091   int msms_ended(void);
00092 
00094   void close_server(int erno = 0);
00095 
00097   void get_triangulated_ses(int component);
00098 
00102   int get_blocking(char *str, int nbytes);
00103 
00106   char *get_message(char *buffer);
00107 
00108 public:
00109   int err;                         
00110   MSMSInterface(void) { err = 0; }
00111   ResizeArray<int>       atomids;  
00112   ResizeArray<MSMSFace>  faces;    
00113   ResizeArray<MSMSCoord> coords;   
00114   ResizeArray<MSMSCoord> norms;    
00115 
00117   enum {BAD_RANGE = -2, NO_PORTS = -3, NO_CONNECTION = -4,
00118         NO_INITIALIZATION = -5, MSMS_DIED = -6, COMPUTED = 1};
00119   int compute_from_socket(float probe_radius, float density,
00120               int n, int *ids, float *xyzr, int *flgs, int component = 0);
00121 
00123   void clear();
00124 
00125   // use file interface instead of sockets
00126   int compute_from_file(float probe_radius, float density,
00127               int n, int *ids, float *xyzr, int *flgs, int component = 0);
00128 };
00129   
00130 #endif
00131 

Generated on Sat Aug 30 01:26:53 2008 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002