private DatabaseIfc(bool generate, Schema schema, ModelView view) { mSchema = schema; mModelView = view; #if (RHINO) mModelSIScale = 1 / GGYM.Units.mLengthConversion[(int)GGYM.GGYMRhino.GGRhino.ActiveUnits()]; Tolerance = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance; #endif if (mSchema == Schema.IFC2x3 || mSchema == Schema.IFC4) { OwnerHistory(IfcChangeActionEnum.ADDED); } mGeomRepContxt = new IfcGeometricRepresentationContext(this, 3, Tolerance) { ContextType = "Model" }; mGeoRepSubContxtAxis = new IfcGeometricRepresentationSubContext(mGeomRepContxt, 0, IfcGeometricProjectionEnum.MODEL_VIEW) { ContextIdentifier = "Axis" }; mGeoRepSubContxtBody = new IfcGeometricRepresentationSubContext(mGeomRepContxt, 0, IfcGeometricProjectionEnum.MODEL_VIEW) { ContextIdentifier = "Body" }; if (generate) { initData(); } }
public IfcGeometricRepresentationContext GeometricRepresentationContext(ContextIdentifier nature) { IfcGeometricRepresentationContext result = null; if (mContexts.TryGetValue(nature, out result)) { return(result); } string type = "Model"; int dimension = 3; if (nature == ContextIdentifier.Annotation) { type = "Annotation"; } result = new IfcGeometricRepresentationContext(mDatabase, dimension, mDatabase.Tolerance) { ContextType = type }; IfcContext context = mDatabase.Context; if (context != null) { context.addRepresentationContext(result); } mContexts.Add(nature, result); return(result); }
internal IfcGeometricRepresentationSubContext(DatabaseIfc db, IfcGeometricRepresentationSubContext s, DuplicateOptions options) : base(db, s, options) { IfcGeometricRepresentationContext parent = s.ParentContext; if (parent != null) { IfcGeometricRepresentationContext.GeometricContextIdentifier contextId = IfcGeometricRepresentationContext.GeometricContextIdentifier.Model; if (Enum.TryParse <IfcGeometricRepresentationSubContext.GeometricContextIdentifier>(s.ContextType, out contextId)) { IfcGeometricRepresentationContext existing = null; if (db.Factory.mContexts.TryGetValue(contextId, out existing)) { ParentContext = existing; } } } if (ParentContext == null) { ParentContext = db.Factory.Duplicate(s.ParentContext, options) as IfcGeometricRepresentationContext; } mTargetScale = s.mTargetScale; mTargetView = s.mTargetView; mUserDefinedTargetView = s.mUserDefinedTargetView; IfcGeometricRepresentationSubContext.SubContextIdentifier id = IfcGeometricRepresentationSubContext.SubContextIdentifier.Axis; if (Enum.TryParse <IfcGeometricRepresentationSubContext.SubContextIdentifier>(ContextIdentifier, out id)) { db.Factory.mSubContexts[id] = this; } }
internal IfcGeometricRepresentationContext(DatabaseIfc db, IfcGeometricRepresentationContext c, DuplicateOptions options) : base(db, c, options) { mCoordinateSpaceDimension = c.mCoordinateSpaceDimension; mPrecision = c.mPrecision; if (c.mWorldCoordinateSystem != null) { WorldCoordinateSystem = db.Factory.Duplicate(c.mDatabase[c.mWorldCoordinateSystem.Index]) as IfcAxis2Placement; } if (c.mTrueNorth != null) { TrueNorth = db.Factory.Duplicate(c.TrueNorth) as IfcDirection; } if (options.DuplicateDownstream) { foreach (IfcGeometricRepresentationSubContext sc in c.mHasSubContexts) { db.Factory.Duplicate(sc, options); } } if (c.mHasCoordinateOperation != null) { db.Factory.Duplicate(c.mHasCoordinateOperation, options); } }
public IfcGeometricRepresentationSubContext(IfcGeometricRepresentationContext container, IfcGeometricProjectionEnum view) : base(container.mDatabase) { ParentContext = container; mContextType = container.mContextType; mTargetView = view; }
internal static void parseFields(IfcGeometricRepresentationContext c, List <string> arrFields, ref int ipos) { IfcRepresentationContext.parseFields(c, arrFields, ref ipos); c.mCoordinateSpaceDimension = ParserSTEP.ParseInt(arrFields[ipos++]); c.mPrecision = ParserSTEP.ParseDouble(arrFields[ipos++]); c.mWorldCoordinateSystem = ParserSTEP.ParseLink(arrFields[ipos++]); c.mTrueNorth = ParserSTEP.ParseLink(arrFields[ipos++]); }
internal IfcGeometricRepresentationSubContext(IfcGeometricRepresentationContext container, double scale, IfcGeometricProjectionEnum view) : base(container.mDatabase) { mContainerContext = container.mIndex; mContextType = container.mContextType; mTargetScale = scale; mTargetView = view; }
internal static void parseFields(IfcGeometricRepresentationSubContext c, List <string> arrFields, ref int ipos) { IfcGeometricRepresentationContext.parseFields(c, arrFields, ref ipos); c.mContainerContext = ParserSTEP.ParseLink(arrFields[ipos++]); c.mTargetScale = ParserSTEP.ParseDouble(arrFields[ipos++]); c.mTargetView = (IfcGeometricProjectionEnum)Enum.Parse(typeof(IfcGeometricProjectionEnum), arrFields[ipos++].Replace(".", "")); c.mUserDefinedTargetView = arrFields[ipos++]; }
internal void relate() { IfcGeometricRepresentationContext gc = mDatabase.mIfcObjects[mContainerContext] as IfcGeometricRepresentationContext; if (gc != null) { mActive = gc.Active; gc.HasSubContexts.Add(this); } }
internal IfcGeometricRepresentationContext(DatabaseIfc db, IfcGeometricRepresentationContext c) : base(db, c) { mCoordinateSpaceDimension = c.mCoordinateSpaceDimension; mPrecision = c.mPrecision; WorldCoordinateSystem = db.Factory.Duplicate(c.mDatabase[c.mWorldCoordinateSystem]) as IfcAxis2Placement; if (c.mTrueNorth > 0) { TrueNorth = db.Factory.Duplicate(c.TrueNorth) as IfcDirection; } foreach (IfcGeometricRepresentationSubContext sc in mHasSubContexts) { db.Factory.Duplicate(sc); } }
public enum SubContextIdentifier { Axis, Body, BoundingBox, FootPrint, PlanSymbol3d, PlanSymbol2d }; // Surface }; public IfcGeometricRepresentationSubContext SubContext(SubContextIdentifier nature) { IfcGeometricRepresentationSubContext result = null; if (mSubContexts.TryGetValue(nature, out result)) { return(result); } string identifier = "Body"; IfcGeometricProjectionEnum projection = IfcGeometricProjectionEnum.MODEL_VIEW; IfcGeometricRepresentationContext context = null; if (nature == SubContextIdentifier.Axis) { identifier = "Axis"; projection = IfcGeometricProjectionEnum.GRAPH_VIEW; } else if (nature == SubContextIdentifier.BoundingBox) { projection = IfcGeometricProjectionEnum.MODEL_VIEW; identifier = "Box"; } else if (nature == SubContextIdentifier.FootPrint) { identifier = "FootPrint"; } else if (nature == SubContextIdentifier.PlanSymbol3d) { projection = IfcGeometricProjectionEnum.PLAN_VIEW; identifier = "Annotation"; } else if (nature == SubContextIdentifier.PlanSymbol2d) { projection = IfcGeometricProjectionEnum.PLAN_VIEW; identifier = "Annotation"; context = GeometricRepresentationContext(ContextIdentifier.Annotation); } if (context == null) { context = GeometricRepresentationContext(ContextIdentifier.Model); } result = new IfcGeometricRepresentationSubContext(context, projection) { ContextIdentifier = identifier }; mSubContexts.Add(nature, result); return(result); }
internal void IdentifyContexts(IEnumerable <IfcRepresentationContext> contexts) { if (mContexts.ContainsKey(ContextIdentifier.Model)) { return; } foreach (IfcRepresentationContext context in contexts) { IfcGeometricRepresentationContext grc = context as IfcGeometricRepresentationContext; if (grc != null) { if (string.Compare(grc.ContextType, "Model", true) == 0) { mContexts.Add(ContextIdentifier.Model, grc); } } } }
internal IfcGeometricRepresentationContext(DatabaseIfc db, IfcGeometricRepresentationContext c, DuplicateOptions options) : base(db, c, options) { mCoordinateSpaceDimension = c.mCoordinateSpaceDimension; mPrecision = c.mPrecision; if (c.mWorldCoordinateSystem != null) { WorldCoordinateSystem = db.Factory.Duplicate <IfcAxis2Placement>(c.mWorldCoordinateSystem); } if (c.mTrueNorth != null) { TrueNorth = db.Factory.Duplicate(c.TrueNorth) as IfcDirection; } if (options.DuplicateDownstream) { foreach (IfcGeometricRepresentationSubContext sc in c.mHasSubContexts) { db.Factory.Duplicate(sc, options); } } if (c.mHasCoordinateOperation != null) { db.Factory.Duplicate(c.mHasCoordinateOperation, options); } IfcGeometricRepresentationSubContext subContext = this as IfcGeometricRepresentationSubContext; if (subContext == null) { IfcGeometricRepresentationContext.GeometricContextIdentifier id = IfcGeometricRepresentationContext.GeometricContextIdentifier.Model; if (Enum.TryParse <IfcGeometricRepresentationContext.GeometricContextIdentifier>(ContextType, out id)) { db.Factory.mContexts[id] = this; } if (db.Context != null) { db.Context.RepresentationContexts.Add(this); } } }
private void postImport(Aggregate aggregate) { mWorldCoordinatePlacement = null; aggregate.RelateObjects(mFolder); if (mContext != null) { mContext.initializeUnitsAndScales(); if (mContext.mRepresentationContexts.Count > 0) { mGeomRepContxt = mIfcObjects[mContext.mRepresentationContexts[0]] as IfcGeometricRepresentationContext; } if (mContext.mDeclares.Count == 0) { List <IfcDefinitionSelect> lds = aggregate.mTypeProducts.ConvertAll(x => (IfcDefinitionSelect)x); IfcRelDeclares rd = new IfcRelDeclares(mContext, lds) { Name = "DeclaredTypes" }; } } customPostImport(aggregate); }
internal BaseClassIfc InterpretLine(string line) { if (line.StartsWith("ISO")) { return(null); } string ts = line.Trim().Replace(" ", ""); if (ts.StartsWith("FILE_SCHEMA(('IFC2X4", true, System.Globalization.CultureInfo.CurrentCulture) || ts.StartsWith("FILE_SCHEMA(('IFC4", true, System.Globalization.CultureInfo.CurrentCulture)) { mRelease = ReleaseVersion.IFC4; return(null); } BaseClassIfc result = ParserIfc.ParseLine(line, mRelease); if (result == null) { int ifcID = 0; string kw = "", str = ""; ParserIfc.GetKeyWord(line, out ifcID, out kw, out str); if (string.IsNullOrEmpty(kw)) { return(null); } result = new BaseClassIfc(ifcID, kw, str); } if (result == null) { return(null); } IfcApplication application = result as IfcApplication; if (application != null) { IfcApplication ea = mFactory.mApplication; if (ea != null && ea.mVersion == application.mVersion) { if (string.Compare(ea.ApplicationFullName, application.ApplicationFullName, true) == 0) { if (string.Compare(ea.mApplicationIdentifier, application.mApplicationIdentifier) == 0) { mIfcObjects[ea.mIndex] = null; mFactory.mApplication = application; mFactory.OwnerHistory(IfcChangeActionEnum.ADDED).mLastModifyingApplication = application.mIndex; if (mFactory.mOwnerHistoryModify != null) { mFactory.mOwnerHistoryModify.mLastModifyingApplication = application.mIndex; } } } } } IfcContext context = result as IfcContext; if (context != null) { mContext = context; } IfcGeometricRepresentationContext geometricRepresentationContext = result as IfcGeometricRepresentationContext; if (geometricRepresentationContext != null) { if (string.Compare(geometricRepresentationContext.mContextType, "Plan", true) != 0) { mFactory.mGeomRepContxt = geometricRepresentationContext; } if (geometricRepresentationContext.mPrecision > 1e-6) { Tolerance = geometricRepresentationContext.mPrecision; } } IfcSIUnit unit = result as IfcSIUnit; if (unit != null) { if (unit.Name == IfcSIUnitName.METRE && unit.Prefix == IfcSIPrefix.NONE) { mFactory.mSILength = unit; } else if (unit.Name == IfcSIUnitName.SQUARE_METRE && unit.Prefix == IfcSIPrefix.NONE) { mFactory.mSIArea = unit; } else if (unit.Name == IfcSIUnitName.CUBIC_METRE && unit.Prefix == IfcSIPrefix.NONE) { mFactory.mSIVolume = unit; } } this[result.mIndex] = result; //IfcWorkPlan workPlan = result as IfcWorkPlan; //if(workPlan != null) //{ // mWorkPlans.Add(workPlan); // return workPlan; //} return(result); }
internal static IfcGeometricRepresentationContext Parse(string strDef) { IfcGeometricRepresentationContext c = new IfcGeometricRepresentationContext(); int ipos = 0; parseFields(c, ParserSTEP.SplitLineFields(strDef), ref ipos); return c; }
internal IfcGeometricRepresentationContext(IfcGeometricRepresentationContext p) : base(p) { mCoordinateSpaceDimension = p.mCoordinateSpaceDimension; mPrecision = p.mPrecision; mTrueNorth = p.mTrueNorth; }
internal static void parseFields(IfcGeometricRepresentationContext c, List<string> arrFields, ref int ipos) { IfcRepresentationContext.parseFields(c, arrFields, ref ipos); c.mCoordinateSpaceDimension = ParserSTEP.ParseInt(arrFields[ipos++]); c.mPrecision = ParserSTEP.ParseDouble(arrFields[ipos++]); c.mWorldCoordinateSystem = ParserSTEP.ParseLink(arrFields[ipos++]); c.mTrueNorth = ParserSTEP.ParseLink(arrFields[ipos++]); }
internal IfcGeometricRepresentationContext(DatabaseIfc db, IfcGeometricRepresentationContext c) : base(db, c) { mCoordinateSpaceDimension = c.mCoordinateSpaceDimension; mPrecision = c.mPrecision; WorldCoordinateSystem = db.Factory.Duplicate(c.mDatabase[ c.mWorldCoordinateSystem]) as IfcAxis2Placement; if (c.mTrueNorth > 0) TrueNorth = db.Factory.Duplicate(c.TrueNorth) as IfcDirection; foreach (IfcGeometricRepresentationSubContext sc in mHasSubContexts) db.Factory.Duplicate(sc); }
internal BaseClassIfc interpretLine(string line) { BaseClassIfc result = ParserIfc.ParseLine(line, mRelease); if (result == null) { if (line.StartsWith("ISO")) { return(null); } if (setFileLine(line)) { return(null); } int ifcID = 0; string kw = "", str = ""; ParserSTEP.GetKeyWord(line, out ifcID, out kw, out str); if (string.IsNullOrEmpty(kw) || !kw.ToLower().StartsWith("ifc")) { return(null); } result = new BaseClassIfc(ifcID, kw, str); } if (result == null) { return(null); } IfcApplication application = result as IfcApplication; if (application != null) { IfcApplication ea = mFactory.mApplication; if (ea != null && ea.mVersion == application.mVersion) { if (string.Compare(ea.ApplicationFullName, application.ApplicationFullName, true) == 0) { if (string.Compare(ea.mApplicationIdentifier, application.mApplicationIdentifier) == 0) { this[ea.mIndex] = null; mFactory.mApplication = application; // mFactory.OwnerHistory(IfcChangeActionEnum.ADDED).mLastModifyingApplication = application.mIndex; // if (mFactory.mOwnerHistories.ContainsKey(IfcChangeActionEnum.MODIFIED)) // mFactory.mOwnerHistories[IfcChangeActionEnum.MODIFIED].mLastModifyingApplication = application.mIndex; } } } } IfcGeometricRepresentationContext geometricRepresentationContext = result as IfcGeometricRepresentationContext; if (geometricRepresentationContext != null) { Tolerance = geometricRepresentationContext.mPrecision; } IfcSIUnit unit = result as IfcSIUnit; if (unit != null) { if (unit.Name == IfcSIUnitName.METRE && unit.Prefix == IfcSIPrefix.NONE) { mFactory.mSILength = unit; } else if (unit.Name == IfcSIUnitName.SQUARE_METRE && unit.Prefix == IfcSIPrefix.NONE) { mFactory.mSIArea = unit; } else if (unit.Name == IfcSIUnitName.CUBIC_METRE && unit.Prefix == IfcSIPrefix.NONE) { mFactory.mSIVolume = unit; } } return(result); }
internal override void parseJObject(JObject obj) { base.parseJObject(obj); JObject jobj = obj.GetValue("ContextOfItems", StringComparison.InvariantCultureIgnoreCase) as JObject; if (jobj != null) { JToken tok = jobj["href"]; if (tok != null) { mContextOfItems = tok.Value <int>(); } else { IfcRepresentationContext rc = extractObject <IfcRepresentationContext>(jobj); IfcContext context = mDatabase.Context; if (context != null) { foreach (IfcRepresentationContext repContext in context.RepresentationContexts) { IfcGeometricRepresentationSubContext gsc = rc as IfcGeometricRepresentationSubContext; if (gsc != null) { IfcGeometricRepresentationContext grc = repContext as IfcGeometricRepresentationContext; if (grc != null) { foreach (IfcGeometricRepresentationSubContext sub in grc.HasSubContexts) { if (string.Compare(sub.mContextIdentifier, gsc.mContextIdentifier, true) == 0) { ContextOfItems = sub; mDatabase[rc.mIndex] = null; } } } } } } if (mContextOfItems == 0) { ContextOfItems = rc; } } } JToken token = obj.GetValue("RepresentationIdentifier", StringComparison.InvariantCultureIgnoreCase); if (token != null) { RepresentationIdentifier = token.Value <string>(); } token = obj.GetValue("RepresentationType", StringComparison.InvariantCultureIgnoreCase); if (token != null) { RepresentationType = token.Value <string>(); } mDatabase.extractJArray <IfcRepresentationItem>(obj.GetValue("Items", StringComparison.InvariantCultureIgnoreCase) as JArray).ForEach(x => addItem(x)); List <IfcPresentationLayerAssignment> assignments = mDatabase.extractJArray <IfcPresentationLayerAssignment>(obj.GetValue("LayerAssignments", StringComparison.InvariantCultureIgnoreCase) as JArray); foreach (IfcPresentationLayerAssignment a in assignments) { a.addItem(this); } }
internal BaseClassIfc InterpretLine(string line,Aggregate aggregate) { if (line.StartsWith("ISO")) return null; string ts = line.Trim().Replace(" ", ""); if (ts.StartsWith("FILE_SCHEMA(('IFC2X4", true, System.Globalization.CultureInfo.CurrentCulture) || ts.StartsWith("FILE_SCHEMA(('IFC4", true, System.Globalization.CultureInfo.CurrentCulture)) { mSchema = Schema.IFC4; return null; } BaseClassIfc result = ParserIfc.ParseLine(line, mSchema); if (result == null) { int ifcID = 0; string kw = "", str = ""; ParserIfc.GetKeyWord(line, out ifcID, out kw, out str); if (string.IsNullOrEmpty(kw)) return null; result = new BaseClassIfc(ifcID, kw,str); } if(result == null) return null; IfcApplication application = result as IfcApplication; if (application != null) { IfcApplication ea = mApplication; if (ea != null && ea.mVersion == application.mVersion) { if (string.Compare(ea.ApplicationFullName, application.ApplicationFullName, true) == 0) { if (string.Compare(ea.mApplicationIdentifier, application.mApplicationIdentifier) == 0) { mIfcObjects[ea.mIndex] = null; mApplication = application; OwnerHistory(IfcChangeActionEnum.ADDED).mLastModifyingApplication = application.mIndex; if (mOwnerHistoryModify != null) mOwnerHistoryModify.mLastModifyingApplication = application.mIndex; } } } } IfcContext context = result as IfcContext; if (context != null) { mContext = context; #warning merge project if existing } IfcGeometricRepresentationContext geometricRepresentationContext = result as IfcGeometricRepresentationContext; if (geometricRepresentationContext != null) { if (string.Compare(geometricRepresentationContext.mContextType, "Plan", true) != 0) mGeomRepContxt = geometricRepresentationContext; if (geometricRepresentationContext.mPrecision > 1e-6) Tolerance = geometricRepresentationContext.mPrecision; } IfcSIUnit unit = result as IfcSIUnit; if(unit != null) { if (unit.Name == IfcSIUnitName.METRE && unit.Prefix == IfcSIPrefix.NONE) mSILength = unit; else if (unit.Name == IfcSIUnitName.SQUARE_METRE && unit.Prefix == IfcSIPrefix.NONE) mSIArea = unit; else if (unit.Name == IfcSIUnitName.CUBIC_METRE && unit.Prefix == IfcSIPrefix.NONE) mSIVolume = unit; } aggregate.setAggregate(result); if (mIfcObjects.Count <= result.mIndex) for (int ncounter = mIfcObjects.Count; ncounter <= result.mIndex; ncounter++) mIfcObjects.Add(new BaseClassIfc()); mIfcObjects[result.mIndex] = result; result.mDatabase = this; //IfcWorkPlan workPlan = result as IfcWorkPlan; //if(workPlan != null) //{ // mWorkPlans.Add(workPlan); // return workPlan; //} return result; }
internal static IfcGeometricRepresentationContext Parse(string strDef) { IfcGeometricRepresentationContext c = new IfcGeometricRepresentationContext(); int ipos = 0; parseFields(c, ParserSTEP.SplitLineFields(strDef), ref ipos); return(c); }
private void postImport(Aggregate aggregate) { mWorldCoordinatePlacement = null; aggregate.RelateObjects(mFolder); if(mContext != null) { mContext.initializeUnitsAndScales(); if (mContext.mRepresentationContexts.Count > 0) mGeomRepContxt = mIfcObjects[mContext.mRepresentationContexts[0]] as IfcGeometricRepresentationContext; if (mContext.mDeclares.Count == 0) { List<IfcDefinitionSelect> lds = aggregate.mTypeProducts.ConvertAll(x => (IfcDefinitionSelect)x); IfcRelDeclares rd = new IfcRelDeclares(mContext, lds) { Name = "DeclaredTypes" }; } } customPostImport(aggregate); }
private DatabaseIfc(bool generate,Schema schema, ModelView view) { mSchema = schema; mModelView = view; #if(RHINO) mModelSIScale = 1 / GGYM.Units.mLengthConversion[(int) GGYM.GGYMRhino.GGRhino.ActiveUnits()]; Tolerance = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance; #endif if (mSchema == Schema.IFC2x3 || mSchema == Schema.IFC4) { OwnerHistory(IfcChangeActionEnum.ADDED); } mGeomRepContxt = new IfcGeometricRepresentationContext(this, 3, Tolerance) { ContextType = "Model" }; mGeoRepSubContxtAxis = new IfcGeometricRepresentationSubContext(mGeomRepContxt, 0, IfcGeometricProjectionEnum.MODEL_VIEW) { ContextIdentifier = "Axis" }; mGeoRepSubContxtBody = new IfcGeometricRepresentationSubContext(mGeomRepContxt, 0, IfcGeometricProjectionEnum.MODEL_VIEW) { ContextIdentifier = "Body" }; if (generate) initData(); }
private IfcGeometricProjectionEnum mTargetView; // : IfcGeometricProjectionEnum; #endregion Fields #region Constructors public IfcGeometricRepresentationSubContext(IfcGeometricRepresentationContext container, IfcGeometricProjectionEnum view) : base(container.mDatabase) { ContainerContext = container; mContextType = container.mContextType; mTargetView = view; }