コード例 #1
0
        internal static bool IfcCorrectUnitAssignment(IItemSet <IfcUnit> Units)
        {
            // local variables
            int NamedUnitNumber    = 0;
            int DerivedUnitNumber  = 0;
            int MonetaryUnitNumber = 0;
            var NamedUnitNames     = new List <IfcUnitEnum>();
            var DerivedUnitNames   = new List <IfcDerivedUnitEnum>();


            NamedUnitNumber =
                SIZEOF(
                    Units.OfType <IfcNamedUnit>().Where(
                        temp => temp.UnitType != IfcUnitEnum.USERDEFINED));
            DerivedUnitNumber =
                SIZEOF(
                    Units.OfType <IfcDerivedUnit>().Where(
                        temp => temp.UnitType != IfcDerivedUnitEnum.USERDEFINED));
            MonetaryUnitNumber = SIZEOF(Units.OfType <IfcMonetaryUnit>());

            // index ok
            for (var i = 0; i < SIZEOF(Units); i++)
            {
                if (Units[i] is IfcNamedUnit && !((Units[i] as IfcNamedUnit).UnitType == IfcUnitEnum.USERDEFINED))
                {
                    NamedUnitNames.Add((Units[i] as IfcNamedUnit).UnitType);
                }
                if (Units[i] is IfcDerivedUnit && !((Units[i] as IfcDerivedUnit).UnitType == IfcDerivedUnitEnum.USERDEFINED))
                {
                    DerivedUnitNames.Add((Units[i] as IfcDerivedUnit).UnitType);
                }
            }

            return(SIZEOF(NamedUnitNames) == NamedUnitNumber && SIZEOF(DerivedUnitNames) == DerivedUnitNumber &&
                   MonetaryUnitNumber <= 1);
        }
コード例 #2
0
 public bool Contains(IItemSet <TOuter> item)
 {
     return(_inner.Contains(GetIn(item)));
 }
コード例 #3
0
 public void Add(IItemSet <TOuter> item)
 {
     _inner.Add(GetIn(item));
 }
コード例 #4
0
 private static IItemSet <TOuter> GetOut(IItemSet <TInner> inner)
 {
     return(new ProxyItemSet <TInner, TOuter>(inner));
 }
コード例 #5
0
 public XbimPolyLoop(IItemSet <IfcPositiveInteger> coordIndex, IIfcCartesianPointList3D coordinates, IItemSet <IfcPositiveInteger> pnIndex)
 {
     this.coordIndex  = coordIndex;
     this.coordinates = coordinates;
     this.pnIndex     = pnIndex;
 }
コード例 #6
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="items"></param>
 public ReadOnlyListA(IItemSet <TValue1, TValue2> items)
 {
     set = items;
 }
コード例 #7
0
 /// <summary>Initializes a new instance of the <see cref="ReadOnlySet{T}"/> class.</summary>
 /// <param name="set">The Set.</param>
 public ReadOnlySet(IItemSet <T> set) => this.set = set;
コード例 #8
0
        internal static bool IfcCorrectObjectAssignment(IfcObjectTypeEnum?Constraint, IItemSet <IfcObjectDefinition> Objects)
        {
            if (!Constraint.HasValue)
            {
                return(true);
            }

            var val = IfcCorrectObjectAssignment((IfcObjectTypeEnum)Constraint, Objects.ToList());

            if (!val.HasValue)
            {
                throw new ArgumentException("Undetermined value in where clause.");
            }
            return(val.Value);
        }
コード例 #9
0
 public static IfcShapeModel Lookup(this IItemSet <IfcShapeModel> models, string identifier)
 {
     return(models.FirstOrDefault(item =>
                                  item.RepresentationIdentifier != null &&
                                  string.Compare(item.RepresentationIdentifier, identifier, true) == 0));
 }
コード例 #10
0
        /// <summary>
        /// Todo: add summary
        /// </summary>
        /// <param name="Degree">degree</param>
        /// <param name="UpKnots">upperIndexOnKnots</param>
        /// <param name="UpCp">upperIndexOnControlPoints</param>
        /// <param name="KnotMult">knotMultiplicities</param>
        /// <param name="Knots">knots</param>
        /// <returns></returns>
        internal static bool IfcConstraintsParamBSpline(IfcInteger Degree, IfcInteger UpKnots, IfcInteger UpCp, IItemSet <IfcInteger> KnotMult, IItemSet <IfcParameterValue> Knots)
        {
            // local variables
            bool Result = true;
            int  K;
            int  Sum;

            Sum = (int)KnotMult[0];
            for (var i = 2; i <= UpKnots; i++)
            {
                Sum = (int)(Sum + KnotMult[i - 1]);
            }


            if ((Degree < 1) || (UpKnots < 2) || (UpCp < Degree) ||
                (Sum != (Degree + UpCp + 2)))
            {
                Result = false;
                return(Result);
            }

            K = (int)KnotMult[1];
            if ((K < 1) || (K > Degree + 1))
            {
                Result = false;
                return(Result);
            }

            for (var i = 2; i <= UpKnots; i++)
            {
                if ((KnotMult[i - 1] < 1) || (Knots[i - 1] <= Knots[i - 2]))
                {
                    Result = false;
                    return(Result);
                }
                K = (int)KnotMult[i - 1];
                if ((i < UpKnots) && (K > Degree))
                {
                    Result = false;
                    return(Result);
                }
                if ((i == UpKnots) && (K > Degree + 1))
                {
                    Result = false;
                    return(Result);
                }
            }

            return(Result);
        }
コード例 #11
0
ファイル: GeometryView.cs プロジェクト: wyh9462/XbimWindowsUI
        private static void Report(IIfcCircle circle, IItemSet <IIfcTrimmingSelect> trim1, IItemSet <IIfcTrimmingSelect> trim2, TextHighliter sb)
        {
            // this one makes an arc, knowing the circle
            var v1 = trim1.FirstOrDefault(); //  as Xbim.Ifc4.MeasureResource.IfcParameterValue;
            var v2 = trim2.FirstOrDefault(); //  as Xbim.Ifc4.MeasureResource.IfcParameterValue;

            if (v1 is null || v2 == null || v1 is IIfcCartesianPoint || v2 is IIfcCartesianPoint)
            {
                Report(circle, sb);
                return;
            }
            var startang = ((Xbim.Ifc4.MeasureResource.IfcParameterValue)v1) * circle.Model.ModelFactors.AngleToRadiansConversionFactor;
            var endang   = ((Xbim.Ifc4.MeasureResource.IfcParameterValue)v2) * circle.Model.ModelFactors.AngleToRadiansConversionFactor;
            // in acad we need the start point
            var startPx = circle.Radius * Math.Cos(startang);
            var startPy = circle.Radius * Math.Sin(startang);

            SetUcs(sb, circle.Position);
            sb.Append("ARC C", Brushes.Black);
            WritePointCoord(sb, 0, 0, 0);
            WritePointCoord(sb, startPx, startPy, double.NaN);
            sb.Append("A", Brushes.Black);
            var presentedEndAngle = (endang - startang) * 180 / Math.PI;

            sb.Append(presentedEndAngle.ToString(), Brushes.Black);
            SetUcs(sb);
        }
コード例 #12
0
ファイル: GeometryView.cs プロジェクト: wyh9462/XbimWindowsUI
 private static void WritePointCoord(TextHighliter sb, IItemSet <Xbim.Ifc4.MeasureResource.IfcLengthMeasure> pt)
 {
     WritePointCoord(sb, pt[0], pt[1], pt[2], false);
 }
コード例 #13
0
        public static void ResolveQuantitySet(IfcStore ifcStore)
        {
            List <IIfcRelDefinesByProperties> relProps = ifcStore.Instances.OfType <IIfcRelDefinesByProperties>().ToList();

            Dictionary <IfcObject, List <IfcPropertySet> > qSetsByIfcObject = new Dictionary <IfcObject, List <IfcPropertySet> >();

            using (var txn = ifcStore.BeginTransaction("QuantitySet Creation Ifc4x1"))
            {
                foreach (IIfcRelDefinesByProperties relProp in relProps)
                {
                    IEnumerable <IIfcPropertySetDefinition> relatingPropertyDefinitions = relProp.RelatingPropertyDefinition.PropertySetDefinitions
                                                                                          .Where(def => def.Name.ToString().Contains("BaseQuantities"));

                    foreach (IIfcPropertySetDefinition relatingPropertyDefinition in relatingPropertyDefinitions)
                    {
                        IItemSet <IIfcObjectDefinition>         relatedObjects = relProp.RelatedObjects;
                        IEnumerable <IIfcPropertySetDefinition> definitions    = relatingPropertyDefinition.PropertySetDefinitions;

                        foreach (var notAssignedSet in definitions)
                        {
                            if (notAssignedSet is IIfcElementQuantity)
                            {
                                IIfcElementQuantity qset = (IIfcElementQuantity)notAssignedSet;
                                IfcPropertySet      pset = ifcStore.Instances.New <IfcPropertySet>(pSet =>
                                {
                                    pSet.Name = qset.Name.ToString().StartsWith("Qto_")
                                    ? "LIBAL_" + qset.Name.ToString()
                                    : "LIBAL_Qto_" + qset.Name.ToString();

                                    IItemSet <IIfcPhysicalQuantity> quantities = qset.Quantities;
                                    foreach (IIfcPhysicalQuantity quan in quantities)
                                    {
                                        var value = resolveValue(quan);
                                        var unit  = resolveUnit(quan);
                                        var name  = quan.Name.ToString();

                                        if (value != null)
                                        {
                                            pSet.HasProperties.Add(ifcStore.Instances.New <IfcPropertySingleValue>(p =>
                                            {
                                                p.Name         = name;
                                                p.NominalValue = value;
                                                p.Unit         = unit;
                                            }));
                                        }
                                    }
                                });

                                foreach (IfcObject ifcObject in relatedObjects)
                                {
                                    if (!qSetsByIfcObject.ContainsKey(ifcObject))
                                    {
                                        qSetsByIfcObject.Add(ifcObject, new List <IfcPropertySet>());
                                    }

                                    List <IfcPropertySet> psets = qSetsByIfcObject[ifcObject];
                                    psets.Add(pset);
                                }
                            }
                        }
                    }
                }
                txn.Commit();
            }

            using (var txn = ifcStore.BeginTransaction("QuantitySet Reference Creation Ifc4x1"))
            {
                foreach (IfcObject key in qSetsByIfcObject.Keys)
                {
                    List <IfcPropertySet> psets = qSetsByIfcObject[key];

                    foreach (IfcPropertySet pset in psets)
                    {
                        var pSetRel = ifcStore.Instances.New <IfcRelDefinesByProperties>(r =>
                        {
                            r.RelatingPropertyDefinition = pset;
                        });
                        pSetRel.RelatedObjects.Add(key);
                    }
                }

                txn.Commit();
            }
        }
コード例 #14
0
 public XbimPolygonalFace(IIfcIndexedPolygonalFace polygonalFace, IIfcCartesianPointList3D coordinates, IItemSet <IfcPositiveInteger> pnIndex)
 {
     this.polygonalFace = polygonalFace;
     this.coordinates   = coordinates;
     this.pnIndex       = pnIndex;
 }
コード例 #15
0
 public XbimCartesianPoint3dList(IItemSet <IfcPositiveInteger> coordIndex, IIfcCartesianPointList3D coordinates, IItemSet <IfcPositiveInteger> pnIndex)
 {
     points = new List <IIfcCartesianPoint>(coordIndex.Count);
     if (pnIndex != null && pnIndex.Count > 0) //we do a lookup
     {
         foreach (int idx in coordIndex)
         {
             var pnt = coordinates.CoordList[(int)(pnIndex[idx - 1] - 1)];
             points.Add(new XbimCartesianPoint3D(pnt[0], pnt[1], pnt[2]));
         }
     }
     else
     {
         foreach (int idx in coordIndex)
         {
             var pnt = coordinates.CoordList[(int)(idx - 1)];
             points.Add(new XbimCartesianPoint3D(pnt[0], pnt[1], pnt[2]));
         }
     }
 }
コード例 #16
0
 public EnumeratorB(IItemSet <TValue1, TValue2> items) => set = items;
コード例 #17
0
        internal static bool IfcShapeRepresentationTypes(IfcLabel?RepType, IItemSet <IfcRepresentationItem> Items)
        {
            // local variables
            int Count = 0;

            if (!RepType.HasValue)
            {
                return(Count == Items.Count);
            }
            switch (RepType.Value)
            {
            case "Point":
                Count = Items.Count(x => x is IIfcPoint);
                break;

            //case "PointCloud":
            //    Count = Items.Count(x => x is IIfcCartesianPointList3D);
            //    break;
            case "Curve":
                Count = Items.Count(x => x is IIfcCurve);
                break;

            case "Curve2D":
                Count = Items.Count(x => x is IIfcCurve && ((IIfcCurve)x).Dim == 2);
                break;

            case "Curve3D":
                Count = Items.Count(x => x is IIfcCurve && ((IIfcCurve)x).Dim == 3);
                break;

            case "Surface":
                Count = Items.Count(x => x is IIfcSurface);
                break;

            case "Surface2D":
                Count = Items.Count(x => x is IIfcSurface && ((IIfcSurface)x).Dim == 2);
                break;

            case "Surface3D":
                Count = Items.Count(x => x is IIfcSurface && ((IIfcSurface)x).Dim == 3);
                break;

            case "FillArea":
                Count = Items.Count(x => x is IIfcAnnotationFillArea);
                break;

            case "Text":
                Count = Items.Count(x => x is IIfcTextLiteral);
                break;
            //case "AdvancedSurface":
            //    Count = Items.Count(x => x is IIfcBSplineSurface);
            //    break;

            case "Annotation2D":
                Count = Items.Count(x =>
                                    x is IIfcPoint ||
                                    x is IIfcCurve ||
                                    x is IIfcGeometricCurveSet ||
                                    x is IIfcAnnotationFillArea ||
                                    x is IIfcTextLiteral
                                    );
                break;


            case "GeometricSet":
                Count = Items.Count(x =>
                                    x is IIfcGeometricSet ||
                                    x is IIfcPoint ||
                                    x is IIfcCurve ||
                                    x is IIfcSurface);
                break;

            case "GeometricCurveSet":
                Count = Items.Count(x =>
                                    x is IIfcGeometricCurveSet ||
                                    x is IIfcGeometricSet ||
                                    x is IIfcPoint ||
                                    x is IIfcCurve);
                foreach (var ifcRepresentationItem in Items)
                {
                    if (ifcRepresentationItem is IIfcGeometricSet)
                    {
                        var asIIfcGeometricSet = ifcRepresentationItem as IIfcGeometricSet;
                        if (asIIfcGeometricSet.Elements.Count(temp => temp is IfcSurface) > 0)
                        {
                            Count--;
                        }
                    }
                }
                break;

            //case "Tessellation":
            //    Count = Items.Count(x => x is IIfcTessellatedItem);
            //    break;
            case "SurfaceOrSolidModel":
                Count = Items.Count(x =>
                                    // x is IIfcTessellatedItem
                                    x is IIfcShellBasedSurfaceModel ||
                                    x is IIfcFaceBasedSurfaceModel ||
                                    x is IIfcSolidModel
                                    );
                break;

            case "SurfaceModel":
                Count = Items.Count(x =>
                                    x is IIfcShellBasedSurfaceModel ||
                                    x is IIfcFaceBasedSurfaceModel
                                    );
                break;

            case "SolidModel":
                Count = Items.Count(x => x is IIfcSolidModel);
                break;

            case "SweptSolid":
                // todo: check this, i'm not sure this is how to interpret the clause
                Count = Items.Count(x =>
                                    x is IIfcExtrudedAreaSolid ||
                                    x is IIfcRevolvedAreaSolid

                                    );
                break;

            case "AdvancedSweptSolid":
                Count = Items.Count(x =>
                                    x is IIfcSweptAreaSolid ||
                                    x is IIfcSweptDiskSolid
                                    );
                break;

            case "CSG":
                Count = Items.Count(x =>
                                    x is IIfcBooleanResult ||
                                    x is IIfcCsgPrimitive3D ||
                                    x is IIfcCsgSolid);
                break;

            case "Clipping":
                Count = Items.Count(x => x is IIfcBooleanClippingResult);
                break;

            case "Brep":

                Count = Items.Count(x => x is IIfcFacetedBrep);
                break;


            case "AdvancedBrep":
                Count = Items.Count(x => x is IIfcManifoldSolidBrep);
                break;

            case "BoundingBox":
                Count = Items.Count(x => x is IIfcBoundingBox);
                if (Items.Count > 1)
                {
                    Count = 0;
                }
                break;

            case "SectionedSpine":
                Count = Items.Count(x => x is IIfcSectionedSpine);
                break;

            case "LightSource":
                Count = Items.Count(x => x is IIfcLightSource);
                break;

            case "MappedRepresentation":
                Count = Items.Count(x => x is IIfcMappedItem);
                break;
            }
            return(Count == Items.Count);
        }
コード例 #18
0
 public bool Remove(IItemSet <TOuter> item)
 {
     Check(item);
     return(_inner.Remove(GetIn(item)));
 }
コード例 #19
0
        /// <summary>
        /// Todo: add summary
        /// </summary>
        /// <param name="Degree">degree</param>
        /// <param name="UpKnots">upperIndexOnKnots</param>
        /// <param name="UpCp">upperIndexOnControlPoints</param>
        /// <param name="KnotMult">knotMultiplicities</param>
        /// <param name="Knots">knots</param>
        /// <returns></returns>
        internal static bool IfcConstraintsParamBSpline(IfcInteger Degree, IfcInteger UpKnots, IfcInteger UpCp, IItemSet <IfcInteger> KnotMult, IItemSet <IfcParameterValue> Knots)
        {
            // local variables
            int K;
            int Sum;

            Sum = (int)KnotMult[0];
            for (var i = 2; i <= UpKnots; i++)
            {
                Sum = (int)(Sum + KnotMult[i - 1]);
            }


            if (Degree < 1 || UpKnots < 2 || UpCp < Degree ||
                Sum != Degree + UpCp + 2)
            {
                return(false);
            }

            K = (int)KnotMult[1];
            if (K < 1 || K > Degree + 1)
            {
                return(false);
            }

            for (var i = 2; i <= UpKnots; i++)
            {
                if (KnotMult[i - 1] < 1 || Knots[i - 1] <= Knots[i - 2])
                {
                    return(false);
                }
                K = (int)KnotMult[i - 1];
                if (i < UpKnots && K > Degree)
                {
                    return(false);
                }
                if (i == UpKnots && K > Degree + 1)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #20
0
 public int IndexOf(IItemSet <TOuter> item)
 {
     return(_inner.IndexOf(GetIn(item)));
 }
コード例 #21
0
 public EnumeratorA(IItemSet <TValue1, TValue2> items)
 {
     set = items;
 }
コード例 #22
0
 public void Insert(int index, IItemSet <TOuter> item)
 {
     _inner.Insert(index, GetIn(item));
 }
コード例 #23
0
 public ReadOnlyItemSet(IItemSet <T> set) : base(set)
 {
 }
コード例 #24
0
 // IIfcIndexedPolygonalFace indexFace;
 public XbimFaceBoundSet(IIfcIndexedPolygonalFace face, IIfcCartesianPointList3D coordinates, IItemSet <IfcPositiveInteger> pnIndex)
 {
     // indexFace = face;
     if (face is IIfcIndexedPolygonalFaceWithVoids)
     {
         var faceWithVoids = (IIfcIndexedPolygonalFaceWithVoids)face;
         faceBounds    = new XbimPolygonalFaceBound[faceWithVoids.InnerCoordIndices.Count + 1];
         faceBounds[0] = new XbimPolygonalFaceBound(faceWithVoids.CoordIndex, coordinates, pnIndex);
         for (int i = 0; i < faceWithVoids.InnerCoordIndices.Count; i++)
         {
             faceBounds[i + 1] = new XbimPolygonalFaceBound(faceWithVoids.InnerCoordIndices[i], coordinates, pnIndex);
         }
     }
     else //there will just be one
     {
         faceBounds = new[] { new XbimPolygonalFaceBound(face.CoordIndex, coordinates, pnIndex) };
     }
 }