private void UnitOfLength_SelectionChanged(object sender, SelectionChangedEventArgs e) { Length_Unit_Types lut = (Length_Unit_Types)UnitOfLength.SelectedItem; updateTextBoxUnits(unitType, lut); unitType = lut; }
/// <summary> /// Creates an instance of <c>Sequence</c> from its string representation. /// </summary> /// <param name="lines">The lines.</param> /// <param name="cellularFloor">The cellular floor.</param> /// <param name="tolerance">The tolerance.</param> /// <returns>Sequence.</returns> /// <exception cref="System.ArgumentException"> /// The name is invalid for a sequence! /// or /// The 'Activation Lambda Factor' is invalid for a sequence! /// or /// The sequence does not include any activities! /// </exception> public static Sequence FromStringRepresentation(List <string> lines, Length_Unit_Types unitType, CellularFloor cellularFloor, double tolerance = 0.0000001d) { if (string.IsNullOrWhiteSpace(lines[0]) || string.IsNullOrEmpty(lines[0])) { throw new ArgumentException("The name is invalid for a sequence!"); } double lambda = 0; if (!double.TryParse(lines[1], out lambda)) { throw new ArgumentException("The 'Activation Lambda Factor' is invalid for a sequence!"); } var activities = lines[2].Split(','); var purged = new List <string>(); foreach (var item in activities) { if (!(string.IsNullOrWhiteSpace(item) && string.IsNullOrEmpty(item))) { purged.Add(item); } } if (purged.Count == 0) { throw new ArgumentException("The sequence does not include any activities!"); } Sequence sequence = new Sequence(purged, lines[0].Trim(' '), lambda); if (lines.Count > 3) { var visualEvent = VisibilityTarget.FromString(lines, 3, unitType, cellularFloor, tolerance); sequence.AssignVisualEvent(visualEvent); } return(sequence); }
public static double ConvertScale(Length_Unit_Types originalType, Length_Unit_Types expectedType) { if (originalType == expectedType) { return(1.0); } //check system equality bool originalSystem = IsImperial(originalType); bool expectedSystem = IsImperial(expectedType); if (originalSystem == expectedSystem) //same unit systems { if (originalSystem) //both imperial units { double scale = ToFeetScale(originalType) * FromFeetScale(expectedType); return(scale); } else //both metric units { double scale = ToMeterScale(originalType) * FromMeterScale(expectedType); return(scale); } } //different unit systems double scale_ = ToMeterScale(originalType) * FromMeterScale(expectedType); return(scale_); }
private static bool IsImperial(Length_Unit_Types unit_type) { if (unit_type == Length_Unit_Types.INCHES || unit_type == Length_Unit_Types.FEET) { return(true); } return(false); }
public static double Convert(double length, Length_Unit_Types originalType, Length_Unit_Types expectedType) { if (originalType == expectedType) { return(length); } double scale = ConvertScale(originalType, expectedType); return(length * scale); }
public static double Convert(double length, Length_Unit_Types originalType, Length_Unit_Types expectedType, int decimalRoundingFactor) { if (originalType == expectedType) { return(length); } double scale = ConvertScale(originalType, expectedType); return(Math.Round(length * scale, decimalRoundingFactor)); }
private static bool IsMetric(Length_Unit_Types unit_type) { if (unit_type == Length_Unit_Types.METERS || unit_type == Length_Unit_Types.DECIMETERS || unit_type == Length_Unit_Types.CENTIMETERS || unit_type == Length_Unit_Types.MILLIMETERS) { return(true); } return(false); }
public static void Transform(UV value, Length_Unit_Types originalType, Length_Unit_Types expectedType) { if (originalType == expectedType) { return; } double scale = ConvertScale(originalType, expectedType); value.U *= scale; value.V *= scale; }
/// <summary> /// Creates an instance of the event from its string representation . /// </summary> /// <param name="lines">The lines.</param> /// <param name="start">The start.</param> /// <param name="cellularFloor">The cellular floor.</param> /// <param name="tolerance">The tolerance.</param> /// <returns>VisibilityEvaluationEvent.</returns> public static VisibilityTarget FromString(List <String> lines, int start, Length_Unit_Types unitType, CellularFloor cellularFloor, double tolerance = 0.0000001d) { List <SpatialAnalysis.Geometry.BarrierPolygon> barriers = new List <Geometry.BarrierPolygon>(); for (int i = start; i < lines.Count; i++) { var barrier = SpatialAnalysis.Geometry.BarrierPolygon.FromStringRepresentation(lines[i]); UnitConversion.Transform(barrier.BoundaryPoints, unitType, cellularFloor.UnitType); barriers.Add(barrier); } return(new VisibilityTarget(barriers, cellularFloor, tolerance)); }
public static void Transform(IList <double> values, Length_Unit_Types originalType, Length_Unit_Types expectedType) { if (originalType == expectedType) { return; } double scale = ConvertScale(originalType, expectedType); for (int i = 0; i < values.Count; i++) { values[i] *= scale; } }
public static void Transform(IEnumerable <UV> values, Length_Unit_Types originalType, Length_Unit_Types expectedType) { if (originalType == expectedType) { return; } double scale = ConvertScale(originalType, expectedType); foreach (UV item in values) { item.U *= scale; item.V *= scale; } }
void updateTextBoxUnits(Length_Unit_Types original, Length_Unit_Types expected) { double number = 0.0; if (double.TryParse(ObstacleSetting.Text, out number)) { ObstacleSetting.Text = UnitConversion.Convert(number, original, expected).ToString("0.000000"); } if (double.TryParse(CurveApproximationLength_.Text, out number)) { CurveApproximationLength_.Text = UnitConversion.Convert(number, original, expected).ToString("0.000000"); } if (double.TryParse(MinimumCurveLength_.Text, out number)) { MinimumCurveLength_.Text = UnitConversion.Convert(number, original, expected).ToString("0.000000"); } }
public static void LoadDefaultParameters(Length_Unit_Types unitTypeOrigin, Length_Unit_Types unitTypeExpected) { UnitConversion cntr = new UnitConversion(unitTypeOrigin, unitTypeExpected); DefaultParameters = new Dictionary <AgentParameters, Parameter> { //{FreeNavigationAgentParameters.OPT_IsovistInternalDepth.ToString(), // Parameter.CreateReadOnly(FreeNavigationAgentParameters.OPT_IsovistInternalDepth.ToString(), 5.0d, 1.0d,5.0d)}, { AgentParameters.OPT_IsovistExternalDepth, Parameter.CreateReadOnly(AgentParameters.OPT_IsovistExternalDepth.ToString(), cntr.Convert(20.0d, 6), cntr.Convert(5.0d, 6), cntr.Convert(25.0d, 6)) }, { AgentParameters.OPT_NumberOfDestinations, Parameter.CreateReadOnly(AgentParameters.OPT_NumberOfDestinations.ToString(), 100.0d, 20.0d, 200.0d) }, { AgentParameters.OPT_AngleDistributionLambdaFactor, Parameter.CreateReadOnly(AgentParameters.OPT_AngleDistributionLambdaFactor.ToString(), 2.5d, 0.001d, 3.0d) }, { AgentParameters.OPT_DesirabilityDistributionLambdaFactor, Parameter.CreateReadOnly(AgentParameters.OPT_DesirabilityDistributionLambdaFactor.ToString(), 1.5d, 0.001d, 3.0d) }, { AgentParameters.OPT_DecisionMakingPeriodLambdaFactor, Parameter.CreateReadOnly(AgentParameters.OPT_DecisionMakingPeriodLambdaFactor.ToString(), 0.88d, 0.05d, 2.0d) }, { AgentParameters.GEN_VelocityMagnitude, Parameter.CreateReadOnly(AgentParameters.GEN_VelocityMagnitude.ToString(), cntr.Convert(3.8, 6), cntr.Convert(2.0d, 6), cntr.Convert(5.0d, 6)) }, { AgentParameters.GEN_AngularVelocity, Parameter.CreateReadOnly(AgentParameters.GEN_AngularVelocity.ToString(), Math.PI, 0.1d, 6.283185d) }, { AgentParameters.GEN_BodySize, Parameter.CreateReadOnly(AgentParameters.GEN_BodySize.ToString(), cntr.Convert(1.80d, 6), cntr.Convert(1.0d, 6), cntr.Convert(2.2d, 6)) }, { AgentParameters.GEN_VisibilityAngle, Parameter.CreateReadOnly(AgentParameters.GEN_VisibilityAngle.ToString(), 160.0d, 0.0d, 180.0d) }, { AgentParameters.GEN_BarrierRepulsionRange, Parameter.CreateReadOnly(AgentParameters.GEN_BarrierRepulsionRange.ToString(), cntr.Convert(1.4d, 6), cntr.Convert(1.0d, 6), cntr.Convert(5.0d, 6)) }, { AgentParameters.GEN_MaximumRepulsion, Parameter.CreateReadOnly(AgentParameters.GEN_MaximumRepulsion.ToString(), cntr.Convert(15.0d, 6), cntr.Convert(1.0d, 6), cntr.Convert(20.0d, 6)) }, { AgentParameters.GEN_AccelerationMagnitude, Parameter.CreateReadOnly(AgentParameters.GEN_AccelerationMagnitude.ToString(), cntr.Convert(15.0d, 6), cntr.Convert(5.0d, 6), cntr.Convert(20.0d, 6)) }, { AgentParameters.GEN_BarrierFriction, Parameter.CreateReadOnly(AgentParameters.GEN_BarrierFriction.ToString(), 0.1d, 0.0d, 1.0d) }, { AgentParameters.GEN_AgentBodyElasticity, Parameter.CreateReadOnly(AgentParameters.GEN_AgentBodyElasticity.ToString(), 0.2d, 0.0d, 1.0d) }, { AgentParameters.MAN_AngularDeviationCost, Parameter.CreateReadOnly(AgentParameters.MAN_AngularDeviationCost.ToString(), 3.0d, 1.0d, 7.0d) }, { AgentParameters.MAN_DistanceCost, Parameter.CreateReadOnly(AgentParameters.MAN_DistanceCost.ToString(), cntr.Convert(1.0d, 6), cntr.Convert(0.05d, 6), cntr.Convert(2.0d, 6)) }, //{AgentParameters.MAN_GAUSSIANNEIGHBORHOODSIZE, // Parameter.CreateReadOnly(AgentParameters.MAN_AngularDeviationCost.ToString(),7,2,20)}, }; }
private static double FromMeterScale(Length_Unit_Types expectedType) { switch (expectedType) { case Length_Unit_Types.METERS: break; case Length_Unit_Types.DECIMETERS: return(10.0); case Length_Unit_Types.CENTIMETERS: return(100.0); case Length_Unit_Types.MILLIMETERS: return(1000.0); case Length_Unit_Types.FEET: return(3.280839895); case Length_Unit_Types.INCHES: return(3.280839895 * 12.0); } return(1.0); }
private static double ToMeterScale(Length_Unit_Types originalType) { switch (originalType) { case Length_Unit_Types.METERS: break; case Length_Unit_Types.DECIMETERS: return(1.0 / 10.0); case Length_Unit_Types.CENTIMETERS: return(1.0 / 100.0); case Length_Unit_Types.MILLIMETERS: return(1.0 / 1000.0); case Length_Unit_Types.FEET: return(1.0 / 3.280839895); case Length_Unit_Types.INCHES: return(1.0 / (12.0 * 3.280839895)); } return(1.0); }
private static double FromFeetScale(Length_Unit_Types expectedType) { switch (expectedType) { case Length_Unit_Types.METERS: return(1.0 / 3.280839895); case Length_Unit_Types.DECIMETERS: return(1.0 / 0.3280839895); case Length_Unit_Types.CENTIMETERS: return(1.0 / 0.03280839895); case Length_Unit_Types.MILLIMETERS: return(1.0 / 0.003280839895); case Length_Unit_Types.FEET: break; case Length_Unit_Types.INCHES: return(12.0); } return(1.0); }
private static double ToFeetScale(Length_Unit_Types originalType) { switch (originalType) { case Length_Unit_Types.METERS: return(3.280839895); case Length_Unit_Types.DECIMETERS: return(0.3280839895); case Length_Unit_Types.CENTIMETERS: return(0.03280839895); case Length_Unit_Types.MILLIMETERS: return(0.003280839895); case Length_Unit_Types.FEET: break; case Length_Unit_Types.INCHES: return(1.0 / 12.0); } return(1.0);//feet mapped to feet }
private static double FromMeter(double length, Length_Unit_Types expectedType) { double scale = FromMeterScale(expectedType); return(length * scale); }
public UnitConversion(Length_Unit_Types origin, Length_Unit_Types expected) { this.FromUnit = origin; this.ToUnit = expected; }
private static double ToFeet(double length, Length_Unit_Types originalType) { double scale = ToFeetScale(originalType); return(length * scale); }
/// <summary> /// Initializes a new instance of the <see cref="OSM_ENV_Setting"/> class. /// </summary> /// <param name="document">The Revit document.</param> /// <exception cref="ArgumentException">There are no 'Floor Plans' in this document!</exception> public OSM_ENV_Setting(Document document) { InitializeComponent(); this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; #region Getting the names of the levels that have floors assosiated to them FilteredElementCollector floorViewCollector = new FilteredElementCollector(document).OfClass(typeof(ViewPlan)); floorPlanNames = new List <ViewPlan>(); foreach (ViewPlan item in floorViewCollector) { if (item.ViewType == ViewType.FloorPlan && item.IsTemplate == false && item.Name != "Site") { FilteredElementCollector floorCollector = new FilteredElementCollector(document, item.Id).OfClass(typeof(Floor)); bool hasFloor = false; foreach (Floor floor in floorCollector) { hasFloor = true; break; } floorCollector.Dispose();//releasing memory if (hasFloor) { floorPlanNames.Add(item); this.LevelMenu.Items.Add(item.Name); } } } floorViewCollector.Dispose();//releasing memory if (this.floorPlanNames.Count == 0) { throw new ArgumentException("There are no 'Floor Plans' in this document!"); } #endregion this.DoorIds = new HashSet <ElementId>(); this.uidoc = new UIDocument(document); this.KeyDown += new System.Windows.Input.KeyEventHandler(FloorSetting_KeyDown); //set units UnitOfLength.Items.Add(Length_Unit_Types.FEET); UnitOfLength.Items.Add(Length_Unit_Types.INCHES); UnitOfLength.Items.Add(Length_Unit_Types.METERS); UnitOfLength.Items.Add(Length_Unit_Types.DECIMETERS); UnitOfLength.Items.Add(Length_Unit_Types.CENTIMETERS); UnitOfLength.Items.Add(Length_Unit_Types.MILLIMETERS); //get unit from Revit document FormatOptions format = document.GetUnits().GetFormatOptions(UnitType.UT_Length); DisplayUnitType lengthUnitType = format.DisplayUnits; bool formatParsed = false; switch (lengthUnitType) { case DisplayUnitType.DUT_METERS: unitType = Length_Unit_Types.METERS; formatParsed = true; break; case DisplayUnitType.DUT_CENTIMETERS: unitType = Length_Unit_Types.CENTIMETERS; formatParsed = true; break; case DisplayUnitType.DUT_DECIMETERS: unitType = Length_Unit_Types.DECIMETERS; formatParsed = true; break; case DisplayUnitType.DUT_MILLIMETERS: unitType = Length_Unit_Types.MILLIMETERS; formatParsed = true; break; case DisplayUnitType.DUT_DECIMAL_FEET: unitType = Length_Unit_Types.FEET; formatParsed = true; break; case DisplayUnitType.DUT_FEET_FRACTIONAL_INCHES: unitType = Length_Unit_Types.FEET; formatParsed = true; break; case DisplayUnitType.DUT_FRACTIONAL_INCHES: unitType = Length_Unit_Types.INCHES; formatParsed = true; break; case DisplayUnitType.DUT_DECIMAL_INCHES: unitType = Length_Unit_Types.INCHES; formatParsed = true; break; case DisplayUnitType.DUT_METERS_CENTIMETERS: unitType = Length_Unit_Types.METERS; formatParsed = true; break; default: break; } if (!formatParsed) { MessageBox.Show("Failed to parse length unit system: " + lengthUnitType.ToString() + "\n" + "The default choice is 'Feet'.\n" + "Select a unit type from the available options." , "Length Unit", MessageBoxButton.OK, MessageBoxImage.Warning); unitType = Length_Unit_Types.FEET; UnitOfLength.SelectedItem = unitType; } else { UnitOfLength.IsEditable = false; UnitOfLength.IsHitTestVisible = false; UnitOfLength.Focusable = false; UnitOfLength.SelectedItem = unitType; updateTextBoxUnits(Length_Unit_Types.FEET, unitType); } UnitOfLength.SelectionChanged += UnitOfLength_SelectionChanged; }
void _loadSequence_Click(object sender, RoutedEventArgs e) { var dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Title = "Load Sequences"; dlg.DefaultExt = ".seq"; dlg.Filter = "SEQ documents (.seq)|*.seq"; Nullable <bool> result = dlg.ShowDialog(this._host); string fileAddress = ""; if (result == true) { fileAddress = dlg.FileName; } else { return; } bool unitAssigned = false; Length_Unit_Types unitType = Length_Unit_Types.FEET; string unitString = "UNIT:"; List <string> lines = new List <string>(); using (System.IO.StreamReader sr = new System.IO.StreamReader(fileAddress)) { string line = string.Empty; while ((line = sr.ReadLine()) != null) { if (!(string.IsNullOrEmpty(line) || string.IsNullOrWhiteSpace(line))) { line = line.Trim(' '); if (line[0] != '#') { if (line.Length > unitString.Length && line.Substring(0, unitString.Length).ToUpper() == unitString.ToUpper()) { string unitName = line.Substring(unitString.Length, line.Length - unitString.Length).ToUpper().Trim(' '); switch (unitName) { case "METERS": unitAssigned = true; unitType = Length_Unit_Types.METERS; break; case "DECIMETERS": unitAssigned = true; unitType = Length_Unit_Types.DECIMETERS; break; case "CENTIMETERS": unitAssigned = true; unitType = Length_Unit_Types.CENTIMETERS; break; case "MILLIMETERS": unitAssigned = true; unitType = Length_Unit_Types.MILLIMETERS; break; case "FEET": unitAssigned = true; unitType = Length_Unit_Types.FEET; break; case "INCHES": unitAssigned = true; unitType = Length_Unit_Types.METERS; break; } } else { lines.Add(line); } } } } } if (lines.Count == 0) { MessageBox.Show("The file includes no input", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (!unitAssigned) { MessageBox.Show("The did not include information for 'Unit of Length'", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } List <List <string> > inputs = new List <List <string> >(); List <string> input = new List <string>(); for (int i = 0; i < lines.Count; i++) { if (lines[i] == "SEQUENCE") { if (input.Count != 0) { List <string> list = new List <string>(input); inputs.Add(list); input.Clear(); } } else { input.Add(lines[i]); } } if (input.Count != 0) { inputs.Add(input); } foreach (List <string> item in inputs) { try { var sequence = Sequence.FromStringRepresentation(item, unitType, this._host.cellularFloor, 0.0000001d); bool add = true; foreach (var activityName in sequence.ActivityNames) { if (!this._host.AllActivities.ContainsKey(activityName)) { MessageBox.Show("The sequence " + sequence.Name + " includes an activity which is not included in the document: " + activityName, "Missing Input", MessageBoxButton.OK, MessageBoxImage.Error); add = false; break; } } if (add) { if (this._host.AgentMandatoryScenario.Sequences.Contains(sequence)) { MessageBox.Show("The sequence " + sequence.Name + " is already included in the document", "Missing Input", MessageBoxButton.OK, MessageBoxImage.Error); add = false; } } if (add) { this._host.AgentMandatoryScenario.Sequences.Add(sequence); } } catch (Exception error) { MessageBox.Show(error.Report()); } } this._existingSequences.Items.Refresh(); }
void _load_Click(object sender, RoutedEventArgs e) { var dlg = new Microsoft.Win32.OpenFileDialog(); dlg.Title = "Load Activities"; dlg.DefaultExt = ".act"; dlg.Filter = "act documents (.act)|*.act"; Nullable <bool> result = dlg.ShowDialog(this._host); string fileAddress = ""; if (result == true) { fileAddress = dlg.FileName; } else { return; } string unitString = "UNIT:"; bool unitAssigned = false; Length_Unit_Types lengthUnitTypes = Length_Unit_Types.FEET; List <string> lines = new List <string>(); using (System.IO.StreamReader sr = new System.IO.StreamReader(fileAddress)) { string line = string.Empty; while ((line = sr.ReadLine()) != null) { if (!(string.IsNullOrEmpty(line) || string.IsNullOrWhiteSpace(line))) { line = line.TrimStart(' '); if (line[0] != '#')//remove comments { if (line.Length > unitString.Length && line.Substring(0, unitString.Length).ToUpper() == unitString.ToUpper()) { string unitName = line.Substring(unitString.Length, line.Length - unitString.Length).ToUpper().Trim(' '); switch (unitName) { case "METERS": unitAssigned = true; lengthUnitTypes = Length_Unit_Types.METERS; break; case "DECIMETERS": unitAssigned = true; lengthUnitTypes = Length_Unit_Types.DECIMETERS; break; case "CENTIMETERS": unitAssigned = true; lengthUnitTypes = Length_Unit_Types.CENTIMETERS; break; case "MILLIMETERS": unitAssigned = true; lengthUnitTypes = Length_Unit_Types.MILLIMETERS; break; case "FEET": unitAssigned = true; lengthUnitTypes = Length_Unit_Types.FEET; break; case "INCHES": unitAssigned = true; lengthUnitTypes = Length_Unit_Types.METERS; break; default: MessageBox.Show("Failed to parse unit information", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } } else { lines.Add(line); } } } } } if (lines.Count == 0) { MessageBox.Show("The file includes no input", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } //find the project unit type if (!unitAssigned) { MessageBox.Show("The did not include information for 'Unit of Length'", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } int n = 7; if (this._includeGuassian.IsChecked.Value) { double _n = 0; if (!double.TryParse(this._range_guassian.Text, out _n)) { MessageBox.Show("'Neighborhood Size' should be a valid number larger than 0", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } n = (int)_n; if (n < 1) { MessageBox.Show("'Neighborhood Size' should be a valid number larger than 0", "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } } double r = 0; if (!double.TryParse(this._range.Text, out r)) { MessageBox.Show("'Neighborhood Size' should be a number larger than 1", "Missing Input", MessageBoxButton.OK, MessageBoxImage.Information); return; } int range = (int)r; if (range < 1) { MessageBox.Show("'Neighborhood Size' should be a number larger than 1", "Missing Input", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (this._host.FieldGenerator == null || this._host.FieldGenerator.Range != range) { this._host.FieldGenerator = new SpatialDataCalculator(this._host, range, OSMDocument.AbsoluteTolerance); } List <ActivityDestination> destinations = new List <ActivityDestination>(); for (int i = 0; i < lines.Count / 4; i++) { try { ActivityDestination destination = ActivityDestination.FromString(lines, i * 4, lengthUnitTypes, this._host.cellularFloor); if (this._host.AllActivities.ContainsKey(destination.Name)) { MessageBox.Show("An activity with the same name exists!", "", MessageBoxButton.OK, MessageBoxImage.Error); } else { destinations.Add(destination); } } catch (Exception error) { MessageBox.Show(error.Report()); } } if (destinations.Count == 0) { return; } Dispatcher.Invoke(new Action(() => { this._report.Visibility = System.Windows.Visibility.Visible; this.grid.IsEnabled = false; this._progressBar.Maximum = destinations.Count; this._activityName.Text = string.Empty; }), System.Windows.Threading.DispatcherPriority.ContextIdle); int count = 0; foreach (var item in destinations) { Dispatcher.Invoke(new Action(() => { this._activityName.Text = item.Name; }), System.Windows.Threading.DispatcherPriority.ContextIdle); count++; try { Activity newField = null; if (this._includeAngularCost.IsChecked.Value) { //double angularVelocityWeight = 0; if (Parameter.DefaultParameters[AgentParameters.MAN_AngularDeviationCost].Value <= 0) { MessageBox.Show("Cost of angular change should be exclusively larger than zero", "Activity Generation", MessageBoxButton.OK, MessageBoxImage.Information); return; } newField = this._host.FieldGenerator.GetDynamicActivity(item, Parameter.DefaultParameters[AgentParameters.MAN_AngularDeviationCost].Value); if (!newField.TrySetEngagementTime(item.MinimumEngagementTime, item.MinimumEngagementTime)) { throw new ArgumentException("Failed to set activity engagement duration!"); } } else { newField = this._host.FieldGenerator.GetStaticActivity(item); if (!newField.TrySetEngagementTime(item.MinimumEngagementTime, item.MaximumEngagementTime)) { throw new ArgumentException("Failed to set activity engagement duration!"); } } if (this._includeGuassian.IsChecked.Value) { //update filter if (this._host.ViewBasedGaussianFilter != null) { if (this._host.ViewBasedGaussianFilter.Range != n) { try { this._host.ViewBasedGaussianFilter = new IsovistClippedGaussian(this._host.cellularFloor, n); } catch (Exception error) { MessageBox.Show(error.Report(), "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } } } else { try { this._host.ViewBasedGaussianFilter = new IsovistClippedGaussian(this._host.cellularFloor, n); } catch (Exception error) { MessageBox.Show(error.Report(), "Invalid Input", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } } var data = this._host.ViewBasedGaussianFilter.GetFilteredValues(newField); newField.Potentials = data; } this._host.AddActivity(newField); } catch (Exception error) { MessageBox.Show(error.Report()); } this.updateProgressBar(count); } this.Close(); }
public OSM_To_Revit(Length_Unit_Types OSM_unit) { //revit uses double values to represent feet imperial unit this.unitConversion = new UnitConversion(OSM_unit, Length_Unit_Types.FEET); }
/// <summary> /// creates an Activity Destination from its string representation /// </summary> /// <param name="lines">The lines.</param> /// <param name="startIndex">The start index.</param> /// <param name="cellularFloor">The cellular floor.</param> /// <param name="tolerance">The tolerance.</param> /// <returns>ActivityDestination.</returns> /// <exception cref="System.ArgumentException"> /// Activity does not include a name! /// or /// Failed to parse activity's engagement duration: " + lines[startIndex + 3] /// or /// Activity does not include cell origins! /// or /// Failed to set activity engagement duration! /// </exception> public static ActivityDestination FromString(List <string> lines, int startIndex, Length_Unit_Types unitType, CellularFloor cellularFloor, double tolerance = 0.0000001d) { string name = lines[startIndex]; if (string.IsNullOrEmpty(lines[startIndex]) || string.IsNullOrWhiteSpace(lines[startIndex])) { throw new ArgumentException("Activity does not include a name!"); } StateBase state = StateBase.FromStringRepresentation(lines[startIndex + 1]); BarrierPolygon barrier = BarrierPolygon.FromStringRepresentation(lines[startIndex + 2]); //unit converion UnitConversion.Transform(state.Location, unitType, cellularFloor.UnitType); UnitConversion.Transform(state.Velocity, unitType, cellularFloor.UnitType); UnitConversion.Transform(barrier.BoundaryPoints, unitType, cellularFloor.UnitType); var strings = lines[startIndex + 3].Split(','); double min = 0, max = 0; if (!double.TryParse(strings[0], out min) || !double.TryParse(strings[1], out max)) { throw new ArgumentException("Failed to parse activity's engagement duration: " + lines[startIndex + 3]); } HashSet <Cell> origins = new HashSet <Cell>(); var indices = cellularFloor.GetIndicesInsideBarrier(barrier, tolerance); if (indices.Count > 0) { foreach (var index in indices) { Cell cell = cellularFloor.FindCell(index); if (cell != null && cell.FieldOverlapState == OverlapState.Inside) { origins.Add(cell); } } } if (origins.Count == 0) { throw new ArgumentException("Activity does not include cell origins!"); } ActivityDestination dest = new ActivityDestination(name, origins, state, barrier); if (!dest.TrySetEngagementTime(min, max)) { throw new ArgumentException("Failed to set activity engagement duration!"); } return(dest); }