Exemplo n.º 1
0
        public static IEnumerable <string> FindFiles(string pattern)
        {
            //TODO
            //Path.IsPathRooted(pattern);

            var tokens = PatternUtils.Tokenize(pattern);

            if (tokens.Length < 2)
            {
                return(Enumerable.Empty <string>());
            }
            string ds    = Path.DirectorySeparatorChar.ToString();
            var    first = tokens[0];

            if (first.EndsWith(":", StringComparison.Ordinal))
            {
                // if the token is a windows drive, add a backslash to make it an absolute path.
                first += ds;
            }
            else if (pattern.StartsWith(ds, StringComparison.Ordinal))
            {
                // if the token was originally an absolute path (unix) or absolute path
                // minus the drive letter (windows) add the slash/backslash again.
                first = ds + first;
            }

            return(FindFiles(first, tokens.Skip(1)).ToList());
        }
Exemplo n.º 2
0
 private void CreateWatchers()
 {
     while (_queue.Count > 0)
     {
         var kvp   = _queue.Dequeue();
         var first = kvp.Value.First();
         var path  = Path.Combine(kvp.Key, first);
         if (!PatternUtils.IsPattern(first) && Directory.Exists(path))
         {
             var rest = kvp.Value.Skip(1).ToList();
             if (rest.Count > 0)
             {
                 _queue.Enqueue(new KeyValuePair <string, IEnumerable <string> >(path, rest));
             }
             else
             {
                 _fileWatcher = CreateWatcher(path, rest.Count == 1 ? rest[0] : "");
             }
         }
         else
         {
             _fileWatcher = CreateWatcher(kvp.Key, "*");
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 创建阵列
 /// </summary>
 private void CreatePattern(ElectrodePitchInfo pitch)
 {
     if ((pitch.PitchXNum > 1 && Math.Abs(pitch.PitchX) > 0) || (pitch.PitchYNum > 1 && Math.Abs(pitch.PitchY) > 0))
     {
         CreateExpression(pitch);
         this.patternFeat = PatternUtils.CreatePattern("xNCopies", "xPitchDistance", "yNCopies",
                                                       "yPitchDistance", this.matr, this.bodys.ToArray());
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 创建阵列
 /// </summary>
 private void CreatePattern(double x, int xNumber, double y, int yNumber)
 {
     if ((xNumber > 1 && Math.Abs(x) > 0) || (yNumber > 1 && Math.Abs(y) > 0))
     {
         CreateExpression(x, xNumber, y, yNumber);
         this.patternFeat = PatternUtils.CreatePattern("xNCopies", "xPitchDistance", "yNCopies",
                                                       "yPitchDistance", this.HeadModel.ConditionModel.Work.WorkMatr, this.HeadModel.ConditionModel.Bodys.ToArray());
     }
 }
Exemplo n.º 5
0
        public FileWatcher(string pattern, Action <string> action)
        {
            _action = action;

            //TODO check if rooted
            _regex = new Regex("^" + Regex.Escape(pattern).Replace(@"\*", ".*").Replace(@"\?", ".") + "$",
                               RegexOptions.IgnoreCase | RegexOptions.Singleline);
            _pattern = pattern;
            _queue   = new Queue <KeyValuePair <string, IEnumerable <string> > >();
            var tokens = PatternUtils.Tokenize(pattern);

            _queue.Enqueue(new KeyValuePair <string, IEnumerable <string> >(tokens[0] + Path.DirectorySeparatorChar, tokens.Skip(1)));

            CreateWatchers();
        }
Exemplo n.º 6
0
        /// <summary>
        /// 创建体特征
        /// </summary>
        private void CreateBodyFeature(double zHeight)
        {
            List <Body> allbody = new List <Body>();
            Matrix4     mat     = new Matrix4();

            mat.Identity();
            foreach (Face face in GetMaxFaceForWave(waveBodys))
            {
                PullFaceUtils.CreatePullFace(new Vector3d(0, 0, -1), zHeight, face);
            }
            NXOpen.Features.PatternGeometry patt = PatternUtils.CreatePattern(" xNCopies", "xPitchDistance", "yNCopies", " yPitchDistance"
                                                                              , mat, waveBodys); //创建阵列(就是绝对坐标的矩阵)
            allbody.AddRange(patt.GetAssociatedBodies());
            allbody.AddRange(waveBodys);
            MoveObject.CreateMoveObjToXYZ("moveX", "moveY", "moveZ", null, allbody.ToArray());
        }
Exemplo n.º 7
0
 public void CreatePatter()
 {
     if (this.double_x.Value == 0 && this.double_y.Value == 0)
     {
         return;
     }
     else
     {
         int coutx = 1;
         int conty = 1;
         if (double_x.Value != 0)
         {
             coutx = 2;
         }
         if (double_y.Value != 0)
         {
             conty = 2;
         }
         feature = PatternUtils.CreatePattern(coutx, double_x.Value, conty, double_y.Value, this.matr, feature, bodys.ToArray());
     }
 }
        private bool CreatWave()
        {
            Matrix4 mat = new Matrix4();

            mat.Identity();
            try
            {
                //  Body[] waveBodys = AssmbliesUtils.WaveAssociativeBodys(this.headBodys.ToArray()).GetBodies();
                PullFaceForWave(headBodys);
                NXOpen.Features.PatternGeometry patt = PatternUtils.CreatePattern(" xNCopies", "xPitchDistance", "yNCopies", " yPitchDistance"
                                                                                  , mat, headBodys.ToArray()); //创建阵列(就是绝对坐标的矩阵)
                AllBodys.AddRange(patt.GetAssociatedBodies());
                AllBodys.AddRange(headBodys);
                MoveObject.CreateMoveObjToXYZ("moveX", "moveY", "moveZ", null, AllBodys.ToArray());
                SetHeadColour();
                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("创建Part档错误!" + ex.Message);
                return(false);
            }
        }
Exemplo n.º 9
0
 public void RotateRight()
 {
     Focus   = PatternUtils.GetRightOf(Focus);
     LeftOf  = PatternUtils.GetRightOf(LeftOf);
     RightOf = PatternUtils.GetRightOf(RightOf);
 }