void ArcPerf::Draw_Link (Arcview_File &file, Link_Data *link_ptr, int dir) { int lane, center, num_lanes, index; double length, side, start, width, offset; bool dir_flag, two_way; XYZ_Point point; Dir_Data *dir_ptr; if (link_ptr->Length () == 0) return; file.clear (); file.parts.clear (); two_way = (dir == 2); if (two_way) dir = 0; //---- bandwidth processing ---- if (bandwidth_flag) { width = file.Get_Double (width_field); if (width < 0) width = -width; if (width < min_value || width == 0) return; width = width / width_factor; if (width < min_width) { width = min_width; } else if (width > max_width) { width = max_width; } width = -width; offset = length = -1; //---- get the centerline points ---- side = (two_way) ? (-width / 2.0) : 0.0; Link_Shape (link_ptr, dir, points, offset, length, side); point = points [0]; file.parts.push_back ((int) file.size ()); file.assign (points.begin (), points.end ()); //---- get the outside points of the band ---- side = (two_way) ? (width / 2.0) : width; Link_Shape (link_ptr, 1 - dir, points, offset, length, side); if (max_angle > 0 && min_length > 0) { Smooth_Shape (points, max_angle, min_length); } file.insert (file.end (), points.begin (), points.end ()); //---- close the polygon ---- file.push_back (point); } else { //---- draw lanes ---- if (lanes_flag) { repeat1: length = UnRound (link_ptr->Length () - link_ptr->Aoffset () - link_ptr->Boffset ()); width = lane_width / 2.0; if (dir) { index = link_ptr->BA_Dir (); start = UnRound (link_ptr->Boffset ()); dir_flag = (link_ptr->AB_Dir () >= 0); } else { index = link_ptr->AB_Dir (); start = UnRound (link_ptr->Aoffset ()); dir_flag = (link_ptr->BA_Dir () >= 0); } if (index >= 0) { dir_ptr = &dir_array [index]; num_lanes = dir_ptr->Lanes () + dir_ptr->Left (); if (center_flag && !dir_flag) { center = num_lanes + dir_ptr->Right () + 1; } else { center = 1; } for (lane = dir_ptr->Left (); lane < num_lanes; lane++) { side = (2 + 2 * lane - center) * width; Link_Shape (link_ptr, dir, points, start, length, side); file.parts.push_back ((int) file.size ()); if (arrow_flag) Add_Arrow (points); file.insert (file.end (), points.begin (), points.end ()); } } if (two_way && dir == 0) { dir = 1; goto repeat1; } } else { if (link_offset != 0.0) { repeat2: //---- draw each direction ---- side = link_offset; if (dir) { index = link_ptr->BA_Dir (); if (center_flag && link_ptr->AB_Dir () < 0) side = 0.0; start = -1.0; } else { index = link_ptr->AB_Dir (); if (center_flag && link_ptr->BA_Dir () < 0) side = 0.0; start = 0.0; } if (index >= 0) { Link_Shape (link_ptr, dir, points, start, -1.0, side); file.parts.push_back ((int) file.size ()); if (arrow_flag) Add_Arrow (points); file.insert (file.end (), points.begin (), points.end ()); } if (two_way && dir == 0) { dir = 1; goto repeat2; } } else { //---- draw centerline ----- file.parts.push_back ((int) file.size ()); if (direction_flag) dir = 0; Link_Shape (link_ptr, dir, file); if (arrow_flag) Add_Arrow (file); } } } //---- write the shape record ---- if (file.size () == 0) return; if (!file.Write_Record ()) { Error (String ("Writing %s") % file.File_Type ()); } }
void ArcPlan::Write_Bandwidth (void) { int dir_index, dir, link_field, dir_field, volume_field; double width, offset, length; XYZ_Point point; Int_Itr volume; Dir_Data *dir_ptr; Link_Data *link_ptr; link_field = arcview_width.Field_Number ("LINK"); dir_field = arcview_width.Field_Number ("DIR"); volume_field = arcview_width.Field_Number ("VOLUME"); Show_Message (String ("Writing %s -- Record") % arcview_width.File_Type ()); Set_Progress (); //---- process each link direction ---- for (dir_index = 0, volume = width_data.begin (); volume != width_data.end (); volume++, dir_index++) { Show_Progress (); if (*volume == 0 || *volume < min_value) continue; //---- write the data fields ---- dir_ptr = &dir_array [dir_index]; link_ptr = &link_array [dir_ptr->Link ()]; arcview_width.Put_Field (link_field, link_ptr->Link ()); arcview_width.Put_Field (dir_field, dir_ptr->Dir ()); arcview_width.Put_Field (volume_field, *volume); dir = dir_ptr->Dir (); width = *volume / width_factor; if (width < min_width) { width = min_width; } else if (width > max_width) { width = max_width; } width = -width; //---- retrieve the link information ---- //length = UnRound (link_ptr->Length ()); //if (dir == 0) { // offset = 0.0; //} else { // offset = length; //} offset = length = -1; //---- get the centerline points ---- arcview_width.clear (); Link_Shape (link_ptr, dir, points, offset, length, 0.0); point = points [0]; arcview_width.assign (points.begin (), points.end ()); //---- get the outside points of the band ---- //offset = length - offset; dir = 1 - dir; Link_Shape (link_ptr, dir, points, offset, length, width); if (max_angle > 0 && min_length > 0) { Smooth_Shape (points, max_angle, min_length); } arcview_width.insert (arcview_width.end (), points.begin (), points.end ()); //---- close the polygon ---- arcview_width.push_back (point); //---- write the shape record ---- if (!arcview_width.Write_Record ()) { Error (String ("Writing %s") % arcview_width.File_Type ()); } num_width++; } End_Progress (); arcview_width.Close (); }
void ArcDelay::Read_Link_Data (void) { int i, center, link, lane, num_lanes, num_rec; double length, side, start, width; bool offset_flag; XYZ_Point point, *ptr; Link_Data *link_ptr; Node_Data *node_ptr; Dir_Data *dir_ptr; offset_flag = (link_offset != 0.0); Show_Message ("Reading %s -- Record", arcview_link_data.File_Type ()); Set_Progress (1000); num_rec = 0; //---- process each link ---- while (link_data_file.Read ()) { Show_Progress (); //---- get the link ---- link = link_data_file.Link (); link_ptr = link_data.Get (link); if (link_ptr == NULL) continue; //---- check the subarea polygon ---- if (subarea_flag) { node_ptr = node_data.Get (link_ptr->Anode ()); if (!In_Polygon (UnRound (node_ptr->X ()), UnRound (node_ptr->Y ()), &select_subarea.points)) { node_ptr = node_data.Get (link_ptr->Bnode ()); if (!In_Polygon (UnRound (node_ptr->X ()), UnRound (node_ptr->Y ()), &select_subarea.points)) { continue; } } } //---- copy the data fields ---- arcview_link_data.Copy_Fields (&link_data_file); arcview_link_data.parts.Reset (); arcview_link_data.points.Reset (); //---- bandwidth processing ---- if (width_flag) { arcview_link_data.Get_Field (width_field, &width); if (width == 0.0) continue; if (width > 0) { width = width / width_factor; } else { width = -width / width_factor; } if (width < min_width) { width = min_width; } else if (width > max_width) { width = max_width; } width = -width; length = UnRound (link_ptr->Length ()); //---- get the centerline points ---- Link_Shape (link_ptr, 0, &points, 0.0, length, 0.0); ptr = points.First (); point = *ptr; if (!arcview_link_data.parts.Add (0)) goto mem_error; for (; ptr; ptr = points.Next ()) { if (!arcview_link_data.points.Add (ptr)) goto point_error; } //---- get the outside points of the band ---- Link_Shape (link_ptr, 1, &points, length, length, width); if (max_angle > 0 && min_length > 0) { Smooth_Shape (&points, max_angle, min_length); } for (ptr = points.First (); ptr; ptr = points.Next ()) { if (!arcview_link_data.points.Add (ptr)) goto point_error; } //---- close the polygon ---- if (!arcview_link_data.points.Add (&point)) goto point_error; } else { //---- draw lanes ---- if (lanes_flag) { if (link_ptr->AB_Dir () > 0) { dir_ptr = dir_data [link_ptr->AB_Dir ()]; if (dir_ptr == NULL) continue; length = UnRound (link_ptr->Length ()); start = UnRound (link_ptr->Aoffset ()); length -= start + UnRound (link_ptr->Boffset ()); lane = dir_ptr->Left (); num_lanes = dir_ptr->Thru () + lane; //---- find the center point ---- if (center_flag && link_ptr->BA_Dir () == 0) { center = num_lanes + dir_ptr->Right () + 1; } else { center = 1; } for (++lane; lane <= num_lanes; lane++) { side = (2 * lane - center) * lane_width / 2.0; Link_Shape (link_ptr, 0, &points, start, length, side); if (!arcview_link_data.parts.Add (arcview_link_data.points.Num_Points ())) goto mem_error; for (i=1; i <= points.Num_Points (); i++) { if (!arcview_link_data.points.Add (points [i])) goto mem_error; } } } if (link_ptr->BA_Dir () > 0) { dir_ptr = dir_data [link_ptr->BA_Dir ()]; if (dir_ptr == NULL) continue; length = UnRound (link_ptr->Length ()); start = length - UnRound (link_ptr->Boffset ()); length = start - UnRound (link_ptr->Aoffset ()); lane = dir_ptr->Left (); num_lanes = dir_ptr->Thru () + lane; //---- find the center point ---- if (center_flag && link_ptr->AB_Dir () == 0) { center = num_lanes + dir_ptr->Right () + 1; } else { center = 1; } for (++lane; lane <= num_lanes; lane++) { side = (2 * lane - center) * lane_width / 2.0; Link_Shape (link_ptr, 1, &points, start, length, side); if (!arcview_link_data.parts.Add (arcview_link_data.points.Num_Points ())) goto mem_error; for (i=1; i <= points.Num_Points (); i++) { if (!arcview_link_data.points.Add (points [i])) goto mem_error; } } } } else { if (offset_flag) { //---- draw link in AB direction ---- if (link_ptr->AB_Dir () > 0) { if (center_flag && link_ptr->BA_Dir () == 0) { side = 0.0; } else { side = link_offset; } Link_Shape (link_ptr, 0, &points, 0.0, -1.0, side); if (!arcview_link_data.parts.Add (0)) goto mem_error; for (i=1; i <= points.Num_Points (); i++) { if (!arcview_link_data.points.Add (points [i])) goto mem_error; } } //---- draw link in BA direciton ---- if (link_ptr->BA_Dir () > 0) { if (center_flag && link_ptr->AB_Dir () == 0) { side = 0.0; } else { side = link_offset; } Link_Shape (link_ptr, 1, &points, -1.0, -1.0, side); if (!arcview_link_data.parts.Add (arcview_link_data.points.Num_Points ())) goto mem_error; for (i=1; i <= points.Num_Points (); i++) { if (!arcview_link_data.points.Add (points [i])) goto mem_error; } } } else { //---- draw centerline ----- if (!arcview_link_data.parts.Add (0)) goto mem_error; Link_Shape (link_ptr, 0, &arcview_link_data.points); } } } //---- save the link record ---- if (!arcview_link_data.Write_Record ()) { Error ("Writing %s", arcview_link_data.File_Type ()); } num_rec++; } End_Progress (); arcview_link_data.Close (); Print (2, "Number of Arcview Link Data Records = %d", num_rec); return; point_error: Error ("Insufficient Memory for %d Points", arcview_link_data.points.Num_Points ()); mem_error: Error ("Insufficient Memory for Link Shape Points"); }