private void btn_testTin_Click(object sender, EventArgs e) { _paramTin = FLabServices.createCalculMedium().GetParametresDuTinParDefaut(); // _paramTin.p11_initialisation_determinationFrontieres = enumModeDelimitationFrontiere.pointsProchesDuMbo; _paramTin.p11_initialisation_determinationFrontieres = enumModeDelimitationFrontiere.pointsProchesDuMbo; //_paramTin.p12_extensionSupplementaireMboEnM = 1000; _paramTin.p12_extensionSupplementaireMboEnM = 0; _paramTin.p13_modeCalculZParDefaut = enumModeCalculZ.alti_0; _paramTin.p14_altitudeParDefaut = -200; _paramTin.p15_nbrePointsSupplMultiples4 = 0; _paramTin.p16_initialisation_modeChoixDuPointCentral.p01_excentrationMinimum = 0; _paramTin.p21_enrichissement_modeChoixDuPointCentral.p01_excentrationMinimum = Convert.ToDouble(tb_precisionEnM.Text); // _topolFacettes = FLabServices.createCalculMedium().GetInitialisationTin(_dataPointsTests, _paramTin); FLabServices.createCalculMedium().AugmenteDetailsTinByRef(ref _topolFacettes, _paramTin); // bool v_visuSpatialTrace_vf = false; if (v_visuSpatialTrace_vf) { FVisualisationServices.createVisualisationSpatialTraceServices().GetVisuTopologieFacettes(_topolFacettes, false, false); FVisualisationServices.createVisualisationSpatialTraceServices().AfficheVisu(); } MessageBox.Show("Traitement terminé."); }
public static Triangulation GenerateTIN(HeightMap hMap, double precision, int srid) { var v_pointsToTest = GetGeoPointsByHMap(hMap, srid); var _paramTin = FLabServices.createCalculMedium().GetParametresDuTinParDefaut(); _paramTin.p11_initialisation_determinationFrontieres = enumModeDelimitationFrontiere.pointsProchesDuMbo; _paramTin.p12_extensionSupplementaireMboEnM = 0; _paramTin.p13_modeCalculZParDefaut = enumModeCalculZ.alti_0; _paramTin.p14_altitudeParDefaut = -200; _paramTin.p15_nbrePointsSupplMultiples4 = 0; _paramTin.p16_initialisation_modeChoixDuPointCentral.p01_excentrationMinimum = 0; _paramTin.p21_enrichissement_modeChoixDuPointCentral.p01_excentrationMinimum = precision; // var _topolFacettes = FLabServices.createCalculMedium().GetInitialisationTin(v_pointsToTest, _paramTin); FLabServices.createCalculMedium().AugmenteDetailsTinByRef(ref _topolFacettes, _paramTin); Dictionary <int, int> v_indiceParIdPoint = new Dictionary <int, int>(); int v_indice = 0; GeoPoint v_geoPoint; List <GeoPoint> p00_geoPoint = new List <GeoPoint>(_topolFacettes.p11_pointsFacettesByIdPoint.Count); List <List <int> > p01_listeIndexPointsfacettes = new List <List <int> >(_topolFacettes.p13_facettesById.Count); foreach (BeanPoint_internal v_point in _topolFacettes.p11_pointsFacettesByIdPoint.Values) { v_geoPoint = new GeoPoint(v_point.p10_coord[1], v_point.p10_coord[0], (float)v_point.p10_coord[2]); p00_geoPoint.Add(v_geoPoint); v_indiceParIdPoint.Add(v_point.p00_id, v_indice); v_indice++; } //p00_geoPoint = p00_geoPoint.CenterOnOrigin().ToList(); p00_geoPoint = p00_geoPoint.ToList(); //Création des listes d'indices et normalisation du sens des points favettes List <int> v_listeIndices; bool v_renvoyerNullSiPointsColineaires_vf = true; bool v_normalisationSensHoraireSinonAntihoraire = false; foreach (BeanFacette_internal v_facette in _topolFacettes.p13_facettesById.Values) { List <BeanPoint_internal> v_normalisationDuSens = FLabServices.createCalculMedium().GetOrdonnancementPointsFacette(v_facette.p01_pointsDeFacette, v_renvoyerNullSiPointsColineaires_vf, v_normalisationSensHoraireSinonAntihoraire); if (v_normalisationDuSens != null) { v_listeIndices = new List <int>(); foreach (BeanPoint_internal v_ptFacette in v_normalisationDuSens) { v_listeIndices.Add(v_indiceParIdPoint[v_ptFacette.p00_id]); } p01_listeIndexPointsfacettes.Add(v_listeIndices); } } return(new Triangulation(p00_geoPoint, p01_listeIndexPointsfacettes.SelectMany(c => c).ToList())); }
private void btnTestFacettes_Click(object sender, EventArgs e) { BeanFacettesToVisu3D v_beanToVisu3d; v_beanToVisu3d = new BeanFacettesToVisu3D(); Dictionary <int, int> v_indiceParIdPoint = new Dictionary <int, int>(); int v_indice = 0; GeoPoint v_geoPoint; foreach (BeanPoint_internal v_point in _topolFacettes.p11_pointsFacettesByIdPoint.Values) { v_geoPoint = new GeoPoint(v_point.p10_coord[1], v_point.p10_coord[0], (float)v_point.p10_coord[2]); v_beanToVisu3d.p00_geoPoint.Add(v_geoPoint); v_indiceParIdPoint.Add(v_point.p00_id, v_indice); v_indice++; } //Création des listes d'indices et normalisation du sens des points favettes List <int> v_listeIndices; bool v_renvoyerNullSiPointsColineaires_vf = true; bool v_normalisationSensHoraireSinonAntihoraire = false; foreach (BeanFacette_internal v_facette in _topolFacettes.p13_facettesById.Values) { List <BeanPoint_internal> v_normalisationDuSens = FLabServices.createCalculMedium().GetOrdonnancementPointsFacette(v_facette.p01_pointsDeFacette, v_renvoyerNullSiPointsColineaires_vf, v_normalisationSensHoraireSinonAntihoraire); if (v_normalisationDuSens != null) { v_listeIndices = new List <int>(); foreach (BeanPoint_internal v_ptFacette in v_normalisationDuSens) { v_listeIndices.Add(v_indiceParIdPoint[v_ptFacette.p00_id]); } v_beanToVisu3d.p01_listeIndexPointsfacettes.Add(v_listeIndices); } } // IglTFService glTFService = new glTFService(null); MeshPrimitive v_trianglesMesh = glTFService.GenerateTriangleMesh(v_beanToVisu3d.p00_geoPoint, v_beanToVisu3d.p01_listeIndexPointsfacettes.SelectMany(c => c).ToList()); Model model = glTFService.GenerateModel(v_trianglesMesh, "Test Triangles"); string v_nomFichierOut = "TIN_"; if (rdSRTMGL3.Checked) { v_nomFichierOut += "SRTM_GL3"; } else if (rdSRTMGL1.Checked) { v_nomFichierOut += "SRTM_GL1"; } else { v_nomFichierOut += "AW3D30"; } v_nomFichierOut += "_p" + tb_precisionEnM.Text; glTFService.Export(model, "Test3D", v_nomFichierOut, false, true); MessageBox.Show("Traitement terminé =>" + v_nomFichierOut); }
private void btn_testCH_Click(object sender, EventArgs e) { List <BeanPoint_internal> v_pointConvexHull; v_pointConvexHull = FLabServices.createCalculMedium().GetConvexHull2D(_dataPointsTests); // string v_message = "ConvexHull calculé"; v_message += " (" + v_pointConvexHull.Count + " pts sur " + _dataPointsTests.Count + ")."; v_message += ". Affichez dans SpatialTrace ?"; if (MessageBox.Show(v_message, "Calcul convexHull", MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } string v_label = ""; Color v_couleurBase = Color.FromArgb(255, 0, 255, 255); FServicesApplicatifs.createVisuSpatialTrace().GetVisuPoints2D(_dataPointsTests, v_label, v_couleurBase, -1); v_label = "CH"; FServicesApplicatifs.createVisuSpatialTrace().GetVisuPoints2D(v_pointConvexHull, v_label, 10); SpatialTrace.Enable(); IGeometry v_ligneCh; for (int v_indexPt = 0; v_indexPt < v_pointConvexHull.Count - 1; v_indexPt++) { v_ligneCh = FLabServices.createUtilitaires().GetGeometryLine(v_pointConvexHull[v_indexPt].p10_coord, v_pointConvexHull[v_indexPt + 1].p10_coord, 2154, true); SpatialTrace.TraceGeometry(v_ligneCh, "CH arc: " + v_indexPt, "CH arc: " + v_indexPt); } v_ligneCh = FLabServices.createUtilitaires().GetGeometryLine(v_pointConvexHull[v_pointConvexHull.Count - 1].p10_coord, v_pointConvexHull[0].p10_coord, 2154, true); SpatialTrace.TraceGeometry(v_ligneCh, "CH arc: " + (v_pointConvexHull.Count - 1), "CH arc: " + (v_pointConvexHull.Count - 1)); SpatialTrace.Disable(); FVisualisationServices.createVisualisationSpatialTraceServices().AfficheVisu(); // MessageBox.Show("Traitement terminé."); }
public BeanTopologieFacettes GetBeanTopologieByVoronoiGraph(VoronoiGraph p_voronoiGraph, BeanAlimentationVoronoi p_beanAlimentationVoronoi) { BeanTopologieFacettes v_topologie = new BeanTopologieFacettes(); try { List <BeanArc_internal> v_arcsVoronoi = new List <BeanArc_internal>(); Dictionary <string, BeanArc_internal> v_arcsParHCode = new Dictionary <string, BeanArc_internal>(); int v_srid = p_beanAlimentationVoronoi.p11_srid; // Dictionary <string, BeanPoint_internal> v_pointsDesArcsByCode = new Dictionary <string, BeanPoint_internal>(); Dictionary <int, BeanArc_internal> v_arcs = new Dictionary <int, BeanArc_internal>(); Dictionary <int, int> v_DicoPointSourceGaucheParArc = new Dictionary <int, int>(); Dictionary <int, int> v_DicoPointSourceDroitParArc = new Dictionary <int, int>(); // //Création du réseau double v_vorX_Left; double v_vorY_Left; double v_vorX_Right; double v_vorY_Right; double v_OrigX_Left; double v_OrigY_Left; double v_OrigX_Right; double v_OrigY_Right; double v_CorrectionX = 0; double v_CorrectionY = 0; ITopologieService v_topologieService = new TopologieService(); int v_KeyArc = 0; HashSet <string> v_testDoublesLignes = new HashSet <string>(); if (p_beanAlimentationVoronoi.p12_parametrage.reductionCoordonneesVf) { v_CorrectionX = (double)p_beanAlimentationVoronoi.p55_origineXCorrigee; v_CorrectionY = (double)p_beanAlimentationVoronoi.p56_origineYCorrigee; } BeanPoint_internal v_pt1; BeanPoint_internal v_pt2; BeanArc_internal v_arc; //On créé une facette/ilot pour chaque point; BeanFacette_internal v_facette; Dictionary <int, BeanFacette_internal> v_toutesFacettes; v_toutesFacettes = p_beanAlimentationVoronoi.p10_dicoDesPointsSources.ToDictionary(c => c.Key, c => new BeanFacette_internal()); //[ATTENTION! On doit mettre à jour l'id foreach (KeyValuePair <int, BeanFacette_internal> v_fac in v_toutesFacettes) { v_fac.Value.p00_idFacette = v_fac.Key; } //On parcourt les arcs: string v_hcodePt1; string v_hcodePt2; string v_hcodeGraineVoronoiAGauche; string v_hcodeGraineVoronoiADroite; int v_idIlotAGauche; int v_idIlotADroite; foreach (VoronoiEdge v_Edges in p_voronoiGraph.Edges) { if (!v_Edges.IsInfinite && !v_Edges.IsPartlyInfinite) { v_KeyArc++; //L'arc voronoi v_vorX_Left = v_Edges.VVertexA[0] + v_CorrectionX; v_vorY_Left = v_Edges.VVertexA[1] + v_CorrectionY; v_vorX_Right = v_Edges.VVertexB[0] + v_CorrectionX; v_vorY_Right = v_Edges.VVertexB[1] + v_CorrectionY; // v_hcodePt1 = FLabServices.createUtilitaires().GetHCodeGeogPoint(new double[2] { v_vorX_Left, v_vorY_Left }); if (v_pointsDesArcsByCode.ContainsKey(v_hcodePt1)) { v_pt1 = v_pointsDesArcsByCode[v_hcodePt1]; } else { v_pt1 = new BeanPoint_internal(v_vorX_Left, v_vorY_Left, 0, v_srid); v_pointsDesArcsByCode.Add(v_hcodePt1, v_pt1); } // v_hcodePt2 = FLabServices.createUtilitaires().GetHCodeGeogPoint(new double[2] { v_vorX_Right, v_vorY_Right }); if (v_pointsDesArcsByCode.ContainsKey(v_hcodePt2)) { v_pt2 = v_pointsDesArcsByCode[v_hcodePt2]; } else { v_pt2 = new BeanPoint_internal(v_vorX_Right, v_vorY_Right, 0, v_srid); v_pointsDesArcsByCode.Add(v_hcodePt2, v_pt2); } // v_arc = new BeanArc_internal(v_pt1, v_pt2); // if (!v_arcsParHCode.ContainsKey(v_arc.p01_hcodeArc)) { v_arcsParHCode.Add(v_arc.p01_hcodeArc, v_arc); } //On référence les points 'graines' voronoi à droite et à gauche v_OrigX_Left = v_Edges.LeftData[0] + v_CorrectionX; v_OrigY_Left = v_Edges.LeftData[1] + v_CorrectionY; v_OrigX_Right = v_Edges.RightData[0] + v_CorrectionX; v_OrigY_Right = v_Edges.RightData[1] + v_CorrectionY; // v_hcodeGraineVoronoiAGauche = FLabServices.createUtilitaires().GetHCodeGeogPoint(new double[2] { v_OrigX_Left, v_OrigY_Left }); v_hcodeGraineVoronoiADroite = FLabServices.createUtilitaires().GetHCodeGeogPoint(new double[2] { v_OrigX_Right, v_OrigY_Right }); // v_facette = null; if (p_beanAlimentationVoronoi.p31_correspondanceHCodePointvsIdPoint.ContainsKey(v_hcodeGraineVoronoiAGauche)) { v_idIlotAGauche = p_beanAlimentationVoronoi.p31_correspondanceHCodePointvsIdPoint[v_hcodeGraineVoronoiAGauche]; v_facette = v_toutesFacettes[v_idIlotAGauche]; v_facette.p02_arcs.Add(v_arc); v_arc.p21_facetteGauche = v_facette; } else { v_arc.p20_statutArc = enumStatutArc.arcExterne; } v_facette = null; if (p_beanAlimentationVoronoi.p31_correspondanceHCodePointvsIdPoint.ContainsKey(v_hcodeGraineVoronoiADroite)) { v_idIlotADroite = p_beanAlimentationVoronoi.p31_correspondanceHCodePointvsIdPoint[v_hcodeGraineVoronoiADroite]; v_facette = v_toutesFacettes[v_idIlotADroite]; v_facette.p02_arcs.Add(v_arc); v_arc.p21_facetteGauche = v_facette; } else { v_arc.p20_statutArc = enumStatutArc.arcExterne; } } //Fin if (!v_Edges.IsInfinite && !v_Edges.IsPartlyInfinite) } //Fin foreach //Création de la topologie v_arcsVoronoi = v_arcsParHCode.Values.OrderBy(c => c.p01_hcodeArc).ToList(); //On actualise les points des facettes: foreach (KeyValuePair <int, BeanFacette_internal> v_fac in v_toutesFacettes) { List <BeanPoint_internal> v_points = v_fac.Value.p02_arcs.Select(c => c.p11_pointDbt).ToList(); v_points.AddRange(v_fac.Value.p02_arcs.Select(c => c.p12_pointFin).ToList()); HashSet <string> v_pointsDeja = new HashSet <string>(); foreach (BeanPoint_internal v_pt in v_points) { if (!v_pointsDeja.Contains(v_pt.p01_hCodeGeog)) { v_fac.Value.p01_pointsDeFacette.Add(v_pt); v_pointsDeja.Add(v_pt.p01_hCodeGeog); } } } // v_topologie = new BeanTopologieFacettes(v_arcsVoronoi); v_topologie.p13_facettesById = v_toutesFacettes; //On supprime les éventuelles facettes sans dimension List <int> v_idFacettesASupprimer; v_idFacettesASupprimer = v_toutesFacettes.Where(c => c.Value.p02_arcs.Count < 3).Select(c => c.Key).ToList(); BeanFacette_internal v_facetteASupprimer; foreach (int v_idFacASuppr in v_idFacettesASupprimer) { v_facetteASupprimer = v_topologie.p13_facettesById[v_idFacASuppr]; v_topologie.FacetteSupprimer(v_facetteASupprimer); } //Géométrie: List <int> v_idFacettes = v_topologie.p13_facettesById.Keys.ToList(); IGeometry v_geomFacette; BeanFacette_internal v_facettePourGeom; foreach (int v_idFac in v_idFacettes) { v_facettePourGeom = v_topologie.p13_facettesById[v_idFac]; v_geomFacette = FLabServices.createCalculMedium().GetGeometryPolygoneFacetteEtOrdonnePointsFacette(ref v_facettePourGeom, ref v_topologie); v_facettePourGeom.p04_geomFacette = v_geomFacette; } } catch (Exception v_ex) { throw v_ex; } return(v_topologie); }