public void StartTest(XmlReader xmldoc, string testToRun, ref gbXMLReport gbr, string username = "******") { log4net.Config.XmlConfigurator.Configure(); TestToRun = testToRun; globalMatchObject = new gbXMLMatches(); globalMatchObject.Init(); //first create a list of lists that is indexed identically to the drop down list the user selects TestDetail = new DOEgbXMLTestDetail(); //then populate the list of lists. All indexing is done "by hand" in InitializeTestResultStrings() TestDetail.InitializeTestResultStrings(); //create report list reportlist will store all the test result ReportList = new List<DOEgbXMLReportingObj>(); //Load an XML File for the test at hand gbXMLTestFile = new XmlDocument(); gbXMLTestFile.Load(xmldoc); gbXMLStandardFile = new XmlDocument(); gbXMLStandardFile.Load(filepaths[TestToRun]); if (!TestFileIsAvailable()) { //TODO: update browser json with something to indicate there is a problem return; } //Define the namespace XmlNamespaceManager gbXMLns1 = new XmlNamespaceManager(gbXMLTestFile.NameTable); gbXMLns1.AddNamespace("gbXMLv5", "http://www.gbxml.org/schema"); XmlNamespaceManager gbXMLns2 = new XmlNamespaceManager(gbXMLStandardFile.NameTable); gbXMLns2.AddNamespace("gbXMLv5", "http://www.gbxml.org/schema"); List<XmlDocument> gbXMLdocs = new List<XmlDocument>(); gbXMLdocs.Add(gbXMLTestFile); gbXMLdocs.Add(gbXMLStandardFile); List<XmlNamespaceManager> gbXMLnsm = new List<XmlNamespaceManager>(); gbXMLnsm.Add(gbXMLns1); gbXMLnsm.Add(gbXMLns2); //standardizing all tests on US-IP Conversions c = new Conversions(); Conversions.volumeUnitEnum testVol = Conversions.volumeUnitEnum.CubicFeet; Conversions.volumeUnitEnum validatorVol = Conversions.volumeUnitEnum.CubicFeet; Conversions.areaUnitEnum testArea = Conversions.areaUnitEnum.SquareFeet; Conversions.areaUnitEnum validatorArea = Conversions.areaUnitEnum.SquareFeet; Conversions.lengthUnitEnum testLength = Conversions.lengthUnitEnum.Feet; Conversions.lengthUnitEnum validatorLength = Conversions.lengthUnitEnum.Feet; Conversions.lengthUnitEnum standardLength = Conversions.lengthUnitEnum.Feet; Conversions.areaUnitEnum standardArea = Conversions.areaUnitEnum.SquareFeet; Conversions.volumeUnitEnum standardVol = Conversions.volumeUnitEnum.CubicFeet; //standardize all units to feet, square feet, and cubic feet double testlengthConversion = 1; double testareaConversion = 1; double testvolumeConversion = 1; double standardlengthConversion = 1; double standardareaConversion = 1; double standardvolConversion = 1; bool mustBePlanar = false; for(int ns=0; ns< gbXMLnsm.Count; ns++) { if (ns == 0) { XmlNodeList nodes = gbXMLdocs[ns].SelectNodes("/gbXMLv5:gbXML", gbXMLnsm[ns]); StandardizeToUSIP(nodes, c, ref testlengthConversion, ref testareaConversion, ref testvolumeConversion, ref testLength, ref testArea, ref testVol); } else { XmlNodeList nodes = gbXMLdocs[ns].SelectNodes("/gbXMLv5:gbXML", gbXMLnsm[ns]); StandardizeToUSIP(nodes, c, ref standardlengthConversion, ref standardareaConversion, ref standardvolConversion, ref standardLength, ref standardArea, ref standardVol); } } //TODO: Add a summary of the Unit of Measures stuff above to the final result //Create a Log file that logs the success or failure of each test. //Eventually maybe I want to create a little HTML factory output = ""; log = ""; table += "<div class='container'>" + "<h3>" + "Test Sections" + "</h3>"; table += "<table class='table table-bordered'>"; table += "<tr class='info'>" + "<td>" + "Test Section Name" + "</td>" + "<td>" + "Standard Result" + "</td>" + "<td>" + "Test File Result" + "</td>" + "<td>" + "Tolerances" + "</td>" + "<td>" + "Pass/Fail" + "</td>" + "</tr>"; string units; DOEgbXMLReportingObj report = new DOEgbXMLReportingObj(); CampusReport camprep = new CampusReport(); //this string I can manipulate to produce the final test output string menujson = JsonConvert.SerializeXmlNode(gbXMLStandardFile); //prepare json for view menujson = MakeViewJson(menujson); gbr.menu = menujson; gbr.CampusReport = camprep; report.standResult = new List<string>(); report.testResult = new List<string>(); report.idList = new List<string>(); report.MessageList = new List<string>(); report.TestPassedDict = new Dictionary<string, bool>(); //Set up the Global Pass/Fail criteria for the test case file TestCriteria = new DOEgbXMLTestCriteriaObject(); TestCriteria.InitializeTestCriteriaWithTestName(testToRun); //needed specially for area and volume tests DOEgbXMLTestDetail afile = TestDetail.TestDetailList.Find(x => x.testName == TestToRun); BuildingSummary bs = new BuildingSummary(); bs.FileType = "Standard"; camprep.BuildingSummary.Add(bs); BuildingSummary bst = new BuildingSummary(); bst.FileType = "Test"; camprep.BuildingSummary.Add(bst); //Test 2 execute //report.tolerance = DOEgbXMLBasics.Tolerances.AreaTolerance; //report.testType = TestType.Building_Area; //units = DOEgbXMLBasics.MeasurementUnits.sqft.ToString(); //report = GetBuildingArea(gbXMLdocs, gbXMLnsm, report, validatorArea, testArea, testareaConversion, standardareaConversion); logger.Info("START: BUILDING AREA TEST"); var baresult = GetBuildingArea(gbXMLdocs, gbXMLnsm, ref camprep, validatorArea, testArea, testareaConversion, standardareaConversion, DOEgbXMLBasics.Tolerances.AreaPercentageTolerance, afile ); if(!baresult) { camprep.BuildingSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; } logger.Info("END: BUILDING AREA TEST"); //GetBuildingArea(gbXMLdocs,gbXMLnsm,) //AddToOutPut("Building Area Test Passed: ", report, true); //Test 3 execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.SpaceCountTolerance; //report.testType = TestType.Space_Count; //units = DOEgbXMLBasics.MeasurementUnits.spaces.ToString(); //report = GetBuildingSpaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: BUILDING SPACE COUNT TEST"); SpacesSummary ssm = new SpacesSummary(); ssm.FileType = "Standard"; camprep.SpacesSummary.Add(ssm); SpacesSummary ssmt = new SpacesSummary(); ssmt.FileType = "Test"; camprep.SpacesSummary.Add(ssmt); var spctResult = GetBuildingSpaceCount(gbXMLdocs, gbXMLnsm, "", DOEgbXMLBasics.Tolerances.SpaceCountTolerance, ref camprep); if(!spctResult) { camprep.BuildingSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; camprep.SpacesSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; } logger.Info("END: BUILDING SPACE COUNT TEST"); //AddToOutPut("Building Space Quantity Count Test Passed: ", report, true); // Building Stories Tests.... ////Test 4 execute //report.Clear(); report.tolerance = DOEgbXMLBasics.Tolerances.LevelCountTolerance; //report.testType = TestType.Building_Story_Count; //units = DOEgbXMLBasics.MeasurementUnits.levels.ToString(); //report = GetBuildingStoryCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: Building Storey Count Test"); var blstctresult = GetBuildingStoryCount(gbXMLdocs, gbXMLnsm, ref camprep, DOEgbXMLBasics.Tolerances.LevelCountTolerance); if(!blstctresult) { camprep.BuildingSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //TODO: Need a Building Story Summary Field } logger.Info("END: Building Storey Count Test"); //AddToOutPut("Building Story Count Test Passed: ", report, true); //Test 5 execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.LevelHeightTolerance; //report.testType = TestType.Building_Story_Z_Height; //units = DOEgbXMLBasics.MeasurementUnits.ft.ToString(); report = GetStoryHeights(gbXMLdocs, gbXMLnsm, report, validatorLength, testLength, testlengthConversion, standardlengthConversion); logger.Info("START: Building Storey Height Test"); var storyHeightsres = GetStoryHeights(gbXMLdocs, gbXMLnsm, ref camprep, validatorLength, testLength, testlengthConversion, standardlengthConversion, DOEgbXMLBasics.Tolerances.LevelHeightTolerance); if (!storyHeightsres) { camprep.BuildingSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //TODO: Need a Building Story Summary Field } logger.Info("END: Building Storey Height Test"); //AddToOutPut("Building Story Z-Height Test: ", report, true); //Test 6 execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.VectorAngleTolerance; //report.testType = TestType.Building_Story_PolyLoop_RHR; //units = "degrees"; //report = TestBuildingStoryRHR(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: Building Story Right Hand Rule Test."); var blstRHResult = TestBuildingStoryRHR(gbXMLdocs, gbXMLnsm, ref camprep); if(!blstRHResult) { //this method has no bearing on the overall pass or fail tests. //camprep.BuildingSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //TODO: Need a Building Story Summary Field } logger.Info("END: Building Story Right Hand Rule Test."); //AddToOutPut("Building Story PolyLoop Right Hand Rule Test Result:", report, true); //String spShellGeometrySurfaceNum = TestShellGeomSurfaceNum(gbXMLTestFile, gbXMLns); //Space Tests ............................................................. //Test 7 execute //only needs to test the test file //report.Clear(); //report.testType = TestType.SpaceId_Match_Test; logger.Info("START: UNIQUE SPACE ID TEST"); var spaceIDresults = UniqueSpaceIdTest(gbXMLdocs, gbXMLnsm, ref camprep); if(!spaceIDresults) { camprep.SpacesSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; } logger.Info("END: UNIQUE SPACE ID TEST"); //AddToOutPut("SpaceId Match Test: ", report, true); //Test 8 execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.SpaceAreaTolerance; //report.testType = TestType.Space_Area; //units = DOEgbXMLBasics.MeasurementUnits.sqft.ToString(); logger.Info("START: SPACE AREAS TEST"); //report = TestSpaceAreas(gbXMLdocs, gbXMLnsm, report, validatorArea, testArea, testareaConversion,standardareaConversion,afile); var result = TestSpaceAreas(gbXMLdocs, gbXMLnsm, ref camprep, validatorArea, testArea, testareaConversion, standardareaConversion, afile, DOEgbXMLBasics.Tolerances.SpaceAreaTolerance); if(!result) { camprep.SpacesSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //gbxml detailed compliance results? } logger.Info("END: SPACE AREAS TEST"); //AddToOutPut("Space Areas Test: ", report, true); //Test 9 execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.VolumeTolerance; //report.testType = TestType.Space_Volume; //units = DOEgbXMLBasics.MeasurementUnits.cubicft.ToString(); logger.Info("START: SPACE VOLUMES TEST"); //report = TestSpaceVolumes(gbXMLdocs, gbXMLnsm, report, validatorVol, testVol, testvolumeConversion,standardvolConversion,afile); var volresult = TestSpaceVolumes(gbXMLdocs, gbXMLnsm, ref camprep, validatorVol, testVol, testvolumeConversion, standardvolConversion, afile, DOEgbXMLBasics.Tolerances.VolumePercentageTolerance); logger.Info("END: SPACE VOLUMES TEST"); if (!volresult) { camprep.SpacesSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //gbxml detailed compliance results? } //AddToOutPut("Space Volumes Test: ", report, true); //Test 10 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.VectorAngleTolerance; //report.testType = TestType.Shell_Geom_RHR; //units = "degrees"; //report = TestShellGeomPLRHR(gbXMLdocs, gbXMLnsm, report, units); //AddToOutPut("Shell Geometry RHR Test: ",report); //Surface Element tests //deprecating all counts tests as criteria for passing and failing. Use this now only to indicate counts in the surfaces summary ////Test 11 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.SurfaceCountTolerance; //report.testType = TestType.Total_Surface_Count; //units = ""; //report = GetSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); //AddToOutPut("Surface Count Test Result: ", report, true); ////Surface Element tests ////Test 12 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.ExteriorWallCountTolerance; //report.testType = TestType.Exterior_Wall_Surface_Count; //units = ""; SurfaceSummary ss = new SurfaceSummary(); ss.FileType = "Standard"; camprep.SurfacesSummary.Add(ss); SurfaceSummary sst = new SurfaceSummary(); sst.FileType = "Test"; camprep.SurfacesSummary.Add(sst); //initialization of summaries complete logger.Info("START: EXTERIOR WALL COUNT"); //report = GetEWSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); var ewctresult = GetEWSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); logger.Info("END: EXTERIOR WALL COUNT"); if (!ewctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } //AddToOutPut("Exterior Wall Surface Count Test Result: ", report, true); //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.SurfaceCountTolerance; //report.testType = TestType.Underground_Surface_Count; //units = ""; //report = GetUGSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: UNDERGROUND WALL COUNT"); var ugwctresult = GetUGSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!ugwctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: UNDERGROUND WALL COUNT"); //AddToOutPut("Underground Wall Count Test Result: ", report, true); logger.Info("START: SLABONGRADE COUNT"); var sogctresult = GetSOGSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!sogctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: SLABONGRADE WALL COUNT"); ////Surface Element tests ////Test 13 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.InteriorWallCountTolerance; //report.testType = TestType.Interior_Wall_Surface_Count; //units = ""; logger.Info("START: INTERIOR WALL COUNT"); //report = GetIWSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); var iwctresult = GetIWSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!iwctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: INTERIOR WALL COUNT"); //AddToOutPut("Interior Wall Surface Count Test Result: ", report, true); ////Surface Element tests ////Test 13 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.InteriorFloorCountTolerance; //report.testType = TestType.Interior_Floor_Surface_Count; //units = ""; //report = GetIFSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: INTERIOR FLOOR/CEILING COUNT"); var ifctresult = GetIFSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!ifctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: INTERIOR FLOOR/CEILING COUNT"); //AddToOutPut("Interior Floor Surface Count Test Result: ", report, true); ////Surface Element tests ////Test 14 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.InteriorWallCountTolerance; //report.testType = TestType.Roof_Surface_Count; //units = ""; //report = GetRoofSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: ROOF COUNT"); var irctresult = GetRoofSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!irctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: ROOF COUNT"); //AddToOutPut("Roof Surface Count Test Result: ", report, true); ////Surface Element tests ////Test 15 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.InteriorWallCountTolerance; //report.testType = TestType.Shading_Surface_Count; //units = ""; //report = GetShadeSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: SHADING DEVICE COUNT"); var shadectresult = GetShadeSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!shadectresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } //AddToOutPut("Shading Surface Count Test Result: ", report, true); logger.Info("END: SHADING DEVICE COUNT"); ////Test 16 Execute //report.Clear(); //report.tolerance = DOEgbXMLBasics.Tolerances.AirWallCountTolerance; //report.testType = TestType.Air_Surface_Count; //units = ""; //report = GetAirSurfaceCount(gbXMLdocs, gbXMLnsm, report, units); logger.Info("START: AIR SURFACE COUNT"); var asctresult = GetAirSurfaceCount(gbXMLdocs, gbXMLnsm, ref camprep); if (!asctresult) { //do nothing, it has no consequence for now //gbxml detailed compliance results? } logger.Info("END: AIR SURFACE COUNT"); //AddToOutPut("Air Surface Count Test Result: ", report, true); #region surface detailed test //Jan 31-2012: We may not want to perform these if the surface counts fail, but for now, we will include these tests //Detailed Surface Checks //Store Surface Element Information List<SurfaceDefinitions> TestSurfaces = new List<SurfaceDefinitions>(); XmlDocument TestFile = gbXMLdocs[0]; XmlNamespaceManager TestNSM = gbXMLnsm[0]; List<SurfaceDefinitions> StandardSurfaces = new List<SurfaceDefinitions>(); XmlDocument StandardFile = gbXMLdocs[1]; XmlNamespaceManager StandardNSM = gbXMLnsm[1]; TestSurfaces = GetFileSurfaceDefs(TestFile, TestNSM); StandardSurfaces = GetFileSurfaceDefs(StandardFile, StandardNSM); string TestSurfaceTable = " <div class='container'><table class='table table-bordered'>"; TestSurfaceTable += "<tr class='info'>" + "<td>" + "Test Section Name" + "</td>" + "<td>" + "Stand Surface ID" + "</td>" + "<td>" + "Test Surface ID" + "</td>" + "<td>" + "Stand Surface Tilt" + "</td>" + "<td>" + "Test Surface Tilt" + "</td>" + "<td>" + "Stand Surface Azimuth" + "</td>" + "<td>" + "Test Surface Azimuth" + "</td>" + "<td>" + "Stand Surface Height" + "</td>" + "<td>" + "Test Surface Height" + "</td>" + "<td>" + "Stand Surface Width" + "</td>" + "<td>" + "Test Surface Width" + "</td>" + "<td>" + "Pass/Fail" + "</td>" + "</tr>"; //Test Surfaces Planar Test //all polyloops must be such that the surface defined by the coordinates is planar //report.Clear(); //report.testType = TestType.Surface_Planar_Test; logger.Info("START: SURFACE PLANARITY TEST"); //report = TestSurfacePlanarTest(TestSurfaces, report); var planarityResult = TestSurfacePlanarTest(TestSurfaces,ref camprep); if (!planarityResult) { camprep.SurfacesSummary.Find(x => x.FileType == "Standard").PassedAllTests = false; //gbxml detailed compliance results? } logger.Info("END: SURFACE PLANARITY TEST"); //if (!report.passOrFail && mustBePlanar) //{ // AddToOutPut("Test File Planar Surface Check: ", report, true); // report.Clear(); //} //only run detailed surface checks if the surfaces are planar if(planarityResult) { //<For each surface in the Standard File, try to find a match for this surface in the test file> //Written Jan 31, 2013 by Chien Si Harriman, Senior Product Manager, Carmel Software Corporation //Execute Tests // globalMatchObject.MatchedSurfaceIds = new Dictionary<string, List<string>>(); int i = 1; foreach (SurfaceDefinitions surface in StandardSurfaces) { report.Clear(); DetailedSurfaceSummary ssSummary = new DetailedSurfaceSummary(); //multiple tolerances used report.testType = TestType.Detailed_Surface_Checks; report.subTestIndex = i; if (surface.SurfaceId == "su-zone_5_Srf_7" || surface.SurfaceId == "su-zone_0_Srf_0") { var d = 1; } logger.Info("START: DETAILED SURFACE TEST"); GetSurfaceMatches(surface, TestSurfaces, ref ssSummary, validatorLength, testLength, testlengthConversion, standardlengthConversion, validatorArea, testArea, testareaConversion, standardareaConversion); logger.Info("END: DETAILED SURFACE TEST"); camprep.SurfacesReport.Add(ssSummary); } #endregion #region opending detailed test //openings detailed tests List<OpeningDefinitions> TestOpenings = new List<OpeningDefinitions>(); XmlDocument testFile = gbXMLdocs[0]; XmlNamespaceManager testNSM = gbXMLnsm[0]; List<OpeningDefinitions> StandardOpenings = new List<OpeningDefinitions>(); XmlDocument standardFile = gbXMLdocs[1]; XmlNamespaceManager standardNSM = gbXMLnsm[1]; TestOpenings = GetFileOpeningDefs(TestFile, TestNSM); StandardOpenings = GetFileOpeningDefs(StandardFile, StandardNSM); string TestOpeningTable = ""; report.Clear(); report.testType = TestType.Opening_Planar_Test; report = TestOpeningPlanarTest(TestOpenings, report); if (!report.passOrFail) { AddToOutPut("Test File Planar Opening Check: ", report, true); report.Clear(); } //only run detailed opening checks if the opening are planar else { TestOpeningTable = "<div class='container'><table class='table table-bordered'>"; TestOpeningTable += "<tr class='info'>" + "<td>" + "Test Section Name" + "</td>" + "<td>" + "Standard Opening Id" + "</td>" + "<td>" + "Test Opening Id" + "</td>" + "<td>" + "Standard Parent Surface Id" + "</td>" + "<td>" + "Test Parent Surface Id" + "</td>" + "<td>" + "Standard Parent Azimuth" + "</td>" + "<td>" + "Test Parent Azimuth" + "</td>" + "<td>" + "Standard Parent Tilt" + "</td>" + "<td>" + "Test Parent Tilt" + "</td>" + "<td>" + "Standard Surface Area" + "</td>" + "<td>" + "Test Surface Area" + "</td>" + "<td>" + "Pass/Fail" + "</td>" + "</tr>"; globalMatchObject.MatchedOpeningIds = new Dictionary<string, List<string>>(); int j = 1; //if no openings remove the table. if (StandardOpenings.Count < 1) TestOpeningTable = ""; //compare the openings foreach (OpeningDefinitions opening in StandardOpenings) { report.Clear(); report.testType = TestType.Detailed_Opening_Checks; report.subTestIndex = j; report = GetPossibleOpeningMatches(opening, TestOpenings, report); AddToOutPut("Test 17 for Opening number " + j + " Result: ", report, false); foreach (OpeningDefinitions to in TestOpenings) { if (globalMatchObject.MatchedOpeningIds.ContainsKey(opening.OpeningId)) { foreach (string id in globalMatchObject.MatchedOpeningIds[opening.OpeningId]) { if (to.OpeningId == id) { if (report.passOrFail) TestOpeningTable += "<tr class='success'>" + "<td>" + "<a href='TestDetailPage.aspx?type=" + (int)report.testType + "&subtype=" + report.subTestIndex + "' target='_blank'>" + "Detailed Opening Checks " + report.subTestIndex + "</a>" + "</td>" + "<td>" + opening.OpeningId + "</td>" + "<td>" + to.OpeningId + "</td>" + "<td>" + opening.ParentSurfaceId + "</td>" + "<td>" + to.ParentSurfaceId + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.ParentAzimuth) + "</td>" + "<td>" + String.Format("{0:#,0.00}", to.ParentAzimuth) + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.ParentTilt) + "</td>" + "<td>" + String.Format("{0:#,0.00}", to.ParentTilt) + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.surfaceArea) + "</td>" + "<td>" + String.Format("{0:#,0.00}", to.surfaceArea) + "</td>" + "<td>" + "Pass" + "</td>" + "</tr>"; } } } } //if didn't find match means it failed the test if (!report.passOrFail) TestOpeningTable += "<tr class='error'>" + "<td>" + "<a href='TestDetailPage.aspx?type=" + (int)report.testType + "&subtype=" + report.subTestIndex + "' target='_blank'>" + "Detailed Opening Checks " + report.subTestIndex + "</a>" + "</td>" + "<td>" + opening.OpeningId + "</td>" + "<td>" + "---" + "</td>" + "<td>" + opening.ParentSurfaceId + "</td>" + "<td>" + "---" + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.ParentAzimuth) + "</td>" + "<td>" + "---" + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.ParentTilt) + "</td>" + "<td>" + "---" + "</td>" + "<td>" + String.Format("{0:#,0.00}", opening.surfaceArea) + "</td>" + "<td>" + "---" + "</td>" + "<td>" + "Fail" + "</td>" + "</tr>"; j += 1; } } TestOpeningTable += "</table></div><br/>"; #endregion //close table table += "</table></div><br/>"; //add TestSurfaceTable table += TestSurfaceTable + TestOpeningTable; } //CreateSummaryTable(); ((FileAppender)LogManager.GetCurrentLoggers()[0].Logger.Repository.GetAppenders()[0]).Close(); }
//Created July 2016 by Chien Si Harriman. Note the area tolerance checks are based on percentage tolerances and not absolute tolerances. private void GetSurfaceMatches(SurfaceDefinitions surface, List<SurfaceDefinitions> TestSurfaces, ref DetailedSurfaceSummary ssSummary,Conversions.lengthUnitEnum standardLengthUnits, Conversions.lengthUnitEnum testLengthUnits, double testlengthConversion, double standardlengthConversion, Conversions.areaUnitEnum standardAreaUnits, Conversions.areaUnitEnum testAreaUnits, double testareaConversion, double standardareaConversion) { try{ List<SurfaceDefinitions> possiblesList1 = new List<SurfaceDefinitions>(); List<SurfaceDefinitions> possiblesList2 = new List<SurfaceDefinitions>(); bool adjSpaceIdMatch = false; bool isLowTiltObject = false; bool isHighTiltObject = false; bool interiorWallFlipped = false; bool issurfaceRegular = false; bool istestSurfaceRegular = false; //try to find a surface in the test file that has the same: //adjacent space Id signature //surfaceType //free list is 1 //list 2 is not used ssSummary.ID = surface.SurfaceId; ssSummary.AreaUnits = "SquareFeet"; //TODO, try to remove this hardcoding. ssSummary.TotalSurfaceArea = GetSurfaceArea(surface,standardareaConversion); #region logger.Info("SURFACE ID: " + surface.SurfaceId); logger.Info("START SUBTEST: AdjacencyId check."); for(int ts = 0; ts<TestSurfaces.Count;ts++) { SurfaceDefinitions testSurface = TestSurfaces[ts]; //has to have the same number of Adjacent Space Ids if (testSurface.AdjSpaceId.Count == surface.AdjSpaceId.Count) { //an exception for a shading device if (surface.AdjSpaceId.Count == 0) { adjSpaceIdMatch = true; //must be set to true for if statements below to work. logger.Info("SHADING EXCEPTION: " + surface.SurfaceId + " is a shading device. No AdjacencyId checks performed."); } //has to have the same order of adjacent space id strings to qualify. This method assumes the strings are identical if(surface.AdjSpaceId.Count == 1) { if (surface.AdjSpaceId[0] == testSurface.AdjSpaceId[0]) { adjSpaceIdMatch = true; logger.Info("TEST SURFACE: "+ testSurface.SurfaceId+ " AdjacencyID MATCH SUCCESS"); } else { logger.Info("TEST SURFACE: "+ testSurface.SurfaceId + " AdjacencyID MATCH FAILED"); } } if(surface.AdjSpaceId.Count == 2) { if(surface.SurfaceType == "Ceiling" && testSurface.SurfaceType == "InteriorFloor") { if (surface.AdjSpaceId[0] == testSurface.AdjSpaceId[1] && surface.AdjSpaceId[1] == testSurface.AdjSpaceId[0]) { adjSpaceIdMatch = true; logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH SUCCESS"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH FAILED"); } } else if (surface.SurfaceType == "InteriorFloor" && testSurface.SurfaceType == "Ceiling") { if (surface.AdjSpaceId[0] == testSurface.AdjSpaceId[1] && surface.AdjSpaceId[1] == testSurface.AdjSpaceId[0]) { adjSpaceIdMatch = true; logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH SUCCESS"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH FAILED"); } } else if (surface.SurfaceType == "InteriorWall" && testSurface.SurfaceType == "InteriorWall") { if (surface.AdjSpaceId[0] == testSurface.AdjSpaceId[0] && surface.AdjSpaceId[1] == testSurface.AdjSpaceId[1]) { adjSpaceIdMatch = true; logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH SUCCESS"); } else if (surface.AdjSpaceId[0] == testSurface.AdjSpaceId[1] && surface.AdjSpaceId[1] == testSurface.AdjSpaceId[0]) { adjSpaceIdMatch = true; interiorWallFlipped = true; logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH SUCCESS"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH FAILED"); } } else { if (surface.AdjSpaceId[0] == testSurface.AdjSpaceId[0] && surface.AdjSpaceId[1] == testSurface.AdjSpaceId[1]) { adjSpaceIdMatch = true; logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH SUCCESS"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH FAILED"); } } } } else { if (surface.SurfaceType == "SlabOnGrade") //slab on grade for some reason we see sometimes with two adjacent space ids, depending on the vendor { if(testSurface.AdjSpaceId.Count == 2 && surface.AdjSpaceId.Count == 2) { if (surface.AdjSpaceId[0] == testSurface.AdjSpaceId[0] && surface.AdjSpaceId[1] == testSurface.AdjSpaceId[1]) { adjSpaceIdMatch = true; logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH SUCCESS"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH FAILED"); } } else if (surface.AdjSpaceId.Count == 2) { if (surface.AdjSpaceId[0] == testSurface.AdjSpaceId[0] && surface.AdjSpaceId[1] == testSurface.AdjSpaceId[0]) { adjSpaceIdMatch = true; logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH SUCCESS"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH FAILED"); } } else { if (surface.AdjSpaceId[0] == testSurface.AdjSpaceId[0]) { adjSpaceIdMatch = true; logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH SUCCESS"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " AdjacencyID MATCH FAILED"); } } } else { logger.Info("TEST SURFACE: AdjacencyID MATCH FAILED. Surfaces should have the same number of Adjacent Space Ids, with the one allowance we give for Slab on Grade."); } } if (adjSpaceIdMatch) { logger.Info("END SUBTEST: AdjacencyId check."); logger.Info("START SUBTEST: surfaceType check."); if(!IsHighTiltSurface(surface) && !IsLowTiltSurface(surface)) { if(surface.SurfaceType == testSurface.SurfaceType) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " surfaceType MATCH SUCCESS"); possiblesList1.Add(testSurface); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " surfaceType MATCH FAILED"); } } else { if(IsLowTiltSurface(surface)) isLowTiltObject = true; if (IsHighTiltSurface(surface)) isHighTiltObject = true; if(IsLowTiltSurface(testSurface) && isHighTiltObject) { if(testSurface.SurfaceType == "Ceiling" && surface.SurfaceType == "InteriorFloor") { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " surfaceType MATCH SUCCESS"); possiblesList1.Add(testSurface); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " surfaceType MATCH FAILED"); } } else if(IsHighTiltSurface(testSurface) && isHighTiltObject) { if(surface.SurfaceType == testSurface.SurfaceType) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " surfaceType MATCH SUCCESS"); possiblesList1.Add(testSurface); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " surfaceType MATCH FAILED"); } } else if(IsLowTiltSurface(testSurface) && isLowTiltObject) { if (surface.SurfaceType == testSurface.SurfaceType) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " surfaceType MATCH SUCCESS"); possiblesList1.Add(testSurface); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " surfaceType MATCH FAILED"); } } else if (IsHighTiltSurface(testSurface) && isLowTiltObject) { if(testSurface.SurfaceType == "InteriorFloor" && surface.SurfaceType == "Ceiling") { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " surfaceType MATCH SUCCESS"); possiblesList1.Add(testSurface); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " surfaceType MATCH FAILED"); } } } adjSpaceIdMatch = false; //must reset it to make sure it will find other valid surfaces for only the proper adjacency. } } logger.Info("END SUBTEST: surfaceType check."); // #reporting if (possiblesList1.Count == 1) { logger.Info("TEST SUMMARY: Based on a comparison of the surface Type and Adjacent SpaceIds, there is " + possiblesList1.Count.ToString() + " surface in the test file that is a possible match for " + surface.SurfaceId + " of the Standard File."); } else if (possiblesList1.Count > 1) { logger.Info("TEST SUMMARY: Based on a comparison of the surface Type and Adjacent SpaceIds, there are " + possiblesList1.Count.ToString() + " surfaces in the test file that are possible matches for " + surface.SurfaceId + " of the Standard File."); } else { logger.Error("TEST SUMMARY: In the vendor test file, no matches could be found for this surface that have the same AdjacentSpaceId(s) and SurfaceType."); ssSummary.FoundMatch = false; return; } #endregion //there is at least one surface that matches the above criteria //now checking for tilt and azimuth criteria, as these have to match //TODO: consider removing, minor clean up if (possiblesList1.Count > 0) { logger.Info("START SUBTEST: Azimuth and Tilt check."); foreach (SurfaceDefinitions testSurface in possiblesList1) { double tiltDifference = 0; double azimuthDifference = Math.Abs(testSurface.Azimuth - surface.Azimuth); #region if(isLowTiltObject) { if(IsLowTiltSurface(testSurface)) //they are the same, both have small tilts { tiltDifference = Math.Abs(testSurface.Tilt - surface.Tilt); } else //they are 180 degrees different, and the test surface is a high tilt while the standard is low tilt { if (testSurface.SurfaceType == "InteriorFloor") { tiltDifference = Math.Abs(Math.Abs(testSurface.Tilt - 180) - surface.Tilt); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt MATCH FAILED"); logger.Info("PROGRAMMER'S NOTE: Expecting test surface type to be Interior Floor"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); logger.Info("TEST SURFACE: "+testSurface.SurfaceId + " has been removed as a candidate for matching."); continue; } } //no azimuth tests for horizontal surfaces if (tiltDifference > DOEgbXMLBasics.Tolerances.SurfaceTiltTolerance) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt MATCH FAILED"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " has been removed as a candidate for matching."); continue; } //if the is within tolerance else { //if the surface is horizontal, just add to the free List because we don't check for azimuth in this case if (surface.Tilt == 0) { possiblesList2.Add(testSurface); if (tiltDifference == 0) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt MATCH SUCCESS:PERFECT"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt MATCH SUCCESS"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); } } else { logger.Info("START SUBTEST: azimuth checks."); //check the azimuth if (azimuthDifference > DOEgbXMLBasics.Tolerances.SurfaceAzimuthTolerance) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Azimuth MATCH FAILED"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " has been removed as a candidate for matching."); continue; } //if the tilt and azimuth is within tolerance else { //add to the free List possiblesList2.Add(testSurface); if (tiltDifference == 0 && azimuthDifference == 0) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Azimuth MATCH SUCCESS:PERFECT"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Azimuth MATCH SUCCESS"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); } } } } } else if (isHighTiltObject) { if(IsHighTiltSurface(testSurface)) //both high tilt interior surfaces { tiltDifference = Math.Abs(testSurface.Tilt - surface.Tilt); } else //standard is high tilt, test is low tilt { if(testSurface.SurfaceType == "Ceiling") { tiltDifference = Math.Abs(Math.Abs(testSurface.Tilt - 180) - surface.Tilt); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt MATCH FAILED"); logger.Info("PROGRAMMER' NOTE: Expected surfaceType to be Ceiling."); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " has been removed as a candidate for matching."); continue; } } //no azimuth tests if (tiltDifference > DOEgbXMLBasics.Tolerances.SurfaceTiltTolerance) //azimuth no longer matters for these surfaces { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt MATCH FAILED"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " has been removed as a candidate for matching."); continue; } //if the tilt and azimuth is within tolerance else { //if the surface is horizontal, just add to the free List because we don't check for azimuth in this case if (surface.Tilt == 180) { possiblesList2.Add(testSurface); if (tiltDifference == 0) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt MATCH SUCCESS:PERFECT"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt MATCH PERFECT"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); } } else { //check the azimuth if (azimuthDifference > DOEgbXMLBasics.Tolerances.SurfaceAzimuthTolerance) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Azimuth MATCH FAILED"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " has been removed as a candidate for matching."); continue; } //if the tilt and azimuth is within tolerance else { //add to the free List possiblesList2.Add(testSurface); if (tiltDifference == 0 && azimuthDifference == 0) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Azimuth MATCH SUCCESS:PERFECT"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Azimuth MATCH SUCCESS"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); } } } } } #endregion //the surface is neither a ceiling nor a floor, it is just something regular else { azimuthDifference = Math.Abs(testSurface.Azimuth - surface.Azimuth); if (interiorWallFlipped) //both high tilt interior surfaces { azimuthDifference = Math.Abs(Math.Abs(testSurface.Azimuth - surface.Azimuth) - 180); //180 is needed because they should be separated by 180 } tiltDifference = Math.Abs(testSurface.Tilt - surface.Tilt); //if the tilt and azimuth is outside of tolerance if (tiltDifference > DOEgbXMLBasics.Tolerances.SurfaceTiltTolerance || azimuthDifference > DOEgbXMLBasics.Tolerances.SurfaceAzimuthTolerance) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt Or Azimuth MATCH FAILED"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " has been removed as a candidate for matching."); continue; } //if the tilt and azimuth is within tolerance else { //add to the free List possiblesList2.Add(testSurface); if (tiltDifference == 0 && azimuthDifference == 0) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt And Azimuth MATCH SUCCESS:PERFECT"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Tilt And Azimuth MATCH SUCCESS"); logger.Debug("Test file surface (Azimuth, Tilt): (" + testSurface.Azimuth.ToString() + "," + testSurface.Tilt.ToString() + ")"); logger.Debug("Standard file surface (Azimuth, Tilt): (" + surface.Azimuth.ToString() + "," + surface.Tilt.ToString() + ")"); } } } logger.Info("END SUBTEST: Azimuth and Tilt check."); } } // //report to the user that no matches could be found else { logger.Error("TEST SUMMARY: In the test file, surfaces could be found that match the standard file's AdjacentSpaceId and SurfaceType, but of these matches, none could be identified that also have a tilt or azimuth that exactly matches the standard file's, or is within the allowable tolerance."); ssSummary.FoundMatch = false; return; } //clear the first list possiblesList1.Clear(); //start to loop through the new refined list //generally want to look at the polyLoop coordinates //list 2 is analyzed //list 1 is free ; if (possiblesList2.Count > 0) { //simple method from this point forward is just to simply start doing a polyloop check //check the standard surface PolyLoop and the test Surface(s) polyloop(s) //check the absolute coordinates of the testSurface(s) polyloop(s) if (possiblesList2.Count == 1) { logger.Info("PROGRAMMER'S INFO: Only one Surface Candidate remaining."); //meaning there is only one candidate still available //go on to test the polyLoop coordinates and the insertion point possiblesList1.Add(possiblesList2[0]); //this should mean theoretically that you can do a one for one comparison and do the simplistic check possiblesList2.Clear(); //polyLoop absolute coordinates //list 1 is analyzed //list 2 is free logger.Info("START SUBTEST: PolyLoop coordinate checks."); #region if (possiblesList1.Count > 0) { foreach (SurfaceDefinitions testSurface in possiblesList1) { //check the polyLoop coordinates bool coordsMatch = false; foreach (Vector.MemorySafe_CartCoord standardPolyLoopCoord in surface.PlCoords) { coordsMatch = GetPolyLoopCoordMatch(standardPolyLoopCoord, testSurface, surface.SurfaceId, testlengthConversion, standardlengthConversion); if (coordsMatch) { continue; } else { logger.Info("TEST SURFACE: "+testSurface.SurfaceId+ " polyloop coordinate MATCH FAILED. It has been removed from the candidate list."); break; } } if (coordsMatch) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " polyloop coordinate MATCH SUCCESS."); possiblesList2.Add(testSurface); } } } else { logger.Error("TEST SUMMARY: In the test file, no surfaces could be found that match standard file;s Surface Id: " + surface.SurfaceId + " AdjacentSpaceId(s), SurfaceType, Tilt, Azimuth, and Surface Area. Failed when attempting to match its polyloop coordinates."); ssSummary.FoundMatch = false; return; } logger.Info("END SUBTEST: PolyLoop coordinate checks."); #endregion possiblesList1.Clear(); issurfaceRegular = IsSurfaceRegular(surface); //Insertion point tests. if (!isHighTiltObject && !isLowTiltObject && issurfaceRegular) //no point in doing these checks if thing is not square and regular #region { logger.Info("PROGRAMMER'S NOTE: Standard Surface is square or rectangle non-horizontal. Assumption that test surface candidate should also be same type of shape."); logger.Info("START SUBTEST: Insertion Point Coordinate check."); if (possiblesList2.Count > 0) { //check the insertion point coordinate foreach (SurfaceDefinitions testSurface in possiblesList2) { //now match the differences double insPtXDiff = Math.Abs((testSurface.InsertionPoint.X * testlengthConversion) - (surface.InsertionPoint.X * standardlengthConversion)); double insPtYDiff = Math.Abs((testSurface.InsertionPoint.Y * testlengthConversion) - (surface.InsertionPoint.Y * standardlengthConversion)); double insPtZDiff = Math.Abs((testSurface.InsertionPoint.Z * testlengthConversion) - (surface.InsertionPoint.Z * standardlengthConversion)); //TODO: this interior flipped algorithm could be improved vastly. How to tell if in lower left has not been solved. if (interiorWallFlipped) { logger.Info("PROGRAMMER'S NOTE: The azimuths are flipped. Adjusting the insertion point test to factor this into account.."); //find the complimenting insertion point for (int pt = 0; pt < testSurface.PlCoords.Count; pt++) { if (Math.Abs((surface.InsertionPoint.Z * standardlengthConversion) - (testSurface.PlCoords[pt].Z * testlengthConversion)) < DOEgbXMLBasics.Tolerances.SurfaceInsPtZTolerance) { if (Math.Abs((surface.InsertionPoint.X * standardlengthConversion) - testSurface.PlCoords[pt].X * testlengthConversion) < DOEgbXMLBasics.Tolerances.SurfaceInsPtXTolerance) { if (Math.Abs((surface.InsertionPoint.Y * standardlengthConversion) - testSurface.PlCoords[pt].Y * testlengthConversion) < DOEgbXMLBasics.Tolerances.SurfaceInsPtYTolerance) { //a match insPtXDiff = Math.Abs((testSurface.PlCoords[pt].X * testlengthConversion) - (surface.InsertionPoint.X * standardlengthConversion)); insPtYDiff = Math.Abs((testSurface.PlCoords[pt].Y * testlengthConversion) - (surface.InsertionPoint.Y * standardlengthConversion)); insPtZDiff = Math.Abs((testSurface.PlCoords[pt].Z * testlengthConversion) - (surface.InsertionPoint.Z * standardlengthConversion)); logger.Info("TEST SURFACE: " + testSurface.SurfaceId + "Insertion Point MATCH SUCCESS."); possiblesList1.Add(testSurface); break; } else { //didn't find a candidate logger.Info("TEST SURFACE: " + testSurface.SurfaceId + "Insertion Point did not Match."); } } } } } else { if (insPtXDiff > DOEgbXMLBasics.Tolerances.SurfaceInsPtXTolerance || insPtYDiff > DOEgbXMLBasics.Tolerances.SurfaceInsPtYTolerance || insPtZDiff > DOEgbXMLBasics.Tolerances.SurfaceInsPtZTolerance) { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Insertion Point MATCH FAILED. It has been removed as a candidate."); continue; } else { //possible match if (insPtXDiff == 0 && insPtYDiff == 0 && insPtZDiff == 0) { //perfect match logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Insertion Point MATCH SUCCESS:PERFECT"); possiblesList1.Add(testSurface); } else { logger.Info("TEST SURFACE: " + testSurface.SurfaceId + " Insertion Point MATCH SUCCESS"); possiblesList1.Add(testSurface); } } } } } else { logger.Error("TEST SUMMARY: In the test file, no surfaces could be found that match standard file's Surface Id: " + surface.SurfaceId + " AdjacentSpaceId(s), SurfaceType, Tilt, Azimuth, Surface Area, and PolyLoop Coordinates. Failed when matching PolyLoop coordinates."); ssSummary.FoundMatch = false; return; } possiblesList2.Clear(); logger.Info("END SUBTEST: Insertion point coordinate check."); if (possiblesList1.Count == 1) { logger.Info("TEST SUMMARY: MATCH SUCCESS for Standard file surface id: " + surface.SurfaceId + " in the test file. Only one match was found to be within all the tolerances allowed."); List<string> testFileSurfIds = new List<string>(); foreach (SurfaceDefinitions surf in possiblesList1) { testFileSurfIds.Add(surf.SurfaceId); } globalMatchObject.MatchedSurfaceIds.Add(surface.SurfaceId, testFileSurfIds); ssSummary.FoundMatch = true; ssSummary.TestSurfaceIDs = testFileSurfIds; ssSummary.TotalTestSurfaceArea = GetSurfaceArea(possiblesList1[0],testareaConversion); return; } else if (possiblesList1.Count == 0) { logger.Error("TEST SUMMARY: No surfaces could be found that match standard file;s Surface Id: " + surface.SurfaceId + " AdjacentSpaceId(s), SurfaceType, Tilt, Azimuth, Surface Area, PolyLoop Coordinates, and Insertion Point. Failed when attempting to match the insertion point coordinates."); ssSummary.FoundMatch = false; return; } else if (possiblesList1.Count > 1) { logger.Error("TEST SUMMARY: Advanced Surface Test found more than one match for Standard file surface id: " + surface.SurfaceId + " in the test file. It was not possible to determine only one unique surface."); ssSummary.FoundMatch = false; return; } } #endregion else { if (possiblesList2.Count == 1) //we do not check insertion points for horizontal surfaces. { possiblesList1 = possiblesList2; //this is just to keep the below code consistent with convention. logger.Info("TEST FILE SUCCESS: for Standard file surface id: " + surface.SurfaceId + " in the test file. Only one match was found to be within all the tolerances allowed."); List<string> testFileSurfIds = new List<string>(); foreach (SurfaceDefinitions surf in possiblesList1) { testFileSurfIds.Add(surf.SurfaceId); } globalMatchObject.MatchedSurfaceIds.Add(surface.SurfaceId, testFileSurfIds); ssSummary.FoundMatch = true; ssSummary.TestSurfaceIDs = testFileSurfIds; ssSummary.TotalTestSurfaceArea = GetSurfaceArea(possiblesList1[0],testareaConversion); return; } else if (possiblesList2.Count == 0) { logger.Error("TEST FILE FAILURE: No surfaces could be found that match standard file;s Surface Id: " + surface.SurfaceId + " AdjacentSpaceId(s), SurfaceType, Tilt, Azimuth, Surface Area, PolyLoop Coordinates, and Insertion Point. Failed when attempting to match the insertion point coordinates."); ssSummary.FoundMatch = false; return; } else if (possiblesList2.Count > 1) { logger.Error("TEST FILE FAILRE: Advanced Surface Test found more than one match for Standard file surface id: " + surface.SurfaceId + " in the test file. It was not possible to determine only one unique surface."); ssSummary.FoundMatch = false; return; } } } //more than one candidate still exists even after the adjacency test, surfaceType test, and tilt and azimuth tests, so filter through #region else { //check to see if the remaining area sums matches the standard surface area, //and that the edges of the test surfaces do not overlap, etc. //first try to find if the standard file has a regular rectangular or square profile logger.Debug("More than one surface remains in the test subset."); logger.Info("PROGRAMMER'S NOTE: Performing advanced surface bondary tests."); //checks to see if the testSurface vertices all lie within the standard surface polygonal boundary foreach(SurfaceDefinitions testSurface in possiblesList2) { logger.Info("Testing test surface " +testSurface.SurfaceId); if(DoesSurfaceContainSurface(surface,testSurface,testlengthConversion,standardlengthConversion)) { possiblesList1.Add(testSurface); } } //now we check to see which of the remaining surfaces and their edges form a coherent surface. //do their edges overlap? is the polygon self-intersecting? //add the surface the the existing possibles list possiblesList1.Insert(0, surface); var edgeDict = FindMatchingEdges(possiblesList1); if(EdgesAreValid(edgeDict)) { //finally, we see if the total area of the remaining surfaces equals the area of the standard surface. If all this above has passed, it should not be an issue. double standardArea = ssSummary.TotalSurfaceArea; double testArea = 0; //remove the zero index surface, because this is the standard surface possiblesList1.RemoveAt(0); //these are the remaining candidates foreach(var ts in possiblesList1) { testArea += GetSurfaceArea(ts,testareaConversion); } if(Math.Abs(standardArea - testArea)/standardArea < DOEgbXMLBasics.Tolerances.AreaPercentageTolerance) { logger.Info("TEST FILE SUCCESS: for Standard file surface id: " + surface.SurfaceId + " in the test file. The wall candidates remaining meet the allowable gemoetry constraints."); List<string> testFileSurfIds = new List<string>(); foreach (SurfaceDefinitions surf in possiblesList1) { testFileSurfIds.Add(surf.SurfaceId); } ssSummary.FoundMatch = true; ssSummary.TestSurfaceIDs = testFileSurfIds; ssSummary.TotalTestSurfaceArea = testArea; } else { logger.Info("TEST FILE FAILURE: for Standard file surface id: " + surface.SurfaceId + " in the test file. The wall candidates remaining did not pass the area test."); } } else { //problem logger.Info("TEST FILE FAILURE: for Standard file surface id: " + surface.SurfaceId + " in the test file. The wall candidates remaining do not meet the allowable geometry constraints."); List<string> testFileSurfIds = new List<string>(); foreach (SurfaceDefinitions surf in possiblesList1) { testFileSurfIds.Add(surf.SurfaceId); } globalMatchObject.MatchedSurfaceIds.Add(surface.SurfaceId, testFileSurfIds); ssSummary.FoundMatch = false; ssSummary.TestSurfaceIDs = testFileSurfIds; } } #endregion } } catch(Exception e){ logger.Fatal(e.ToString()); return; } }