Exemplo n.º 1
0
        void buildParmsFromValues()
        {
            try
            {
                meshSize    = .003;
                jetDiameter = .110;
                double nominalSurfaceSpeed = 50.0;
                double depthPerPass        = .005;
                int    runs          = 10;
                int    iterations    = 1;
                int    equationIndex = 4;
                double searchRadius  = jetDiameter * .1;

                var jet         = new AbMachJet(meshSize, jetDiameter, equationIndex);
                var runInfo     = new RunInfo(runs, iterations, ModelRunType.RunAsIs);
                var removalRate = new RemovalRate(nominalSurfaceSpeed, depthPerPass);
                var depthInfo   = new DepthInfo(new Vector3(.456, .8254, 0), DepthSearchType.FindAveDepth, searchRadius);
                var op          = AbMachOperation.ROCKETCHANNEL;
                var mat         = new Material(
                    MaterialType.Metal,
                    "Aluminum",
                    thickness: .25,
                    millMachinabilityIndex: 1,
                    cutMachinabilityIndex: 1,
                    criticalAngleRadians: Math.PI * 70.0 / 180);
                parms = AbMachParamBuilder.Build(op, runInfo, removalRate, mat, jet, depthInfo, meshSize);
                AbMachParametersFile.Save(parms, "params.xml");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        public void paramFile_openSavedFile_parmsOK()
        {
            double meshSize            = .005;
            double diameter            = .04;
            double nominalSurfaceSpeed = 40;
            double depthPerPass        = .001;
            int    runs          = 3;
            int    iterations    = 1;
            int    equationIndex = 2;

            var jet         = new AbMachJet(diameter, equationIndex);
            var runInfo     = new RunInfo(runs, iterations, ModelRunType.NewFeedrates);
            var removalRate = new RemovalRate(nominalSurfaceSpeed, depthPerPass);
            var depthInfo   = new DepthInfo(new GeometryLib.Vector3(1, 1, 0), DepthSearchType.FindAveDepth, diameter / 10);
            var op          = AbMachOperation.ROCKETCHANNEL;
            var mat         = new AWJModel.Material(AWJModel.MaterialType.Metal, "Aluminum", .25, 123, 456, 789, 143, 345, 543, 1);

            AbMachParameters parms    = AbMachParamBuilder.Build(op, runInfo, removalRate, mat, jet, depthInfo, meshSize);
            string           fileName = "paramSaveTest.prx";

            AbMachParametersFile.Save(parms, fileName);
            AbMachParameters parmsOpen = AbMachParametersFile.Open(fileName);

            Assert.AreEqual(parms.Material.CriticalRemovalAngle, parmsOpen.Material.CriticalRemovalAngle);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a copy of this depth info instance.
        /// </summary>
        /// <returns></returns>
        internal DepthInfo Copy()
        {
            DepthInfo copy = new DepthInfo
            {
                CurrentDepth     = this.CurrentDepth,
                MaxDepth         = this.MaxDepth,
                MaxDepthExceeded = this.MaxDepthExceeded
            };

            return(copy);
        }
Exemplo n.º 4
0
        public static void Add(TrackableId trackableId, Pose pose, TrackingState trackingState)
        {
            lock (stateLock)
            {
                var tmp = new DepthInfo()
                {
                    trackableId   = trackableId,
                    pose          = pose,
                    trackingState = trackingState
                };

                all[trackableId] = tmp;
                added.Add(tmp);
            }
        }
Exemplo n.º 5
0
        void initParms()
        {
            meshSize = .005;
            diameter = .04;
            double nominalSurfaceSpeed = 40;
            double depthPerPass        = .001;
            int    runs          = 1;
            int    iterations    = 1;
            int    equationIndex = 2;
            double searchRadius  = diameter * .1;
            var    jet           = new AbMachJet(diameter, equationIndex);
            var    runInfo       = new RunInfo(runs, iterations, ModelRunType.NewFeedrates);
            var    removalRate   = new RemovalRate(nominalSurfaceSpeed, depthPerPass);
            var    depthInfo     = new DepthInfo(new Vector3(1, 1, 0), DepthSearchType.FindAveDepth, searchRadius);
            var    op            = AbMachOperation.ROCKETCHANNEL;
            var    mat           = new AWJModel.Material(AWJModel.MaterialType.Metal, "Aluminum", .25, 123, 456, 789, 143, 345, 543, 1);

            parms = AbMachParamBuilder.Build(op, runInfo, removalRate,
                                             mat, jet, depthInfo, meshSize);
        }
Exemplo n.º 6
0
        private DepthInfo ParseDepth(string readingLine)
        {
            try
            {
                var info = new DepthInfo();

                var parts = readingLine.Split(',');

                info.F1   = decimal.Parse(parts[3]);
                info.Unit = parts[4];
                info.F2   = decimal.Parse(parts[8]);

                return(info);
            }
            catch
            {
                _logger.LogError($"Invalid Depth Line Reading: {readingLine}");
                return(null);
            }
        }
        /// <summary>
        /// Get converted Depth
        /// </summary>
        /// <param name="service">BuzzexDotNet service</param>
        /// <param name="pair">Trading pair</param>
        /// <returns>Converted DepthDetail object</returns>
        public static async Task <DepthDetail> GetDepthConverted(this IBuzzexDotNet service, string pair)
        {
            var result = await service.GetDepth(pair);

            List <List <decimal> > asks = null;
            List <List <decimal> > bids = null;

            foreach (var kvp in result)
            {
                asks = kvp.Value.Asks;
                bids = kvp.Value.Bids;
            }

            var asksInfo = new List <DepthInfo>();
            var bidsInfo = new List <DepthInfo>();

            for (var i = 0; i < asks.Count; i++)
            {
                var depthInfo = new DepthInfo
                {
                    Amount = asks[i][0],
                    Price  = asks[i][1]
                };
                asksInfo.Add(depthInfo);
            }
            for (var i = 0; i < bids.Count; i++)
            {
                var depthInfo = new DepthInfo
                {
                    Amount = bids[i][0],
                    Price  = bids[i][1]
                };
                bidsInfo.Add(depthInfo);
            }

            return(new DepthDetail {
                Pair = pair, Asks = asksInfo, Bids = bidsInfo
            });
        }
Exemplo n.º 8
0
        public void abmTests_Const_valuesAreCorrect()
        {
            double meshSize            = .005;
            double diameter            = .04;
            double nominalSurfaceSpeed = 40;
            double depthPerPass        = .001;
            int    runs          = 3;
            int    iterations    = 1;
            int    equationIndex = 2;

            var jet         = new AbMachJet(diameter, equationIndex);
            var runInfo     = new RunInfo(runs, iterations, ModelRunType.NewFeedrates);
            var removalRate = new RemovalRate(nominalSurfaceSpeed, depthPerPass);
            var depthInfo   = new DepthInfo(new GeometryLib.Vector3(1, 1, 0), DepthSearchType.FindAveDepth, diameter / 10);
            var op          = AbMachOperation.ROCKETCHANNEL;
            var mat         = new AWJModel.Material(AWJModel.MaterialType.Metal, "Aluminum", .25, 1, 1, 1, 1, 1, 1, 1);

            AbMachParameters parms = AbMachParamBuilder.Build(op, runInfo, removalRate,
                                                              mat, jet, depthInfo, meshSize);

            Assert.AreEqual(nominalSurfaceSpeed, parms.RemovalRate.SurfaceSpeed, "surfspeed");
        }
Exemplo n.º 9
0
        private void RegisterDepth(IExpression expr, bool isDef)
        {
            if (Recognizer.IsBeingIndexed(context))
            {
                return;
            }
            int depth = Recognizer.GetIndexingDepth(expr);
            IVariableDeclaration baseVar = Recognizer.GetVariableDeclaration(expr);

            // If not an indexed variable reference, skip it (e.g. an indexed argument reference)
            if (baseVar == null)
            {
                return;
            }
            // If the variable is not stochastic, skip it
            if (!CodeRecognizer.IsStochastic(context, baseVar))
            {
                return;
            }
            ChannelInfo ci = context.InputAttributes.Get <ChannelInfo>(baseVar);

            if (ci != null && ci.IsMarginal)
            {
                return;
            }
            DepthInfo depthInfo;

            if (!depthInfos.TryGetValue(baseVar, out depthInfo))
            {
                depthInfo           = new DepthInfo();
                depthInfos[baseVar] = depthInfo;
            }
            if (isDef)
            {
                depthInfo.definitionDepth = depth;
                return;
            }
            depthInfo.useCount++;
            if (depth < depthInfo.minDepth)
            {
                depthInfo.minDepth = depth;
            }
            int literalIndexingDepth = 0;

            foreach (var bracket in Recognizer.GetIndices(expr))
            {
                if (!bracket.All(index => index is ILiteralExpression))
                {
                    break;
                }
                literalIndexingDepth++;
            }
            IndexInfo info;

            if (depthInfo.indexInfoOfDepth.TryGetValue(depth, out info))
            {
                Containers containers = new Containers(context);
                info.containers           = Containers.Intersect(info.containers, containers);
                info.literalIndexingDepth = System.Math.Min(info.literalIndexingDepth, literalIndexingDepth);
            }
            else
            {
                info                              = new IndexInfo();
                info.containers                   = new Containers(context);
                info.literalIndexingDepth         = literalIndexingDepth;
                depthInfo.indexInfoOfDepth[depth] = info;
            }
        }
Exemplo n.º 10
0
    protected override void Init()
    {
        base.Init();

        MotionType = MotionType.MultiDepth;
        // Camera.main.fieldOfView = 30f;

        _touchIds = new Dictionary <int, ClickData>();
        PosAndDir[] datas = new PosAndDir[ComputeBuffer.count];

        ComputeBuffer.GetData(datas);

        List <PosAndDir> temp        = new List <PosAndDir>();
        List <PosAndDir> allDataList = new List <PosAndDir>();



        //这里注意,posAndDir属于结构体,值拷贝
        for (int i = 0; i < datas.Length; i++)
        {
            PosAndDir data = datas[i];
            if (i < Common.PictureCount * 3)
            {
                temp.Add(data);//编号一样的单独拿出来
            }
            else
            {
                data.position    = Vector4.zero;//其他编号都隐藏
                data.originalPos = Vector4.one;
                allDataList.Add(data);
            }
        }
        _zeroIndexCount = allDataList.Count;
        PosAndDir[] newData = temp.ToArray();
        int         stride  = Marshal.SizeOf(typeof(DepthInfo));

        _depthBuffer = new ComputeBuffer(3, stride);
        _depths      = new DepthInfo[3];

        //点击缓存
        _clickPointBuff = new ComputeBuffer(1, Marshal.SizeOf(typeof(PosAndDir)));
        PosAndDir[] clickPoint = { new PosAndDir(-1) };
        _clickPointBuff.SetData(clickPoint);

        int   k      = 0;
        float z      = 6;
        float scaleY = 1;//y轴位置屏幕有内容的比率

        //得到随机点的个数,第一层的随机点个数不允许低于40
        //这个参数存在的意义是Common.Sample2D方法采样的时候会得不到正确的个数,有时候明显偏低,这个参数就是为了修正这个数据
        //这个数据如果scaleY s 两个参数有变化,应该考虑第一层随机点个数的变化
        int            count     = 40;
        List <Vector2> randomPos = new List <Vector2>();

        for (int j = 0; j < newData.Length; j++)
        {
            if (j % Common.PictureCount == 0)
            {
                //距离相机的深度值
                float tempZ = k * z - 4;
                k++;
                _screenPosLeftDown  = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, tempZ - Camera.main.transform.position.z));
                _screenPosLeftUp    = Camera.main.ScreenToWorldPoint(new Vector3(0, Height, tempZ - Camera.main.transform.position.z));
                _screenPosRightDown = Camera.main.ScreenToWorldPoint(new Vector3(Width, 0, tempZ - Camera.main.transform.position.z));
                _screenPosRightUp   = Camera.main.ScreenToWorldPoint(new Vector3(Width, Height, tempZ - Camera.main.transform.position.z));

                float s = 1f; //不同层次的给定不同的缩放
                float a = 1f; //不同层次的给定不同的透明度
                if (k == 1)
                {
                    s      = 1f;
                    a      = 1f;
                    scaleY = 0.55f;
                }
                else if (k == 2)
                {
                    s      = 1.2f;
                    a      = 0.45f;
                    scaleY = 0.25f;
                }
                else if (k == 3)
                {
                    s      = 1.4f;
                    a      = 0.25f;
                    scaleY = 0.18f;
                }
                else if (k == 4)
                {
                    s      = 1.6f;
                    a      = 0.45f;
                    scaleY = 0.7f;
                }
                else if (k == 5)
                {
                    s      = 1.8f;
                    a      = 0.25f;
                    scaleY = 0.6f;
                }



                while (true)
                {
                    if (count >= randomPos.Count)//如果得到的个数比上一个还小,那是不正确的采样,必须重新采样
                    {
                        // Debug.Log("x:" + _screenPosRightDown.x + " \r\n x1:" + _screenPosLeftDown.x + " \r\n  y:" + _screenPosLeftUp.y + "\r\n  y1:" + _screenPosLeftDown.y + " \r\n scaleY:" + scaleY + " \r\n  s:" + s);
                        randomPos = Common.Sample2D((_screenPosRightDown.x - _screenPosLeftDown.x) * 4, (_screenPosLeftUp.y - _screenPosLeftDown.y) * scaleY, s + 0.75f, 25);
                    }
                    else
                    {
                        count = randomPos.Count;
                        break;
                    }
                }



                Debug.Log("randomPos count is  " + randomPos.Count + " 层级为=> " + (k - 1) + "   tempZ is=>" + tempZ);
                _depths[k - 1] = new DepthInfo(k - 1, tempZ, s, a);
            }



            float rangeZ = Random.Range(-0.5f, 0.5f);//在同一层次,再随机不同的深度位置,不至于重叠一起,显得错落有致


            Vector4 posTemp = newData[j].position;
            newData[j].position = new Vector4(posTemp.x, posTemp.y, posTemp.z, 1);

            Vector2 randomPoint;



            if (randomPos.Count > 0)
            {
                // Random.InitState(Random.Range(0, randomPos.Count));

                int rangIndex = Random.Range(0, randomPos.Count);

                randomPoint = randomPos[rangIndex];

                randomPos.RemoveAt(rangIndex);
            }
            else//如果多出来,则放到看不到的地方
            {
                randomPoint = new Vector2(_screenPosLeftDown.x, Random.Range(1000f, 2000f));
            }


            // Vector2 randomPoint = randomPos[j % randomPos.Count];

            //计算Y轴的位置(1 - scaleY)为空余的位置(1 - scaleY)/2f上下空余的位置,(1 - scaleY)/2f*(_screenPosLeftUp.y - _screenPosLeftDown.y)空余位置的距离
            float heightTmep = (1 - scaleY) / 2f * (_screenPosLeftUp.y - _screenPosLeftDown.y);

            randomPoint = new Vector2(randomPoint.x + _screenPosLeftDown.x, randomPoint.y + _screenPosLeftDown.y + heightTmep);

            newData[j].moveTarget = new Vector3(randomPoint.x, randomPoint.y + Common.HeightTemp, rangeZ);
            newData[j].uvOffset   = new Vector4(1f, 1f, 0f, 0f);
            newData[j].uv2Offset  = new Vector4(1f, 1f, 0f, 0f);

            int     picIndex = 0;
            Vector2 size     = PictureHandle.Instance.GetLevelIndexSize(j, k - 1, out picIndex);//得到缩放尺寸

            float xScale     = size.x / 512f;
            float yScale     = size.y / 512f;
            float proportion = size.x / size.y;
            if (xScale >= 2 || yScale >= 2)
            {
                //如果超过2倍大小,则强制缩放到一倍大小以内,并以宽度为准,等比例减少
                int a = (int)xScale;
                xScale = xScale - (a) + 2f;

                yScale = xScale / proportion;
            }


            newData[j].initialVelocity = new Vector3(xScale, yScale, 0f);//填充真实宽高
            newData[j].picIndex        = picIndex;

            newData[j].bigIndex = picIndex;
            //x存储层次的索引,y存储透明度,   z存储,x轴右边的边界值,为正数   ,最后一个为随机深度
            newData[j].velocity = new Vector4(k - 1, 1f, _screenPosRightDown.x * 4f, 0);
            Vector4 otherData = new Vector4();
            newData[j].originalPos = otherData;
        }
        TextureInstanced.Instance.ChangeInstanceMat(CurMaterial);
        CurMaterial.enableInstancing = true;

        TextureInstanced.Instance.CurMaterial.SetVector("_WHScale", new Vector4(1f, 1f, 1f, 1f));



        allDataList.AddRange(newData);

        ComputeBuffer.SetData(allDataList.ToArray());
        _depthBuffer.SetData(_depths);

        ComputeShader.SetBuffer(dispatchID, "depthBuffer", _depthBuffer);
        ComputeShader.SetBuffer(dispatchID, "positionBuffer", ComputeBuffer);

        ComputeShader.SetFloat("Width", Screen.width);
        ComputeShader.SetFloat("Height", Screen.height);

        Matrix4x4 camMatri = Camera.main.projectionMatrix;

        ComputeShader.SetFloat("m32", camMatri.m32);
        ComputeShader.SetFloat("m00", camMatri.m00);
        ComputeShader.SetFloat("m11", camMatri.m11);
        ComputeShader.SetVector("camPos", Camera.main.transform.position);



        // ComputeShader.SetFloats(dispatchID, "positionBuffer", ComputeBuffer);


        // _depthPictureMove = new MultiDepthPictureMove(newData,_depths,Canvas);

        //ComputeShader.SetBuffer(InitID, "positionBuffer", ComputeBuffer);
        //ComputeShader.SetBuffer(InitID, "depthBuffer", _depthBuffer);

        TextureInstanced.Instance.CurMaterial.SetBuffer("positionBuffer", ComputeBuffer);
        TextureInstanced.Instance.CurMaterial.SetTexture("_TexArr", TextureInstanced.Instance.TexArr);


        MoveSpeed = 50f;//更改更快的插值速度
        ComputeShader.SetFloat("MoveSpeed", MoveSpeed);
        ComputeShader.SetFloat("dis", 800);

        ComputeShader.SetBuffer(dispatchID, "clickPointsBuff", _clickPointBuff);


        //触摸点最大为十个
        List <Vector3> clicks = new List <Vector3>();

        for (int i = 0; i < 10; i++)
        {
            clicks.Add(Vector3.one * 100000);
        }
        _clickBuff = new ComputeBuffer(10, 12);
        _clickBuff.SetData(clicks.ToArray());
        ComputeShader.SetBuffer(dispatchID, "clicks", _clickBuff);
        InitDisPatch(InitID);
    }
Exemplo n.º 11
0
        internal ResolvedAttributeSet FetchResolvedAttributes(ResolveOptions resOpt = null, AttributeContextParameters acpInContext = null)
        {
            bool wasPreviouslyResolving = this.Ctx.Corpus.isCurrentlyResolving;

            this.Ctx.Corpus.isCurrentlyResolving = true;
            if (resOpt == null)
            {
                resOpt = new ResolveOptions(this, this.Ctx.Corpus.DefaultResolutionDirectives);
            }


            const string   kind = "rasb";
            ResolveContext ctx  = this.Ctx as ResolveContext;
            ResolvedAttributeSetBuilder rasbResult = null;
            // keep track of the context node that the results of this call would like to use as the parent
            CdmAttributeContext         parentCtxForResult = null;
            ResolvedAttributeSetBuilder rasbCache          = this.FetchObjectFromCache(resOpt, acpInContext);
            CdmAttributeContext         underCtx           = null;

            if (acpInContext != null)
            {
                parentCtxForResult = acpInContext.under;
            }

            // store the previous document set, we will need to add it with
            // children found from the constructResolvedTraits call
            SymbolSet currDocRefSet = resOpt.SymbolRefSet;

            if (currDocRefSet == null)
            {
                currDocRefSet = new SymbolSet();
            }
            resOpt.SymbolRefSet = new SymbolSet();

            // if using the cache passes the maxDepth, we cannot use it
            if (rasbCache != null && resOpt.DepthInfo != null && resOpt.DepthInfo.CurrentDepth + rasbCache.ResolvedAttributeSet.DepthTraveled > resOpt.DepthInfo.MaxDepth)
            {
                rasbCache = null;
            }

            if (rasbCache == null)
            {
                if (this.resolvingAttributes)
                {
                    // re-entered this attribute through some kind of self or looping reference.
                    this.Ctx.Corpus.isCurrentlyResolving = wasPreviouslyResolving;
                    //return new ResolvedAttributeSet();  // uncomment this line as a test to turn off allowing cycles
                    resOpt.InCircularReference = true;
                    this.circularReference     = true;
                }
                this.resolvingAttributes = true;

                // a new context node is needed for these attributes,
                // this tree will go into the cache, so we hang it off a placeholder parent
                // when it is used from the cache (or now), then this placeholder parent is ignored and the things under it are
                // put into the 'receiving' tree
                underCtx = CdmAttributeContext.GetUnderContextForCacheContext(resOpt, this.Ctx, acpInContext);

                rasbCache = this.ConstructResolvedAttributes(resOpt, underCtx);

                this.resolvingAttributes = false;

                if (rasbCache != null)
                {
                    // register set of possible docs
                    CdmObjectDefinition oDef = this.FetchObjectDefinition <CdmObjectDefinitionBase>(resOpt);
                    if (oDef != null)
                    {
                        ctx.Corpus.RegisterDefinitionReferenceSymbols(oDef, kind, resOpt.SymbolRefSet);

                        // get the new cache tag now that we have the list of docs
                        string cacheTag = ctx.Corpus.CreateDefinitionCacheTag(resOpt, this, kind, acpInContext != null ? "ctx" : null);

                        // save this as the cached version
                        if (!string.IsNullOrWhiteSpace(cacheTag))
                        {
                            ctx.Cache[cacheTag] = rasbCache;
                        }
                    }
                    // get the 'underCtx' of the attribute set from the acp that is wired into
                    // the target tree
                    underCtx = (rasbCache as ResolvedAttributeSetBuilder).ResolvedAttributeSet.AttributeContext?.GetUnderContextFromCacheContext(resOpt, acpInContext);
                }

                if (this.circularReference)
                {
                    resOpt.InCircularReference = false;
                }
            }
            else
            {
                // get the 'underCtx' of the attribute set from the cache. The one stored there was build with a different
                // acp and is wired into the fake placeholder. so now build a new underCtx wired into the output tree but with
                // copies of all cached children
                underCtx = (rasbCache as ResolvedAttributeSetBuilder).ResolvedAttributeSet.AttributeContext?.GetUnderContextFromCacheContext(resOpt, acpInContext);
                //underCtx.ValidateLineage(resOpt); // debugging
            }

            if (rasbCache != null)
            {
                // either just built something or got from cache
                // either way, same deal: copy resolved attributes and copy the context tree associated with it
                // 1. deep copy the resolved att set (may have groups) and leave the attCtx pointers set to the old tree
                // 2. deep copy the tree.

                // 1. deep copy the resolved att set (may have groups) and leave the attCtx pointers set to the old tree
                rasbResult = new ResolvedAttributeSetBuilder();
                rasbResult.ResolvedAttributeSet = (rasbCache as ResolvedAttributeSetBuilder).ResolvedAttributeSet.Copy();

                // 2. deep copy the tree and map the context references.
                if (underCtx != null) // null context? means there is no tree, probably 0 attributes came out
                {
                    if (underCtx.AssociateTreeCopyWithAttributes(resOpt, rasbResult.ResolvedAttributeSet) == false)
                    {
                        return(null);
                    }
                }
            }

            DepthInfo currDepthInfo = resOpt.DepthInfo;

            if (this is CdmEntityAttributeDefinition && currDepthInfo != null)
            {
                // if we hit the maxDepth, we are now going back up
                currDepthInfo.CurrentDepth--;
                // now at the top of the chain where max depth does not influence the cache
                if (currDepthInfo.CurrentDepth <= 0)
                {
                    resOpt.DepthInfo = null;
                }
            }

            // merge child document set with current
            currDocRefSet.Merge(resOpt.SymbolRefSet);
            resOpt.SymbolRefSet = currDocRefSet;

            this.Ctx.Corpus.isCurrentlyResolving = wasPreviouslyResolving;
            return(rasbResult?.ResolvedAttributeSet);
        }