static public double FindTilt(Vector.MemorySafe_CartVect normalVector)
        {
            double calculatedTilt = -999;
            //may need to also take into account other factors that, at this stage, seem to not be important
            //building Direction of Relative North
            //zone Direction of Relative North
            //GlobalGeometryRules coordinate system
            //I may need to know this in the future then rotate the axis vectors I am making below

            //x-axis [1 0 0] points east, y-axis [0 1 0] points north, z-axis[0 0 1] points up to the sky
            //alignment with y axis means north pointing, alignment with z-axis means it is pointing up to the sky (like a flat roof)
            double nX = 0;
            double nY = 1;
            double nZ = 0;
            Vector.MemorySafe_CartVect northVector = new Vector.MemorySafe_CartVect(nX, nY, nZ);

            double uX = 0;
            double uY = 0;
            double uZ = 1;
            Vector.MemorySafe_CartVect upVector = new Vector.MemorySafe_CartVect(uX, uY, uZ);

            //rotate the axis vectors for the future

            //ensure the vector passed into the function is a unit vector
            normalVector = Vector.UnitVector(normalVector);
            //get tilt:  cross product of normal vector and upVector
            //since parallel and anti parallel vectors will return the same cross product [0,0,0] I need to filter out the antiparalll case
            if (normalVector.X == upVector.X * -1 && normalVector.Y == upVector.Y * -1 && normalVector.Z == upVector.Z * -1)
            {
                calculatedTilt = 180;
                return calculatedTilt;
            }
            else
            {
                Vector.MemorySafe_CartVect tiltVector = Vector.CrossProduct(normalVector, upVector);
                double tiltVectorMagnitude = Vector.VectorMagnitude(tiltVector);
                calculatedTilt = Math.Round(Math.Asin(tiltVectorMagnitude) * 180 / Math.PI, 2);
                return calculatedTilt;
            }
        }
Beispiel #2
0
        public static double FindAzimuth(Vector.MemorySafe_CartVect normalVector)
        {
            double calculatedAzimuth = -999;
            //may need to also take into account other factors that, at this stage, seem to not be important
            //building Direction of Relative North
            //zone Direction of Relative North
            //GlobalGeometryRules coordinate system
            //I may need to know this in the future then rotate the axis vectors I am making below

            //x-axis [1 0 0] points east, y-axis [0 1 0] points north, z-axis[0 0 1] points up to the sky
            //alignment with y axis means north pointing, alignment with z-axis means it is pointing up to the sky (like a flat roof)

            Vector.MemorySafe_CartVect northVector = new Vector.MemorySafe_CartVect(0, 1, 0);

            Vector.MemorySafe_CartVect southVector = new Vector.MemorySafe_CartVect(0, -1, 0);

            Vector.MemorySafe_CartVect eastVector = new Vector.MemorySafe_CartVect(1, 0, 0);

            Vector.MemorySafe_CartVect westVector = new Vector.MemorySafe_CartVect(-1, 0, 0);

            Vector.MemorySafe_CartVect upVector = new Vector.MemorySafe_CartVect(0, 0, 1);

            //rotate the axis vectors for the future

            //ensure the vector passed into the function is a unit vector
            normalVector = Vector.UnitVector(normalVector);
            //get X-Y projection of the normal vector
            //normalVector.Z = 0;
            //get azimuth:  cross product of normal vector x-y projection and northVector
            //2-14-2014 we added last two statements to deal with normal
            //1st quadrant
            if ((normalVector.X == 0 && normalVector.Y == 1) || (normalVector.X == 1 && normalVector.Y == 0) || (normalVector.X > 0 && normalVector.Y > 0) || (normalVector.X > 0 && normalVector.Z != 0) || (normalVector.Y > 0 && normalVector.Z != 0))
            {
                //get azimuth:  cross product of normal vector x-y projection and northVector
                Vector.MemorySafe_CartVect azVector = Vector.CrossProduct(normalVector, northVector);
                double azVectorMagnitude = Vector.VectorMagnitude(azVector);

                //modification for when the vector is in different quadrants
                calculatedAzimuth = Math.Round(Math.Asin(azVectorMagnitude) * 180 / Math.PI, 2);
                return calculatedAzimuth;
            }
            //second quadrant
            else if ((normalVector.X < 0 && normalVector.Y > 0) )
            {
                Vector.MemorySafe_CartVect azVector = Vector.CrossProduct(normalVector, westVector);
                double azVectorMagnitude = Vector.VectorMagnitude(azVector);

                //modification for when the vector is in different quadrants
                calculatedAzimuth = Math.Round(Math.Asin(azVectorMagnitude) * 180 / Math.PI, 2) + 270;
                return calculatedAzimuth;
            }
            //quadrant 3
            else if ((normalVector.X < 0 && normalVector.Y < 0) || (normalVector.X == -1 && normalVector.Y == 0) || (normalVector.X < 0 && normalVector.Z !=0))
            {
                Vector.MemorySafe_CartVect azVector = Vector.CrossProduct(normalVector, southVector);
                double azVectorMagnitude = Vector.VectorMagnitude(azVector);

                //modification for when the vector is in different quadrants
                calculatedAzimuth = Math.Round(Math.Asin(azVectorMagnitude) * 180 / Math.PI, 2) + 180;
                return calculatedAzimuth;
            }
            //quadrant 4
            else if ((normalVector.X > 0 && normalVector.Y < 0) || (normalVector.X == 0 && normalVector.Y == -1) || (normalVector.Y < 0 && normalVector.Z != 0))
            {
                Vector.MemorySafe_CartVect azVector = Vector.CrossProduct(normalVector, eastVector);
                double azVectorMagnitude = Vector.VectorMagnitude(azVector);

                //modification for when the vector is in different quadrants
                calculatedAzimuth = Math.Round(Math.Asin(azVectorMagnitude) * 180 / Math.PI, 2) + 90;
                return calculatedAzimuth;
            }
            //this will happen to vectors that point straight down or straight up because we are only interested in the X-Y projection and set the Z to zero anyways
            else if (normalVector.X == 0 && normalVector.Y == 0)
            {
                calculatedAzimuth = 0;
                return calculatedAzimuth;
            }

            //get the

            return calculatedAzimuth;
        }
        private static DOEgbXMLReportingObj GetOpeningPolyLoopCoordMatch(Vector.MemorySafe_CartCoord standardPolyLoopCoord, OpeningDefinitions testOpening, DOEgbXMLReportingObj report, string standardOpeningId)
        {
            List<Vector.MemorySafe_CartCoord> possibleMatch = new List<Vector.MemorySafe_CartCoord>();
            List<Vector.MemorySafe_CartCoord> exactMatch = new List<Vector.MemorySafe_CartCoord>();
            report.MessageList.Add("Testing Polyloop coordinates for Standard opening " + standardOpeningId);
            report.MessageList.Add(" X: " + standardPolyLoopCoord.X.ToString() + ", Y: " + standardPolyLoopCoord.Y.ToString() + ", Z: " + standardPolyLoopCoord.Z.ToString());
            foreach (Vector.MemorySafe_CartCoord testPolyLoopCoord in testOpening.PlCoords)
            {

                //find an appropriate match
                double diffX = Math.Abs(testPolyLoopCoord.X - standardPolyLoopCoord.X);
                if (diffX < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                {
                    //found a perfect X Match
                    if (diffX == 0)
                    {
                        //test Y
                        double diffY = Math.Abs(testPolyLoopCoord.Y - standardPolyLoopCoord.Y);
                        if (diffY < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                        {
                            //perfect Y Match
                            if (diffY == 0)
                            {
                                double diffZ = Math.Abs(testPolyLoopCoord.Z - standardPolyLoopCoord.Z);
                                if (diffZ < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                                {
                                    //perfect Z match
                                    if (diffZ == 0)
                                    {
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId + ": Found polyLoop coordinate that matches Standard Opening " + standardOpeningId + " exactly");
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId);
                                        report.MessageList.Add(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        exactMatch.Add(testPolyLoopCoord);
                                    }
                                    else
                                    {
                                        //not a perfect Z match but within bounds
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId + ": Found polyLoop coordinate that matches Standard Opening " + standardOpeningId + " X and Y coordinates exactly.  Z coordinate within allowable tolerance.");
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId);
                                        report.MessageList.Add(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                }
                                else
                                {
                                    //z coordinate not within tolerance
                                    continue;
                                }
                            }
                            //Y Match is within the allowable tolerance
                            else
                            {
                                double diffZ = Math.Abs(testPolyLoopCoord.Z - standardPolyLoopCoord.Z);
                                if (diffZ < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                                {
                                    //perfect Z match
                                    if (diffZ == 0)
                                    {
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId + ": Found polyLoop coordinate that matches Standard Opening " + standardOpeningId + " in the X and Z coordinates, exactly.  Y coordinate is within tolerance.");
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId);
                                        report.MessageList.Add(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                    else
                                    {
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId + ": Found polyLoop coordinate that matches Standard Opening " + standardOpeningId + " X exactly.  Y and Z coordinates are within tolerance.");
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId);
                                        report.MessageList.Add(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                }
                                else
                                {
                                    //z coordinate is not within tolerance
                                    continue;
                                }
                            }
                        }
                        else
                        {
                            //a y match could not be found within tolerance
                            continue;
                        }

                    }
                    else
                    {
                        //not a perfect X match, but within tolerance
                        //test Y
                        double diffY = Math.Abs(testPolyLoopCoord.Y - standardPolyLoopCoord.Y);
                        if (diffY < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                        {
                            //perfect Y Match
                            if (diffY == 0)
                            {
                                double diffZ = Math.Abs(testPolyLoopCoord.Z - standardPolyLoopCoord.Z);
                                if (diffZ < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                                {
                                    //perfect Z match
                                    if (diffZ == 0)
                                    {
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId + ": Found polyLoop coordinate that matches Standard Opening " + standardOpeningId + " Y and Z coordinate exactly.  X is within tolerance.");
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId);
                                        report.MessageList.Add(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                    else
                                    {
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId + ": Found polyLoop coordinate that matches Standard Opening " + standardOpeningId + " Y coordinate exactly.  X and Z is within tolerance.");
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId);
                                        report.MessageList.Add(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                }
                                else
                                {
                                    //z is not matched so continue
                                    continue;
                                }
                            }
                            // the Y match is not perfect but within tolerance
                            else
                            {
                                double diffZ = Math.Abs(testPolyLoopCoord.Z - standardPolyLoopCoord.Z);
                                if (diffZ < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                                {
                                    //perfect Z match
                                    if (diffZ == 0)
                                    {
                                        report.MessageList.Add("Test opening " + testOpening.OpeningId + ": Found polyLoop coordinate that matches Standard Opening " + standardOpeningId + " Z coordinate exactly.  The X and Y coordinates are within tolerance.");
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId);
                                        report.MessageList.Add(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                    else
                                    {
                                        report.MessageList.Add("Test opening " + testOpening.OpeningId + ": Found polyLoop coordinate that matches Standard Opening " + standardOpeningId + ".  The X, Y, and Z coordinates are within tolerance.");
                                        report.MessageList.Add("Test Opening " + testOpening.OpeningId);
                                        report.MessageList.Add(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                }
                                // no match found for the Z
                                else
                                {
                                    continue;
                                }
                            }
                        }
                        //no match could be found for the Y
                        else
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    //not a match found for the X and continue
                    continue;
                }
            }
            if (exactMatch.Count > 1)
            {
                report.MessageList.Add("Error, overlapping polyLoop coordinates found in the Test Opening PolyLoop.");
                report.passOrFail = false;
                return report;
            }
            else if (exactMatch.Count == 1)
            {
                report.MessageList.Add("One coordinate candidate found.  Exact match");
                report.passOrFail = true;
                return report;
            }
            if (possibleMatch.Count > 1)
            {
                report.MessageList.Add("No exact solution for a match of the polyLoop coordinate.  More than one coordinate candidate found.");
                report.passOrFail = false;
                return report;
            }
            else if (possibleMatch.Count == 1)
            {
                report.MessageList.Add("One coordinate candidate found.");
                report.passOrFail = true;
                return report;
            }
            else
            {
                report.MessageList.Add("No coordinate candidate found.");
                report.passOrFail = false;
                return report;
            }

        }
        private static bool GetPolyLoopCoordMatch(Vector.MemorySafe_CartCoord standardPolyLoopCoord, SurfaceDefinitions testSurface, string standardSurfaceId, double testlengthConversion, double standardlengthConversion)
        {
            List<Vector.MemorySafe_CartCoord> possibleMatch = new List<Vector.MemorySafe_CartCoord>();
            List<Vector.MemorySafe_CartCoord> exactMatch = new List<Vector.MemorySafe_CartCoord>();
            logger.Debug("START SUBROUTINE: GetPolyLoopCoordMatch");
            logger.Debug(standardSurfaceId +"Coordinates: "+" X: " + standardPolyLoopCoord.X.ToString() + ", Y: " + standardPolyLoopCoord.Y.ToString() + ", Z: " + standardPolyLoopCoord.Z.ToString());
            foreach (Vector.MemorySafe_CartCoord testPolyLoopCoord in testSurface.PlCoords)
            {

                //find an appropriate match
                double diffX = Math.Abs((testPolyLoopCoord.X * testlengthConversion) - (standardPolyLoopCoord.X * standardlengthConversion));
                if (diffX < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                {
                    //found a perfect X Match
                    if (diffX == 0)
                    {
                        //test Y
                        double diffY = Math.Abs((testPolyLoopCoord.Y * testlengthConversion) - (standardPolyLoopCoord.Y * standardlengthConversion));
                        if (diffY < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                        {
                            //perfect Y Match
                            if (diffY == 0)
                            {
                                double diffZ = Math.Abs((testPolyLoopCoord.Z * testlengthConversion) - (standardPolyLoopCoord.Z * standardlengthConversion));
                                if (diffZ < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                                {
                                    //perfect Z match
                                    if (diffZ == 0)
                                    {
                                        logger.Debug("Test Surface " + testSurface.SurfaceId + ": Found polyLoop coordinate that matches Standard Surface " + standardSurfaceId + " exactly");
                                        logger.Debug("Test Surface " + testSurface.SurfaceId);
                                        logger.Debug(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        exactMatch.Add(testPolyLoopCoord);
                                    }
                                    else
                                    {
                                        //not a perfect Z match but within bounds
                                        logger.Debug("Test Surface " + testSurface.SurfaceId + ": Found polyLoop coordinate that matches Standard Surface " + standardSurfaceId + " X and Y coordinates exactly.  Z coordinate within allowable tolerance.");
                                        logger.Debug("Test Surface " + testSurface.SurfaceId);
                                        logger.Debug(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                }
                                else
                                {
                                    //z coordinate not within tolerance
                                    continue;
                                }
                            }
                            //Y Match is within the allowable tolerance
                            else
                            {
                                double diffZ = Math.Abs((testPolyLoopCoord.Z * testlengthConversion) - (standardPolyLoopCoord.Z * standardlengthConversion));
                                if (diffZ < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                                {
                                    //perfect Z match
                                    if (diffZ == 0)
                                    {
                                        logger.Debug("Test Surface " + testSurface.SurfaceId + ": Found polyLoop coordinate that matches Standard Surface " + standardSurfaceId + " in the X and Z coordinates, exactly.  Y coordinate is within tolerance.");
                                        logger.Debug("Test Surface " + testSurface.SurfaceId);
                                        logger.Debug(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                    else
                                    {
                                        logger.Debug("Test Surface " + testSurface.SurfaceId + ": Found polyLoop coordinate that matches Standard Surface " + standardSurfaceId + " X exactly.  Y and Z coordinates are within tolerance.");
                                        logger.Debug("Test Surface " + testSurface.SurfaceId);
                                        logger.Debug(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                }
                                else
                                {
                                    //z coordinate is not within tolerance
                                    continue;
                                }
                            }
                        }
                        else
                        {
                            //a y match could not be found within tolerance
                            continue;
                        }

                    }
                    else
                    {
                        //not a perfect X match, but within tolerance
                        //test Y
                        double diffY = Math.Abs((testPolyLoopCoord.Y * testlengthConversion) - (standardPolyLoopCoord.Y * standardlengthConversion));
                        if (diffY < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                        {
                            //perfect Y Match
                            if (diffY == 0)
                            {
                                double diffZ = Math.Abs((testPolyLoopCoord.Z * testlengthConversion) - (standardPolyLoopCoord.Z * standardlengthConversion));
                                if (diffZ < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                                {
                                    //perfect Z match
                                    if (diffZ == 0)
                                    {
                                        logger.Info("Test Surface " + testSurface.SurfaceId + ": Found polyLoop coordinate that matches Standard Surface " + standardSurfaceId + " Y and Z coordinate exactly.  X is within tolerance.");
                                        logger.Info("Test Surface " + testSurface.SurfaceId);
                                        logger.Info(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                    else
                                    {
                                        logger.Info("Test Surface " + testSurface.SurfaceId + ": Found polyLoop coordinate that matches Standard Surface " + standardSurfaceId + " Y coordinate exactly.  X and Z is within tolerance.");
                                        logger.Info("Test Surface " + testSurface.SurfaceId);
                                        logger.Info(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                }
                                else
                                {
                                    //z is not matched so continue
                                    continue;
                                }
                            }
                            // the Y match is not perfect but within tolerance
                            else
                            {
                                double diffZ = Math.Abs((testPolyLoopCoord.Z * testlengthConversion) - (standardPolyLoopCoord.Z * standardlengthConversion));
                                if (diffZ < DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance)
                                {
                                    //perfect Z match
                                    if (diffZ == 0)
                                    {
                                        logger.Info("Test Surface " + testSurface.SurfaceId + ": Found polyLoop coordinate that matches Standard Surface " + standardSurfaceId + " Z coordinate exactly.  The X and Y coordinates are within tolerance.");
                                        logger.Info("Test Surface " + testSurface.SurfaceId);
                                        logger.Info(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                    else
                                    {
                                        logger.Info("Test Surface " + testSurface.SurfaceId + ": Found polyLoop coordinate that matches Standard Surface " + standardSurfaceId + ".  The X, Y, and Z coordinates are within tolerance.");
                                        logger.Info("Test Surface " + testSurface.SurfaceId);
                                        logger.Info(" X: " + testPolyLoopCoord.X.ToString() + ", Y: " + testPolyLoopCoord.Y.ToString() + ", Z: " + testPolyLoopCoord.Z.ToString());
                                        possibleMatch.Add(testPolyLoopCoord);
                                    }
                                }
                                // no match found for the Z
                                else
                                {
                                    continue;
                                }
                            }
                        }
                        //no match could be found for the Y
                        else
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    //not a match found for the X and continue
                    continue;
                }
            }
            if (exactMatch.Count > 1)
            {
                logger.Info("Error, overlapping polyLoop coordinates found in the Test Surface PolyLoop.");
                return false;
            }
            else if (exactMatch.Count == 1)
            {
                logger.Info("One coordinate candidate found.  Exact match");
                return true;
            }
            if (possibleMatch.Count > 1)
            {
                logger.Info("No exact solution for a match of the polyLoop coordinate.  More than one coordinate candidate found.");
                return false;
            }
            else if (possibleMatch.Count == 1)
            {
                logger.Info("One coordinate candidate found.");
                return true;
            }
            else
            {
                logger.Info("No coordinate candidate found.");
                return false;
            }

        }
        public bool EdgesShareVertex(Vector.MemorySafe_CartCoord vertex, DOEgbXMLBasics.EdgeFamily edge)
        {
            double lengthTol = DOEgbXMLBasics.Tolerances.SurfacePLCoordTolerance;
            double dx = Math.Abs(vertex.X - edge.startendpt[0].X);
            double dy = Math.Abs(vertex.Y - edge.startendpt[0].Y);
            double dz = Math.Abs(vertex.Z - edge.startendpt[0].Z);
            if(dx <= lengthTol && dy <= lengthTol && dz <= lengthTol)
            {
                return true;
            }

            dx = Math.Abs(vertex.X - edge.startendpt[1].X);
            dy = Math.Abs(vertex.Y - edge.startendpt[1].Y);
            dz = Math.Abs(vertex.Z - edge.startendpt[1].Z);

            if(dx <= lengthTol && dy <= lengthTol && dz <= lengthTol)
            {
                return true;
            }

            return false;
        }
        public bool FoundVertexMatch(Vector.MemorySafe_CartCoord vertex, List<DOEgbXMLBasics.EdgeFamily> edges)
        {
            int vertexMatchCount = 0;
            for(int e = 0; e < edges.Count(); e++)
            {
                if(EdgesShareVertex(vertex,edges[e]))
                {
                    vertexMatchCount++;
                }
            }

            if(vertexMatchCount == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
            
        }
 private static string MakeCoordString(Vector.MemorySafe_CartCoord coord)
 {
     return "(" + coord.X + "," + coord.Y + "," + coord.Z + ")";
 }
        public static CartesianPoint makegbCartesianPt(Vector.MemorySafe_CartCoord pt)
        {
            CartesianPoint cp = new CartesianPoint();
            cp.Coordinate = new string[3];

            cp.Coordinate[0] = gb.FormatDoubleToString(pt.X);
            cp.Coordinate[1] = gb.FormatDoubleToString(pt.Y);
            cp.Coordinate[2] = gb.FormatDoubleToString(pt.Z);
            return cp;
        }
        //we have already proven that the neighboring edges are aligned with the edge
        //so we do not perform an exhaustive vector search to find the answer.  All we do instead is try and position them correctly
        //in sequence as well as is possible.
        //we do not check for overlaps until later
        public static Vector.EdgeFamily[] AlignEdges(Vector.EdgeFamily[] alignededges, Vector.EdgeFamily edge, double tol)
        {
            try
            {
                List<double> magnitudes = new List<double>();
                List<int> indices = new List<int>();
                for (int i = 0; i < edge.relatedEdges.Count(); i++)
                {
                    Vector.MemorySafe_CartCoord longstart = edge.startendpt[0];
                    Vector.MemorySafe_CartCoord longend = edge.startendpt[1];
                    Vector.MemorySafe_CartVect longv = Vector.CreateMemorySafe_Vector(longstart, longend);
                    double maglong = Vector.VectorMagnitude(longv);
                    Vector.EdgeFamily shortedge = edge.relatedEdges[i];
                    Vector.MemorySafe_CartCoord shortstart = shortedge.startendpt[0];
                    Vector.MemorySafe_CartCoord shortend = shortedge.startendpt[1];
                    Vector.MemorySafe_CartVect el1 = Vector.CreateMemorySafe_Vector(longstart, shortstart);
                    Vector.MemorySafe_CartVect el2 = Vector.CreateMemorySafe_Vector(longstart, shortend);
                    double magel1 = Vector.VectorMagnitude(el1);
                    double magel2 = Vector.VectorMagnitude(el2);

                    //put the greater of the two magnitudes in the list
                    if (magel1 > magel2)
                    {
                        shortedge.startendpt.Reverse();
                        if (magnitudes.Count >= 1)
                        {
                            bool added = false;
                            for (int m = 0; m < magnitudes.Count(); m++)
                            {
                                if (magel1 < magnitudes[m])
                                {
                                    magnitudes.Insert(m, magel1);
                                    indices.Insert(m, i);
                                    added = true;
                                    break;
                                }
                            }
                            if (!added)
                            {
                                magnitudes.Add(magel1);
                                indices.Add(i);
                            }

                        }
                        else
                        {
                            magnitudes.Add(magel1);
                            indices.Add(i);
                        }
                    }
                    else
                    {
                        if (magnitudes.Count >= 1)
                        {
                            bool added = false;
                            for (int m = 0; m < magnitudes.Count(); m++)
                            {
                                if (magel1 < magnitudes[m])
                                {
                                    magnitudes.Insert(m, magel2);
                                    indices.Insert(m, i);
                                    added = true;
                                    break;
                                }
                            }
                            if (!added)
                            {
                                magnitudes.Add(magel2);
                                indices.Add(i);
                            }

                        }
                        else
                        {
                            magnitudes.Add(magel2);
                            indices.Add(i);
                        }
                    }

                }
                int alignedcounter = 0;
                foreach (int i in indices)
                {
                    alignededges[alignedcounter] = edge.relatedEdges[i];
                    alignedcounter++;
                }

                return alignededges;

            }
            catch (Exception e)
            {

            }
            return alignededges;
        }
Beispiel #10
0
 private static bool isCoordUnique(Dictionary<Vector.CartCoord, Tuple<List<string>, List<bool>>> clist, Vector.CartCoord coord)
 {
     foreach (Vector.CartCoord approvedcoord in clist.Keys)
     {
         //a text for tolerances?
         if (approvedcoord.X == coord.X && approvedcoord.Y == coord.Y && approvedcoord.Z == coord.Z)
         {
             return false;
         }
     }
     return true;
 }