Ejemplo n.º 1
0
 public ImageClasificationModel(ModelOptions options)
 {
     _options     = options;
     Context      = new MLContext(1);
     Context.Log += Context_Log;
     Input        = options.Input;
 }
        public RectangularCrossSection(ModelOptions modelOption, double x, double y, double depth)
        {
            //Position of the 2D rectangular section (Will remain fixed).
            CartesianPoint2D  p           = CartesianPoint2D.Origin(modelOption.Model);
            DirectionVector2D v           = DirectionVector2D.UnitX(modelOption.Model);
            PlacementAxis2D   postion     = new PlacementAxis2D(modelOption.Model, p, v);
            RectangleProfile  rectProfile = new RectangleProfile(modelOption.Model, x, y, Xbim.Ifc2x3.ProfileResource.IfcProfileTypeEnum.AREA, postion);


            //Local placement of the 3D definition shape of the column(Will remain fixed).
            CartesianPoint3D    Expoint        = CartesianPoint3D.Origin(modelOption.Model);
            DirectionVector3D   exMain         = DirectionVector3D.UnitZ(modelOption.Model);
            DirectionVector3D   exReff         = DirectionVector3D.UnitX(modelOption.Model);
            PlacementAxis3D     Exaxis         = new PlacementAxis3D(modelOption.Model, Expoint, exMain, exReff);
            DirectionVector3D   extVec         = DirectionVector3D.UnitZ(modelOption.Model);
            ExtrudedAreaSolid   solid          = new ExtrudedAreaSolid(modelOption.Model, depth, rectProfile, extVec, Exaxis);
            ShapeRepresentation representation = new ShapeRepresentation(modelOption.Model, modelOption.Environment.SubContext, new List <ExtrudedAreaSolid>()
            {
                solid
            });

            ProductShape = new ProductionDefinitionShape(modelOption.Model, new List <ShapeRepresentation>()
            {
                representation
            });



            //Local placement of the object placement of the column (This will be manipulated according to Autodesk Revit readings).
            CartesianPoint3D  point     = CartesianPoint3D.Origin(modelOption.Model);
            DirectionVector3D main      = DirectionVector3D.UnitZ(modelOption.Model);
            DirectionVector3D reff      = DirectionVector3D.UnitX(modelOption.Model);
            PlacementAxis3D   axis      = new PlacementAxis3D(modelOption.Model, point, main, reff);
            LocalPlacement    placement = new LocalPlacement(modelOption.Model, modelOption.Environment.Stories.FirstOrDefault().LocalPlacement, axis);
        }
Ejemplo n.º 3
0
        public void customize_property()
        {
            ModelOptions modelOptions = new ModelOptions();

            modelOptions.Configure <TargetEntity>()
            .Member(m => m.Value)
            .Setter(Lambda(
                        Parameter(typeof(TargetEntity), out Expression entity),
                        Parameter(typeof(int), out Expression value),
                        Parameter(typeof(IMapperContext), out Expression context),
                        Block(
                            Assign(Property(entity, nameof(TargetEntity.Value)), value),
                            Call("Add", Field(entity, "_modified"), Constant(nameof(TargetEntity.Value)))
                            )
                        ));

            Mapper mapper = new Mapper(
                Options.Create(modelOptions),
                new TypeMapFactory());

            var result = mapper.Map <SourceEntity, TargetEntity>(new SourceEntity {
                Value = 2
            });

            bool contains = result.IsSet(nameof(TargetEntity.Value));

            Assert.True(contains);
        }
Ejemplo n.º 4
0
        static async Task RunModelsAsync(ModelOptions options)
        {
            var file = await OpenContainerAsync(options) as IModelContainer;

            await ProcessModelsAsync(options, file);

            Goodbye();
        }
Ejemplo n.º 5
0
 /// <summary>
 ///     Create new instance.
 /// </summary>
 public TimedModelService(IServiceProvider serviceProvider,
                          ILogger <TimedModelService> logger,
                          IOptions <ModelOptions> options)
 {
     _servicesProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
     _logger           = logger ?? throw new ArgumentNullException(nameof(logger));
     _options          = options?.Value ?? throw new ArgumentNullException(nameof(options));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Parameters(QueryBuilder pQuery, Model pModel)
        {
            _query = pQuery;
            _model = pModel;
            _settings = pModel.Settings;
            _source = pModel.DataSource;

            Data = new Dictionary<string, object>();
        }
Ejemplo n.º 7
0
        public DetachedDbContext(DbContextOptions options)
            : base(options)
        {
            ModelOptions modelOptions = new ModelOptions();

            modelOptions.Conventions.Add(new IsEntityConvention(this));
            OnMapperCreating(modelOptions);
            Mapper        = new Mapper(Options.Create(modelOptions), new TypeMapFactory());
            QueryProvider = new QueryProvider(Mapper);
        }
Ejemplo n.º 8
0
        public ITypeOptions Create(ModelOptions options, Type type)
        {
            ITypeOptions result = null;

            if (type.IsDictionary(out Type keyType, out Type valueType) &&
                keyType == typeof(string) &&
                valueType == typeof(object))
            {
                result = _typeOptions;
            }

            return(result);
        }
Ejemplo n.º 9
0
 public void Apply(ModelOptions modelOptions, ClassTypeOptions typeOptions)
 {
     if (!typeOptions.Members.Any(m => m.IsKey))
     {
         foreach (ClassMemberOptions memberOptions in typeOptions.Members)
         {
             if (memberOptions.Name == "Id")
             {
                 memberOptions.IsKey = true;
                 return;
             }
         }
     }
 }
Ejemplo n.º 10
0
        public void customize_constructor()
        {
            ModelOptions modelOptions = new ModelOptions();

            modelOptions.Configure <TargetEntity>().Constructor(c => new TargetEntity(1));

            Mapper mapper = new Mapper(
                Options.Create(modelOptions),
                new TypeMapFactory());

            var result = mapper.Map <SourceEntity, TargetEntity>(new SourceEntity {
                Value = 2
            });

            Assert.Equal(1, result.Id);
            Assert.Equal(2, result.Value);
        }
Ejemplo n.º 11
0
        public bool IsBackReference(
            ModelOptions options,
            TypeMap typeMap,
            IMemberOptions memberOptions,
            out BackReferenceMap backReferenceMap)
        {
            bool result = false;

            backReferenceMap = null;

            ITypeOptions memberTypeOptions = options.GetTypeOptions(memberOptions.Type);

            if (typeMap.Parent != null)
            {
                if (typeMap.TargetOptions.IsEntity &&
                    (typeMap.Parent.TargetOptions.Type == memberTypeOptions.Type ||
                     typeMap.Parent.TargetOptions.Type == memberTypeOptions.ItemType))
                {
                    backReferenceMap = new BackReferenceMap
                    {
                        MemberOptions     = memberOptions,
                        MemberTypeOptions = options.GetTypeOptions(memberOptions.Type),
                        Parent            = typeMap.Parent
                    };
                    result = true;
                }
                else if (typeMap.Parent.Parent != null &&
                         typeMap.Parent.TargetOptions.IsCollection &&
                         (typeMap.Parent.Parent.TargetOptions.Type == memberTypeOptions.Type ||
                          typeMap.Parent.Parent.TargetOptions.Type == memberTypeOptions.ItemType))
                {
                    backReferenceMap = new BackReferenceMap
                    {
                        MemberOptions     = memberOptions,
                        MemberTypeOptions = options.GetTypeOptions(memberOptions.Type),
                        Parent            = typeMap.Parent.Parent
                    };
                    result = true;
                }
            }

            return(result);
        }
Ejemplo n.º 12
0
        static async Task ProcessModelsAsync(ModelOptions options, IModelContainer container)
        {
            string dir = options.InputFile + ".models";

            Directory.CreateDirectory(dir);

            for (int i = 0; i < container.ModelCount; i++)
            {
                var model = await container.GetModelAsync(i);

                WriteLine($"Found model #{i}; Extracting to OBJ...");

                string filePath = Path.Combine(dir, $"model_{i}.obj");
                using (var writer = File.CreateText(filePath))
                {
                    await model.WriteToOBJAsync(writer);
                }

                WriteLine($"Conversion successful! Wrote output to file: {filePath}", OutputImportance.Verbose);
            }
        }
Ejemplo n.º 13
0
 public override void Apply(AggregationAttribute annotation, ModelOptions modelOptions, ClassTypeOptions typeOptions, ClassMemberOptions memberOptions)
 {
     memberOptions.Owned = false;
 }
Ejemplo n.º 14
0
 protected virtual void OnMapperCreating(ModelOptions options)
 {
 }
Ejemplo n.º 15
0
 public override void Apply(KeyAttribute annotation, ModelOptions modelOptions, ClassTypeOptions typeOptions, ClassMemberOptions memberOptions)
 {
     memberOptions.IsKey = true;
 }
Ejemplo n.º 16
0
 public override void Apply(CompositionAttribute annotation, ModelOptions modelOptions, ClassTypeOptions typeOptions, ClassMemberOptions memberOptions)
 {
     memberOptions.Owned = true;
 }
Ejemplo n.º 17
0
 public void Apply(Attribute annotation, ModelOptions modelOptions, ClassTypeOptions typeOptions, ClassMemberOptions memberOptions)
 {
     Apply((TAttribute)annotation, modelOptions, typeOptions, memberOptions);
 }
Ejemplo n.º 18
0
 public abstract void Apply(TAttribute annotation, ModelOptions modelOptions, ClassTypeOptions typeOptions, ClassMemberOptions memberOptions);
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            //CHANGE PATH HERE.
            string path = @"C:\Users\Scorias\Desktop\IFC trails";

            var editor = new XbimEditorCredentials
            {
                ApplicationDevelopersName = "xBIM Team",
                ApplicationFullName       = "xBIM Toolkit",
                ApplicationIdentifier     = "xBIM",
                ApplicationVersion        = "4.0",
                EditorsFamilyName         = "MoSalah",
                EditorsGivenName          = "sane",
                EditorsOrganisationName   = "Independent"
            };

            RevitSeeker seeker;

            string filename = "RF";
            string filepath = @"C:\Users\Scorias\Desktop\IFC trails";

            using (var stepModel = IfcStore.Open($"{filepath}\\{filename}.ifc"))
            {
                seeker = new RevitSeeker(stepModel);
            }



            using (IfcStore model = IfcStore.Create(editor, IfcSchemaVersion.Ifc2X3, XbimStoreType.InMemoryModel))
            {
                using (var txn = model.BeginTransaction("Initialise Model"))
                {
                    Environment  env    = Environment.Create(model);
                    ModelOptions option = new ModelOptions(model, env);



                    //Local placement of the main storey.
                    LocalPlacement storeyPlacement = new LocalPlacement(model, env.Building.LocalPlacement, env.ProjectAxis);
                    BuildingStorey storey          = new BuildingStorey(model, "Story", storeyPlacement, IfcElementCompositionEnum.ELEMENT, 0);
                    env.AddStorey(model, storey);


                    //Assigning the material and the main column.
                    Material material = new Material(model, "S235JR");


                    var RevitColumns = seeker.RevitColumns;
                    List <TeklaPlate> StoryComponants = new List <TeklaPlate>();
                    TeklaPlatePlacementInitializer plateInitializer;

                    foreach (var rColumn in RevitColumns)
                    {
                        List <RevitPlate> rColumnComp = rColumn.Components;
                        foreach (var revitPlate in rColumnComp)
                        {
                            plateInitializer = new TeklaPlatePlacementInitializer(model, env, revitPlate.Origin, revitPlate.Axis, revitPlate.ReffDirection);
                            TeklaPlate plate = new TeklaPlate(option, plateInitializer.LocalPlacement, revitPlate.OverallWidth, revitPlate.OverallDepth, revitPlate.Height);
                            StoryComponants.Add(plate);
                            plate.AssignMaterial(material);
                        }
                    }
                    storey.AddModelObject(StoryComponants.ToArray());
                    txn.Commit();
                }
                model.SaveAs($"{path}\\TheRealMindWurks.ifcxml");
            }
        }
Ejemplo n.º 20
0
 public PatchJsonConverterFactory(IOptions <ModelOptions> options)
 {
     _options = options.Value;
 }
Ejemplo n.º 21
0
 public override void Apply(PatchAttribute annotation, ModelOptions modelOptions, ClassTypeOptions typeOptions, ClassMemberOptions memberOptions)
 {
     typeOptions.UsePatchProxy = true;
 }
Ejemplo n.º 22
0
 protected override void OnMapperCreating(ModelOptions options)
 {
 }
Ejemplo n.º 23
0
 public override void Apply(NotMappedAttribute annotation, ModelOptions modelOptions, ClassTypeOptions typeOptions, ClassMemberOptions memberOptions)
 {
     memberOptions.Ignored = true;
 }
Ejemplo n.º 24
0
 public void Apply(ModelOptions modelOptions, ClassTypeOptions typeOptions)
 {
     typeOptions.IsEntity = _dbContext.Model.FindEntityType(typeOptions.Type) != null;
 }
Ejemplo n.º 25
0
        public TypeMap Create(Mapper mapper, ModelOptions options, TypeMap parentMap, Type sourceType, Type targetType, bool owned)
        {
            TypeMap typeMap = new TypeMap();

            typeMap.Parent        = parentMap;
            typeMap.Mapper        = mapper;
            typeMap.SourceOptions = options.GetTypeOptions(sourceType);
            typeMap.Source        = Parameter(sourceType, "source_" + sourceType.Name);
            typeMap.TargetOptions = options.GetTypeOptions(targetType);
            typeMap.Target        = Parameter(targetType, "target_" + targetType.Name);
            typeMap.Owned         = owned;

            if (parentMap == null)
            {
                typeMap.Context = Parameter(typeof(IMapperContext), "context");
            }
            else
            {
                typeMap.Context = parentMap.Context;
            }

            while (parentMap != null)
            {
                if (typeMap.TargetOptions == parentMap.TargetOptions &&
                    typeMap.SourceOptions == parentMap.SourceOptions &&
                    typeMap.Owned == parentMap.Owned)
                {
                    return(parentMap);
                }
                parentMap = parentMap.Parent;
            }

            if (typeMap.TargetOptions.IsCollection)
            {
                Type sourceItemType = typeMap.SourceOptions.ItemType;
                Type targetItemType = typeMap.TargetOptions.ItemType;

                if (typeMap.SourceOptions.Type == typeof(object))
                {
                    sourceItemType = typeof(object);
                }

                typeMap.ItemMap = Create(mapper, options, typeMap, sourceItemType, targetItemType, owned);
            }
            else if (typeMap.TargetOptions.IsComplexType)
            {
                IEnumerable <string> memberNames = typeMap.TargetOptions.MemberNames;
                if (memberNames != null)
                {
                    foreach (string memberName in memberNames)
                    {
                        IMemberOptions targetMemberOptions = typeMap.TargetOptions.GetMember(memberName);

                        if (targetMemberOptions != null && targetMemberOptions.CanWrite && !targetMemberOptions.Ignored)
                        {
                            if (IsBackReference(options, typeMap, targetMemberOptions, out BackReferenceMap backRefMap))
                            {
                                typeMap.BackReference = backRefMap;
                            }
                            else
                            {
                                IMemberOptions sourceMemberOptions = typeMap.SourceOptions.GetMember(memberName);

                                if (sourceMemberOptions != null && sourceMemberOptions.CanRead && !sourceMemberOptions.Ignored)
                                {
                                    MemberMap memberMap = new MemberMap();
                                    memberMap.SourceOptions = sourceMemberOptions;
                                    memberMap.TargetOptions = targetMemberOptions;
                                    memberMap.TypeMap       = Create(
                                        mapper,
                                        options,
                                        typeMap,
                                        memberMap.SourceOptions.Type,
                                        memberMap.TargetOptions.Type,
                                        targetMemberOptions.Owned);

                                    typeMap.Members.Add(memberMap);
                                }
                            }
                        }
                    }
                }
            }

            return(typeMap);
        }