// 三角形要素の節点ナンバリング private void NumberTriangleNodes(FEWorld world, IList <int> zeroCoordIds) { Mesher2D mesh = world.Mesh; // ナンバリング int nodeId = 0; IList <uint> feIds = TriangleFEArray.GetObjectIds(); foreach (uint feId in feIds) { TriangleFE fe = TriangleFEArray.GetObject(feId); int elemPtCnt = fe.NodeCoordIds.Length; int[] coIds = fe.NodeCoordIds; for (int iPt = 0; iPt < elemPtCnt; iPt++) { int coId = coIds[iPt]; if (!Co2Node.ContainsKey(coId) && zeroCoordIds.IndexOf(coId) == -1) { Co2Node[coId] = nodeId; nodeId++; } } uint meshId = fe.MeshId; int iElem = fe.MeshElemId; uint elemCnt; MeshType meshType; int loc; uint cadId; mesh.GetMeshInfo(meshId, out elemCnt, out meshType, out loc, out cadId); System.Diagnostics.Debug.Assert(meshType == MeshType.Tri); var triArray = mesh.GetTriArrays(); var tri = triArray[loc].Tris[iElem]; tri.FEId = (int)feId; string key = string.Format(meshId + "_" + iElem); Mesh2TriangleFE.Add(key, feId); } }
public void UpdateCadGeometry(CadObject2D cad2D) { Mesher2D mesh = new Mesher2D(cad2D); for (int idp = 0; idp < DrawParts.Count; idp++) { CadObject2DDrawPart dp = DrawParts[idp]; dp.Clear(); uint cadId = dp.CadId; CadElementType cadType = dp.Type; if (!cad2D.IsElementId(cadType, cadId)) { continue; } uint meshId = mesh.GetIdFromCadId(cadId, cadType); if (meshId == 0) { continue; } MeshType meshType; uint elemCnt; int loc; uint cadId0; mesh.GetMeshInfo(meshId, out elemCnt, out meshType, out loc, out cadId0); System.Diagnostics.Debug.Assert(cadId0 == cadId); if (meshType == MeshType.Tri) { dp.SetTriArray(mesh.GetTriArrays()[loc]); double[] color = cad2D.GetLoopColor(cadId0); for (int iTmp = 0; iTmp < 3; iTmp++) { dp.Color[iTmp] = (float)color[iTmp]; } } else if (meshType == MeshType.Bar) { dp.SetBarArray(mesh.GetBarArrays()[loc]); System.Diagnostics.Debug.Assert(cadType == CadElementType.Edge); Edge2D edge = cad2D.GetEdge(cadId); dp.CurveType = edge.CurveType; dp.CtrlPoints.Clear(); // 2019-03-11 エッジの色 FIX double[] color = edge.Color; for (int iTmp = 0; iTmp < 3; iTmp++) { dp.Color[iTmp] = (float)color[iTmp]; } if (edge.CurveType == CurveType.CurveArc) { OpenTK.Vector2d cPt; double radius; edge.GetCenterRadius(out cPt, out radius); dp.CtrlPoints.Add(cPt); } else if (edge.CurveType == CurveType.CurveBezier) { IList <OpenTK.Vector2d> cos = edge.GetCurvePoint(); dp.CtrlPoints.Add(cos[0]); dp.CtrlPoints.Add(cos[1]); } } else if (meshType == MeshType.Vertex) { dp.SetVertex(mesh.GetVertexs()[loc]); } } { // 座標をセット IList <OpenTK.Vector2d> vec2Ds = mesh.GetVectors(); uint ptCnt = (uint)vec2Ds.Count; uint ndim = 2; VertexArray.SetSize(ptCnt, ndim); for (int iPt = 0; iPt < ptCnt; iPt++) { VertexArray.VertexCoordArray[iPt * ndim] = vec2Ds[iPt].X; VertexArray.VertexCoordArray[iPt * ndim + 1] = vec2Ds[iPt].Y; } if (VertexArray.UVCoordArray != null) { for (int iPt = 0; iPt < ptCnt; iPt++) { VertexArray.UVCoordArray[iPt * ndim] = vec2Ds[iPt].X * TexScale; VertexArray.UVCoordArray[iPt * ndim + 1] = vec2Ds[iPt].Y * TexScale; } } } }
private bool Set(Mesher2D mesher) { SutableRotMode = RotMode.RotMode2D; // DrawMode 1 : 2D int layerMin = 0; int layerMax = 0; { bool isInited = false; IList <MeshTriArray2D> triArrays = mesher.GetTriArrays(); for (int itri = 0; itri < triArrays.Count; itri++) { int layer = triArrays[itri].Layer; if (isInited) { layerMin = (layer < layerMin) ? layer : layerMin; layerMax = (layer > layerMax) ? layer : layerMax; } else { layerMin = layer; layerMax = layer; isInited = true; } } IList <MeshQuadArray2D> quadArrays = mesher.GetQuadArrays(); for (int iquad = 0; iquad < quadArrays.Count; iquad++) { int layer = quadArrays[iquad].Layer; if (isInited) { layerMin = (layer < layerMin) ? layer : layerMin; layerMax = (layer > layerMax) ? layer : layerMax; } else { layerMin = layer; layerMax = layer; isInited = true; } } } double layerHeight = 1.0 / (layerMax - layerMin + 1); { // 三角形要素をセット IList <MeshTriArray2D> triArrays = mesher.GetTriArrays(); for (int itri = 0; itri < triArrays.Count; itri++) { Mesher2DDrawPart dp = new Mesher2DDrawPart(triArrays[itri]); int layer = triArrays[itri].Layer; dp.Height = (layer - layerMin) * layerHeight; DrawParts.Add(dp); } } { // 四角形要素をセット IList <MeshQuadArray2D> quadArrays = mesher.GetQuadArrays(); for (int iquad = 0; iquad < quadArrays.Count; iquad++) { Mesher2DDrawPart dp = new Mesher2DDrawPart(quadArrays[iquad]); int layer = quadArrays[iquad].Layer; dp.Height = (layer - layerMin) * layerHeight; DrawParts.Add(dp); } } { // 線要素をセット IList <MeshBarArray> barArrays = mesher.GetBarArrays(); for (int ibar = 0; ibar < barArrays.Count; ibar++) { double height = 0; { int layer = barArrays[ibar].Layer; height += (layer - layerMin + 0.01) * layerHeight; } Mesher2DDrawPart dp = new Mesher2DDrawPart(barArrays[ibar]); dp.Height = height; DrawParts.Add(dp); } } { // 頂点をセット IList <MeshVertex> vertexs = mesher.GetVertexs(); for (int iver = 0; iver < vertexs.Count; iver++) { double height = 0; /* * { * int layer = vertexs[iver].Layer; * height += (layer - layerMin + 0.1) * layerHeight; * } */ height = 0.2; Mesher2DDrawPart dp = new Mesher2DDrawPart(vertexs[iver]); dp.Height = height; DrawParts.Add(dp); } } { // 座標をセット IList <OpenTK.Vector2d> vec2Ds = mesher.GetVectors(); uint nDim = 2; uint nVec = (uint)vec2Ds.Count; VertexArray.SetSize(nVec, nDim); for (int ivec = 0; ivec < nVec; ivec++) { VertexArray.VertexCoordArray[ivec * nDim] = vec2Ds[ivec].X; VertexArray.VertexCoordArray[ivec * nDim + 1] = vec2Ds[ivec].Y; } } return(true); }