Пример #1
0
        public void CreateProductIfc(ProductIfcRequest request,
                                     Stream outputStream)
        {
            IfcPerson person = IfcInit.CreatePerson(request.owner.person.givenName,
                                                    request.owner.person.familyName,
                                                    request.owner.person.identifier);
            IfcOrganization organization =
                IfcInit.CreateOrganization(request.owner.organization.name,
                                           request.owner.organization.description,
                                           request.owner.organization.identifier);
            IfcOrganization applicationOrganization =
                IfcInit.CreateOrganization(request.owner.application.organization.name,
                                           request.owner.application.organization.description,
                                           request.owner.application.organization.identifier);
            IfcApplication application =
                IfcInit.CreateApplication(applicationOrganization,
                                          request.owner.application.version,
                                          request.owner.application.name,
                                          request.owner.application.identifier);
            IfcOwnerHistory ownerHistory =
                IfcInit.CreateOwnerHistory(person, organization, application);

            IfcProject project = IfcInit.CreateProject(request.project.name,
                                                       request.project.description,
                                                       ownerHistory);
            IfcSite site = IfcInit.CreateSite(null, null, ownerHistory);

            project.Aggregate(site, ownerHistory);
            IfcBuilding building =
                IfcInit.CreateBuilding(null, null, ownerHistory, site.ObjectPlacement);

            site.Aggregate(building, ownerHistory);
            IfcBuildingStorey storey =
                IfcInit.CreateBuildingStorey(null, null, ownerHistory, building.ObjectPlacement);

            building.Aggregate(storey, ownerHistory);
            IfcProduct product;

            switch (request.product.type)
            {
            default:
                product = IfcInit.CreateProxy(request.product.name,
                                              request.product.description,
                                              ownerHistory,
                                              storey.ObjectPlacement,
                                              null);
                break;
            }
            List <IfcRepresentationContext> contextList =
                new List <IfcRepresentationContext> (project.RepresentationContexts);

            product.Representation =
                CreateProductRepresentation(contextList, request.product.representations);
            storey.Contains(product, ownerHistory);
            project.SerializeToStep(outputStream, request.schema.ToString(), null);
            return;
        }
Пример #2
0
        public void ExtrudeAndRevolveTest()
        {
            //Set up project hierarchy
            IfcProject project = IfcInit.CreateProject(null, null, null);
            IfcSite    site    = IfcInit.CreateSite(null, null, null);

            project.Aggregate(site, null);
            IfcBuilding building = IfcInit.CreateBuilding(null, null, null, null);

            site.Aggregate(building, null);
            IfcBuildingStorey storey = IfcInit.CreateBuildingStorey(null, null, null, null);

            building.Aggregate(storey, null);

            //Create shape representation
            // -- extruded profile shape
            IfcPolyline outerCurve = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { -0.5, -0.5 },
                new double[] { -0.5, 0.5 },
                new double[] { 0.5, 0.5 },
                new double[] { 0.5, -0.5 },
                new double[] { -0.5, -0.5 }
            });
            IfcProfileDef profileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA,
                                                                        null,
                                                                        outerCurve);
            IfcRepresentationItem extrudedRepresentation = profileDef.Extrude(1).Rotate(new double[] { 45, 0, 45 }).Translate(new double[] { -2, 0, 0 });

            // -- revolved profile shape
            IfcRepresentationItem revolvedRepresentation = profileDef.Revolve(-45,
                                                                              new IfcAxis1Placement(new IfcCartesianPoint(1, 0, 0),
                                                                                                    new IfcDirection(0, 1, 0)),
                                                                              null);

            //Create product with representation and place in storey
            var contextEnum = project.RepresentationContexts.GetEnumerator();

            contextEnum.MoveNext();
            IfcShapeRepresentation shapeRepresentation =
                new IfcShapeRepresentation(contextEnum.Current,
                                           new IfcLabel("extruded square"),
                                           new IfcLabel("SweptSolid"),
                                           new IfcRepresentationItem[] { extrudedRepresentation, revolvedRepresentation });
            IfcProxy product = IfcInit.CreateProxy(null, null, null, storey.ObjectPlacement, null);

            product.Representation = new IfcProductDefinitionShape(null, null, new IfcRepresentation[] { shapeRepresentation });;
            storey.Contains(product, null);

            //Write to IFC file
            using (FileStream fs = File.Create("./swept_geom_test.ifc"))
            {
                project.SerializeToStep(fs, "IFC2X3", null);
            }
        }
Пример #3
0
        public void CreateProjectInitTest()
        {
            //==== DEFAULT PROJECT ====
            IfcProject project_default = IfcInit.CreateProject(null, null, null);
            IfcSite    site_default    = IfcInit.CreateSite(null, null, null);

            project_default.Aggregate(site_default, null);
            IfcBuilding building_default = IfcInit.CreateBuilding(null, null, null, null);

            site_default.Aggregate(building_default, null);
            IfcBuildingStorey storey_default = IfcInit.CreateBuildingStorey(null, null, null, null);

            building_default.Aggregate(storey_default, null);
            using (FileStream fs = File.Create("./default_project.ifc"))
            {
                project_default.SerializeToStep(fs, "IFC2X3", null);
            }

            //==== MANUAL CONTENT PROJECT ====
            IfcPerson       person       = IfcInit.CreatePerson("Melange", "Cedric");
            IfcOrganization organization = IfcInit.CreateOrganization("test organization", "a dummy organization for testing", "MyOrg");
            IfcApplication  application  = IfcInit.CreateApplication(organization, "1.0", "test app", "TestApp");
            IfcOwnerHistory ownerHistory = IfcInit.CreateOwnerHistory(person,
                                                                      organization,
                                                                      application);
            IfcProject project_manual = IfcInit.CreateProject("manual",
                                                              "My manual test project",
                                                              ownerHistory);
            IfcSite site_manual = IfcInit.CreateSite("test site", "a dummy site for testing", ownerHistory);

            project_manual.Aggregate(site_manual, ownerHistory);
            IfcBuilding building_manual = IfcInit.CreateBuilding("test building", "a dummy building for testing", ownerHistory, site_manual.ObjectPlacement);

            site_manual.Aggregate(building_manual, ownerHistory);
            IfcBuildingStorey storey_manual = IfcInit.CreateBuildingStorey("first storey", "first storey for testing", ownerHistory, building_manual.ObjectPlacement);

            building_manual.Aggregate(storey_manual, null);
            using (FileStream fs = File.Create("./manual_project.ifc"))
            {
                project_manual.SerializeToStep(fs, "IFC2X3", "my company");
            }
        }
Пример #4
0
        public void BooleanOperatorTest()
        {
            //Set up project hierarchy
            IfcProject project = IfcInit.CreateProject(null, null, null);
            IfcSite    site    = IfcInit.CreateSite(null, null, null);

            project.Aggregate(site, null);
            IfcBuilding building = IfcInit.CreateBuilding(null, null, null, null);

            site.Aggregate(building, null);
            IfcBuildingStorey storey = IfcInit.CreateBuildingStorey(null, null, null, null);

            building.Aggregate(storey, null);

            //Create shape representation
            IfcCsgPrimitive3D union_first = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(0, 0, 0), null, null),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1));
            IfcCsgPrimitive3D union_second = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(0.5, 0.5, 0.5), null, null),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1));
            IfcRepresentationItem unionRepresentation = union_first.Union(union_second);

            IfcCsgPrimitive3D diff_first = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(2, 0, 0), null, null),
                                                        new IfcPositiveLengthMeasure(1),
                                                        new IfcPositiveLengthMeasure(1),
                                                        new IfcPositiveLengthMeasure(1));
            IfcCsgPrimitive3D diff_second = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(2.5, 0.5, 0.5), null, null),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1));
            IfcRepresentationItem diffRepresentation = diff_first.Difference(diff_second);

            IfcCsgPrimitive3D inter_first = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(4, 0, 0), null, null),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1),
                                                         new IfcPositiveLengthMeasure(1));
            IfcCsgPrimitive3D inter_second = new IfcBlock(new IfcAxis2Placement3D(new IfcCartesianPoint(4.5, 0.5, 0.5), null, null),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1),
                                                          new IfcPositiveLengthMeasure(1));
            IfcRepresentationItem interRepresentation = inter_first.Intersection(inter_second);
            IfcPolyline           outerCurve          = IfcGeom.CreatePolyLine(new List <double[]>()
            {
                new double[] { 6, 0 },
                new double[] { 6, 1 },
                new double[] { 7, 1 },
                new double[] { 7, 0 },
                new double[] { 6, 0 }
            });
            IfcProfileDef profileDef = new IfcArbitraryClosedProfileDef(IfcProfileTypeEnum.AREA,
                                                                        null,
                                                                        outerCurve);
            IfcSweptAreaSolid cut_reference = profileDef.Extrude(1);
            IfcPlane          plane         = IfcGeom.CreatePlane(new double[] { 6.5, 0.5, 0 },
                                                                  new double[] { 1, 1, 0 });
            IfcRepresentationItem cutRepresentation = cut_reference.ClipByPlane(plane);

            //Create product with representation and place in storey
            var contextEnum = project.RepresentationContexts.GetEnumerator();

            contextEnum.MoveNext();
            IfcShapeRepresentation shapeRepresentation =
                new IfcShapeRepresentation(contextEnum.Current,
                                           new IfcLabel("union shape"),
                                           new IfcLabel("BooleanResult"),
                                           new IfcRepresentationItem[] { unionRepresentation, diffRepresentation, interRepresentation, cutRepresentation });
            IfcProxy product = IfcInit.CreateProxy(null, null, null, storey.ObjectPlacement, null);

            product.Representation = new IfcProductDefinitionShape(null, null, new IfcRepresentation[] { shapeRepresentation });
            storey.Contains(product, null);

            //Write to IFC file
            using (FileStream fs = File.Create("./constructive_geom_test.ifc"))
            {
                project.SerializeToStep(fs, "IFC2X3", null);
            }
        }