Example #1
0
        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);
        }
        public static Relation2GeomState Next(Relation2GeomState _prev_state)
        {
            if (_prev_state.IsRealized)
            {
                // no change
                return new Relation2GeomState {
                           IsRealized = true, Type = _prev_state.Type
                }
            }
            ;
            else
            {
                switch (_prev_state.Type)
                {
                case Relation2GeomType.NONE:
                    return(new Relation2GeomState {
                        IsRealized = false, Type = Relation2GeomType.DESCRIBES
                    });

                case Relation2GeomType.DESCRIBES:
                    return(new Relation2GeomState {
                        IsRealized = false, Type = Relation2GeomType.ALIGNED_WITH
                    });

                case Relation2GeomType.ALIGNED_WITH:
                    return(new Relation2GeomState {
                        IsRealized = false, Type = Relation2GeomType.CONTAINED_IN
                    });

                case Relation2GeomType.CONTAINED_IN:
                    return(new Relation2GeomState {
                        IsRealized = false, Type = Relation2GeomType.CONNECTS
                    });

                case Relation2GeomType.CONNECTS:
                    return(new Relation2GeomState {
                        IsRealized = false, Type = Relation2GeomType.GROUPS
                    });

                case Relation2GeomType.DESCRIBES_3D:
                case Relation2GeomType.DESCRIBES_2DorLESS:
                case Relation2GeomType.GROUPS:
                    return(new Relation2GeomState {
                        IsRealized = false, Type = Relation2GeomType.NONE
                    });

                default:
                    return(new Relation2GeomState {
                        IsRealized = false, Type = Relation2GeomType.NONE
                    });
                }
            }
        }
Example #3
0
        internal GeometricRelationship(long _id, string _name, Relation2GeomState _state, Point4D _ids,
                                       Matrix3D _cs, Matrix3D _tr_WC2LC, Matrix3D _tr_LC2WC)
        {
            this.ID = _id;
            GeometricRelationship.NR_GEOMETRICRELATIONSHIPS = Math.Max(GeometricRelationship.NR_GEOMETRICRELATIONSHIPS, _id);

            this.Name      = _name;
            this.State     = _state;
            this.GeomIDs   = _ids;
            this.GeomCS    = _cs;
            this.TRm_WC2LC = _tr_WC2LC;
            this.TRm_LC2WC = _tr_LC2WC;
        }
Example #4
0
        internal GeometricRelationship(long _id, string _name, Relation2GeomState _state, Point4D _ids,
                                       Matrix3D _cs, Matrix3D _tr_WC2LC, Matrix3D _tr_LC2WC,
                                       List <double> _i_size, List <GeomSizeTransferDef> _i_size_tr, long _i_nwe_id, string _i_nwe_name, List <Point3D> _i_path)
        {
            this.ID = _id;
            GeometricRelationship.NR_GEOMETRICRELATIONSHIPS = Math.Max(GeometricRelationship.NR_GEOMETRICRELATIONSHIPS, _id);

            this.Name      = _name;
            this.State     = _state;
            this.GeomIDs   = _ids;
            this.GeomCS    = _cs;
            this.TRm_WC2LC = _tr_WC2LC;
            this.TRm_LC2WC = _tr_LC2WC;

            this.InstanceSize          = new List <double>(_i_size);
            this.InstanceNWElementID   = _i_nwe_id;
            this.InstanceNWElementName = _i_nwe_name;
            this.InstancePath          = new List <Point3D>(_i_path);
            this.InstanceParamValues   = new Dictionary <string, double>(); // transient!

            // last, so that everything is transferred after initialization
            if (_i_size_tr != null && _i_size_tr.Count > 5)
            {
                this.InstanceSizeTransferSettings = new List <GeomSizeTransferDef>(_i_size_tr); // setter calls snychronization with size
            }
            else
            {
                // LEGACY HELPER: for earlier versions of GeometricRelationships w/o transfer settings
                this.instance_size_transfer_settings = new List <GeomSizeTransferDef>();
                for (int i = 0; i < 6; i++)
                {
                    this.instance_size_transfer_settings.Add(new GeomSizeTransferDef
                    {
                        Source        = GeomSizeTransferSource.USER,
                        ParameterName = string.Empty,
                        Correction    = 0.0,
                        InitialValue  = 0.0
                    });
                }
            }

            // LEGACY HELPER: for connecting GR w/o check for IsRealized after the placement of the sart and end contained_in instances
            // ???
        }
Example #5
0
        public GeometricRelationship(string _name, Relation2GeomState _state, Point4D _ids, Matrix3D _cs, Matrix3D _tr_WC2LC, Matrix3D _tr_LC2WC)
        {
            // general
            this.ID        = (++GeometricRelationship.NR_GEOMETRICRELATIONSHIPS);
            this.Name      = (string.IsNullOrEmpty(_name)) ? "Geometry" : _name;
            this.State     = _state;
            this.GeomIDs   = _ids;
            this.GeomCS    = _cs;
            this.TRm_WC2LC = _tr_WC2LC;
            this.TRm_LC2WC = _tr_LC2WC;

            // instance information
            this.instance_size = new List <double>();
            this.instance_size_transfer_settings = new List <GeomSizeTransferDef>();
            this.instance_nwe_id     = -1L;
            this.instance_nwe_name   = "NW_Element";
            this.InstancePath        = new List <Point3D>();
            this.InstanceParamValues = new Dictionary <string, double>(); // transient!

            this.UpdateState = GeometricRelationshipUpdateState.NEUTRAL;
        }
Example #6
0
        internal void Reset()
        {
            // general
            Relation2GeomState state_old = this.State;

            this.state = new Relation2GeomState {
                IsRealized = false, Type = state_old.Type
            };
            this.GeomIDs   = new Point4D(-1, -1, -1, -1);
            this.GeomCS    = Matrix3D.Identity;
            this.TRm_WC2LC = Matrix3D.Identity;
            this.TRm_LC2WC = Matrix3D.Identity;

            // instance information
            this.instance_size = new List <double>();
            this.instance_size_transfer_settings = new List <GeomSizeTransferDef>();
            this.instance_nwe_id     = -1L;
            this.instance_nwe_name   = "NW_Element";
            this.InstancePath        = new List <Point3D>();
            this.InstanceParamValues = new Dictionary <string, double>(); // transient!

            this.UpdateState = GeometricRelationshipUpdateState.NEUTRAL;
        }
        }                                           // default value = NONE

        public Relation2GeomState(Relation2GeomState _state)
            : this()
        {
            this.IsRealized = _state.IsRealized;
            this.Type       = _state.Type;
        }
Example #8
0
 public GeometricRelationship(string _name, Relation2GeomState _state, Point4D _ids)
     : this(_name, _state, _ids, Matrix3D.Identity, Matrix3D.Identity, Matrix3D.Identity)
 {
 }