private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e) { var input = e.Argument as WriteInput; if (input.IFCType == IFCType.IFC2x3) { var model = WriteIfc2.CreateSite(this.tbName.Text, Properties.Settings.Default.familyName, Properties.Settings.Default.givenName, Properties.Settings.Default.company, "Site with Terrain", input.Placement, this.Mesh, input.SurfaceType, input.BreakDist); WriteIfc2.WriteFile(model, input.Filename, input.FileType == FileType.XML); } else { var model = input.WriteGeo ? WriteIfc4.CreateSiteWithGeo(this.tbName.Text, Properties.Settings.Default.familyName, Properties.Settings.Default.givenName, Properties.Settings.Default.company, "Site with Terrain", input.Placement, this.Mesh, input.SurfaceType, input.BreakDist) : WriteIfc4.CreateSite(this.tbName.Text, Properties.Settings.Default.familyName, Properties.Settings.Default.givenName, Properties.Settings.Default.company, "Site with Terrain", input.Placement, this.Mesh, input.SurfaceType, input.BreakDist); WriteIfc4.WriteFile(model, input.Filename, input.FileType == FileType.XML); } e.Result = Path.GetFileName(input.Filename); }
//siteplacement-argument? public void mapProcess(JsonSettings jSettings, double?breakDist = null, double?refLatitude = null, double?refLongitude = null, double?refElevation = null) { var logger = LogManager.GetCurrentClassLogger(); logger.Info("----------------------------------------------"); // //Read // var result = new Result(); string[] fileNames = new string[1]; fileNames[0] = jSettings.fileName; switch (jSettings.fileType) { case "LandXML": result = LandXml.ReadTIN(jSettings.is3D, jSettings.fileName, jSettings.minDist, jSettings.logFilePath, jSettings.verbosityLevel); break; case "CityGML": result = CityGml.ReadTIN(jSettings.is3D, jSettings.fileName, jSettings.minDist, jSettings.logFilePath, jSettings.verbosityLevel); break; case "DXF": DXF.ReadFile(jSettings.fileName, out this.dxfFile); if (jSettings.isTin) { result = DXF.ReadDXFTin(jSettings.is3D, this.dxfFile, jSettings.layer, jSettings.minDist, jSettings.logFilePath, jSettings.verbosityLevel); } else { result = DXF.ReadDXFIndPoly(jSettings.is3D, this.dxfFile, jSettings.layer, jSettings.minDist, jSettings.logFilePath, jSettings.verbosityLevel); } break; case "REB": this.rebData = RebDa.ReadREB(fileNames); result = RebDa.ConvertReb(jSettings.is3D, this.rebData, jSettings.horizon, jSettings.minDist, jSettings.logFilePath, jSettings.verbosityLevel); break; case "Grid": result = ElevationGrid.ReadGrid(jSettings.is3D, jSettings.fileName, jSettings.minDist, jSettings.gridSize, jSettings.bBox, jSettings.bbNorth, jSettings.bbEast, jSettings.bbSouth, jSettings.bbWest); break; } this.Mesh = result.Mesh; try { logger.Debug("Mesh created with: " + this.Mesh.Points.Count + " Points; " + this.Mesh.FixedEdges + " Lines; " + this.Mesh.FaceEdges + " Faces"); } catch { logger.Debug("No Faces or Points found"); } // //Write // if (jSettings.projectName is null) { jSettings.projectName = "Name of project"; } var writeInput = new WriteInput(); writeInput.Placement = Axis2Placement3D.Standard; if (jSettings.customOrigin) { writeInput.Placement.Location = Vector3.Create(jSettings.xOrigin, jSettings.yOrigin, jSettings.zOrigin); } else { double midX = (this.Mesh.MaxX + this.Mesh.MinX) / 2; double midY = (this.Mesh.MaxY + this.Mesh.MinY) / 2; double midZ = (this.Mesh.MaxZ + this.Mesh.MinZ) / 2; writeInput.Placement.Location = Vector3.Create(midX, midY, midZ); } // Placement verschieben? writeInput.SurfaceType = SurfaceType.TFS; if (jSettings.surfaceType == "GCS") { writeInput.SurfaceType = SurfaceType.GCS; } else if (jSettings.surfaceType == "SBSM") { writeInput.SurfaceType = SurfaceType.SBSM; } writeInput.FileType = FileType.Step; if (jSettings.outFileType == "XML") { writeInput.FileType = FileType.XML; } logger.Debug("Writing IFC with:"); logger.Debug("IFC Version: " + jSettings.outIFCType); logger.Debug("Surfacetype: " + jSettings.surfaceType); logger.Debug("Filetype: " + jSettings.fileType); if (jSettings.outIFCType == "IFC2x3") { var model = WriteIfc2.CreateSite(jSettings.projectName, jSettings.editorsFamilyName, jSettings.editorsGivenName, jSettings.editorsOrganisationName, "Site with Terrain", writeInput.Placement, this.Mesh, writeInput.SurfaceType, breakDist); logger.Debug("IFC Site created"); WriteIfc2.WriteFile(model, jSettings.destFileName, writeInput.FileType == FileType.XML); logger.Info("IFC file writen: " + jSettings.destFileName); } else { logger.Debug("Geographical Element: " + jSettings.geoElement); var model = jSettings.geoElement ? WriteIfc4.CreateSiteWithGeo(jSettings.projectName, jSettings.editorsFamilyName, jSettings.editorsGivenName, jSettings.editorsOrganisationName, "Site with Terrain", writeInput.Placement, this.Mesh, writeInput.SurfaceType, breakDist) : WriteIfc4.CreateSite(jSettings.projectName, jSettings.editorsFamilyName, jSettings.editorsGivenName, jSettings.editorsOrganisationName, "Site with Terrain", writeInput.Placement, this.Mesh, writeInput.SurfaceType, breakDist); logger.Debug("IFC Site created"); WriteIfc4.WriteFile(model, jSettings.destFileName, writeInput.FileType == FileType.XML); logger.Info("IFC file writen: " + jSettings.destFileName); } logger.Info("----------------------------------------------"); }
//siteplacement-argument? public void mapProcess(JsonSettings jSettings, double?breakDist = null, double?refLatitude = null, double?refLongitude = null, double?refElevation = null) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Info("----------------------------------------------"); #region Reader // //Read // var result = new Result(); string[] fileNames = new string[1]; fileNames[0] = jSettings.fileName; #region import data typ selection switch (jSettings.fileType) { case "LandXML": result = LandXml.ReadTIN(jSettings.is3D, jSettings.fileName, jSettings.minDist, jSettings.logFilePath, jSettings.verbosityLevel); break; case "CityGML": result = CityGml.ReadTIN(jSettings.is3D, jSettings.fileName, jSettings.minDist, jSettings.logFilePath, jSettings.verbosityLevel); break; case "DXF": DXF.ReadFile(jSettings.fileName, out dxfFile); if (jSettings.isTin) { //READING as TIN result = DXF.ReadDXFTin(jSettings.is3D, dxfFile, jSettings.layer, jSettings.breakline_layer, jSettings.minDist, jSettings.breakline); } else { //READING as MESH --> have to be changed into TIN result = DXF.ReadDXFIndPoly(jSettings.is3D, dxfFile, jSettings.layer, jSettings.breakline_layer, jSettings.minDist, jSettings.logFilePath, jSettings.verbosityLevel, jSettings.breakline); } break; case "REB": this.rebData = RebDa.ReadREB(fileNames); result = RebDa.ConvertReb(jSettings.is3D, this.rebData, jSettings.horizon, jSettings.minDist, jSettings.logFilePath, jSettings.verbosityLevel); break; case "Grid": result = ElevationGrid.ReadGrid(jSettings.is3D, jSettings.fileName, jSettings.minDist, jSettings.gridSize, jSettings.bBox, jSettings.bbNorth, jSettings.bbEast, jSettings.bbSouth, jSettings.bbWest); break; case "OUT": if (jSettings.isTin) { //result = Out.ReadOUTTin(jSettings.is3D, jSettings.fileName,jSettings.onlyTypes, jSettings.layer, jSettings.minDist, jSettings.ignPos, jSettings.ignHeight, jSettings.onlyHorizon, jSettings.horizonFilter, jSettings.breakline, jSettings.breakline_layer); //reworking result = ReadOUT.ReadOutData(jSettings.fileName, out pointIndex2NumberMap, out triangleIndex2NumberMap); //pointIndex2NumberMap & triangleIndex2NumberMap ggf. entfernen } /* ENTFERNT, da derzeit nur über FACES verarbeitet wird * else * { * * //result = Out.ReadOUT_Points_Lines(jSettings.is3D, jSettings.fileName, jSettings.layer, jSettings.minDist, jSettings.ignPos, jSettings.ignHeight, jSettings.breakline, jSettings.breakline_layer); * }*/ break; case "PostGIS": result = PostGIS.ReadPostGIS(jSettings.is3D, jSettings.minDist, jSettings.host, jSettings.port, jSettings.user, jSettings.password, jSettings.database, jSettings.schema, jSettings.tin_table, jSettings.tin_column, jSettings.tinid_column, jSettings.tin_id, jSettings.breakline, jSettings.breakline_table, jSettings.breakline_column, jSettings.breakline_tin_id); break; } this.Tin = result.Tin; this.Mesh = result.Mesh; this.Breaklines = result.Breaklines; #endregion #region Mesh-Checker if (Mesh != null) { try { logger.Debug("Mesh created with: " + Mesh.Points.Count + " Points; " + Mesh.FixedEdges.Count + " Lines; " + Mesh.FaceEdges.Count + " Faces"); } catch { logger.Debug("No Faces or Points found!"); } } /* * else * { * * try * { * //Removed --> relocate in reader * //logger.Debug("Tin created with: " + Tin.Points.Count + " Points; " + Tin.NumTriangles + " Triangels"); * } * catch * { * //logger.Debug("No Triangels or Points found!"); * } * } */ #endregion #endregion #region Writer // //Write // #region project Name if (jSettings.projectName is null) { jSettings.projectName = "Name of project"; } #endregion var writeInput = new WriteInput(); #region Placement writeInput.Placement = Axis2Placement3D.Standard; if (jSettings.customOrigin) { writeInput.Placement.Location = Vector3.Create(jSettings.xOrigin, jSettings.yOrigin, jSettings.zOrigin); } else { double MinX = 0; double MinY = 0; double MinZ = 0; double MaxX = 0; double MaxY = 0; double MaxZ = 0; if (Mesh != null) { double midX = (this.Mesh.MaxX + this.Mesh.MinX) / 2; double midY = (this.Mesh.MaxY + this.Mesh.MinY) / 2; double midZ = (this.Mesh.MaxZ + this.Mesh.MinZ) / 2; writeInput.Placement.Location = Vector3.Create(midX, midY, midZ); } //Vorschlag für BimGisCad.Composed (in MESH ist dies bereits vorhanden) else { int i = 0; foreach (Point3 point in Tin.Points) { //initalisierung durch ersten Punkt if (i > 0) { if (point.X < MinX) { MinX = point.X; } if (point.X > MaxX) { MaxX = point.X; } if (point.Y < MinY) { MinY = point.Y; } if (point.Y > MaxY) { MaxY = point.Y; } if (point.Z < MinZ) { MinZ = point.Z; } if (point.Z > MaxZ) { MaxZ = point.Z; } } else { MinX = point.X; MinY = point.Y; MinZ = point.Z; MaxX = point.X; MaxY = point.Y; MaxZ = point.Z; } i++; } double MidX = (MaxX + MinX) / 2; double MidY = (MaxY + MinY) / 2; double MidZ = (MaxZ + MinZ) / 2; writeInput.Placement.Location = Vector3.Create(MidX, MidY, MidZ); } } #endregion #region IFC Version writeInput.SurfaceType = SurfaceType.TFS; if (jSettings.surfaceType == "GCS") { writeInput.SurfaceType = SurfaceType.GCS; } else if (jSettings.surfaceType == "SBSM") { writeInput.SurfaceType = SurfaceType.SBSM; } else if (jSettings.surfaceType == "TIN") { writeInput.SurfaceType = SurfaceType.TIN; } #endregion #region IFC Version Filetyp writeInput.FileType = FileType.Step; if (jSettings.outFileType == "XML") { writeInput.FileType = FileType.XML; } logger.Debug("Writing IFC with:"); logger.Debug("IFC Version: " + jSettings.outIFCType); logger.Debug("Surfacetype: " + jSettings.surfaceType); logger.Debug("Filetype: " + jSettings.fileType); #endregion #region IFC2x3 if (jSettings.outIFCType == "IFC2x3") { var model = WriteIfc2.CreateSite(jSettings.projectName, jSettings.editorsFamilyName, jSettings.editorsGivenName, jSettings.editorsOrganisationName, "Site with Terrain", writeInput.Placement, this.Mesh, writeInput.SurfaceType, breakDist); logger.Debug("IFC Site created"); WriteIfc2.WriteFile(model, jSettings.destFileName, writeInput.FileType == FileType.XML); logger.Info("IFC file writen: " + jSettings.destFileName); } #endregion #region IFC4 - MESH else if (jSettings.outIFCType == "IFC4") { logger.Debug("Geographical Element: " + jSettings.geoElement); var model = jSettings.geoElement ? WriteIfc4.CreateSiteWithGeo(jSettings.projectName, jSettings.editorsFamilyName, jSettings.editorsGivenName, jSettings.editorsOrganisationName, "Site with Terrain", writeInput.Placement, this.Mesh, writeInput.SurfaceType, breakDist) : WriteIfc4.CreateSite(jSettings.projectName, jSettings.editorsFamilyName, jSettings.editorsGivenName, jSettings.editorsOrganisationName, "Site with Terrain", writeInput.Placement, this.Mesh, writeInput.SurfaceType, breakDist); logger.Debug("IFC Site created"); WriteIfc4.WriteFile(model, jSettings.destFileName, writeInput.FileType == FileType.XML); logger.Info("IFC file writen: " + jSettings.destFileName); } #endregion //DRAFT VERSION BELOW #region IFC4 - TIN if (jSettings.outIFCType == "IFC4TIN") { var model = jSettings.geoElement ? WriteIfc4Tin.CreateSiteWithGeo(jSettings.projectName, jSettings.editorsFamilyName, jSettings.editorsGivenName, jSettings.editorsOrganisationName, //jSettings.minDist, "Site with Terrain", writeInput.Placement, this.Tin, this.Breaklines, writeInput.SurfaceType, breakDist) : WriteIfc4Tin.CreateSite(jSettings.projectName, jSettings.projectName, jSettings.editorsFamilyName, jSettings.editorsGivenName, //jSettings.minDist, "Site with Terrain", writeInput.Placement, this.Tin, this.Breaklines, writeInput.SurfaceType, breakDist);; WriteIfc4Tin.WriteFile(model, jSettings.destFileName, writeInput.FileType == FileType.XML); } #endregion #region IFC2x3 TIN if (jSettings.outIFCType == "IFC2x3TIN") { var model = WriteIfc2TIN.CreateSite(jSettings.projectName, jSettings.editorsFamilyName, jSettings.editorsGivenName, jSettings.editorsOrganisationName, "Site with Terrain", writeInput.Placement, this.Tin, writeInput.SurfaceType, breakDist); logger.Debug("IFC Site created"); WriteIfc2TIN.WriteFile(model, jSettings.destFileName, writeInput.FileType == FileType.XML); logger.Info("IFC file writen: " + jSettings.destFileName); } #endregion #endregion logger.Info("----------------------------------------------"); }