//It detects all the symmetry relations in a set of MyRepeatedComponent
        //on a given MyPathOfPoints.
        //(symmetry types considered: translation, reflection, rotation)
        //It returns TRUE if only one pattern has been detected and it has maximum length, FALSE otherwise.

        public static bool GetPatternsFromPath_Assembly(MyPathOfPoints myPathOfPoints,
                                                        List <MyRepeatedComponent> listOfComponents, ref List <MyPathOfPoints> listOfPathOfPoints,
                                                        ref List <MyMatrAdj> listOfMatrAdj, ref List <MyPatternOfComponents> listOfOutputPattern,
                                                        ref List <MyPatternOfComponents> listOfOutputPatternTwo, ModelDoc2 SwModel, SldWorks SwApplication)
        {
            var listOfOriginsOnThePath = listOfComponents.Select(re => re.Origin).ToList();

            var listOfComponentsOnThePath = myPathOfPoints.path.Select(ind => listOfComponents[ind]).ToList();


            if (myPathOfPoints.pathGeometricObject.GetType() == typeof(MyLine))
            {
                SwApplication.SendMsgToUser("traslazione vecchia");
                return(GetPatternsFromLinearPath_Assembly(listOfComponentsOnThePath, myPathOfPoints.pathGeometricObject,
                                                          ref listOfPathOfPoints, listOfOriginsOnThePath, ref listOfMatrAdj,
                                                          ref listOfOutputPattern, ref listOfOutputPatternTwo));
            }
            else
            {
                SwApplication.SendMsgToUser("tras circ vecchia");

                return(GetPatternsFromCircularPath_Assembly(listOfComponentsOnThePath, myPathOfPoints.pathGeometricObject,
                                                            ref listOfPathOfPoints, listOfOriginsOnThePath, ref listOfMatrAdj,
                                                            ref listOfOutputPattern, ref listOfOutputPatternTwo, SwModel, SwApplication));
            }
        }
Exemple #2
0
        public static void GetComposedPatternsFromListOfPathsLine_Assembly(List <MyPathOfPoints> listOfPathsOfCentroids,
                                                                           List <MyPatternOfComponents> listOfParallelPatterns, ref List <MyMatrAdj> listOfMyMatrAdj,
                                                                           ref List <MyComposedPatternOfComponents> listOfOutputComposedPattern,
                                                                           ref List <MyComposedPatternOfComponents> listOfOutputComposedPatternTwo, SldWorks SwApplication, ref StringBuilder fileOutput)
        {
            var nameFile = "ComposedPatterns_Assembly.txt";

            while (listOfPathsOfCentroids.Count > 0)
            {
                var currentPathOfCentroids = new MyPathOfPoints(listOfPathsOfCentroids[0].path,
                                                                listOfPathsOfCentroids[0].pathGeometricObject);
                listOfPathsOfCentroids.RemoveAt(0);
                //I remove it immediately so in the update phase there is not it in the listOfMyPathsOfCentroids

                bool maxLength;
                if (currentPathOfCentroids.pathGeometricObject.GetType() == typeof(MyLine))
                {
                    maxLength = GetComposedPatternsFromPathLine_Assembly(currentPathOfCentroids,
                                                                         listOfParallelPatterns, ref listOfPathsOfCentroids, ref listOfMyMatrAdj,
                                                                         ref listOfOutputComposedPattern,
                                                                         ref listOfOutputComposedPatternTwo);
                }
                else
                {
                    //composed rotational pattern of patterns line
                    maxLength = GetComposedPatternsFromPathCircum_Assembly(currentPathOfCentroids,
                                                                           listOfParallelPatterns, ref listOfPathsOfCentroids, ref listOfMyMatrAdj,
                                                                           ref listOfOutputComposedPattern, ref listOfOutputComposedPatternTwo,
                                                                           SwApplication, ref fileOutput);
                }
            }
        }
        //It detects all the symmetry relations in a set of MyRepeatedComponent
        //on a given MyPathOfPoints.
        //(symmetry types considered: translation, reflection, rotation)
        //It returns TRUE if only one pattern has been detected and it has maximum length, FALSE otherwise.

        public static bool GetPatternsFromPath_Assembly(MyPathOfPoints myPathOfPoints,
                                                        List <MyRepeatedComponent> listOfComponents, ref List <MyPathOfPoints> listOfPathOfPoints,
                                                        ref List <MyMatrAdj> listOfMatrAdj, ref List <MyPatternOfComponents> listOfOutputPattern,
                                                        ref List <MyPatternOfComponents> listOfOutputPatternTwo)
        {
            var listOfOriginsOnThePath = listOfComponents.Select(re => re.Origin).ToList();

            var listOfComponentsOnThePath = myPathOfPoints.path.Select(ind => listOfComponents[ind]).ToList();


            if (myPathOfPoints.pathGeometricObject.GetType() == typeof(MyLine))
            {
                const string nameFile = "GetTranslationalPatterns.txt";

                return(GetPatternsFromLinearPath_Assembly(listOfComponentsOnThePath, myPathOfPoints.pathGeometricObject,
                                                          ref listOfPathOfPoints, listOfOriginsOnThePath, ref listOfMatrAdj,
                                                          ref listOfOutputPattern, ref listOfOutputPatternTwo));
            }
            else
            {
                const string nameFile = "GetCircularPatterns.txt";

                return(GetPatternsFromCircularPath_Assembly(listOfComponentsOnThePath, myPathOfPoints.pathGeometricObject,
                                                            ref listOfPathOfPoints, listOfOriginsOnThePath, ref listOfMatrAdj,
                                                            ref listOfOutputPattern, ref listOfOutputPatternTwo));
            }
        }
        // Pecedura duplicata in modo che non ricalcoli le origini delle componenti, ma usi quelle che ha chiesto in input prima!
        public static bool KLGetPatternsFromPath_Assembly(MyPathOfPoints myPathOfPoints,
                                                          List <MyRepeatedComponent> listOfComponents, List <MyVertex> listOfOriginsOnThePath, ref List <MyPathOfPoints> listOfPathOfPoints,
                                                          ref List <MyMatrAdj> listOfMatrAdj, ref List <MyPatternOfComponents> listOfOutputPattern,
                                                          ref List <MyPatternOfComponents> listOfOutputPatternTwo, ModelDoc2 SwModel, SldWorks SwApplication)
        {
            if (myPathOfPoints != null)
            {
                if (myPathOfPoints.path.Any())
                {
                    //KLdebug.Print("Comp max " + listOfComponents.Count.ToString(), "indici.txt");
                    //foreach (var ind in myPathOfPoints.path)
                    //{
                    //    KLdebug.Print(ind.ToString(), "indici.txt");
                    //}

                    var listOfComponentsOnThePath = myPathOfPoints.path.Select(ind => listOfComponents[ind]).ToList();


                    // Aggiunto per non fargli pescare indici che non ha, ma così facendo va in loop da qualche altra parte.
                    //var listOfComponentsOnThePathEnumerable = from ind in myPathOfPoints.path
                    //    where ind < listOfComponents.Count
                    //    select listOfComponents[ind];

                    //if (!listOfComponentsOnThePathEnumerable.Any())
                    //{
                    //    listOfPathOfPoints.Clear();
                    //    return false;
                    //}
                    //var listOfComponentsOnThePath =
                    //    (List<MyRepeatedComponent>) listOfComponentsOnThePathEnumerable.ToList();
                    //SwApplication.SendMsgToUser("Seleziono path point FINE");

                    if (myPathOfPoints.pathGeometricObject.GetType() == typeof(MyLine))
                    {
                        //SwApplication.SendMsgToUser("Cerco linear path");
                        //const string nameFile = "GetTranslationalPatterns.txt";
                        //KLdebug.Print(" ", nameFile);
                        //KLdebug.Print("POSSIBILE TRASLAZIONE retta. AVVIO", nameFile);
                        return(KLGetPatternsFromLinearPath_Assembly(listOfComponentsOnThePath, myPathOfPoints.pathGeometricObject,
                                                                    ref listOfPathOfPoints, listOfOriginsOnThePath, ref listOfMatrAdj,
                                                                    ref listOfOutputPattern, ref listOfOutputPatternTwo, SwApplication));
                    }
                    else
                    {
                        //SwApplication.SendMsgToUser("Cerco circular path");
                        //const string nameFile = "GetCircularPatterns.txt";
                        //KLdebug.Print(" ", nameFile);
                        //KLdebug.Print("POSSIBILE TRASLAZIONE o ROTAZIONE su circonferenza. AVVIO", nameFile);
                        return(KLGetPatternsFromCircularPath_Assembly(listOfComponentsOnThePath, myPathOfPoints.pathGeometricObject,
                                                                      ref listOfPathOfPoints, listOfOriginsOnThePath, ref listOfMatrAdj,
                                                                      ref listOfOutputPattern, ref listOfOutputPatternTwo, SwModel, SwApplication));
                    }
                }
            }

            return(false);
        }
Exemple #5
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);
        }
Exemple #6
0
        //It detects all the symmetry relations in a set of MyRepeatedComponent
        //it saves patterns of length = 1 in a list;
        //it saves patterns of length = 2 in a list;
        //it saves patterns of length > 2 in a list.
        //It returns TRUE if only one pattern has been detected and it has maximum length, FALSE otherwise.

        public static void GetPatternsFromListOfPaths_Assembly(List <MyPathOfPoints> listOfMyPathsOfPoints,
                                                               List <MyRepeatedComponent> listOfComponents, ref List <MyMatrAdj> listOfMatrAdj,
                                                               ref List <MyPatternOfComponents> listOfOutputPattern, ref List <MyPatternOfComponents> listOfOutputPatternTwo, ModelDoc2 SwModel, SldWorks SwApplication)
        {
            Part.PartUtilities.GeometryAnalysis.ReorderListOfPaths(ref listOfMyPathsOfPoints);

            while (listOfMyPathsOfPoints.Count > 0)
            {
                var currentPathOfPoints = new MyPathOfPoints(listOfMyPathsOfPoints[0].path,
                                                             listOfMyPathsOfPoints[0].pathGeometricObject);
                listOfMyPathsOfPoints.RemoveAt(0);
                //I remove it immediately so in the update phase there is not it in the listOfMyPathsOfCentroids

                var maxLength = GetPatternsFromPath_Assembly(currentPathOfPoints,
                                                             listOfComponents, ref listOfMyPathsOfPoints, ref listOfMatrAdj,
                                                             ref listOfOutputPattern, ref listOfOutputPatternTwo, SwModel, SwApplication);
            }
        }
Exemple #7
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);
        }
        public static void KLGetPatternsFromListOfPaths_Assembly(List <MyPathOfPoints> listOfMyPathsOfPoints,
                                                                 List <MyRepeatedComponent> listOfComponents, List <MyVertex> listCentroid, ref List <MyMatrAdj> listOfMatrAdj,
                                                                 ref List <MyPatternOfComponents> listOfOutputPattern, ref List <MyPatternOfComponents> listOfOutputPatternTwo)
        {
            Part.PartUtilities.GeometryAnalysis.ReorderListOfPaths(ref listOfMyPathsOfPoints);
            while (listOfMyPathsOfPoints.Count > 0)
            {
                var firstIndex          = listOfMyPathsOfPoints.IndexOf(listOfMyPathsOfPoints.First());
                var currentPathOfPoints = new MyPathOfPoints(listOfMyPathsOfPoints[firstIndex].path,
                                                             listOfMyPathsOfPoints[firstIndex].pathGeometricObject);
                listOfMyPathsOfPoints.RemoveAt(firstIndex);
                //I remove it immediately so in the update phase there is not it in the listOfMyPathsOfCentroids

                //listOfOutputPatternTwo.Clear();
                //listOfOutputPattern.Clear();

                var maxLength = KLGetPatternsFromPath_Assembly(currentPathOfPoints,
                                                               listOfComponents, listCentroid, ref listOfMyPathsOfPoints, ref listOfMatrAdj,
                                                               ref listOfOutputPattern, ref listOfOutputPatternTwo);
            }
        }
        //It detects all the symmetry relations in a set of MyRepeatedEntity
        //on a given MyPathOfPoints.
        //(symmetry types considered: translation)  <-- reflection? rotation?
        //It returns TRUE if only one pattern has been detected and it has maximum length, FALSE otherwise.

        public static bool GetPatternsFromPath(MyPathOfPoints myPathOfPoints,
                                               List <MyRepeatedEntity> listOfREOnThisSurface, ref List <MyPathOfPoints> listOfPathOfCentroids,
                                               ref List <MyMatrAdj> listOfMatrAdj, ref List <MyGroupingSurface> listOfMyGroupingSurface,
                                               List <MyGroupingSurface> listOfInitialGroupingSurface, ref List <MyPattern> listOfOutputPattern,
                                               ref List <MyPattern> listOfOutputPatternTwo)
        {
            var listOfREOnThePath = myPathOfPoints.path.Select(ind => listOfREOnThisSurface[ind]).ToList();

            if (myPathOfPoints.pathGeometricObject.GetType() == typeof(MyLine))
            {
                return(GetPatternsFromLinearPath(listOfREOnThePath, myPathOfPoints.pathGeometricObject,
                                                 ref listOfPathOfCentroids, listOfREOnThisSurface, ref listOfMatrAdj, ref listOfMyGroupingSurface,
                                                 listOfInitialGroupingSurface, ref listOfOutputPattern, ref listOfOutputPatternTwo));
            }
            else
            {
                return(GetPatternsFromCircularPath(listOfREOnThePath, myPathOfPoints.pathGeometricObject,
                                                   ref listOfPathOfCentroids, listOfREOnThisSurface, ref listOfMatrAdj, ref listOfMyGroupingSurface,
                                                   listOfInitialGroupingSurface, ref listOfOutputPattern, ref listOfOutputPatternTwo));
            }
        }
Exemple #10
0
        public static bool GetComposedPatternsFromPathLine_Assembly(MyPathOfPoints currentPathOfCentroids,
                                                                    List <MyPatternOfComponents> listOfParallelPatterns, ref List <MyPathOfPoints> listOfPathsOfCentroids,
                                                                    ref List <MyMatrAdj> listOfMyMatrAdj,
                                                                    ref List <MyComposedPatternOfComponents> listOfOutputComposedPattern,
                                                                    ref List <MyComposedPatternOfComponents> 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 MyComposedPatternOfComponents();
                var foundNewComposedPattern = GetMaximumTranslation_Assembly_ComposedPatterns(listOfPatternOnThePath,
                                                                                              currentPathOfCentroids.pathGeometricObject, ref i,
                                                                                              ref numOfPatterns, ref noStop, ref newComposedPattern);

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

                    GeometryAnalysis.CheckAndUpdate_Assembly_ComposedPatterns(newComposedPattern, ref listOfPathsOfCentroids,
                                                                              listOfParallelPatterns, ref listOfMyMatrAdj,
                                                                              ref listOfOutputComposedPattern, ref listOfOutputComposedPatternTwo);
                }
            }

            if (noStop)
            {
                return(true);
            }
            return(false);
        }
Exemple #11
0
        //It detects all the symmetry relations in a set of MyRepeatedEntity
        //(symmetry types considered: translation, reflection,rotation)
        //it saves patterns of length = 1 in a list;
        //it saves patterns of length = 2 in a list;
        //it saves patterns of length > 2 in a list.
        //It returns TRUE if only one pattern has been detected and it has maximum length, FALSE otherwise.

        public static void GetPatternsFromListOfPaths(List <MyPathOfPoints> listOfMyPathsOfCentroids,
                                                      List <MyRepeatedEntity> listOfREOnThisSurface, ref List <MyMatrAdj> listOfMatrAdj,
                                                      ref List <MyGroupingSurface> listOfMyGroupingSurface, List <MyGroupingSurface> listOfInitialGroupingSurface,
                                                      ref List <MyPattern> listOfOutputPattern,
                                                      ref List <MyPattern> listOfOutputPatternTwo)
        {
            ReorderListOfPaths(ref listOfMyPathsOfCentroids);


            while (listOfMyPathsOfCentroids.Count > 0)
            {
                var currentPathOfCentroids = new MyPathOfPoints(listOfMyPathsOfCentroids[0].path,
                                                                listOfMyPathsOfCentroids[0].pathGeometricObject);
                listOfMyPathsOfCentroids.RemoveAt(0);
                //I remove it immediately so in the update phase there is not it in the listOfMyPathsOfCentroids

                var maxLength = GetPatternsFromPath(currentPathOfCentroids,
                                                    listOfREOnThisSurface, ref listOfMyPathsOfCentroids, ref listOfMatrAdj,
                                                    ref listOfMyGroupingSurface, listOfInitialGroupingSurface, ref listOfOutputPattern,
                                                    ref listOfOutputPatternTwo);
            }
        }
Exemple #12
0
        //Update the list of paths of centroids found in the current MyMatrAdj
        public static void UpdateListOfMyPathOfCentroids(ref List <MyPathOfPoints> listOfPathOfCentroids,
                                                         int indOfThisCentroid, string nameFile)
        {
            //const string nameFile = "GetTranslationalPatterns.txt";
            //KLdebug.Print("     ---> UpdateListOfMyPathOfCentroids", nameFile);


            // I check if there are candidate MyPathOfPoints not geometrically verified yet:
            // for each of them I split them in 2 MyPathOfPoints sons
            // if the two sons are long enough I save them for a future Geometrical Verification.

            var listOfPathOfCentroidsToSplit = listOfPathOfCentroids.FindAll(
                myPathOfCentroids => myPathOfCentroids.path.FindIndex(ind => ind == indOfThisCentroid) != -1);

            if (listOfPathOfCentroidsToSplit.Any())
            {
                //KLdebug.Print(" Trovati Path contenenti il centroid della RE corrente: ", nameFile);

                //KLdebug.Print(" Numero di path trovati: " + listOfPathOfCentroidsToSplit.Count, nameFile);
                //KLdebug.Print(" ", nameFile);

                foreach (var myPathOfCentroids in listOfPathOfCentroidsToSplit)
                {
                    //KLdebug.Print(" -considero il " + listOfPathOfCentroidsToSplit.IndexOf(myPathOfCentroids) + "path:", nameFile);
                    //for (int i = 0; i < myPathOfCentroids.path.Count; i++)
                    //{
                    //    KLdebug.Print("      " + myPathOfCentroids.path[i], nameFile);
                    //}

                    var indInPathOfThisCentroid = myPathOfCentroids.path.IndexOf(indOfThisCentroid);
                    //KLdebug.Print("  in questo path il centroid di Current RE è al posto " + indInPathOfThisCentroid, nameFile);

                    var firstPartOfThePath       = myPathOfCentroids.path.GetRange(0, indInPathOfThisCentroid);
                    var firstPartOfThePathLength = firstPartOfThePath.Count;
                    //KLdebug.Print("Spezzo il path in un 1° path di lunghezza " + firstPartOfThePathLength, nameFile);

                    if (firstPartOfThePathLength > 2)
                    {
                        var newSonPath = new MyPathOfPoints(firstPartOfThePath,
                                                            myPathOfCentroids.pathGeometricObject);
                        listOfPathOfCentroids.Add(newSonPath);
                        //KLdebug.Print("è sufficientemente lungo: lo aggiungo di nuovo alla lista path da esaminare. Eccolo:", nameFile);
                        //for (int i = 0; i < newSonPath.path.Count; i++)
                        //{
                        //    KLdebug.Print("      " + newSonPath.path[i], nameFile);
                        //}
                    }
                    //else
                    //{
                    //    KLdebug.Print("Non è sufficientemente lungo: non lo aggiungo alla lista path da esaminare", nameFile);

                    //}

                    var secondPartOfThePath = myPathOfCentroids.path.GetRange(indInPathOfThisCentroid + 1,
                                                                              myPathOfCentroids.path.Count - (indInPathOfThisCentroid + 1));
                    var secondPartOfThePathLength = secondPartOfThePath.Count;
                    //KLdebug.Print("Spezzo il path in un 2° path di lunghezza " + secondPartOfThePathLength, nameFile);

                    if (secondPartOfThePathLength > 2)
                    {
                        var newSonPath = new MyPathOfPoints(secondPartOfThePath,
                                                            myPathOfCentroids.pathGeometricObject);
                        listOfPathOfCentroids.Add(newSonPath);
                        //KLdebug.Print("è sufficientemente lungo: lo aggiungo di nuovo alla lista path da esaminare. Eccolo:", nameFile);
                        //for (int i = 0; i < newSonPath.path.Count; i++)
                        //{
                        //    KLdebug.Print("      " + newSonPath.path[i], nameFile);
                        //}
                    }
                    //else
                    //{
                    //    KLdebug.Print("Non è sufficientemente lungo: non lo aggiungo alla lista path da esaminare", nameFile);
                    //}

                    listOfPathOfCentroids.Remove(myPathOfCentroids);
                    //KLdebug.Print("RIMOSSO il Path spezzato in due.", nameFile);
                    //KLdebug.Print(" ", nameFile);
                }
                listOfPathOfCentroids = listOfPathOfCentroids.OrderByDescending(x => x.path.Count).ThenBy(y => y.pathGeometricObject.GetType() == typeof(MyLine) ? 0 : 1).ToList();
                //KLdebug.Print("Riordino la lista listOfPathOfCentroids ancora da geometricamente verificare.", nameFile);
            }
            else
            {
                //KLdebug.Print("Non ho trovato nessun path che intersechi la RE " + indOfThisCentroid, nameFile);
            }

            // KLdebug.Print(" ", nameFile);
        }
Exemple #13
0
        public static void AddPathsFromNewCheckOfMB(MyMatrAdj matrAdjToSee, List <MyVertex> listCentroid,
                                                    ref List <MyPathOfPoints> listOfPaths, List <int> listOfExtremePoints, List <int> listOfMBPoints,
                                                    ref StringBuilder fileOutput, ref bool toleranceOk)
        {
            //Ultima ricerca:
            //individuo i path di length >3 e t.c. se num di MB nel path = s allora 0<s<length e
            //per ogni MB di tali path verifico che esista un path che contenga b1-MB-b2, con b1,b2 branch di MB.
            //[QUESTA PARTE SERVE IN PARTICOLARE PER I CASI "GRIGLIA"]
            if (listOfPaths.FindIndex(pathObject =>
                                      (pathObject.path.Count > 3 && pathObject.path.Count(listOfMBPoints.Contains) < pathObject.path.Count &&
                                       pathObject.path.Count(listOfMBPoints.Contains) > 0)) != -1)
            {
                var listOfPathsContainingMBToCheckAgain = new List <MyPathOfPoints>(
                    listOfPaths.FindAll(pathObject => (pathObject.path.Count > 3 && pathObject.path.Count(listOfMBPoints.Contains) < pathObject.path.Count &&
                                                       pathObject.path.Count(listOfMBPoints.Contains) > 0)));
                var listOfMBToCheckAgain = new List <int>(listOfMBPoints.FindAll(
                                                              mb => listOfPathsContainingMBToCheckAgain.FindIndex(pathObject => pathObject.path.Contains(mb)) != -1));

                fileOutput.AppendLine("\n");
                fileOutput.AppendLine("\n Path derivanti dal MB Check Again:");

                foreach (var mb in listOfMBToCheckAgain)
                {
                    List <int> branchesOfMB         = matrAdjToSee.matr.GetRow(mb).Find(entry => entry == 1).ToList(); //indici dei branch di mb
                    int        lengthOfBranchesList = branchesOfMB.Count;
                    for (var i = 0; i < lengthOfBranchesList - 1; i++)
                    {
                        for (var j = i + 1; j < lengthOfBranchesList; j++)
                        {
                            var branch1 = branchesOfMB[i];
                            var branch2 = branchesOfMB[j];
                            if (!(listOfExtremePoints.Contains(branch1)) && !(listOfExtremePoints.Contains(branch2)))
                            //perché se uno dei due branch è un estremo sono sicura che un path contenente branch1-mb-branch2 esiste
                            {
                                if (listOfPaths.FindIndex(pathObject => (pathObject.path.Contains(branch1) && pathObject.path.Contains(mb) && pathObject.path.Contains(branch2))) == -1)
                                //se non esiste path contenente branch1-mb-branch2
                                {
                                    List <int>            currentPath;
                                    MyPathGeometricObject pathCurve;
                                    if (listCentroid[branch2].Lieonline(GeometricUtilities.FunctionsLC.LinePassingThrough(listCentroid[mb], listCentroid[branch1])))
                                    {
                                        currentPath = ThreePointsGivenPathsLine(matrAdjToSee, listCentroid,
                                                                                listOfExtremePoints, branch1, mb, branch2, ref fileOutput,
                                                                                ref toleranceOk, out pathCurve);
                                    }
                                    else
                                    {
                                        currentPath = ThreePointsGivenPathsCircum(matrAdjToSee, listCentroid,
                                                                                  listOfExtremePoints, branch1, mb, branch2, ref fileOutput,
                                                                                  ref toleranceOk, out pathCurve);
                                    }

                                    //Verifica LongestPattern?

                                    //se nel path che ho creato ci fossero dei MB li avrei già presi,
                                    //se ci fossero dei simple non ancora toccati li avrei già presi,
                                    //sono quasi certa che il path sia composto da punti già percorsi almeno una volta
                                    //(sicuramente almeno una volta i branch del MB sono stati percorsi)...
                                    //----> Non faccio il salvataggio dei penultimi punti.

                                    var newPathObject = new MyPathOfPoints(currentPath, pathCurve);
                                    listOfPaths.Add(newPathObject);
                                }
                            }
                        }
                    }
                }
            }
        }// fine AddPathsFromNewCheckOfMB
        // This function updates the list of paths adding the paths raising from
        // the given 1st and 2nd seed set points (FOR ASSEMBLY)
        public static void TwoPointsGivenPaths_Assembly_ComposedPatterns(MyMatrAdj matrAdjToSee, int n, int startPointInd,
                                                                         int secondPointInd, List <MyPatternOfComponents> listOfPatternsOfComponents, List <MyVertex> listOfCentroids,
                                                                         List <int> listOfExtremePoints, ref List <int> listOfSimplePoints_Copy, List <int> listOfMBPoints,
                                                                         ref bool longestPattern, ref List <MyPathOfPoints> listOfPaths, ref List <int> listOfPenultimate,
                                                                         ref List <int> listOfLast, ref StringBuilder fileOutput, ref bool toleranceOk,
                                                                         ref List <MyMatrAdj> listOfMatrAdj, ref List <MyComposedPatternOfComponents> listOfOutputComposedPattern,
                                                                         ref List <MyComposedPatternOfComponents> listOfOutputComposedPatternTwo, ref List <int> listOfIndicesOfLongestPath,
                                                                         ModelDoc2 SwModel, SldWorks SwApplication)
        {
            if (listOfExtremePoints.Contains(secondPointInd))
            //If the branch is an ExtremePoint, I treat it in a special way as I have not
            //the path equation yet. So I guide the 3rd point search.
            {
                //I come back, so I look what are the branches of the StartPoint
                List <int> branchesSecond = matrAdjToSee.matr.GetRow(startPointInd).Find(entry => entry == 1).ToList();
                branchesSecond.Remove(secondPointInd);
                foreach (var branch2 in branchesSecond)
                {
                    var newMyPathOfPoints = new MyPathOfPoints();

                    //if (SecondPointInd(extreme), StartPointInd(MB), branch2 don't belong to an existing path in ListOfPaths)
                    if (listOfPaths.FindIndex(pathObject => (pathObject.path.Contains(secondPointInd) &&
                                                             pathObject.path.Contains(startPointInd) && pathObject.path.Contains(branch2))) == -1)
                    {
                        List <int>            currentPath;
                        MyPathGeometricObject pathCurve;

                        if (listOfCentroids[branch2].Lieonline(FunctionsLC.LinePassingThrough(listOfCentroids[startPointInd], listOfCentroids[secondPointInd])))
                        {
                            currentPath = Part.PathCreation_Part.Functions.ThreePointsGivenPathsLine(matrAdjToSee, listOfCentroids,
                                                                                                     listOfExtremePoints, secondPointInd, startPointInd, branch2,
                                                                                                     ref fileOutput, ref toleranceOk, out pathCurve);
                            // Notice that expansion will procede only in one direction
                        }
                        else
                        {
                            currentPath = Part.PathCreation_Part.Functions.ThreePointsGivenPathsCircum(matrAdjToSee, listOfCentroids,
                                                                                                       listOfExtremePoints, secondPointInd, startPointInd, branch2,
                                                                                                       ref fileOutput, ref toleranceOk, out pathCurve);
                            // Notice that expansion will procede only in one direction
                        }

                        if (toleranceOk == false)
                        {
                            return;
                        }
                        //If I have found a complete circumference I delete the repeated centroid index:
                        if (currentPath[0] == currentPath[currentPath.Count - 1])
                        {
                            currentPath.RemoveAt(currentPath.Count - 1);
                        }

                        newMyPathOfPoints.path = currentPath;
                        newMyPathOfPoints.pathGeometricObject = pathCurve;

                        listOfPaths.Add(newMyPathOfPoints);

                        fileOutput.AppendLine("Aggiunto alla lista nuovo path: ");
                        fileOutput.AppendLine("  -numero di baricentri:" + newMyPathOfPoints.path.Count);
                        if (pathCurve.GetType() == typeof(MyLine))
                        {
                            fileOutput.AppendLine("  -tipo di path: retta");
                            fileOutput.AppendLine("");
                        }
                        else
                        {
                            fileOutput.AppendLine("  -tipo di path: criconferenza");
                            fileOutput.AppendLine("");
                        }

                        //If a path of length n or n-1 is found, I move up the geometrical verify to see
                        //if the process can be stopped at this point (sufficiently satisfying result on this GS)
                        int m = currentPath.Count;
                        if (m == n || m == n - 1)
                        {
                            fileOutput.AppendLine("\n Trovato path che potrebbe dare un Longest Pattern: VERIFICO");

                            // Removing of the path from the list:
                            //this is done because if the pattern is verified the updating phase (in particular
                            //referred to the part of list of paths updating) will consider all the paths existing
                            //in the list of paths (so also the current long one) and the updating would be
                            //long and useless (we would try to compare the current path to itself).
                            listOfPaths.RemoveAt(listOfPaths.Count - 1);

                            if (newMyPathOfPoints.pathGeometricObject.GetType() == typeof(MyLine))
                            {
                                if (AssemblyUtilities_ComposedPatterns.LC_AssemblyTraverse.GetComposedPatternsFromPathLine_Assembly(newMyPathOfPoints,
                                                                                                                                    listOfPatternsOfComponents, ref listOfPaths,
                                                                                                                                    ref listOfMatrAdj,
                                                                                                                                    ref listOfOutputComposedPattern, ref listOfOutputComposedPatternTwo))
                                {
                                    fileOutput.AppendLine("\n è longestPattern verificato!! ");
                                    longestPattern = true;
                                    return;
                                }
                                else
                                {
                                    fileOutput.AppendLine("\n longestPattern NON verificato!! ");
                                    listOfPaths.Add(newMyPathOfPoints);

                                    // Updating of the list of Simple points not yet passed through:
                                    var ListOfPaths_copy = new List <MyPathOfPoints>(listOfPaths);
                                    listOfSimplePoints_Copy.RemoveAll(
                                        point => ListOfPaths_copy[ListOfPaths_copy.Count - 1].path.Contains(point));

                                    Part.PathCreation_Part.Functions.UpdateListsOfPenultimateAndLast(listOfExtremePoints,
                                                                                                     listOfMBPoints, ref listOfPenultimate, ref listOfLast, currentPath);

                                    listOfIndicesOfLongestPath.Add(listOfPaths.IndexOf(newMyPathOfPoints));
                                }
                            }
                            else //newMyPathOfCentroids.pathGeometricObject.GetType() == typeof (MyCircumForPath)
                            {
                                if (AssemblyUtilities_ComposedPatterns.LC_AssemblyTraverse.GetComposedPatternsFromPathCircum_Assembly(newMyPathOfPoints,
                                                                                                                                      listOfPatternsOfComponents, ref listOfPaths,
                                                                                                                                      ref listOfMatrAdj,
                                                                                                                                      ref listOfOutputComposedPattern, ref listOfOutputComposedPatternTwo,
                                                                                                                                      SwApplication, ref fileOutput))
                                {
                                    fileOutput.AppendLine("\n è longestPattern verificato!! ");
                                    longestPattern = true;
                                    return;
                                }
                                else
                                {
                                    fileOutput.AppendLine("\n longestPattern NON verificato!! ");
                                    listOfPaths.Add(newMyPathOfPoints);

                                    // Updating of the list of Simple points not yet passed through:
                                    var ListOfPaths_copy = new List <MyPathOfPoints>(listOfPaths);
                                    listOfSimplePoints_Copy.RemoveAll(
                                        point => ListOfPaths_copy[ListOfPaths_copy.Count - 1].path.Contains(point));

                                    Part.PathCreation_Part.Functions.UpdateListsOfPenultimateAndLast(listOfExtremePoints,
                                                                                                     listOfMBPoints, ref listOfPenultimate, ref listOfLast, currentPath);

                                    listOfIndicesOfLongestPath.Add(listOfPaths.IndexOf(newMyPathOfPoints));
                                }
                            }
                        }
                        else
                        {
                            Part.PathCreation_Part.Functions.UpdateListsOfPenultimateAndLast(listOfExtremePoints,
                                                                                             listOfMBPoints, ref listOfPenultimate, ref listOfLast, currentPath);
                        }
                    }
                }
            }
            else  // cioè listOfMBPoints.Contains(SecondPointInd) || ListOfSimplePoints.Contains(SecondPointInd)
            {
                List <int> branchesSecond = matrAdjToSee.matr.GetRow(secondPointInd).Find(entry => entry == 1).ToList();
                branchesSecond.Remove(startPointInd); //I remove the startingPoint not to come back in the start direction
                foreach (var branch2 in branchesSecond)
                {
                    var newMyPathOfPoints = new MyPathOfPoints();

                    // if (StartPointInd, SecondPointInd, branch2 don't belong to an existing path in ListOfPaths )
                    if (listOfPaths.FindIndex(pathObject => (pathObject.path.Contains(startPointInd) && pathObject.path.Contains(secondPointInd) && pathObject.path.Contains(branch2))) == -1)
                    {
                        List <int>            currentPath;
                        MyPathGeometricObject pathCurve;

                        if (listOfCentroids[branch2].Lieonline(FunctionsLC.LinePassingThrough(listOfCentroids[startPointInd], listOfCentroids[secondPointInd])))
                        {
                            currentPath = Part.PathCreation_Part.Functions.ThreePointsGivenPathsLine(matrAdjToSee, listOfCentroids,
                                                                                                     listOfExtremePoints, startPointInd, secondPointInd, branch2,
                                                                                                     ref fileOutput, ref toleranceOk, out pathCurve);
                        }
                        else
                        {
                            currentPath = Part.PathCreation_Part.Functions.ThreePointsGivenPathsCircum(matrAdjToSee, listOfCentroids,
                                                                                                       listOfExtremePoints, startPointInd, secondPointInd, branch2,
                                                                                                       ref fileOutput, ref toleranceOk, out pathCurve);
                        }

                        if (toleranceOk == false)
                        {
                            return;
                        }
                        //If I have found a complete circumference I delete the repeated centroid index:
                        if (currentPath[0] == currentPath[currentPath.Count - 1])
                        {
                            currentPath.RemoveAt(currentPath.Count - 1);
                        }

                        newMyPathOfPoints.path = currentPath;
                        newMyPathOfPoints.pathGeometricObject = pathCurve;

                        listOfPaths.Add(newMyPathOfPoints);

                        fileOutput.AppendLine("Aggiunto alla lista nuovo path: ");
                        fileOutput.AppendLine("  -numero di baricentri:" + newMyPathOfPoints.path.Count);
                        if (pathCurve.GetType() == typeof(MyLine))
                        {
                            fileOutput.AppendLine("  -tipo di path: retta");
                        }
                        else
                        {
                            fileOutput.AppendLine("  -tipo di path: circonferenza");
                        }

                        //If a path of length n or n-1 is found, I move up the geometrical verify to see
                        //if the process can be stopped at this point (sufficiently satisfying result on this GS)
                        int m = currentPath.Count;
                        if (m == n || m == n - 1)
                        {
                            fileOutput.AppendLine("\n Trovato path che potrebbe dare un Longest Pattern: VERIFICO");

                            // Removing of the path from the list:
                            listOfPaths.RemoveAt(listOfPaths.Count - 1);

                            if (newMyPathOfPoints.pathGeometricObject.GetType() == typeof(MyLine))
                            {
                                if (AssemblyUtilities_ComposedPatterns.LC_AssemblyTraverse.GetComposedPatternsFromPathLine_Assembly(newMyPathOfPoints,
                                                                                                                                    listOfPatternsOfComponents, ref listOfPaths,
                                                                                                                                    ref listOfMatrAdj,
                                                                                                                                    ref listOfOutputComposedPattern, ref listOfOutputComposedPatternTwo))
                                {
                                    fileOutput.AppendLine("\n è longestPattern verificato!! ");
                                    longestPattern = true;
                                    return;
                                }
                                else
                                {
                                    fileOutput.AppendLine("\n longestPattern NON verificato!! ");
                                    listOfPaths.Add(newMyPathOfPoints);

                                    // Updating of the list of Simple points not yet passed through:
                                    var ListOfPaths_copy = new List <MyPathOfPoints>(listOfPaths);
                                    listOfSimplePoints_Copy.RemoveAll(
                                        point => ListOfPaths_copy[ListOfPaths_copy.Count - 1].path.Contains(point));

                                    Part.PathCreation_Part.Functions.UpdateListsOfPenultimateAndLast(listOfExtremePoints,
                                                                                                     listOfMBPoints, ref listOfPenultimate, ref listOfLast, currentPath);

                                    listOfIndicesOfLongestPath.Add(listOfPaths.IndexOf(newMyPathOfPoints));
                                }
                            }
                            else //newMyPathOfCentroids.pathGeometricObject.GetType() == typeof (MyCircumForPath)
                            {
                                if (AssemblyUtilities_ComposedPatterns.LC_AssemblyTraverse.GetComposedPatternsFromPathCircum_Assembly(newMyPathOfPoints,
                                                                                                                                      listOfPatternsOfComponents, ref listOfPaths,
                                                                                                                                      ref listOfMatrAdj,
                                                                                                                                      ref listOfOutputComposedPattern, ref listOfOutputComposedPatternTwo,
                                                                                                                                      SwApplication, ref fileOutput))
                                {
                                    fileOutput.AppendLine("\n è longestPattern verificato!! ");
                                    longestPattern = true;
                                    return;
                                }
                                else
                                {
                                    fileOutput.AppendLine("\n longestPattern NON verificato!! ");
                                    listOfPaths.Add(newMyPathOfPoints);

                                    // Updating of the list of Simple points not yet passed through:
                                    var ListOfPaths_copy = new List <MyPathOfPoints>(listOfPaths);
                                    listOfSimplePoints_Copy.RemoveAll(
                                        point => ListOfPaths_copy[ListOfPaths_copy.Count - 1].path.Contains(point));

                                    Part.PathCreation_Part.Functions.UpdateListsOfPenultimateAndLast(listOfExtremePoints,
                                                                                                     listOfMBPoints, ref listOfPenultimate, ref listOfLast, currentPath);

                                    listOfIndicesOfLongestPath.Add(listOfPaths.IndexOf(newMyPathOfPoints));
                                }
                            }
                        }
                        else
                        {
                            Part.PathCreation_Part.Functions.UpdateListsOfPenultimateAndLast(listOfExtremePoints,
                                                                                             listOfMBPoints, ref listOfPenultimate, ref listOfLast, currentPath);
                        }
                    }
                }
            }
        }
Exemple #15
0
        // This function updates the list of paths adding the paths raising from the given 1st and 2nd seed set points.
        public static void TwoPointsGivenPaths(MyMatrAdj matrAdjToSee, int n, int startPointInd,
                                               int secondPointInd, List <MyRepeatedEntity> listOfREOnThisSurface, List <MyVertex> listCentroid,
                                               List <int> listOfExtremePoints, ref List <int> listOfSimplePoints_Copy, List <int> listOfMBPoints,
                                               ref bool longestPattern, ref List <MyPathOfPoints> listOfPaths, ref List <int> listOfPenultimate,
                                               ref List <int> listOfLast, ref StringBuilder fileOutput, ref bool toleranceOk,
                                               ref List <MyMatrAdj> listOfMatrAdj, ref List <MyGroupingSurface> listOfMyGroupingSurface,
                                               List <MyGroupingSurface> listOfInitialGroupingSurface,
                                               ref List <MyPattern> listOfOutputPattern, ref List <MyPattern> listOfOutputPatternTwo,
                                               ref List <int> listOfIndicesOfLongestPath)
        {
            if (listOfExtremePoints.Contains(secondPointInd))
            //If the branch is an ExtremePoint, I treat it in a special way as I have not
            //the path equation yet. So I guide the 3rd point search.
            {
                //I come back, so I look what are the branches of the StartPoint
                List <int> BranchesSecond = matrAdjToSee.matr.GetRow(startPointInd).Find(entry => entry == 1).ToList();
                BranchesSecond.Remove(secondPointInd);
                foreach (int branch2 in BranchesSecond)
                {
                    var newMyPathOfCentroids = new MyPathOfPoints();

                    //if (SecondPointInd(extreme), StartPointInd(MB), branch2 don't belong to an existing path in ListOfPaths)
                    if (listOfPaths.FindIndex(pathObject => (pathObject.path.Contains(secondPointInd) &&
                                                             pathObject.path.Contains(startPointInd) && pathObject.path.Contains(branch2))) == -1)
                    {
                        List <int> Path      = new List <int>();
                        var        pathCurve = new MyPathGeometricObject();

                        if (listCentroid[branch2].Lieonline(FunctionsLC.LinePassingThrough(
                                                                listCentroid[startPointInd], listCentroid[secondPointInd])))
                        {
                            Path = ThreePointsGivenPathsLine(matrAdjToSee, listCentroid,
                                                             listOfExtremePoints, secondPointInd, startPointInd, branch2,
                                                             ref fileOutput, ref toleranceOk, out pathCurve);
                            // Notice that expansion will procede only in one direction
                        }
                        else
                        {
                            Path = ThreePointsGivenPathsCircum(matrAdjToSee, listCentroid,
                                                               listOfExtremePoints, secondPointInd, startPointInd, branch2,
                                                               ref fileOutput, ref toleranceOk, out pathCurve);
                            // Notice that expansion will procede only in one direction
                        }

                        if (toleranceOk == false)
                        {
                            return;
                        }

                        //If I have found a complete circumference I delete the repeated centroid index:
                        if (Path[0] == Path[Path.Count - 1])
                        {
                            Path.RemoveAt(Path.Count - 1);
                        }

                        newMyPathOfCentroids.path = Path;
                        newMyPathOfCentroids.pathGeometricObject = pathCurve;

                        listOfPaths.Add(newMyPathOfCentroids);

                        fileOutput.AppendLine("Aggiunto alla lista nuovo path: ");
                        fileOutput.AppendLine("  -numero di baricentri:" + newMyPathOfCentroids.path.Count);
                        if (pathCurve.GetType() == typeof(MyLine))
                        {
                            fileOutput.AppendLine("  -tipo di path: retta");
                            fileOutput.AppendLine("");
                        }
                        else
                        {
                            fileOutput.AppendLine("  -tipo di path: criconferenza");
                            fileOutput.AppendLine("");
                        }

                        //If a path of length n or n-1 is found, I move up the geometrical verify to see
                        //if the process can be stopped at this point (sufficiently satisfying result on this GS)
                        int m = Path.Count;
                        if (m == n || m == n - 1)
                        {
                            fileOutput.AppendLine("\n Trovato path che potrebbe dare un Longest Pattern: VERIFICO");

                            // Removing of the path from the list:
                            //this is done because if the pattern is verified the updating phase (in particular
                            //referred to the part of list of paths updating) will consider all the paths existing
                            //in the list of paths (so also the current long one) and the updating would be
                            //long and useless (we would try to compare the current path to itself).
                            listOfPaths.RemoveAt(listOfPaths.Count - 1);

                            if (PartUtilities.GeometryAnalysis.GetPatternsFromPath(newMyPathOfCentroids, listOfREOnThisSurface,
                                                                                   ref listOfPaths, ref listOfMatrAdj, ref listOfMyGroupingSurface, listOfInitialGroupingSurface,
                                                                                   ref listOfOutputPattern, ref listOfOutputPatternTwo))
                            {
                                longestPattern = true;
                                return;
                            }
                            else
                            {
                                listOfPaths.Add(newMyPathOfCentroids);
                                // Updating of the list of Simple points not yet passed through:
                                var ListOfPaths_copy = new List <MyPathOfPoints>(listOfPaths);
                                listOfSimplePoints_Copy.RemoveAll(point => ListOfPaths_copy[ListOfPaths_copy.Count - 1].path.Contains(point));

                                UpdateListsOfPenultimateAndLast(listOfExtremePoints,
                                                                listOfMBPoints, ref listOfPenultimate, ref listOfLast, Path);

                                listOfIndicesOfLongestPath.Add(listOfPaths.IndexOf(newMyPathOfCentroids));
                            }
                        }
                        else
                        {
                            UpdateListsOfPenultimateAndLast(listOfExtremePoints,
                                                            listOfMBPoints, ref listOfPenultimate, ref listOfLast, Path);
                        }
                    }
                }
            }


            else  // cioè listOfMBPoints.Contains(SecondPointInd) || ListOfSimplePoints.Contains(SecondPointInd)
            {
                //trasforma in lista la selezione sull'array (SecondPointInd,:)
                List <int> BranchesSecond = matrAdjToSee.matr.GetRow(secondPointInd).Find(entry => entry == 1).ToList();

                //levo il punto di partenza (che è sicuramente un branch) per non tornare indietro
                BranchesSecond.Remove(startPointInd);
                foreach (int branch2 in BranchesSecond)
                {
                    var newMyPathOfCentroids = new MyPathOfPoints();

                    // if (StartPointInd, SecondPointInd, branch2 don't belong to an existing path in ListOfPaths )
                    if (listOfPaths.FindIndex(pathObject => (pathObject.path.Contains(startPointInd) &&
                                                             pathObject.path.Contains(secondPointInd) && pathObject.path.Contains(branch2))) == -1)
                    {
                        List <int> Path      = new List <int>();
                        var        pathCurve = new MyPathGeometricObject();

                        if (listCentroid[branch2].Lieonline(FunctionsLC.LinePassingThrough(
                                                                listCentroid[startPointInd], listCentroid[secondPointInd])))
                        {
                            Path = ThreePointsGivenPathsLine(matrAdjToSee, listCentroid,
                                                             listOfExtremePoints, startPointInd, secondPointInd, branch2,
                                                             ref fileOutput, ref toleranceOk, out pathCurve);
                        }
                        else
                        {
                            Path = ThreePointsGivenPathsCircum(matrAdjToSee, listCentroid,
                                                               listOfExtremePoints, startPointInd, secondPointInd, branch2,
                                                               ref fileOutput, ref toleranceOk, out pathCurve);
                        }

                        if (toleranceOk == false)
                        {
                            return;
                        }


                        //If I have found a complete circumference I delete the repeated centroid index:
                        if (Path[0] == Path[Path.Count - 1])
                        {
                            Path.RemoveAt(Path.Count - 1);
                        }
                        newMyPathOfCentroids.path = Path;
                        newMyPathOfCentroids.pathGeometricObject = pathCurve;

                        listOfPaths.Add(newMyPathOfCentroids);

                        fileOutput.AppendLine("Aggiunto alla lista nuovo path: ");
                        fileOutput.AppendLine("  -numero di baricentri:" + newMyPathOfCentroids.path.Count);
                        if (pathCurve.GetType() == typeof(MyLine))
                        {
                            fileOutput.AppendLine("  -tipo di path: retta");
                        }
                        else
                        {
                            fileOutput.AppendLine("  -tipo di path: circonferenza");
                        }

                        //If a path of length n or n-1 is found, I move up the geometrical verify to see
                        //if the process can be stopped at this point (sufficiently satisfying result on this GS)
                        int m = Path.Count;
                        if (m == n || m == n - 1)
                        {
                            fileOutput.AppendLine("\n Trovato path che potrebbe dare un Longest Pattern: VERIFICO");

                            // Removing of the path from the list:
                            listOfPaths.RemoveAt(listOfPaths.Count - 1);

                            if (PartUtilities.GeometryAnalysis.GetPatternsFromPath(newMyPathOfCentroids, listOfREOnThisSurface,
                                                                                   ref listOfPaths, ref listOfMatrAdj, ref listOfMyGroupingSurface, listOfInitialGroupingSurface,
                                                                                   ref listOfOutputPattern, ref listOfOutputPatternTwo))
                            {
                                longestPattern = true;
                                return;
                            }
                            else
                            {
                                listOfPaths.Add(newMyPathOfCentroids);

                                // Updating of the list of Simple points not yet passed through:
                                var ListOfPaths_copy = new List <MyPathOfPoints>(listOfPaths);
                                listOfSimplePoints_Copy.RemoveAll(point => ListOfPaths_copy[ListOfPaths_copy.Count - 1].path.Contains(point));

                                UpdateListsOfPenultimateAndLast(listOfExtremePoints,
                                                                listOfMBPoints, ref listOfPenultimate, ref listOfLast, Path);

                                listOfIndicesOfLongestPath.Add(listOfPaths.IndexOf(newMyPathOfCentroids));
                            }
                        }
                        else
                        {
                            UpdateListsOfPenultimateAndLast(listOfExtremePoints,
                                                            listOfMBPoints, ref listOfPenultimate, ref listOfLast, Path);
                        }
                    }
                }
            }
        }