00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef AMLLatticeExpander_hpp
00026 #define AMLLatticeExpander_hpp 1
00027
00028 #include "AML/AMLUtilities.hpp"
00029 #include "UAP/UAPNode.hpp"
00030 #include "UAP/UAPUtilities.hpp"
00031
00037 class AMLLatticeExpander {
00038
00039 public:
00040
00041 AMLLatticeExpander();
00042
00043 ~AMLLatticeExpander();
00044
00054 UAPNode* AMLExpandLattice(UAPNode* UAPRoot);
00055
00061 static bool InheritBookkeeper (UAPNode* root);
00062
00063 private:
00064
00065 UAPNode* scratch_root;
00066 UAPNode* master_root;
00067 UAPNode* control_root;
00068 UAPNode* global_root;
00069 NodeMap sector_map;
00070 NodeMap element_map;
00071 NodeMap girder_map;
00072 NodeMap controller_map;
00073 NodeMap all_map;
00074 NodeVec girder_list;
00075
00076 std::map<std::string, NodeVecCIter> map_list_iter;
00077 std::map<std::string, NodeVec> map_list_children;
00078
00079 StrList sector_call_list;
00080
00081 PrintInfoStruct info_out;
00082 AMLUtilities AU;
00083
00084 struct multipass_struct {
00085 int n_pass;
00086 NodeVec masters;
00087 NodeVecCIter iter;
00088 int direction;
00089 };
00090
00091 typedef std::map<std::string, multipass_struct*> MultiMap;
00092 MultiMap multi_map;
00093 multipass_struct* this_multi;
00094
00095 NodeVec parents;
00096 std::list<NodeVecIter> iter_list;
00097
00098
00099
00100 void make_named_lists(UAPNode* root);
00101 bool expand_machines (UAPNode* aml_rep, UAPNode* expand_root);
00102 bool connect_branch_and_merger (UAPNode* expand_root);
00103 bool add_controls (UAPNode* aml_rep, UAPNode* expand_root);
00104
00105 void expand_this_machine (UAPNode* machine_in, UAPNode* aml_rep, UAPNode* expand_root);
00106 void transfer_node_info_to_machine (std::string who, UAPNode* aml_rep,
00107 UAPNode* machine_in, UAPNode* machine);
00108
00109 void transfer_info_to_new_node (UAPNode* old_node, UAPNode* new_node);
00110 void expand_this_sector_or_list (UAPNode* lat_root, UAPNode* sector_in,
00111 int direction, bool multipass, bool expanding_a_list, std::string tag);
00112
00113 void add_this_element_or_sector (UAPNode* lat_root, UAPNode* node, StrMap& arg_map,
00114 int direction, bool multipass, bool expanding_a_list, std::string tag);
00115
00116 bool get_arg_map (UAPNode* main_sector, UAPNode* sub_sector, StrMap& arg_map);
00117
00118 void add_multipass_element (UAPNode* element);
00119 void calc_s_positions (UAPNode* tracking_root);
00120 void convert_to_actual (UAPNode* tracking_root);
00121
00122 void superimpose_sector_given_ref (UAPNode* super_sect_in,
00123 UAPNode* ref_ele, std::string ref_origin = "");
00124 void superimpose_sector_given_s (UAPNode* super_sect_in, double s_entrance,
00125 UAPNode* machine_root, std::string tag = "");
00126 void superimpose_element (UAPNode* super_ele, UAPNode* tracking_lattice);
00127 UAPNode* superimpose_element_given_ref (UAPNode* super_ele, UAPNode* ref_ele);
00128 UAPNode* superimpose_element_given_s (UAPNode* ele_in, double s_ref,
00129 UAPNode* machine_root);
00130
00131 NodeVec get_named_elements (const std::string& ref_name, UAPNode* root);
00132
00133 void apply_sets (std::string set_str, std::string value_str, UAPNode* aml_rep);
00134 void apply_post_sets (std::string set_str, std::string value_str,
00135 UAPNode* aml_rep, UAPNode* target_root);
00136
00137 UAPNode* tree_transverser (UAPNode* root = NULL);
00138
00151 void map_sub_nodes(UAPNode* root, const std::string& _name, const std::string& _attribute,
00152 NodeMap& map, StrList& duplicates, bool clear = true);
00153
00154 static void inherit_from (UAPNode* parent_ref);
00155 static void inherit_pusher (UAPNode* from_child, UAPNode* to_node);
00156
00157 };
00158
00159 #endif