internal static GeometricRelationship CreateAndPlaceInFlowNetworkElement(Component.FlNetElement _nwe, System.Windows.Point _offset, double _scale, Dictionary <string, double> _params) { if (_nwe == null) { return(null); } Relation2GeomState gr_state = new Relation2GeomState { IsRealized = false, Type = (_nwe is Component.FlNetEdge) ? Relation2GeomType.CONNECTS : Relation2GeomType.CONTAINED_IN }; List <Point3D> gr_path; Matrix3D gr_ucs; GeometricRelationship.DeriveGeomPositionOutOfPlacementIn(_nwe, _offset, _scale, out gr_ucs, out gr_path); GeometricRelationship gr_placement = new GeometricRelationship("placement", gr_state, new Point4D(-1, -1, -1, -1), gr_ucs, Matrix3D.Identity, Matrix3D.Identity); // todo: adjust the transforms... gr_placement.instance_size = new List <double> { 0, 0, 0, 0, 0, 0 }; gr_placement.instance_size_transfer_settings = new List <GeomSizeTransferDef>(); gr_placement.instance_nwe_id = _nwe.ID; gr_placement.instance_nwe_name = _nwe.Name; gr_placement.InstancePath = gr_path; gr_placement.InstanceParamValues = (_params == null) ? new Dictionary <string, double>() : new Dictionary <string, double>(_params); return(gr_placement); }
internal void PlaceInFlowNetworkElement(Component.FlNetElement _nwe, System.Windows.Point _offset, double _scale, List <double> _sizes, Dictionary <string, double> _params) { if (this.State.IsRealized) { return; } if (_nwe == null || _sizes == null || _params == null) { return; } if (_sizes.Count < 6) { return; } List <Point3D> gr_path; Matrix3D gr_ucs; GeometricRelationship.DeriveGeomPositionOutOfPlacementIn(_nwe, _offset, _scale, out gr_ucs, out gr_path); this.GeomCS = gr_ucs; if (this.State.Type == Relation2GeomType.CONNECTS) { this.InstancePath = gr_path; } this.InstanceNWElementID = _nwe.ID; this.InstanceNWElementName = _nwe.Name; this.InstanceSize = new List <double>(_sizes); this.instance_size_transfer_settings = new List <GeomSizeTransferDef>(); // per default NONE (i.e. direct user input into the InstanceSize list) this.InstanceParamValues = new Dictionary <string, double>(_params); }
internal static void UpdateConnectivityBasedRelaization(GeometricRelationship _n1, GeometricRelationship _n2, ref GeometricRelationship _connector) { if (_n1 == null || _n2 == null || _connector == null) { return; } if (_n1.State.Type == Geometry.Relation2GeomType.CONTAINED_IN && _n2.State.Type == Geometry.Relation2GeomType.CONTAINED_IN && _connector.State.Type == Geometry.Relation2GeomType.CONNECTS) { if (_n1.State.IsRealized && _n2.State.IsRealized) { _connector.State = new Relation2GeomState { Type = Geometry.Relation2GeomType.CONNECTS, IsRealized = true } } ; else { _connector.State = new Relation2GeomState { Type = Geometry.Relation2GeomType.CONNECTS, IsRealized = false } }; } } #endregion }
/// <summary> /// <para>Updates the local coordinate system if _nwe is a node.</para> /// <para>If _nwe is an edge, it also updates the path. If the geometric relationship is already realized nothing changes.</para> /// </summary> internal void UpdatePositionFrom(Component.FlNetElement _nwe, System.Windows.Point _offset, double _scale) { if (this.State.IsRealized) { return; } if (_nwe == null) { return; } List <Point3D> gr_path; Matrix3D gr_ucs; GeometricRelationship.DeriveGeomPositionOutOfPlacementIn(_nwe, _offset, _scale, out gr_ucs, out gr_path); this.GeomCS = gr_ucs; if (this.State.Type == Relation2GeomType.CONNECTS) { this.InstancePath = gr_path; } }
public static bool ReferenceSameGeometry(GeometricRelationship _gr1, GeometricRelationship _gr2) { if (_gr1 == null || _gr2 == null) { return(false); } if (_gr1.State.Type != _gr2.State.Type) { return(false); } if (!_gr1.State.IsRealized || !_gr2.State.IsRealized) { return(false); } switch (_gr1.State.Type) { case Relation2GeomType.DESCRIBES_3D: case Relation2GeomType.GROUPS: return(_gr1.GeomIDs.X == _gr2.GeomIDs.X); case Relation2GeomType.DESCRIBES_2DorLESS: return(_gr1.GeomIDs.X == _gr2.GeomIDs.X && _gr1.GeomIDs.Y == _gr2.GeomIDs.Y); case Relation2GeomType.ALIGNED_WITH: case Relation2GeomType.CONTAINED_IN: case Relation2GeomType.CONNECTS: return(_gr1.GeomIDs.X == _gr2.GeomIDs.X && _gr1.GeomIDs.Y == _gr2.GeomIDs.Y && _gr1.GeomIDs.Z == _gr2.GeomIDs.Z); default: return(false); } }