예제 #1
0
        // NEW (07.08.2017)
        /// <summary>
        /// <para>Call in order to update the id of automatically generated components.</para>
        /// </summary>
        /// <param name="_msg_query"></param>
        /// <returns>A component representation with current component id -1 but with the same content.</returns>
        private CompRepInfo FindSameStructureNoCompId(ComponentMessage _msg_query)
        {
            if (_msg_query == null)
            {
                return(null);
            }

            foreach (CompRep cr in this.comp_rep_record_flat)
            {
                CompRepInfo cri = cr as CompRepInfo;
                if (cri == null)
                {
                    continue;
                }
                if (cri.Comp_ID > -1)
                {
                    continue;
                }

                ComponentMessage msg_test = cri.Comp_Msg;
                if (msg_test == null)
                {
                    msg_test = cri.ExtractMessage(MessagePositionInSeq.SINGLE_MESSAGE);
                }

                bool found = ComponentMessage.HaveSameContent(_msg_query, msg_test);
                if (found)
                {
                    return(cri);
                }
            }

            return(null);
        }
예제 #2
0
        /// <summary>
        /// <para>The search involves all subcomponents. E.g.if a comp rep has a sub comp rep somewhere </para>
        /// <para>with a type contained in '_types', it will be included. For this reason the same component</para>
        /// <para>collected multiple times.</para>
        /// </summary>
        /// <param name="_types"></param>
        /// <returns></returns>
        public ReadOnlyCollection <CompRepInfo> PartialCompRepRecord(List <Relation2GeomType> _types)
        {
            List <CompRepInfo> found = new List <CompRepInfo>();

            if (_types == null)
            {
                return(found.AsReadOnly());
            }
            if (_types.Count == 0)
            {
                return(found.AsReadOnly());
            }

            List <long> added_parent = new List <long>();

            foreach (CompRep cr in this.comp_rep_record)
            {
                CompRepInfo cri = cr as CompRepInfo;
                if (cri == null)
                {
                    continue;
                }

                if (_types.Contains(cri.GR_State.Type))
                {
                    found.Add(cri);
                }
                else
                if (cri.HasCompRepOfType(_types))
                {
                    found.Add(cri);
                }
            }
            return(found.AsReadOnly());
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (container == null)
            {
                return(null);
            }
            FrameworkElement element = container as FrameworkElement;

            if (element == null)
            {
                return(null);
            }

            if (item == null)
            {
                return(element.TryFindResource("DT_Empty") as DataTemplate);
            }

            CompRepInfo cr  = item as CompRepInfo;
            Material    mat = item as Material;

            if (cr != null)
            {
                return(element.TryFindResource("CompRepInList") as DataTemplate);
            }
            else if (mat != null)
            {
                return(element.TryFindResource("MaterialInTreeView") as DataTemplate);
            }
            else
            {
                return(element.TryFindResource("DT_Unknown") as DataTemplate);
            }
        }
예제 #4
0
        private bool CanExecute_OnSwitchFromCompRepToZonedVolumeCommand(object _o)
        {
            if (_o == null)
            {
                return(false);
            }

            CompRepInfo comp = _o as CompRepInfo;

            if (comp == null)
            {
                return(false);
            }
            if (comp.GR_State.Type != InterProcCommunication.Specific.Relation2GeomType.DESCRIBES &&
                comp.GR_State.Type != InterProcCommunication.Specific.Relation2GeomType.GROUPS)
            {
                return(false);
            }

            if (this.ZoneDisp == null || this.CompDisp == null)
            {
                return(false);
            }

            return(true);
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (container == null)
            {
                return(null);
            }
            FrameworkElement element = container as FrameworkElement;

            if (element == null)
            {
                return(null);
            }

            if (item == null)
            {
                return(element.TryFindResource("DT_Empty") as DataTemplate);
            }

            CompRepInfo cr = item as CompRepInfo;

            if (cr == null)
            {
                return(element.TryFindResource("DT_Empty") as DataTemplate);
            }

            if (!(cr is CompRepAlignedWith) && !(cr is CompRepContainedIn) && !(cr is CompRepContainedIn_Instance) &&
                !(cr is CompRepConnects) && !(cr is CompRepConnects_Instance))
            {
                return(element.TryFindResource("CompRepInList") as DataTemplate);
            }
            else
            {
                return(element.TryFindResource("HDT_Empty") as DataTemplate);
            }
        }
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (container == null)
            {
                return(null);
            }
            FrameworkElement element = container as FrameworkElement;

            if (element == null)
            {
                return(null);
            }

            if (item == null)
            {
                return(element.TryFindResource("DT_Empty") as DataTemplate);
            }

            CompRepInfo cr = item as CompRepInfo;

            if (cr == null)
            {
                return(element.TryFindResource("DT_Empty") as DataTemplate);
            }

            if (!(cr is CompRepDescirbes) && !(cr is CompRepDescirbes3D) && !(cr is CompRepDescribes2DorLess) &&
                !(cr is CompRepAlignedWith) && !(cr is CompRepGroups))
            {
                return(element.TryFindResource("CompRepInList") as DataTemplate);
            }
            else
            {
                return(element.TryFindResource("HDT_Empty") as DataTemplate);
            }
        }
예제 #7
0
        public void Select(CompRepInfo _comp)
        {
            // expand
            if (_comp != null)
            {
                _comp.IsExpanded = true;
                List <CompRep> parent_chain = this.GetParentChain(_comp);
                foreach (CompRep cr in parent_chain)
                {
                    cr.IsExpanded = true;
                }
            }

            // reset selection
            foreach (CompRep cr in this.CompRepRecord)
            {
                cr.IsSelected = false;
                if (cr is CompRepInfo)
                {
                    CompRepInfo        cri      = cr as CompRepInfo;
                    List <CompRepInfo> cri_subs = cri.GetFlatListOfSubCompReps();
                    foreach (CompRepInfo cri_subs_i in cri_subs)
                    {
                        cri_subs_i.IsSelected = false;
                    }
                }
            }

            // select
            if (_comp != null)
            {
                _comp.IsSelected = true;
            }
        }
예제 #8
0
 public void UpdateFlatRecord()
 {
     this.comp_rep_record_flat = new List <CompRep>();
     foreach (CompRep cr in this.comp_rep_record)
     {
         this.comp_rep_record_flat.Add(cr);
         if (cr is CompRepInfo)
         {
             CompRepInfo        cri      = cr as CompRepInfo;
             List <CompRepInfo> cri_subs = cri.GetFlatListOfSubCompReps();
             this.comp_rep_record_flat.AddRange(cri_subs);
         }
     }
 }
예제 #9
0
        private void OnAlignCompRepWZonedVolumeCommand()
        {
            CompRepInfo comp = this.CompDisp.SelectedCompRep;

            if (comp == null)
            {
                return;
            }

            this.comp_waiting_to_be_aligned_w_volume_wall        = comp;
            this.comp_waiting_for_alignment_w_picked_volume_wall = true;
            this.viewPort.SwitchActionModeCmd.Execute("BUILDING_PHYSICS");
            this.ZoneDisp.SwitchZoneEditModeCmd.Execute("VOLUME_PICK");
        }
예제 #10
0
        public List <ComponentMessage> ExtractMessagesFrom(CompRep _cr)
        {
            List <ComponentMessage> extracted = new List <ComponentMessage>();

            if (_cr == null)
            {
                return(extracted);
            }

            CompRepInfo cri = _cr as CompRepInfo;

            if (cri == null)
            {
                return(extracted);
            }

            List <CompRepInfo> cr_subCRs = cri.GetFlatListOfSubCompReps();
            int nrSub = cr_subCRs.Count;

            if (nrSub == 0)
            {
                ComponentMessage msg = cri.ExtractMessage(MessagePositionInSeq.SINGLE_MESSAGE);
                if (msg != null)
                {
                    extracted.Add(msg);
                }
            }
            else
            {
                ComponentMessage msg = cri.ExtractMessage(MessagePositionInSeq.SEQUENCE_START_MESSAGE);
                if (msg != null)
                {
                    extracted.Add(msg);
                }
                for (int i = 0; i < nrSub; i++)
                {
                    MessagePositionInSeq pos_current = (i == (nrSub - 1)) ? MessagePositionInSeq.SEQUENCE_END_MESSAGE : MessagePositionInSeq.MESSAGE_INSIDE_SEQUENCE;
                    ComponentMessage     msg_i       = cr_subCRs[i].ExtractMessage(pos_current);
                    if (msg_i != null)
                    {
                        extracted.Add(msg_i);
                    }
                }
            }

            return(extracted);
        }
예제 #11
0
        public CompRepInfo FindByReferencedCompId(long _ref_id)
        {
            foreach (CompRep record in this.comp_rep_record_flat)
            {
                CompRepInfo cri = record as CompRepInfo;
                if (cri == null)
                {
                    continue;
                }

                if (cri.Comp_RefCompIDs.Contains(_ref_id))
                {
                    return(cri);
                }
            }

            return(null);
        }
예제 #12
0
        public CompRepInfo FindByGeomId(long _id_volume, int _id_surface)
        {
            foreach (CompRep record in this.comp_rep_record_flat)
            {
                CompRepInfo cri = record as CompRepInfo;
                if (cri == null)
                {
                    continue;
                }

                GeometricRelationship geom_rel = cri.GR_Relationships.FirstOrDefault(x => x.GrIds.X == _id_volume && x.GrIds.Y == _id_surface);
                if (geom_rel != null)
                {
                    return(cri);
                }
            }

            return(null);
        }
예제 #13
0
        private List <CompRep> GetParentChain(CompRepInfo _cri)
        {
            if (_cri == null)
            {
                return(new List <CompRep>());
            }

            List <CompRep> chain         = new List <CompRep>();
            CompRep        parent        = (_cri.CR_Parent > -1) ? this.FindById(_cri.CR_Parent) : null;
            CompRepInfo    parent_as_cri = (parent == null) ? null : (parent as CompRepInfo);

            while (parent_as_cri != null)
            {
                chain.Add(parent);
                parent        = (parent_as_cri.CR_Parent > -1) ? this.FindById(parent_as_cri.CR_Parent) : null;
                parent_as_cri = (parent == null) ? null : (parent as CompRepInfo);
            }

            return(chain);
        }
예제 #14
0
        public void ReAssociateZonedVolumeWComp(CompRepInfo _comp)
        {
            if (_comp == null)
            {
                return;
            }

            if (this.SelectedVolume != null)
            {
                this.SelectedVolume.EditModeType = ZonedVolumeEditModeType.ISBEING_REASSOCIATED;
            }

            switch (_comp.GR_State.Type)
            {
            case InterProcCommunication.Specific.Relation2GeomType.DESCRIBES:
                CompRepDescirbes crd = _comp as CompRepDescirbes;
                if (crd != null)
                {
                    // if the Volume is NULL, the relationship turns to 'not realized'
                    // (see CompRepDescirbes.Geom_Zone setter)
                    crd.Geom_Zone = this.SelectedVolume;
                }
                break;

            case InterProcCommunication.Specific.Relation2GeomType.CONTAINED_IN:
                CompRepContainedIn_Instance crci = _comp as CompRepContainedIn_Instance;
                if (crci != null)
                {
                    // if the Volume is NULL, nothing happens
                    crci.PlaceIn(this.SelectedVolume);
                }
                break;

            default:
                break;
            }
        }
예제 #15
0
        private void OnSwitchFromCompRepToZonedVolumeCommand(object _o)
        {
            CompRepInfo comp = _o as CompRepInfo;

            if (comp == null)
            {
                return;
            }

            this.viewPort.SwitchActionModeCmd.Execute("BUILDING_PHYSICS");
            switch (comp.GR_State.Type)
            {
            case InterProcCommunication.Specific.Relation2GeomType.DESCRIBES:
                CompRepDescirbes crd = comp as CompRepDescirbes;
                if (crd != null)
                {
                    this.ZoneDisp.SelectedEntity = crd.Geom_Zone;
                }
                break;

            default:
                break;
            }
        }
예제 #16
0
        private bool CanExecute_OnAssociateCompRepWZonedVolumeCommand()
        {
            if (this.ZoneDisp == null || this.CompDisp == null)
            {
                return(false);
            }

            CompRepInfo comp = this.CompDisp.SelectedCompRep;

            if (comp == null)
            {
                return(false);
            }
            if (!(comp is CompRepDescirbes))
            {
                return(false);
            }
            if (comp.GR_State.IsRealized)
            {
                return(false);
            }

            return(true);
        }
예제 #17
0
        private bool CanExecute_OnAlignCompRepWZonedVolumeCommand()
        {
            if (this.ZoneDisp == null || this.CompDisp == null)
            {
                return(false);
            }

            CompRepInfo comp = this.CompDisp.SelectedCompRep;

            if (comp == null)
            {
                return(false);
            }
            if (!(comp is CompRepContainedIn_Instance))
            {
                return(false);
            }
            if (!comp.GR_State.IsRealized)
            {
                return(false);
            }

            return(true);
        }
예제 #18
0
        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);
            }
        }
예제 #19
0
        // 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;
        }
예제 #20
0
        public List <ComponentMessage> ExtractMessagesForReferenceUpdateFrom(CompRep _cr)
        {
            List <ComponentMessage> extracted = new List <ComponentMessage>();

            if (_cr == null)
            {
                return(extracted);
            }

            CompRepInfo cri = _cr as CompRepInfo;

            if (cri == null)
            {
                return(extracted);
            }

            // call 'ExtractMessage' to force synchronization with geometry
            ComponentMessage msg1 = cri.ExtractMessage(MessagePositionInSeq.SINGLE_MESSAGE);
            // .............................................................................

            List <CompRepInfo> cr_subCRs     = cri.GetFlatListOfSubCompReps();
            List <CompRepInfo> cr_CRs_w_refs = cr_subCRs.Where(x => x.Comp_RefCompIDs.Count > 0).ToList();

            if (cri.Comp_RefCompIDs.Count > 0)
            {
                cr_CRs_w_refs.Insert(0, cri);
            }

            int nrMsg = cr_CRs_w_refs.Count;

            if (nrMsg == 1)
            {
                ComponentMessage msg = cr_CRs_w_refs[0].ExtractMessage(MessagePositionInSeq.SINGLE_MESSAGE);
                if (msg != null)
                {
                    extracted.Add(msg);
                }
            }
            else if (nrMsg > 1)
            {
                for (int i = 0; i < nrMsg; i++)
                {
                    MessagePositionInSeq pos_current = MessagePositionInSeq.SEQUENCE_START_MESSAGE;
                    if (i > 0 && i < (nrMsg - 1))
                    {
                        pos_current = MessagePositionInSeq.MESSAGE_INSIDE_SEQUENCE;
                    }
                    else if (i == (nrMsg - 1))
                    {
                        pos_current = MessagePositionInSeq.SEQUENCE_END_MESSAGE;
                    }

                    ComponentMessage msg_i = cr_CRs_w_refs[i].ExtractMessage(pos_current);
                    if (msg_i != null)
                    {
                        extracted.Add(msg_i);
                    }
                }
            }

            return(extracted);
        }