Beispiel #1
0
        /// <summary>
        /// Return geometry for a particular representation item.
        /// </summary>
        /// <param name="shapeEditScope">The shape edit scope.</param>
        /// <param name="lcs">Local coordinate system for the geometry, without scale.</param>
        /// <param name="scaledLcs">Local coordinate system for the geometry, including scale, potentially non-uniform.</param>
        /// <param name="guid">The guid of an element for which represntation is being created.</param>
        /// <returns>The created geometry.</returns>
        protected override IList <GeometryObject> CreateGeometryInternal(
            IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid)
        {
            // since IFCAdvancedBrep must contain a closed shell, we set the BuildPreferenceType to be solid for now
            for (int pass = 0; pass < 2; pass++)
            {
                using (BuilderScope bs = shapeEditScope.InitializeBuilder(IFCShapeBuilderType.BrepBuilder))
                {
                    BrepBuilderScope brepBuilderScope = bs as BrepBuilderScope;

                    BRepType brepType = (pass == 0) ? BRepType.Solid : BRepType.OpenShell;
                    brepBuilderScope.StartCollectingFaceSet(brepType);

                    Outer.AllowInvalidFace = (pass == 0);
                    Outer.CreateShape(shapeEditScope, lcs, scaledLcs, guid);

                    IList <GeometryObject> geomObjs = null;
                    geomObjs = brepBuilderScope.CreateGeometry();

                    // We'll return only if we have geometry; otherwise we'll try again with looser validation, if we can.
                    if (geomObjs != null)
                    {
                        if (pass == 1)
                        {
                            Importer.TheLog.LogError(Id, "Some faces are missing from this Solid; reading in as an Open Shell instead.", false);
                        }
                        return(geomObjs);
                    }
                }
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Create geometry for a particular representation item.
        /// </summary>
        /// <param name="shapeEditScope">The geometry creation scope.</param>
        /// <param name="lcs">Local coordinate system for the geometry, without scale.</param>
        /// <param name="scaledLcs">Local coordinate system for the geometry, including scale, potentially non-uniform.</param>
        /// <param name="guid">The guid of an element for which represntation is being created.</param>
        protected override void CreateShapeInternal(IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid)
        {
            if (shapeEditScope.BuilderType != IFCShapeBuilderType.BrepBuilder)
            {
                throw new InvalidOperationException("AdvancedFace can only be created using BrepBuilder");
            }

            // We may revisit this face on a second pass, after a first attempt to create a Solid failed.  Ignore this face.
            if (!IsValidForCreation)
            {
                return;
            }

            BrepBuilderScope brepBuilderScope = shapeEditScope.BuilderScope as BrepBuilderScope;

            Transform localTransform = lcs != null ? lcs : Transform.Identity;

            brepBuilderScope.StartCollectingFace(FaceSurface, localTransform, SameSense, GetMaterialElementId(shapeEditScope));

            foreach (IFCFaceBound faceBound in Bounds)
            {
                try
                {
                    brepBuilderScope.InitializeNewLoop();

                    faceBound.CreateShape(shapeEditScope, lcs, scaledLcs, guid);
                    IsValidForCreation = faceBound.IsValidForCreation || (!brepBuilderScope.HaveActiveFace());

                    brepBuilderScope.StopConstructingLoop(IsValidForCreation);

                    if (!IsValidForCreation)
                    {
                        break;
                    }
                }
                catch
                {
                    IsValidForCreation = false;
                    break;
                }
            }

            brepBuilderScope.StopCollectingFace(IsValidForCreation);
        }
Beispiel #3
0
        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);
        }