private bool ShapeRepresentationTypesComply( out string errStr) { string repType = RepresentationType.GetValueOrDefault(); string msg = ""; bool found = true; XbimSet <IfcRepresentationItem> items = Items; int count = 0; //split case statements to overcome bug in db4o, which cannot traverse more than 5 deep in a case statement switch (repType) { case "Curve2D": count = items.OfType <IfcCurve>().Where(i => i.Dim == 2).Count(); msg = "RepresentationType = Curve2D, but Items contains shapes that are not Curve"; break; case "Annotation2D": count = items.Where( i => i is IfcPoint || i is IfcCurve || i is IfcGeometricCurveSet || i is IfcAnnotationFillArea || i is IfcDefinedSymbol || i is IfcTextLiteral || i is IfcDraughtingCallOut).Count(); msg = "RepresentationType = Annotation2D, but Items contains shapes that are not GeometricCurveSet, Curve, or AnnotationFillArea, DefinedSymbol, TextLiteral or DraughtingCallOut"; break; case "GeometricSet": count = items.Where(i => i is IfcGeometricSet || i is IfcPoint || i is IfcCurve || i is IfcSurface). Count(); msg = "RepresentationType = GeometricSet, but Items contains shapes that are not Point, Curve, or Surface"; break; case "GeometricCurveSet": count = items.Where( i => i is IfcGeometricCurveSet || i is IfcPoint || i is IfcCurve || i is IfcGeometricSet). Count(); msg = "RepresentationType = GeometricCurveSet, but Items contains shapes that are not Point, Curve, or GeometricSet"; foreach (IfcRepresentationItem item in items) { IfcGeometricSet gs = item as IfcGeometricSet; if (gs != null) { if (gs.Elements.OfType <IfcSurface>().Count() > 0) { count--; } } } break; case "SurfaceModel": count = items.Where( i => i is IfcShellBasedSurfaceModel || i is IfcFaceBasedSurfaceModel || i is IfcFacetedBrep || i is IfcFacetedBrepWithVoids).Count(); msg = "RepresentationType = SurfaceModel, but Items contains shapes that are not ShellBasedSurfaceModel, FaceBasedSurfaceModel, FacetedBrepWithVoids or FacetedBrep"; break; default: found = false; break; } if (!found) { found = true; switch (repType) { case "SolidModel": count = items.OfType <IfcSolidModel>().Count(); msg = "RepresentationType = SolidModel, but Items contains shapes that are not SolidModel"; break; case "SweptSolid": count = items.OfType <IfcSweptAreaSolid>().Count(); msg = "RepresentationType = SweptSolid, but Items contains shapes that are not SweptAreaSolid"; break; case "CSG": count = items.OfType <IfcBooleanResult>().Count(); msg = "RepresentationType = CSG, but Items contains shapes that are not BooleanResult"; break; case "Clipping": count = items.OfType <IfcBooleanClippingResult>().Count(); msg = "RepresentationType = Clipping, but Items contains shapes that are not BooleanClippingResult"; break; case "AdvancedSweptSolid": count = items.Where(i => i is IfcSurfaceCurveSweptAreaSolid || i is IfcSweptDiskSolid).Count(); msg = "RepresentationType = AdvancedSweptSolid, but Items contains shapes that are not SurfaceCurveSweptAreaSolid or SweptDiskSolid"; break; default: found = false; break; } } if (!found) { found = true; switch (repType) { case "Brep": count = items.Where(i => i is IfcFacetedBrep || i is IfcFacetedBrepWithVoids).Count(); msg = "RepresentationType = Brep, but Items contains shapes that are not FacetedBrep or FacetedBrepWithVoids"; break; case "BoundingBox": count = items.OfType <IfcBoundingBox>().Count(); msg = "RepresentationType = BoundingBox, but Items contains shapes that are not BoundingBox"; if (items.Count > 1) { count = 0; } break; case "SectionedSpine": count = items.OfType <IfcSectionedSpine>().Count(); msg = "RepresentationType = SectionedSpine, but Items contains shapes that are not SectionedSpine"; break; case "MappedRepresentation": count = items.OfType <IfcMappedItem>().Count(); msg = "RepresentationType = MappedRepresentation, but Items contains shapes that are not MappedItem"; break; default: found = false; break; } } if (!found) { errStr = string.Format("Illegal or unknown Representation Identifier, {0}", repType); return(false); } if (count != items.Count) { errStr = msg; return(false); } else { errStr = ""; return(true); } }