示例#1
0
 public TessellatedShapeBuilderScope(IFCImportShapeEditScope container)
     : base(container)
 {
     IFCImportShapeEditScope.BuildPreferenceType BuildPreference = container.BuildPreference;
     if (BuildPreference == IFCImportShapeEditScope.BuildPreferenceType.ForceSolid)
     {
         SetTargetAndFallbackGeometry(TessellatedShapeBuilderTarget.Solid, TessellatedShapeBuilderFallback.Abort);
     }
     else if (BuildPreference == IFCImportShapeEditScope.BuildPreferenceType.AnyMesh)
     {
         SetTargetAndFallbackGeometry(TessellatedShapeBuilderTarget.Mesh, TessellatedShapeBuilderFallback.Salvage);
     }
     else if (BuildPreference == IFCImportShapeEditScope.BuildPreferenceType.AnyGeometry)
     {
         SetTargetAndFallbackGeometry(TessellatedShapeBuilderTarget.AnyGeometry, TessellatedShapeBuilderFallback.Mesh);
     }
 }
示例#2
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>
        /// <remarks>As this doesn't inherit from IfcSolidModel, this is a non-virtual CreateSolid function.</remarks>
        protected IList <GeometryObject> CreateGeometry(
            IFCImportShapeEditScope shapeEditScope, Transform lcs, Transform scaledLcs, string guid)
        {
            if (Shells.Count == 0)
            {
                return(null);
            }

            IList <GeometryObject> geomObjs = null;
            int numExpectedFaces            = 0;

            foreach (IFCConnectedFaceSet faceSet in Shells)
            {
                numExpectedFaces += faceSet.Faces.Count;
            }

            // We are going to start by trying to create a Solid, even if we are passed a shell-based model, since we can frequently
            // do so.  However, if we have even one missing face, we'll loosen the requirements and revert to mesh only.
            for (int pass = 0; pass < 2; pass++)
            {
                IFCImportShapeEditScope.BuildPreferenceType target =
                    (pass == 0) ? IFCImportShapeEditScope.BuildPreferenceType.AnyGeometry : IFCImportShapeEditScope.BuildPreferenceType.AnyMesh;
                using (IFCImportShapeEditScope.BuildPreferenceSetter setter =
                           new IFCImportShapeEditScope.BuildPreferenceSetter(shapeEditScope, target))
                {
                    using (BuilderScope bs = shapeEditScope.InitializeBuilder(IFCShapeBuilderType.TessellatedShapeBuilder))
                    {
                        TessellatedShapeBuilderScope tsBuilderScope = shapeEditScope.BuilderScope as TessellatedShapeBuilderScope;

                        tsBuilderScope.StartCollectingFaceSet();

                        foreach (IFCConnectedFaceSet faceSet in Shells)
                        {
                            faceSet.CreateShape(shapeEditScope, lcs, scaledLcs, guid);
                        }

                        // If we are on our first pass, try again.  If we are on our second pass, warn and create the best geometry we can.
                        if (tsBuilderScope.CreatedFacesCount != numExpectedFaces)
                        {
                            if (pass == 0)
                            {
                                continue;
                            }

                            Importer.TheLog.LogWarning
                                (Id, "Processing " + tsBuilderScope.CreatedFacesCount + " valid faces out of " + numExpectedFaces + " total.", false);
                        }

                        geomObjs = tsBuilderScope.CreateGeometry(guid);

                        WarnOnTooFewCreatedFaces(geomObjs, numExpectedFaces);

                        break;
                    }
                }
            }

            if (geomObjs == null || geomObjs.Count == 0)
            {
                if (numExpectedFaces != 0)
                {
                    Importer.TheLog.LogError
                        (Id, "No valid geometry found.  This may be due to slivery triangles or other similar geometric issues.", false);
                    return(null);
                }
            }

            return(geomObjs);
        }