controls.h

Go to the documentation of this file.
00001 // Author: Justin Kinney
00002 // Date: Sep 2008
00003 
00004 #ifndef CONTROLS_H
00005 #define CONTROLS_H 1
00006 
00007 #include <string>
00008 
00009 class Controls
00010 {
00011 public:
00012   static Controls & instance     (void);
00013   std::string processDir         (char *);
00014   void        parseCommandLine   (int argc,char **argv,std::string const & message);
00015   void        redefineGroup      (void);
00016   void        recordOctreeSize   (double size);
00017   std::string getUsageMessage    (void);
00018   std::string getCommandSettings (void);
00019   std::string d2str              (double const & i);
00020   std::string i2str              (int const & i);
00021 
00022   void        set_strict_face_intersection_prevention () throw() { STRICT_FACE_INTERSECTION_PREVENTION=true; }
00023 
00024   int    get_measure_ecw_and_exit                 () const throw() { return MEASURE_ECW_AND_EXIT; }
00025   int    get_max_items_per_leaf                   () const throw() { return MAX_ITEMS_PER_LEAF; }
00026   int    get_max_octree_depth                     () const throw() { return MAX_OCTREE_DEPTH; }
00027   int    get_max_filename_size                    () const throw() { return MAX_FILENAME_SIZE; }
00028   int    get_number_radius_steps                  () const throw() { return NUMBER_RADIUS_STEPS; }
00029   int    get_group_size                           () const throw() { return GROUP_SIZE; }
00030   int    get_num_groups                           () const throw() { return NUM_GROUPS; }
00031   int    get_refractory_period                    () const throw() { return REFRACTORY_PERIOD; }
00032   int    get_max_touches                          () const throw() { return MAX_TOUCHES; }
00033   int    get_energy_sample_period                 () const throw() { return ENERGY_SAMPLE_PERIOD; }
00034   int    get_print_period                         () const throw() { return PRINT_PERIOD; }
00035   int    get_begin_short_print_period             () const throw() { return BEGIN_SHORT_PRINT_PERIOD; }
00036   int    get_write_mesh_now                       () const throw() { return WRITE_MESH_NOW; }
00037   int    get_vector_reserve                       () const throw() { return VECTOR_RESERVE; }
00038   int    get_write_verbose_init                   () const throw() { return WRITE_VERBOSE_INIT; }
00039   int    get_write_refracted_vertices_to_file     () const throw() { return WRITE_REFRACTED_VERTICES_TO_FILE; }
00040   int    get_write_intersected_faces_to_file      () const throw() { return WRITE_INTERSECTED_FACES_TO_FILE; }
00041   int    get_write_nonnice_vertices_to_file       () const throw() { return WRITE_NONNICE_VERTICES_TO_FILE; }
00042   int    get_write_every_group                    () const throw() { return WRITE_EVERY_GROUP; }
00043   int    get_write_ecw_to_file                    () const throw() { return WRITE_ECW_TO_FILE; }
00044   int    get_write_vertex_move_histogram          () const throw() { return WRITE_VERTEX_MOVE_HISTOGRAM; }
00045   int    get_append_group_number                  () const throw() { return APPEND_GROUP_NUMBER; }
00046   int    get_strict_face_intersection_prevention  () const throw() { return STRICT_FACE_INTERSECTION_PREVENTION; }
00047   int    get_use_edge_reference_length            () const throw() { return USE_EDGE_REFERENCE_LENGTH; }
00048   int    get_enable_vtrack                        () const throw() { return ENABLE_VTRACK; }
00049   int    get_disable_gain_scheduling              () const throw() { return DISABLE_GAIN_SCHEDULING; }
00050   int    get_disable_messages                     () const throw() { return DISABLE_MESSAGES; }
00051   double get_octree_min_x                         () const throw() { return OCTREE_MIN_X; }
00052   double get_octree_min_y                         () const throw() { return OCTREE_MIN_Y; }
00053   double get_octree_min_z                         () const throw() { return OCTREE_MIN_Z; }
00054   double get_octree_width                         () const throw() { return OCTREE_WIDTH; }
00055   double get_min_cell_size                        () const throw() { return MIN_CELL_SIZE; }
00056   double get_edge_angle_threshold                 () const throw() { return EDGE_ANGLE_THRESHOLD; }
00057   double get_my_double_epsilon                    () const throw() { return MY_DOUBLE_EPSILON; }
00058   double get_epsilon                              () const throw() { return EPSILON; }
00059   double get_update_region_size                   () const throw() { return UPDATE_REGION_SIZE; }
00060   double get_seed_region_size                     () const throw() { return SEED_REGION_SIZE; }
00061   double get_min_search_cone_radius               () const throw() { return MIN_SEARCH_CONE_RADIUS; }
00062   double get_search_radius_sq                     () const throw() { return SEARCH_RADIUS_SQ; }
00063   double get_closest_point_angle                  () const throw() { return CLOSEST_POINT_ANGLE; }
00064   double get_closest_point_cosine                 () const throw() { return CLOSEST_POINT_COSINE; }
00065   double get_closest_point_sine                   () const throw() { return CLOSEST_POINT_SINE; }
00066   double get_intersection_weight                  () const throw() { return INTERSECTION_WEIGHT; }
00067   double get_edge_length_weight                   () const throw() { return EDGE_LENGTH_WEIGHT; }
00068   double get_ecw_weight                           () const throw() { return ECW_WEIGHT ; }
00069   double get_edge_angle_weight                    () const throw() { return EDGE_ANGLE_WEIGHT; }
00070   double get_ecw_gain                             () const throw() { return ECW_GAIN; }
00071   double get_edge_angle_gain                      () const throw() { return EDGE_ANGLE_GAIN; }
00072   double get_edge_length_gain                     () const throw() { return EDGE_LENGTH_GAIN; }
00073   double get_aspect_ratio_gain                    () const throw() { return ASPECT_RATIO_GAIN; }
00074   double get_aspect_ratio_threshold               () const throw() { return ASPECT_RATIO_THRESHOLD; }
00075   double get_overall_gain                         () const throw() { return OVERALL_GAIN; }
00076   double get_min_displacement_sq                  () const throw() { return MIN_DISPLACEMENT_SQ; }
00077   double get_pi                                   () const throw() { return PI; }
00078   double get_target_ecw                           () const throw() { return TARGET_ECW; }
00079   double get_ecw_threshold                        () const throw() { return ECW_THRESHOLD; }
00080   double get_target_ecw_high                      () const throw() { return TARGET_ECW_HIGH; }
00081   double get_target_ecw_low                       () const throw() { return TARGET_ECW_LOW; }
00082   double get_max_actual_displ_fraction            () const throw() { return MAX_ACTUAL_DISPL_FRACTION; }
00083   double get_max_runtime                          () const throw() { return MAX_RUNTIME; }
00084   double get_ecw_sampling_length                  () const throw() { return ECW_SAMPLING_LENGTH; }
00085   double get_small_ecw_threshold                  () const throw() { return SMALL_ECW_THRESHOLD; }
00086   std::string get_format_intersected_faces        () const throw() { return FORMAT_INTERSECTED_FACES; }
00087   std::string get_format_nonnice_vertices         () const throw() { return FORMAT_NONNICE_VERTICES; }
00088   std::string get_input_data_dir                  () const throw() { return INPUT_DATA_DIR; }
00089   std::string get_output_data_dir                 () const throw() { return OUTPUT_DATA_DIR; }
00090   std::string get_frozen_vertices_file            () const throw() { return FROZEN_VERTICES_FILE; }
00091   std::string get_vertex_sequence_file            () const throw() { return VERTEX_SEQUENCE_FILE; }
00092   std::string get_mesh_output_suffix              () const throw() { return MESH_OUTPUT_SUFFIX; }
00093   std::string get_main_log_file                   () const throw() { return MAIN_LOG_FILE; }
00094   std::string get_cont_log_file                   () const throw() { return CONT_LOG_FILE; }
00095   std::string get_sep_log_file                    () const throw() { return SEP_LOG_FILE; }
00096   std::string get_object_list_file                () const throw() { return OBJECT_LIST_FILE; }
00097   std::string get_control_file                    () const throw() { return CONTROL_FILE; }
00098   std::string get_vertex_selection_file           () const throw() { return VERTEX_SELECTION_FILE; }
00099   std::string get_refracted_file                  () const throw() { return REFRACTED_FILE; }
00100   std::string get_intersected_file                () const throw() { return INTERSECTED_FILE; }
00101   std::string get_nonnice_file                    () const throw() { return NONNICE_FILE; }
00102   void updatePrintPeriod (int count);
00103 
00104 private:
00105   static Controls * only_one;
00106   Controls                (void);
00107   Controls                (Controls const &);
00108   Controls & operator =   (Controls const &);
00109 
00110 private:
00111   // octree parameters
00112   int MAX_ITEMS_PER_LEAF;
00113   int MAX_OCTREE_DEPTH;
00114   double MIN_CELL_SIZE;
00115   double OCTREE_MIN_X;
00116   double OCTREE_MIN_Y;
00117   double OCTREE_MIN_Z;
00118   double OCTREE_WIDTH;
00119 
00120   double PI;
00121   // maximum file name size
00122   int MAX_FILENAME_SIZE;
00123 
00124   // Directs the model to be written to file at a
00125   // user-specified iteration number each group.
00126   // WRITE_MESH_NOW is the number of vertex moves in group after which
00127   // the entire mesh model will be written to file once.
00128   // Minimum value == 1 which will write mesh after one vertex move.
00129   // Default is '0' which does nothing.
00130   int WRITE_MESH_NOW;
00131 
00132   // set to true to write initialization information
00133   //            for each file to stdout, i.e. verbose setting
00134   // set to false for concise initialization informatin, i.e. concise setting
00135   int WRITE_VERBOSE_INIT;
00136 
00137   // set to true to write refracted vertices to
00138   //            file specified by REFRACTED_FILE
00139   int WRITE_REFRACTED_VERTICES_TO_FILE;
00140 
00141   // set to true to write intersected faces to
00142   //            file specified by INTERSECTED_FILE
00143   int WRITE_INTERSECTED_FACES_TO_FILE;
00144 
00145   // choice of output format for intersected faces
00146   //    dreamm = dreamm custom points format
00147   //    detail = face name and index + vertex details(3X)
00148   // choose one
00149   std::string FORMAT_INTERSECTED_FACES;
00150 
00151   // set to true to write nonnice vertices to
00152   //            file specified by NONNICE_FILE
00153   int WRITE_NONNICE_VERTICES_TO_FILE;
00154 
00155   // choice of output format for nonnice vertices
00156   //    dreamm = dreamm custom points format
00157   //    detail = vertex name,index,x,y,z
00158   // choose one
00159   std::string FORMAT_NONNICE_VERTICES;
00160 
00161   // set to true to write various output data
00162   // to file after completion of every group
00163   // set to false to only write output data
00164   // to file after the last group has finished
00165   int WRITE_EVERY_GROUP;
00166 
00167   // set to true to write closest point distance
00168   //            to file
00169   // set to false to do nothing
00170   int WRITE_ECW_TO_FILE;
00171 
00172   // The surface sampling density for extracellular width
00173   // measurement has an area equal
00174   // to an equilateral triangle of ECW_SAMPLING_LENGTH.
00175   double ECW_SAMPLING_LENGTH;
00176 
00177   // set to true to write vertex move histogram to file after each group
00178   // set to false to do nothing
00179   int WRITE_VERTEX_MOVE_HISTOGRAM;
00180 
00181   // set to true to use group number in output data filenames
00182   // set to false to not automatically use group number in output data filenames
00183   int APPEND_GROUP_NUMBER;
00184 
00185   // set to true to prevent any new intersections of faces
00186   // set to false to allow new intersecting faces
00187   //    (useful when faces exist with all three vertices nonnice)
00188   int STRICT_FACE_INTERSECTION_PREVENTION;
00189 
00190   // if moving a vertex creates an edge angle
00191   // less than EDGE_ANGLE_THRESHOLD,
00192   // then vertex is not moved
00193   double EDGE_ANGLE_THRESHOLD; //radians
00194 
00195   // for use with "is float close to zero?" 
00196   // in conditional statement
00197   double MY_DOUBLE_EPSILON;
00198   double EPSILON;
00199 
00200   // The region of space in which the model will be updated after a vertex move.
00201   // All vertices of all faces in octree cells that overlap this
00202   // region of space will have their closest point, extracellular
00203   // width, total force, virtual displacement, and virtual
00204   // displacement rank updated.
00205   double UPDATE_REGION_SIZE;
00206 
00207   // vertices are moved in sets consisting of a seed vertex
00208   // (typically the vertex with the largest virtual displacement)
00209   // and vertices of all faces in octree cells intersected by
00210   // cube centered on seed vertex with side length 
00211   // equal to 2*SEED_REGION_SIZE
00212   double SEED_REGION_SIZE;
00213 
00214   // If a candidate closest point is more than SEARCH_RADIUS 
00215   // distance away from given vertex, then the candidate closest 
00216   // point is disqualified from being a closest point to given vertex.
00217   double SEARCH_RADIUS_SQ; // nm * nm
00218 
00219   // The closest point to a vertex is found by first searching
00220   // a region defined by MIN_SEARCH_CONE_RADIUS. While no
00221   // closest point is found the search region is expanded up to
00222   // SEARCH_RADIUS_SQ in NUMBER_RADIUS_STEPS.
00223   int NUMBER_RADIUS_STEPS;       // must be greater than zero
00224   double MIN_SEARCH_CONE_RADIUS; // nm
00225 
00226   //  maximum allowed angle between closest point and vertex normal
00227   //  precompute cosine and sine of angle
00228   double CLOSEST_POINT_ANGLE; // radians
00229   double CLOSEST_POINT_COSINE;
00230   double CLOSEST_POINT_SINE;
00231 
00232   // if USE_EDGE_REFERENCE_LENGTH == true
00233   // then compare edge lengths to instantaneous 
00234   // mean edge length of adjacent faces to edge
00235   // else use original length of each edge
00236   int USE_EDGE_REFERENCE_LENGTH;
00237 
00238   // NOTE!! If USE_EDGE_REFERENCE_LENGTH==false
00239   // need to implemenet aspect_ratio detection
00240   // using the constants defined below
00241   // whereby edges associated with adjacent faces
00242   // with aspect ratios greater than ASPECT_RATIO_THRESHOLD
00243   // will experience a force to improve the aspect_ratio
00244   // proportional to ASPECT_GAIN
00245 //  double FACE_ASPECT_RATIO_GAIN;
00246 
00247   // Force Function Weights
00248   // Weights are normalized during the force calculation,
00249   // so all that matters is the ratio of the four weights.
00250   // NOTE THESE MUST SUM TO 100!!!!!!!!!!!!!!!
00251   double INTERSECTION_WEIGHT; // nN
00252   double EDGE_LENGTH_WEIGHT;  // nN/nm
00253   double ECW_WEIGHT;          // nN/nm
00254   double EDGE_ANGLE_WEIGHT;   // nN
00255 
00256   // Force Function gains
00257   // The four principal forces are functions of
00258   // their associated error multiplied by a gain
00259   double ECW_GAIN;
00260   double EDGE_ANGLE_GAIN;
00261   double EDGE_LENGTH_GAIN;
00262   double ASPECT_RATIO_GAIN;
00263   double ASPECT_RATIO_THRESHOLD;
00264 
00265   // The displacement of each vertex is equal to
00266   // the product of the calculated force using the relative weights
00267   // from above and the overall gain.
00268   // It could be interesting to think of mapping from force to displacement
00269   // as motion of a massless particle in a viscous fluid, where
00270   // the overall gain is the time step (s) divided by damping (nN/(nm/s)).
00271   double OVERALL_GAIN;
00272 
00273   // number of vertex moves per group
00274   int GROUP_SIZE;
00275   
00276   // honor GROUP_SIZE specified from command line
00277   int REDEFINE_GROUP_SIZE;
00278 
00279   // Number of groups of GROUP_SIZE vertex moves to execute.
00280   int NUM_GROUPS;
00281 
00282   // honor NUM_GROUPS specified from command line
00283   int REDEFINE_NUM_GROUPS;
00284 
00285   // size of vertex move refractory period
00286   // i.e. the minimum number of vertex moves between moves of the same vertex
00287   int REFRACTORY_PERIOD;
00288 
00289   // maximum number of moves each vertex may make per group
00290   int MAX_TOUCHES;
00291 
00292   // energy averaging window size
00293   int ENERGY_WINDOW;
00294 
00295   // calculate and record total model energy
00296   // with the following period
00297   int ENERGY_SAMPLE_PERIOD;
00298 
00299   // minimum acceptable virtual displacment of vertex
00300   // if virtual_displacement*virtual_displacement < MIN_DISPLACEMENT_SQ
00301   //  then put vertex into refractory period
00302   double MIN_DISPLACEMENT_SQ;
00303 
00304 
00305   // desired distance between object surfaces
00306   double TARGET_ECW; // nm
00307 
00308   // If ECW_THRESHOLD is specified, then vertices with an extracellular width
00309   // greater than or equal to ECW_THREHSOLD will be morphed so as to have
00310   // an extracellular width of size TARGET_ECW_HIGH.
00311   // Vertices with an extracellular width less
00312   // than ECW_THRESHOLD will be morphed so as to have
00313   // an extracellular width of size TARGET_ECW_LOW.
00314   double ECW_THRESHOLD; // nm
00315   double TARGET_ECW_HIGH; // nm
00316   double TARGET_ECW_LOW; // nm
00317 
00318   // If gain scheduling is not disabled, then after
00319   // each group the maximum allwed gain is decremented
00320   // by NUM*overall_gain/num_groups. If NUM is positive
00321   // then the maximum gain decreases. If NUM is negative
00322   // then the maximum gain increases.
00323   double GAIN_STEP;
00324 
00325   // vertex single-move displacement shall be capped at MAX_ACTUAL_DISPL_SQ.
00326   // i.e. if (disp>MAX_ACTUAL_DISPL_SQ) then disp=MAX_ACTUAL_DISPL_SQ
00327   // max ratio of vertex displacement to minimum adjacent face edge length
00328   // max 5.7392 (asin(0.1)) degree change in edge angle
00329   // (although vertices on high aspect ratio faces could be moved a lot)
00330   double MAX_ACTUAL_DISPL_FRACTION;
00331 
00332   // maximum allowed runtime in seconds
00333   double MAX_RUNTIME;
00334 
00335   // number of vertex moves in cycle with disabled printing
00336   // alternating with a single vertex move logged to stdout
00337   // minimum value == 1 which will print each vertex move
00338   int PRINT_PERIOD;
00339   int BEGIN_SHORT_PRINT_PERIOD;
00340 
00341   // if true then print detailed information about moved vertex
00342   // else do nothing
00343   int ENABLE_VTRACK;
00344 
00345   int DISABLE_GAIN_SCHEDULING;
00346 
00347   // initial size of vectors to avoid vector resizing
00348   // and consequent data copying
00349   int VECTOR_RESERVE;
00350 
00351   std::string INPUT_DATA_DIR;
00352   std::string OUTPUT_DATA_DIR;
00353   std::string FROZEN_VERTICES_FILE;
00354   std::string VERTEX_SEQUENCE_FILE;
00355 
00356   std::string MESH_OUTPUT_SUFFIX;
00357   std::string MAIN_LOG_FILE;
00358   std::string CONT_LOG_FILE;
00359   std::string SEP_LOG_FILE;
00360   std::string OBJECT_LIST_FILE;
00361   std::string CONTROL_FILE;
00362   std::string VERTEX_SELECTION_FILE;
00363   std::string REFRACTED_FILE;
00364   std::string INTERSECTED_FILE;
00365   std::string NONNICE_FILE;
00366   
00367   // Small extracellular width for which closest point
00368   // can be outside of search cone
00369   double SMALL_ECW_THRESHOLD;
00370 
00371   // if true then do not print messages from refractory and virtual_displacement classes
00372   // else do nothing
00373   int DISABLE_MESSAGES;
00374 
00375   // if true, then measure and write to file
00376   // the extracellular width in the model
00377   // then exit
00378   int MEASURE_ECW_AND_EXIT;
00379 };
00380 
00381 #endif

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