private string ReverseDoorStyleOperation(string orig)
 {
     if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(orig, "DoubleDoorSingleSwingOppositeLeft"))
     {
         return("DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_RIGHT");
     }
     else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(orig, "DoubleDoorSingleSwingOppositeRight"))
     {
         return("DOUBLE_DOOR_SINGLE_SWING_OPPOSITE_LEFT");
     }
     else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(orig, "DoubleSwingLeft"))
     {
         return("DOUBLE_SWING_RIGHT");
     }
     else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(orig, "DoubleSwingRight"))
     {
         return("DOUBLE_SWING_LEFT");
     }
     else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(orig, "FoldingToLeft"))
     {
         return("FOLDING_TO_RIGHT");
     }
     else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(orig, "FoldingToRight"))
     {
         return("FOLDING_TO_LEFT");
     }
     else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(orig, "SingleSwingLeft"))
     {
         return("SINGLE_SWING_RIGHT");
     }
     else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(orig, "SingleSwingRight"))
     {
         return("SINGLE_SWING_LEFT");
     }
     else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(orig, "SlidingToLeft"))
     {
         return("SLIDING_TO_RIGHT");
     }
     else if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(orig, "SlidingToRight"))
     {
         return("SLIDING_TO_LEFT");
     }
     else
     {
         return(orig);
     }
 }
        private void CalculateDoorWindowInformation(ExporterIFC exporterIFC, FamilyInstance famInst,
                                                    ElementId overrideLevelId, Transform trf)
        {
            IFCFile file = exporterIFC.GetFile();

            if (ExportingDoor)
            {
                string doorOperationType = null;

                Element doorType = famInst.Document.GetElement(famInst.GetTypeId());
                if (doorType != null)
                {
                    // Look at the "Operation" override first, then the built-in parameter.
                    ParameterUtil.GetStringValueFromElementOrSymbol(doorType, "Operation", out doorOperationType);
                    if (!string.IsNullOrWhiteSpace(doorOperationType))
                    {
                        ParameterUtil.GetStringValueFromElement(doorType, BuiltInParameter.DOOR_OPERATION_TYPE, out doorOperationType);
                    }
                }

                DoorOperationTypeString = "NOTDEFINED";
                if (!string.IsNullOrWhiteSpace(doorOperationType))
                {
                    Type enumType = null;
                    if (ExporterCacheManager.ExportOptionsCache.ExportAs4)
                    {
                        enumType = typeof(Toolkit.IFC4.IFCDoorStyleOperation);
                    }
                    else
                    {
                        enumType = typeof(Toolkit.IFCDoorStyleOperation);
                    }

                    foreach (Enum ifcDoorStyleOperation in Enum.GetValues(enumType))
                    {
                        string enumAsString = ifcDoorStyleOperation.ToString();
                        if (NamingUtil.IsEqualIgnoringCaseSpacesAndUnderscores(enumAsString, doorOperationType))
                        {
                            DoorOperationTypeString = enumAsString;
                            break;
                        }
                    }
                }

                if (DoorOperationTypeString == "NOTDEFINED")
                {
                    // We are going to try to guess the hinge placement.
                    DoorOperationTypeString = CalculateDoorOperationStyle(famInst);
                }

                if (FlippedX ^ FlippedY)
                {
                    DoorOperationTypeString = ReverseDoorStyleOperation(DoorOperationTypeString);
                }

                if (String.Compare(DoorOperationTypeString, "USERDEFINED", true) == 0)
                {
                    string userDefinedOperationType;
                    ParameterUtil.GetStringValueFromElementOrSymbol(doorType, "UserDefinedOperationType", out userDefinedOperationType);
                    if (!string.IsNullOrEmpty(userDefinedOperationType))
                    {
                        UserDefinedOperationType = userDefinedOperationType;
                    }
                    else
                    {
                        DoorOperationTypeString = "NOTDEFINED";   //re-set to NotDefined if operation type is set to UserDefined but the userDefinedOperationType parameter is empty!
                    }
                }
            }

            if (HasRealWallHost)
            {
                // do hingeside calculation
                Wall wall = HostObject as Wall;
                PosHingeSide = true;

                BoundingBoxXYZ  famBBox     = null;
                Options         options     = GeometryUtil.GetIFCExportGeometryOptions();
                GeometryElement geomElement = famInst.GetOriginalGeometry(options);
                if (geomElement != null)
                {
                    famBBox = geomElement.GetBoundingBox();
                }

                if (famBBox != null)
                {
                    XYZ bboxCtr = trf.OfPoint((famBBox.Min + famBBox.Max) / 2.0);

                    Curve curve = WallExporter.GetWallAxis(wall);

                    XYZ wallZDir = WallExporter.GetWallHeightDirection(wall);

                    // famInst.HostParameter will fail if FamilyPlacementType is WorkPlaneBased, regardless of whether or not the reported host is a Wall.
                    // In this case, just use the start parameter of the curve.
                    bool   hasHostParameter = famInst.Symbol.Family.FamilyPlacementType != FamilyPlacementType.WorkPlaneBased;
                    double param            = hasHostParameter ? famInst.HostParameter : curve.GetEndParameter(0);

                    Transform wallTrf  = curve.ComputeDerivatives(param, false);
                    XYZ       wallOrig = wallTrf.Origin;
                    XYZ       wallXDir = wallTrf.BasisX;
                    XYZ       wallYDir = wallZDir.CrossProduct(wallXDir);

                    double eps = MathUtil.Eps();

                    bboxCtr     -= wallOrig;
                    PosHingeSide = (bboxCtr.DotProduct(wallYDir) > -eps);

                    XYZ famInstYDir = trf.BasisY;
                    FlippedSymbol = (PosHingeSide != (wallYDir.DotProduct(famInstYDir) > -eps));
                }
            }
        }