Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   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-2019 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.28 $       $Date: 2019/01/17 21:21:00 $
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) {
00046     return !memcmp(x, c.x, 3L*sizeof(float));
00047   }
00048 };
00049 
00051 struct MSMSFace {
00052   int vertex[3];    
00053 
00054   int surface_type; 
00055 
00056 
00057 
00058   int anaface;      
00059 
00060 
00061   int component;    
00062 
00063   int operator==(const MSMSFace &f) {
00064     return (!memcmp(vertex, f.vertex, 3L*sizeof(float)) &&
00065                     surface_type==f.surface_type && anaface==f.anaface &&
00066                     component==f.component);
00067   }
00068 };
00069 
00072 class MSMSInterface {
00073 private:
00074   void *msms_server;               
00075   static int find_free_port(void); 
00076 
00078   static const char *server_name(void);
00079 
00080   static int start_msms(int port); 
00081 
00083   static void *conn_to_service_port(int portnum);
00084 
00087   int check_for_input(int timeout_in_seconds, int num_reps, int stage);
00088 
00090   int call_msms(float probe_radius, float density,
00091                 int n, float *xyzr, int *flgs);
00092 
00094   int msms_ended(void);
00095 
00097   void close_server(int erno = 0);
00098 
00100   void get_triangulated_ses(int component);
00101 
00105   int get_blocking(char *str, int nbytes);
00106 
00109   char *get_message(char *buffer);
00110 
00111 public:
00112   int err;                         
00113   MSMSInterface(void) { err = 0; }
00114   ResizeArray<int>       atomids;  
00115   ResizeArray<MSMSFace>  faces;    
00116   ResizeArray<MSMSCoord> coords;   
00117   ResizeArray<MSMSCoord> norms;    
00118 
00120   enum {BAD_RANGE = -2, NO_PORTS = -3, NO_CONNECTION = -4,
00121         NO_INITIALIZATION = -5, MSMS_DIED = -6, COMPUTED = 1};
00122   int compute_from_socket(float probe_radius, float density,
00123               int n, int *ids, float *xyzr, int *flgs, int component = 0);
00124 
00126   void clear();
00127 
00128   // use file interface instead of sockets
00129   int compute_from_file(float probe_radius, float density,
00130               int n, int *ids, float *xyzr, int *flgs, int component = 0);
00131 };
00132   
00133 #endif
00134 

Generated on Fri Oct 4 02:44:22 2024 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002