-
Notifications
You must be signed in to change notification settings - Fork 179
Open
Description
I have problem with finding how to get IfcMappedItem geometry like beam, door, window, column ...etc
else if (item is IIfcMappedItem mappedItem)
{
geometryTypes.Add("MappedItem");
// Add empty entries for the MappedItem itself to keep lists synchronized
// We add these now because this function MUST add an entry to every list.
basePlanes.Add(elementPlane);
startPoints.Add(elementPlane.Origin);
profileCurves.Add(null);
extrusionDepths.Add(0);
extrusionDirections.Add(Vector3d.Zero);
polylines.Add(null, path); // *** FIX: Added 'path' argument for DataTree
boundingBoxCorners.Add(Point3d.Origin);
boundingBoxDimensions.Add(Vector3d.Zero);
rectangleXDims.Add(0);
rectangleYDims.Add(0);
log.Add("Found MappedItem, now investigating its source representation...");
// --- NEW LOGGING: Check if the source is valid ---
if (mappedItem.MappingSource == null || mappedItem.MappingSource.MappedRepresentation == null || !mappedItem.MappingSource.MappedRepresentation.Items.Any())
{
log.Add("!!! CRITICAL: MappedItem source or its geometry items are null or empty. Cannot create geometry.");
return;
}
log.Add($"... Source is valid, containing {mappedItem.MappingSource.MappedRepresentation.Items.Count()} items.");
// Get the mapping transformation
Transform mappingTransform = Transform.Identity;
if (mappedItem.MappingTarget is IIfcCartesianTransformationOperator3D transform3D)
{
mappingTransform = ConvertCartesianTransformation3D(transform3D, scale);
log.Add($"... Calculated 3D mapping transform. IsIdentity: {mappingTransform.IsIdentity}");
}
else if (mappedItem.MappingTarget is IIfcCartesianTransformationOperator2D transform2D)
{
mappingTransform = ConvertCartesianTransformation2D(transform2D, scale);
log.Add($"... Calculated 2D mapping transform. IsIdentity: {mappingTransform.IsIdentity}");
}
// Store the original collections' counts to apply transformation to newly added items
int originalProfileCount = profileCurves.Count;
int originalPolylineBranches = polylines.BranchCount; // Corrected to BranchCount
// Process the source geometry that is being instanced
foreach (var mappedItemRep in mappedItem.MappingSource.MappedRepresentation.Items)
{
// --- NEW LOGGING: What is the type of the source geometry? ---
log.Add($" -> Processing source item of type: {mappedItemRep.GetType().Name}");
ExtractGeometryData((IIfcGeometricRepresentationItem)mappedItemRep, scale, element, path,
log, elementIds, geometryTypes, profileCurves, extrusionDepths,
extrusionDirections, basePlanes, startPoints, polylines,
boundingBoxCorners, boundingBoxDimensions, rectangleXDims, rectangleYDims);
}
// --- NEW LOGGING: Check if any geometry was actually created ---
int newProfiles = profileCurves.Count - originalProfileCount;
int newPolylineBranches = polylines.BranchCount - originalPolylineBranches;
log.Add($"... Finished processing source. Found {newProfiles} new profiles and {newPolylineBranches} new polyline branches.");
// Apply mapping transformation to newly added geometry if any was created
if (newProfiles > 0 || newPolylineBranches > 0)
{
ApplyTransformationToNewGeometry(mappingTransform, originalProfileCount, originalPolylineBranches,
profileCurves, polylines, basePlanes, startPoints, boundingBoxCorners);
log.Add("... Successfully applied mapping transformation to new geometry.");
}
else
{
log.Add("... No new geometry was created from the source, so no transformation was applied.");
}
}Metadata
Metadata
Assignees
Labels
No labels