Ejemplo n.º 1
0
        public static bool IsRotationTwoPatterns(MyPattern firstMyPattern, MyPattern secondMyPattern, double teta,
                                                 double[] axisDirection, MyVertex circumCenter, SldWorks SwApplication, ref StringBuilder fileOutput)
        {
            //check of the length correspondence:
            var firstPatternLength  = firstMyPattern.listOfMyREOfMyPattern.Count;
            var secondPatternLength = secondMyPattern.listOfMyREOfMyPattern.Count;

            if (firstPatternLength != secondPatternLength)
            {
                return(false);
            }

            //KLdebug.Print("La 0^ RE del 1° pattern è compatibile con la 0^ RE del 2° pattern? " +
            //    IsRotationTwoRE(firstMyPattern.listOfMyREOfMyPattern[0],
            //    secondMyPattern.listOfMyREOfMyPattern[0], teta, axisDirection, circumCenter), nameFile);
            //KLdebug.Print("La 0^ RE del 1° pattern è compatibile con la (n-1)^ RE del 2° pattern? " +
            //    IsRotationTwoRE(firstMyPattern.listOfMyREOfMyPattern[0],
            //    secondMyPattern.listOfMyREOfMyPattern[secondPatternLength - 1], teta, axisDirection, circumCenter), nameFile);

            if (PartUtilities.GeometryAnalysis.IsRotationTwoRE(firstMyPattern.listOfMyREOfMyPattern[0],
                                                               secondMyPattern.listOfMyREOfMyPattern[0], teta, axisDirection, circumCenter) ||
                PartUtilities.GeometryAnalysis.IsRotationTwoRE(firstMyPattern.listOfMyREOfMyPattern[0],
                                                               secondMyPattern.listOfMyREOfMyPattern[secondPatternLength - 1], teta, axisDirection, circumCenter))
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        //Update the list of MyGroupingSurface, deleting the MyRepeatedEntity already set in the newPattern
        public static void UpdateListOfMyGroupingSurface_ComposedPatterns(MyPattern pattern,
                                                                          ref List <MyGroupingSurfaceForPatterns> listOfMyGroupingSurface, int indOfThisPattern)
        {
            var indOfFound =
                listOfMyGroupingSurface.FindIndex(
                    gs => gs.listOfPatternsLine.FindIndex(patternInGS =>
                                                          patternInGS.idMyPattern == pattern.idMyPattern) != -1);

            if (indOfFound != -1)
            {
                var listOfGroupingSurfaceToUpdate = listOfMyGroupingSurface.FindAll(
                    gs => gs.listOfPatternsLine.FindIndex(patternInGS =>
                                                          patternInGS.idMyPattern == pattern.idMyPattern) != -1);

                foreach (var gs in listOfGroupingSurfaceToUpdate)
                {
                    gs.listOfPatternsLine.Remove(pattern);

                    if (gs.listOfPatternsLine.Count < 2)
                    {
                        listOfMyGroupingSurface.Remove(gs);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        //This function verifies if two given patterns are related by translation, with the difference
        //vector between the two pattern centroids as candidate translational vector.
        public static bool IsTranslationTwoPatterns(MyPattern firstMyPattern, MyPattern secondMyPattern)
        {
            const string nameFile    = "ComposedPatterns_Linear.txt";
            var          whatToWrite = "";

            //check of the length correspondence:
            var firstPatternLength  = firstMyPattern.listOfMyREOfMyPattern.Count;
            var secondPatternLength = secondMyPattern.listOfMyREOfMyPattern.Count;

            if (firstPatternLength != secondPatternLength)
            {
                return(false);
            }

            //candidate translational array computation:
            double[] candidateTranslationArray =
            {
                secondMyPattern.patternCentroid.x - firstMyPattern.patternCentroid.x,
                secondMyPattern.patternCentroid.y - firstMyPattern.patternCentroid.y,
                secondMyPattern.patternCentroid.z - firstMyPattern.patternCentroid.z,
            };

            if (PartUtilities.GeometryAnalysis.IsTranslationTwoREGivenCandidateVector(firstMyPattern.listOfMyREOfMyPattern[0],
                                                                                      secondMyPattern.listOfMyREOfMyPattern[0], candidateTranslationArray) ||
                PartUtilities.GeometryAnalysis.IsTranslationTwoREGivenCandidateVector(firstMyPattern.listOfMyREOfMyPattern[0],
                                                                                      secondMyPattern.listOfMyREOfMyPattern[secondPatternLength - 1], candidateTranslationArray))
            {
                return(true);
            }
            return(false);
        }
        public static bool KLGetPatternsFromLinearPath_Assembly(List <MyRepeatedComponent> listOfComponentsOnThePath,
                                                                MyPathGeometricObject pathObject, ref List <MyPathOfPoints> listOfPathOfPoints,
                                                                List <MyVertex> listOfOrigins, ref List <MyMatrAdj> listOfMatrAdj,
                                                                ref List <MyPatternOfComponents> listOfOutputPattern, ref List <MyPatternOfComponents> listOfOutputPatternTwo)
        {
            // Se non uso listOfComponentsOnThePath probabilmente dovrò aggiornare listOfOrigins con il numero effettivo di elementi che appartengono al pattern selezionato.
            var numOfCompOnThisPath = listOfComponentsOnThePath.Count;
            //var numOfCompOnThisPath = listOfOrigins.Count;

            var noStop = true;

            //const string nameFile = "GetTranslationalPatterns.txt";
            //KLdebug.Print(" ", nameFile);
            //KLdebug.Print("VERIFICA DELLE POSSIBILI TRASLAZIONI TRA " + numOfCompOnThisPath + " COMPONENTS:", nameFile);
            //KLdebug.Print(" ", nameFile);

            var i = 0;

            while (i < (numOfCompOnThisPath - 1))
            {
                var newPattern      = new MyPatternOfComponents();
                var foundNewPattern = KLGetMaximumTranslation_Assembly(listOfComponentsOnThePath, pathObject, ref i, ref numOfCompOnThisPath,
                                                                       ref noStop, ref newPattern);

                if (foundNewPattern)
                {
                    if (newPattern.listOfMyRCOfMyPattern.Count == numOfCompOnThisPath ||
                        newPattern.listOfMyRCOfMyPattern.Count == numOfCompOnThisPath - 1)
                    {
                        noStop = true;
                    }

                    var listREofRcomponents = new List <MyRepeatedEntity>(listOfComponentsOnThePath.Select(comp => comp.RepeatedEntity).ToList());
                    //var listGS = new List<Surface>();
                    var newPatternPoint = new MyPattern(listREofRcomponents, newPattern.pathOfMyPattern,
                                                        newPattern.typeOfMyPattern);

                    KLCheckAndUpdate_Assembly(newPattern, ref listOfPathOfPoints,
                                              listOfOrigins, ref listOfMatrAdj,
                                              ref listOfOutputPattern, ref listOfOutputPatternTwo);
                }
            }
            //KLdebug.Print(" ", nameFile);
            //KLdebug.Print("FINE LISTA :) ", nameFile);

            if (noStop)
            {
                //KLdebug.Print("NESSUNA INTERRUZIONE: PATTERN DI LUNGHEZZA MASSIMA SU QUESTO PATH!", nameFile);
                return(true);
            }
            return(false);
        }
        //   (NOT USED function)
        //This function verifies is two linear patterns are collinear (share the same line corresponding
        //to their path). It returns TRUE if they do, FALSE otherwise.
        public static bool AreCollinear(MyPattern first, MyPattern second)
        {
            var firstLine = (MyLine)first.pathOfMyPattern;

            if (second.listOfMyREOfMyPattern[0].centroid.Lieonline(firstLine) &&
                second.listOfMyREOfMyPattern[1].centroid.Lieonline(firstLine))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static bool GetPatternsFromCircularPath(List <MyRepeatedEntity> listOfREOnThePath,
                                                       MyPathGeometricObject pathObject, ref List <MyPathOfPoints> listOfPathOfCentroids,
                                                       List <MyRepeatedEntity> listOfREOnThisSurface, ref List <MyMatrAdj> listOfMatrAdj,
                                                       ref List <MyGroupingSurface> listOfMyGroupingSurface,
                                                       List <MyGroupingSurface> listOfInitialGroupingSurface, ref List <MyPattern> listOfOutputPattern,
                                                       ref List <MyPattern> listOfOutputPatternTwo)
        {
            var numOfRE = listOfREOnThePath.Count;
            var noStop  = true;


            var i = 0;

            while (i < (numOfRE - 1))
            {
                var newPattern      = new MyPattern();
                var j               = i;
                var foundNewPattern = GetMaximumTranslation(listOfREOnThePath, pathObject, ref j, ref numOfRE, ref noStop,
                                                            ref newPattern, listOfInitialGroupingSurface);

                if (foundNewPattern == false)
                {
                    var pathCircumference = (MyCircumForPath)pathObject;
                    foundNewPattern = GetMaximumRotation(listOfREOnThePath, pathCircumference, ref i, ref numOfRE, ref noStop,
                                                         ref newPattern, listOfInitialGroupingSurface);
                }
                else
                {
                    i = j;
                }

                if (foundNewPattern)
                {
                    if (newPattern.listOfMyREOfMyPattern.Count == numOfRE || newPattern.listOfMyREOfMyPattern.Count == numOfRE - 1)
                    {
                        noStop = true;
                    }

                    CheckAndUpdate(newPattern, ref listOfPathOfCentroids,
                                   listOfREOnThisSurface, ref listOfMatrAdj, ref listOfMyGroupingSurface,
                                   ref listOfOutputPattern, ref listOfOutputPatternTwo);
                }
            }

            if (noStop)
            {
                return(true);
            }
            return(false);
        }
Ejemplo n.º 7
0
        //Update data in case on newPatternPoint of length > 2
        public static void UpdateOtherData(MyPattern newPattern, ref List <MyPathOfPoints> listOfPathOfCentroids,
                                           List <MyRepeatedEntity> listOfREOnThisSurface, ref List <MyMatrAdj> listOfMatrAdj,
                                           ref List <MyGroupingSurface> listOfMyGroupingSurface, ref List <MyPattern> listOfOutputPatternTwo)
        {
            const string nameFile = "GetTranslationalPatterns.txt";

            foreach (var re in newPattern.listOfMyREOfMyPattern)
            {
                var indOfThisCentroid = listOfREOnThisSurface.IndexOf(re);

                UpdateListOfMyPathOfCentroids(ref listOfPathOfCentroids, indOfThisCentroid, nameFile);
                UpdateListOfMyMatrAdj(ref listOfMatrAdj, indOfThisCentroid, nameFile);
                UpdateListOfMyGroupingSurface(re, ref listOfMyGroupingSurface, indOfThisCentroid);
                UpdateListOfPatternTwo(re, ref listOfOutputPatternTwo, indOfThisCentroid);
            }
        }
Ejemplo n.º 8
0
        //Update list of MyComposedPattern geometrically verified of length = 2: delete the ones containing
        //a pattern of the newComposedPattern
        public static void UpdateListOfPatternTwo_ComposedPatterns(MyPattern pattern,
                                                                   ref List <MyComposedPattern> listOfOutputComposedPatternTwo, int indOfThisPattern)
        {
            var indOfFound =
                listOfOutputComposedPatternTwo.FindIndex(
                    composedPattern => composedPattern.listOfMyPattern.FindIndex(
                        patternInComposedPattern => patternInComposedPattern.idMyPattern == pattern.idMyPattern) != -1);

            if (indOfFound != -1)
            {
                var found = listOfOutputComposedPatternTwo.Find(
                    composedPattern => composedPattern.listOfMyPattern.FindIndex(
                        patternInComposedPattern => patternInComposedPattern.idMyPattern == pattern.idMyPattern) != -1);

                listOfOutputComposedPatternTwo.Remove(found);
            }
        }
Ejemplo n.º 9
0
        public static void CheckAndUpdate(MyPattern newPattern, ref List <MyPathOfPoints> listOfPathOfCentroids,
                                          List <MyRepeatedEntity> listOfREOnThisSurface, ref List <MyMatrAdj> listOfMatrAdj,
                                          ref List <MyGroupingSurface> listOfMyGroupingSurface,
                                          ref List <MyPattern> listOfOutputPattern, ref List <MyPattern> listOfOutputPatternTwo)
        {
            var lengthOfPattern = newPattern.listOfMyREOfMyPattern.Count;

            // if lengthOfPattern = 2, I add the newPatternPoint only if there is not another pattern in listOfOutputPatternTwo
            // containing one of the two RE in the newPatternPoint.
            if (lengthOfPattern == 2)
            {
                int i        = 0;
                var addOrNot = true;
                while (addOrNot == true && i < 2)
                {
                    var currentRE  = newPattern.listOfMyREOfMyPattern[i];
                    var indOfFound =
                        listOfOutputPatternTwo.FindIndex(
                            pattern => pattern.listOfMyREOfMyPattern.FindIndex(re => re.idRE == currentRE.idRE) != -1);
                    if (indOfFound != -1)
                    {
                        addOrNot = false;
                    }
                    i++;
                }

                if (addOrNot == true)
                {
                    listOfOutputPatternTwo.Add(newPattern);
                }
            }
            // if lengthOfPattern > 2, I add the newPatternPoint and I update the other data
            // (aiming not to find pattern containing RE already set in this newPatternPoint)
            else
            {
                listOfOutputPattern.Add(newPattern);

                UpdateOtherData(newPattern, ref listOfPathOfCentroids, listOfREOnThisSurface, ref listOfMatrAdj,
                                ref listOfMyGroupingSurface, ref listOfOutputPatternTwo);
            }
        }
Ejemplo n.º 10
0
        //This function verifies if two given patterns are related by translation, with the difference
        //vector between the two pattern centroids as candidate translational vector.
        public static bool IsReflectionTwoPatterns(MyPattern firstMyPattern, MyPattern secondMyPattern)
        {
            //check of the length correspondence:
            var firstPatternLength  = firstMyPattern.listOfMyREOfMyPattern.Count;
            var secondPatternLength = secondMyPattern.listOfMyREOfMyPattern.Count;

            if (firstPatternLength != secondPatternLength)
            {
                return(false);
            }

            //candidate reflectional plane computation:
            var candidateReflMyPlane = PartUtilities.GeometryAnalysis.GetCandidateReflectionalMyPlane(firstMyPattern.patternCentroid,
                                                                                                      secondMyPattern.patternCentroid, null);

            if (PartUtilities.GeometryAnalysis.IsReflectionTwoREGivenCandidateReflPlane(firstMyPattern.listOfMyREOfMyPattern[0],
                                                                                        secondMyPattern.listOfMyREOfMyPattern[0], candidateReflMyPlane) ||
                PartUtilities.GeometryAnalysis.IsReflectionTwoREGivenCandidateReflPlane(firstMyPattern.listOfMyREOfMyPattern[0],
                                                                                        secondMyPattern.listOfMyREOfMyPattern[secondPatternLength - 1], candidateReflMyPlane))
            {
                return(true);
            }
            return(false);
        }
        //It detect the maximum symmetry relation in a set of MyRepeatedEntity, starting from index i of the list of MyRE
        public static bool GetMaximumRotation(List <MyRepeatedEntity> listOfREOnThePath, MyCircumForPath pathObject,
                                              ref int i, ref int numOfRE, ref bool noStop, ref MyPattern outputPattern,
                                              List <MyGroupingSurface> listOfInitialGroupingSurface)
        {
            //const string nameFile = "GetRotationalPatterns.txt";
            //KLdebug.Print(" ", nameFile);
            //KLdebug.Print("NUOVO AVVIO DI RICERCA ROTAZIONE", nameFile);
            //KLdebug.Print(" ", nameFile);
            //var whatToWrite = "";

            var listOfREOfNewMyPattern = new List <MyRepeatedEntity> {
                listOfREOnThePath[i]
            };
            var lengthOfCurrentPath = 1;   // = it represents the number of couples related by translation
            var exit = false;

            //Computation of the rotation angle:
            double[] planeNormal =
            {
                pathObject.circumplane.a,
                pathObject.circumplane.b,
                pathObject.circumplane.c
            };
            var teta = FunctionsLC.FindAngle(listOfREOnThePath[0].centroid, listOfREOnThePath[1].centroid, pathObject.circumcenter);

            var axisDirection = establishAxisDirection(listOfREOnThePath[0].centroid, listOfREOnThePath[1].centroid,
                                                       pathObject.circumcenter, planeNormal);

            //var SwModel = (ModelDoc2)SwApplication.ActiveDoc;
            //SwModel.ClearSelection2(true);
            //SwModel.Insert3DSketch();
            //SwModel.CreatePoint2(pathObject.circumcenter.x, pathObject.circumcenter.y, pathObject.circumcenter.z);
            //SwModel.InsertSketch();

            while (i < (numOfRE - 1) && exit == false) //fino alla penultima RE
            {
                //KLdebug.Print(" ", nameFile);
                //KLdebug.Print(" ", nameFile);
                //whatToWrite = string.Format("         Confronto {0}^ RE e la {1}^ RE: ", i, i + 1);
                //KLdebug.Print(whatToWrite, nameFile);

                if (IsRotationTwoRE(listOfREOnThePath[i], listOfREOnThePath[i + 1], teta, axisDirection, pathObject.circumcenter))
                {
                    listOfREOfNewMyPattern.Add(listOfREOnThePath[i + 1]);
                    lengthOfCurrentPath += 1;
                    //KLdebug.Print("Aggiunta " + (i + 1) + "-esima RE al MYPattern. lengthOfCurrentPath = " + lengthOfCurrentPath, nameFile);
                    i++;
                }
                else
                {
                    exit   = true;
                    noStop = false;

                    //KLdebug.Print(" ", nameFile);
                    //KLdebug.Print("------>>> Interruzione alla posizione: " + i, nameFile);
                    //KLdebug.Print(" ", nameFile);

                    i++;
                }
            }
            // KLdebug.Print(" ", nameFile);

            if (lengthOfCurrentPath > 1)
            {
                outputPattern.listOfMyREOfMyPattern = listOfREOfNewMyPattern;
                outputPattern.pathOfMyPattern       = pathObject;
                var listOfGroupingSurfaceForThisPattern = findGroupingSurfacesForThisPattern(listOfInitialGroupingSurface,
                                                                                             listOfREOfNewMyPattern, lengthOfCurrentPath);
                outputPattern.listOfGroupingSurfaces = listOfGroupingSurfaceForThisPattern;
                //KLdebug.Print("lengthOfCurrentPath = " + lengthOfCurrentPath, nameFile);

                outputPattern.typeOfMyPattern      = "ROTATION";
                outputPattern.constStepOfMyPattern = listOfREOfNewMyPattern[0].centroid.Distance(listOfREOfNewMyPattern[1].centroid);
                //KLdebug.Print("CREATO PATTERN Rotazionale circolare DI LUNGHEZZA = " + lengthOfCurrentPath, nameFile);

                outputPattern.angle = teta;
                return(true);
            }
            //KLdebug.Print("lengthOfCurrentPath = " + lengthOfCurrentPath, nameFile);
            //KLdebug.Print("IL PATTERN TRANS ha LUNGHEZZA NULLA, NON HO CREATO NIENTE.", nameFile);
            //KLdebug.Print(" ", nameFile);
            return(false);
        }
Ejemplo n.º 12
0
        //PRIMA DI USARE QUESTO METODO RICORDARSI DI ELIMINARE LA CURRENTgROUPINGSURFACE DALLA LISTA!!!!

        public static void FindPatternsInGS(MyGroupingSurface currentGroupingSurface, ref StringBuilder fileOutput,
                                            ref List <MyPattern> listOfMyPattern, ref List <MyGroupingSurface> listOfMyGroupingSurface,
                                            ref List <MyPattern> listOfMyPatternTwo, ref bool toleranceOK, List <MyGroupingSurface> listOfInitialGroupingSurface)
        {
            var ListOfREOnThisSurface =
                currentGroupingSurface.listOfREOfGS.Select(myRepeatedEntity => myRepeatedEntity).ToList();
            var listOfCentroidsThisGS =
                currentGroupingSurface.listOfREOfGS.Select(myRepeatedEntity => myRepeatedEntity.centroid).ToList();
            var numOfCentroidsOnThisGS = listOfCentroidsThisGS.Count;
            var maxPath = false; //it is TRUE if the maximum Pattern is found, FALSE otherwise.


            if (numOfCentroidsOnThisGS > 2)
            {
                List <MyMatrAdj> listOfMyMatrAdj = Functions.CreateMatrAdj(listOfCentroidsThisGS, ref fileOutput);


                while (listOfMyMatrAdj.Count > 0 && maxPath == false && toleranceOK == true)
                {
                    bool onlyShortPath;

                    var currentMatrAdj = new MyMatrAdj(listOfMyMatrAdj[0].d, listOfMyMatrAdj[0].matr, listOfMyMatrAdj[0].nOccur);
                    listOfMyMatrAdj.Remove(listOfMyMatrAdj[0]);
                    //NOTA: forse la mia MatrAdj non deve essere rimossa ma conservata,
                    //soprattutto nel caso in cui si presenta onlyShortPath = true
                    //(non avrebbe senso cancellarla, ma conservarla per la ricerca di path
                    //di 2 RE).
                    fileOutput.AppendLine("----> Considero NUOVA MatrAdj. Sono rimaste ancora " + listOfMyMatrAdj.Count +
                                          " MatrAdj da controllare.");
                    fileOutput.AppendLine(" ");

                    List <MyPathOfPoints> listOfPathOfCentroids;
                    maxPath = Functions.FindPaths(currentMatrAdj, ListOfREOnThisSurface, ref fileOutput,
                                                  out listOfPathOfCentroids, out onlyShortPath, ref toleranceOK,
                                                  ref listOfMyMatrAdj, ref listOfMyGroupingSurface,
                                                  listOfInitialGroupingSurface, ref listOfMyPattern, ref listOfMyPatternTwo);
                    fileOutput.AppendLine(" ");
                    fileOutput.AppendLine("PER QUESTA MATRADJ prima della ricerca 'ufficiale' di pattern': ");
                    fileOutput.AppendLine("maxPath = " + maxPath);
                    fileOutput.AppendLine("listOfMyPattern.Count = " + listOfMyPattern.Count);
                    fileOutput.AppendLine("listOfMyPatternTwo.Count = " + listOfMyPatternTwo.Count);
                    fileOutput.AppendLine("onlyShortPath = " + onlyShortPath);
                    fileOutput.AppendLine("toleranceOK = " + toleranceOK);
                    //fileOutput.AppendLine("listOfPathOfCentroids.Count = " + listOfPathOfCentroids.Count);

                    if (toleranceOK == true)
                    {
                        if (listOfPathOfCentroids != null)
                        {
                            if (maxPath == false)
                            {
                                if (onlyShortPath == false)
                                {
                                    GetPatternsFromListOfPaths(listOfPathOfCentroids, ListOfREOnThisSurface,
                                                               ref listOfMyMatrAdj, ref listOfMyGroupingSurface, listOfInitialGroupingSurface,
                                                               ref listOfMyPattern, ref listOfMyPatternTwo);
                                }
                                else
                                {
                                    //non faccio niente e li rimetto in gioco per
                                }
                            }
                        }
                        else
                        {
                            fileOutput.AppendLine(" ---> NO PATH FOUND in this adjacency matrix!");
                        }
                    }
                    else
                    {
                        fileOutput.AppendLine("===>>    TOLLERANZA NON SUFFICIENTEMENTE PICCOLA. TERMINATO.");
                        return;
                    }
                }
            }
            else
            {
                //numOfCentroidsOnThisGS = 2
                if (numOfCentroidsOnThisGS == 2)
                {
                    fileOutput.AppendLine("Su QUESTA GS ci sono solo 2 RE: ");

                    if (IsTranslationTwoRE(ListOfREOnThisSurface[0], ListOfREOnThisSurface[1]))
                    {
                        fileOutput.AppendLine("Le due RE sono legate da TRASLAZIONE!");
                        var listOfPathOfCentroids = new List <MyPathOfPoints>();
                        var listOfMyMatrAdj       = new List <MyMatrAdj>();
                        var newPatternRE          = new List <MyRepeatedEntity>();
                        newPatternRE.Add(ListOfREOnThisSurface[0]);
                        newPatternRE.Add(ListOfREOnThisSurface[1]);
                        var newPatternGeomObject = FunctionsLC.LinePassingThrough(listOfCentroidsThisGS[0], listOfCentroidsThisGS[1]);
                        var newPatternType       = "TRANSLATION of length 2";
                        var listOfGroupingSurfaceForThisPattern = findGroupingSurfacesForThisPattern(listOfInitialGroupingSurface,
                                                                                                     newPatternRE, numOfCentroidsOnThisGS);
                        var newPattern = new MyPattern(newPatternRE, newPatternGeomObject, newPatternType, listOfGroupingSurfaceForThisPattern);
                        CheckAndUpdate(newPattern, ref listOfPathOfCentroids,
                                       ListOfREOnThisSurface, ref listOfMyMatrAdj, ref listOfMyGroupingSurface,
                                       ref listOfMyPattern, ref listOfMyPatternTwo);
                    }
                    else
                    {
                        if (IsReflectionTwoRE(ListOfREOnThisSurface[0], ListOfREOnThisSurface[1], null))
                        {
                            fileOutput.AppendLine("Le due RE sono legate da RIFLESSIONE!");
                            var listOfPathOfCentroids = new List <MyPathOfPoints>();
                            var listOfMyMatrAdj       = new List <MyMatrAdj>();
                            var newPatternRE          = new List <MyRepeatedEntity>();
                            newPatternRE.Add(ListOfREOnThisSurface[0]);
                            newPatternRE.Add(ListOfREOnThisSurface[1]);
                            var newPatternGeomObject = FunctionsLC.LinePassingThrough(listOfCentroidsThisGS[0], listOfCentroidsThisGS[1]);
                            var newPatternType       = "REFLECTION";
                            var listOfGroupingSurfaceForThisPattern = findGroupingSurfacesForThisPattern(listOfInitialGroupingSurface,
                                                                                                         newPatternRE, numOfCentroidsOnThisGS);
                            var newPattern = new MyPattern(newPatternRE, newPatternGeomObject, newPatternType, listOfGroupingSurfaceForThisPattern);
                            CheckAndUpdate(newPattern, ref listOfPathOfCentroids,
                                           ListOfREOnThisSurface, ref listOfMyMatrAdj, ref listOfMyGroupingSurface,
                                           ref listOfMyPattern, ref listOfMyPatternTwo);
                        }
                    }
                }
            }
        }
Ejemplo n.º 13
0
        //It detect the maximum translational relation in a set of MyRepeatedEntity, starting from index i of the list of MyRE
        //(INITIAL PATH TYPE: line or circumference)
        public static bool GetMaximumTranslation(List <MyRepeatedEntity> listOfREOnThePath, MyPathGeometricObject pathObject,
                                                 ref int i, ref int numOfRE, ref bool noStop, ref MyPattern outputPattern, List <MyGroupingSurface> listOfInitialGroupingSurface)
        {
            #region Old version: computation of the candidate translational array computed as the MEAN VECTOR of all the connection arrays of the centroids
            //To compute the candidateTranslationArray I compute the mean vector
            //of all the difference vector between the centroids:
            //double sumOfx = 0;
            //double sumOfy = 0;
            //double sumOfz = 0;
            //for (int i = 0; i < (numOfRE - 1); i++)
            //{
            //    sumOfx += listOfREOnThePath[i + 1].centroid.x - listOfREOnThePath[i].centroid.x;
            //    sumOfy += listOfREOnThePath[i + 1].centroid.y - listOfREOnThePath[i].centroid.y;
            //    sumOfz += listOfREOnThePath[i + 1].centroid.z - listOfREOnThePath[i].centroid.z;
            //}
            //double[] candidateTranslationArray =
            //{
            //    sumOfx/(numOfRE-1),
            //    sumOfy/(numOfRE-1),
            //    sumOfz/(numOfRE-1)
            //};
            //var whatToWrite = string.Format("Candidate translational array: ({0}, {1}, {2})",
            //    candidateTranslationArray[0], candidateTranslationArray[1], candidateTranslationArray[2]);
            //KLdebug.Print(whatToWrite, nameFile);
            #endregion

            var listOfREOfNewMyPattern = new List <MyRepeatedEntity> {
                listOfREOnThePath[i]
            };
            var lengthOfCurrentPath = listOfREOfNewMyPattern.Count; // = number of couple possibly related by translation (= number of repetition of distance d)
            var exit = false;
            while (i < (numOfRE - 1) && exit == false)              //fino alla penultima RE
            {
                if (IsTranslationTwoRE(listOfREOnThePath[i], listOfREOnThePath[i + 1]))
                {
                    listOfREOfNewMyPattern.Add(listOfREOnThePath[i + 1]);
                    lengthOfCurrentPath += 1;
                    i++;
                }
                else
                {
                    exit   = true;
                    noStop = false;

                    i++;
                }
            }

            if (lengthOfCurrentPath > 1)
            {
                outputPattern.listOfMyREOfMyPattern = listOfREOfNewMyPattern;
                outputPattern.pathOfMyPattern       = pathObject;

                var listOfGroupingSurfaceForThisPattern = findGroupingSurfacesForThisPattern(listOfInitialGroupingSurface,
                                                                                             listOfREOfNewMyPattern, lengthOfCurrentPath);

                outputPattern.listOfGroupingSurfaces = listOfGroupingSurfaceForThisPattern;
                if (pathObject.GetType() == typeof(MyLine))
                {
                    outputPattern.typeOfMyPattern = "linear TRANSLATION";
                }
                else
                {
                    outputPattern.typeOfMyPattern = "circular TRANSLATION";

                    var teta = FunctionsLC.FindAngle(listOfREOfNewMyPattern[0].centroid,
                                                     listOfREOfNewMyPattern[1].centroid, ((MyCircumForPath)pathObject).circumcenter);
                    outputPattern.angle = teta;
                }
                outputPattern.constStepOfMyPattern = listOfREOfNewMyPattern[0].centroid.Distance(listOfREOfNewMyPattern[1].centroid);
                return(true);
            }

            return(false);
        }