log.cc

Go to the documentation of this file.
00001 #include "log.h"
00002 
00003 #include <sys/time.h>
00004 
00005 #include <cassert>
00006 #include <cmath>
00007 #include <iostream>
00008 
00009 #include "box.h"
00010 #include "container.h"
00011 #include "edge.h"
00012 #include "face.h"
00013 #include "gain_schedule.h"
00014 #include "intersecting_faces.h"
00015 #include "misc.h"
00016 #include "nice.h"
00017 #include "object.h"
00018 #include "refractory.h"
00019 #include "state.h"
00020 #include "space.h"
00021 #include "vertex.h"
00022 #include "vertex_schedule.h"
00023 #include "virtual_disp.h"
00024 
00025 using std::cout;
00026 using std::endl;
00027 using std::left;
00028 using std::right;
00029 
00030 Log * Log::only_one = NULL;
00031 
00032 Log & Log::instance()
00033 {
00034   // Not thread-safe.
00035   // -- lock mutex
00036   if (only_one == NULL)
00037     only_one = new Log();
00038   // -- unlock mutex
00039   return *only_one;
00040 }
00041 
00042 Log::Log (void)
00043   :Olist(),Cfile(),Mfile(),num_verts(0),box_mean(0),box_min(1000000),
00044   box_max(-1000000),face_mean(0),face_min(1000000),face_max(-1000000),
00045   num_sets(0),vps_mean(0),vps_min(1000000),vps_max(-1000000),
00046   N(0),touch_histo_freq(0),interval(0),d_min(1E30),d_max(-1E30),md(2,0),
00047   vv(0),topN_val(2,0),vd_val(2,0),sepdis(2,0),p_orig(3,-1.0),
00048   p_new(3,-1.0),cp_orig(3,-1.0),cp_new(3,-1.0),trouble(0),
00049   num_faces(0),bpf_mean(0),bpf_min(1000000),bpf_max(-1000000),
00050   num_boxes(0),num_empty_boxes(0),fpb_mean(0),fpb_min(1000000),fpb_max(-1000000),
00051   t1(0),tim(),currtime()
00052 {
00053   setTime(time(NULL));
00054   mainFileInit();
00055 }
00056 
00057 
00058 Log::Log (const Log& rhs)
00059   :Olist(),Cfile(),Mfile(),num_verts(0),box_mean(0),box_min(1000000),
00060   box_max(-1000000),face_mean(0),face_min(1000000),face_max(-1000000),
00061   num_sets(0),vps_mean(0),vps_min(1000000),vps_max(-1000000),
00062   N(0),touch_histo_freq(0),interval(0),d_min(1E30),d_max(-1E30),md(2,0),
00063   vv(0),topN_val(2,0),vd_val(2,0),sepdis(2,0),p_orig(3,-1.0),
00064   p_new(3,-1.0),cp_orig(3,-1.0),cp_new(3,-1.0),trouble(0),
00065   num_faces(0),bpf_mean(0),bpf_min(1000000),bpf_max(-1000000),
00066   num_boxes(0),num_empty_boxes(0),fpb_mean(0),fpb_min(1000000),fpb_max(-1000000),
00067   t1(0),tim(),currtime()
00068 {
00069   cout << "Copy constructor prohibited on instances of Log class.\n";
00070   cout << "Log " << rhs.N << endl;
00071   exit(0);
00072 }
00073 
00074 Log& Log::operator = (const Log& rhs)
00075 {
00076   cout << "Assignment operator prohibited on instances of Log class.\n";
00077   cout << "VTRack " << rhs.N << endl;
00078   exit(0);
00079 }
00080 
00081 void Log::groupInit (void)
00082 {
00083   // intialize vertex displacement stats
00084   clearVals();
00085   // initialize variable used to track how many times each vertex was moved
00086   touch_histo_freq = 0;
00087   // track elapsed time
00088   gettimeofday(&tim,NULL);
00089   t1=tim.tv_sec+(tim.tv_usec/1000000.0);
00090 }
00091 
00092 void Log::updateStatsAndPrint (void)
00093 {
00094   // update container stats
00095   updateStats(sqrt(State::instance().getVD2()));
00096   // print number of times each vertex has been moved
00097   if(!WRITE_MESH_EVERY_ITERATION && touch_histo_freq==VERTEX_TOUCH_HISTOGRAM_FREQUENCY)
00098   {
00099     touch_histo_freq = 0;
00100     printVertexSelect(++interval);
00101   }
00102   // print to stdout
00103   //if(!((Vertex_Schedule::instance().count-1)%1000))
00104   //if(Vertex_Schedule::instance().getNumMovedVertsGroup()-1)
00105   //{
00106   //  if(PRINT_FLAG)
00107   //  {
00108   //    char name[1024];
00109   //    sprintf(name,"bpf (%.6g,%.6g,%.6g), ",bpf_min,bpf_mean,bpf_max);
00110   //    cout << left << name;
00111   //    sprintf(name,"fpb (%.6g,%.6g,%.6g), ",fpb_min,fpb_mean,fpb_max);
00112   //    cout << left << name;
00113   //  }
00114   //}
00115 }
00116 
00117 void Log::printVertexSelect (const int group)
00118 {
00119   int zero=0;
00120   // open log file
00121   char sint[128];
00122   sprintf(sint,".%d",group);
00123   str line(sint);
00124   str file = OUTPUT_DATA_DIR + VERTEX_SELECTION_FILE + line;
00125   std::ofstream this_file (file.c_str());
00126   //for(o_it i=Container::instance().o.begin();i!=Container::instance().o.end();i++)
00127   for(o_cit i=Container::instance().o.begin();i!=Container::instance().o.end();i++)
00128   {
00129     //for(v_it j=i->v.begin();j!=i->v.end();j++)
00130     for(v_cit j=i->v.begin();j!=i->v.end();j++)
00131     {
00132       //vhm_it t = Refractory::instance().touch_map.find(const_cast<Vertex*>(&(*j)));
00133       // if vertex was touched
00134       if(Refractory::instance().vertexInTouchMap(const_cast<Vertex*>(&(*j)))==true)
00135       {
00136         this_file << Refractory::instance().numVertexTouches(const_cast<Vertex*>(&(*j))) << endl;
00137       }
00138       else
00139       {
00140         this_file << zero << endl;
00141       }
00142     }
00143   }
00144   this_file.close();
00145 }
00146 
00147 //void Log::getFacesPerBox (void)
00148 //{
00149 //  fpb_min = 1E30;
00150 //  fpb_max = -1E30;
00151 //  int n=0;
00152 //  double summ=0;
00153 //  // for each box in space
00154 //  //for (b_it i=s.b.begin();i!=s.b.end();i++)
00155 //  for (b_cit i=Space::instance().begin();i!=Space::instance().end();i++)
00156 //  {
00157 //    int a = i->getNumFaces();
00158 //    if(a)
00159 //    {
00160 //      n++;
00161 //      summ+=a;
00162 //      if(a>fpb_max){fpb_max=a;} 
00163 //      if(a<fpb_min){fpb_min=a;} 
00164 //    }
00165 //  }
00166 //  fpb_mean=summ/n;
00167 //}
00168 
00169 void Log::writeSepDistances (const int group)
00170 {
00171   //cout << "Writing separation distances to files..........";
00172   //cout.flush();
00173   str file,
00174         file_NOCP,
00175         file_haus1,
00176         file_haus2,
00177         file_haus1_noself,
00178         file_haus2_noself;
00179   // create output filename
00180   if (APPEND_ITERATION_NUMBER_TO_DISTANCES)
00181   {
00182     char sint[128];
00183     str line;
00184     sprintf(sint,"closest_point_distances_%i.dat",group);
00185     line = sint;
00186     file = OUTPUT_DATA_DIR + line;
00187     sprintf(sint,"closest_point_distances_NOCP_%i.dat",group);
00188     line = sint;
00189     file_NOCP = OUTPUT_DATA_DIR + line;
00190     sprintf(sint,"closest_point_distances_one_sided_hausdorff_%i.dat",group);
00191     line = sint;
00192     file_haus1 = OUTPUT_DATA_DIR + line;
00193     sprintf(sint,"closest_point_distances_two_sided_hausdorff_%i.dat",group);
00194     line = sint;
00195     file_haus2 = OUTPUT_DATA_DIR + line;
00196     sprintf(sint,"closest_point_distances_one_sided_hausdorff_noself_%i.dat",group);
00197     line = sint;
00198     file_haus1_noself = OUTPUT_DATA_DIR + line;
00199     sprintf(sint,"closest_point_distances_two_sided_hausdorff_noself_%i.dat",group);
00200     line = sint;
00201     file_haus2_noself = OUTPUT_DATA_DIR + line;
00202   }
00203   else
00204   {
00205     char sint[128];
00206     str line;
00207     sprintf(sint,"closest_point_distances.dat");
00208     line = sint;
00209     file = OUTPUT_DATA_DIR + line;
00210     sprintf(sint,"closest_point_distances_NOCP.dat");
00211     line = sint;
00212     file_NOCP = OUTPUT_DATA_DIR + line;
00213     sprintf(sint,"closest_point_distances_one_sided_hausdorff.dat");
00214     line = sint;
00215     file_haus1 = OUTPUT_DATA_DIR + line;
00216     sprintf(sint,"closest_point_distances_two_sided_hausdorff.dat");
00217     line = sint;
00218     file_haus2 = OUTPUT_DATA_DIR + line;
00219     sprintf(sint,"closest_point_distances_one_sided_hausdorff_noself.dat");
00220     line = sint;
00221     file_haus1_noself = OUTPUT_DATA_DIR + line;
00222     sprintf(sint,"closest_point_distances_two_sided_hausdorff_noself.dat");
00223     line = sint;
00224     file_haus2_noself = OUTPUT_DATA_DIR + line;
00225   }
00226   // open output files
00227   std::ofstream out,
00228         out_NOCP,
00229         out_haus1,
00230         out_haus2,
00231         out_haus1_noself,
00232         out_haus2_noself;
00233   out.open (file.c_str());
00234   if(out.fail())
00235   {
00236     fprintf(stderr,"\nCouldn't open output file %s\n",file.c_str());
00237     exit(0);
00238   }
00239   out_NOCP.open (file_NOCP.c_str());
00240   if(out_NOCP.fail())
00241   {
00242     fprintf(stderr,"\nCouldn't open output file %s\n",file_NOCP.c_str());
00243     exit(0);
00244   }
00245   out_haus1.open (file_haus1.c_str());
00246   if(out_haus1.fail())
00247   {
00248     fprintf(stderr,"\nCouldn't open output file %s\n",file_haus1.c_str());
00249     exit(0);
00250   }
00251   out_haus2.open (file_haus2.c_str());
00252   if(out_haus2.fail())
00253   {
00254     fprintf(stderr,"\nCouldn't open output file %s\n",file_haus2.c_str());
00255     exit(0);
00256   }
00257   out_haus1_noself.open (file_haus1_noself.c_str());
00258   if(out_haus1_noself.fail())
00259   {
00260     fprintf(stderr,"\nCouldn't open output file %s\n",file_haus1_noself.c_str());
00261     exit(0);
00262   }
00263   out_haus2_noself.open (file_haus2_noself.c_str());
00264   if(out_haus2_noself.fail())
00265   {
00266     fprintf(stderr,"\nCouldn't open output file %s\n",file_haus2_noself.c_str());
00267     exit(0);
00268   }
00269   out.precision(4);
00270   out_NOCP.precision(4);
00271   out_haus1.precision(4);
00272   out_haus2.precision(4);
00273   out_haus1_noself.precision(4);
00274   out_haus2_noself.precision(4);
00275   out_NOCP << "x_coordinate y_coordinate z_coordinate state_value x_normal y_normal z_normal\n";
00276   // declare variables
00277   int total_vertices=0,vertices_used=0,vertices_used_noself=0;
00278   sd_it w,x;
00279   str ss,t;
00280   map_s_d hausdorff_2_noself; // create map: string->double
00281   map_s_d hausdorff_2;        // create map: string->double
00282   map_s_d hausdorff_1_noself; // create map: string->double
00283   map_s_d hausdorff_1;        // create map: string->double
00284   vec_d storage_1_noself;
00285   vec_d storage_2_noself;
00286   vec_d storage_1;
00287   vec_d storage_2;
00288   // for each object
00289   for(o_it i=Container::instance().o.begin();i!=Container::instance().o.end();i++)
00290   {
00291     hausdorff_1.clear();
00292     hausdorff_1_noself.clear();
00293     // for each vertex in object
00294     for(v_it j=i->v.begin();j!=i->v.end();j++)
00295     {
00296       total_vertices++;
00297       // if vertex has a closest face
00298       if(j->getFace()!=NULL)
00299       {
00300         vertices_used++;
00301         // get closest point
00302         //double pC[3];
00303         //vec_d pC = Container::instance().getNearPtOnFaceToVertex(j->getFace(),&(*j));
00304         vec_fp fp(1,const_cast<Face*>(j->getFace()));
00305         vec_d p;
00306         double sqd=0.0;
00307         Face *ncl = NULL;
00308         Container::instance().findClosestPtToVertexAmongFaces(&(*j),fp,p,sqd,ncl);
00309         double dd = sqrt(sqd);
00310         // compute separation vector
00311         //double s[3];
00312         //for(int k=0;k<3;k++){ s[k]=pC[k]-j->getCoord(k); }
00313         // compute separation distance
00314         if(Nice::instance().vertexIsNice(&(*j))==false){ dd=-dd;}
00315         // print separation distance
00316         out << dd << endl;
00318         // if object found in map
00319         w=hausdorff_1.find((j->getFace())->getVertex(0)->getObject()->getName());
00320         if(w!=hausdorff_1.end())
00321         {
00322           // if new separation distance is larger than stored value
00323           if(dd>(*w).second){hausdorff_1[(j->getFace())->getVertex(0)->getObject()->getName()]=dd;}
00324         }
00325         else
00326         {
00327           // add distance to map
00328           hausdorff_1[(j->getFace())->getVertex(0)->getObject()->getName()]=dd;
00329         }
00332         // if object found in map
00333         ss=(j->getFace())->getVertex(0)->getObject()->getName()+"_"+i->getName();
00334         w=hausdorff_2.find(ss);
00335         t=i->getName()+"_"+(j->getFace())->getVertex(0)->getObject()->getName();
00336         x=hausdorff_2.find(t);
00337         if(w!=hausdorff_2.end())
00338         {
00339           // if new separation distance is larger than stored value
00340           if(dd>(*w).second){hausdorff_2[ss]=dd;}
00341         }
00342         else if (x!=hausdorff_2.end())
00343         {
00344           // if new separation distance is larger than stored value
00345           if(dd>(*x).second){hausdorff_2[t]=dd;}
00346         }
00347         else
00348         {
00349           // add distance to map
00350           hausdorff_2[ss]=dd;
00351         }
00353         // if object different from self
00354         if(i->getName()!=((&(*j))->getFace())->getVertex(0)->getObject()->getName())
00355         {
00356           vertices_used_noself++;
00358           // if object found in map
00359           w=hausdorff_1_noself.find((j->getFace())->getVertex(0)->getObject()->getName());
00360           if(w!=hausdorff_1_noself.end())
00361           {
00362             // if new separation distance is larger than stored value
00363             if(dd>(*w).second){hausdorff_1_noself[(j->getFace())->getVertex(0)->getObject()->getName()]=dd;}
00364           }
00365           else
00366           {
00367             // add distance to map
00368             hausdorff_1_noself[(j->getFace())->getVertex(0)->getObject()->getName()]=dd;
00369           }
00372           // if object found in map
00373           ss=(j->getFace())->getVertex(0)->getObject()->getName()+"_"+i->getName();
00374           w=hausdorff_2_noself.find(ss);
00375           t=i->getName()+"_"+(j->getFace())->getVertex(0)->getObject()->getName();
00376           x=hausdorff_2_noself.find(t);
00377           if(w!=hausdorff_2_noself.end())
00378           {
00379             // if new separation distance is larger than stored value
00380             if(dd>(*w).second){hausdorff_2_noself[ss]=dd;}
00381           }
00382           else if (x!=hausdorff_2_noself.end())
00383           {
00384             // if new separation distance is larger than stored value
00385             if(dd>(*x).second){hausdorff_2_noself[t]=dd;}
00386           }
00387           else
00388           {
00389             // add distance to map
00390             hausdorff_2_noself[ss]=dd;
00391           }
00393         }
00394       }
00395       else
00396       {
00397         out_NOCP << j->getCoord(0) << " " << j->getCoord(1) << " " << j->getCoord(2) << " 1 0 0 1\n";
00398       }
00399     }
00400     for(w=hausdorff_1.begin();w!=hausdorff_1.end();w++)
00401     {
00402       storage_1.push_back((*w).second);
00403     }
00404     for(w=hausdorff_2.begin();w!=hausdorff_2.end();w++)
00405     {
00406       storage_2.push_back((*w).second);
00407     }
00408     for(w=hausdorff_1_noself.begin();w!=hausdorff_1_noself.end();w++)
00409     {
00410       storage_1_noself.push_back((*w).second);
00411     }
00412     for(w=hausdorff_2_noself.begin();w!=hausdorff_2_noself.end();w++)
00413     {
00414       storage_2_noself.push_back((*w).second);
00415     }
00416   }
00417   // haus1
00418   out_haus1 << "# One-sided Hausdorff distances\n"
00419         << "# total_vertices " << total_vertices
00420         << ", vertices_used " << vertices_used << endl;
00421   for(d_it i=storage_1.begin();i!=storage_1.end();i++)
00422   {
00423     out_haus1 << *i << endl;
00424   }
00425   // haus1
00426   // haus2
00427   out_haus2 << "# Two-sided Hausdorff distances\n"
00428         << "# total_vertices " << total_vertices
00429         << ", vertices_used " << vertices_used << endl;
00430   for(d_it i=storage_2.begin();i!=storage_2.end();i++)
00431   {
00432     out_haus2 << *i << endl;
00433   }
00434   // haus2
00435   // haus1_noself
00436   out_haus1_noself << "# One-sided Hausdorff distances - no self\n"
00437         << "# total_vertices " << total_vertices
00438         << ", vertices_used " << vertices_used_noself << endl;
00439   for(d_it i=storage_1_noself.begin();i!=storage_1_noself.end();i++)
00440   {
00441     out_haus1_noself << *i << endl;
00442   }
00443   // haus1_noself
00444   // haus2_noself
00445   out_haus2_noself << "# Two-sided Hausdorff distances - no self\n"
00446         << "# total_vertices " << total_vertices
00447         << ", vertices_used " << vertices_used_noself << endl;
00448   for(d_it i=storage_2_noself.begin();i!=storage_2_noself.end();i++)
00449   {
00450     out_haus2_noself << *i << endl;
00451   }
00452   // haus2_noself
00453   out.close();
00454   out_NOCP.close();
00455   out_haus1.close();
00456   out_haus2.close();
00457   out_haus1_noself.close();
00458   out_haus2_noself.close();
00459   //cout << "complete.\n";
00460   //cout.flush();
00461 }
00462 
00463 void Log::statusFileInit (void)
00464 {
00465   str file = OUTPUT_DATA_DIR + CONT_LOG_FILE;
00466   Cfile.open(file.c_str());
00467   Cfile << "\nLEGEND_______________________\n"
00468         << "'Iteration'\n"
00469         << "0th group is the original data.\n"
00470         << "For 1st group vertices have moved once or not at all.\n"
00471         << "--\n"
00472         << "'Nonnice'\n"
00473         << "Nonnice vertices are inside of another object, possibly the parent object.\n"
00474         << "--\n"
00475         << "'Self-Nonnice'\n"
00476         << "Self-nonnice vertices are inside of their parent object.\n"
00477         << "--\n"
00478         << "'Int. Faces'\n"
00479         << "Total number of pairs of intersecting faces in all objects.\n"
00480         << "--\n"
00481         << "'Self-Int. Faces'\n"
00482         << "Number of pairs of self-intersecting faces, i.e. faces share a common parent object.\n"
00483         << "--\n"
00484         << "'Force'\n"
00485         << "Cumulative force on all vertices in all objects.\n"
00486         << "--\n"
00487         << "'Energy'\n"
00488         << "Cumulative potential energy in all vertices in all objects.\n"
00489         << "--\n"
00490         << "'Mean Disp.'\n"
00491         << "Mean displacement of all vertices in all objects chosen to move during the group.\n"
00492         << "--\n"
00493         << "'Min. Edge Angle (rad.)'\n"
00494         << "The minimum edge angle of all edges in all objects.\n"
00495         << "Minimum edge angle is the angle between the two faces that share the edge.\n"
00496         << "___________________________________________\n\n\n\n";
00497 
00498   Cfile << "I            S\n";
00499   Cfile << "t            .\n";
00500   Cfile << "e            n            S\n";
00501   Cfile << "r            o            .\n";
00502   Cfile << "a            n            F\n";
00503   Cfile << "t            n            a\n";
00504   Cfile << "i            i            c\n";
00505   Cfile << "o            c            e\n";
00506   Cfile << "n   Nonnice  e   I.Faces  s   ";
00507   Cfile.width(10);
00508   Cfile << left << "N";
00509   Cfile.width(10);
00510   Cfile << left << "Max Gain";
00511   Cfile.width(16);
00512   Cfile << left << "Energy";
00513   Cfile.width(11);
00514   Cfile << left << "Disp_Mean";
00515   Cfile.width(15);
00516   Cfile << right << "Disp_Min";
00517   Cfile.width(1);
00518   Cfile << ":";
00519   Cfile.width(15);
00520   Cfile << left << "Disp_Max";
00521   Cfile.width(19);
00522   Cfile << left << "MinEdgeAngle(deg)";
00523   Cfile.width(13);
00524   Cfile << left << "Duration(sec)" << endl;
00525   Cfile.flush();
00526 }
00527 
00528 void Log::fileOutit (void)
00529 {
00530   Cfile.close();
00531   Mfile.close();
00532 }
00533 
00534 void Log::updateFile (const int group,bool flag,double elapsed_time)
00535 {
00536   if(group==0)
00537   {
00538     cout << "Update log files...............................";
00539   }
00540   else
00541   {
00542     cout << "Iteration " << group << ": ";
00543     cout << "Update log files...............................";
00544   }
00545   cout.flush();
00546   Cfile.precision(10);
00547   Cfile.width(4);
00548   Cfile << left << group;
00549   Cfile.width(9);
00550   Cfile << left << Nice::instance().getNonniceCount(false); // all nonnice
00551   Cfile.width(4);
00552   Cfile << left << Nice::instance().getNonniceCount(true);  // nonnince to self
00553   Cfile.width(9);
00554   Cfile << left << Intersecting_Faces::instance().getCountOfIntFaces(false);
00555   Cfile.width(4);
00556   Cfile << left << Intersecting_Faces::instance().getCountOfIntFaces(true);
00557   Cfile.precision(8);
00558   Cfile.width(10);
00559   Cfile << left << N;
00560   Cfile.width(10);
00561   Cfile << left << "NA";
00562   Cfile.width(16);
00563   Cfile << left << Container::instance().getEnergy();
00564   if (!flag)
00565   {
00566     Cfile.width(11);
00567     Cfile << left << "NA";
00568     Cfile.width(15);
00569     Cfile << right << "NA";
00570     Cfile.width(1);
00571     Cfile << ":";
00572     Cfile.width(15);
00573     Cfile << left << "NA";
00574   }
00575   else
00576   {
00577     Cfile.width(11);
00578     Cfile << left << md[1];
00579     Cfile.width(15);
00580     char name[1024];
00581     sprintf(name,"%.6g",d_min);
00582     Cfile << right << name;
00583     Cfile.width(1);
00584     Cfile << ":";
00585     Cfile.width(15);
00586     sprintf(name,"%.6g",d_max);
00587     Cfile << left << name;
00588   }
00589   Cfile.precision(10);
00590   Cfile.width(19);
00591   Cfile << left << Container::instance().getMinEdgeAngle()*180.0/PI;
00592   Cfile.width(13);
00593   Cfile.precision(4);
00594   Cfile << left << elapsed_time << endl;
00595   Cfile.flush();
00596   cout << "complete.\n";
00597   cout.flush();
00598 }
00599 
00600 void Log::writeObjectData (void)
00601 {
00602   cout << "Writing object data to log files...............";
00603   cout.flush();
00604   writeObjectList();
00605   statusFileInit();
00606   cout << "complete.\n";
00607   cout.flush();
00608 }
00609 
00610 void Log::writeObjectList (void)
00611 {
00612   //char file[FILENAME_SIZE];
00613   str file;
00614   // open file
00615   file = OUTPUT_DATA_DIR + OBJECT_LIST_FILE;
00616   Olist.open(file.c_str());
00617   // add stuff
00618   Olist << "Input data directory = " << INPUT_DATA_DIR << "\n"
00619         << "Total number of input files = " << Container::instance().getFileCount() << "\n"
00620         << "Total number of (objects, vertices, faces, edges) = (" 
00621         << Container::instance().o.size() << ","
00622         << Container::instance().getVertexCount() << ","
00623         << Container::instance().getFaceCount() << ","
00624         << Container::instance().getEdgeCount() << ")\n\n";
00625   Olist.width(15);
00626   Olist << left << "Object name";       
00627   Olist.width(15);
00628   Olist << left << "#vertices";
00629   Olist.width(15);
00630   Olist << left << "#faces";
00631   Olist.width(15);
00632   Olist << left << "#edges" << endl;
00633 
00634   // for each object, write name and index
00635   for (o_cit i=Container::instance().o.begin();i!=Container::instance().o.end();i++)
00636   {
00637     Olist.width(15);
00638     Olist << left << i->getName();
00639     Olist.width(15);
00640     Olist << left << i->v.size();
00641     Olist.width(15);
00642     Olist << left << i->f.size();
00643     Olist.width(15);
00644     Olist << left << i->e.size() << endl;
00645   }
00646   Olist.close();
00647 }
00648 
00649 void Log::updateStats (double d)
00650 {
00651   if(d)
00652   {
00653     N++;
00654     md[0]=md[1];
00655     md[1]=md[0]*(N-1)/N+d/N;
00656     if(d<d_min){d_min=d;}
00657     if(d>d_max){d_max=d;}
00658   }
00659 }
00660 
00661 void Log::clearVals (void)
00662 {
00663   N=0;                  // count of moved vertices
00664   md[0]=md[1]=0;        // mean displacement of N moved vertices
00665   d_min=1E30;           // min displacement of N moved vertices
00666   d_max=-1E30;  // max displacement of N moved vertices
00667 }
00668 
00669 void Log::writeFiles (const int group)
00670 {
00671  if (WRITE_MESH_EVERY_ITERATION)
00672   {
00673     cout << "Iteration " << group << ": ";
00674     cout << "Build Mesh after...............................";
00675     cout.flush();
00676     Container::instance().writeMeshData(group);
00677     cout << "complete.\n";
00678     cout.flush();
00679   }
00680   if(WRITE_PUNISHED_VERTICES_TO_FILE)
00681   {
00682     cout << "Iteration " << group << ": ";
00683     cout << "Write punished vertices........................";
00684     cout.flush();
00685     writePunished(group);
00686     cout << "complete.\n";
00687     cout.flush();
00688   }
00689   if(WRITE_INTERSECTED_FACES_TO_FILE)
00690   {
00691     cout << "Iteration " << group << ": ";
00692     cout << "Write intersected faces........................";
00693     cout.flush();
00694     writeIntersected(group);
00695     cout << "complete.\n";
00696     cout.flush();
00697   }
00698   if(WRITE_NONNICE_VERTICES_TO_FILE)
00699   {
00700     cout << "Iteration " << group << ": ";
00701     cout << "Write nonnice vertices.........................";
00702     cout.flush();
00703     writeNonnice(group);
00704     cout << "complete.\n";
00705     cout.flush();
00706   }
00707 
00708   gettimeofday(&tim,NULL);
00709   double t2=tim.tv_sec+(tim.tv_usec/1000000.0);
00710   updateFile(group,Vertex_Schedule::instance().getNumMovedVertsGroup()>1,t2-t1);
00711   if (WRITE_DISTANCES_EVERY_ITERATION)
00712   {
00713     cout << "Iteration " << group << ": ";
00714     cout << "Write vertex separation distances..............";
00715     cout.flush();
00716     writeSepDistances(group);
00717     cout << "complete.\n";
00718     cout.flush();
00719   }
00720 }
00721 
00722 void Log::writeNonnice (const int group)
00723 {
00724   str file;
00725   // create output filename
00726   if (APPEND_ITERATION_NUMBER_TO_MESH)
00727   {
00728     char sint[128];
00729     sprintf(sint,".%i",group);
00730     str line(sint);
00731     file = OUTPUT_DATA_DIR + NONNICE_FILE + line;
00732   }
00733   else
00734   {
00735     file = OUTPUT_DATA_DIR + NONNICE_FILE;
00736   }
00737   // open output file
00738   std::ofstream newfile (file.c_str(),std::ios::out);
00739   if(newfile.is_open())
00740   {
00741     // create vector set
00742     v_set vs;
00743     // for each nonnice hashtable element in object
00744     for(vhm_cit j=Nice::instance().beginNice();j!=Nice::instance().endNice();j++)
00745     {
00746       // add vertex* to set
00747       vs.insert((*j).first);
00748     }
00749     // vector set was collected
00750     // if cp
00751     if("FORMAT_NONNICE_VERTICES"=="cp")
00752     {
00753       // print header
00754       newfile << "x_coordinate y_coordinate z_coordinate "
00755             << "state_value x_normal y_normal z_normal\n";
00756       // for each vertex in set
00757       newfile.precision(12);
00758       for(vs_it i=vs.begin();i!=vs.end();i++)
00759       {
00760         // print vertex
00761         (*i)->printCP(newfile);
00762       }
00763     }
00764     else
00765     { // else detail
00766       newfile.precision(12);
00767       // for each vertex in set
00768       for(vs_it i=vs.begin();i!=vs.end();i++)
00769       {
00770         // print vertex
00771         (*i)->print(newfile);
00772       }
00773     }
00774     newfile.close();
00775   }
00776 }
00777 
00778 void Log::writeIntersected (const int group)
00779 {
00780   str file;
00781   // create output filename
00782   if (APPEND_ITERATION_NUMBER_TO_MESH)
00783   {
00784     char sint[128];
00785     sprintf(sint,".%i",group);
00786     str line(sint);
00787     file = OUTPUT_DATA_DIR + INTERSECTED_FILE + line;
00788   }
00789   else
00790   {
00791     file = OUTPUT_DATA_DIR + INTERSECTED_FILE;
00792   }
00793   // open output file
00794   std::ofstream newfile (file.c_str(),std::ios::out);
00795   if(newfile.is_open())
00796   {
00797     // if cp
00798     if("FORMAT_INTERSECTED_FACES"=="cp")
00799     {
00800       // create vector set
00801       v_set vs;
00802       // for each intersected hashtable element in object
00803       for(htff_cit j=Intersecting_Faces::instance().begin();j!=Intersecting_Faces::instance().end();j++)
00804       {
00805         // grab Face *key
00806         Face *ff=(*j).first;
00807         // for each vertex of Face* key
00808         for(int k=0;k<3;k++)
00809         {
00810           // add vertex* to set
00811           vs.insert(ff->getVertex(k));
00812         }
00813         // for each Face* in vector
00814         const vec_fp *fv=&(*j).second;
00815         for(fp_cit k=fv->begin();k!=fv->end();k++)
00816         {
00817           // for each vertex of Face*
00818           for(int nn=0;nn<3;nn++)
00819           {
00820             // add vertex* to set
00821             vs.insert((*k)->getVertex(nn));
00822           }
00823         }
00824       }
00825       // vector set was collected
00826       // print header
00827       newfile << "x_coordinate y_coordinate z_coordinate "
00828             << "state_value x_normal y_normal z_normal\n";
00829       // for each vertex in set
00830       newfile.precision(12);
00831       for(vs_it i=vs.begin();i!=vs.end();i++)
00832       {
00833         // print vertex
00834         (*i)->printCP(newfile);
00835       }
00836     }
00837     else
00838     { // else detail
00839       // create face set
00840       f_set ffs;
00841       // for each intersected hashtable element
00842       for(htff_cit j=Intersecting_Faces::instance().begin();j!=Intersecting_Faces::instance().end();j++)
00843       {
00844         // add Face* to set
00845         ffs.insert((*j).first);
00846         // for each Face* in vector
00847         const vec_fp *fv=&(*j).second;
00848         for(fp_cit k=fv->begin();k!=fv->end();k++)
00849         {
00850           // add Face* to set
00851           ffs.insert(*k);
00852         }
00853       }
00854       // face set was collected
00855       newfile.precision(12);
00856       // for each face in set
00857       for(fs_it i=ffs.begin();i!=ffs.end();i++)
00858       {
00859         // print face
00860         (*i)->print(newfile);
00861       }
00862     }
00863     newfile.close();
00864   }
00865 }
00866 
00867 void Log::writePunished (const int group)
00868 {
00869   str file;
00870   // create output filename
00871   if (APPEND_ITERATION_NUMBER_TO_MESH)
00872   {
00873     char sint[128];
00874     sprintf(sint,".%i",group);
00875     str line(sint);
00876     file = OUTPUT_DATA_DIR + PUNISHED_FILE + line;
00877   }
00878   else
00879   {
00880     file = OUTPUT_DATA_DIR + PUNISHED_FILE;
00881   }
00882   // open output file
00883   std::ofstream newfile (file.c_str(),std::ios::out);
00884   if(newfile.is_open())
00885   {
00886     newfile.precision(12);
00887     if(Refractory::instance().numPunishedN() > 0)
00888     {
00889       // for each vertex moved too many time
00890       newfile << "# vertices punished for moving MAX_TOUCHES="
00891             << MAX_TOUCHES << "times in group=" << group << endl;
00892       for(vhm_cit i=Refractory::instance().beginN();i!=Refractory::instance().endN();i++)
00893       {
00894         Vertex *v=(*i).first;
00895         v->print(newfile);
00896       }
00897     }
00898     //if(Refractory::instance().pun_int.empty()==false)
00899     if(Refractory::instance().numPunishedInt() > 0)
00900     {
00901       // for each punished vertex
00902       newfile << "# vertices punished for causing intersecting faces"
00903             << " in group=" << group << endl;
00904       for(vhm_cit i=Refractory::instance().beginInt();i!=Refractory::instance().endInt();i++)
00905       {
00906         Vertex *v=(*i).first;
00907         v->print(newfile);
00908       }
00909     }
00910     //if(Refractory::instance().pun_ang.empty()==false)
00911     if(Refractory::instance().numPunishedAng() > 0)
00912     {
00913       // for each punished vertex
00914       newfile << "# vertices punished for causing very small or very large edge angles"
00915             << " in group=" << group << endl;
00916       for(vhm_cit i=Refractory::instance().beginAng();i!=Refractory::instance().endAng();i++)
00917       {
00918         Vertex *v=(*i).first;
00919         v->print(newfile);
00920       }
00921     }
00922     //if(Refractory::instance().pun_com.empty()==false)
00923     if(Refractory::instance().numPunishedCom() > 0)
00924     {
00925       // for each punished vertex
00926       newfile << "# vertices whose punishment is not "
00927             << "attributable to either of the above categories" << endl;
00928       for(vhm_cit i=Refractory::instance().beginCom();i!=Refractory::instance().endCom();i++)
00929       {
00930         Vertex *v=(*i).first;
00931         v->print(newfile);
00932       }
00933     }
00934     newfile.close();
00935   }
00936   else
00937   {
00938     cout << "Vertex_Schedule::writePunished: Error.\n"
00939           << "Could not open " << file << " for writing punished vertices.\n";
00940   }
00941 }
00942 
00943 void Log::printDetailedInfo (void)
00944 {
00945   cout.precision(12);
00946   cout <<  "position       ["
00947         << p_orig[0] << " "
00948         << p_orig[1] << " "
00949         << p_orig[2] << "]->["
00950         << p_new[0] << " "
00951         << p_new[1] << " "
00952         << p_new[2] << "]\n"
00953         << "closest point  ["
00954         << cp_orig[0] << " "
00955         << cp_orig[1] << " "
00956         << cp_orig[2] << "]->["
00957         << cp_new[0] << " "
00958         << cp_new[1] << " "
00959         << cp_new[2] << "]\n"
00960         << "separation dis ["
00961         << sepdis[0] << "]->["
00962         << sepdis[1] << "]\n"
00963         << "virtual disp   ["
00964         << vd_val[0] << "]->["
00965         << vd_val[1] << "]\n"
00966         << "topN rank      ["
00967         << topN_val[0] << "]->["
00968         << topN_val[1] << "]\n\n";
00969   if (vd_val[0]!=vd_val[0])
00970   {
00971     cout << "\n\nLog::printDetailInfo: Error: "
00972           << "vd_val[0] = " << vd_val[0] << endl << endl;
00973     exit(0);
00974   }
00975 }
00976 
00977 #if 0
00978 void Log::print (const int group)
00979 {
00980   // print to stdout
00981   //if(!(count++%1000))
00982   if(Vertex_Schedule::instance().getNumMovedVertsGroup())
00983   {
00984     char name[1024];
00985     sprintf(name,"count %d, ",Vertex_Schedule::instance().getNumMovedVertsGroup()-1);
00986     cout << name;
00987     sprintf(name,"group %d, ",group);
00988     cout << name;
00989     cout.width(45);
00990     sprintf(name,"%s->%d, ",Vertex_Schedule::instance().getCurrentVertex()->getObject()->getName().c_str(),Vertex_Schedule::instance().getCurrentVertex()->getIndex());
00991     cout << left << name;
00992     cout.width(24);
00993     sprintf(name,"vd %.12g, ",sqrt(State::instance().getVD2()));
00994     cout << left << name;
00995     cout.width(24);
00996     sprintf(name,"e %.12g, ",Container::instance().getEnergy());
00997     cout << left << name;
00998     cout << endl << endl;
00999   }
01000 }
01001 #endif
01002 
01003 void Log::print (const int group)
01004 {
01005   if(Vertex_Schedule::instance().getNumMovedVertsGroup())
01006   {
01007     cout.precision(12);
01008     cout << endl;
01009     if (Vertex_Schedule::instance().getCurrentVertex()==Vertex_Schedule::instance().getSeedVertex())
01010     {
01011       cout << "SEEDSEEDSEEDSEEDSEEDSEED\n";
01012     }
01013     cout << "count          " << Vertex_Schedule::instance().getNumMovedVertsGroup()-1 << endl
01014          << "group          " << group << endl
01015          << "object         " << Vertex_Schedule::instance().getCurrentVertex()->getObject()->getName().c_str() << endl
01016          << "vertex         " << Vertex_Schedule::instance().getCurrentVertex()->getIndex() << endl
01017          << "displacement   " << sqrt(State::instance().getVD2()) << endl
01018          << "world energy   " << Container::instance().getEnergy() << endl
01019          << "gain           " << Gain_Schedule::instance().getGain() << endl;
01020   }
01021 }
01022 
01023 void Log::recordTime (str line)
01024 {
01025   time_t after,diff;
01026   after = time (NULL);
01027   diff = after-currtime;
01028   Mfile << line << " " << diff << " seconds\n";
01029   Mfile.flush();
01030   currtime = after;
01031 }
01032 
01033 void Log::setTime (time_t t)
01034 {
01035   currtime = t;
01036 }
01037 
01038 void Log::mainFileInit (void)
01039 {
01040   str log_file = OUTPUT_DATA_DIR + MAIN_LOG_FILE;
01041   Mfile.open(log_file.c_str());
01042   if(Mfile.is_open()==false){cout << "\nFailed to open file " << log_file << ".\n"; }
01043 }
01044 
01045 void Log::printBad (void)
01046 {
01047   if (vv==NULL){cout << "vertex* is NULL.\n";}
01048   if (p_orig[0]<0){cout << "orig pos not set.\n";}
01049   if (p_new[0]<0){cout << "new pos not set.\n";}
01050   if (cp_orig[0]<0){cout << "orig clos pos not set.\n";}
01051   if (cp_new[0]<0){cout << "new clos pos not set.\n";}
01052   if (topN_val[0]<0){cout << "orig topN_val not set.\n";}
01053   if (topN_val[1]<0){cout << "new topN_val not set.\n";}
01054   if (vd_val[0]<0){cout << "orig vd_val not set.\n";}
01055   if (vd_val[1]<0){cout << "new vd_val not set.\n";}
01056   if (sepdis[0]<0){cout << "orig sepdis not set.\n";}
01057   if (sepdis[1]<0){cout << "new sepdis not set.\n";}
01058   cout << "p_orig[0] = " << p_orig[0] << endl;
01059   cout << "p_new[0] = " << p_new[0] << endl;
01060   cout << "cp_orig[0] = " << cp_orig[0] << endl;
01061   cout << "cp_new[0] = " << cp_new[0] << endl;
01062   cout << "topN_val[0] = " << topN_val[0] << endl;
01063   cout << "topN_val[1] = " << topN_val[1] << endl;
01064   cout << "vd_val[0] = " << vd_val[0] << endl;
01065   cout << "vd_val[1] = " << vd_val[1] << endl;
01066   cout << "sepdis[0] = " << sepdis[0] << endl;
01067   cout << "sepdis[1] = " << sepdis[1] << endl;
01068 }
01069 
01070 Vertex* Log::getVertex (void)
01071 {
01072   return vv;
01073 }
01074 
01075 void Log::addVertex (Vertex *uu)
01076 {
01077   vv=uu;
01078 }
01079 
01080 bool Log::isGood (void)
01081 {
01082   return        vv!=NULL &&
01083         (p_orig[0]>0) &&
01084         (p_new[0]>0) &&
01085         (cp_orig[0]>0) &&
01086         (cp_new[0]>0) &&
01087         (topN_val[0]>0) &&
01088         (topN_val[1]>0) &&
01089         (vd_val[0]>=0) &&
01090         (vd_val[1]>=0) &&
01091         (sepdis[0]>=0) &&
01092         (sepdis[1]>0);
01093 }
01094 
01095 void Log::addNewSepDis (double i)
01096 {
01097   sepdis[1]=i;
01098 }
01099 
01100 double Log::getNewSepDis (void)
01101 {
01102   return sepdis[1];
01103 }
01104 
01105 void Log::addNewVD (double i)
01106 {
01107   vd_val[1]=i;
01108 }
01109 
01110 double Log::getNewVD (void)
01111 {
01112   return vd_val[1];
01113 }
01114 
01115 void Log::addNewTopN (double i)
01116 {
01117   topN_val[1]=i;
01118 }
01119 
01120 double Log::getNewTopN (void)
01121 {
01122   return topN_val[1];
01123 }
01124 
01125 void Log::addOrigSepDis (double i)
01126 {
01127   sepdis[0]=i;
01128 }
01129 
01130 double Log::getOrigSepDis (void)
01131 {
01132   return sepdis[0];
01133 }
01134 
01135 void Log::addOrigVD (double i)
01136 {
01137   vd_val[0]=i;
01138 }
01139 
01140 double Log::getOrigVD (void)
01141 {
01142   return vd_val[0];
01143 }
01144 
01145 void Log::addOrigTopN (double i)
01146 {
01147   topN_val[0]=i;
01148 }
01149 
01150 double Log::getOrigTopN (void)
01151 {
01152   return topN_val[0];
01153 }
01154 
01155 void Log::clear (void)
01156 {
01157   p_orig[0]  = p_orig[1]  = p_orig[2]  = -1.0;
01158   p_new[0]   = p_new[1]   = p_new[2]   = -1.0;
01159   cp_orig[0] = cp_orig[1] = cp_orig[2] = -1.0;
01160   cp_new[0]  = cp_new[1]  = cp_new[2]  = -1.0;
01161   for(int i=0;i<2;i++)
01162   {
01163     topN_val[i]=vd_val[i]=sepdis[i]=-1.0;
01164   }
01165 }
01166 
01167 //void Log::addOrigP(vec_d const &q)
01168 //{
01169 //  p_orig[0]=q[0];
01170 //  p_orig[1]=q[1];
01171 //  p_orig[2]=q[2];
01172 //}
01173 
01174 void Log::addOrigP (vec_d const * const q)
01175 {
01176   p_orig[0]=(*q)[0];
01177   p_orig[1]=(*q)[1];
01178   p_orig[2]=(*q)[2];
01179 }
01180 
01181 //void Log::getOrigP (double q[3])
01182 //{
01183 //  q[0]=p_orig[0];
01184 //  q[1]=p_orig[1];
01185 //  q[2]=p_orig[2];
01186 //}
01187 
01188 //void Log::getNewP (double q[3])
01189 //{
01190 //  q[0]=p_new[0];
01191 //  q[1]=p_new[1];
01192 //  q[2]=p_new[2];
01193 //}
01194 
01195 //void Log::addNewP (vec_d const & q)
01196 //{
01197 //  p_new[0]=q[0];
01198 //  p_new[1]=q[1];
01199 //  p_new[2]=q[2];
01200 //}
01201 
01202 void Log::addNewP (vec_d const * const q)
01203 {
01204   p_new[0]=(*q)[0];
01205   p_new[1]=(*q)[1];
01206   p_new[2]=(*q)[2];
01207 }
01208 
01209 void Log::addOrigCP (vec_d q)
01210 {
01211   cp_orig[0]=q[0];
01212   cp_orig[1]=q[1];
01213   cp_orig[2]=q[2];
01214 }
01215 
01216 //void Log::getOrigCP (double q[3])
01217 //{
01218 //  q[0]=cp_orig[0];
01219 //  q[1]=cp_orig[1];
01220 //  q[2]=cp_orig[2];
01221 //}
01222 
01223 //void Log::getNewCP (double q[3])
01224 //{
01225 //  q[0]=cp_new[0];
01226 //  q[1]=cp_new[1];
01227 //  q[2]=cp_new[2];
01228 //}
01229 
01230 void Log::addNewCP (vec_d q)
01231 {
01232   cp_new[0]=q[0];
01233   cp_new[1]=q[1];
01234   cp_new[2]=q[2];
01235 }
01236 
01237 void Log::premove (Vertex * v) 
01238 {
01239   clear();
01240   addVertex(v);
01241   addOrigP(v->getPos());
01242   addOrigSepDis(sqrt(v->getSqSepDist()));
01243 
01244   int rank;
01245   tv_it t;
01246   if (Virtual_Disp::instance().findTopN(v,t,rank)==true)
01247   {
01248     addOrigVD(sqrt((*t).first));
01249     addOrigTopN(Virtual_Disp::instance().getSizeTopN()-rank);
01250   }
01251   else
01252   {
01253     addOrigVD(0);
01254     addOrigTopN(0);
01255   }
01256   vec_d pC(3,0.0);
01257   if (v->getFace()!=NULL)
01258   {
01259     vec_fp fp(1,const_cast<Face*>(v->getFace()));
01260     double dd=0.0;
01261     Face *ncl = NULL;
01262     Container::instance().findClosestPtToVertexAmongFaces(v,fp,pC,dd,ncl);
01263   }
01264   addOrigCP(pC);
01265 }
01266 
01267 void Log::postmove (Vertex * v) 
01268 {
01269   addNewP(v->getPos());
01270   addNewSepDis(sqrt(v->getSqSepDist()));
01271   int rank;
01272   tv_it t;
01273   if (Virtual_Disp::instance().findTopN(v,t,rank)==true)
01274   {
01275     addNewVD(sqrt((*t).first));
01276     addNewTopN(Virtual_Disp::instance().getSizeTopN()-rank);
01277   }
01278   else
01279   {
01280     addNewVD(0);
01281     addNewTopN(0);
01282   }
01283   vec_d pC(3,0.0);
01284   if(v->getFace()!=NULL)
01285   {
01286     vec_fp fp(1,const_cast<Face*>(v->getFace()));
01287     double dd=0.0;
01288     Face *ncl = NULL;
01289     Container::instance().findClosestPtToVertexAmongFaces(v,fp,pC,dd,ncl);
01290   }
01291   addNewCP(pC);
01292   printDetailedInfo();
01293 }
01294 
01295 void Log::updateClosestPtStats (int face_count,int box_count)
01296 {
01297   double previous_face_sum = num_verts*face_mean;
01298   double previous_box_sum  = num_verts*box_mean;
01299 
01300   num_verts++;
01301   face_mean = (previous_face_sum+face_count)/num_verts; 
01302   if(face_count<face_min) face_min=face_count;
01303   if(face_count>face_max) face_max=face_count;
01304   box_mean  = (previous_box_sum + box_count)/num_verts; 
01305   if(box_count<box_min) box_min=box_count;
01306   if(box_count>box_max) box_max=box_count;
01307 }
01308 
01309 void Log::printClosestPtStats (std::ostream & target) const
01310 {
01311   char str[1024];
01312   sprintf(str,"\nLog: mean number of boxes used in closest pt search = %g\n",box_mean);
01313   target << str;
01314   sprintf(str,"Log: min  number of boxes used in closest pt search = %d\n",box_min);
01315   target << str;
01316   sprintf(str,"Log: max  number of boxes used in closest pt search = %d\n",box_max);
01317   target << str;
01318   sprintf(str,"Log: mean number of faces used in closest pt search = %g\n",face_mean);
01319   target << str;
01320   sprintf(str,"Log: min  number of faces used in closest pt search = %d\n",face_min);
01321   target << str;
01322   sprintf(str,"Log: max  number of faces used in closest pt search = %d\n",face_max);
01323   target << str;
01324   sprintf(str,"Log: number of vertices in closest pt search stats  = %d\n\n",num_verts);
01325   target << str;
01326 }
01327 
01328 void Log::printNumNonnice (std::ostream & target) const
01329 {
01330   char str[1024];
01331   sprintf(str,"\nLog: number of nonnice vertices = %d\n\n",Nice::instance().getNonniceCount(false));
01332   target << str;
01333 }
01334 
01335 void Log::printNumInt (std::ostream & target) const
01336 {
01337   char str[1024];
01338   int i = Intersecting_Faces::instance().getCountOfIntFaces(false);
01339   sprintf(str,"\nLog: number of face intersections = %d\n\n",i);
01340   target << str;
01341 }
01342 
01343 void Log::updatePartitioningFaceStats (int box_count)
01344 {
01345   double previous_box_sum = num_faces*bpf_mean;
01346 
01347   num_faces++;
01348   bpf_mean = (previous_box_sum+box_count)/num_faces; 
01349   if(box_count<bpf_min) bpf_min=box_count;
01350   if(box_count>bpf_max) bpf_max=box_count;
01351 }
01352 
01353 void Log::setPartitioningBoxStats (void)
01354 {
01355   // for each box
01356   for(b_cit i=Space::instance().begin();i!=Space::instance().end();i++)
01357   {
01358     int face_count = (*i).getNumFaces();
01359     if(face_count==0)
01360     {
01361       num_empty_boxes++;
01362     }
01363     else
01364     {
01365       double previous_face_sum = num_boxes*fpb_mean;
01366 
01367       num_boxes++;
01368       fpb_mean = (previous_face_sum+face_count)/num_boxes; 
01369       if(face_count<fpb_min) fpb_min=face_count;
01370       if(face_count>fpb_max) fpb_max=face_count;
01371     }
01372   }
01373 }
01374 
01375 void Log::printPartitioningStats (std::ostream & target) const
01376 {
01377   char str[1024];
01378   sprintf(str,"\nLog: mean number of boxes per face = %g\n",bpf_mean);
01379   target << str;
01380   sprintf(str,"Log: min  number of boxes per face = %d\n",bpf_min);
01381   target << str;
01382   sprintf(str,"Log: max  number of boxes per face = %d\n",bpf_max);
01383   target << str;
01384   sprintf(str,"Log: mean number of faces per box  = %g\n",fpb_mean);
01385   target << str;
01386   sprintf(str,"Log: min  number of faces per box  = %d\n",fpb_min);
01387   target << str;
01388   sprintf(str,"Log: max  number of faces per box  = %d\n",fpb_max);
01389   target << str;
01390   sprintf(str,"Log: number of boxes with no faces = %d\n\n",num_empty_boxes);
01391   target << str;
01392 }
01393 
01394 void Log::updateVertexSchedulingStats (int vertex_count)
01395 {
01396   double previous_vertex_sum = num_sets*vps_mean;
01397 
01398   num_sets++;
01399   vps_mean = (previous_vertex_sum+vertex_count)/num_sets; 
01400   if(vertex_count<vps_min) vps_min=vertex_count;
01401   if(vertex_count>vps_max) vps_max=vertex_count;
01402 }
01403 
01404 void Log::printVertexSchedulingStats (std::ostream & target) const
01405 {
01406   char str[1024];
01407   sprintf(str,"\nLog: mean number of vertices per moved set = %g\n",vps_mean);
01408   target << str;
01409   sprintf(str,  "Log: min  number of vertices per moved set = %d\n",vps_min);
01410   target << str;
01411   sprintf(str,  "Log: max  number of vertices per moved set = %d\n",vps_max);
01412   target << str;
01413   sprintf(str,  "Log: (note not all vertices in a \"moved set\" are allowed to move)\n\n");
01414   target << str;
01415 }
01416 
01417 

Generated on Fri Jul 18 19:43:40 2008 for meshmorph by  doxygen 1.5.1