/// <summary> /// Добавление структурных ребер. /// </summary> /// <param name="points">Список узлов структурных ребер.</param> protected virtual List <Rib> SetRibs(List <Vertex> points) { var structRibs = new List <Rib>(); var n = points.Count; for (int i0 = 0; i0 < n; i0++) { var i1 = i0 + 1; if (i1 == n) { i1 = 0; } var rib = new Rib(points[i0], points[i1], null, null); // Добавление граничных условий. if (dfdn.HasValue) { rib.dfdn = dfdn.Value; } structRibs.Add(rib); } return(structRibs); }
public bool Equals(Rib x) { bool result = (x.BottomVertex == this.BottomVertex && x.TopVertex == this.TopVertex) || (x.BottomVertex == this.TopVertex && x.TopVertex == this.BottomVertex); return(result); }
public double GetTime(Rib rib) { double res; if (!times.TryGetValue(rib, out res)) { throw new KeyNotFoundException(string.Format("the rib {0} is not found",rib.Sprite.Id)); } return res; }
private void CreateT_D() { T_D = new Triangle(); BD = new Rib(B, D, T_D, null); CD = new Rib(C, D, T_D, null); T_D.SetRibs(BC, BD, CD); BC.Update(null, T_D); T_D.Update(); }
public int GetHashCode(Rib x) { unchecked { int hash = 29; hash = hash * 31 + x.BottomVertex.GetHashCode(); hash = hash * 23 + x.TopVertex.GetHashCode(); return(hash); } }
internal void RotationskörperErstellen() { // Hauptkoerper in Bearbeitung definieren hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody; //Rotationskörper erzeugen ShapeFactory catShapeFactorySenkkopf = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory; Rib senkKopf = catShapeFactorySenkkopf.AddNewRib(hsp_catiaProfil_Senkkopf, hsp_catiaProfil_Schaft); }
} // Ищет индекс вершины в коллекции по её индексу private bool IsExist(Rib newrib) { for (int i = 0; i < Ribs.Count; i++) { if (Ribs[i].top_from == newrib.top_from && Ribs[i].top_to == newrib.top_to && Ribs[i].X1 == newrib.X1 && Ribs[i].X2 == newrib.X2 && Ribs[i].Y1 == newrib.Y1 && Ribs[i].Y2 == newrib.Y2 && Ribs[i].lenght == newrib.lenght || Ribs[i].top_from == newrib.top_to && Ribs[i].top_to == newrib.top_from && Ribs[i].X1 == newrib.X2 && Ribs[i].X2 == newrib.X1 && Ribs[i].Y1 == newrib.Y2 && Ribs[i].Y2 == newrib.Y1 && Ribs[i].lenght == newrib.lenght) { return(true); } } return(false); } // Проверка на существование уже такого ребра
public void GetSeparatingRib() { #region Arrange var A = new Point(0, 0); var B = new Point(1, 2); var C = new Point(2, 0); var D = new Point(3, 1); var E = new Point(0, 1); var F = new Point(1, -1); var ABC = new Triangle(); var BCD = new Triangle(); var ABE = new Triangle(); var ACF = new Triangle(); var AB = new Rib(A, B, ABC, ABE); var BC = new Rib(B, C, ABC, BCD); var AC = new Rib(A, C, ABC, ACF); var BD = new Rib(B, D, BCD, null); var CD = new Rib(C, D, BCD, null); var AE = new Rib(A, E, ABE, null); var BE = new Rib(B, E, ABE, null); var AF = new Rib(A, F, ACF, null); var CF = new Rib(C, F, ACF, null); ABC.SetRibs(AB, BC, AC); BCD.SetRibs(BC, BD, CD); ABE.SetRibs(AB, AE, BE); ACF.SetRibs(AC, AF, CF); // Update triangles. Triangle.Update(ABC, BCD, ABE, ACF); #endregion //Act. var bc = Triangulation.GetSeparatingRib(ABC, D); var ab = Triangulation.GetSeparatingRib(ABC, E); var ac = Triangulation.GetSeparatingRib(ABC, F); var inv_bc = Triangulation.GetSeparatingRib(BCD, A); var inv_ab = Triangulation.GetSeparatingRib(ABE, C); var inv_ac = Triangulation.GetSeparatingRib(ACF, B); // Assert. Assert.AreSame(BC, bc); Assert.AreSame(BC, inv_bc); Assert.AreSame(AB, ab); Assert.AreSame(AB, inv_ab); Assert.AreSame(AC, ac); Assert.AreSame(AC, inv_ac); }
public List <List <T> > Classify() { var sourceTree = BuildTree(); double oldQuality; double newQuality = double.MinValue; var trees = new Dictionary <Tree <T>, Rib <T> > { { sourceTree, null } }; Dictionary <Tree <T>, Rib <T> > previousStepTrees; do { previousStepTrees = trees; oldQuality = newQuality; Rib <T> maxRib = null; Tree <T> maxRibTree = null; double maxRibLength = 0d; foreach (var tree in trees) { var rib = tree.Key.GetMaxRib(); if (rib != null && rib.Distance > maxRibLength) { maxRib = rib; maxRibTree = tree.Key; maxRibLength = rib.Distance; } } if (maxRib == null) { break; } var t = new Dictionary <Tree <T>, Rib <T> > (); foreach (var tree in trees) { if (tree.Key == maxRibTree) { var splittedTrees = tree.Key.Split(maxRib.FirstNode, maxRib.SecondNode); t.Add(splittedTrees.Item1, null); t.Add(splittedTrees.Item2, maxRib); continue; } t.Add(tree.Key, tree.Value); } trees = t; newQuality = new QualityFuncCalculator <T>(trees).Calculate(); } while (oldQuality < newQuality); return(previousStepTrees.Select(tree => tree.Key.GetNodes().Select(node => node.Data).ToList()).ToList()); }
public RibRect(Rib r) { var radius = r.Sprite.Radius; min = r.StartPos; max = r.EndPos; if (max.X < min.X) { var t = max.X; max.X = min.X; min.X = t; } if (max.Y < min.Y) { var t = max.Y; max.Y = min.Y; min.Y = t; } min.X -= radius; min.Y -= radius; max.X += radius; max.Y += radius; }
public void ChangeRib(int from, int to, int value) { int buffer; if (from > to) { buffer = from; from = to; to = buffer; } from--; to--; Rib rib = this.ribMapping[new Tuple <int, int>(from, to)]; int subCount = Math.Min(this.count[from], this.count[to]); result += (value - rib.Value) * subCount * (this.n - subCount); rib.Value = value; }
} // Сохранить в памяти первую верину в ребре public bool AddSecondTopOfRib(int name) { if (name_firsttopinrib != name) { int secondindex = IndexOfTop(name); Rib newrib = new Rib(name_firsttopinrib, name, X_firstpointrib, Y_firstpointrib, Tops[secondindex].X + 12, Tops[secondindex].Y + 12); if (!IsExist(newrib)) { Ribs.Add(newrib); Tops[secondindex].Connected.Add(name_firsttopinrib); Tops[firsttop_index].Connected.Add(name); } Tops[firsttop_index].chosen = false; return(true); } else { Tops[firsttop_index].chosen = false; return(false); } } // Добавить ребро в память, на основе первой вершины в памяти и второй вершины (вторая вершина - аргумент)
public ImportantValue(int n, IEnumerable <Tuple <int, int, int> > ribs) { this.n = n; this.to = new List <Rib> [this.n]; this.ribMapping = new Dictionary <Tuple <int, int>, Rib>(); this.count = new int[this.n]; for (int i = 0; i < n; i++) { this.to[i] = new List <Rib>(); } int ribCount = 0; foreach (var rib in ribs) { int from = Math.Min(rib.Item1, rib.Item2) - 1; int to = Math.Max(rib.Item1, rib.Item2) - 1; Rib ribObject = new Rib() { From = from, To = to, Value = rib.Item3 }; this.ribMapping[new Tuple <int, int>(from, to)] = ribObject; this.to[from].Add(ribObject); this.to[to].Add(ribObject); ribCount++; } this.result = 0; this.DFSInit(0); }
public void GenerateRibs() { // GIVEN float length = data.length; float halfBeam = data.beamRatio * length / 2f; float draft = length * data.fullDraftRatio; // Bow attributes float bowAngle = data.bow.topAngle * 0.5f * Mathf.PI; float bowLength = data.midship.location * length; // The length of the bow float bowBeam = data.bow.widthRatio * halfBeam; float bowSin = Mathf.Sin(bowAngle); // The sin of the first angle to be sampled for the bow float bowSheerHeight = data.bow.sheerRatio * draft; float bowSheerAngle = data.bow.sheerAngle * 0.5f * Mathf.PI; float bowSheerSin = Mathf.Sin(bowSheerAngle);; // Stern attributes float sternAngle = data.stern.topAngle * 0.5f * Mathf.PI; float sternLength = length - bowLength; // The length of the stern float sternBeam = data.stern.widthRatio * halfBeam; float sternSin = Mathf.Sin(sternAngle); float sternSheerHeight = draft * data.stern.sheerRatio; float sternSheerAngle = data.stern.sheerAngle * 0.5f * Mathf.PI; float sternSheerSin = Mathf.Sin(sternSheerAngle);; // CALCULATED // bow attributes float bowSampleProfile = 1f - Mathf.Cos(bowAngle); float bowSampleMult = 1 - bowBeam / halfBeam; float bowSheerSampleProfile = 1f - Mathf.Cos(bowSheerAngle); float midSampleProfile = 1 - Mathf.Cos(sternAngle); float midSampleMult = 1 - sternBeam / halfBeam; float sternSheerSampleProfile = 1f - Mathf.Cos(sternSheerAngle); CircleInterpolator bowDeck = new CircleInterpolator(bowAngle, 0f); CircleInterpolator bowSheer = new CircleInterpolator(bowSheerAngle, 0f); CircleInterpolator bowWales = new CircleInterpolator(1f, 0f); CircleInterpolator sternDeck = new CircleInterpolator(sternAngle, 0f); CircleInterpolator sternSheer = new CircleInterpolator(sternSheerAngle, 0); // SETTING RIB POSITIONS ribs = new List <Rib>(); // incremental variables float deckX, deckY, deckZ = 0f; // Bow while (deckZ < bowLength) { float keyProp = deckZ / bowLength; deckY = draft + bowSheerHeight * (1f - bowSheer.GetX(keyProp)); deckX = bowBeam + (halfBeam - bowBeam) * bowDeck.GetX(keyProp); Rib rib = new Rib(); rib.deck = new Vector3(deckX, deckY, deckZ); float waleProp = bowWales.GetX(keyProp); float waleX = deckX * (data.midship.waleWidthRatio * waleProp + data.bow.waleWidthRatio * (1f - waleProp)); float waleY = deckY * (data.midship.waleDraftRatio * waleProp + data.bow.waleDraftRatio * (1f - waleProp)); rib.wale = new Vector3(waleX, waleY, deckZ); float bilgeX = deckX * (data.midship.bilgeWidthRatio * waleProp + data.bow.bilgeWidthRatio * (1f - waleProp)); float bilgeY = deckY * (data.midship.bilgeDraftRatio * waleProp + data.bow.bilgeDraftRatio * (1f - waleProp)); rib.bilge = new Vector3(bilgeX, bilgeY, deckZ); float bottomX = deckX * (data.midship.bottomWidthRatio * waleProp + data.bow.bottomWidthRatio * (1f - waleProp)); float bottomY = deckY * (data.midship.bottomDraftRatio * waleProp + data.bow.bottomDraftRatio * (1f - waleProp)); rib.bottom = new Vector3(bottomX, bottomY, deckZ); ribs.Add(rib); deckZ++; } while (deckZ <= length) { float keyProp = (1f - (deckZ - bowLength) / sternLength); deckY = draft + sternSheerHeight * (1f - sternSheer.GetX(keyProp)); deckX = sternBeam + (halfBeam - sternBeam) * sternDeck.GetX(keyProp); Rib rib = new Rib(); rib.deck = new Vector3(deckX, deckY, deckZ); float waleProp = bowWales.GetX(keyProp); float waleX = deckX * (data.midship.waleWidthRatio * waleProp + data.stern.waleWidthRatio * (1f - waleProp)); float waleY = deckY * (data.midship.waleDraftRatio * waleProp + data.stern.waleDraftRatio * (1f - waleProp)); rib.wale = new Vector3(waleX, waleY, deckZ); float bilgeX = deckX * (data.midship.bilgeWidthRatio * waleProp + data.stern.bilgeWidthRatio * (1f - waleProp)); float bilgeY = deckY * (data.midship.bilgeDraftRatio * waleProp + data.stern.bilgeDraftRatio * (1f - waleProp)); rib.bilge = new Vector3(bilgeX, bilgeY, deckZ); float bottomX = deckX * (data.midship.bottomWidthRatio * waleProp + data.stern.bottomWidthRatio * (1f - waleProp)); float bottomY = deckY * (data.midship.bottomDraftRatio * waleProp + data.stern.bottomDraftRatio * (1f - waleProp)); rib.bottom = new Vector3(bottomX, bottomY, deckZ); ribs.Add(rib); deckZ++; } }
public void Remove(Rib rib) { if (times.ContainsKey(rib)) { rib.Collision.times.Remove(self); times.Remove(rib); } }
/* public void Move(double dt) { x += (float)(vx * dt); y += (float)(vy * dt); alpha += (float)(omega * dt); if (vx < 0) { if (x < radius) { x = radius * 2 - x; vx = -vx; } } else if (x >= U.WX - radius) { x = (U.WX - radius) * 2 - x; vx = -vx; } if (vy < 0) { if (y < radius) { y = radius * 2 - y; vy = -vy; } } else if (y >= U.WY - radius) { y = (U.WY - radius) * 2 - y; vy = -vy; } } */ public void MakeMove(double starttime, double endtime, List<Rib> ribs) { Rib r = new Rib(this, endtime, starttime); r.Clip(ribs); ribs.Add(r); }
public Collision(Rib rib) { self = rib; rect = new RibRect(rib); times = new Dictionary<Rib, double>(); }
public void Update(Rib rib) { Position = rib.EndPos; Speed = rib.Speed; alpha += omega * rib.DeltaTime; }
public void Ribの出力_リブ外形を構築() { WingSection partWing = new WingSection(null); Plank plank = new Plank(partWing); plank.PlankThin.Value = 2; plank.PlankUpperPos.Value = 0.4; plank.PlankDownerPos.Value = 0.2; Stringer stringer1 = new Stringer(partWing); stringer1.AirfoilSide.Value = AirfoilSide.Upper; stringer1.StringerPos.Value = 0.4; stringer1.StringerHeight.Value = 4; stringer1.StringerWidth.Value = 2; Stringer stringer2 = new Stringer(partWing); stringer2.AirfoilSide.Value = AirfoilSide.Upper; stringer2.StringerPos.Value = 0.2; stringer2.StringerHeight.Value = 4; stringer2.StringerWidth.Value = 2; Stringer stringer3 = new Stringer(partWing); stringer3.AirfoilSide.Value = AirfoilSide.Downer; stringer3.StringerPos.Value = 0.2; stringer3.StringerHeight.Value = 4; stringer3.StringerWidth.Value = 2; Rib rib = new Rib(partWing); rib.Chord.Value = 1000; rib.RibCap.Value.RibCapThin.Value = 1; rib.Airfoil.Coordinate.Points = new List <Pos>() { { new Pos(1.00000, 0.00060) }, { new Pos(0.99344, 0.00216) }, { new Pos(0.98165, 0.00494) }, { new Pos(0.96782, 0.00820) }, { new Pos(0.95254, 0.01174) }, { new Pos(0.93656, 0.01540) }, { new Pos(0.92034, 0.01904) }, { new Pos(0.90394, 0.02264) }, { new Pos(0.88745, 0.02620) }, { new Pos(0.87096, 0.02969) }, { new Pos(0.85444, 0.03311) }, { new Pos(0.83791, 0.03647) }, { new Pos(0.82138, 0.03975) }, { new Pos(0.80484, 0.04296) }, { new Pos(0.78829, 0.04609) }, { new Pos(0.77175, 0.04914) }, { new Pos(0.75520, 0.05211) }, { new Pos(0.73864, 0.05500) }, { new Pos(0.72207, 0.05782) }, { new Pos(0.70549, 0.06054) }, { new Pos(0.68890, 0.06319) }, { new Pos(0.67234, 0.06575) }, { new Pos(0.65579, 0.06822) }, { new Pos(0.63925, 0.07058) }, { new Pos(0.62277, 0.07284) }, { new Pos(0.60630, 0.07497) }, { new Pos(0.58980, 0.07700) }, { new Pos(0.57336, 0.07890) }, { new Pos(0.55689, 0.08068) }, { new Pos(0.54041, 0.08233) }, { new Pos(0.52391, 0.08386) }, { new Pos(0.50740, 0.08528) }, { new Pos(0.49093, 0.08658) }, { new Pos(0.47448, 0.08773) }, { new Pos(0.45804, 0.08876) }, { new Pos(0.44164, 0.08964) }, { new Pos(0.42531, 0.09037) }, { new Pos(0.40900, 0.09093) }, { new Pos(0.39270, 0.09133) }, { new Pos(0.37637, 0.09156) }, { new Pos(0.36001, 0.09163) }, { new Pos(0.34360, 0.09155) }, { new Pos(0.32714, 0.09133) }, { new Pos(0.31066, 0.09097) }, { new Pos(0.29417, 0.09050) }, { new Pos(0.27783, 0.08991) }, { new Pos(0.26173, 0.08917) }, { new Pos(0.24588, 0.08824) }, { new Pos(0.23032, 0.08707) }, { new Pos(0.21499, 0.08564) }, { new Pos(0.19990, 0.08391) }, { new Pos(0.18499, 0.08184) }, { new Pos(0.17016, 0.07943) }, { new Pos(0.15538, 0.07667) }, { new Pos(0.14076, 0.07361) }, { new Pos(0.12636, 0.07023) }, { new Pos(0.11227, 0.06655) }, { new Pos(0.09860, 0.06257) }, { new Pos(0.08537, 0.05829) }, { new Pos(0.07278, 0.05382) }, { new Pos(0.06126, 0.04929) }, { new Pos(0.05105, 0.04478) }, { new Pos(0.04218, 0.04032) }, { new Pos(0.03460, 0.03598) }, { new Pos(0.02824, 0.03180) }, { new Pos(0.02293, 0.02781) }, { new Pos(0.01848, 0.02403) }, { new Pos(0.01473, 0.02054) }, { new Pos(0.01155, 0.01741) }, { new Pos(0.00885, 0.01465) }, { new Pos(0.00660, 0.01217) }, { new Pos(0.00472, 0.00989) }, { new Pos(0.00318, 0.00774) }, { new Pos(0.00194, 0.00569) }, { new Pos(0.00100, 0.00372) }, { new Pos(0.00035, 0.00181) }, { new Pos(-0.00000, -0.00003) }, { new Pos(-0.00004, -0.00185) }, { new Pos(0.00022, -0.00368) }, { new Pos(0.00082, -0.00552) }, { new Pos(0.00173, -0.00735) }, { new Pos(0.00293, -0.00918) }, { new Pos(0.00443, -0.01100) }, { new Pos(0.00623, -0.01280) }, { new Pos(0.00837, -0.01457) }, { new Pos(0.01086, -0.01630) }, { new Pos(0.01379, -0.01790) }, { new Pos(0.01726, -0.01936) }, { new Pos(0.02137, -0.02066) }, { new Pos(0.02632, -0.02186) }, { new Pos(0.03239, -0.02309) }, { new Pos(0.03973, -0.02447) }, { new Pos(0.04842, -0.02584) }, { new Pos(0.05871, -0.02701) }, { new Pos(0.07083, -0.02794) }, { new Pos(0.08476, -0.02870) }, { new Pos(0.09979, -0.02937) }, { new Pos(0.11534, -0.02985) }, { new Pos(0.13129, -0.03015) }, { new Pos(0.14744, -0.03027) }, { new Pos(0.16378, -0.03023) }, { new Pos(0.18028, -0.03005) }, { new Pos(0.19687, -0.02974) }, { new Pos(0.21359, -0.02932) }, { new Pos(0.23047, -0.02883) }, { new Pos(0.24741, -0.02827) }, { new Pos(0.26443, -0.02766) }, { new Pos(0.28157, -0.02701) }, { new Pos(0.29876, -0.02636) }, { new Pos(0.31597, -0.02571) }, { new Pos(0.33319, -0.02507) }, { new Pos(0.35042, -0.02444) }, { new Pos(0.36766, -0.02381) }, { new Pos(0.38492, -0.02318) }, { new Pos(0.40218, -0.02255) }, { new Pos(0.41944, -0.02192) }, { new Pos(0.43669, -0.02129) }, { new Pos(0.45393, -0.02066) }, { new Pos(0.47116, -0.02003) }, { new Pos(0.48838, -0.01939) }, { new Pos(0.50557, -0.01876) }, { new Pos(0.52274, -0.01813) }, { new Pos(0.53990, -0.01749) }, { new Pos(0.55706, -0.01687) }, { new Pos(0.57423, -0.01623) }, { new Pos(0.59142, -0.01560) }, { new Pos(0.60864, -0.01498) }, { new Pos(0.62583, -0.01434) }, { new Pos(0.64299, -0.01371) }, { new Pos(0.66015, -0.01308) }, { new Pos(0.67729, -0.01245) }, { new Pos(0.69444, -0.01182) }, { new Pos(0.71158, -0.01119) }, { new Pos(0.72873, -0.01056) }, { new Pos(0.74587, -0.00993) }, { new Pos(0.76302, -0.00930) }, { new Pos(0.78018, -0.00867) }, { new Pos(0.79735, -0.00804) }, { new Pos(0.81454, -0.00741) }, { new Pos(0.83176, -0.00678) }, { new Pos(0.84894, -0.00615) }, { new Pos(0.86610, -0.00552) }, { new Pos(0.88324, -0.00489) }, { new Pos(0.90035, -0.00426) }, { new Pos(0.91741, -0.00364) }, { new Pos(0.93432, -0.00301) }, { new Pos(0.95093, -0.00240) }, { new Pos(0.96680, -0.00182) }, { new Pos(0.98113, -0.00129) }, { new Pos(0.99325, -0.00085) }, { new Pos(1.00000, -0.00060) } }; partWing.TrainingEdge.Value.TrainlingEdgeLength.Value = 25; string actual = DXF.Content(rib); StreamReader sr = new StreamReader("Resource/DXF/Rib.dxf"); string expect = sr.ReadToEnd(); sr.Close(); Assert.AreEqual(actual, expect); }
private List<Rib> applyCollision(Collision first, Rib rib, double dt) { double time = first.GetTime(rib); Collision second = rib.Collision; Rib self = first.SelfRib; // remove ribs from both collisions first.Remove(rib); if (self.Sprite.image == rib.Sprite.image) { // the collision occurs b/w the same type of objects // remove all ribs corresponding to this sprite ribs.RemoveAll(r => r.Sprite == rib.Sprite); ribs.RemoveAll(r => r.Sprite == self.Sprite); // scan through all other ribs in the collections and remove first.RemoveAll(); second.RemoveAll(); rib.SetEndTime(time); self.SetEndTime(time); // move sprites rib.Sprite.Update(rib); self.Sprite.Update(self); // create a new rib Sprite sprite = new Sprite(self.Sprite.image, self.Sprite, rib.Sprite); List<Rib> moreribs = new List<Rib>(); sprite.MakeMove(time, dt, moreribs); return moreribs; } else { return null; } }
private static bool matchRibNull(Rib rib) { return rib == null || rib.Sprite == null; }
/* private static int compareRibRectsByX(RibRect a, RibRect b) { return a.min.X.CompareTo(b.min.X); } */ private static int compareRibsByEndTime(Rib a, Rib b) { return a.EndTime.CompareTo(b.EndTime); }
public void Flip() { #region Arrange // Nodes. var A = new Point(0, 5); var B = new Point(5, 0); var C = new Point(0, 0); var D = new Point(5, 5); var L = new Point(-3, 2); var T = new Point(3, 7); var R = new Point(7, 2); var Q = new Point(3, -2); // Triangles. var LT = new Triangle(); var TT = new Triangle(); var RT = new Triangle(); var QT = new Triangle(); var T1 = new Triangle(); var T2 = new Triangle(); // Ribs. // Left triangle. var LA = new Rib(L, A, LT, null); var LC = new Rib(L, C, LT, null); var AC = new Rib(A, C, LT, T1); // Top triangle. var TA = new Rib(T, A, TT, null); var TD = new Rib(T, D, TT, null); var AD = new Rib(A, D, TT, T2); // Right triangle. var RD = new Rib(R, D, RT, null); var RB = new Rib(R, B, RT, null); var BD = new Rib(B, D, RT, T2); // Bottom triangle. var QC = new Rib(Q, C, QT, null); var QB = new Rib(Q, B, QT, null); var BC = new Rib(B, C, QT, T1); // Diagonal. var AB = new Rib(A, B, T1, T2); // Set ribs for triangles. LT.SetRibs(LA, LC, AC); TT.SetRibs(TA, TD, AD); RT.SetRibs(RD, RB, BD); QT.SetRibs(QC, QB, BC); T1.SetRibs(AC, BC, AB); T2.SetRibs(AD, BD, AB); // Update triangles. Triangle.Update(LT, TT, RT, QT, T1, T2); #endregion #region Act Triangulation.Flip(T1, T2); #endregion #region Assert // Left. Assert.IsTrue(LT.IsAdjacent(T1)); Assert.IsFalse(LT.IsAdjacent(T2)); Assert.IsTrue(LT.IsAdjacent(null)); // Top. Assert.IsTrue(TT.IsAdjacent(T1)); Assert.IsFalse(TT.IsAdjacent(T2)); Assert.IsTrue(TT.IsAdjacent(null)); // Right. Assert.IsTrue(RT.IsAdjacent(T2)); Assert.IsFalse(RT.IsAdjacent(T1)); Assert.IsTrue(RT.IsAdjacent(null)); // Bottom. Assert.IsTrue(QT.IsAdjacent(T2)); Assert.IsFalse(QT.IsAdjacent(T1)); Assert.IsTrue(QT.IsAdjacent(null)); // T1 & T2. Assert.IsTrue(T1.IsAdjacent(T2)); Assert.IsTrue(T2.IsAdjacent(T1)); Assert.IsFalse(T1.IsAdjacent(null)); Assert.IsFalse(T2.IsAdjacent(null)); #endregion }
public RibViewModel(Rib rib) { model = rib; rib.Airfoil = new Airfoil(); Chord = rib.Chord.ToReactiveProperty(); Lrho = rib.Chord.CombineLatest(rib.Airfoil.AirfoilPerformance.CL, (x, y) => x * y).ToReactiveProperty(); Airfoil = ReactiveProperty.FromObject(rib, x => x.Airfoil); Airfoils = Project.Airfoil.ToReadOnlyReactiveCollection(); ExportDXF.Subscribe(async _ => { // TODO // 本来ここは入らない WingSection partWing = model.Parent.Value as WingSection; Plank plank = new Plank(partWing); plank.PlankThin.Value = 2; plank.PlankUpperPos.Value = 0.4; plank.PlankDownerPos.Value = 0.2; Stringer stringer1 = new Stringer(partWing); stringer1.AirfoilSide.Value = AirfoilSide.Upper; stringer1.StringerPos.Value = 0.4; stringer1.StringerHeight.Value = 4; stringer1.StringerWidth.Value = 2; Stringer stringer2 = new Stringer(partWing); stringer2.AirfoilSide.Value = AirfoilSide.Upper; stringer2.StringerPos.Value = 0.2; stringer2.StringerHeight.Value = 4; stringer2.StringerWidth.Value = 2; Stringer stringer3 = new Stringer(partWing); stringer3.AirfoilSide.Value = AirfoilSide.Downer; stringer3.StringerPos.Value = 0.2; stringer3.StringerHeight.Value = 4; stringer3.StringerWidth.Value = 2; partWing.Plank.Value = plank; partWing.Stringers.Add(stringer1); partWing.Stringers.Add(stringer2); partWing.Stringers.Add(stringer3); partWing.TrainingEdge.Value.TrainlingEdgeLength.Value = 25; //ここまで string content = DXF.Content(model); var savePicker = new FileSavePicker(); savePicker.FileTypeChoices.Add("DXF図面交換ファイル", new List <string>() { ".dxf" }); StorageFile file = await savePicker.PickSaveFileAsync(); if (file != null) { await FileIO.WriteTextAsync(file, content); } }); }