/// <summary> /// Processes IfcProductRepresentation attributes. /// </summary> /// <param name="ifcProductRepresentation">The IfcProductRepresentation handle.</param> protected override void Process(IFCAnyHandle ifcProductRepresentation) { base.Process(ifcProductRepresentation); Name = IFCImportHandleUtil.GetOptionalStringAttribute(ifcProductRepresentation, "Name", null); Description = IFCImportHandleUtil.GetOptionalStringAttribute(ifcProductRepresentation, "Description", null); List <IFCAnyHandle> representations = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcProductRepresentation, "Representations"); if (representations != null) { foreach (IFCAnyHandle representationHnd in representations) { try { IFCRepresentation representation = IFCRepresentation.ProcessIFCRepresentation(representationHnd); if (representation != null) { if (representation.RepresentationItems.Count > 0 || representation.BoundingBox != null) { Representations.Add(representation); } } } catch (Exception ex) { string msg = ex.Message; // Ignore some specific errors. if (msg != null) { if (!msg.Contains("not imported")) { Importer.TheLog.LogError(Id, msg, false); } } } } } if (IFCImportFile.TheFile.SchemaVersionAtLeast(IFCSchemaVersion.IFC2x3)) { if (IFCAnyHandleUtil.IsSubTypeOf(ifcProductRepresentation, IFCEntityType.IfcMaterialDefinitionRepresentation)) { IFCAnyHandle representedMaterial = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcProductRepresentation, "RepresentedMaterial", false); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(representedMaterial)) { RepresentedMaterial = IFCMaterial.ProcessIFCMaterial(representedMaterial); } } } }
/// <summary> /// Process IfcTriangulatedFaceSet instance /// </summary> /// <param name="ifcTriangulatedFaceSet">the handle</param> protected override void Process(IFCAnyHandle ifcTriangulatedFaceSet) { base.Process(ifcTriangulatedFaceSet); // Process the IFCCartesianPointLIst3D IFCAnyHandle coordinates = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcTriangulatedFaceSet, "Coordinates", true); if (IFCAnyHandleUtil.IsSubTypeOf(coordinates, IFCEntityType.IfcCartesianPointList3D)) { IFCCartesianPointList3D coordList = IFCCartesianPointList3D.processIFCCartesianPointList3D(coordinates); if (coordList != null) { Coordinates = coordList; } } IList <IList <double> > normals = IFCImportHandleUtil.GetListOfListOfDoubleAttribute(ifcTriangulatedFaceSet, "Normals"); if (normals != null) { if (normals.Count > 0) { Normals = normals; } } bool?closed = IFCAnyHandleUtil.GetBooleanAttribute(ifcTriangulatedFaceSet, "Closed"); if (closed != null) { Closed = closed; } IList <IList <int> > coordIndex = IFCImportHandleUtil.GetListOfListOfIntegerAttribute(ifcTriangulatedFaceSet, "CoordIndex"); if (coordIndex != null) { if (coordIndex.Count > 0) { CoordIndex = coordIndex; } } IList <IList <int> > normalIndex = IFCImportHandleUtil.GetListOfListOfIntegerAttribute(ifcTriangulatedFaceSet, "NormalIndex"); if (normalIndex != null) { if (normalIndex.Count > 0) { NormalIndex = normalIndex; } } }
protected override void Process(IFCAnyHandle ifcCurve) { base.Process(ifcCurve); IFCAnyHandle position = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcCurve, "Position", false); if (position == null) { return; } Position = IFCLocation.ProcessIFCAxis2Placement(position); }
override protected void Process(IFCAnyHandle ifcSurface) { base.Process(ifcSurface); IFCAnyHandle ifcAxisPosition = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcSurface, "AxisPosition", true); AxisPosition = IFCLocation.ProcessIFCAxis1Placement(ifcAxisPosition); if (AxisPosition == null) { Importer.TheLog.LogError(ifcSurface.StepId, "Cannot find the axis position of this surface of revolution", true); } }
override protected void Process(IFCAnyHandle ifcDerivedProfileDef) { base.Process(ifcDerivedProfileDef); IFCAnyHandle ifcParentProfile = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcDerivedProfileDef, "ParentProfile", true); ParentProfile = IFCProfileDef.ProcessIFCProfileDef(ifcParentProfile); IFCAnyHandle ifcOperator = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcDerivedProfileDef, "Operator", true); Operator = IFCCartesianTransformOperator.ProcessIFCCartesianTransformOperator(ifcOperator); Label = IFCAnyHandleUtil.GetStringAttribute(ifcDerivedProfileDef, "Label"); }
private IList <Curve> ProcessIFCCompositeCurveSegment(IFCAnyHandle ifcCurveSegment) { bool found = false; bool sameSense = IFCImportHandleUtil.GetRequiredBooleanAttribute(ifcCurveSegment, "SameSense", out found); if (!found) { sameSense = true; } IFCAnyHandle ifcParentCurve = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcCurveSegment, "ParentCurve", true); IFCCurve parentCurve = null; using (TemporaryVerboseLogging logger = new TemporaryVerboseLogging()) { parentCurve = IFCCurve.ProcessIFCCurve(ifcParentCurve); } if (parentCurve == null) { Importer.TheLog.LogWarning(ifcCurveSegment.StepId, "Error processing ParentCurve (#" + ifcParentCurve.StepId + ") for IfcCompositeCurveSegment; this may be repairable.", false); return(null); } bool hasCurve = (parentCurve.Curve != null); bool hasCurveLoop = (parentCurve.CurveLoop != null); if (!hasCurve && !hasCurveLoop) { Importer.TheLog.LogWarning(ifcCurveSegment.StepId, "Error processing ParentCurve (#" + ifcParentCurve.StepId + ") for IfcCompositeCurveSegment; this may be repairable.", false); return(null); } IList <Curve> curveSegments = new List <Curve>(); if (hasCurve) { curveSegments.Add(parentCurve.Curve); } else if (hasCurveLoop) { foreach (Curve subCurve in parentCurve.CurveLoop) { curveSegments.Add(subCurve); } } return(curveSegments); }
protected override void Process(IFCAnyHandle ifcMaterialProfileSetUsageTapering) { base.Process(ifcMaterialProfileSetUsageTapering); IFCAnyHandle ifcMaterialProfileSet = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcMaterialProfileSetUsageTapering, "ForProfileEndSet", true); if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcMaterialProfileSet)) { ForProfileSet = IFCMaterialProfileSet.ProcessIFCMaterialProfileSet(ifcMaterialProfileSet); } bool found = false; CardinalPoint = IFCImportHandleUtil.GetOptionalIntegerAttribute(ifcMaterialProfileSetUsageTapering, "CardinalEndPoint", out found); }
override protected void Process(IFCAnyHandle solid) { base.Process(solid); IFCAnyHandle directrix = IFCImportHandleUtil.GetRequiredInstanceAttribute(solid, "Directrix", true); Directrix = IFCCurve.ProcessIFCCurve(directrix); bool found = false; Radius = IFCImportHandleUtil.GetRequiredScaledLengthAttribute(solid, "Radius", out found); if (!found || !Application.IsValidThickness(Radius)) { Importer.TheLog.LogError(solid.StepId, "IfcSweptDiskSolid radius is invalid, aborting.", true); } double innerRadius = IFCImportHandleUtil.GetOptionalScaledLengthAttribute(solid, "InnerRadius", 0.0); if (Application.IsValidThickness(innerRadius)) { if (!Application.IsValidThickness(Radius - innerRadius)) { Importer.TheLog.LogError(solid.StepId, "IfcSweptDiskSolid inner radius is too large, aborting.", true); } InnerRadius = innerRadius; } StartParameter = IFCImportHandleUtil.GetOptionalDoubleAttribute(solid, "StartParam", 0.0); if (StartParameter < MathUtil.Eps()) { StartParameter = 0.0; } double endParameter = IFCImportHandleUtil.GetOptionalDoubleAttribute(solid, "EndParam", -1.0); if (!MathUtil.IsAlmostEqual(endParameter, -1.0)) { if (endParameter < StartParameter + MathUtil.Eps()) { Importer.TheLog.LogWarning(solid.StepId, "IfcSweptDiskSolid swept curve end parameter less than or equal to start parameter, ignoring both.", true); StartParameter = 0.0; } else { EndParameter = endParameter; } } }
/// <summary> /// Converts an IfcVector into a UV or XYZ value. /// </summary> /// <param name="vector">The handle to the IfcVector.</param> /// <returns>An XYZ value corresponding to the value in the file. There are no transformations done in this routine. /// If the return is an XY point, the Z value will be set to 0.</returns> public static XYZ ProcessScaledLengthIFCVector(IFCAnyHandle vector) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(vector)) { Importer.TheLog.LogNullError(IFCEntityType.IfcVector); return(null); } if (!IFCAnyHandleUtil.IsValidSubTypeOf(vector, IFCEntityType.IfcVector)) { Importer.TheLog.LogUnexpectedTypeError(vector, IFCEntityType.IfcVector, false); return(null); } XYZ xyz; int stepId = vector.StepId; if (IFCImportFile.TheFile.XYZMap.TryGetValue(stepId, out xyz)) { return(xyz); } IFCAnyHandle direction = IFCImportHandleUtil.GetRequiredInstanceAttribute(vector, "Orientation", false); if (direction == null) { return(null); } bool found = false; double magnitude = IFCImportHandleUtil.GetRequiredScaledLengthAttribute(vector, "Magnitude", out found); if (!found) { magnitude = 1.0; } XYZ directionXYZ = IFCPoint.ProcessIFCDirection(direction); if (directionXYZ == null) { return(null); } xyz = directionXYZ * magnitude; AddToCaches(stepId, IFCEntityType.IfcVector, xyz); return(xyz); }
override protected void Process(IFCAnyHandle ifcSurface) { base.Process(ifcSurface); IFCAnyHandle extrudedDirection = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcSurface, "ExtrudedDirection", true); ExtrudedDirection = IFCPoint.ProcessNormalizedIFCDirection(extrudedDirection); bool found = false; Depth = IFCImportHandleUtil.GetRequiredScaledLengthAttribute(ifcSurface, "Depth", out found); if (!found) { Importer.TheLog.LogError(Id, "IfcSurfaceOfLinearExtrusion has no height, ignoring.", true); } }
/// <summary> /// Process IfcTriangulatedFaceSet instance /// </summary> /// <param name="ifcTessellatedFaceSet">the handle</param> protected override void Process(IFCAnyHandle ifcTessellatedFaceSet) { base.Process(ifcTessellatedFaceSet); // Process the IFCCartesianPointLIst3D IFCAnyHandle coordinates = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcTessellatedFaceSet, "Coordinates", true); if (IFCAnyHandleUtil.IsSubTypeOf(coordinates, IFCEntityType.IfcCartesianPointList3D)) { IFCCartesianPointList3D coordList = IFCCartesianPointList3D.processIFCCartesianPointList3D(coordinates); if (coordList != null) { Coordinates = coordList; } } }
override protected void Process(IFCAnyHandle solid) { base.Process(solid); IFCAnyHandle treeRootExpression = IFCImportHandleUtil.GetRequiredInstanceAttribute(solid, "TreeRootExpression", false); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(treeRootExpression)) { if (IFCAnyHandleUtil.IsSubTypeOf(treeRootExpression, IFCEntityType.IfcBooleanResult)) { BooleanResult = IFCBooleanResult.ProcessIFCBooleanResult(treeRootExpression); } else { IFCImportFile.TheLog.LogUnhandledSubTypeError(treeRootExpression, "IfcCsgSelect", false); } } }
protected void ProcessGridPlacement(IFCAnyHandle gridPlacement) { Importer.TheCache.PreProcessGrids(); IFCAnyHandle placementLocation = IFCImportHandleUtil.GetRequiredInstanceAttribute(gridPlacement, "PlacementLocation", true); IFCVirtualGridIntersection virtualGridIntersection = IFCVirtualGridIntersection.ProcessIFCVirtualGridIntersection(placementLocation); IFCAnyHandle placementRefDirection = IFCAnyHandleUtil.GetInstanceAttribute(gridPlacement, "PlacementRefDirection"); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(placementRefDirection)) { // TODO: Handle later, if we see examples of use. Importer.TheLog.LogError(gridPlacement.Id, "placementRefDirection attribute not handled.", false); } RelativeTransform = virtualGridIntersection.LocalCoordinateSystem; }
protected override void Process(IFCAnyHandle ifcMaterialLayerSetUsage) { base.Process(ifcMaterialLayerSetUsage); IFCAnyHandle ifcMaterialLayerSet = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcMaterialLayerSetUsage, "ForLayerSet", true); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(ifcMaterialLayerSet)) { MaterialLayerSet = IFCMaterialLayerSet.ProcessIFCMaterialLayerSet(ifcMaterialLayerSet); } string directionAsString = IFCAnyHandleUtil.GetEnumerationAttribute(ifcMaterialLayerSetUsage, "LayerSetDirection"); if (directionAsString == null) { Direction = IFCLayerSetDirection.Axis3; IFCImportFile.TheLog.LogWarning(ifcMaterialLayerSetUsage.StepId, "No LayerSetDirection defined, defaulting to Axis3.", false); } else { Direction = (IFCLayerSetDirection)Enum.Parse(typeof(IFCLayerSetDirection), directionAsString, true); } string directionSenseAsString = IFCAnyHandleUtil.GetEnumerationAttribute(ifcMaterialLayerSetUsage, "DirectionSense"); if (directionSenseAsString == null) { DirectionSense = IFCDirectionSense.Positive; IFCImportFile.TheLog.LogWarning(ifcMaterialLayerSetUsage.StepId, "No DirectionSense defined, defaulting to Positive.", false); } else { DirectionSense = (IFCDirectionSense)Enum.Parse(typeof(IFCDirectionSense), directionSenseAsString, true); } bool found = false; Offset = IFCImportHandleUtil.GetRequiredScaledLengthAttribute(ifcMaterialLayerSetUsage, "OffsetFromReferenceLine", out found); if (!found) { IFCImportFile.TheLog.LogWarning(ifcMaterialLayerSetUsage.StepId, "No Offset defined, defaulting to 0.", false); } }
protected override void Process(IFCAnyHandle ifcCurve) { base.Process(ifcCurve); IFCAnyHandle basisCurve = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcCurve, "BasisCurve", false); if (basisCurve == null) { return; } IFCAnyHandle dir = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcCurve, "RefDirection", false); bool found = false; double distance = IFCImportHandleUtil.GetRequiredScaledLengthAttribute(ifcCurve, "Distance", out found); if (!found) { distance = 0.0; } IFCCurve ifcBasisCurve = IFCCurve.ProcessIFCCurve(basisCurve); XYZ dirXYZ = (dir == null) ? ifcBasisCurve.GetNormal() : IFCPoint.ProcessNormalizedIFCDirection(dir); try { if (ifcBasisCurve.Curve != null) { SetCurve(ifcBasisCurve.Curve.CreateOffset(distance, XYZ.BasisZ)); } else { CurveLoop baseCurveLoop = ifcBasisCurve.GetTheCurveLoop(); if (baseCurveLoop != null) { SetCurveLoop(CurveLoop.CreateViaOffset(baseCurveLoop, distance, XYZ.BasisZ)); } } } catch { Importer.TheLog.LogError(ifcCurve.StepId, "Couldn't create offset curve.", false); } }
override protected void Process(IFCAnyHandle ifcSurface) { base.Process(ifcSurface); IFCAnyHandle sweptCurve = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcSurface, "SweptCurve", true); SweptCurve = IFCProfile.ProcessIFCProfile(sweptCurve); IFCAnyHandle position = IFCImportHandleUtil.GetOptionalInstanceAttribute(ifcSurface, "Position"); if (IFCAnyHandleUtil.IsNullOrHasNoValue(position)) { Position = Transform.Identity; } else { Position = IFCLocation.ProcessIFCAxis2Placement(position); } }
override protected void Process(IFCAnyHandle solid) { base.Process(solid); IFCAnyHandle sweptArea = IFCImportHandleUtil.GetRequiredInstanceAttribute(solid, "SweptArea", true); SweptArea = IFCProfileDef.ProcessIFCProfileDef(sweptArea); IFCAnyHandle location = IFCImportHandleUtil.GetRequiredInstanceAttribute(solid, "Position", false); if (location != null) { Position = IFCLocation.ProcessIFCAxis2Placement(location); } else { Position = Transform.Identity; } }
override protected void Process(IFCAnyHandle ifcOrientedEdge) { base.Process(ifcOrientedEdge); IFCAnyHandle edgeElement = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcOrientedEdge, "EdgeElement", true); EdgeElement = IFCEdge.ProcessIFCEdge(edgeElement); bool found = false; bool orientation = IFCImportHandleUtil.GetRequiredBooleanAttribute(ifcOrientedEdge, "Orientation", out found); if (found) { Orientation = orientation; } else { Importer.TheLog.LogWarning(ifcOrientedEdge.StepId, "Cannot find Orientation attribute, defaulting to true", false); Orientation = true; } }
protected override void Process(IFCAnyHandle ifcEdgeCurve) { base.Process(ifcEdgeCurve); IFCAnyHandle edgeGeometry = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcEdgeCurve, "EdgeGeometry", true); EdgeGeometry = IFCCurve.ProcessIFCCurve(edgeGeometry); bool found = false; bool sameSense = IFCImportHandleUtil.GetRequiredBooleanAttribute(ifcEdgeCurve, "SameSense", out found); if (found) { SameSense = sameSense; } else { Importer.TheLog.LogWarning(ifcEdgeCurve.StepId, "Cannot find SameSense attribute, defaulting to true", false); SameSense = true; } }
override protected void Process(IFCAnyHandle ifcOrientedEdge) { base.Process(ifcOrientedEdge); IFCAnyHandle edgeElement = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcOrientedEdge, "EdgeElement", true); EdgeElement = IFCEdge.ProcessIFCEdge(edgeElement); bool found = false; bool orientation = IFCImportHandleUtil.GetRequiredBooleanAttribute(ifcOrientedEdge, "Orientation", out found); if (found) { Orientation = orientation; } else { Importer.TheLog.LogWarning(ifcOrientedEdge.StepId, "Cannot find Orientation attribute, defaulting to true", false); Orientation = true; } // ODA Toolkit doesn't support derived attributes. Set EdgeStart and EdgeEnd // if they haven't been set. if (EdgeStart == null) { EdgeStart = Orientation ? EdgeElement.EdgeStart : EdgeElement.EdgeEnd; if (EdgeStart == null) { Importer.TheLog.LogError(ifcOrientedEdge.StepId, "Cannot find the starting vertex", true); } } if (EdgeEnd == null) { EdgeEnd = Orientation ? EdgeElement.EdgeEnd : EdgeElement.EdgeStart; if (EdgeEnd == null) { Importer.TheLog.LogError(ifcOrientedEdge.StepId, "Cannot find the ending vertex", true); } } }
override protected void Process(IFCAnyHandle solid) { base.Process(solid); bool found = false; bool agreementFlag = IFCImportHandleUtil.GetRequiredBooleanAttribute(solid, "AgreementFlag", out found); if (found) { AgreementFlag = agreementFlag; } IFCAnyHandle baseSurface = IFCImportHandleUtil.GetRequiredInstanceAttribute(solid, "BaseSurface", true); BaseSurface = IFCSurface.ProcessIFCSurface(baseSurface); if (!(BaseSurface is IFCPlane)) { Importer.TheLog.LogUnhandledSubTypeError(baseSurface, IFCEntityType.IfcSurface, true); } if (IFCAnyHandleUtil.IsValidSubTypeOf(solid, IFCEntityType.IfcPolygonalBoundedHalfSpace)) { IFCAnyHandle position = IFCImportHandleUtil.GetRequiredInstanceAttribute(solid, "Position", false); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(position)) { BaseBoundingCurveTransform = IFCLocation.ProcessIFCAxis2Placement(position); } else { BaseBoundingCurveTransform = Transform.Identity; } IFCAnyHandle boundaryCurveHandle = IFCImportHandleUtil.GetRequiredInstanceAttribute(solid, "PolygonalBoundary", true); BaseBoundingCurve = IFCCurve.ProcessIFCCurve(boundaryCurveHandle); if (BaseBoundingCurve == null || BaseBoundingCurve.GetTheCurveLoop() == null) { Importer.TheLog.LogError(Id, "IfcPolygonalBoundedHalfSpace has an invalid boundary, ignoring.", true); } } }
/// <summary> /// Processes IfcRepresentationMap attributes. /// </summary> /// <param name="ifcRepresentationMap">The IfcRepresentationMap handle.</param> protected override void Process(IFCAnyHandle ifcRepresentationMap) { base.Process(ifcRepresentationMap); IFCAnyHandle mappingOrigin = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentationMap, "MappingOrigin", false); if (mappingOrigin != null) { MappingOrigin = IFCLocation.ProcessIFCAxis2Placement(mappingOrigin); } else { MappingOrigin = Transform.Identity; } IFCAnyHandle mappedRepresentation = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentationMap, "MappedRepresentation", false); if (mappedRepresentation != null) { MappedRepresentation = IFCRepresentation.ProcessIFCRepresentation(mappedRepresentation); } }
protected override void Process(IFCAnyHandle ifcMaterialConstituent) { base.Process(ifcMaterialConstituent); IFCAnyHandle ifcMaterial = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcMaterialConstituent, "Material", true); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(ifcMaterial)) { Material = IFCMaterial.ProcessIFCMaterial(ifcMaterial); } Name = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialConstituent, "Name", null); Description = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialConstituent, "Description", null); double fraction = IFCImportHandleUtil.GetOptionalRealAttribute(ifcMaterialConstituent, "Fraction", -1); if (fraction >= 0) { Fraction = fraction; } Category = IFCImportHandleUtil.GetOptionalStringAttribute(ifcMaterialConstituent, "Category", null); return; }
protected override void Process(IFCAnyHandle ifcEdge) { base.Process(ifcEdge); IFCAnyHandle edgeStart = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcEdge, "EdgeStart", false); if (IFCAnyHandleUtil.IsNullOrHasNoValue(edgeStart)) { Importer.TheLog.LogError(ifcEdge.StepId, "Cannot find the starting vertex", true); return; } IFCAnyHandle edgeEnd = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcEdge, "EdgeEnd", false); if (IFCAnyHandleUtil.IsNullOrHasNoValue(edgeEnd)) { Importer.TheLog.LogError(ifcEdge.StepId, "Cannot find the ending vertex", true); return; } EdgeStart = IFCVertex.ProcessIFCVertex(edgeStart); EdgeEnd = IFCVertex.ProcessIFCVertex(edgeEnd); }
override protected void Process(IFCAnyHandle solid) { base.Process(solid); // We will not fail if the direction is not given, but instead assume it to be normal to the swept area. IFCAnyHandle direction = IFCImportHandleUtil.GetRequiredInstanceAttribute(solid, "ExtrudedDirection", false); if (direction != null) { Direction = IFCPoint.ProcessNormalizedIFCDirection(direction); } else { Direction = XYZ.BasisZ; } bool found = false; Depth = IFCImportHandleUtil.GetRequiredScaledLengthAttribute(solid, "Depth", out found); if (found && Depth < 0.0) { // Reverse depth and orientation. if (Application.IsValidThickness(-Depth)) { Depth = -Depth; Direction = -Direction; IFCImportFile.TheLog.LogWarning(solid.StepId, "negative extrusion depth is invalid, reversing direction.", false); } } if (!found || !Application.IsValidThickness(Depth)) { string depthAsString = UnitFormatUtils.Format(IFCImportFile.TheFile.Document.GetUnits(), UnitType.UT_Length, Depth, true, false); IFCImportFile.TheLog.LogError(solid.StepId, "extrusion depth of " + depthAsString + " is invalid, aborting.", true); } }
private void ProcessIFCConic(IFCAnyHandle ifcCurve) { IFCAnyHandle position = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcCurve, "Position", false); if (position == null) { return; } Transform transform = IFCLocation.ProcessIFCAxis2Placement(position); if (IFCAnyHandleUtil.IsSubTypeOf(ifcCurve, IFCEntityType.IfcCircle)) { ProcessIFCCircle(ifcCurve, transform); } else if (IFCAnyHandleUtil.IsSubTypeOf(ifcCurve, IFCEntityType.IfcEllipse)) { ProcessIFCEllipse(ifcCurve, transform); } else { IFCImportFile.TheLog.LogUnhandledSubTypeError(ifcCurve, IFCEntityType.IfcConic, true); } }
protected override void Process(IFCAnyHandle ifcMaterialLayerSetUsage) { base.Process(ifcMaterialLayerSetUsage); IFCAnyHandle ifcMaterialLayerSet = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcMaterialLayerSetUsage, "ForLayerSet", true); if (!IFCAnyHandleUtil.IsNullOrHasNoValue(ifcMaterialLayerSet)) { MaterialLayerSet = IFCMaterialLayerSet.ProcessIFCMaterialLayerSet(ifcMaterialLayerSet); } Direction = IFCEnums.GetSafeEnumerationAttribute(ifcMaterialLayerSetUsage, "LayerSetDirection", IFCLayerSetDirection.Axis3); DirectionSense = IFCEnums.GetSafeEnumerationAttribute(ifcMaterialLayerSetUsage, "DirectionSense", IFCDirectionSense.Positive); bool found = false; Offset = IFCImportHandleUtil.GetRequiredScaledLengthAttribute(ifcMaterialLayerSetUsage, "OffsetFromReferenceLine", out found); if (!found) { Importer.TheLog.LogWarning(ifcMaterialLayerSetUsage.StepId, "No Offset defined, defaulting to 0.", false); } }
protected override void Process(IFCAnyHandle ifcCurve) { base.Process(ifcCurve); IFCAnyHandle basisCurve = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcCurve, "BasisCurve", false); if (basisCurve == null) { return; } bool found = false; double distance = IFCImportHandleUtil.GetRequiredScaledLengthAttribute(ifcCurve, "Distance", out found); if (!found) { distance = 0.0; } try { IFCCurve ifcBasisCurve = IFCCurve.ProcessIFCCurve(basisCurve); if (ifcBasisCurve.Curve != null) { Curve = ifcBasisCurve.Curve.CreateOffset(distance, XYZ.BasisZ); } else if (ifcBasisCurve.CurveLoop != null) { CurveLoop = CurveLoop.CreateViaOffset(ifcBasisCurve.CurveLoop, distance, XYZ.BasisZ); } } catch { Importer.TheLog.LogError(ifcCurve.StepId, "Couldn't create offset curve.", false); } }
/// <summary> /// Processes IfcRepresentation attributes. /// </summary> /// <param name="ifcRepresentation">The IfcRepresentation handle.</param> override protected void Process(IFCAnyHandle ifcRepresentation) { base.Process(ifcRepresentation); IFCAnyHandle representationContext = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcRepresentation, "ContextOfItems", false); if (representationContext != null) { Context = IFCRepresentationContext.ProcessIFCRepresentationContext(representationContext); } string identifier = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentation, "RepresentationIdentifier", null); Identifier = GetRepresentationIdentifier(identifier, ifcRepresentation); Type = IFCImportHandleUtil.GetOptionalStringAttribute(ifcRepresentation, "RepresentationType", null); HashSet <IFCAnyHandle> items = IFCAnyHandleUtil.GetAggregateInstanceAttribute <HashSet <IFCAnyHandle> >(ifcRepresentation, "Items"); LayerAssignment = IFCPresentationLayerAssignment.GetTheLayerAssignment(ifcRepresentation, true); foreach (IFCAnyHandle item in items) { IFCRepresentationItem repItem = null; try { if (NotAllowedInRepresentation(item)) { IFCEntityType entityType = IFCAnyHandleUtil.GetEntityType(item); Importer.TheLog.LogWarning(item.StepId, "Ignoring unhandled representation item of type " + entityType.ToString() + " in " + Identifier.ToString() + " representation.", true); continue; } // Special processing for bounding boxes - only IfcBoundingBox allowed. if (IFCAnyHandleUtil.IsSubTypeOf(item, IFCEntityType.IfcBoundingBox)) { // Don't read in Box represenation unless options allow it. if (IFCImportFile.TheFile.Options.ProcessBoundingBoxGeometry == IFCProcessBBoxOptions.Never) { Importer.TheLog.LogWarning(item.StepId, "BoundingBox not imported with ProcessBoundingBoxGeometry=Never", false); } else { if (BoundingBox != null) { Importer.TheLog.LogWarning(item.StepId, "Found second IfcBoundingBox representation item, ignoring.", false); continue; } BoundingBox = ProcessBoundingBox(item); } } else { repItem = IFCRepresentationItem.ProcessIFCRepresentationItem(item); } } catch (Exception ex) { Importer.TheLog.LogError(item.StepId, ex.Message, false); } if (repItem != null) { RepresentationItems.Add(repItem); } } }
override protected void Process(IFCAnyHandle item) { base.Process(item); IFCAnyHandle localOrigin = IFCImportHandleUtil.GetRequiredInstanceAttribute(item, "LocalOrigin", false); XYZ origin = null; if (localOrigin != null) { origin = IFCPoint.ProcessScaledLengthIFCCartesianPoint(localOrigin); } else { origin = XYZ.Zero; } IFCAnyHandle axis1 = IFCImportHandleUtil.GetOptionalInstanceAttribute(item, "Axis1"); XYZ xAxis = null; if (axis1 != null) { xAxis = IFCPoint.ProcessNormalizedIFCDirection(axis1); } IFCAnyHandle axis2 = IFCImportHandleUtil.GetOptionalInstanceAttribute(item, "Axis2"); XYZ yAxis = null; if (axis2 != null) { yAxis = IFCPoint.ProcessNormalizedIFCDirection(axis2); } Scale = IFCImportHandleUtil.GetOptionalRealAttribute(item, "Scale", 1.0); XYZ zAxis = null; // Assume that the dimensionality of the IfcCartesianTransformationOperator is 2, unless determined otherwise below. int dim = 2; if (IFCAnyHandleUtil.IsSubTypeOf(item, IFCEntityType.IfcCartesianTransformationOperator2DnonUniform)) { ScaleY = IFCImportHandleUtil.GetOptionalRealAttribute(item, "Scale2", Scale); } else if (IFCAnyHandleUtil.IsSubTypeOf(item, IFCEntityType.IfcCartesianTransformationOperator3D)) { dim = 3; IFCAnyHandle axis3 = IFCImportHandleUtil.GetOptionalInstanceAttribute(item, "Axis3"); if (axis3 != null) { zAxis = IFCPoint.ProcessNormalizedIFCDirection(axis3); } if (IFCAnyHandleUtil.IsSubTypeOf(item, IFCEntityType.IfcCartesianTransformationOperator3DnonUniform)) { ScaleY = IFCImportHandleUtil.GetOptionalRealAttribute(item, "Scale2", Scale); ScaleZ = IFCImportHandleUtil.GetOptionalRealAttribute(item, "Scale3", Scale); } } // Set the axes based on what is specified. Transform = CreateTransformUsingIfcBaseAxisCalculation(xAxis, yAxis, zAxis, origin, dim, Id); }