public BbCompositeCurve() { ifcCompositeCurve = new IfcCompositeCurve { Segments = new List<IfcCompositeCurveSegment>(), SelfIntersect = LOGICAL.dbTrue, }; }
public static IfcCompositeCurve CreateTestCase(this IfcCompositeCurve c) { IfcCompositeCurve curve = new IfcCompositeCurve() { }; return curve; }
public BbCompositeCurve() { ifcCompositeCurve = new IfcCompositeCurve { Segments = new List <IfcCompositeCurveSegment>(), SelfIntersect = LOGICAL.dbTrue, }; }
static public IfcCompositeCurve CreateTestCase(this IfcCompositeCurve c) { IfcCompositeCurve curve = new IfcCompositeCurve() { }; return(curve); }
internal static IfcCompositeCurve CreateCompositeProfile(IfcStore model, List <IfcCompositeCurveSegment> segments) { IfcCompositeCurve compositProf = model.Instances.New <IfcCompositeCurve>(); compositProf.Segments.AddRange(segments); compositProf.SelfIntersect = false; return(compositProf); }
public void CompositeCurve2DTest() { var operandStack = new Stack(); operandStack.Push('{'); operandStack.Push(IfcGeom.CreatePolyLine(new List <double[]>() { new double[] { -0.5, -0.5 }, new double[] { 0, 0 } })); operandStack.Push(IfcGeom.CreatePolyLine(new List <double[]>() { new double[] { 0, 0 }, new double[] { 0.5, 0.5 } })); var operation = OperationName.COMPOSITE_CURVE2D; ConstructionOperations.ExecuteOperation(operation, operandStack); Assert.Single(operandStack); var response = operandStack.Pop(); Assert.IsType <IfcCompositeCurve>(response); IfcCompositeCurve curve = (IfcCompositeCurve)response; Assert.Equal(2, curve.Segments.Count); IfcCompositeCurveSegment curve0 = curve.Segments[0]; Assert.Equal(IfcTransitionCode.CONTINUOUS, curve0.Transition); Assert.True(curve0.SameSense.Value); Assert.Equal(-0.5, ((IfcPolyline)curve0.ParentCurve).Points[0].Coordinates[0].Value); Assert.Equal(-0.5, ((IfcPolyline)curve0.ParentCurve).Points[0].Coordinates[1].Value); Assert.Equal(0, ((IfcPolyline)curve0.ParentCurve).Points[1].Coordinates[0].Value); Assert.Equal(0, ((IfcPolyline)curve0.ParentCurve).Points[1].Coordinates[1].Value); IfcCompositeCurveSegment curve1 = curve.Segments[1]; Assert.Equal(IfcTransitionCode.CONTINUOUS, curve1.Transition); Assert.True(curve1.SameSense.Value); Assert.Equal(0, ((IfcPolyline)curve1.ParentCurve).Points[0].Coordinates[0].Value); Assert.Equal(0, ((IfcPolyline)curve1.ParentCurve).Points[0].Coordinates[1].Value); Assert.Equal(0.5, ((IfcPolyline)curve1.ParentCurve).Points[1].Coordinates[0].Value); Assert.Equal(0.5, ((IfcPolyline)curve1.ParentCurve).Points[1].Coordinates[1].Value); }
public override void IfcParse(int propIndex, IPropertyValue value) { switch (propIndex) { case 0: _spineCurve = (IfcCompositeCurve)value.EntityVal; break; case 1: _crossSections.Add((IfcProfileDef)value.EntityVal); break; case 2: _crossSectionPositions.Add((IfcAxis2Placement3D)value.EntityVal); break; default: this.HandleUnexpectedAttribute(propIndex, value); break; } }
public override void Parse(int propIndex, IPropertyValue value, int[] nestedIndex) { switch (propIndex) { case 0: _spineCurve = (IfcCompositeCurve)(value.EntityVal); return; case 1: _crossSections.InternalAdd((IfcProfileDef)value.EntityVal); return; case 2: _crossSectionPositions.InternalAdd((IfcAxis2Placement3D)value.EntityVal); return; default: throw new XbimParserException(string.Format("Attribute index {0} is out of range for {1}", propIndex + 1, GetType().Name.ToUpper())); } }
/// <summary> /// Creates an outer curve made of two trimmed semi circles /// </summary> /// <param name="c"></param> /// <returns></returns> public static IfcCompositeCurve CreateOuterCurveTestCase(this IfcCompositeCurve c) { IfcCompositeCurve curve = new IfcCompositeCurve() { }; curve.Segments.Add ( new IfcTrimmedCurve() { BasisCurve = new IfcCircle() { Position = new IfcAxis2Placement2D() { Location = new IfcCartesianPoint(0, 0), RefDirection = new IfcDirection(1, 0) } } } ); curve.Segments.Add ( new IfcTrimmedCurve() { BasisCurve = new IfcCircle() { Position = new IfcAxis2Placement2D() { Location = new IfcCartesianPoint(0, 0), RefDirection = new IfcDirection(1, 0) } } } ); return curve; }
/// <summary> /// Creates an outer curve made of two trimmed semi circles /// </summary> /// <param name="c"></param> /// <returns></returns> static public IfcCompositeCurve CreateOuterCurveTestCase(this IfcCompositeCurve c) { IfcCompositeCurve curve = new IfcCompositeCurve() { }; curve.Segments.Add ( new IfcTrimmedCurve() { BasisCurve = new IfcCircle() { Position = new IfcAxis2Placement2D() { Location = new IfcCartesianPoint(0, 0), RefDirection = new IfcDirection(1, 0) } } } ); curve.Segments.Add ( new IfcTrimmedCurve() { BasisCurve = new IfcCircle() { Position = new IfcAxis2Placement2D() { Location = new IfcCartesianPoint(0, 0), RefDirection = new IfcDirection(1, 0) } } } ); return(curve); }
private static void Main(string[] args) { var database = new DatabaseIfc(ModelView.Ifc4X3NotAssigned); database.Factory.ApplicationDeveloper = "Sebastian Esser"; // turn owner history off database.Factory.Options.GenerateOwnerHistory = false; // basic setup var site = new IfcSite(database, "SiteA"); var project = new IfcProject( site, "SampleProject with a span annotation", IfcUnitAssignment.Length.Metre ); // create an annotation var annotation = new IfcAnnotation(database) { Name = "DesignSpeed", }; annotation.AddComment("Annotation item span-placed along the alignment"); // link annotation with site var contained = new IfcRelContainedInSpatialStructure(site); contained.RelatedElements.Add(annotation); #region Alignment var alignment = new IfcAlignment(site) { Name = "Basic alignment with a single horizontal segment" }; alignment.AddComment("Generate alignment representation"); // semantic var horizSegment = new IfcAlignmentHorizontalSegment( new IfcCartesianPoint(database, 5, 10), 0, 0, 0, 200, IfcAlignmentHorizontalSegmentTypeEnum.LINE); // geometric representation of a single segment. It gets referenced by IfcCompositeCurve.segments and IfcAlignmentSegment.Representation var curveSegment = new IfcCurveSegment( IfcTransitionCode.CONTSAMEGRADIENTSAMECURVATURE, new IfcAxis2Placement2D(new IfcCartesianPoint(database, 0, 0)), new IfcParameterValue(0), new IfcParameterValue(200), null); var segments = new List <IfcSegment> { curveSegment }; var compositeCurve = new IfcCompositeCurve(segments); var rep = new IfcShapeRepresentation(compositeCurve) { RepresentationIdentifier = "Axis", RepresentationType = "Curve2D" }; alignment.Representation = new IfcProductDefinitionShape(rep); alignment.Axis = compositeCurve; // create an alignment horizontal instance that takes a list of horizontal segments var alignmentHorizontal = new IfcAlignmentHorizontal(database) { Segments = new LIST <IfcAlignmentHorizontalSegment>() { horizSegment } }; // link alignment and and its horizontal part semantically new IfcRelAggregates(alignment, alignmentHorizontal); // create a new alignmentSegment with then gets one curve segment as its geometric representation var alignmentSegment = new IfcAlignmentSegment(database); // link horizontal alignment with the recently created alignment segment new IfcRelNests(alignmentHorizontal, alignmentSegment); // sorted list -> IfcRelNests // connect geom representation to this segment alignmentSegment.Representation = new IfcProductDefinitionShape(new IfcShapeRepresentation(curveSegment)); #endregion Alignment #region Annotation placement alignmentSegment.AddComment("Create placement for annotation"); var axis2place = new IfcAxis2PlacementLinear( new IfcPointByDistanceExpression(25, compositeCurve), null, null); var linPlacement = new IfcLinearPlacement(axis2place); linPlacement.Distance = new IfcPointByDistanceExpression(128, compositeCurve); annotation.ObjectPlacement = linPlacement; #endregion Annotation placement #region PSet //var lengthUnit = new IfcSIUnit(database, IfcUnitEnum.LENGTHUNIT, IfcSIPrefix.NONE, IfcSIUnitName.METRE); var lengthDerivedUnit = new IfcSIUnit(database, IfcUnitEnum.LENGTHUNIT, IfcSIPrefix.KILO, IfcSIUnitName.METRE); lengthDerivedUnit.AddComment("PSet setup"); var timeBaseUnit = new IfcSIUnit(database, IfcUnitEnum.TIMEUNIT, IfcSIPrefix.NONE, IfcSIUnitName.SECOND); var timeDerivedUnit = new IfcConversionBasedUnit(IfcUnitEnum.TIMEUNIT, "hour", new IfcMeasureWithUnit(new IfcPositiveInteger(3600), timeBaseUnit)); var ifcderivedunitelem1 = new IfcDerivedUnitElement(lengthDerivedUnit, 1); var ifcderivedunitelem2 = new IfcDerivedUnitElement(timeDerivedUnit, -1); var speedUnit = new IfcDerivedUnit( new List <IfcDerivedUnitElement> { ifcderivedunitelem1, ifcderivedunitelem2 }, IfcDerivedUnitEnum.LINEARVELOCITYUNIT); var pSet = new IfcPropertySet(annotation, "PSET_SpeedData", new List <IfcProperty> { new IfcPropertySingleValue(database, "CargoSpeed", new IfcLinearVelocityMeasure(60), speedUnit), new IfcPropertySingleValue(database, "DesignSpeed", new IfcLinearVelocityMeasure(110), speedUnit) }); #endregion PSet database.WriteFile("AlignmentWithSpanAnnotation.ifc"); }
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]); }
public IXbimFace CreateFace(IfcCompositeCurve cCurve) { return(_engine.CreateFace(cCurve)); }
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, }; }
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, }; }
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); }
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); }
public IfcSectionedSpine(IfcCompositeCurve __SpineCurve, IfcProfileDef[] __CrossSections, IfcAxis2Placement3D[] __CrossSectionPositions) { this._SpineCurve = __SpineCurve; this._CrossSections = new List <IfcProfileDef>(__CrossSections); this._CrossSectionPositions = new List <IfcAxis2Placement3D>(__CrossSectionPositions); }
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); } } }
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); }