コード例 #1
0
ファイル: IFCEdgeLoop.cs プロジェクト: zfcJerry/revit-ifc
        protected override void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid)
        {
            if (shapeEditScope.BuilderType == IFCShapeBuilderType.BrepBuilder)
            {
                if (shapeEditScope.BuilderScope == null)
                {
                    throw new InvalidOperationException("BuilderScope hasn't been initialized yet");
                }
                BrepBuilderScope brepBuilderScope = shapeEditScope.BuilderScope as BrepBuilderScope;

                if (brepBuilderScope == null)
                {
                    throw new InvalidOperationException("The wrong BuilderScope is created");
                }

                foreach (IFCOrientedEdge edge in EdgeList)
                {
                    if (edge == null || edge.EdgeStart == null || edge.EdgeEnd == null)
                    {
                        Importer.TheLog.LogError(Id, "Invalid edge loop", true);
                        return;
                    }

                    edge.CreateShape(shapeEditScope, lcs, scaledLcs, guid);

                    if (lcs == null)
                    {
                        lcs = Transform.Identity;
                    }

                    IFCEdge edgeElement  = edge.EdgeElement;
                    Curve   edgeGeometry = null;
                    if (edgeElement is IFCEdgeCurve)
                    {
                        edgeGeometry = edgeElement.GetGeometry();
                    }
                    else
                    {
                        //TODO: find a way to get the edgegeometry here
                        edgeGeometry = null;
                    }

                    if (edgeGeometry == null)
                    {
                        Importer.TheLog.LogError(edgeElement.Id, "Cannot get the edge geometry of this edge", true);
                    }
                    XYZ edgeStart = edgeElement.EdgeStart.GetCoordinate();
                    XYZ edgeEnd   = edgeElement.EdgeEnd.GetCoordinate();

                    if (edgeStart == null || edgeEnd == null)
                    {
                        Importer.TheLog.LogError(Id, "Invalid start or end vertices", true);
                    }

                    bool orientation = lcs.HasReflection ? !edge.Orientation : edge.Orientation;
                    if (!brepBuilderScope.AddOrientedEdgeToTheBoundary(edgeElement.Id, edgeGeometry.CreateTransformed(lcs), lcs.OfPoint(edgeStart), lcs.OfPoint(edgeEnd), edge.Orientation))
                    {
                        Importer.TheLog.LogWarning(edge.Id, "Cannot add this edge to the edge loop with Id: " + Id, false);
                        IsValidForCreation = false;
                        return;
                    }
                }
            }
            else
            {
                Importer.TheLog.LogError(Id, "Unsupported IFCEdgeLoop", true);
            }
            base.CreateShapeInternal(shapeEditScope, lcs, scaledLcs, guid);
        }