Esempio n. 1
0
        private bool CanExecute_OnSwitchFromZonedVolumeToCompRepCommand(object _o)
        {
            if (_o == null)
            {
                return(false);
            }

            ZonedVolume zv = _o as ZonedVolume;

            if (zv == null)
            {
                return(false);
            }
            if (!zv.AssociatedWComp)
            {
                return(false);
            }

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

            return(true);
        }
 public NeighbNode(ZonedVolume _volume)
 {
     this.Volume  = _volume;
     this.Edges   = new List <NeighbEdge>();
     this.IsValid = (this.Volume != null);
     if (this.IsValid)
     {
         this.Degree = this.Volume.GetNrOfEnclosingSurfaces();
     }
     this.IsBeingProcessed = true;
 }
        private void AddToGraph(List <SurfaceMatch> _matches)
        {
            if (_matches == null || _matches.Count == 0)
            {
                return;
            }

            if (this.nodes == null)
            {
                this.nodes = new List <NeighbNode>();
            }
            if (this.edges == null)
            {
                this.edges = new List <NeighbEdge>();
            }

            foreach (SurfaceMatch match in _matches)
            {
                if (!match.IsContainment)
                {
                    continue;
                }

                // look for the nodes
                NeighbNode n1 = this.nodes.FirstOrDefault(x => x.IsValid && x.Volume.ID == match.Match01.VolumeID);
                if (n1 == null)
                {
                    ZonedVolume v1 = this.volumes_tested.Where(x => x.Key.ID == match.Match01.VolumeID).Select(x => x.Key).FirstOrDefault();
                    if (v1 != null)
                    {
                        n1 = new NeighbNode(v1);
                        this.nodes.Add(n1);
                    }
                }

                NeighbNode n2 = this.nodes.FirstOrDefault(x => x.IsValid && x.Volume.ID == match.Match02.VolumeID);
                if (n2 == null)
                {
                    ZonedVolume v2 = this.volumes_tested.Where(x => x.Key.ID == match.Match02.VolumeID).Select(x => x.Key).FirstOrDefault();
                    if (v2 != null)
                    {
                        n2 = new NeighbNode(v2);
                        this.nodes.Add(n2);
                    }
                }

                // create the edge
                if (n1 != null && n2 != null)
                {
                    this.edges.Add(new NeighbEdge(n1, n2, match));
                }
            }
        }
Esempio n. 4
0
        private void OnSwitchFromZonedVolumeToCompRepCommand(object _o)
        {
            ZonedVolume zv = _o as ZonedVolume;

            if (zv == null)
            {
                return;
            }

            this.viewPort.SwitchActionModeCmd.Execute("SPACES_OPENINGS");
            this.CompDisp.SelectedCompRep = zv.GetDescribingCompOrFirst();
        }
Esempio n. 5
0
        internal ZonedVolume ReconstructZonedVolume(long _id, string _name, SharpDX.Color _color, EntityVisibility _vis, bool _is_valid, bool _assoc_w_comp,
                                                    float _line_thickness_GUI, List <string> _mLtext, bool _is_top_closure, bool _is_bottom_closure,
                                                    Layer _layer, bool _color_by_layer, List <ZonedPolygonGroup> _rulingLevels,
                                                    Dictionary <int, ComponentInteraction.Material> _material_per_level, Dictionary <Utils.Composite4IntKey, ComponentInteraction.Material> _material_per_label)
        {
            // reconstruct the volume
            ZonedVolume created = new ZonedVolume(_id, _name, _color, _vis, _is_valid, _assoc_w_comp,
                                                  _line_thickness_GUI, _mLtext, _is_top_closure, _is_bottom_closure,
                                                  _layer, _color_by_layer, _rulingLevels, _material_per_level, _material_per_label);

            Entity.Nr_Entities = Math.Max(Entity.Nr_Entities, _id) + 1;
            // setting the layer adds the ZonedVolume to the ContainedEntities of the layer (see DXFLayer)

            return(created);
        }
Esempio n. 6
0
        void ZoneDisp_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            ZoneGroupDisplay zgd = sender as ZoneGroupDisplay;

            if (zgd != null)
            {
                if (e != null && e.PropertyName == "PickedZonedVolume")
                {
                    if (this.comp_waiting_to_be_assoc_w_volume != null && this.comp_waiting_for_picked_volume)
                    {
                        // complete command OnAssociateCompRepWZonedVolumeCommand()
                        zgd.EManager.ReAssociateZonedVolumeWComp(this.comp_waiting_to_be_assoc_w_volume);

                        this.viewPort.SwitchActionModeCmd.Execute("SPACES_OPENINGS");
                        if (this.CompDisp != null)
                        {
                            this.CompDisp.CompRepMANAGER.UpdateFlatRecord();
                            this.CompDisp.UpdateCompRepList();
                        }
                        // this.viewPort.SendDataToCompBuilder(this.comp_waiting_to_be_assoc_w_volume); // not necessary, call is performed from the CompRep class
                        this.comp_waiting_for_picked_volume = false;
                    }
                    else if (this.comp_waiting_to_be_aligned_w_volume_wall != null && this.comp_waiting_for_alignment_w_picked_volume_wall)
                    {
                        // complete command OnAlignCompRepWZonedVolumeCommand()
                        ZonedVolume selected_vol = zgd.EManager.SelectedVolume;
                        CompRepContainedIn_Instance selected_comp = this.comp_waiting_to_be_aligned_w_volume_wall as CompRepContainedIn_Instance;
                        if (selected_vol != null && selected_comp != null && selected_comp.GR_Relationships[0].GrIds.X == selected_vol.ID)
                        {
                            bool    successful_wall_hit = false;
                            Vector3 new_X_Axis          = selected_vol.GetHorizontalAxisOfHitWall(zgd.HitPointOnVolumeMesh.ToVector3(), out successful_wall_hit);
                            if (successful_wall_hit)
                            {
                                selected_comp.AlignPlacement(new_X_Axis.ToVector3D());
                            }
                            this.viewPort.SwitchActionModeCmd.Execute("SPACES_OPENINGS");
                            if (this.CompDisp != null)
                            {
                                this.CompDisp.CompRepMANAGER.UpdateFlatRecord();
                                this.CompDisp.UpdateCompRepList();
                            }
                        }

                        this.comp_waiting_for_alignment_w_picked_volume_wall = false;
                    }
                }
            }
        }
        public List <ZonedVolume> GetNeighborsOf(ZonedVolume _zv)
        {
            List <ZonedVolume> neighbors = new List <ZonedVolume>();

            if (this.nodes == null)
            {
                return(neighbors);
            }
            if (this.nodes.Count < 1)
            {
                return(neighbors);
            }
            if (_zv == null)
            {
                return(neighbors);
            }

            NeighbNode n = this.nodes.FirstOrDefault(x => x.IsValid && x.Volume.ID == _zv.ID);

            if (n == null)
            {
                return(neighbors);
            }
            if (n.Edges.Count == 0)
            {
                return(neighbors);
            }

            foreach (NeighbEdge e in n.Edges)
            {
                if (!e.IsValid)
                {
                    continue;
                }

                if (e.Node1.Volume.ID == _zv.ID)
                {
                    neighbors.Add(e.Node2.Volume);
                }
                else if (e.Node2.Volume.ID == _zv.ID)
                {
                    neighbors.Add(e.Node1.Volume);
                }
            }

            return(neighbors);
        }
        public ZonedVolumeSurfaceVis(ZonedVolume _ownerV, bool _is_wall, long _idInOwner, int _key,
                                     ICollection <Vector3> _quad, float _area, int _opening_ind = -1)
            : base(null)
        {
            // ownership
            this.OwnerVolume  = _ownerV;
            this.IsWall       = _is_wall;
            this.KeyInOwner   = _key;
            this.IDInOwner    = _idInOwner;
            this.OpeningIndex = _opening_ind;

            // geometry
            this.quad = new List <Vector3>(_quad);

            this.AssocArea = _area;
            this.contour   = null;
        }
Esempio n. 9
0
        public bool RemoveEntity(Entity _e)
        {
            if (_e == null)
            {
                return(false);
            }

            GeometricEntity ge    = _e as GeometricEntity;
            Layer           layer = _e as Layer;

            if (ge != null)
            {
                // if the entity is a volume, release the connection to its defining levels and polygons
                // trigger its PropertyChanged event to alert a Space that may use it
                ZonedVolume zv = ge as ZonedVolume;
                if (zv != null)
                {
                    zv.ReleaseLevels();
                    zv.EditModeType = ZonedVolumeEditModeType.ISBEING_DELETED;
                }

                // if the entity is a polygon, trigger its PropertyChanged event to alert a Volume that may use it
                ZonedPolygon zp = ge as ZonedPolygon;
                if (zp != null)
                {
                    zp.EditModeType = ZonePolygonEditModeType.ISBEING_DELETED;
                }

                // remove from the layer
                Layer geL = ge.EntityLayer;
                return(geL.RemoveEntity(_e));
            }
            else if (layer != null)
            {
                return(this.RemoveLayer(layer));
            }

            return(false);
        }
Esempio n. 10
0
        private void AdaptSelectionState(List <GeometricEntity> _gList, long _gID)
        {
            if (_gList == null)
            {
                return;
            }

            this.ResetSelectionVaraibles();

            int n = _gList.Count;

            for (int i = 0; i < n; i++)
            {
                GeometricEntity ge = _gList[i];
                if (_gID != ge.ID)
                {
                    ge.IsSelected = false;
                }
                else
                {
                    ge.IsSelected = true;

                    // process state in GUI
                    ge.EntityLayer.IsExpanded = true;
                    Layer topParent = GetParentLayer(ge.EntityLayer);
                    if (topParent != null)
                    {
                        topParent.IsExpanded = true;
                    }

                    // process further, if selected entity is a ZonedPolygon or a ZonedVolume
                    ZonedPolygon zp = ge as ZonedPolygon;
                    ZonedVolume  zv = ge as ZonedVolume;
                    if (zp != null)
                    {
                        this.SelectedPolygon           = zp;
                        this.SelectedEntityIsPolygon   = true;
                        this.VerticesOfSelectedPolygon = zp.ExtractVerticesForDisplay();
                        this.OpeningsOfSelectedPolygon = zp.ExtractOpeningsForDisplay();
                        this.SurfacesOfSelectedVolume  = new List <ZonedVolumeSurfaceVis>();

                        this.SelectedVolume         = null;
                        this.SelectedEntityIsVolume = false;
                    }
                    else if (zv != null)
                    {
                        this.SelectedVolume         = zv;
                        this.SelectedEntityIsVolume = true;

                        this.SelectedPolygon           = null;
                        this.SelectedEntityIsPolygon   = false;
                        this.VerticesOfSelectedPolygon = new List <ZonedPolygonVertexVis>();
                        this.OpeningsOfSelectedPolygon = new List <ZoneOpeningVis>();
                        this.SurfacesOfSelectedVolume  = zv.ExtractSurfacesAndOpeningsForDisplay(); // changed 30.08.2017
                    }
                    else
                    {
                        this.ResetSelectionVaraibles();
                    }
                    this.SelectedGeomIndex = i;
                    break;
                }
            }
        }
        private void FindNeighbors()
        {
            if (this.volumes_tested.Count < 2)
            {
                return;
            }

            // ---------------------------------------- ALIGNMENT ----------------------------------------------

            // extract the surfaces of the 'first' volume and set them as cluster initiators
            ZonedVolume v1 = this.volumes_tested.ElementAt(0).Key;

            this.volumes_tested[v1] = true;

            List <SurfaceBasicInfo>            v1_surf       = v1.ExportBasicInfoForNeighborhoodTest();
            Dictionary <SurfaceBasicInfo, int> surf_clusters = NeighborhoodGraph.ClusterAccToAlignment(v1_surf);

            for (int i = 1; i < this.volumes_tested.Count; i++)
            {
                // get the next volume
                ZonedVolume v_next = this.volumes_tested.ElementAt(i).Key;
                this.volumes_tested[v_next] = true;

                // extract its enclosing surfaces
                List <SurfaceBasicInfo> v_next_surf = v_next.ExportBasicInfoForNeighborhoodTest();
                // try to place them in a cluster
                NeighborhoodGraph.ClusterAccToAlignment(ref surf_clusters, v_next_surf);
            }

            // assemble the clusters
            List <List <SurfaceBasicInfo> > clusters_alignment = NeighborhoodGraph.AssembleClusters(surf_clusters);

            // debug
            string debug = string.Empty;

            foreach (List <SurfaceBasicInfo> cluster in clusters_alignment)
            {
                if (cluster.Count < 2)
                {
                    continue;
                }
                foreach (SurfaceBasicInfo sbi in cluster)
                {
                    debug += sbi.ToString() + "\n";
                }
                debug += "\n";
            }
            string test = debug;

            // --------------------------------------- OVERLAPPING ---------------------------------------------

            // start overlap testing in each cluster
            this.ClearGraph();
            List <SurfaceMatch> overlaps_all = new List <SurfaceMatch>();

            foreach (List <SurfaceBasicInfo> cluster in clusters_alignment)
            {
                if (cluster.Count < 2)
                {
                    continue;
                }

                List <SurfaceMatch> overlaps = NeighborhoodGraph.FindOverlaps(cluster, this.MaxOverlapError);
                overlaps_all.AddRange(overlaps);
            }
            this.AddToGraph(overlaps_all);
        }