本文整理汇总了C#中Revit.IFC.Export.Exporter.BodyExporterOptions类的典型用法代码示例。如果您正苦于以下问题:C# BodyExporterOptions类的具体用法?C# BodyExporterOptions怎么用?C# BodyExporterOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BodyExporterOptions类属于Revit.IFC.Export.Exporter命名空间,在下文中一共展示了BodyExporterOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportDuctLining
/// <summary>
/// Exports an element as a covering of type insulation.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportDuctLining(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
if (element == null || geometryElement == null)
return false;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.LocalPlacement);
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return false;
}
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
IFCAnyHandle ductLining = IFCInstanceExporter.CreateCovering(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag, "Wrapping");
ExporterCacheManager.ElementToHandleCache.Register(element.Id, ductLining);
productWrapper.AddElement(element, ductLining, placementSetter.LevelInfo, ecData, true);
ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element);
CategoryUtil.CreateMaterialAssociation(exporterIFC, ductLining, matId);
}
}
tr.Commit();
return true;
}
}
示例2: ExportBuildingElementProxy
/// <summary>
/// Exports an element as building element proxy.
/// </summary>
/// <remarks>
/// This function is called from the Export function, but can also be called directly if you do not
/// want CreateInternalPropertySets to be called.
/// </remarks>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>The handle if created, null otherwise.</returns>
public static IFCAnyHandle ExportBuildingElementProxy(ExporterIFC exporterIFC, Element element,
GeometryElement geometryElement, ProductWrapper productWrapper)
{
if (element == null || geometryElement == null)
return null;
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle buildingElementProxy = null;
using (IFCTransaction tr = new IFCTransaction(file))
{
using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, element))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
ecData.SetLocalPlacement(placementSetter.LocalPlacement);
ElementId categoryId = CategoryUtil.GetSafeCategoryId(element);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
IFCAnyHandle representation = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, element,
categoryId, geometryElement, bodyExporterOptions, null, ecData, true);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(representation))
{
ecData.ClearOpenings();
return null;
}
string guid = GUIDUtil.CreateGUID(element);
IFCAnyHandle ownerHistory = ExporterCacheManager.OwnerHistoryHandle;
string revitObjectType = exporterIFC.GetFamilyName();
string name = NamingUtil.GetNameOverride(element, revitObjectType);
string description = NamingUtil.GetDescriptionOverride(element, null);
string objectType = NamingUtil.GetObjectTypeOverride(element, revitObjectType);
IFCAnyHandle localPlacement = ecData.GetLocalPlacement();
string elementTag = NamingUtil.GetTagOverride(element, NamingUtil.CreateIFCElementId(element));
buildingElementProxy = IFCInstanceExporter.CreateBuildingElementProxy(file, guid,
ownerHistory, name, description, objectType, localPlacement, representation, elementTag, null);
productWrapper.AddElement(element, buildingElementProxy, placementSetter.LevelInfo, ecData, true);
}
tr.Commit();
}
}
return buildingElementProxy;
}
示例3: ExportCeilingAndFloorElement
//.........这里部分代码省略.........
return;
if (floorAndProperties.Handle != null)
{
IList<IFCAnyHandle> representations = new List<IFCAnyHandle>();
representations.Add(floorAndProperties.Handle);
IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, representations);
prodReps.Add(prodRep);
repTypes.Add(ShapeRepresentationType.SweptSolid);
if (floorAndProperties.Data != null)
loopExtraParams.Add(floorAndProperties.Data);
}
}
}
}
// Use internal routine as backup that handles openings.
if (prodReps.Count == 0)
{
exportedAsInternalExtrusion = ExporterIFCUtils.ExportSlabAsExtrusion(exporterIFC, floorElement,
geometryElement, transformSetter, localPlacement, out localPlacements, out prodReps,
out extrusionLoops, out loopExtraParams, floorPlane);
for (int ii = 0; ii < prodReps.Count; ii++)
{
// all are extrusions
repTypes.Add(ShapeRepresentationType.SweptSolid);
}
}
if (prodReps.Count == 0)
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
bodyExporterOptions.TessellationLevel = BodyExporter.GetTessellationLevel();
BodyData bodyData;
IFCAnyHandle prodDefHnd = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC,
floorElement, catId, geometryElement, bodyExporterOptions, null, ecData, out bodyData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodDefHnd))
{
ecData.ClearOpenings();
return;
}
prodReps.Add(prodDefHnd);
repTypes.Add(bodyData.ShapeRepresentationType);
}
}
// Create the slab from either the extrusion or the BRep information.
string ifcGUID = GUIDUtil.CreateGUID(floorElement);
int numReps = exportParts ? 1 : prodReps.Count;
string entityType = null;
switch (exportType)
{
case IFCExportType.IfcFooting:
if (ExporterCacheManager.ExportOptionsCache.ExportAs4)
entityType = IFCValidateEntry.GetValidIFCType<Revit.IFC.Export.Toolkit.IFC4.IFCFootingType>(floorElement, ifcEnumType, null);
else
entityType = IFCValidateEntry.GetValidIFCType<IFCFootingType>(floorElement, ifcEnumType, null);
break;
case IFCExportType.IfcCovering:
entityType = IFCValidateEntry.GetValidIFCType<IFCCoveringType>(floorElement, ifcEnumType, "FLOORING");
示例4: ExportSurface
/// <summary>
/// Exports a geometry element to boundary representation.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="element">The element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="exportBoundaryRep">True if to export boundary representation.</param>
/// <param name="exportAsFacetation">True if to export the geometry as facetation.</param>
/// <param name="bodyRep">Body representation.</param>
/// <param name="boundaryRep">Boundary representation.</param>
/// <returns>True if success, false if fail.</returns>
public static bool ExportSurface(ExporterIFC exporterIFC, Element element, GeometryElement geometryElement,
bool exportBoundaryRep, bool exportAsFacetation, ref IFCAnyHandle bodyRep, ref IFCAnyHandle boundaryRep)
{
if (geometryElement == null)
return false;
IFCGeometryInfo ifcGeomInfo = null;
Document doc = element.Document;
Plane plane = GeometryUtil.CreateDefaultPlane();
XYZ projDir = new XYZ(0, 0, 1);
double eps = UnitUtil.ScaleLength(doc.Application.VertexTolerance);
ifcGeomInfo = IFCGeometryInfo.CreateFaceGeometryInfo(exporterIFC, plane, projDir, eps, exportBoundaryRep);
ExporterIFCUtils.CollectGeometryInfo(exporterIFC, ifcGeomInfo, geometryElement, XYZ.Zero, true);
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle surface;
// Use tessellated geometry for surface in IFC Reference View
if (ExporterUtil.IsReferenceView())
{
BodyExporterOptions options = new BodyExporterOptions(false);
surface = BodyExporter.ExportBodyAsTriangulatedFaceSet(exporterIFC, element, options, geometryElement);
}
else
{
HashSet<IFCAnyHandle> faceSets = new HashSet<IFCAnyHandle>();
IList<ICollection<IFCAnyHandle>> faceList = ifcGeomInfo.GetFaces();
foreach (ICollection<IFCAnyHandle> faces in faceList)
{
// no faces, don't complain.
if (faces.Count == 0)
continue;
HashSet<IFCAnyHandle> faceSet = new HashSet<IFCAnyHandle>(faces);
faceSets.Add(IFCInstanceExporter.CreateConnectedFaceSet(file, faceSet));
}
if (faceSets.Count == 0)
return false;
surface = IFCInstanceExporter.CreateFaceBasedSurfaceModel(file, faceSets);
}
if (IFCAnyHandleUtil.IsNullOrHasNoValue(surface))
return false;
BodyExporter.CreateSurfaceStyleForRepItem(exporterIFC, doc, surface, BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, element));
ISet<IFCAnyHandle> surfaceItems = new HashSet<IFCAnyHandle>();
surfaceItems.Add(surface);
ElementId catId = CategoryUtil.GetSafeCategoryId(element);
bodyRep = RepresentationUtil.CreateSurfaceRep(exporterIFC, element, catId, exporterIFC.Get3DContextHandle("Body"), surfaceItems,
exportAsFacetation, bodyRep);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
return false;
ICollection<IFCAnyHandle> boundaryRepresentations = ifcGeomInfo.GetRepresentations();
if (exportBoundaryRep && boundaryRepresentations.Count > 0)
{
HashSet<IFCAnyHandle> boundaryRepresentationSet = new HashSet<IFCAnyHandle>();
boundaryRepresentationSet.UnionWith(boundaryRepresentations);
boundaryRep = RepresentationUtil.CreateBoundaryRep(exporterIFC, element, catId, exporterIFC.Get3DContextHandle("FootPrint"), boundaryRepresentationSet,
boundaryRep);
}
return true;
}
示例5: ExportBeam
//.........这里部分代码省略.........
Transform offsetTransform = null;
// If we have a beam with a Linear location line that only has one solid geometry,
// we will try to use the ExtrusionAnalyzer to generate an extrusion with 0 or more clippings.
// This code is currently limited in that it will not process beams with openings, so we
// use other methods below if this one fails.
if (solids.Count == 1 && meshes.Count == 0 && (canExportAxis && (curve is Line)))
{
bool completelyClipped;
beamDirection = orientTrf.BasisX;
Plane beamExtrusionPlane = new Plane(orientTrf.BasisY, orientTrf.BasisZ, orientTrf.Origin);
repHnd = ExtrusionExporter.CreateExtrusionWithClipping(exporterIFC, element,
catId, solids[0], beamExtrusionPlane, beamDirection, null, out completelyClipped);
if (completelyClipped)
return;
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd))
{
// This is used by the BeamSlopeCalculator. This should probably be generated automatically by
// CreateExtrusionWithClipping.
IFCExtrusionBasis bestAxis = (Math.Abs(beamDirection[0]) > Math.Abs(beamDirection[1])) ?
IFCExtrusionBasis.BasisX : IFCExtrusionBasis.BasisY;
extrusionCreationData.Slope = GeometryUtil.GetSimpleExtrusionSlope(beamDirection, bestAxis);
ElementId materialId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(solids[0], exporterIFC, element);
if (materialId != ElementId.InvalidElementId)
materialIds.Add(materialId);
}
}
if (IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd))
{
BodyData bodyData = null;
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
if (solids.Count > 0 || meshes.Count > 0)
{
bodyData = BodyExporter.ExportBody(exporterIFC, element, catId, ElementId.InvalidElementId,
solids, meshes, bodyExporterOptions, extrusionCreationData);
}
else
{
IList<GeometryObject> geomlist = new List<GeometryObject>();
geomlist.Add(geometryElement);
bodyData = BodyExporter.ExportBody(exporterIFC, element, catId, ElementId.InvalidElementId,
geomlist, bodyExporterOptions, extrusionCreationData);
}
repHnd = bodyData.RepresentationHnd;
materialIds = bodyData.MaterialIds;
offsetTransform = bodyData.OffsetTransform;
}
if (IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd))
{
extrusionCreationData.ClearOpenings();
return;
}
IList<IFCAnyHandle> representations = new List<IFCAnyHandle>();
if (canExportAxis)
{
XYZ curveOffset = new XYZ(0, 0, 0);
if (offsetTransform != null)
curveOffset = -UnitUtil.UnscaleLength(offsetTransform.Origin);
else
{
示例6: CreateOpening
/// <summary>
/// Creates an opening from a solid.
/// </summary>
/// <param name="exporterIFC">The exporter.</param>
/// <param name="hostObjHnd">The host object handle.</param>
/// <param name="hostElement">The host element.</param>
/// <param name="insertElement">The insert element.</param>
/// <param name="openingGUID">The GUID for the opening, depending on how the opening is created.</param>
/// <param name="solid">The solid.</param>
/// <param name="scaledHostWidth">The scaled host width.</param>
/// <param name="isRecess">True if it is recess.</param>
/// <param name="extrusionCreationData">The extrusion creation data.</param>
/// <param name="setter">The placement setter.</param>
/// <param name="localWrapper">The product wrapper.</param>
/// <returns>The created opening handle.</returns>
static public IFCAnyHandle CreateOpening(ExporterIFC exporterIFC, IFCAnyHandle hostObjHnd, Element hostElement, Element insertElement, string openingGUID,
Solid solid, double scaledHostWidth, bool isRecess, IFCExtrusionCreationData extrusionCreationData, PlacementSetter setter, ProductWrapper localWrapper)
{
IFCFile file = exporterIFC.GetFile();
ElementId catId = CategoryUtil.GetSafeCategoryId(insertElement);
XYZ prepToWall;
bool isLinearWall = GetOpeningDirection(hostElement, out prepToWall);
if (isLinearWall)
{
extrusionCreationData.CustomAxis = prepToWall;
extrusionCreationData.PossibleExtrusionAxes = IFCExtrusionAxes.TryCustom;
}
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
BodyData bodyData = BodyExporter.ExportBody(exporterIFC, insertElement, catId, ElementId.InvalidElementId,
solid, bodyExporterOptions, extrusionCreationData);
IFCAnyHandle openingRepHnd = bodyData.RepresentationHnd;
if (IFCAnyHandleUtil.IsNullOrHasNoValue(openingRepHnd))
{
extrusionCreationData.ClearOpenings();
return null;
}
IList<IFCAnyHandle> representations = new List<IFCAnyHandle>();
representations.Add(openingRepHnd);
IFCAnyHandle prodRep = IFCInstanceExporter.CreateProductDefinitionShape(file, null, null, representations);
IFCAnyHandle openingPlacement = extrusionCreationData.GetLocalPlacement();
IFCAnyHandle hostObjPlacementHnd = IFCAnyHandleUtil.GetObjectPlacement(hostObjHnd);
Transform relTransform = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(openingPlacement, hostObjPlacementHnd);
openingPlacement = ExporterUtil.CreateLocalPlacement(file, hostObjPlacementHnd,
relTransform.Origin, relTransform.BasisZ, relTransform.BasisX);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
double scaledOpeningLength = extrusionCreationData.ScaledLength;
string openingObjectType = "Opening";
if (!MathUtil.IsAlmostZero(scaledHostWidth) && !MathUtil.IsAlmostZero(scaledOpeningLength))
openingObjectType = scaledOpeningLength < (scaledHostWidth - MathUtil.Eps()) ? "Recess" : "Opening";
else
openingObjectType = isRecess ? "Recess" : "Opening";
string openingName = NamingUtil.GetNameOverride(insertElement, null);
if (string.IsNullOrEmpty(openingName))
{
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(hostObjHnd))
openingName = IFCAnyHandleUtil.GetStringAttribute(hostObjHnd, "Name");
else
openingName = NamingUtil.GetNameOverride(hostElement, NamingUtil.CreateIFCObjectName(exporterIFC, hostElement));
}
IFCAnyHandle openingHnd = IFCInstanceExporter.CreateOpeningElement(file, openingGUID, ownerHistory, openingName, null,
openingObjectType, openingPlacement, prodRep, null);
if (ExporterCacheManager.ExportOptionsCache.ExportBaseQuantities)
PropertyUtil.CreateOpeningQuantities(exporterIFC, openingHnd, extrusionCreationData);
if (localWrapper != null)
{
Element elementForProperties = null;
if (GUIDUtil.IsGUIDFor(insertElement, openingGUID))
elementForProperties = insertElement;
localWrapper.AddElement(insertElement, openingHnd, setter, extrusionCreationData, true);
}
string voidGuid = GUIDUtil.CreateGUID();
IFCInstanceExporter.CreateRelVoidsElement(file, voidGuid, ownerHistory, null, null, hostObjHnd, openingHnd);
return openingHnd;
}
示例7: CreateAppropriateProductDefinitionShape
/// <summary>
/// Creates a SweptSolid, Brep, or Surface product definition shape representation, depending on the geoemtry and export version.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="categoryId">The category id.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="bodyExporterOptions">The body exporter options.</param>
/// <param name="extraReps">Extra representations (e.g. Axis, Boundary). May be null.</param>
/// <param name="extrusionCreationData">The extrusion creation data.</param>
/// <param name="allowOffsetTransform">Allows local coordinate system to be placed close to geometry.</param>
/// <returns>The handle.</returns>
/// <remarks>allowOffsetTransform should only be set to true if no other associated geometry is going to be exported. Otherwise,
/// there could be an offset between this geometry and the other, non-transformed, geometry.</remarks>
public static IFCAnyHandle CreateAppropriateProductDefinitionShape(ExporterIFC exporterIFC, Element element, ElementId categoryId,
GeometryElement geometryElement, BodyExporterOptions bodyExporterOptions, IList<IFCAnyHandle> extraReps,
IFCExtrusionCreationData extrusionCreationData, bool allowOffsetTransform)
{
BodyData bodyData;
BodyExporterOptions newBodyExporterOptions = new BodyExporterOptions(bodyExporterOptions);
newBodyExporterOptions.AllowOffsetTransform = allowOffsetTransform;
return CreateAppropriateProductDefinitionShape(exporterIFC, element, categoryId,
geometryElement, newBodyExporterOptions, extraReps, extrusionCreationData, out bodyData);
}
示例8: ExportWallBase
//.........这里部分代码省略.........
foreach (IFCAnyHandle axisItem in axisItems)
axisItemSet.Add(axisItem);
IFCAnyHandle contextOfItemsAxis = exporterIFC.Get3DContextHandle("Axis");
axisRep = RepresentationUtil.CreateShapeRepresentation(exporterIFC, element, catId, contextOfItemsAxis,
identifierOpt, representationTypeOpt, axisItemSet);
}
}
}
IList<IFCExtrusionData> cutPairOpenings = new List<IFCExtrusionData>();
if (!exportParts && exportingWallElement && exportingAxis && trimmedCurve != null)
{
bool isCompletelyClipped;
bodyRep = TryToCreateAsExtrusion(exporterIFC, wallElement, connectedWalls, solids, meshes, baseWallElevation,
catId, centerCurve, trimmedCurve, wallLCS, depth, zSpan, range, setter,
out cutPairOpenings, out isCompletelyClipped, out scaledFootprintArea, out scaledLength);
if (isCompletelyClipped)
return null;
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
exportedAsWallWithAxis = true;
}
using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData())
{
BodyData bodyData = null;
if (!exportedAsWallWithAxis)
{
extraParams.PossibleExtrusionAxes = IFCExtrusionAxes.TryZ; // only allow vertical extrusions!
extraParams.AreInnerRegionsOpenings = true;
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
// Swept solids are not natively exported as part of CV2.0.
// We have removed the UI toggle for this, so that it is by default false, but keep for possible future use.
if (ExporterCacheManager.ExportOptionsCache.ExportAdvancedSweptSolids)
bodyExporterOptions.TryToExportAsSweptSolid = true;
ElementId overrideMaterialId = ElementId.InvalidElementId;
if (exportingWallElement)
overrideMaterialId = HostObjectExporter.GetFirstLayerMaterialId(wallElement);
if (!exportParts)
{
if ((solids.Count > 0) || (meshes.Count > 0))
{
bodyRep = BodyExporter.ExportBody(exporterIFC, element, catId, overrideMaterialId,
solids, meshes, bodyExporterOptions, extraParams).RepresentationHnd;
}
else
{
IList<GeometryObject> geomElemList = new List<GeometryObject>();
geomElemList.Add(geometryElement);
bodyData = BodyExporter.ExportBody(exporterIFC, element, catId, overrideMaterialId,
geomElemList, bodyExporterOptions, extraParams);
bodyRep = bodyData.RepresentationHnd;
}
if (IFCAnyHandleUtil.IsNullOrHasNoValue(bodyRep))
{
extraParams.ClearOpenings();
return null;
}
}
示例9: ExportBody
/// <summary>
/// Exports list of geometries to IFC body representation.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="categoryId">The category id.</param>
/// <param name="geometryListIn">The geometry list.</param>
/// <param name="options">The settings for how to export the body.</param>
/// <param name="exportBodyParams">The extrusion creation data.</param>
/// <returns>The BodyData containing the handle, offset and material ids.</returns>
public static BodyData ExportBody(ExporterIFC exporterIFC,
Element element,
ElementId categoryId,
ElementId overrideMaterialId,
IList<GeometryObject> geometryList,
BodyExporterOptions options,
IFCExtrusionCreationData exportBodyParams)
{
BodyData bodyData = new BodyData();
if (geometryList.Count == 0)
return bodyData;
Document document = element.Document;
bool tryToExportAsExtrusion = options.TryToExportAsExtrusion;
bool canExportSolidModelRep = tryToExportAsExtrusion && ExporterCacheManager.ExportOptionsCache.CanExportSolidModelRep;
bool useCoarseTessellation = (ExporterCacheManager.ExportOptionsCache.LevelOfDetail < 4);
bool allowAdvancedBReps = ExporterCacheManager.ExportOptionsCache.ExportAs4 && !ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView;
// We will try to export as a swept solid if the option is set, and we are either exporting to a schema that allows it,
// or we are using a coarse tessellation, in which case we will export the swept solid as an optimzed BRep.
bool tryToExportAsSweptSolid = options.TryToExportAsSweptSolid && (allowAdvancedBReps || useCoarseTessellation);
// We will allow exporting swept solids as BReps or TriangulatedFaceSet if we are exporting to a schema before IFC4, or to a Reference View MVD,
// and we allow coarse representations. In the future, we may allow more control here.
// Note that we disable IFC4 because in IFC4, we will export it as a true swept solid instead, except for the Reference View MVD.
bool tryToExportAsSweptSolidAsTessellation = tryToExportAsSweptSolid && useCoarseTessellation && !allowAdvancedBReps;
IFCFile file = exporterIFC.GetFile();
IFCAnyHandle contextOfItems = exporterIFC.Get3DContextHandle("Body");
double eps = UnitUtil.ScaleLength(element.Document.Application.VertexTolerance);
bool allFaces = true;
foreach (GeometryObject geomObject in geometryList)
{
if (!(geomObject is Face))
{
allFaces = false;
break;
}
}
IList<IFCAnyHandle> bodyItems = new List<IFCAnyHandle>();
IList<ElementId> materialIdsForExtrusions = new List<ElementId>();
// This is a list of geometries that can be exported using the coarse facetation of the SweptSolidExporter.
IList<KeyValuePair<int, SimpleSweptSolidAnalyzer>> exportAsBRep = new List<KeyValuePair<int, SimpleSweptSolidAnalyzer>>();
IList<int> exportAsSweptSolid = new List<int>();
IList<int> exportAsExtrusion = new List<int>();
bool hasExtrusions = false;
bool hasSweptSolids = false;
bool hasSweptSolidsAsBReps = false;
ShapeRepresentationType hasRepresentationType = ShapeRepresentationType.Undefined;
BoundingBoxXYZ bbox = GeometryUtil.GetBBoxOfGeometries(geometryList);
XYZ unscaledTrfOrig = new XYZ();
int numItems = geometryList.Count;
bool tryExtrusionAnalyzer = tryToExportAsExtrusion && (options.ExtrusionLocalCoordinateSystem != null) && (numItems == 1) && (geometryList[0] is Solid);
bool supportOffsetTransformForExtrusions = !(tryExtrusionAnalyzer || tryToExportAsSweptSolidAsTessellation);
bool useOffsetTransformForExtrusions = (options.AllowOffsetTransform && supportOffsetTransformForExtrusions && (exportBodyParams != null));
using (IFCTransaction tr = new IFCTransaction(file))
{
// generate "bottom corner" of bbox; create new local placement if passed in.
// need to transform, but not scale, this point to make it the new origin.
using (TransformSetter transformSetter = TransformSetter.Create())
{
if (useOffsetTransformForExtrusions)
bodyData.OffsetTransform = transformSetter.InitializeFromBoundingBox(exporterIFC, bbox, exportBodyParams, out unscaledTrfOrig);
// If we passed in an ExtrusionLocalCoordinateSystem, and we have 1 Solid, we will try to create an extrusion using the ExtrusionAnalyzer.
// If we succeed, we will skip the rest of the routine, otherwise we will try with the backup extrusion method.
// This doesn't yet create fallback information for solid models that are hybrid extrusions and BReps.
if (tryToExportAsExtrusion)
{
if (tryExtrusionAnalyzer)
{
using (IFCTransaction extrusionTransaction = new IFCTransaction(file))
{
Plane extrusionPlane = new Plane(
options.ExtrusionLocalCoordinateSystem.BasisY,
options.ExtrusionLocalCoordinateSystem.BasisZ,
options.ExtrusionLocalCoordinateSystem.Origin);
XYZ extrusionDirection = options.ExtrusionLocalCoordinateSystem.BasisX;
bool completelyClipped;
HandleAndData extrusionData = ExtrusionExporter.CreateExtrusionWithClippingAndProperties(exporterIFC, element,
//.........这里部分代码省略.........
示例10: ExportBodyAsBRep
// NOTE: the useMappedGeometriesIfPossible and useGroupsIfPossible options are experimental and do not yet work well.
// In shipped code, these are always false, and should be kept false until API support routines are proved to be reliable.
private static BodyData ExportBodyAsBRep(ExporterIFC exporterIFC, IList<GeometryObject> splitGeometryList,
IList<KeyValuePair<int, SimpleSweptSolidAnalyzer>> exportAsBRep, IList<IFCAnyHandle> bodyItems,
Element element, ElementId categoryId, ElementId overrideMaterialId, IFCAnyHandle contextOfItems, double eps,
BodyExporterOptions options, BodyData bodyDataIn)
{
bool exportAsBReps = true;
bool hasTriangulatedGeometry = false;
bool hasAdvancedBrepGeometry = false;
IFCFile file = exporterIFC.GetFile();
Document document = element.Document;
// Can't use the optimization functions below if we already have partially populated our body items with extrusions.
int numExtrusions = bodyItems.Count;
bool useMappedGeometriesIfPossible = options.UseMappedGeometriesIfPossible && (numExtrusions != 0);
bool useGroupsIfPossible = options.UseGroupsIfPossible && (numExtrusions != 0);
IList<HashSet<IFCAnyHandle>> currentFaceHashSetList = new List<HashSet<IFCAnyHandle>>();
IList<int> startIndexForObject = new List<int>();
BodyData bodyData = new BodyData(bodyDataIn);
IDictionary<SolidMetrics, HashSet<Solid>> solidMappingGroups = null;
IList<KeyValuePair<int, Transform>> solidMappings = null;
IList<ElementId> materialIds = new List<ElementId>();
// This should currently be always false in shipped code.
if (useMappedGeometriesIfPossible)
{
IList<GeometryObject> newGeometryList = null;
useMappedGeometriesIfPossible = GatherMappedGeometryGroupings(splitGeometryList, out newGeometryList, out solidMappingGroups, out solidMappings);
if (useMappedGeometriesIfPossible && (newGeometryList != null))
splitGeometryList = newGeometryList;
}
BodyGroupKey groupKey = null;
BodyGroupData groupData = null;
// This should currently be always false in shipped code.
if (useGroupsIfPossible)
{
BodyData bodyDataOut = null;
useGroupsIfPossible = ProcessGroupMembership(exporterIFC, file, element, categoryId, contextOfItems, splitGeometryList, bodyData,
out groupKey, out groupData, out bodyDataOut);
if (bodyDataOut != null)
return bodyDataOut;
if (useGroupsIfPossible)
useMappedGeometriesIfPossible = true;
}
bool isCoarse = (options.TessellationLevel == BodyExporterOptions.BodyTessellationLevel.Coarse);
int numBRepsToExport = exportAsBRep.Count;
bool selectiveBRepExport = (numBRepsToExport > 0);
int numGeoms = selectiveBRepExport ? numBRepsToExport : splitGeometryList.Count;
bool canExportAsAdvancedGeometry = ExporterCacheManager.ExportOptionsCache.ExportAs4DesignTransferView;
bool canExportAsTessellatedFaceSet = ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView;
// We will cycle through all of the geometries one at a time, doing the best export we can for each.
for (int index = 0; index < numGeoms; index++)
{
int brepIndex = selectiveBRepExport ? exportAsBRep[index].Key : index;
SimpleSweptSolidAnalyzer currAnalyzer = selectiveBRepExport ? exportAsBRep[index].Value : null;
GeometryObject geomObject = selectiveBRepExport ? splitGeometryList[brepIndex] : splitGeometryList[index];
// A simple test to see if the geometry is a valid solid. This will save a lot of time in CanCreateClosedShell later.
if (exportAsBReps && (geomObject is Solid))
{
try
{
// We don't care what the value is here. What we care about is whether or not it can be calculated. If it can't be calculated,
// it is probably not a valid solid.
double volume = (geomObject as Solid).Volume;
// Current code should already prevent 0 volume solids from coming here, but may as well play it safe.
if (volume <= MathUtil.Eps())
exportAsBReps = false;
}
catch
{
exportAsBReps = false;
}
}
startIndexForObject.Add(currentFaceHashSetList.Count);
ElementId materialId = SetBestMaterialIdInExporter(geomObject, element, overrideMaterialId, exporterIFC);
materialIds.Add(materialId);
bodyData.AddMaterial(materialId);
bool alreadyExported = false;
// First, see if this could be represented as a simple swept solid.
if (exportAsBReps && (currAnalyzer != null))
{
SweptSolidExporter sweptSolidExporter = SweptSolidExporter.Create(exporterIFC, element, currAnalyzer, geomObject);
HashSet<IFCAnyHandle> facetHnds = (sweptSolidExporter != null) ? sweptSolidExporter.Facets : null;
if (facetHnds != null && facetHnds.Count != 0)
//.........这里部分代码省略.........
示例11: ExportBodyAsSolid
private static bool ExportBodyAsSolid(ExporterIFC exporterIFC, Element element, BodyExporterOptions options,
IList<HashSet<IFCAnyHandle>> currentFaceHashSetList, GeometryObject geomObject)
{
IFCFile file = exporterIFC.GetFile();
Document document = element.Document;
bool exportedAsSolid = false;
try
{
if (geomObject is Solid)
{
Solid solid = geomObject as Solid;
exportedAsSolid = ExportPlanarBodyIfPossible(exporterIFC, solid, currentFaceHashSetList);
if (exportedAsSolid)
return exportedAsSolid;
SolidOrShellTessellationControls tessellationControlsOriginal = options.TessellationControls;
SolidOrShellTessellationControls tessellationControls = ExporterUtil.GetTessellationControl(element, tessellationControlsOriginal);
TriangulatedSolidOrShell solidFacetation = null;
// We will make (up to) 2 attempts. First we will use tessellationControls, and then we will try tessellationControlsOriginal, but only
// if they are different.
for (int ii = 0; ii < 2; ii++)
{
if (ii == 1 && tessellationControls.Equals(tessellationControlsOriginal))
break;
try
{
SolidOrShellTessellationControls tessellationControlsToUse = (ii == 0) ? tessellationControls : tessellationControlsOriginal;
solidFacetation = SolidUtils.TessellateSolidOrShell(solid, tessellationControlsToUse);
break;
}
catch
{
solidFacetation = null;
}
}
// Only handle one solid or shell.
if (solidFacetation != null && solidFacetation.ShellComponentCount == 1)
{
TriangulatedShellComponent component = solidFacetation.GetShellComponent(0);
int numberOfTriangles = component.TriangleCount;
int numberOfVertices = component.VertexCount;
// We are going to limit the number of triangles to 50,000. This is a arbitrary number
// that should prevent the solid faceter from creating too many extra triangles to sew the surfaces.
// We may evaluate this number over time.
if ((numberOfTriangles > 0 && numberOfVertices > 0) && (numberOfTriangles < 50000))
{
IList<IFCAnyHandle> vertexHandles = new List<IFCAnyHandle>();
HashSet<IFCAnyHandle> currentFaceSet = new HashSet<IFCAnyHandle>();
if (ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView)
{
List<List<double>> coordList = new List<List<double>>();
// create list of vertices first.
for (int i = 0; i < numberOfVertices; i++)
{
List<double> vertCoord = new List<double>();
XYZ vertex = component.GetVertex(i);
XYZ vertexScaled = ExporterIFCUtils.TransformAndScalePoint(exporterIFC, vertex);
vertCoord.Add(vertexScaled.X);
vertCoord.Add(vertexScaled.Y);
vertCoord.Add(vertexScaled.Z);
coordList.Add(vertCoord);
}
}
else
{
// create list of vertices first.
for (int ii = 0; ii < numberOfVertices; ii++)
{
XYZ vertex = component.GetVertex(ii);
XYZ vertexScaled = ExporterIFCUtils.TransformAndScalePoint(exporterIFC, vertex);
IFCAnyHandle vertexHandle = ExporterUtil.CreateCartesianPoint(file, vertexScaled);
vertexHandles.Add(vertexHandle);
}
if (!ExportPlanarFacetsIfPossible(file, component, vertexHandles, currentFaceSet))
{
// Export all of the triangles instead.
for (int ii = 0; ii < numberOfTriangles; ii++)
{
TriangleInShellComponent triangle = component.GetTriangle(ii);
IList<IFCAnyHandle> vertices = new List<IFCAnyHandle>();
vertices.Add(vertexHandles[triangle.VertexIndex0]);
vertices.Add(vertexHandles[triangle.VertexIndex1]);
vertices.Add(vertexHandles[triangle.VertexIndex2]);
IFCAnyHandle face = CreateFaceFromVertexList(file, vertices);
currentFaceSet.Add(face);
}
}
//.........这里部分代码省略.........
示例12: ExportSurfaceAsTriangulatedFaceSet
/// <summary>
/// Return a triangulated face set from the list of faces
/// </summary>
/// <param name="exporterIFC">exporter IFC</param>
/// <param name="element">the element</param>
/// <param name="options">the body export options</param>
/// <param name="geomObject">the geometry object</param>
/// <returns>returns the handle</returns>
private static IFCAnyHandle ExportSurfaceAsTriangulatedFaceSet(ExporterIFC exporterIFC, Element element, BodyExporterOptions options,
GeometryObject geomObject)
{
IFCFile file = exporterIFC.GetFile();
List<List<XYZ>> triangleList = new List<List<XYZ>>();
if (geomObject is Solid)
{
Solid geomSolid = geomObject as Solid;
FaceArray faces = geomSolid.Faces;
foreach (Face face in faces)
{
double tessellationLevel = options.TessellationControls.LevelOfDetail;
Mesh faceTriangulation = face.Triangulate(tessellationLevel);
for (int i = 0; i < faceTriangulation.NumTriangles; ++i)
{
List<XYZ> triangleVertices = new List<XYZ>();
MeshTriangle triangle = faceTriangulation.get_Triangle(i);
for (int tri = 0; tri < 3; ++tri)
{
XYZ vert = triangle.get_Vertex(tri);
triangleVertices.Add(vert);
}
triangleList.Add(triangleVertices);
}
}
}
else if (geomObject is Mesh)
{
Mesh geomMesh = geomObject as Mesh;
for (int i = 0; i < geomMesh.NumTriangles; ++i)
{
List<XYZ> triangleVertices = new List<XYZ>();
MeshTriangle triangle = geomMesh.get_Triangle(i);
for (int tri = 0; tri < 3; ++tri)
{
XYZ vert = triangle.get_Vertex(tri);
triangleVertices.Add(vert);
}
triangleList.Add(triangleVertices);
}
}
return GeometryUtil.GetIndexedTriangles(file, triangleList);
}
示例13: ExportBodyAsTriangulatedFaceSet
/// <summary>
/// Export Geometry in IFC4 Triangulated tessellation
/// </summary>
/// <param name="exporterIFC">the exporter</param>
/// <param name="element">the element</param>
/// <param name="options">the options</param>
/// <param name="geomObject">geometry objects</param>
/// <returns>returns a handle</returns>
public static IFCAnyHandle ExportBodyAsTriangulatedFaceSet(ExporterIFC exporterIFC, Element element, BodyExporterOptions options,
GeometryObject geomObject)
{
IFCFile file = exporterIFC.GetFile();
Document document = element.Document;
IFCAnyHandle triangulatedBody = null;
if (geomObject is Solid)
{
try
{
Solid solid = geomObject as Solid;
SolidOrShellTessellationControls tessellationControls = options.TessellationControls;
// Convert integer level of detail into a 0 to 1 scale.
tessellationControls.LevelOfDetail = ((double)ExporterCacheManager.ExportOptionsCache.LevelOfDetail) / 4.0;
TriangulatedSolidOrShell solidFacetation =
SolidUtils.TessellateSolidOrShell(solid, tessellationControls);
// Only handle one solid or shell.
if (solidFacetation.ShellComponentCount == 1)
{
TriangulatedShellComponent component = solidFacetation.GetShellComponent(0);
int numberOfTriangles = component.TriangleCount;
int numberOfVertices = component.VertexCount;
// We are going to limit the number of triangles to 50,000. This is a arbitrary number
// that should prevent the solid faceter from creating too many extra triangles to sew the surfaces.
// We may evaluate this number over time.
if ((numberOfTriangles > 0 && numberOfVertices > 0) && (numberOfTriangles < 50000))
{
IList<IList<double>> coordList = new List<IList<double>>();
IList<IList<int>> coordIdx = new List<IList<int>>();
// create list of vertices first.
for (int i = 0; i < numberOfVertices; i++)
{
List<double> vertCoord = new List<double>();
XYZ vertex = component.GetVertex(i);
XYZ vertexScaled = ExporterIFCUtils.TransformAndScalePoint(exporterIFC, vertex);
vertCoord.Add(vertexScaled.X);
vertCoord.Add(vertexScaled.Y);
vertCoord.Add(vertexScaled.Z);
coordList.Add(vertCoord);
}
// Create the entity IfcCartesianPointList3D from the List of List<double> and assign it to attribute Coordinates of IfcTriangulatedFaceSet
// Export all of the triangles
for (int i = 0; i < numberOfTriangles; i++)
{
List<int> vertIdx = new List<int>();
TriangleInShellComponent triangle = component.GetTriangle(i);
vertIdx.Add(triangle.VertexIndex0 + 1); // IFC uses index that starts with 1 instead of 0 (following similar standard in X3D)
vertIdx.Add(triangle.VertexIndex1 + 1);
vertIdx.Add(triangle.VertexIndex2 + 1);
coordIdx.Add(vertIdx);
}
// Create attribute CoordIndex from the List of List<int> of the IfcTriangulatedFaceSet
IFCAnyHandle coordPointLists = IFCAnyHandleUtil.CreateInstance(file, IFCEntityType.IfcCartesianPointList3D);
IFCAnyHandleUtil.SetAttribute(coordPointLists, "CoordList", coordList, 1, null, 3, 3);
triangulatedBody = IFCAnyHandleUtil.CreateInstance(file, IFCEntityType.IfcTriangulatedFaceSet);
IFCAnyHandleUtil.SetAttribute(triangulatedBody, "Coordinates", coordPointLists);
IFCAnyHandleUtil.SetAttribute(triangulatedBody, "CoordIndex", coordIdx, 1, null, 3, 3);
}
}
}
catch
{
// Failed! Likely because of the tessellation failed. Try to create from the faceset instead
return ExportSurfaceAsTriangulatedFaceSet(exporterIFC, element, options, geomObject);
}
}
else
{
// It is not from Solid, so we will use the faces to export. It works for Surface export too
triangulatedBody = ExportSurfaceAsTriangulatedFaceSet(exporterIFC, element, options, geomObject);
}
return triangulatedBody;
}
示例14: ExportBodyAsAdvancedBrep
/// <summary>
/// Returns a handle for creation of an AdvancedBrep with AdvancedFace and assigns it to the file
/// </summary>
/// <param name="exporterIFC">exporter IFC</param>
/// <param name="element">the element</param>
/// <param name="options">exporter option</param>
/// <param name="geomObject">the geometry object</param>
/// <returns>the handle</returns>
public static IFCAnyHandle ExportBodyAsAdvancedBrep(ExporterIFC exporterIFC, Element element, BodyExporterOptions options,
GeometryObject geomObject)
{
IFCFile file = exporterIFC.GetFile();
Document document = element.Document;
// IFCFuzzyXYZ will be used in this routine to compare 2 XYZs, we consider two points are the same if their distance
// is within this tolerance
IFCFuzzyXYZ.IFCFuzzyXYZEpsilon = document.Application.VertexTolerance;
IFCAnyHandle advancedBrep = null;
using (IFCTransaction tr = new IFCTransaction(file))
{
try
{
if (!(geomObject is Solid))
{
return null;
}
HashSet<IFCAnyHandle> cfsFaces = new HashSet<IFCAnyHandle>();
Solid geomSolid = geomObject as Solid;
FaceArray faces = geomSolid.Faces;
// Check for supported curve and face types before creating an advanced BRep.
IList<KeyValuePair<Edge, Curve>> edgesAndCurves = new List<KeyValuePair<Edge, Curve>>();
foreach (Edge edge in geomSolid.Edges)
{
Curve currCurve = edge.AsCurve();
if (currCurve == null)
return null;
bool isValidCurve = !(currCurve is CylindricalHelix);
if (!isValidCurve)
return null;
// based on the definition of IfcAdvancedBrep in IFC 4 specification, an IfcAdvancedBrep must contain a closed shell, so we
// have a test to reject all open shells here.
// we check that geomSolid is an actual solid and not an open shell by verifying that each edge is shared by exactly 2 faces.
for (int ii = 0; ii < 2; ii++)
{
if (edge.GetFace(ii) == null)
return null;
}
edgesAndCurves.Add(new KeyValuePair<Edge, Curve>(edge, currCurve));
}
foreach (Face face in geomSolid.Faces)
{
bool isValidFace = (face is PlanarFace) || (face is CylindricalFace) || (face is RuledFace) || (face is HermiteFace) || (face is RevolvedFace) || (face is ConicalFace);
if (!isValidFace)
{
return null;
}
}
Dictionary<Face, IList<Edge>> faceToEdges = new Dictionary<Face, IList<Edge>>();
Dictionary<Edge, IFCAnyHandle> edgeToIfcEdgeCurve = new Dictionary<Edge, IFCAnyHandle>();
// A map of already created IfcCartesianPoints, to avoid duplication. This is used for vertex points and other geometry in the BRep.
// We do not share IfcCartesianPoints across BReps.
IDictionary<IFCFuzzyXYZ, IFCAnyHandle> cartesianPoints = new SortedDictionary<IFCFuzzyXYZ, IFCAnyHandle>();
// A map of already created IfcVertexPoints, to avoid duplication.
IDictionary<IFCFuzzyXYZ, IFCAnyHandle> vertices = new SortedDictionary<IFCFuzzyXYZ, IFCAnyHandle>();
// First phase: get all the vertices:
foreach (KeyValuePair<Edge, Curve> edgeAndCurve in edgesAndCurves)
{
Edge edge = edgeAndCurve.Key;
Curve currCurve = edgeAndCurve.Value;
XYZ startPoint = currCurve.GetEndPoint(0);
XYZ endPoint = currCurve.GetEndPoint(1);
IFCFuzzyXYZ fuzzyStartPoint = new IFCFuzzyXYZ(startPoint);
IFCFuzzyXYZ fuzzyEndPoint = new IFCFuzzyXYZ(endPoint);
IFCAnyHandle edgeStart = null;
IFCAnyHandle edgeEnd = null;
if (vertices.ContainsKey(fuzzyStartPoint))
{
edgeStart = vertices[fuzzyStartPoint];
}
else
{
IFCAnyHandle edgeStartCP = GeometryUtil.XYZtoIfcCartesianPoint(exporterIFC, currCurve.GetEndPoint(0), cartesianPoints);
edgeStart = IFCInstanceExporter.CreateVertexPoint(file, edgeStartCP);
vertices.Add(fuzzyStartPoint, edgeStart);
}
if (vertices.ContainsKey(fuzzyEndPoint))
//.........这里部分代码省略.........
示例15: ExportGenericSlab
/// <summary>
/// Exports a generic element as an IfcSlab.</summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="floor">The floor element.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="ifcEnumType">The string value represents the IFC type.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <returns>True if the floor is exported successfully, false otherwise.</returns>
public static void ExportGenericSlab(ExporterIFC exporterIFC, Element slabElement, GeometryElement geometryElement, string ifcEnumType,
ProductWrapper productWrapper)
{
if (geometryElement == null)
return;
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
using (IFCTransformSetter transformSetter = IFCTransformSetter.Create())
{
using (PlacementSetter placementSetter = PlacementSetter.Create(exporterIFC, slabElement))
{
using (IFCExtrusionCreationData ecData = new IFCExtrusionCreationData())
{
bool exportParts = PartExporter.CanExportParts(slabElement);
IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle();
IFCAnyHandle localPlacement = placementSetter.LocalPlacement;
IFCAnyHandle prodDefHnd = null;
bool isBRepSlabHnd = false;
if (!exportParts)
{
ecData.SetLocalPlacement(localPlacement);
ElementId catId = CategoryUtil.GetSafeCategoryId(slabElement);
BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true);
bodyExporterOptions.TessellationLevel = BodyExporter.GetTessellationLevel();
BodyData bodyData;
prodDefHnd = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC,
slabElement, catId, geometryElement, bodyExporterOptions, null, ecData, out bodyData);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(prodDefHnd))
{
ecData.ClearOpenings();
return;
}
isBRepSlabHnd = (bodyData.ShapeRepresentationType == ShapeRepresentationType.Brep);
}
// Create the slab from either the extrusion or the BRep information.
string ifcGUID = GUIDUtil.CreateGUID(slabElement);
string entityType = IFCValidateEntry.GetValidIFCType<IFCSlabType>(slabElement, ifcEnumType, "FLOOR");
string ifcName = NamingUtil.GetNameOverride(slabElement, NamingUtil.GetIFCName(slabElement));
string ifcDescription = NamingUtil.GetDescriptionOverride(slabElement, null);
string ifcObjectType = NamingUtil.GetObjectTypeOverride(slabElement, exporterIFC.GetFamilyName());
string ifcTag = NamingUtil.GetTagOverride(slabElement, NamingUtil.CreateIFCElementId(slabElement));
IFCAnyHandle slabHnd = IFCInstanceExporter.CreateSlab(file, ifcGUID, ownerHistory, ifcName,
ifcDescription, ifcObjectType, localPlacement, exportParts ? null : prodDefHnd,
ifcTag, entityType);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(slabHnd))
return;
if (exportParts)
PartExporter.ExportHostPart(exporterIFC, slabElement, slabHnd, productWrapper, placementSetter, localPlacement, null);
productWrapper.AddElement(slabElement, slabHnd, placementSetter, ecData, true);
if (!exportParts)
{
if (slabElement is HostObject)
{
HostObject hostObject = slabElement as HostObject;
HostObjectExporter.ExportHostObjectMaterials(exporterIFC, hostObject, slabHnd,
geometryElement, productWrapper, ElementId.InvalidElementId, Toolkit.IFCLayerSetDirection.Axis3, isBRepSlabHnd);
}
else if (slabElement is FamilyInstance)
{
ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, slabElement);
Document doc = slabElement.Document;
CategoryUtil.CreateMaterialAssociation(exporterIFC, slabHnd, matId);
}
OpeningUtil.CreateOpeningsIfNecessary(slabHnd, slabElement, ecData, null,
exporterIFC, ecData.GetLocalPlacement(), placementSetter, productWrapper);
}
}
}
tr.Commit();
return;
}
}
}