private void ContainedEnditiesToGeometryDef() { // reset this.outer_polygon_index = -1; this.polygon = null; this.holes = null; // convert the contained entities into a list of coordinates float level_height = 0f; List <List <Point3D> > coordinates = new List <List <Point3D> >(); foreach (Entity e in this.ContainedEntities) { ZonedPolygon zp = e as ZonedPolygon; if (zp != null && zp.Polygon_Coords.Count > 0) { level_height = Math.Max(level_height, zp.Height); coordinates.Add(zp.Polygon_Coords); } } this.Height = level_height; MeshesCustom.ToPolygonWithHoles(coordinates, Orientation.XZ, out this.outer_polygon_index, out this.polygon, out this.holes); }
internal void AddReconstructedOpeningToZonedPolygon(ZonedPolygon _zp, int _id, string _name, int _ind_in_poly, Vector3D _v_prev, Vector3D _v_next, Vector3D _poly_wallT, Vector3D _poly_wallT_adj, float _dist_from_v_prev, float _len_along_segm, float _dist_from_poly, float _height_along_wallT) { if (_zp == null) { return; } _zp.AddParsedOpening(_id, _name, _ind_in_poly, _v_prev, _v_next, _poly_wallT, _poly_wallT_adj, _dist_from_v_prev, _len_along_segm, _dist_from_poly, _height_along_wallT); }
public ZoneOpeningVis(ZonedPolygon _ownerP, int _indInOwner, int _idInOwner, Layer _layer, float _distFromVertex, float _length, float _distFromFloorPolygon, float _height) : base(_layer) { // ownership this.OwnerPolygon = _ownerP; this.IndInOwner = _indInOwner; this.idInOwner = _idInOwner; // position and size this.DistFromVertex = _distFromVertex; this.Length = _length; this.DistFromFloorPolygon = _distFromFloorPolygon; this.Height = _height; }
public void ReleasePolygons() { int n = this.ContainedEntities.Count; for (int i = 0; i < n; i++) { ZonedPolygon zp = this.ContainedEntities[i] as ZonedPolygon; if (zp == null) { continue; } zp.ResetAllOpeningPolygonNormals(); zp.PropertyChanged -= polygon_PropertyChanged; } this.ContainedEntities = null; }
internal ZonedPolygonGroup ReconstructZonedLevel(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, List <long> _zoned_polygon_ids) { // find all polygons contained in the group (level) if (_zoned_polygon_ids == null) { return(null); } if (_zoned_polygon_ids.Count < 1) { return(null); } List <ZonedPolygon> level_polygons = new List <ZonedPolygon>(); foreach (long id in _zoned_polygon_ids) { GeometricEntity ge_found = this.parsed_GE_before_adding_to_Layer.FirstOrDefault(x => x.ID == id); if (ge_found == null) { continue; } ZonedPolygon zp_found = ge_found as ZonedPolygon; if (zp_found == null) { continue; } level_polygons.Add(zp_found); } if (level_polygons.Count < 1) { return(null); } // reconstruct the grouop (level) ZonedPolygonGroup created = new ZonedPolygonGroup(_id, _name, _color, _vis, _is_valid, _assoc_w_comp, _line_thickness_GUI, _mLtext, _is_top_closure, _is_bottom_closure, level_polygons); Entity.Nr_Entities = Math.Max(Entity.Nr_Entities, _id) + 1; return(created); }
public List <ZonedPolygon> ExtractZonedPolygons() { List <ZonedPolygon> polygons = new List <ZonedPolygon>(); int n = this.ContainedEntities.Count; for (int i = 0; i < n; i++) { ZonedPolygon zp = this.ContainedEntities[i] as ZonedPolygon; if (zp == null) { continue; } polygons.Add(zp); } return(polygons); }
////////////////////////////////////////////////////////////////////////////////////////////////////////////// // =============================================== CLASS METHODS ========================================== // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region EVENT HANDLER: Polygons void polygon_PropertyChanged(object sender, PropertyChangedEventArgs e) { ZonedPolygon zp = sender as ZonedPolygon; if (e == null || zp == null) { return; } if (e.PropertyName == "EditModeType") { if (zp.EditModeType == ZonePolygonEditModeType.NONE) { // polygon returning from editing if (zp.GeometryChanged) { // reset geometry this.Fill = null; this.IsDirty = true; } this.OpeningsDirty = zp.OpeningsChanged; } else if (zp.EditModeType == ZonePolygonEditModeType.OPENING_ADD || zp.EditModeType == ZonePolygonEditModeType.OPENING_REMOVE) { this.OpeningsDirty = false; } else if (zp.EditModeType == ZonePolygonEditModeType.ISBEING_DELETED) { // remove polygon from the definition this.ContainedEntities.Remove(zp); if (this.ContainedEntities.Count < 1) { this.IsValid = false; } // reset geometry this.Fill = null; this.IsDirty = true; } } }
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); }
internal ZonedPolygon ReconstructZonedPolygon(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 <Point3D> _coords, float _height, List <int> _zone_inds) { // create the polygon ZonedPolygon zp = new ZonedPolygon(_id, _name, _color, _vis, _is_valid, _assoc_w_comp, _line_thickness_GUI, _mLtext, _is_top_closure, _is_bottom_closure, _layer, _color_by_layer, _coords, _height); if (_zone_inds != null && _zone_inds.Count == _coords.Count) { zp.ReDefineAllZones(_zone_inds); } Entity.Nr_Entities = Math.Max(Entity.Nr_Entities, _id) + 1; // setting the layer adds the ZonedPolygon to the ContainedEntities of its layer // (see DXFLayer and Property GeometricEntity.EnitiyLayer) // add to temporary container this.parsed_GE_before_adding_to_Layer.Add(zp); return(zp); }
public void CalculateAvgHeight() { this.avg_height = 0.0; if (this.ContainedEntities == null) { return; } int n = this.ContainedEntities.Count; foreach (Entity e in this.ContainedEntities) { ZonedPolygon zp = e as ZonedPolygon; if (zp == null) { continue; } this.avg_height += zp.GetPivot().Y; } this.avg_height /= n; }
public ZonedPolygonVertexVis(ZonedPolygon _owner, int _indInOwner, Layer _layer, Vector3 _position, Vector3 _moveLimitForward, Vector3 _moveLimitBackward) : base(_layer) { this.Owner = _owner; this.AdjustToPolygonChange(_indInOwner, _position, _moveLimitForward, _moveLimitBackward); }
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; } } }
internal void ResetStaticCounters() { Entity.Nr_Entities = 0; ZonedPolygon.ResetZoneOpeningCounter(); this.parsed_GE_before_adding_to_Layer = new List <GeometricEntity>(); }