/// <summary> /// Create an IFCElementarySurface object from a handle of type IfcElementarySurface. /// </summary> /// <param name="ifcElementarySurface">The IFC handle.</param> /// <returns>The IFCElementarySurface object.</returns> public static IFCElementarySurface ProcessIFCElementarySurface(IFCAnyHandle ifcElementarySurface) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcElementarySurface)) { Importer.TheLog.LogNullError(IFCEntityType.IfcElementarySurface); return(null); } IFCEntity elementarySurface; if (IFCImportFile.TheFile.EntityMap.TryGetValue(ifcElementarySurface.StepId, out elementarySurface)) { return(elementarySurface as IFCElementarySurface); } if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcElementarySurface, IFCEntityType.IfcPlane)) { return(IFCPlane.ProcessIFCPlane(ifcElementarySurface)); } if (IFCAnyHandleUtil.IsValidSubTypeOf(ifcElementarySurface, IFCEntityType.IfcCylindricalSurface)) { return(IFCCylindricalSurface.ProcessIfcCylindricalSurface(ifcElementarySurface)); } Importer.TheLog.LogUnhandledSubTypeError(ifcElementarySurface, IFCEntityType.IfcElementarySurface, true); return(null); }
/// <summary> /// In case of a Boolean operation failure, provide a recommended direction to shift the geometry in for a second attempt. /// </summary> /// <param name="lcs">The local transform for this entity.</param> /// <returns>An XYZ representing a unit direction vector, or null if no direction is suggested.</returns> /// <remarks>If the 2nd attempt fails, a third attempt will be done with a shift in the opposite direction.</remarks> public XYZ GetSuggestedShiftDirection(Transform lcs) { IFCPlane ifcPlane = BaseSurface as IFCPlane; Plane plane = (ifcPlane != null) ? ifcPlane.Plane : null; XYZ untransformedNorm = (plane != null) ? plane.Normal : null; return((lcs == null) ? untransformedNorm : lcs.OfVector(untransformedNorm)); }
/// <summary> /// Create an IFCPlane object from a handle of type ifcPlane. /// </summary> /// <param name="ifcPlane">The IFC handle.</param> /// <returns>The IFCPlane object.</returns> public static IFCPlane ProcessIFCPlane(IFCAnyHandle ifcPlane) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcPlane)) { Importer.TheLog.LogNullError(IFCEntityType.IfcPlane); return null; } IFCEntity plane; if (!IFCImportFile.TheFile.EntityMap.TryGetValue(ifcPlane.StepId, out plane)) plane = new IFCPlane(ifcPlane); return plane as IFCPlane; }
/// <summary> /// Create an IFCPlane object from a handle of type ifcPlane. /// </summary> /// <param name="ifcPlane">The IFC handle.</param> /// <returns>The IFCPlane object.</returns> public static IFCPlane ProcessIFCPlane(IFCAnyHandle ifcPlane) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcPlane)) { Importer.TheLog.LogNullError(IFCEntityType.IfcPlane); return(null); } IFCEntity plane; if (!IFCImportFile.TheFile.EntityMap.TryGetValue(ifcPlane.StepId, out plane)) { plane = new IFCPlane(ifcPlane); } return(plane as IFCPlane); }
/// <summary> /// Create geometry for an IfcHalfSpaceSolid. /// </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>A list containing one geometry for the IfcHalfSpaceSolid.</returns> protected virtual IList <GeometryObject> CreateGeometryInternal( IFCImportShapeEditScope shapeEditScope, Transform unscaledLcs, Transform scaledLcs, string guid) { IFCPlane ifcPlane = BaseSurface as IFCPlane; Plane plane = ifcPlane.Plane; XYZ origin = plane.Origin; XYZ xVec = plane.XVec; XYZ yVec = plane.YVec; // Set some huge boundaries for now. const double largeCoordinateValue = 100000; XYZ[] corners = new XYZ[4] { unscaledLcs.OfPoint((xVec * -largeCoordinateValue) + (yVec * -largeCoordinateValue) + origin), unscaledLcs.OfPoint((xVec * largeCoordinateValue) + (yVec * -largeCoordinateValue) + origin), unscaledLcs.OfPoint((xVec * largeCoordinateValue) + (yVec * largeCoordinateValue) + origin), unscaledLcs.OfPoint((xVec * -largeCoordinateValue) + (yVec * largeCoordinateValue) + origin) }; IList <CurveLoop> loops = new List <CurveLoop>(); CurveLoop loop = new CurveLoop(); for (int ii = 0; ii < 4; ii++) { if (AgreementFlag) { loop.Append(Line.CreateBound(corners[(5 - ii) % 4], corners[(4 - ii) % 4])); } else { loop.Append(Line.CreateBound(corners[ii], corners[(ii + 1) % 4])); } } loops.Add(loop); XYZ normal = unscaledLcs.OfVector(AgreementFlag ? -plane.Normal : plane.Normal); SolidOptions solidOptions = new SolidOptions(GetMaterialElementId(shapeEditScope), shapeEditScope.GraphicsStyleId); Solid baseSolid = GeometryCreationUtilities.CreateExtrusionGeometry(loops, normal, largeCoordinateValue, solidOptions); if (BaseBoundingCurve != null) { CurveLoop polygonalBoundary = BaseBoundingCurve.CurveLoop; Transform unscaledTotalTransform = unscaledLcs.Multiply(BaseBoundingCurveTransform); Transform scaledTotalTransform = scaledLcs.Multiply(BaseBoundingCurveTransform); // Make sure this bounding polygon extends below base of half-space soild. Transform moveBaseTransform = Transform.Identity; moveBaseTransform.Origin = new XYZ(0, 0, -largeCoordinateValue); unscaledTotalTransform = unscaledTotalTransform.Multiply(moveBaseTransform); scaledTotalTransform = scaledTotalTransform.Multiply(moveBaseTransform); CurveLoop transformedPolygonalBoundary = IFCGeometryUtil.CreateTransformed(polygonalBoundary, Id, unscaledTotalTransform, scaledTotalTransform); IList <CurveLoop> boundingLoops = new List <CurveLoop>(); boundingLoops.Add(transformedPolygonalBoundary); Solid boundingSolid = GeometryCreationUtilities.CreateExtrusionGeometry(boundingLoops, unscaledTotalTransform.BasisZ, 2.0 * largeCoordinateValue, solidOptions); baseSolid = IFCGeometryUtil.ExecuteSafeBooleanOperation(Id, BaseBoundingCurve.Id, baseSolid, boundingSolid, BooleanOperationsType.Intersect, null); } IList <GeometryObject> returnList = new List <GeometryObject>(); returnList.Add(baseSolid); return(returnList); }