private readonly string comment_format = "{0}-{1}:"; // тип-id: public GroundPollution() { this.watertime = 0.0f; this.concentration = 0.0f; this.petrochemicatype = new PetrochemicalType(); this.cadastretype = new CadastreType(); this.distance = 0.0f; this.angle = 0.0f; this.name = String.Empty; this.comment = String.Empty; this.pointtype = POINTTYPE.UNDEF; }
private POINTTYPE PointTypeFunction(int x) { POINTTYPE type = POINTTYPE.regular; ///TODO do other types here first too if (x % 20 == 0) { type = POINTTYPE.great; } return(type); }
public GroundPollution(SpreadPoint spreadpoint, float concentration = 0.0f, float watertime = 0.0f) : base(spreadpoint) { this.pointtype = POINTTYPE.RISK; this.comment = string.Format(comment_format, RiskObject.PREFIX, (spreadpoint.isriskobject? spreadpoint.riskobject.id: 0)); this.watertime = watertime; this.concentration = concentration; this.petrochemicatype = spreadpoint.petrochemicaltype; this.cadastretype = spreadpoint.cadastretype; this.distance = 0.0f; this.angle = 0.0f; this.name = spreadpoint.isriskobject? spreadpoint.riskobject.name: this.comment; }
public GroundPollution(EcoObject ecojbject, float distance, float angle, PetrochemicalType petrochemicatype, float concentration = 0.0f, float watertime = 0.0f) : base(ecojbject) { this.pointtype = POINTTYPE.ECO; this.comment = string.Format(comment_format, EcoObject.PREFIX, ecojbject.id); this.watertime = watertime; this.concentration = concentration; this.petrochemicatype = petrochemicatype; this.cadastretype = ecojbject.cadastretype; this.distance = distance; this.angle = angle; this.name = ecojbject.name; }
public GroundPollution(AnchorPoint anchorpoint, float distance, float angle, PetrochemicalType petrochemicatype, float concentration = 0.0f, float watertime = 0.0f) : base(anchorpoint) { this.pointtype = POINTTYPE.ANCHOR; this.comment = string.Format(comment_format, AnchorPoint.PREFIX, anchorpoint.id); this.watertime = watertime; this.concentration = concentration; this.petrochemicatype = petrochemicatype; this.cadastretype = anchorpoint.cadastretype; this.distance = distance; this.angle = angle; this.name = this.comment; }
private GameObject GetPointPrefab(POINTTYPE type) { switch (type) { case POINTTYPE.regular: return(pointsPrefab); case POINTTYPE.great: return(greatPointsPrefab); } Debug.LogError("GetPointPrefab: Trying to get prefab type " + type); return(null); }
private readonly string comment_format = "{0}-{1}:"; // тип-id: public WaterPollution() { this.petrochemicatype = new PetrochemicalType(); this.cadastretype = new CadastreType(); this.waterpollutioncategories = new WaterPollutionCategories(); this.distance = 0.0f; this.maxconcentration = 0.0f; this.timemaxconcentration = 0.0f; this.datemaxconcentration = DateTime.Parse("1900-01-01 01:01:01"); this.speedhorizontal = 0.0f; this.angle = 0.0f; this.name = String.Empty; this.comment = String.Empty; this.pointtype = POINTTYPE.UNDEF; this.iswaterobject = false; }
public GroundPollution(XmlNode node) : base(new Point(node.SelectSingleNode(".//Point"))) { this.watertime = Helper.GetFloatAttribute(node, "watertime", 0.0f); this.concentration = Helper.GetFloatAttribute(node, "concentration", 0.0f); XmlNode petro = node.SelectSingleNode(".//PetrochemicalType"); if (petro != null) { this.petrochemicatype = new PetrochemicalType(petro); } else { this.petrochemicatype = null; } XmlNode cad = node.SelectSingleNode(".//CadastreType"); if (cad != null) { this.cadastretype = new CadastreType(cad); } else { this.cadastretype = null; } this.distance = Helper.GetFloatAttribute(node, "distance", 0.0f); this.angle = Helper.GetFloatAttribute(node, "angle", 0.0f); this.name = Helper.GetStringAttribute(node, "name", ""); this.comment = Helper.GetStringAttribute(node, "comment", ""); string string_pointtype = Helper.GetStringAttribute(node, "pointtype", ""); { POINTTYPE p = POINTTYPE.UNDEF; if (Enum.TryParse(string_pointtype, out p)) { this.pointtype = p; } else { this.pointtype = POINTTYPE.UNDEF; } } }
public WaterPollution(EcoObject ecojbject, float distance, float angle, PetrochemicalType petrochemicatype, float speedhorizontal, float maxconcentration = 0.0f, float timemaxconcentration = 0.0f, WaterPollutionCategories waterpollutioncategories = null) : base(ecojbject) { this.pointtype = POINTTYPE.ECO; this.comment = string.Format(comment_format, EcoObject.PREFIX, ecojbject.id); this.petrochemicatype = petrochemicatype; this.cadastretype = ecojbject.cadastretype; this.distance = distance; this.angle = angle; this.name = ecojbject.name; this.speedhorizontal = speedhorizontal; this.maxconcentration = maxconcentration; this.timemaxconcentration = timemaxconcentration; this.datemaxconcentration = Const.DATE_INFINITY; this.iswaterobject = ecojbject.iswaterobject; this.waterpollutioncategories = waterpollutioncategories; }
private void SpawnPoint(DIRECTION direction, POINTTYPE type) { GameObject pointObject = Instantiate(GetPointPrefab(type)); PointController point = pointObject.GetComponent <PointController>(); point.Init(direction); pointsList.Add(point); // Determine what row/column to spawn in int row = 0; int column = 0; switch (direction) { case DIRECTION.UP: row = 0; column = Random.Range(0, 10); break; case DIRECTION.DOWN: row = 9; column = Random.Range(0, 10); break; case DIRECTION.LEFT: row = Random.Range(0, 10); column = 9; break; case DIRECTION.RIGHT: row = Random.Range(0, 10); column = 0; break; } // Determine starting location Vector2 offsetDir = GridManager.DirectionToVector(GridManager.GetOppositeDirection(direction)); Vector2 baseLocation = gridManager.GetRealLocation(row, column); pointObject.transform.position = baseLocation + offsetDir * offscreenOffset; }
public void EdgeSwapping(Mesh mesh, int usemetric) { if (!faceindex) { if (usemetric != 0) { PrintMessage(3, "Edgeswapping, metric"); } else { PrintMessage(3, "Edgeswapping, topological"); } for (faceindex = 1; faceindex <= mesh.GetNFD(); faceindex++) { EdgeSwapping(mesh, usemetric); if (multithread.terminate) { throw new Exception("Meshing stopped"); } } faceindex = 0; mesh.CalcSurfacesOfNode(); return; } //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method: // static int timer = NgProfiler::CreateTimer("EdgeSwapping 2D"); NgProfiler.RegionTimer reg1 = new NgProfiler.RegionTimer(EdgeSwapping_timer); //C++ TO C# CONVERTER NOTE: This static local variable declaration (not allowed in C#) has been moved just prior to the method: // static int timerstart = NgProfiler::CreateTimer("EdgeSwapping 2D start"); NgProfiler.StartTimer(EdgeSwapping_timerstart); Array <SurfaceElementIndex> seia = new Array <SurfaceElementIndex>(); mesh.GetSurfaceElementsOfFace(faceindex, seia); for (int i = 0; i < seia.Size(); i++) { if (mesh[seia[i]].GetNP() != 3) { GenericImprove(mesh); return; } } int surfnr = mesh.GetFaceDescriptor(faceindex).SurfNr(); Array <Neighbour> neighbors = new Array <Neighbour>(mesh.GetNSE()); INDEX_2_HASHTABLE <trionedge> other = new INDEX_2_HASHTABLE <trionedge>(seia.Size() + 2); Array <char> swapped = new Array <char>(mesh.GetNSE()); Array <int, PointIndex.BASE> pdef = new Array <int, PointIndex.BASE>(mesh.GetNP()); Array <double, PointIndex.BASE> pangle = new Array <double, PointIndex.BASE>(mesh.GetNP()); // int e; // double d; // Vec3d nv1, nv2; // double loch(-1); double[] minangle = { 0, 1.481, 2.565, 3.627, 4.683, 5.736, 7, 9 }; for (int i = 0; i < seia.Size(); i++) { Element2d sel = mesh[seia[i]]; for (int j = 0; j < 3; j++) { pangle[sel[j]] = 0.0; } } // pangle = 0; for (int i = 0; i < seia.Size(); i++) { Element2d sel = mesh[seia[i]]; for (int j = 0; j < 3; j++) { POINTTYPE typ = mesh[sel[j]].Type(); if (typ == FIXEDPOINT || typ == EDGEPOINT) { pangle[sel[j]] += Angle(mesh[sel[(j + 1) % 3]] - mesh[sel[j]], mesh[sel[(j + 2) % 3]] - mesh[sel[j]]); } } } // for (PointIndex pi = PointIndex::BASE; // pi < mesh.GetNP()+PointIndex::BASE; pi++) // pdef = 0; for (int i = 0; i < seia.Size(); i++) { Element2d sel = mesh[seia[i]]; for (int j = 0; j < 3; j++) { PointIndex pi = sel[j]; if (mesh[pi].Type() == INNERPOINT || mesh[pi].Type() == SURFACEPOINT) { pdef[pi] = -6; } else { for (int j = 0; j < 8; j++) { if (pangle[pi] >= minangle[j]) { pdef[pi] = -1 - j; } } } } } for (int i = 0; i < seia.Size(); i++) { Element2d sel = mesh[seia[i]]; for (int j = 0; j < 3; j++) { pdef[sel[j]]++; } } for (int i = 0; i < seia.Size(); i++) { for (int j = 0; j < 3; j++) { neighbors[seia[i]].SetNr(j, -1); neighbors[seia[i]].SetOrientation(j, 0); } } /* * Array<Vec3d> normals(mesh.GetNP()); * for (i = 1; i <= mesh.GetNSE(); i++) * { * Element2d & hel = mesh.SurfaceElement(i); * if (hel.GetIndex() == faceindex) * for (k = 1; k <= 3; k++) * { * int pi = hel.PNum(k); * SelectSurfaceOfPoint (mesh.Point(pi), hel.GeomInfoPi(k)); * int surfi = mesh.GetFaceDescriptor(faceindex).SurfNr(); * GetNormalVector (surfi, mesh.Point(pi), normals.Elem(pi)); * normals.Elem(pi) /= normals.Elem(pi).Length(); * } * } */ for (int i = 0; i < seia.Size(); i++) { Element2d sel = mesh[seia[i]]; for (int j = 0; j < 3; j++) { PointIndex pi1 = sel.PNumMod(j + 2); PointIndex pi2 = sel.PNumMod(j + 3); // double loch = mesh.GetH(mesh[pi1]); INDEX_2 edge = new INDEX_2(pi1, pi2); edge.Sort(); if (mesh.IsSegment(pi1, pi2)) { continue; } /* * if (segments.Used (edge)) * continue; */ INDEX_2 ii2 = new INDEX_2(pi1, pi2); if (other.Used(ii2)) { // INDEX_2 i2s(ii2); // i2s.Sort(); int i2 = other.Get(ii2).tnr; int j2 = other.Get(ii2).sidenr; neighbors[seia[i]].SetNr(j, i2); neighbors[seia[i]].SetOrientation(j, j2); neighbors[i2].SetNr(j2, seia[i]); neighbors[i2].SetOrientation(j2, j); } else { other.Set(new INDEX_2(pi2, pi1), new trionedge(seia[i], j)); } } } for (int i = 0; i < seia.Size(); i++) { swapped[seia[i]] = 0; } NgProfiler.StopTimer(EdgeSwapping_timerstart); int t = 4; int done = 0; while (done == 0 && t >= 2) { for (int i = 0; i < seia.Size(); i++) { SurfaceElementIndex t1 = seia[i]; if (mesh[t1].IsDeleted()) { continue; } if (mesh[t1].GetIndex() != faceindex) { continue; } if (multithread.terminate) { throw new Exception("Meshing stopped"); } for (int o1 = 0; o1 < 3; o1++) { bool should; SurfaceElementIndex t2 = neighbors[t1].GetNr(o1); int o2 = neighbors[t1].GetOrientation(o1); if (t2 == -1) { continue; } if (swapped[t1] || swapped[t2]) { continue; } PointIndex pi1 = mesh[t1].PNumMod(o1 + 1 + 1); PointIndex pi2 = mesh[t1].PNumMod(o1 + 1 + 2); PointIndex pi3 = mesh[t1].PNumMod(o1 + 1); PointIndex pi4 = mesh[t2].PNumMod(o2 + 1); PointGeomInfo gi1 = mesh[t1].GeomInfoPiMod(o1 + 1 + 1); PointGeomInfo gi2 = mesh[t1].GeomInfoPiMod(o1 + 1 + 2); PointGeomInfo gi3 = mesh[t1].GeomInfoPiMod(o1 + 1); PointGeomInfo gi4 = mesh[t2].GeomInfoPiMod(o2 + 1); bool allowswap = true; Vec <3> auxvec1 = mesh[pi3] - mesh[pi4]; Vec <3> auxvec2 = mesh[pi1] - mesh[pi4]; allowswap = allowswap && ngsimd.GlobalMembers.fabs(1.0 - (auxvec1 * auxvec2) / (auxvec1.Length() * auxvec2.Length())) > 1e-4; if (!allowswap) { continue; } // normal of new Vec <3> nv1 = netgen.GlobalMembers.Cross(auxvec1, auxvec2); auxvec1 = new mesh.Point(pi4) - new mesh.Point(pi3); auxvec2 = new mesh.Point(pi2) - new mesh.Point(pi3); allowswap = allowswap && ngsimd.GlobalMembers.fabs(1.0 - (auxvec1 * auxvec2) / (auxvec1.Length() * auxvec2.Length())) > 1e-4; if (!allowswap) { continue; } Vec <3> nv2 = netgen.GlobalMembers.Cross(auxvec1, auxvec2); // normals of original Vec <3> nv3 = netgen.GlobalMembers.Cross(mesh[pi1] - mesh[pi4], mesh[pi2] - mesh[pi4]); Vec <3> nv4 = netgen.GlobalMembers.Cross(mesh[pi2] - mesh[pi3], mesh[pi1] - mesh[pi3]); nv3 *= -1; nv4 *= -1; nv3.Normalize(); nv4.Normalize(); nv1.Normalize(); nv2.Normalize(); Vec <3> nvp3, nvp4; SelectSurfaceOfPoint(new mesh.Point(pi3), gi3); GetNormalVector(surfnr, new mesh.Point(pi3), gi3, nvp3); nvp3.Normalize(); SelectSurfaceOfPoint(new mesh.Point(pi4), gi4); GetNormalVector(surfnr, new mesh.Point(pi4), gi4, nvp4); nvp4.Normalize(); double critval = ngsimd.GlobalMembers.cos(DefineConstants.M_PI / 6); // 30 degree allowswap = allowswap && (nv1 * nvp3 > critval) && (nv1 * nvp4 > critval) && (nv2 * nvp3 > critval) && (nv2 * nvp4 > critval) && (nvp3 * nv3 > critval) && (nvp4 * nv4 > critval); double horder = netgen.GlobalMembers.Dist(new mesh.Point(pi1), new mesh.Point(pi2)); if (nv1.Length() > 1e-3 * horder * horder && nv2.Length() > 1e-3 * horder * horder && allowswap) { if (usemetric == 0) { int e = pdef[pi1] + pdef[pi2] - pdef[pi3] - pdef[pi4]; double d = netgen.GlobalMembers.Dist2(new mesh.Point(pi1), new mesh.Point(pi2)) - netgen.GlobalMembers.Dist2(new mesh.Point(pi3), new mesh.Point(pi4)); should = e >= t && (e > 2 || d > 0); } else { double loch = mesh.GetH(mesh[pi1]); should = CalcTriangleBadness(new mesh.Point(pi4), new mesh.Point(pi3), new mesh.Point(pi1), metricweight, loch) + CalcTriangleBadness(new mesh.Point(pi3), new mesh.Point(pi4), new mesh.Point(pi2), metricweight, loch) < CalcTriangleBadness(new mesh.Point(pi1), new mesh.Point(pi2), new mesh.Point(pi3), metricweight, loch) + CalcTriangleBadness(new mesh.Point(pi2), new mesh.Point(pi1), new mesh.Point(pi4), metricweight, loch); } if (allowswap) { Element2d sw1 = new Element2d(pi4, pi3, pi1); Element2d sw2 = new Element2d(pi3, pi4, pi2); int legal1 = mesh.LegalTrig(mesh.SurfaceElement(t1)) + mesh.LegalTrig(mesh.SurfaceElement(t2)); int legal2 = mesh.LegalTrig(sw1) + mesh.LegalTrig(sw2); if (legal1 < legal2) { should = true; } if (legal2 < legal1) { should = false; } } if (should) { // do swapping ! done = 1; mesh[t1].PNum(1) = pi1; mesh[t1].PNum(2) = pi4; mesh[t1].PNum(3) = pi3; mesh[t2].PNum(1) = pi2; mesh[t2].PNum(2) = pi3; mesh[t2].PNum(3) = pi4; mesh[t1].GeomInfoPi(1) = gi1; mesh[t1].GeomInfoPi(2) = gi4; mesh[t1].GeomInfoPi(3) = gi3; mesh[t2].GeomInfoPi(1) = gi2; mesh[t2].GeomInfoPi(2) = gi3; mesh[t2].GeomInfoPi(3) = gi4; pdef[pi1]--; pdef[pi2]--; pdef[pi3]++; pdef[pi4]++; swapped[t1] = 1; swapped[t2] = 1; } } } } t--; } mesh.SetNextTimeStamp(); }