public static SceneBuildSettings ByParameters(string transformationStrategy, string positioningStrategy, CRSTransform crs, UnitScale unitScale, string[] sceneContexts, string identificationStrategy) { if (string.IsNullOrEmpty(transformationStrategy) || string.IsNullOrEmpty(positioningStrategy) || string.IsNullOrEmpty(identificationStrategy)) { throw new ArgumentNullException("transformationStrategy | positioningStrategy | identificationStrategy"); } var settings = new SceneBuildSettings(new ExportPreferences { Transforming = DynamicArgumentDelegation.TryCastEnumOrDefault <SceneTransformationStrategy>(transformationStrategy), Positioning = DynamicArgumentDelegation.TryCastEnumOrDefault <ScenePositioningStrategy>(positioningStrategy), UserModelCenter = crs.Transform.T, CRS = crs.Transform.R * (unitScale?.UnitsPerMeter ?? 1), SelectedContext = sceneContexts?.Select(c => new SceneContext { Name = c.ToQualifier() }).ToArray() ?? new SceneContext[] { }, ComponentIdentificationStrategy = DynamicArgumentDelegation.TryCastEnumOrDefault <SceneComponentIdentificationStrategy>(identificationStrategy) }); return(settings); }
public static CanonicalFilter ByCanonicals(object matchingTypeEnum, Canonical[] canonicals) { var matchingType = DynamicArgumentDelegation.TryCastEnumOrDefault <Bitub.Dto.Concept.FilterMatchingType>(matchingTypeEnum); var filter = new Bitub.Dto.Concept.CanonicalFilter(matchingType, StringComparison.OrdinalIgnoreCase); if (null != canonicals) { filter.Filter.AddRange(canonicals.Select(c => c.Qualifier.ToClassifier())); } return(new CanonicalFilter(filter)); }
/// <summary> /// Directly retrieves the validations messages. /// </summary> /// <param name="validationTask">The task</param> /// <param name="reportFilter">The IfcReportDomain filter</param> /// <returns>An array of messages</returns> public static IfcValidationMessage[] Messages(IfcValidationTask validationTask, object reportFilter) { IfcReportDomain domainFilter; if (!DynamicArgumentDelegation.TryCastEnum <IfcReportDomain>(reportFilter, out domainFilter)) { log.LogWarning($"Parsing reportFilter failed in ({nameof(IfcValidationResult.Messages)}. Using '{domainFilter}'."); domainFilter = IfcReportDomain.AllIssues; } return(validationTask?.Result().Messages(domainFilter)); }
/// <summary> /// Retrieve all messages of given type. /// </summary> /// <param name="reportFilter">The IfcReportDomain filter</param> /// <returns>The validation messages</returns> public IfcValidationMessage[] Messages(object reportFilter) { IfcReportDomain domainFilter; if (!DynamicArgumentDelegation.TryCastEnum <IfcReportDomain>(reportFilter, out domainFilter)) { log.LogWarning($"Parsing reportFilter failed in ({nameof(IfcValidationResult.Messages)}. Using '{domainFilter}'."); domainFilter = IfcReportDomain.AllIssues; } return(MessagePipe.Where(m => domainFilter.HasFlag(m.Domain)).ToArray()); }
public static IfcTransform NewRepresentationRefactorTransform(Logger logInstance, IfcAuthorMetadata newMetadata, string[] contexts, object refactorStrategy) { ProductRefactorStrategy strategy = default(ProductRefactorStrategy); if (!DynamicArgumentDelegation.TryCastEnum(refactorStrategy, out strategy)) { log.LogWarning("Unable to cast '{0}' to type {1}. Using '{2}'.", refactorStrategy, nameof(ProductRefactorStrategy), strategy); } return(new IfcTransform(new ProductRepresentationRefactorTransform(logInstance?.LoggerFactory, defaultLogFilter) { ContextIdentifiers = contexts, Strategy = strategy, EditorCredentials = newMetadata?.MetaData.ToEditorCredentials() })); }
public static IfcTransform NewTransformPlacementRequest(Logger logInstance, IfcAuthorMetadata newMetadata, Alignment alignment, object placementStrategy) { ModelPlacementStrategy strategy = default(ModelPlacementStrategy); if (!DynamicArgumentDelegation.TryCastEnum(placementStrategy, out strategy)) { log.LogWarning("Unable to cast '{0}' to type {1}. Using '{2}'.", placementStrategy, nameof(ModelPlacementStrategy), strategy); } return(new IfcTransform(new ModelPlacementTransform(logInstance?.LoggerFactory, defaultLogFilter) { AxisAlignment = alignment.TheAxisAlignment, PlacementStrategy = strategy, EditorCredentials = newMetadata?.MetaData.ToEditorCredentials() })); }
private void RestoreSelection(string[] serializedSelection) { var restored = DynamicArgumentDelegation .FilterBySerializationValue(NodeModel.Items.ToArray(), serializedSelection, false) .Cast <AstReference>(); DispatchUI(() => { if (0 == _control?.SelectionListBox.SelectedItems.Count) { foreach (var astReference in restored) { _control.SelectionListBox.SelectedItems.Add(astReference); } } }); }
public static IfcModel BySourceAndTransform(IfcModel source, IfcTransform transform, string nameAddon, object objFilterMask) { if (null == source) { throw new ArgumentNullException(nameof(source)); } if (null == transform) { throw new ArgumentNullException(nameof(transform)); } if (null == nameAddon) { nameAddon = transform.Mark; } LogReason filterMask = DynamicArgumentDelegation.TryCastEnumOrDefault(objFilterMask, LogReason.Any); if (null == transform.CancellationSource) { transform.CancellationSource = new CancellationTokenSource(); } return(IfcStore.ByTransform(source, (model, node) => { log.LogInformation("Starting '{1}' ({0}) on {2} ...", node.GetHashCode(), transform.transformDelegate.Name, node.Name); try { using (var task = transform.transformDelegate.Run(model, node.CreateProgressMonitor(LogReason.Transformed))) { task.Wait(transform.TimeOutMillis, transform.CancellationSource.Token); log.LogInformation("Finalized '{1}' ({0}) on {2}.", node.GetHashCode(), transform.transformDelegate.Name, node.Name); if (task.IsCompleted) { if (node is ProgressingTask np) { np.OnProgressEnded(LogReason.Changed, false); } using (var result = task.Result) { switch (result.ResultCode) { case TransformResult.Code.Finished: var name = $"{transform.transformDelegate.Name}({node.Name})"; node.OnActionLogged(TransformLogToMessage(name, result.Log, filterMask).ToArray()); return result.Target; case TransformResult.Code.Canceled: node.OnActionLogged(LogMessage.BySeverityAndMessage( node.Name, LogSeverity.Error, LogReason.Any, "Canceled by user request ({0}).", node.Name)); break; case TransformResult.Code.ExitWithError: node.OnActionLogged(LogMessage.BySeverityAndMessage( node.Name, LogSeverity.Error, LogReason.Any, "Caught error ({0}): {1}", node.Name, result.Cause)); break; } } } else { if (node is ProgressingTask np) { np.OnProgressEnded(LogReason.Changed, true); } node.OnActionLogged(LogMessage.BySeverityAndMessage( node.Name, LogSeverity.Error, LogReason.Changed, $"Task incompletely terminated (Status {task.Status}).")); } return null; } } catch (Exception thrownOnExec) { log.LogError("{0} '{1}'\n{2}", thrownOnExec, thrownOnExec.Message, thrownOnExec.StackTrace); throw new Exception("Exception while executing task"); } }, nameAddon)); }