log.h

Go to the documentation of this file.
00001 // Author: Justin Kinney
00002 // Date: Sep 2008
00003 
00004 #ifndef LOG_H
00005 #define LOG_H 1
00006 
00007 #include <fstream>
00008 
00009 #include <cstdlib>
00010 #include <cstdarg>
00011 #include <cstdio>
00012 #include "meshmorph.h"
00013 
00014 #include "state.h"
00015 
00016 typedef std::map<std::string,double,lts>                             map_s_d;
00017 typedef std::map<std::string,double,lts>::iterator                   sd_it;
00018 
00019 class Log
00020 {
00021 private:
00022   Log                         (void);
00023   Log                         (Log const &);
00024   Log& operator =             (Log const &);
00025   ~Log                        (void);
00026   static Log * only_one;
00027   std::ofstream  Cfile;
00028   std::ofstream  Mfile;
00029   // closest point search
00030   int        num_verts; // # vertices for which closest point has been searched
00031   double   leaves_mean; // mean number of octree leaves visited in search for closest point
00032   int       leaves_min; // min  number of octree leaves visited in search for closest point
00033   int       leaves_max; // max  number of octree leaves visited in search for closest point
00034   double     face_mean; // mean number of faces returned from octree in search for closest point
00035   int         face_min; // min  number of faces returned from octree in search for closest point
00036   int         face_max; // max  number of faces returned from octree in search for closest point
00037   double  f_check_mean; // mean number of faces checked in search for closest point
00038   int      f_check_min; // min  number of faces checked in search for closest point
00039   int      f_check_max; // max  number of faces checked in search for closest point
00040   // vertex scheduling
00041   int         num_sets; // number of vertex sets used in statistics
00042   double      vps_mean; // mean number of vertices per set
00043   int          vps_min; // min  number of vertices per set
00044   int          vps_max; // max  number of vertices per set
00045   // (note not all verts necessarily moved)
00046   double    moved_mean; // mean number of moved vertices per set
00047   int        moved_min; // min  number of moved vertices per set
00048   int        moved_max; // max  number of moved vertices per set
00049   // moved vertices
00050   int                N; // count of moved vertices per group
00051   double         d_min; // min actual displacement
00052   double         d_max; // max actual displacement
00053   vec_d             md; // mean vertex displacement for {N-1,N} vertices of group
00054   double       fs_mean; // mean number of vertices undergoing full closest point search
00055   int           fs_min; // min number of vertices undergoing full closest point search
00056   int           fs_max; // max number of vertices undergoing full closest point search
00057   double       ps_mean; // mean number of vertices undergoing partial closest point search
00058   double        ps_min; // min number of vertices undergoing partial closest point search
00059   double        ps_max; // max number of vertices undergoing partial closest point search
00060 
00061   double        fs_face_change_mean; // number of vertices whose closest faces changed
00062   double        fs_face_change_min;  // number of vertices whose closest faces changed
00063   double        fs_face_change_max;  // number of vertices whose closest faces changed
00064   double        ps_face_change_mean; // number of vertices whose closest faces changed
00065   double        ps_face_change_min;  // number of vertices whose closest faces changed
00066   double        ps_face_change_max;  // number of vertices whose closest faces changed
00067 //  double        fs_mean_face_change_is_adj; // number of new closest faces that are adjacent to moved vertex
00068 //  double        ps_mean_face_change_is_adj; // number of new closest faces that are adjacent to moved vertex
00069   // topN_val[0]: stored virtual displacement as estimated
00070   // before the move for the last moved vertex.
00071   // topN_val[1]: stored virtual displacement as estimated
00072   // after the move for the last moved vertex.
00073   vec_d       topN_val;
00074   // vd_val[0]: stored virtual displacement as estimated
00075   // before the move for the last moved vertex.
00076   // vd_val[1]: stored virtual displacement as estimated
00077   // after the move for the last moved vertex.
00078   vec_d         vd_val;
00079   // sepdis[0]: stored extracellular width as measured
00080   // before the move for the last moved vertex.
00081   // sepdis[1]: stored extracellular width as measured
00082   // after the move for the last moved vertex.
00083   vec_d         sepdis;
00084   //vec_d         p_orig; 
00085   vector3         p_orig; 
00086   vector3 const *  p_new; 
00087   vector3        cp_orig; 
00088   vector3         cp_new; 
00089   vec_i        trouble;
00090   // space partitioning
00091   int        num_faces; // number of faces used in statistics
00092   double      bpf_mean; // mean number of boxes per face
00093   int          bpf_min; // min  number of boxes per face
00094   int          bpf_max; // max  number of boxes per face
00095   int        num_boxes; // number of boxes used in statistics
00096   int  num_empty_boxes; // number of boxes with no faces
00097   double      fpb_mean; // mean number of faces per box
00098   int          fpb_min; // min  number of faces per box
00099   int          fpb_max; // max  number of faces per box
00100   // time
00101   double            t1; // track elapsed time
00102   timeval          tim; // time the main loop
00103   time_t      currtime; // store time
00104 public:
00105   static Log & instance               (void);
00106 
00107   int getN (void)
00108   {
00109     return N;
00110   }
00111 
00112   void    groupInit                   (void);
00113   void    writeVertMoveDistribution   (int const &);
00114   void    writeFiles                  (int const & group);
00115   void    writeSepDistances           (int const &);
00116   void    updateHauss_1               (std::string const &,double const &,map_s_d &);
00117   void    updateHauss_2               (std::string const &,o_it const &,double const &,map_s_d &);
00118   void    updateHauss_1_noself        (std::string const &,double const &,map_s_d &);
00119   void    updateHauss_2_noself        (std::string const &,o_it const &,double const &,map_s_d &);
00120   void    writeCommandSettings        (void);
00121   void    closeFiles                  (void);
00122   void    updateFile                  (int const &,bool,double const &);
00123   void    statusFileInit              (void);
00124   void    writeObjectList             (void);
00125   void    writeObjectData             (void);
00126   //void    updateVertDisplStats        (double const &);
00127   void    updateVertDisplStats        (Vertex * const,vector3 const &);
00128   void    clearVals                   (void);
00129   void    writeMoveSummary            (int const &,int const &);
00130   void    writeRefracted              (int const &);
00131   void    writeRefractedNow           (int const & group,int code);
00132   void    writeIntersected            (int const &);
00133   void    writeNonnice                (int const &);
00134   void    writeVD                     (int const &);
00135   void    writeAD                     (int const & group);
00136   void    printNumNonnice             (std::ostream &) const;
00137   void    printNumInt                 (std::ostream &) const;
00138   void    setTime                     (time_t);
00139   void    openMainFile                (void);
00140   void    recordTime                  (std::string const &);
00141   void    updateBoxesPerFaceStats     (int const &);
00142   void    calculateFacesPerBoxStats   (void);
00143   void    printPartitioningStats      (std::ostream &) const;
00144   void    updateClosestPtStats        (int const &,int const &,int const &);
00145   void    printClosestPtStats         (std::ostream &) const;
00146   void    updateVertexSchedulingStats (int const &);
00147   void    updateMovedVertsFromSet     (void);
00148   void    printVertexSchedulingStats  (std::ostream &) const;
00149   void    updateClosestPtSearchStats  (int const &,int const &,Search_Stats const &);
00150   void    printClosestPtSearchStats   (std::ostream &) const;
00151   void    openOrDie                   (std::ofstream * const handle,std::string str,const int & group);
00152   // originally vtrack
00153   bool    isGood                      (Vertex const * const) const;
00154   void    writeDetailedMoveInfo       (void);
00155   void    printBad                    (Vertex const * const) const;
00156   void    setDetailedInfoPreMove      (Vertex * const); 
00157   void    setDetailedInfoPostMove     (Vertex *); 
00158   //
00159   std::string formatv(char const *fmt, va_list args)
00160   {
00161     char buffer[512];
00162     uint needLen;
00163     va_list argsCopy;
00164     va_copy(argsCopy, args);
00165   
00166     needLen = vsnprintf(buffer, sizeof(buffer), fmt, args);
00167     if (needLen <= sizeof(buffer))
00168     {
00169       va_end(argsCopy);
00170       return std::string(buffer);
00171     }
00172     else
00173     {
00174       char *big_buffer = new char[needLen + 1];
00175       vsnprintf(big_buffer, needLen + 1, fmt, argsCopy);
00176       std::string ret(big_buffer);
00177       delete[] big_buffer;
00178       va_end(argsCopy);
00179       return ret;
00180     }
00181   };
00182   
00183   std::string format(char const *fmt, ...)
00184   {
00185     va_list args;
00186     va_start(args, fmt);
00187     std::string ret(formatv(fmt, args));
00188     va_end(args);
00189     return ret;
00190   };
00191 
00192 };
00193 
00194 
00195 //struct Grid
00196 //{
00197 //  vector3 unit_u;
00198 //  vector3 unit_v;
00199 //  double uv_vert1_u;
00200 //  double uv_vert2[2];
00201 //  Grid(Face*);
00202 //  void computeBarycenter(vector3 &,int,int,Face*);
00203 //};
00204 
00205 #endif

Generated on Fri Feb 13 13:58:10 2009 for meshmorph by  doxygen 1.5.1