/// <summary>
            /// Построить граненный стакан в САПР Компас 3D.
            /// </summary>
            /// <param name="glass">Граненный стакан.</param>
            public void Build(IGlass glass)
            {
                _builderBlank.Build(glass);

                _startX = 0;
                _startY = 0;

                _glass      = glass;
                _calcParams = new CalcParams(glass);

                var doc = _kompas.ActiveDocument3D;

                var part = (ksPart)doc.GetPart((short)Part_Type.pTop_Part);

                var basePlane = (ksEntity)part.GetDefaultEntity(
                    (short)Obj3dType.o3d_planeXOY);

                var offsetCutFacetedPlane = _kompas.CreateOffsetPlane(
                    part, basePlane, _calcParams.OffsetFacetedPlane);

                var sketchCutFaceted = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchCutFaceted.name = "Эскиз граней";

                var sketchDefCutFaceted =
                    (ksSketchDefinition)sketchCutFaceted.GetDefinition();

                sketchDefCutFaceted.SetPlane(offsetCutFacetedPlane);

                sketchCutFaceted.Create();

                GenerateCutFaceted2d(sketchDefCutFaceted);
                GenerateCutFaceted3d(sketchCutFaceted, part);
            }
Exemple #2
0
            /// <summary>
            /// Сгладить дно и горлышко болванки стакана.
            /// </summary>
            /// <param name="glass">Параметры стакана.</param>
            /// <param name="part">Сборка детали.</param>
            private void FilletedBottomAndTop(IGlass glass, ksPart part)
            {
                //дно стакана
                var rBottom     = glass.DiameterBottom / 2;
                var pointBottom = new Point3D(_startX, rBottom, 0);
                var edge0       = _kompas.FindIntersectionPointWithEdge(
                    part, pointBottom);

                _kompas.FilletedOnEdge(part, edge0,
                                       _calcParams.RadiusBottomFilleted);

                //с внешней стороны диаметр горлышка
                var pointTop = new Point3D(_startX,
                                           _calcParams.DiameterTop / 2, glass.Height);
                var edge = _kompas.FindIntersectionPointWithEdge(
                    part, pointTop);

                _kompas.FilletedOnEdge(part, edge,
                                       _calcParams.RadiusTopFilleted);

                //с внутренней стороны диаметр горлышка
                //  (вырезаемых внутренностей)
                var pointTop2 = new Point3D(_startX,
                                            _calcParams.DiameterSideCutting / 2, glass.Height);
                var edge2 = _kompas.FindIntersectionPointWithEdge(
                    part, pointTop2);

                _kompas.FilletedOnEdge(part, edge2,
                                       _calcParams.RadiusTopFilleted);
            }
        /// <summary>
        /// Инициализация представление стакана
        /// </summary>
        /// <param name="glass">Стакан</param>
        /// <param name="name">Название стакана</param>
        public GlassViewModel(IGlass glass, IBuilder builder, string name)
        {
            _glass   = glass;
            _name    = name;
            _builder = builder;

            var prop = _glass.Properties;

            _properties = new List <Tuple <string, bool, string> >
            {
                new Tuple <string, bool, string>(_labelHeight.Item1,
                                                 prop.Height, _labelHeight.Item2),
                new Tuple <string, bool, string>(_labelDiameterBottom.Item1,
                                                 prop.DiameterBottom, _labelDiameterBottom.Item2),
                new Tuple <string, bool, string>(_labelAngleHeight.Item1,
                                                 prop.AngleHeight, _labelAngleHeight.Item2),
                new Tuple <string, bool, string>(_labelDepthSide.Item1,
                                                 prop.DepthSide, _labelDepthSide.Item2),
                new Tuple <string, bool, string>(_labelDepthBottom.Item1,
                                                 prop.DepthBottom, _labelDepthBottom.Item2),
                new Tuple <string, bool, string>(_labelCountFaceted.Item1,
                                                 prop.CountFaceted, _labelCountFaceted.Item2),
                new Tuple <string, bool, string>(_labelHeightFaceted.Item1,
                                                 prop.HeightFaceted, _labelHeightFaceted.Item2),
            };
        }
Exemple #4
0
 public BeerDataModel(IGlass glass, ISrm srm, IStyle style, ILabels labels)
 {
     Glass  = glass;
     Srm    = srm;
     Style  = style;
     Labels = labels;
 }
            /// <summary>
            /// Построить гофрированный стакан.
            /// </summary>
            /// <param name="glass">Гофрированный стакан.</param>
            public void Build(IGlass glass)
            {
                _builderBlank.Build(glass);

                _glass      = glass;
                _calcParams = new CalcParams(glass);

                var doc = _kompas.ActiveDocument3D;

                var part = (ksPart)doc.GetPart(
                    (short)Part_Type.pTop_Part);

                var basePlane = (ksEntity)part.GetDefaultEntity(
                    (short)Obj3dType.o3d_planeXOY);

                var offsetCrimpPlane = _kompas.CreateOffsetPlane(
                    part, basePlane, _calcParams.OffsetFacetedPlane);

                var sketchCrimp = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchCrimp.name = "Эскиз рефлёностей";

                var sketchDefCrimp =
                    (ksSketchDefinition)sketchCrimp.GetDefinition();

                sketchDefCrimp.SetPlane(offsetCrimpPlane);

                sketchCrimp.Create();

                GenerateExtrusionCrimp2d(sketchDefCrimp);
                GenerateExtrusionCrimp3d(sketchCrimp, part);
            }
        /// <summary>
        /// Проверяет автовычисляемые параметры стакана
        /// </summary>
        /// <param name="exp">Массив ожидаемых автовычисляемых
        ///     параметров стакана</param>
        /// <param name="glass">Проверяемый стакан</param>
        public static void CheckAutoCalcParamsOfGlass(bool[] exp,
                                                      IGlass glass)
        {
            var was = CreateArrayAutoCalcParams(
                glass.Properties);

            Assert.That(exp, Is.EqualTo(was));
        }
 public Beer(IGlass glass, ISrm srm, IAvailable available, IStyle style, List <Brewery> breweries, ILabels labels,
             List <SocialAccount> socialAccounts)
 {
     Glass     = glass;
     Srm       = srm;
     Available = available;
     Style     = style;
     Breweries = breweries;
     Labels    = labels;
 }
Exemple #8
0
        public Beer(IGlass glass, ISrm srm, IAvailable available, IStyle style, List<Brewery> breweries, ILabels labels,
            List<SocialAccount> socialAccounts)
        {
            Glass = glass;
            Srm = srm;
            Available = available;
            Style = style;
            Breweries = breweries;
            Labels = labels;

        } 
        public void CheckCalculateParams(IGlass glass)
        {
            var actual = new CalcParams(glass);
            var exp    = new CalcParamsFake(glass);

            Assert.That(exp.DiameterFacetedStart,
                        Is.EqualTo(actual.DiameterFacetedStart),
                        "DiameterFacetedStart");
            Assert.That(exp.DiameterSideCutting,
                        Is.EqualTo(actual.DiameterSideCutting),
                        "DiameterSideCutting");
            Assert.That(exp.DiameterStripsCrimp,
                        Is.EqualTo(actual.DiameterStripsCrimp),
                        "DiameterStripsCrimp");
            Assert.That(exp.HeightCutting,
                        Is.EqualTo(actual.HeightCutting),
                        "HeightCutting");
            Assert.That(exp.OffsetFacetedPlane,
                        Is.EqualTo(actual.OffsetFacetedPlane),
                        "OffsetFacetedPlane");
        }
        /// <summary>
        /// Вычисление параметров стакана
        ///     для работы алгоритма построения.
        /// </summary>
        /// <param name="glass">Стакан для построения.</param>
        public CalcParamsFake(IGlass glass)
        {
            _offsetFacetedPlane =
                glass.Height / 2 + glass.HeightFaceted / 2;

            var angleRad = glass.AngleHeight * System.Math.PI / 180;
            var tanRad   = System.Math.Tan(angleRad);

            _diameterFacetedStart = 2 * _offsetFacetedPlane * tanRad
                                    + glass.DiameterBottom;

            DiameterTop = 2 * glass.Height * tanRad
                          + glass.DiameterBottom;
            _diameterSideCutting = DiameterTop *
                                   (100 - glass.DepthSide) / 100;

            var diameterCutSide = _diameterFacetedStart *
                                  (100 - glass.DepthSide / 1.5) / 100;

            _diameterStripsCrimp = _diameterFacetedStart
                                   - diameterCutSide;

            _heightCutting = glass.Height *
                             (100 - glass.DepthBottom) / 100;

            var filletedTop = DiameterTop *
                              (1 - (100 - glass.DepthSide / 2) / 100);

            //Так как сглаживание горылшка происходит с двух сторон,
            //  то делим толщину стенки на два
            RadiusTopFilleted = filletedTop / 2;

            var delta = _offsetFacetedPlane;

            if (glass.HeightFaceted == 0)
            {
                delta = glass.Height * _percentFilletedBottom / 100;
            }
            RadiusBottomFilleted = (glass.Height - delta);
        }
Exemple #11
0
 public DbBeer(IGlass glass, ISrm srm, IAvailable available, IStyle style, List <Brewery> breweries, ILabels labels, List <SocialAccount> socialAccounts) : base(glass, srm, available, style, breweries, labels, socialAccounts)
 {
 }
Exemple #12
0
            /// <summary>
            /// Построить модель стакана в САПР Компас 3D.
            /// </summary>
            /// <param name="photoFrame">Шаблон стакана.</param>
            /// <exception cref="InvalidOperationException">
            ///     Вызывается тогда, когда параметры стакана
            ///     имеют недопустимые значения.</exception>
            public void Build(IGlass glass)
            {
                if (glass.IsValid == false)
                {
                    var msg = String.Format("Шаблон стакана имеет" +
                                            " недопустимые параметры для построения.");
                    throw new InvalidOperationException(msg);
                }

                _kompas.ShowCAD();

                _startX = 0;
                _startY = 0;

                _glass      = glass;
                _calcParams = new CalcParams(glass);

                var doc = _kompas.Document3D;

                doc.Create();

                var part = (ksPart)doc.GetPart((short)Part_Type.pTop_Part);

                var sketchBase = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchBase.name = "Эскиз основания";

                var basePlane = (ksEntity)part.GetDefaultEntity(
                    (short)Obj3dType.o3d_planeXOY);

                var sketchDefBase =
                    (ksSketchDefinition)sketchBase.GetDefinition();

                sketchDefBase.SetPlane(basePlane);

                sketchBase.Create();

                var sketchCutSide = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchCutSide.name = "Эскиз вырезанных внутренностей";

                var offsetCutPlane = _kompas.CreateOffsetPlane(
                    part, basePlane, glass.Height);

                var sketchDefCutSide =
                    (ksSketchDefinition)sketchCutSide.GetDefinition();

                sketchDefCutSide.SetPlane(offsetCutPlane);

                sketchCutSide.Create();

                GenerateBlank2d(sketchDefBase);
                GenerateBlank3d(sketchBase, part);
                GenerateCutSide2d(sketchDefCutSide);
                GenerateCutSide3d(sketchCutSide, part);

                if (glass.Filleted)
                {
                    FilletedBottomAndTop(glass, part);
                }
            }
Exemple #13
0
        public bool BaseRunEx()
        {
            mRelationship = Relationship.Get(Actor, Target, true);
            if (mRelationship == null)
            {
                return(false);
            }
            bool flag = false;

            if (IsSlowDance)
            {
                string reason;
                GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                if (CommonSocials.CanGetRomantic(Actor, Target, false, false, true, ref greyedOutTooltipCallback, out reason))
                {
                    flag = true;
                }
            }
            else
            {
                foreach (CommodityTypes types in kAcceptableCommodities)
                {
                    if (mRelationship.STC.CurrentCommodity == types)
                    {
                        flag = true;
                        break;
                    }
                }
            }

            Definition interactionDefinition = InteractionDefinition as Definition;
            IDanceable danceObject           = interactionDefinition.DanceObject;

            if (flag)
            {
                mDanceFloor = DanceFloor.FindAndRouteOntoADanceFloorWithFollower(Actor, Target, danceObject);
                if (mDanceFloor != null)
                {
                    mDanceFloor.AddToUseList(Actor);
                    if (!mDanceFloor.IsActorUsingMe(Target))
                    {
                        mDanceFloor.AddToUseList(Target);
                    }
                }
            }

            Stereo targetStereo = interactionDefinition.TargetStereo;

            if (targetStereo != null)
            {
                targetStereo.AddSimListener(Actor);
                targetStereo.AddSimListener(Target);
            }

            string         instanceName = "SocialJigTwoPerson";
            ProductVersion baseGame     = ProductVersion.BaseGame;

            if (IsSlowDance)
            {
                instanceName = "SlowdanceJig";
                baseGame     = ProductVersion.EP8;
            }

            SocialJig = GlobalFunctions.CreateObjectOutOfWorld(instanceName, baseGame) as SocialJigTwoPerson;
            bool succeeded = false;

            Actor.SynchronizationLevel  = Sim.SyncLevel.NotStarted;
            Target.SynchronizationLevel = Sim.SyncLevel.NotStarted;
            string name = (Stereo.PartySimIsGettingMusicFromPartyLocation(Actor, danceObject) || Stereo.PartySimIsGettingMusicFromPartyLocation(Target, danceObject)) ? LocalizeString("BeRockingDancingTogether", new object[0x0]) : LocalizeString("BeDancingTogether", new object[0x0]);

            if (BeginSocialInteraction(new SocialInteractionB.Definition(null, name, false), true, false))
            {
                IGlass objectInRightHand = Actor.GetObjectInRightHand() as IGlass;
                if (objectInRightHand != null)
                {
                    objectInRightHand.PutGlassAway();
                }
                objectInRightHand = Target.GetObjectInRightHand() as IGlass;
                if (objectInRightHand != null)
                {
                    objectInRightHand.PutGlassAway();
                }

                string             stateMachineName = IsSlowDance ? "slowdance_together" : "dance_together";
                StateMachineClient smc = StateMachineClient.Acquire(Actor, stateMachineName);
                if (IsSlowDance)
                {
                    smc.SetActor("x", Actor);
                    smc.SetActor("y", Target);
                }
                else
                {
                    smc.SetActor("x", Target);
                    smc.SetActor("y", Actor);
                }
                smc.EnterState("x", "enter");
                smc.EnterState("y", "enter");
                if (GameUtils.IsInstalled(ProductVersion.EP7))
                {
                    smc.SetParameter("xIsProper", Target.HasTrait(TraitNames.Proper));
                    smc.SetParameter("yIsProper", Actor.HasTrait(TraitNames.Proper));
                }
                BeginCommodityUpdates();
                smc.RequestState(false, "x", "Ask_To_Dance");
                smc.RequestState(true, "y", "Ask_To_Dance");
                if (flag)
                {
                    smc.RequestState(false, "x", "Last_Sync");
                    smc.RequestState(true, "y", "Last_Sync");
                    smc.RequestState(false, "x", "dance");
                    smc.RequestState(true, "y", "dance");
                    Actor.SkillManager.StartGainAndAddSkillIfNeeded(SkillNames.Dancing, Stereo.kRateOfSkillGainForDancing);
                    Target.SkillManager.StartGainAndAddSkillIfNeeded(SkillNames.Dancing, Stereo.kRateOfSkillGainForDancing);
                    if (IsSlowDance)
                    {
                        EventTracker.SendEvent(EventTypeId.kSlowDanced, Actor, Target);
                        EventTracker.SendEvent(EventTypeId.kSlowDanced, Target, Actor);
                    }
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), new InteractionInstance.InsideLoopFunction(DanceTogetherDelegate), smc);
                    Actor.SkillManager.StopSkillGain(SkillNames.Dancing);
                    Target.SkillManager.StopSkillGain(SkillNames.Dancing);
                    smc.RequestState(false, "x", "friendly");
                    smc.RequestState(true, "y", "friendly");
                }
                else
                {
                    smc.RequestState(false, "x", "awkward");
                    smc.RequestState(true, "y", "awkward");
                    mRelationship.LTR.UpdateLiking(Stereo.kLtrDecreaseAfterRejectingDanceTogether);
                    succeeded = false;
                }
            }

            Definition definition2 = InteractionDefinition as Definition;

            if ((definition2 != null) && (definition2.DanceObject is DJTurntable))
            {
                EventTracker.SendEvent(EventTypeId.kDanceToDJMusic, Target);
                EventTracker.SendEvent(EventTypeId.kDanceToDJMusic, Actor);
            }

            EndCommodityUpdates(succeeded);
            Actor.ClearSynchronizationData();
            return(succeeded);
        }
 public void PutGlass(IGlass glass)
 {
     Console.WriteLine("Putting glass");
     glass1 = glass;
 }
Exemple #15
0
 /// <summary>
 /// Построить гладкий стакан.
 /// </summary>
 /// <param name="glass">Гладкий стакан.</param>
 public void Build(IGlass glass)
 {
     _builderBlank.Build(glass);
 }