private CompRepAlignedWith FindCompRepAssociatedWith(long _material_id) { if (_material_id < 0) { return(null); } if (this.comp_rep_record_flat == null) { this.UpdateFlatRecord(); } foreach (CompRep cr in this.comp_rep_record_flat) { if (!(cr is CompRepAlignedWith)) { continue; } CompRepAlignedWith wall_constr_rep = cr as CompRepAlignedWith; if (wall_constr_rep.WallConstr == null) { continue; } if (wall_constr_rep.WallConstr.ID == _material_id) { return(wall_constr_rep); } } return(null); }
public long ConvertMaterialID2CompReference(long _material_id) { CompRepAlignedWith cra = this.FindCompRepAssociatedWith(_material_id); if (cra == null) { return(-1L); } else { return(cra.Comp_ID); } }
/// <summary> /// <para>Call both for realized and not realized components.</para> /// </summary> /// <param name="_cra"></param> /// <returns></returns> public bool ReAssociate(CompRepAlignedWith _cra) { // look for the corresponding material first Material found = this.materials.FirstOrDefault(x => x.BoundCRID == _cra.Comp_ID); if (found != null) { // restore the binding found.BoundCR = _cra; return(true); } else { // create a new material return(this.AddMaterial(_cra)); } }
/// <summary> /// Binds the material to the component representation, if found. If not, it calls the CreateMaterial method of CompRepAlignedWith. /// </summary> /// <param name="_cra"></param> /// <returns></returns> public bool AddMaterial(CompRepAlignedWith _cra) { if (_cra == null) { return(false); } Material m = this.materials.FirstOrDefault(x => x.Name == _cra.Comp_Description); if (m != null) { m.BoundCR = _cra; return(true); } this.materials.Add(_cra.CreateMaterial()); return(true); }
internal void SetOffsets(CompRepAlignedWith _sender, double _offset_out, double _offset_in) { if (_sender == null) { return; } if (this.BoundCR == null) { return; } if (this.BoundCR.CR_ID != _sender.CR_ID) { return; } bool found_offset_change = false; found_offset_change = Math.Abs(this.Thickness - (float)(_offset_out + _offset_in)) > Utils.CommonExtensions.LINEDISTCALC_TOLERANCE; this.Thickness = (float)(_offset_out + _offset_in); MaterialPosToWallAxisPlane pos = MaterialPosToWallAxisPlane.MIDDLE; if (_offset_in * 10 < _offset_out) { pos = MaterialPosToWallAxisPlane.IN; } else if (_offset_out * 10 < _offset_in) { pos = MaterialPosToWallAxisPlane.OUT; } found_offset_change |= (this.Position == pos); this.Position = pos; this.OffsetsChanged = found_offset_change; }
// for a sequence of messages public void AddCompReps(List <ComponentMessage> _cmsgs) { if (_cmsgs == null) { return; } if (_cmsgs.Count == 0) { return; } // add all List <CompRep> added = new List <CompRep>(); foreach (ComponentMessage cmsg in _cmsgs) { CompRep cr_new = AddCompRep(cmsg); if (cr_new != null) { added.Add(cr_new); } } if (added.Count == 0) { // updates only of Component Ids, if any this.RecordChanged = false; this.RecordChanged = true; return; } // establish the relationships btw the component representations: // assign the parent ID // assing the representations of sub-components foreach (CompRep cr in added) { CompRepInfo cri = cr as CompRepInfo; if (cri == null) { continue; } if (cri.Comp_Parent > -1) { CompRepInfo parent = this.FindByCompId(cri.Comp_Parent); if (parent != null) { cri.CR_Parent = parent.CR_ID; parent.AddSubCompRep(cri); this.comp_rep_record.Remove(cri); } } } this.UpdateFlatRecord(); // establish connectivity List <CompRepContainedIn> connection_nodes = this.comp_rep_record_flat.Where(x => x is CompRepContainedIn).Select(x => x as CompRepContainedIn).ToList(); if (connection_nodes.Count > 0) { foreach (CompRep cr in this.comp_rep_record_flat) { if (cr is CompRepConnects) { CompRepConnects connection_edge = cr as CompRepConnects; connection_edge.RetrieveConnectionPoints(connection_nodes); } } } // re-associate with existing geometry (this causes information flow back to the ComponentBuilder) // NOTE: after the hierarchy has been established in the previous step foreach (CompRep cr in this.comp_rep_record_flat) { if (cr is CompRepDescirbes) { CompRepDescirbes crd = cr as CompRepDescirbes; if (crd.GR_State.IsRealized) { this.communcation_manager.ConnectCompRepToZonedVolume(crd); } } else if (cr is CompRepAlignedWith) { CompRepAlignedWith cra = cr as CompRepAlignedWith; this.communcation_manager.ConnectCompRepToMaterial(cra); } } // done this.RecordChanged = false; this.RecordChanged = true; }
public CompRep AddCompRep(ComponentMessage _cmsg) { if (_cmsg == null) { return(null); } if (this.communcation_manager == null) { return(null); // unable to communicate... } // check for duplicate COMPONENT representations CompRep same_comp_id = this.FindByCompId(_cmsg.CompID); if (same_comp_id != null) { return(same_comp_id); } // check for component representations with duplicate content -> take the one with the VALID COMPONENT ID CompRepInfo same_comp_content = this.FindSameStructureNoCompId(_cmsg); if (same_comp_content != null) { // just transfer the comp id same_comp_content.AdoptCompId(_cmsg); return(null); } // creates a representation of a component that has been here before and looks for the referenced geometry // OR... // creates a representation of a component that is here for the first time switch (_cmsg.GeomType) { case InterProcCommunication.Specific.Relation2GeomType.DESCRIBES: CompRepDescirbes created_D = new CompRepDescirbes(_cmsg, this.communcation_manager); this.AddCompRepToRecord(created_D); return(created_D); case InterProcCommunication.Specific.Relation2GeomType.DESCRIBES_3D: CompRepDescirbes3D created_D3d = new CompRepDescirbes3D(_cmsg, this.communcation_manager); this.AddCompRepToRecord(created_D3d); return(created_D3d); case InterProcCommunication.Specific.Relation2GeomType.DESCRIBES_2DorLESS: CompRepDescribes2DorLess created_D2d = new CompRepDescribes2DorLess(_cmsg, this.communcation_manager); this.AddCompRepToRecord(created_D2d); return(created_D2d); case InterProcCommunication.Specific.Relation2GeomType.GROUPS: return(null); case InterProcCommunication.Specific.Relation2GeomType.CONTAINED_IN: CompRepContainedIn created_CI = new CompRepContainedIn(_cmsg, this.communcation_manager); this.AddCompRepToRecord(created_CI); return(created_CI); case InterProcCommunication.Specific.Relation2GeomType.CONNECTS: CompRepConnects created_CO = new CompRepConnects(_cmsg, this.communcation_manager); this.AddCompRepToRecord(created_CO); return(created_CO); case InterProcCommunication.Specific.Relation2GeomType.ALIGNED_WITH: CompRepAlignedWith created_A = new CompRepAlignedWith(_cmsg, this.communcation_manager); this.AddCompRepToRecord(created_A); return(created_A); case InterProcCommunication.Specific.Relation2GeomType.NONE: // this is for the parent of a geometry containing component CompRepInfo created_N = new CompRepInfo(_cmsg, this.communcation_manager); this.AddCompRepToRecord(created_N); return(created_N); default: return(null); } }