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)); }
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)); }