Пример #1
0
        public static bool GetComposedPatternsFromPathCircum(MyPathOfPoints currentPathOfCentroids,
                                                             List <MyPattern> listOfCoherentPatterns, ref List <MyPathOfPoints> listOfPathsOfCentroids,
                                                             ref List <MyMatrAdj> listOfMyMatrAdj, ref List <MyGroupingSurfaceForPatterns> listOfMyGroupingSurface,
                                                             ref List <MyComposedPattern> listOfOutputComposedPattern,
                                                             ref List <MyComposedPattern> listOfOutputComposedPatternTwo, SldWorks SwApplication, ref StringBuilder fileOutput)
        {
            var numOfPatterns = currentPathOfCentroids.path.Count;
            var noStop        = true;

            var listOfPatternOnThePath = currentPathOfCentroids.path.Select(ind => listOfCoherentPatterns[ind]).ToList();
            var pathCircumference      = (MyCircumForPath)currentPathOfCentroids.pathGeometricObject;

            var i = 0;

            while (i < (numOfPatterns - 1))
            {
                var newComposedPattern = new MyComposedPattern();
                var j = i;
                var foundNewComposedPattern = GetMaximumTranslation_ComposedPatterns(listOfPatternOnThePath,
                                                                                     pathCircumference, ref j, ref numOfPatterns, ref noStop, ref newComposedPattern);

                if (foundNewComposedPattern == false)
                {
                    foundNewComposedPattern = GetMaximumRotation_ComposedPatterns(listOfPatternOnThePath,
                                                                                  pathCircumference, ref i, ref numOfPatterns, ref noStop, ref newComposedPattern, SwApplication, ref fileOutput);
                }
                else
                {
                    i = j;
                }

                if (foundNewComposedPattern)
                {
                    if (newComposedPattern.listOfMyPattern.Count == numOfPatterns ||
                        newComposedPattern.listOfMyPattern.Count == numOfPatterns - 1)
                    {
                        noStop = true;
                    }

                    CheckAndUpdate_ComposedPatterns(newComposedPattern, ref listOfPathsOfCentroids,
                                                    listOfCoherentPatterns, ref listOfMyMatrAdj, ref listOfMyGroupingSurface,
                                                    ref listOfOutputComposedPattern, ref listOfOutputComposedPatternTwo);
                }
            }

            if (noStop)
            {
                return(true);
            }
            return(false);
        }
Пример #2
0
        public static bool GetMaximumTranslation_ComposedPatterns(List <MyPattern> listOfPatternOnThePath,
                                                                  MyPathGeometricObject pathObject, ref int i, ref int numOfPatterns, ref bool noStop,
                                                                  ref MyComposedPattern outputComposedPattern)
        {
            const string nameFile    = "ComposedPatterns_Linear.txt";
            var          whatToWrite = "";

            var listOfPatternsOfNew = new List <MyPattern> {
                listOfPatternOnThePath[i]
            };
            var lengthOfNew = 1;
            var exit        = false;

            while (i < (numOfPatterns - 1) && exit == false)
            {
                whatToWrite = string.Format("         Confronto {0}^ pattern e la {1}^ pattern: ", i, i + 1);

                if (IsTranslationTwoPatterns(listOfPatternOnThePath[i], listOfPatternOnThePath[i + 1]))
                {
                    listOfPatternsOfNew.Add(listOfPatternOnThePath[i + 1]);
                    lengthOfNew += 1;

                    i++;
                }
                else
                {
                    exit   = true;
                    noStop = false;

                    i++;
                }
            }

            if (lengthOfNew > 1)
            {
                outputComposedPattern.listOfMyPattern         = listOfPatternsOfNew;
                outputComposedPattern.pathOfMyComposedPattern = pathObject;

                outputComposedPattern.typeOfMyComposedPattern = "(linear) TRANSLATION";

                outputComposedPattern.constStepOfMyComposedPattern = listOfPatternsOfNew[0].patternCentroid.Distance(
                    listOfPatternsOfNew[1].patternCentroid);
                return(true);
            }

            return(false);
        }
Пример #3
0
        //Update data in case on newPattern of length > 2
        public static void UpdateOtherData_ComposedPatterns(MyComposedPattern newComposedPattern,
                                                            ref List <MyPathOfPoints> listOfPathOfCentroids, List <MyPattern> listOfParallelPatterns,
                                                            ref List <MyMatrAdj> listOfMatrAdj, ref List <MyGroupingSurfaceForPatterns> listOfMyGroupingSurface,
                                                            ref List <MyComposedPattern> listOfOutputComposedPatternTwo)
        {
            const string nameFile = "CheckAndUpdate_ComposedPatterns.txt";

            foreach (var pattern in newComposedPattern.listOfMyPattern)
            {
                var indOfThisPattern = listOfParallelPatterns.IndexOf(pattern);

                PartUtilities.GeometryAnalysis.UpdateListOfMyPathOfCentroids(ref listOfPathOfCentroids, indOfThisPattern, nameFile);
                PartUtilities.GeometryAnalysis.UpdateListOfMyMatrAdj(ref listOfMatrAdj, indOfThisPattern, nameFile);
                UpdateListOfMyGroupingSurface_ComposedPatterns(pattern, ref listOfMyGroupingSurface, indOfThisPattern);
                UpdateListOfPatternTwo_ComposedPatterns(pattern, ref listOfOutputComposedPatternTwo, indOfThisPattern);
            }
        }
Пример #4
0
        public static void CheckAndUpdate_ComposedPatterns(MyComposedPattern newComposedPattern,
                                                           ref List <MyPathOfPoints> listOfPathOfCentroids,
                                                           List <MyPattern> listOfParallelPatterns, ref List <MyMatrAdj> listOfMatrAdj,
                                                           ref List <MyGroupingSurfaceForPatterns> listOfMyGroupingSurface,
                                                           ref List <MyComposedPattern> listOfOutputComposedPattern,
                                                           ref List <MyComposedPattern> listOfOutputComposedPatternTwo)
        {
            var lengthOfComposedPattern = newComposedPattern.listOfMyPattern.Count;

            // if lengthOfComposedPattern = 2, I add the newComposedPattern only if there is not another pattern in
            //listOfOutputComposedPatternTwo containing one of the two patterns in the newComposedPattern.
            if (lengthOfComposedPattern == 2)
            {
                int i        = 0;
                var addOrNot = true;
                while (addOrNot == true && i < 2)
                {
                    var currentPattern = newComposedPattern.listOfMyPattern[i];
                    var indOfFound     =
                        listOfOutputComposedPatternTwo.FindIndex(
                            composedPattern => composedPattern.listOfMyPattern.FindIndex(
                                pattern => pattern.idMyPattern == currentPattern.idMyPattern) != -1);
                    if (indOfFound != -1)
                    {
                        addOrNot = false;
                    }
                    i++;
                }

                if (addOrNot == true)
                {
                    listOfOutputComposedPatternTwo.Add(newComposedPattern);
                }
            }
            // if lengthOfComposedPattern > 2, I add the newComposedPattern and I update the other data
            // (aiming not to find composed pattern containing pattern already set in this newComposedPattern)
            else
            {
                listOfOutputComposedPattern.Add(newComposedPattern);

                UpdateOtherData_ComposedPatterns(newComposedPattern, ref listOfPathOfCentroids,
                                                 listOfParallelPatterns, ref listOfMatrAdj,
                                                 ref listOfMyGroupingSurface, ref listOfOutputComposedPatternTwo);
            }
        }
        public static void BuildNewComposedPatternOfLength2(StringBuilder fileOutput, string typeOfNewComposedPattern,
                                                            ref List <MyComposedPattern> listOfComposedPattern, ref List <MyComposedPattern> listOfComposedPatternTwo,
                                                            ref List <MyGroupingSurfaceForPatterns> listOfGroupingSurfaceForPatterns, List <MyPattern> listOfPatternsToConsider)
        {
            var listOfPathOfCentroids = new List <MyPathOfPoints>();
            var listOfMyMatrAdj       = new List <MyMatrAdj>();
            var newListOfPatterns     = new List <MyPattern>();

            newListOfPatterns.Add(listOfPatternsToConsider[0]);
            newListOfPatterns.Add(listOfPatternsToConsider[1]);
            var newComposedPatternGeomObject = FunctionsLC.LinePassingThrough(
                listOfPatternsToConsider[0].patternCentroid, listOfPatternsToConsider[1].patternCentroid);
            var newComposedPatternType = typeOfNewComposedPattern;
            var newComposedPattern     = new MyComposedPattern(newListOfPatterns,
                                                               newComposedPatternGeomObject, newComposedPatternType);

            CheckAndUpdate_ComposedPatterns(newComposedPattern, ref listOfPathOfCentroids,
                                            listOfPatternsToConsider, ref listOfMyMatrAdj, ref listOfGroupingSurfaceForPatterns,
                                            ref listOfComposedPattern, ref listOfComposedPatternTwo);
        }
Пример #6
0
        public static bool GetComposedPatternsFromPathLine(MyPathOfPoints currentPathOfCentroids,
                                                           List <MyPattern> listOfParallelPatterns, ref List <MyPathOfPoints> listOfPathsOfCentroids,
                                                           ref List <MyMatrAdj> listOfMyMatrAdj, ref List <MyGroupingSurfaceForPatterns> listOfMyGroupingSurface,
                                                           ref List <MyComposedPattern> listOfOutputComposedPattern,
                                                           ref List <MyComposedPattern> listOfOutputComposedPatternTwo)
        {
            var numOfPatterns = currentPathOfCentroids.path.Count;
            var noStop        = true;

            var listOfPatternOnThePath = currentPathOfCentroids.path.Select(ind => listOfParallelPatterns[ind]).ToList();

            var i = 0;

            while (i < (numOfPatterns - 1))
            {
                var newComposedPattern      = new MyComposedPattern();
                var foundNewComposedPattern = GetMaximumTranslation_ComposedPatterns(listOfPatternOnThePath,
                                                                                     currentPathOfCentroids.pathGeometricObject, ref i,
                                                                                     ref numOfPatterns, ref noStop, ref newComposedPattern);

                if (foundNewComposedPattern)
                {
                    if (newComposedPattern.listOfMyPattern.Count == numOfPatterns ||
                        newComposedPattern.listOfMyPattern.Count == numOfPatterns - 1)
                    {
                        noStop = true;
                    }

                    CheckAndUpdate_ComposedPatterns(newComposedPattern, ref listOfPathsOfCentroids,
                                                    listOfParallelPatterns, ref listOfMyMatrAdj, ref listOfMyGroupingSurface,
                                                    ref listOfOutputComposedPattern, ref listOfOutputComposedPatternTwo);

                    // RICORDA: modificare anche il FindPaths_ComposedPatterns caso Maximum
                }
            }
            if (noStop)
            {
                return(true);
            }
            return(false);
        }
Пример #7
0
        public static bool GetMaximumRotation_ComposedPatterns(List <MyPattern> listOfPatternOnThePath,
                                                               MyCircumForPath pathObject, ref int i, ref int numOfPatterns, ref bool noStop,
                                                               ref MyComposedPattern outputComposedPattern, SldWorks SwApplication, ref StringBuilder fileOutput)
        {
            const string nameFile = "ComposedPatterns_Linear.txt";

            var listOfPatternsOfNew = new List <MyPattern> {
                listOfPatternOnThePath[i]
            };
            var lengthOfNew = 1;
            var exit        = false;

            //Computation of the rotation angle:
            double[] planeNormal =
            {
                pathObject.circumplane.a,
                pathObject.circumplane.b,
                pathObject.circumplane.c
            };

            var teta = FunctionsLC.FindAngle(listOfPatternOnThePath[0].patternCentroid,
                                             listOfPatternOnThePath[1].patternCentroid, pathObject.circumcenter);

            var axisDirection = PartUtilities.GeometryAnalysis.establishAxisDirection(listOfPatternOnThePath[0].patternCentroid,
                                                                                      listOfPatternOnThePath[1].patternCentroid,
                                                                                      pathObject.circumcenter, planeNormal);

            while (i < (numOfPatterns - 1) && exit == false)
            {
                var whatToWrite = string.Format("         Confronto {0}^ pattern e la {1}^ pattern: ", i, i + 1);

                if (IsRotationTwoPatterns(listOfPatternOnThePath[i], listOfPatternOnThePath[i + 1], teta, axisDirection,
                                          pathObject.circumcenter, SwApplication, ref fileOutput))
                {
                    listOfPatternsOfNew.Add(listOfPatternOnThePath[i + 1]);
                    lengthOfNew += 1;

                    i++;
                }
                else
                {
                    exit   = true;
                    noStop = false;

                    i++;
                }
            }

            if (lengthOfNew > 1)
            {
                outputComposedPattern.listOfMyPattern         = listOfPatternsOfNew;
                outputComposedPattern.pathOfMyComposedPattern = pathObject;

                outputComposedPattern.typeOfMyComposedPattern = "ROTATION";

                outputComposedPattern.constStepOfMyComposedPattern = listOfPatternsOfNew[0].patternCentroid.Distance(
                    listOfPatternsOfNew[1].patternCentroid);
                return(true);
            }

            return(false);
        }