Exemplo n.º 1
0
        private static IfcTrimmedCurve ToIfcTrimmedCurve(this Arc arc, Document doc)
        {
            var t         = new Transform(arc.Plane.Origin, arc.Plane.Normal);
            var placement = t.ToIfcAxis2Placement3D(doc);
            var ifcCircle = new IfcCircle(new IfcAxis2Placement(placement), new IfcPositiveLengthMeasure(arc.Radius));
            var start     = arc.Start.ToIfcCartesianPoint();
            var end       = arc.End.ToIfcCartesianPoint();
            var trim1     = new IfcTrimmingSelect(start);
            var trim2     = new IfcTrimmingSelect(end);
            var tc        = new IfcTrimmedCurve(ifcCircle, new List <IfcTrimmingSelect> {
                trim1
            }, new List <IfcTrimmingSelect> {
                trim2
            },
                                                true, IfcTrimmingPreference.CARTESIAN);

            doc.AddEntity(start);
            doc.AddEntity(end);
            doc.AddEntity(placement);
            doc.AddEntity(ifcCircle);

            return(tc);
        }
Exemplo n.º 2
0
        private static IfcTrimmedCurve ToIfcTrimmedCurve(this Line line, Document doc)
        {
            var start = line.Start.ToIfcCartesianPoint();
            var end   = line.End.ToIfcCartesianPoint();

            var dir = line.Direction().ToIfcVector(doc);

            var ifcLine = new IfcLine(start, dir);
            var trim1   = new IfcTrimmingSelect(start);
            var trim2   = new IfcTrimmingSelect(end);
            var tc      = new IfcTrimmedCurve(ifcLine, new List <IfcTrimmingSelect> {
                trim1
            }, new List <IfcTrimmingSelect> {
                trim2
            },
                                              true, IfcTrimmingPreference.CARTESIAN);

            doc.AddEntity(start);
            doc.AddEntity(end);
            doc.AddEntity(dir);
            doc.AddEntity(ifcLine);

            return(tc);
        }
        public void Circleline2DTest()
        {
            var operandStack = new Stack();

            operandStack.Push("[0.5, -0.5]");   // center
            operandStack.Push("1.5");           // radius
            operandStack.Push("180");           // start parameter
            operandStack.Push("90");            // end parameter
            var operation = OperationName.CIRCLELINE2D;

            ConstructionOperations.ExecuteOperation(operation, operandStack);
            Assert.Single(operandStack);
            var response = operandStack.Pop();

            Assert.IsType <IfcTrimmedCurve>(response);
            IfcTrimmedCurve curve = (IfcTrimmedCurve)response;

            Assert.IsType <IfcCircle>(curve.BasisCurve);
            IfcCircle circle = (IfcCircle)curve.BasisCurve;

            Assert.Equal(0.5, ((IfcAxis2Placement2D)circle.Position).Location.Coordinates[0].Value);
            Assert.Equal(-0.5, ((IfcAxis2Placement2D)circle.Position).Location.Coordinates[1].Value);
            Assert.Equal(1, ((IfcAxis2Placement2D)circle.Position).RefDirection.DirectionRatios[0].Value);
            Assert.Equal(0, ((IfcAxis2Placement2D)circle.Position).RefDirection.DirectionRatios[1].Value);
            Assert.Equal(1.5, circle.Radius.Value.Value);
            var trim1Enumerator = curve.Trim1.GetEnumerator();

            trim1Enumerator.MoveNext();
            Assert.Equal(180, ((IfcParameterValue)trim1Enumerator.Current).Value);
            var trim2Enumerator = curve.Trim2.GetEnumerator();

            trim2Enumerator.MoveNext();
            Assert.Equal(90, ((IfcParameterValue)trim2Enumerator.Current).Value);
            Assert.True(curve.SenseAgreement.Value);
            Assert.Equal(IfcTrimmingPreference.PARAMETER, curve.MasterRepresentation);
        }
Exemplo n.º 4
0
        protected override void GenerateInstance(IfcBuilding building)
        {
            DatabaseIfc database  = building.Database;
            double      angFactor = database.Factory.Options.AngleUnitsInRadians ? 1 : 180 / Math.PI;

            building.Comments.Add("These profile curves are intentionally expressed in a more complicated manner than possible to test parameterization");
            IfcMaterial material = new IfcMaterial(database, "Steel");

            //-IfcBSplineCurve
            //- IfcCompositeCurve
            //- IfcCompositeCurveSegment
            //- IfcIndexedPolyCurve
            //- IfcTrimmedCurve
            //- IfcPCurve ?
            double root2 = Math.Sqrt(2), root2div2 = Math.Sqrt(2) / 2.0, root3 = Math.Sqrt(3), root3div2 = Math.Sqrt(3) / 2.0;

            List <IfcCompositeCurveSegment> segments = new List <IfcCompositeCurveSegment>();
            IfcLine         line                     = new IfcLine(new IfcCartesianPoint(database, -1000, 1000), new IfcVector(new IfcDirection(database, 1, -1), 1000 * Math.Sqrt(2)));
            IfcTrimmedCurve trimmedCurve             = new IfcTrimmedCurve(line, new IfcTrimmingSelect((root2 - 1) / root2), new IfcTrimmingSelect(1 + (1 / root2)), true, IfcTrimmingPreference.PARAMETER);

            segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));
            IfcCircle circle = new IfcCircle(database, 1000);

            trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(7.0 / 4 * Math.PI * angFactor), new IfcTrimmingSelect(3.0 / 4 * Math.PI * angFactor), true, IfcTrimmingPreference.PARAMETER);
            segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));

            string name = "SemiCircle";
            IfcArbitraryClosedProfileDef profile            = new IfcArbitraryClosedProfileDef(name, new IfcCompositeCurve(segments));
            IfcMaterialProfileSet        materialProfileSet = new IfcMaterialProfileSet(name, new IfcMaterialProfile(name, material, profile));
            IfcColumnType columnType = new IfcColumnType(name, materialProfileSet, IfcColumnTypeEnum.COLUMN);

            database.Context.AddDeclared(columnType);
            IfcColumnStandardCase column = new IfcColumnStandardCase(building, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.MID), new IfcAxis2Placement3D(new IfcCartesianPoint(database, 0, 0, 0)), 2000)
            {
                Name = name, RelatingType = columnType
            };

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            columnType.GlobalId = "24mq0gwVr7bgEMXPmo$TrF";
            column.GlobalId     = "0RGc8lepr7BRF_EtHrWJ45";
            columnType.ObjectTypeOf.GlobalId = "0devdSRyf3uBEQbSqWTDjo";
            columnType.MaterialSelect.Associates.GlobalId = "1gdVo5TjPETPZlW8HSRupM";
            column.MaterialSelect.Associates.GlobalId     = "35z8gDFbb6gvrCOz$24tUJ";

            database.NextObjectRecord = 100;
            circle = new IfcCircle(new IfcAxis2Placement2D(new IfcCartesianPoint(database, 0, 1000))
            {
                RefDirection = new IfcDirection(database, -1, 0)
            }, root3 * 1000);
            segments     = new List <IfcCompositeCurveSegment>();
            trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(Math.PI / 3 * angFactor), new IfcTrimmingSelect(2 * Math.PI / 3 * angFactor), true, IfcTrimmingPreference.PARAMETER);
            segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));
            circle = new IfcCircle(new IfcAxis2Placement2D(new IfcCartesianPoint(database, -1000 * root3div2, -500))
            {
                RefDirection = new IfcDirection(database, 0, -1)
            }, root3 * 1000);
            trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(Math.PI / 2 * angFactor), new IfcTrimmingSelect(5 * Math.PI / 6 * angFactor), true, IfcTrimmingPreference.PARAMETER);
            segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));
            circle = new IfcCircle(new IfcAxis2Placement2D(new IfcCartesianPoint(database, 1000 * root3div2, -500))
            {
                RefDirection = new IfcDirection(database, 0, 1)
            }, root3 * 1000);
            trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(Math.PI / 6 * angFactor), new IfcTrimmingSelect(Math.PI / 2 * angFactor), true, IfcTrimmingPreference.PARAMETER);
            segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));

            name               = "CurviLinearTriangle";
            profile            = new IfcArbitraryClosedProfileDef(name, new IfcCompositeCurve(segments));
            materialProfileSet = new IfcMaterialProfileSet(name, new IfcMaterialProfile(name, material, profile));
            columnType         = new IfcColumnType(name, materialProfileSet, IfcColumnTypeEnum.COLUMN);
            database.Context.AddDeclared(columnType);
            column = new IfcColumnStandardCase(building, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.MID), new IfcAxis2Placement3D(new IfcCartesianPoint(database, 2500, 0, 0)), 2000)
            {
                Name = name, RelatingType = columnType
            };

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            columnType.GlobalId = "3N_qc_BjX1hvEgwfRvVcb_";
            column.GlobalId     = "0bmIILAwj8$PLHK1jcmad0";
            columnType.ObjectTypeOf.GlobalId = "3tGocD1N51oOvSvHbJI_qD";
            columnType.MaterialSelect.Associates.GlobalId = "1M5oofzjD3IOM43brXW6wT";
            column.MaterialSelect.Associates.GlobalId     = "0gnTzVmkbE9hPsJDxOUOL3";

            database.NextObjectRecord = 150;
            IfcEllipse ellipse = new IfcEllipse(new IfcAxis2Placement2D(database), 1000, 500);

            segments     = new List <IfcCompositeCurveSegment>();
            trimmedCurve = new IfcTrimmedCurve(ellipse, new IfcTrimmingSelect(0), new IfcTrimmingSelect(Math.PI / 4 * angFactor), true, IfcTrimmingPreference.PARAMETER);
            segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));
            double x = root2div2, y = 0.5 * root2div2, len = Math.Sqrt(0.5 + Math.Pow(y, 2));

            line         = new IfcLine(new IfcCartesianPoint(database, 0, 0), new IfcVector(new IfcDirection(database, x / len, y / len), 1));
            trimmedCurve = new IfcTrimmedCurve(line, new IfcTrimmingSelect(0), new IfcTrimmingSelect(len * 1000), false, IfcTrimmingPreference.PARAMETER);
            segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));
            line         = new IfcLine(new IfcCartesianPoint(database, 0, 0), new IfcVector(new IfcDirection(database, 1, 0), 1));
            trimmedCurve = new IfcTrimmedCurve(line, new IfcTrimmingSelect(0), new IfcTrimmingSelect(1000), true, IfcTrimmingPreference.PARAMETER);
            segments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));

            name               = "PartialEllipse";
            profile            = new IfcArbitraryClosedProfileDef(name, new IfcCompositeCurve(segments));
            materialProfileSet = new IfcMaterialProfileSet(name, new IfcMaterialProfile(name, material, profile));
            columnType         = new IfcColumnType(name, materialProfileSet, IfcColumnTypeEnum.COLUMN);
            database.Context.AddDeclared(columnType);
            column = new IfcColumnStandardCase(building, new IfcMaterialProfileSetUsage(materialProfileSet, IfcCardinalPointReference.MID), new IfcAxis2Placement3D(new IfcCartesianPoint(database, 5000, 0, 0)), 2000)
            {
                Name = name, RelatingType = columnType
            };

            //Unique ids assigned to generate constant IfcScript  sample files, remove otherwise
            columnType.GlobalId = "0dtemVu1P2682BcO3CPWAy";
            column.GlobalId     = "1JCvykjKH71R7_uck4n6hN";
            columnType.ObjectTypeOf.GlobalId = "0rNx6sqCH2mOt1cWOT6zSU";
            columnType.MaterialSelect.Associates.GlobalId = "2OfhB1Dcz2cAdV$CDh9PHV";
            column.MaterialSelect.Associates.GlobalId     = "3bTNkVsf9099xrALHA6WhF";
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            DatabaseIfc db = new DatabaseIfc(ReleaseVersion.IFC4X3_RC2);

            db.Factory.Options.AngleUnitsInRadians  = false;
            db.Factory.Options.GenerateOwnerHistory = false;
            IfcRailway railway = new IfcRailway(db)
            {
                Name = "Default Railway", GlobalId = "2Iw5TO8gL8cQQMnPMEy58o"
            };
            IfcProject project = new IfcProject(railway, "Default Project", IfcUnitAssignment.Length.Metre)
            {
                GlobalId = "2VgFtp_1zCO98zJG_O3kln"
            };

            db.Factory.Options.GenerateOwnerHistory = true;
            project.OwnerHistory = db.Factory.OwnerHistoryAdded;
            db.Factory.Options.GenerateOwnerHistory = false;

            IfcGeometricRepresentationSubContext axisSubContext = db.Factory.SubContext(IfcGeometricRepresentationSubContext.SubContextIdentifier.Axis);

            IfcAlignment alignment = new IfcAlignment(railway)
            {
                Name = "TfNSW Alignment", GlobalId = "1F78QPlVv6N9AnnF$LSkp$"
            };
            IfcCartesianPoint alignmentOrigin = new IfcCartesianPoint(db, 0, 0, 0);

            //IfcCartesianPoint alignmentOrigin = new IfcCartesianPoint(db, 1000, 2000, 3000);
            alignment.ObjectPlacement = new IfcLocalPlacement(new IfcAxis2Placement3D(alignmentOrigin));

            double            lineLength = 100;
            IfcCartesianPoint point1     = new IfcCartesianPoint(db, -lineLength, 0);
            IfcCartesianPoint point2     = new IfcCartesianPoint(db, 0, 0);

            double xc               = 99.89734;
            double radius           = 500;
            double transitionLength = 100;

            double d          = -0.75 * Math.Sqrt(3) * xc / radius;
            double ang1       = (Math.Acos(-0.75 * Math.Sqrt(3) * xc / radius) * 180 / Math.PI / 3) + 240;
            double thiRadians = Math.Asin(2 / Math.Sqrt(3) * Math.Cos(ang1 * Math.PI / 180));
            double thi        = thiRadians * 180 / Math.PI;

            double m  = Math.Tan(thiRadians) / (3 * xc * xc);
            double yc = m * Math.Pow(xc, 3);

            IfcCartesianPoint point3 = new IfcCartesianPoint(db, xc, yc);

            double            cx        = Math.Sin(thiRadians) * radius;
            double            cy        = Math.Cos(thiRadians) * radius;
            IfcCartesianPoint arcCentre = new IfcCartesianPoint(db, xc - cx, yc + cy);

            double arcLength = 100;
            double arcAngle  = arcLength / radius * 180 / Math.PI;

            List <IfcSegment> compositeSegments = new List <IfcSegment>();

            IfcLine xLine = new IfcLine(db.Factory.Origin2d, new IfcVector(new IfcDirection(db, 1, 0), 1));

            IfcAlignmentHorizontalSegment linearSegment = new IfcAlignmentHorizontalSegment(point1, 0, 0, 0, lineLength, IfcAlignmentHorizontalSegmentTypeEnum.LINE);
            IfcLine         line         = new IfcLine(point1, new IfcVector(db.Factory.XAxis, 1));
            IfcTrimmedCurve trimmedCurve = new IfcTrimmedCurve(line, new IfcTrimmingSelect(0, point1), new IfcTrimmingSelect(lineLength, point2), true, IfcTrimmingPreference.PARAMETER);

            compositeSegments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTINUOUS, true, trimmedCurve));

            List <double> coefficientsX = new List <double>()
            {
                0, 1, 0, 0, 0, -0.9 * m * m, 0, 0, 0, 5.175 * Math.Pow(m, 4), 0, 0, 0, -43.1948 * Math.Pow(m, 6), 0, 0, 0, 426.0564 * Math.Pow(m, 8)
            };
            List <double> coefficientsY = new List <double>()
            {
                0, 0, 0, m, 0, 0, 0, -2.7 * Math.Pow(m, 3), 0, 0, 0, 17.955 * Math.Pow(m, 5), 0, 0, 0, -158.258 * Math.Pow(m, 7), 0, 0, 0, 1604.338 * Math.Pow(m, 9)
            };
            IfcSeriesParameterCurve seriesParameterCurve = new IfcSeriesParameterCurve(db.Factory.Origin2dPlace, coefficientsX, coefficientsY);

            IfcAlignmentHorizontalSegment transitionSegment = new IfcAlignmentHorizontalSegment(point2, 0, 0, radius, transitionLength, IfcAlignmentHorizontalSegmentTypeEnum.CUBICSPIRAL);            // { ObjectType = "TfNSW" };

            trimmedCurve = new IfcTrimmedCurve(seriesParameterCurve, new IfcTrimmingSelect(0, point2), new IfcTrimmingSelect(transitionLength, point3), true, IfcTrimmingPreference.PARAMETER);
            compositeSegments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE, true, trimmedCurve));

            IfcAxis2Placement2D circlePlacement = new IfcAxis2Placement2D(arcCentre)
            {
                RefDirection = new IfcDirection(db, Math.Sin(thiRadians), -Math.Cos(thiRadians))
            };
            IfcCircle circle = new IfcCircle(circlePlacement, radius);

            trimmedCurve = new IfcTrimmedCurve(circle, new IfcTrimmingSelect(0, point3), new IfcTrimmingSelect(arcLength / radius * 180 / Math.PI), true, IfcTrimmingPreference.PARAMETER);

            IfcAlignmentHorizontalSegment arcSegment = new IfcAlignmentHorizontalSegment(point3, thi, radius, radius, arcLength, IfcAlignmentHorizontalSegmentTypeEnum.CIRCULARARC);

            compositeSegments.Add(new IfcCompositeCurveSegment(IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE, true, trimmedCurve));

            IfcCompositeCurve alignmentCurve = new IfcCompositeCurve(compositeSegments);

            alignment.Axis = alignmentCurve;

            double startDist = -123;
            IfcAlignmentHorizontal alignmentHorizontal = new IfcAlignmentHorizontal(alignment, linearSegment, transitionSegment, arcSegment)
            {
                StartDistAlong = startDist,
            };

            alignmentHorizontal.GlobalId        = "0sEEGBFgr289x9s$R$T7N9";
            alignmentHorizontal.ObjectPlacement = alignment.ObjectPlacement;
            alignmentHorizontal.Representation  = new IfcProductDefinitionShape(new IfcShapeRepresentation(axisSubContext, alignmentCurve, ShapeRepresentationType.Curve2D));

            IfcAlignmentSegment alignmentSegment = new IfcAlignmentSegment(alignmentHorizontal, transitionSegment);

            alignmentSegment.GlobalId   = "2_crD$eoPDah_QvgsPhXF3";
            alignmentSegment.ObjectType = "TFNSW";
            new IfcPropertySet(alignmentSegment, "TfNSW_Transition", new IfcPropertySingleValue(db, "m", m));

            IfcPointByDistanceExpression verticalDistanceExpression = new IfcPointByDistanceExpression(0, alignmentCurve);
            double startHeight = 25;

            verticalDistanceExpression.OffsetVertical = startHeight;
            IfcAlignmentVerticalSegment verticalSegment = new IfcAlignmentVerticalSegment(db, startDist, lineLength + transitionLength + arcLength, startHeight, 0.01, IfcAlignmentVerticalSegmentTypeEnum.CONSTANTGRADIENT);

            IfcAlignmentVertical alignmentVertical = new IfcAlignmentVertical(alignment, verticalSegment);

            alignmentVertical.GlobalId = "2YR0TUxTv75RC2XxZVmlj8";

            //IfcLinearAxis2Placement verticalAxisPlacement = new IfcLinearAxis2Placement(verticalDistanceExpression);
            //IfcLinearPlacement verticalLinearPlacement = new IfcLinearPlacement(alignmentPlacement, verticalAxisPlacement);
            //alignmentVertical.ObjectPlacement = verticalLinearPlacement;

            //List<IfcCurveSegment> verticalSegments = new List<IfcCurveSegment>();
            //IfcLine linearGradient = new IfcLine(db.Factory.Origin, new IfcVector(new IfcDirection(db, 1, 0, 0.01), 1)); //not right and should it be xy or xz
            //IfcCurveSegment verticalCurveSegment = new IfcCurveSegment(IfcTransitionCode.CONTINUOUS, new IfcAxis2Placement3D(db.Factory.Origin2d), 50, linearGradient);
            //verticalSegments.Add(verticalCurveSegment);
            //IfcAlignmentVerticalSegment verticalSegment = new IfcAlignmentVerticalSegment(alignmentVertical,
            //	verticalLinearPlacement, verticalCurveSegment, 0, 50, startHeight, 0.01,
            //	IfcAlignmentVerticalSegmentTypeEnum.LINE);

            //IfcGradientCurve gradientCurve = new IfcGradientCurve(horizontalCurve, verticalSegments);
            //alignment.Representation = new IfcProductDefinitionShape(new IfcShapeRepresentation(axisSubContext, gradientCurve, ShapeRepresentationType.Curve3D));
            IfcPointByDistanceExpression distanceExpression = new IfcPointByDistanceExpression(150, alignmentCurve);

            distanceExpression.OffsetLateral = 5;
            IfcAxis2PlacementLinear   axis2PlacementLinear   = new IfcAxis2PlacementLinear(distanceExpression);
            IfcLinearPlacement        linearPlacement        = new IfcLinearPlacement(alignment.ObjectPlacement, axis2PlacementLinear);
            IfcExtrudedAreaSolid      extrudedAreaSolid      = new IfcExtrudedAreaSolid(new IfcRectangleProfileDef(db, "", 0.5, 0.5), 5);
            IfcProductDefinitionShape productDefinitionShape = new IfcProductDefinitionShape(new IfcShapeRepresentation(extrudedAreaSolid));
            IfcPile pile = new IfcPile(railway, linearPlacement, productDefinitionShape);

            new IfcRelPositions(db, alignment, new List <IfcProduct>()
            {
                pile
            });

            // Conceptual 50m span Bridge from chainage -80
            distanceExpression   = new IfcPointByDistanceExpression(-80 - startDist, alignmentCurve);
            axis2PlacementLinear = new IfcAxis2PlacementLinear(distanceExpression);
            IfcCurveSegment curveSegment = new IfcCurveSegment(IfcTransitionCode.CONTINUOUS, axis2PlacementLinear, 50, alignmentCurve);

            productDefinitionShape = new IfcProductDefinitionShape(new IfcShapeRepresentation(axisSubContext, curveSegment, ShapeRepresentationType.Curve2D));
            IfcBridge bridge = new IfcBridge(railway, alignment.ObjectPlacement, productDefinitionShape);

            db.WriteFile(args[0]);
        }
Exemplo n.º 6
0
        public BbSlottedHoleProfile(double cToCDistance, double radius)
        {
            var cir1 = new IfcCircle
                {
                    Position = new IfcAxis2Placement
                        {
                            Value =  new IfcAxis2Placement2D
                                {
                                    Location = new IfcCartesianPoint(cToCDistance / 2.0, 0),
                                },
                        },
                    Radius = radius,
                };
            var trimmed1 = new IfcTrimmedCurve
                {
                    BasisCurve = cir1,
                    Trim1 = new List<IfcTrimmingSelect>{new IfcTrimmingSelect{Value = new IfcParameterValue{Value = 270}}},
                    Trim2 = new List<IfcTrimmingSelect> { new IfcTrimmingSelect { Value = new IfcParameterValue { Value = 90 } } },
                    SenseAgreement = true,
                    MasterRepresentation = IfcTrimmingPreference.PARAMETER,
                };

            var line1 = new IfcPolyline
                {
                    Points = new List<IfcCartesianPoint>
                        {
                            new IfcCartesianPoint(cToCDistance / 2.0, radius),
                            new IfcCartesianPoint(cToCDistance / -2.0, radius),
                        },
                };

            var cir2 = new IfcCircle
                {
                    Position = new IfcAxis2Placement
                        {
                            Value = new IfcAxis2Placement2D
                                {
                                    Location = new IfcCartesianPoint(cToCDistance / -2.0, 0),
                                },
                        },
                    Radius = radius,
                };
            var trimmed2 = new IfcTrimmedCurve
                {
                    BasisCurve = cir2,
                    Trim1 = new List<IfcTrimmingSelect> { new IfcTrimmingSelect { Value = new IfcParameterValue { Value = 90 } } },
                    Trim2 = new List<IfcTrimmingSelect> { new IfcTrimmingSelect { Value = new IfcParameterValue { Value = 270 } } },
                    SenseAgreement = true,
                    MasterRepresentation = IfcTrimmingPreference.PARAMETER,
                };

            var line2 = new IfcPolyline
                {
                    Points = new List<IfcCartesianPoint>
                        {
                            new IfcCartesianPoint(cToCDistance / -2.0, -radius),
                            new IfcCartesianPoint(cToCDistance / 2.0, -radius),
                        },
                };

            var seg1 = new IfcCompositeCurveSegment
                {
                    Transition = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                    SameSense = true,
                    ParentCurve = trimmed1,
                };
            var seg2 = new IfcCompositeCurveSegment
                {
                    Transition = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                    SameSense = true,
                    ParentCurve = line1,
                };

            var seg3 = new IfcCompositeCurveSegment
                {
                    Transition = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                    SameSense = true,
                    ParentCurve = trimmed2,
                };
            var seg4 = new IfcCompositeCurveSegment
                {
                    Transition = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                    SameSense = true,
                    ParentCurve = line2,
                };

            var cCurve = new IfcCompositeCurve
                {
                    Segments = new List<IfcCompositeCurveSegment>
                        {
                            seg1, seg2, seg3, seg4
                        },
                    SelfIntersect = EbInstanceModel.LOGICAL.dbTrue,

                };

            _ifcProfileDef = new IfcArbitraryClosedProfileDef
                {
                    ProfileType = IfcProfileTypeEnum.AREA,
                    OuterCurve = cCurve,
                };
        }
Exemplo n.º 7
0
        public void ArbitraryClosedProfileDefWithIncorrectPlacementTest()
        {
            using (var model = IfcStore.Create(new XbimEditorCredentials(), IfcSchemaVersion.Ifc4, XbimStoreType.InMemoryModel))
            {
                using (var txn = model.BeginTransaction("Create Column"))
                {
                    IfcProject project = model.Instances.New <IfcProject>();
                    project.Initialize(ProjectUnits.SIUnitsUK);
                    project.Name = "Test Project";

                    IfcColumn col = model.Instances.New <IfcColumn>();
                    col.Name = "Column With ArbitraryClosedProfileDef";


                    //Creating IfcArbitraryClosedProfileDef that will contain IfcCompositeCurve
                    IfcArbitraryClosedProfileDef arbClosedProf = model.Instances.New <IfcArbitraryClosedProfileDef>();

                    //To create IfcArbitraryClosedProfileDef, we'll need to create IfcCompositeCurve
                    //Creating IfcCompositeCurve
                    IfcCompositeCurve myCompCurve = model.Instances.New <IfcCompositeCurve>();

                    //To Create IfcCompositeCurve, We'll need to create IfcCompositeCurveSegment
                    //create IfcCompositeCurveSegment (polyline)
                    IfcCompositeCurveSegment polylineSeg = model.Instances.New <IfcCompositeCurveSegment>();

                    //create IfcCompositeCurveSegment (arc)
                    IfcCompositeCurveSegment arcSeg = model.Instances.New <IfcCompositeCurveSegment>();

                    //Creating IfcPolyline that will be the parent curve for IfcCompositeCurveSegment "polylineSeg"
                    IfcPolyline myPolyline = model.Instances.New <IfcPolyline>();

                    //Creating Points to build the IfcPolyline
                    IfcCartesianPoint p0 = model.Instances.New <IfcCartesianPoint>();
                    p0.SetXY(200, 100);

                    IfcCartesianPoint p1 = model.Instances.New <IfcCartesianPoint>();
                    p1.SetXY(0, 100);

                    IfcCartesianPoint p2 = model.Instances.New <IfcCartesianPoint>();
                    p2.SetXY(0, 0);

                    IfcCartesianPoint p3 = model.Instances.New <IfcCartesianPoint>();
                    p3.SetXY(400, 0);

                    IfcCartesianPoint p4 = model.Instances.New <IfcCartesianPoint>();
                    p4.SetXY(400, 600);

                    IfcCartesianPoint p5 = model.Instances.New <IfcCartesianPoint>();
                    p5.SetXY(0, 600);

                    IfcCartesianPoint p6 = model.Instances.New <IfcCartesianPoint>();
                    p6.SetXY(0, 500);

                    IfcCartesianPoint p7 = model.Instances.New <IfcCartesianPoint>();
                    p7.SetXY(200, 500);

                    //Adding points to the polyline
                    myPolyline.Points.Add(p0);
                    myPolyline.Points.Add(p1);
                    myPolyline.Points.Add(p2);
                    myPolyline.Points.Add(p3);
                    myPolyline.Points.Add(p4);
                    myPolyline.Points.Add(p5);
                    myPolyline.Points.Add(p6);
                    myPolyline.Points.Add(p7);

                    //Assigning myPolyline to the IfcCompositeCurveSegment polylineSeg
                    polylineSeg.ParentCurve = myPolyline;

                    //Creating Arc using IfcTrimmedCurve
                    IfcTrimmedCurve myArc = model.Instances.New <IfcTrimmedCurve>();

                    //To create IfcTrimmedCurve, We'll need to create IfcCircle and trim it using IfcTrimmingSelect
                    IfcCircle myCirc = model.Instances.New <IfcCircle>();
                    myCirc.Radius = 213.554;
                    IfcCartesianPoint cP = model.Instances.New <IfcCartesianPoint>();
                    cP.SetXY(125.1312, 300); //this should really be a 3D point

                    IfcAxis2Placement3D plcmnt = model.Instances.New <IfcAxis2Placement3D>();
                    plcmnt.Location     = cP;
                    plcmnt.RefDirection = model.Instances.New <IfcDirection>();
                    plcmnt.RefDirection.SetXY(0, 1);//this should eb a 3D axis
                    myCirc.Position = plcmnt;

                    myArc.BasisCurve = myCirc;

                    IfcTrimmingSelect v1 = p7;
                    IfcTrimmingSelect v2 = p0;

                    myArc.Trim1.Add(v1);
                    myArc.Trim2.Add(v2);

                    arcSeg.ParentCurve = myArc;

                    //Adding the created two IfcCompositeCurveSegments to the IfcCompositeCurve
                    myCompCurve.Segments.Add(arcSeg);
                    myCompCurve.Segments.Add(polylineSeg);

                    //Assigning IfcCompositeCurve "myCompCurve" to the IfcArbitraryClosedProfileDef
                    arbClosedProf.OuterCurve = myCompCurve;

                    arbClosedProf.ProfileType = IfcProfileTypeEnum.AREA;

                    //model as a swept area solid
                    IfcExtrudedAreaSolid body = model.Instances.New <IfcExtrudedAreaSolid>();
                    body.Depth             = 2000;
                    body.SweptArea         = arbClosedProf;
                    body.ExtrudedDirection = model.Instances.New <IfcDirection>();
                    body.ExtrudedDirection.SetXYZ(0, 0, 1);


                    txn.Commit();
                    var solid = _xbimGeometryCreator.CreateSolid(body);
                    Assert.IsTrue((int)solid.Volume == 239345450);
                }
            }
        }
Exemplo n.º 8
0
        internal static IfcSweptDiskSolid ProfileSweptDiskSolidByCompositeCurve(IfcStore model, Entity profPath, double raduis)
        {
            IfcSweptDiskSolid body           = model.Instances.New <IfcSweptDiskSolid>();
            IfcCompositeCurve compositeCurve = model.Instances.New <IfcCompositeCurve>();

            compositeCurve.SelfIntersect = false;
            if (profPath is LinearPath)
            {
                LinearPath linearPath            = profPath as LinearPath;
                IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>();
                IfcPolyline pLine = model.Instances.New <IfcPolyline>();
                for (int i = 0; i < linearPath.Vertices.Length; i++)
                {
                    IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                    point.SetXYZ(linearPath.Vertices[i].X, linearPath.Vertices[i].Y, linearPath.Vertices[i].Z);
                    pLine.Points.Add(point);
                }
                segment.ParentCurve = pLine;
                segment.Transition  = IfcTransitionCode.CONTINUOUS;
                compositeCurve.Segments.Add(segment);
            }
            else if (profPath is CompositeCurve)
            {
                CompositeCurve compCurvePath = profPath as CompositeCurve;
                for (int i = 0; i < compCurvePath.CurveList.Count; i++)
                {
                    IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>();
                    //segment.Transition = i == compCurvePath.CurveList.Count - 1 ? IfcTransitionCode.DISCONTINUOUS : IfcTransitionCode.CONTINUOUS;
                    segment.Transition = IfcTransitionCode.DISCONTINUOUS;
                    if (compCurvePath.CurveList[i] is Line)
                    {
                        segment.SameSense = true;
                        Line        line  = compCurvePath.CurveList[i] as Line;
                        IfcPolyline pLine = model.Instances.New <IfcPolyline>();
                        for (int j = 0; j < line.Vertices.Length; j++)
                        {
                            IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                            point.SetXYZ(line.Vertices[j].X, line.Vertices[j].Y, line.Vertices[j].Z);
                            pLine.Points.Add(point);
                        }
                        segment.ParentCurve = pLine;
                        compositeCurve.Segments.Add(segment);
                    }
                    else
                    {
                        Arc             arc          = compCurvePath.CurveList[i] as Arc;
                        IfcTrimmedCurve trimmedCurve = model.Instances.New <IfcTrimmedCurve>();
                        IfcCircle       cir          = model.Instances.New <IfcCircle>(e => e.Radius = arc.Radius);
                        cir.Position = model.Instances.New <IfcAxis2Placement3D>(e =>
                                                                                 e.Location = model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.Center.X, arc.Center.Y, arc.Center.Z)));

                        trimmedCurve.BasisCurve = cir;
                        trimmedCurve.Trim1.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.StartPoint.X, arc.StartPoint.Y, arc.StartPoint.Z)));
                        trimmedCurve.Trim2.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.EndPoint.X, arc.EndPoint.Y, arc.EndPoint.Z)));
                        trimmedCurve.SenseAgreement = arc.Plane.AxisZ == Vector3D.AxisZ ? true : false;
                        //segment.SameSense = arc.Plane.AxisZ == Vector3D.AxisZ ? false : true;
                        trimmedCurve.MasterRepresentation = IfcTrimmingPreference.CARTESIAN;
                        segment.ParentCurve = trimmedCurve;
                        compositeCurve.Segments.Add(segment);
                    }
                }
            }
            else if (profPath is Circle)
            {
                IfcCircle ifcCirc = model.Instances.New <IfcCircle>();
            }



            body.Directrix   = compositeCurve;
            body.Radius      = raduis;
            body.InnerRadius = raduis * .75;
            return(body);
        }
Exemplo n.º 9
0
        internal static IfcSurfaceCurveSweptAreaSolid ProfileSurfaceSweptSolidCreateByCompositeCurve(IfcStore model, IfcProfileDef prof, Entity profPath)
        {
            IfcSurfaceCurveSweptAreaSolid body           = model.Instances.New <IfcSurfaceCurveSweptAreaSolid>();
            IfcCompositeCurve             compositeCurve = model.Instances.New <IfcCompositeCurve>();

            if (profPath is LinearPath)
            {
                LinearPath linearPath            = profPath as LinearPath;
                IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>();
                IfcPolyline pLine = model.Instances.New <IfcPolyline>();
                for (int i = 0; i < linearPath.Vertices.Length; i++)
                {
                    IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                    point.SetXYZ(linearPath.Vertices[i].X, linearPath.Vertices[i].Y, linearPath.Vertices[i].Z);
                    pLine.Points.Add(point);
                }
                segment.ParentCurve = pLine;
                segment.Transition  = IfcTransitionCode.CONTINUOUS;
                compositeCurve.Segments.Add(segment);
            }
            else
            {
                CompositeCurve compCurvePath = profPath as CompositeCurve;
                for (int i = 0; i < compCurvePath.CurveList.Count; i++)
                {
                    if (compCurvePath.CurveList[i] is Line)
                    {
                        Line line = compCurvePath.CurveList[i] as Line;
                        IfcCompositeCurveSegment segment = model.Instances.New <IfcCompositeCurveSegment>();
                        IfcPolyline pLine = model.Instances.New <IfcPolyline>();
                        for (int j = 0; j < line.Vertices.Length; j++)
                        {
                            IfcCartesianPoint point = model.Instances.New <IfcCartesianPoint>();
                            point.SetXYZ(line.Vertices[j].X, line.Vertices[j].Y, line.Vertices[j].Z);
                            pLine.Points.Add(point);
                        }
                        segment.ParentCurve = pLine;
                        segment.Transition  = IfcTransitionCode.CONTINUOUS;
                        compositeCurve.Segments.Add(segment);
                    }
                    else
                    {
                        Arc arc = compCurvePath.CurveList[i] as Arc;
                        IfcCompositeCurveSegment segment      = model.Instances.New <IfcCompositeCurveSegment>();
                        IfcTrimmedCurve          trimmedCurve = model.Instances.New <IfcTrimmedCurve>();
                        IfcCircle cir = model.Instances.New <IfcCircle>(e => e.Radius = arc.Radius);
                        cir.Position = model.Instances.New <IfcAxis2Placement3D>(e => e.Location = model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.Center.X, arc.Center.Y, arc.Center.Z)));

                        trimmedCurve.BasisCurve = cir;
                        trimmedCurve.Trim1.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.StartPoint.X, arc.StartPoint.Y, arc.StartPoint.Z)));
                        trimmedCurve.Trim2.Add(model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(arc.EndPoint.X, arc.EndPoint.Y, arc.EndPoint.Z)));
                        trimmedCurve.SenseAgreement       = arc.Plane.AxisZ == Vector3D.AxisZ ? false : true;
                        trimmedCurve.MasterRepresentation = IfcTrimmingPreference.CARTESIAN;
                        segment.ParentCurve = trimmedCurve;
                        segment.Transition  = IfcTransitionCode.CONTINUOUS;
                        compositeCurve.Segments.Add(segment);
                    }
                }
            }



            body.Directrix = compositeCurve;
            body.SweptArea = prof;
            var plane = model.Instances.New <IfcPlane>();

            plane.Position          = model.Instances.New <IfcAxis2Placement3D>();
            plane.Position.Location = model.Instances.New <IfcCartesianPoint>();
            //plane.Position.Location.SetXYZ(profPath.X, lstPoints[0].Y, lstPoints[0].Z);

            plane.Position.Axis = model.Instances.New <IfcDirection>();
            plane.Position.Axis.SetXYZ(0, 0, 1);
            plane.Position.RefDirection = model.Instances.New <IfcDirection>();
            plane.Position.RefDirection.SetXYZ(1, 0, 0);
            body.ReferenceSurface = plane;
            //body.FixedReference.SetXYZ(1, 0, 0);
            return(body);
        }
Exemplo n.º 10
0
        public BbSlottedHoleProfile(double cToCDistance, double radius)

        {
            var cir1 = new IfcCircle
            {
                Position = new IfcAxis2Placement
                {
                    Value = new IfcAxis2Placement2D
                    {
                        Location = new IfcCartesianPoint(cToCDistance / 2.0, 0),
                    },
                },
                Radius = radius,
            };
            var trimmed1 = new IfcTrimmedCurve
            {
                BasisCurve = cir1,
                Trim1      = new List <IfcTrimmingSelect> {
                    new IfcTrimmingSelect {
                        Value = new IfcParameterValue {
                            Value = 270
                        }
                    }
                },
                Trim2 = new List <IfcTrimmingSelect> {
                    new IfcTrimmingSelect {
                        Value = new IfcParameterValue {
                            Value = 90
                        }
                    }
                },
                SenseAgreement       = true,
                MasterRepresentation = IfcTrimmingPreference.PARAMETER,
            };

            var line1 = new IfcPolyline
            {
                Points = new List <IfcCartesianPoint>
                {
                    new IfcCartesianPoint(cToCDistance / 2.0, radius),
                    new IfcCartesianPoint(cToCDistance / -2.0, radius),
                },
            };

            var cir2 = new IfcCircle
            {
                Position = new IfcAxis2Placement
                {
                    Value = new IfcAxis2Placement2D
                    {
                        Location = new IfcCartesianPoint(cToCDistance / -2.0, 0),
                    },
                },
                Radius = radius,
            };
            var trimmed2 = new IfcTrimmedCurve
            {
                BasisCurve = cir2,
                Trim1      = new List <IfcTrimmingSelect> {
                    new IfcTrimmingSelect {
                        Value = new IfcParameterValue {
                            Value = 90
                        }
                    }
                },
                Trim2 = new List <IfcTrimmingSelect> {
                    new IfcTrimmingSelect {
                        Value = new IfcParameterValue {
                            Value = 270
                        }
                    }
                },
                SenseAgreement       = true,
                MasterRepresentation = IfcTrimmingPreference.PARAMETER,
            };

            var line2 = new IfcPolyline
            {
                Points = new List <IfcCartesianPoint>
                {
                    new IfcCartesianPoint(cToCDistance / -2.0, -radius),
                    new IfcCartesianPoint(cToCDistance / 2.0, -radius),
                },
            };


            var seg1 = new IfcCompositeCurveSegment
            {
                Transition  = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                SameSense   = true,
                ParentCurve = trimmed1,
            };
            var seg2 = new IfcCompositeCurveSegment
            {
                Transition  = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                SameSense   = true,
                ParentCurve = line1,
            };

            var seg3 = new IfcCompositeCurveSegment
            {
                Transition  = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                SameSense   = true,
                ParentCurve = trimmed2,
            };
            var seg4 = new IfcCompositeCurveSegment
            {
                Transition  = IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE,
                SameSense   = true,
                ParentCurve = line2,
            };


            var cCurve = new IfcCompositeCurve
            {
                Segments = new List <IfcCompositeCurveSegment>
                {
                    seg1, seg2, seg3, seg4
                },
                SelfIntersect = EbInstanceModel.LOGICAL.dbTrue,
            };

            _ifcProfileDef = new IfcArbitraryClosedProfileDef
            {
                ProfileType = IfcProfileTypeEnum.AREA,
                OuterCurve  = cCurve,
            };
        }
Exemplo n.º 11
0
        private static ICurve getICurveFromIfcCurve(IfcCurve ifcCurve, ViewportLayout viewportLayout1 = null, Transformation entityTrs = null)
        {
            ICurve result = null;

            if (ifcCurve is IfcConic)
            {
                IfcConic ifcConic = (IfcConic)ifcCurve;

                Plane pln = getPlaneFromPosition((IfcPlacement)ifcConic.Position);

                if (ifcConic is IfcCircle)
                {
                    IfcCircle ifcCircle = (IfcCircle)ifcCurve;

                    Circle circle = new Circle(pln, ifcCircle.Radius);

                    result = circle;
                }
                else
                {
                    IfcEllipse ifcEllipse = (IfcEllipse)ifcConic;

                    Ellipse ellipse = new Ellipse(pln, pln.Origin, ifcEllipse.SemiAxis1, ifcEllipse.SemiAxis2);

                    result = ellipse;
                }
            }
            else if (ifcCurve is IfcPolyline)
            {
                IfcPolyline p = (IfcPolyline)ifcCurve;

                Point3D[] points = new Point3D[p.Points.Count];

                for (int i = 0; i < p.Points.Count; i++)
                {
                    points[i] = getPoint3DFromIfcCartesianPoint(p.Points[i]);
                }
                LinearPath lp = new LinearPath(points);

                result = lp;
            }
            else if (ifcCurve is IfcCompositeCurve)             // verificare sense e transition
            {
                IfcCompositeCurve cc = (IfcCompositeCurve)ifcCurve;

                result = new CompositeCurve();

                foreach (IfcCompositeCurveSegment ccSegment in cc.Segments)
                {
                    ICurve segment = getICurveFromIfcCurve(ccSegment.ParentCurve, viewportLayout1, entityTrs);

                    if (segment != null)
                    {
                        ((CompositeCurve)result).CurveList.Add(segment);
                    }
                    else
                    {
                        result = null;
                        break;
                    }
                }
            }
            else if (ifcCurve is IfcTrimmedCurve)
            {
                IfcTrimmedCurve tc = (IfcTrimmedCurve)ifcCurve;

                ICurve basisCurve = getICurveFromIfcCurve(tc.BasisCurve, viewportLayout1, entityTrs);

                if (basisCurve != null)
                {
                    ICurve trimCurve = null;

                    if (tc.MasterRepresentation == IfcTrimmingPreference.PARAMETER)
                    {
                        double startParam = tc.Trim1.IfcParameterValue * Math.PI / 180;
                        double endParam   = tc.Trim2.IfcParameterValue * Math.PI / 180;

                        if (tc.SenseAgreement)
                        {
                            if (startParam > endParam)
                            {
                                startParam = startParam - Math.PI * 2;
                            }

                            basisCurve.SubCurve(startParam, endParam, out trimCurve);
                        }
                        else
                        {
                            if (endParam > startParam)
                            {
                                endParam = endParam - Math.PI * 2;
                            }

                            basisCurve.SubCurve(endParam, startParam, out trimCurve);

                            trimCurve.Reverse();
                        }
                        result = trimCurve; //new CompositeCurve(trimCurve);
                    }
                    else if (tc.MasterRepresentation == IfcTrimmingPreference.CARTESIAN)
                    {
                        debug += "IfcTrimmed cartesianPoint not supported: \n";
                    }
                    else
                    {
                        debug += "IfcTrimmed not supported: \n";
                    }
                }
            }
            else
            {
                if (!debug.Contains("IfcCurve not supported: " + ifcCurve.KeyWord))
                {
                    debug += "IfcCurve not supported: " + ifcCurve.KeyWord + "\n";
                }
            }
            return(result);
        }