public override void MoveGripPointsAt(Int32Array Indexes, double dx, double dy, double dz) { if (Indexes == null || Indexes.Count == 0 || (dx == 0.0 && dy == 0.0 && dz == 0.0)) { return; } gPoints grips = GetGripPoints(); if (Indexes.Count == grips.Count) { Matrix mat = new Matrix(); mat.TranslateMatrix(dx, dy, dz); Transformby(mat); } else { foreach (int index in Indexes) { switch (index) { case 0: StartPoint += new gPoint(dx, dy, dz); break; case 1: EndPoint += new gPoint(dx, dy, dz); break; default: break; } } } Update(); }
public gPoints GetDisNetPipePoints() { string fName = "C:\\DisNetPoints.txt"; StreamReader sr = new StreamReader(new FileStream(fName, FileMode.Open, FileAccess.Read)); gPoints pts = new gPoints(); string[] values; string kStr = ""; double dx = 0.0, dy, dz; dx = dy = dz = 0.0; while (!sr.EndOfStream) { try { kStr = sr.ReadLine(); values = kStr.Split(new char[] { ',' }); dx = double.Parse(values[0]); dy = double.Parse(values[1]); dz = double.Parse(values[2]); pts.Add(dx, dy, dz); } catch (Exception exx) { } } sr.Close(); return(pts); }
public gPoints GetPoints(int div, double unitFactor) { gPoints gps = new gPoints(); div = 10; double x, y, xIncr; x = y = xIncr = 0.0d; xIncr = Length / div; UdlLoad = UdlLoad / unitFactor; for (int i = 0; i <= div; i++) { y = CalculateMomentWithConsLoad(x); if (i == 0) { y = -(Math.Abs(StartMoment)); } else if (i == div) { y = -(Math.Abs(EndMoment)); } gPoint gp = new gPoint(x, y); gps.Add(gp); x += xIncr; } return(gps); }
public override gPoints GetGripPoints() { gPoints ret = new gPoints(); ret.Add(StartPoint); ret.Add(EndPoint); return(ret); }
public override gPoints GetGripPoints() { gPoints ret = new gPoints(); gPoint cen = new gPoint(); ret.Add(cen); ECSMatrix.Transform(ret); return(ret); }
public static Vertexes GetVertexesFromPoints(List<PointData> points) { Vertexes vtxs = new Vertexes(); gPoints gps = new gPoints(); points.ForEach(pt => gps.Add(new gPoint(pt.X, pt.Y, pt.Z))); gps.RemoveEqualPoints(0.01); vtxs.AddRange(gps); return vtxs; }
///判断是个边是否符合圆柱体标准 bool IS4SideCyln(gPoints gEndSide1, gPoints gEndSide2, gPoints gParaSide1, gPoints gParaSide2, ref gPoint center1, ref gPoint center2, out double radius) { int half = gEndSide1.Count / 2; radius = 0.0; gPoint gp1 = gEndSide1[half]; gPoint gp2 = Globals.LineNearestTo(gParaSide1[0], gParaSide1[1], gp1, false); gPoint gp3 = Globals.LineNearestTo(gParaSide2[0], gParaSide2[1], gp1, false); gPoints gps1 = new gPoints(); if (gp1.AreEqual(gp2) || gp1.AreEqual(gp3) || gp2.AreEqual(gp3)) { return(false); } center1 = getCircleCenFrom3Pts(gp1, gp2, gp3); double dist = gp1.Distance3D(center1); gp1 = gEndSide2[half]; gp2 = Globals.LineNearestTo(gParaSide1[0], gParaSide1[1], gp1, false); gp3 = Globals.LineNearestTo(gParaSide2[0], gParaSide2[1], gp1, false); if (gp1.AreEqual(gp2) || gp1.AreEqual(gp3) || gp2.AreEqual(gp3)) { return(false); } center2 = getCircleCenFrom3Pts(gp1, gp2, gp3); //上边的距离是否满足半径要求 for (int i = 0; i < gEndSide1.Count; i++) { double ddd = Globals.distPointFromLine(gEndSide1[i], center1, center2); if (Math.Abs((ddd - dist)) > Globals.VD_ZERO2) { radius = 0; return(false); } } //下边的距离是否满足半径要求 for (int i = 0; i < gEndSide2.Count; i++) { double ddd = Globals.distPointFromLine(gEndSide2[i], center1, center2); if (Math.Abs((ddd - dist)) > Globals.VD_ZERO2) { radius = 0; return(false); } } radius = dist; return(true); }
/// <summary> /// 找到对应的点和向量 /// </summary> /// <param name="i32">定点数组</param> /// <param name="points">坐标数组</param> /// <param name="vdPf">父图形,里面存点和向量</param> /// <param name="orgin">输出找到的点</param> /// <param name="vector">输出找到的向量</param> /// <returns>是否找到</returns> /// bool FindPointVector(gPoints Points, vdPolyface vdp, vdFigure vdPf, ref gPoint orign, ref Vector vector) { int iii = 1; while (true) { string strName = "POINTVECTOR" + iii.ToString(); iii++; vdXProperty vdx = vdPf.XProperties.FindName(strName); if (vdx != null) { string strValue = (string)vdx.PropValue; string[] strs = strValue.Split(new char[] { ',' }); orign = new gPoint(double.Parse(strs[0]), double.Parse(strs[1]), double.Parse(strs[2])); vector = new Vector(double.Parse(strs[3]), double.Parse(strs[4]), double.Parse(strs[5])); double d = -1.0; gPoint gEnd = orign + vector; int currenti = 0; for (int i = 0; i < Points.Count; i++) { currenti = i; gPoint gp = Points[i]; double dd = gp.DistanceFromLine(orign, gEnd); if (d < 0) { d = dd; } else { if (Math.Abs(dd - d) > Globals.VD_ZERO5) { //MessageBox.Show("Error!"); break; } } } if (currenti == Points.Count - 1) { return(true); } } else { return(false); } } }
public double MaxX(gPoints gps) { double x = 0.0d; foreach (gPoint gp in gps) { if (Math.Abs(gp.x) > x) { x = Math.Abs(gp.x); } } return(x); }
public double MaxY(gPoints gps) { double y = 0.0d; foreach (gPoint gp in gps) { if (Math.Abs(gp.y) > y) { y = Math.Abs(gp.y); } } return(y); }
public override void MoveGripPointsAt(Int32Array Indexes, double dx, double dy, double dz) { if (Indexes == null || Indexes.Count == 0 || (dx == 0.0 && dy == 0.0 && dz == 0.0)) { return; } Matrix mat = new Matrix(); mat.TranslateMatrix(dx, dy, dz); gPoints grips = GetGripPoints(); ECSMatrix.GetInvertion().Transform(grips); Transformby(mat); Update(); }
double GetArea3D(gPoint gp1, gPoint gp2, gPoint gp3) { try { gPoints gps = new gPoints(); gps.Add(gp1); gps.Add(gp2); gps.Add(gp3); return(Math.Abs(gps.Area3D(gps.GetNormal()))); } catch { } return(0.0); }
public override gPoints GetGripPoints() { gPoints ret = new gPoints(); gPoint cen = new gPoint(); ret.Add(cen); double stepangle = Globals.VD_TWOPI / this.NumSides; double sang = 0.0d; for (int i = 0; i < NumSides; i++) { ret.Add(gPoint.Polar(cen, sang, Radius)); sang += stepangle; } ECSMatrix.Transform(ret); return(ret); }
public CRevit2vdl(string strFile, ProgressBar pgressBar) { progressBar1 = pgressBar; vec.EnsureDocument(); vec.ActiveDocument.EnsureDefaults(); doc = vec.ActiveDocument; vec.Progress += vec_Progress; doc.Open(strFile); foreach (vdFigure vdf in doc.ActiveLayOut.Entities) { if (vdf is vdPolyface) { vdPolyface vdp = vdf as vdPolyface; gPoints gps = vdp.VertexList.Clone() as gPoints; gps.RemoveEqualPoints(); } } }
bool FindPointVector(Int32Array i32, gPoints Points, vdFigure vdPf, ref gPoint orign, ref Vector vector) { int iii = 1; while (true) { string strName = "POINTVECTOR" + iii.ToString(); iii++; vdXProperty vdx = vdPf.XProperties.FindName(strName); if (vdx != null) { string strValue = (string)vdx.PropValue; string[] strs = strValue.Split(new char[] { ',' }); orign = new gPoint(double.Parse(strs[0]), double.Parse(strs[1]), double.Parse(strs[2])); vector = new Vector(double.Parse(strs[3]), double.Parse(strs[4]), double.Parse(strs[5])); double d = -1.0; for (int i = 0; i < i32.Count; i++) { gPoint gEnd = orign + vector; gPoint gp = Points[i32[i]]; double dd = gp.DistanceFromLine(orign, gEnd); if (d < 0) { d = dd; } else { if (Math.Abs(dd - d) > Globals.VD_ZERO5) { break; } } } return(true); } else { return(false); } } }
public override void MoveGripPointsAt(Int32Array Indexes, double dx, double dy, double dz) { try { if (Indexes == null || Indexes.Count == 0 || (dx == 0.0 && dy == 0.0 && dz == 0.0)) { return; } Matrix mat = new Matrix(); mat.TranslateMatrix(dx, dy, dz); gPoints grips = GetGripPoints(); ECSMatrix.GetInvertion().Transform(grips); if (Indexes.Count == grips.Count) { Transformby(mat); } else { foreach (int index in Indexes) { switch (index) { case 0: Transformby(mat); break; default: gPoint grip = new gPoint(grips[index]); grip = ECSMatrix.Transform(grip); grip += new gPoint(dx, dy, dz); this.Radius = gPoint.Distance2D(grip, this.Origin); break; } } } Update(); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); } }
/// <summary> /// /处理polyface /// </summary> //bool <param name="vdp"></param> bool GetVDPBorderLine(vdPolyface vdp, vdFigure vdPf) { vdPolyface vdpOut = new vdPolyface(); Dictionary <string, bool> kvs = new Dictionary <string, bool>(); Int32Array iii32 = vdp.FaceList; for (int i = 0; i < iii32.Count; i++) { if (vdp.FaceList[i] < 0) { if (i % 5 != 4) { vdp.FaceList[i] = -vdp.FaceList[i]; } } } iii32 = vdp.FaceList; for (int i = 0; i < iii32.Count; i = i + 5) { AddSide(kvs, iii32[i], iii32[i + 1]); AddSide(kvs, iii32[i + 1], iii32[i + 2]); AddSide(kvs, iii32[i + 2], iii32[i]); } //找到外边界 Int32Array i32 = ParaseSide2List(kvs, vdp.VertexList.Count + 1); if (i32.Count < 5) { return(false); } //找到向量 ///int iii = 1; gPoints Points = vdp.VertexList; Points.makeClosed(); gPoints gps = new gPoints();// Points.Clone() as gPoints; foreach (int ii in i32) { gps.Add(Points[ii - 1]); } gps.RemoveEqualPoints(Globals.VD_ZERO5); //gps.RemoveInLinePoints(); Int32Array ii32 = new Int32Array(); gPoints gpss = new gPoints(); #region 延长线段到最长 gpss.Add(gps[0]); for (int i = 0; i < gps.Count - 1; i++) { //if (i == 5) //{ // int j = 0; //} if (i != gps.Count - 2) { double dd = Globals.distPointFromLine(gps[i + 2], gps[i], gps[i + 1]); if (Globals.distPointFromLine(gps[i + 2], gps[i], gps[i + 1]) < 0.2) { continue; } else { gpss.Add(gps[i + 1]); } } if (i == gps.Count - 2) { if (Globals.distPointFromLine(gps[1], gps[i], gps[i + 1]) < 0.2) { gpss.RemoveAt(0); } else { gpss.Add(gps[i + 1]); } } } #endregion gpss.makeClosed(); gpss.RemoveLast(); //找到四条边中符合圆柱体标准的。 if (gpss.Count % 2 != 0 || gpss.Count < 10) { return(false); } int half = gpss.Count / 2; gPoints gEndSide1 = new gPoints(); gPoints gEndSide2 = new gPoints(); gPoints gParaSide1 = new gPoints(); gPoints gParaSide2 = new gPoints(); for (int i = 0; i < gpss.Count / 2; i++) { Vector v1 = new Vector(gpss[i], gpss[i + 1]); Vector v2 = new Vector(gpss[i + half], gpss[(half + i + 1) % gpss.Count]); v1.Cross(v2); if (v1.Length < Globals.VD_ZERO6) //说明平行 { gEndSide1.RemoveAll(); gEndSide2.RemoveAll(); gParaSide1.RemoveAll(); gParaSide2.RemoveAll(); gParaSide1.Add(gpss[i]); gParaSide1.Add(gpss[i + 1]); gParaSide2.Add(gpss[i + half]); gParaSide2.Add(gpss[(half + i + 1) % gpss.Count]); for (int j = i + 1; j < i + half; j++) { gEndSide1.Add(gpss[j]); } for (int j = i + half + 1; j < i + 2 * half; j++) { gEndSide2.Add(gpss[j % gpss.Count]); } gPoint sp1 = new gPoint(); gPoint sp2 = new gPoint(); double radius = 0.0; //判断是个边是否符合圆柱体标准 if (!IS4SideCyln(gEndSide1, gEndSide2, gParaSide1, gParaSide2, ref sp1, ref sp2, out radius)) //不符合圆柱体标准 ,直接返回错误 { continue; } gpss.RemoveAll(); //这里可以进行圆柱简化 gpss.AddRange(gEndSide1); gpss.AddRange(gParaSide2); gpss.AddRange(gEndSide2); gpss.AddRange(gParaSide1); //是否齐头圆柱,即没有切过的圆柱,如果齐圆柱头,特殊处理,此处暂时不变, // half = gpss.Count / 2; vdpOut.VertexList = gpss; vdpOut.FaceList = new Int32Array(); for (int ii = 1; ii < half; ii++) { vdpOut.FaceList.Add(ii); vdpOut.FaceList.Add(ii + 1); vdpOut.FaceList.Add(gpss.Count - (ii + 1) + 1); vdpOut.FaceList.Add(gpss.Count - ii + 1); vdpOut.FaceList.Add(-1); } vdp.FaceList = vdpOut.FaceList; vdp.VertexList = vdpOut.VertexList; //vdp.Invalidate(); //vdp.Update(); break; } } //找到两个顶边,如果多个就扔掉了。 //GetNonParaSide(vdp.VertexList, i32, orign, vector); return(true); //Int32Array side1= }
public void Draw_StructureGraph(vdDocument document) { gPoints gps = astDoc.BeamAnalysisCalc.GetPoints(10, astDoc.LoadUnitFactor); //Jay Shree Krishna //Jay Shree Ganesh document.ActiveLayOut.Entities.RemoveAll(); #region MainLIne vdLine mainLine = new vdLine(); mainLine.SetUnRegisterDocument(document); mainLine.setDocumentDefaults(); mainLine.StartPoint = new gPoint(10.0d, 10.0d); mainLine.EndPoint = new gPoint(30.0d, 10.0d); document.ActiveLayOut.Entities.AddItem(mainLine); #endregion #region Side Line 1 vdLine sideLine1 = new vdLine(); sideLine1.SetUnRegisterDocument(document); sideLine1.setDocumentDefaults(); sideLine1.StartPoint = new gPoint(10, 5); sideLine1.EndPoint = new gPoint(10, 15); document.ActiveLayOut.Entities.AddItem(sideLine1); #endregion #region Side Line 2 vdLine sideLine2 = new vdLine(); sideLine2.SetUnRegisterDocument(document); sideLine2.setDocumentDefaults(); sideLine2.StartPoint = new gPoint(30, 5); sideLine2.EndPoint = new gPoint(30, 15); document.ActiveLayOut.Entities.AddItem(sideLine2); #endregion #region Draw PolyLine vdPolyline pLine = new vdPolyline(); pLine.SetUnRegisterDocument(document); pLine.setDocumentDefaults(); //pLine.VertexList.Add(mainLine.StartPoint); double st, en, highest; st = en = highest = 0.0d; //if (IsShear) //{ highest = MaxY(gps); //} //else //{ // highest = MaxMoment(SpanNo); //} double xIncr = 0.0d; for (int i = 0; i < gps.Count; i++) { st = -gps[i].y; gPoint gp = new gPoint(); gp.x = mainLine.StartPoint.x + xIncr; xIncr += 2.0d; st = -st; if (st > 0) { gp.y = mainLine.StartPoint.y + (sideLine1.EndPoint.y - mainLine.StartPoint.y) * (st / highest); } else { gp.y = mainLine.StartPoint.y - (sideLine1.StartPoint.y - mainLine.StartPoint.y) * (st / highest); } pLine.VertexList.Add(gp); vdLine vLine = new vdLine(); vLine.SetUnRegisterDocument(document); vLine.setDocumentDefaults(); vLine.StartPoint = gp; vLine.EndPoint = new gPoint(gp.x, mainLine.StartPoint.y); document.ActiveLayOut.Entities.AddItem(vLine); vdText yValue = new vdText(); yValue.SetUnRegisterDocument(document); yValue.setDocumentDefaults(); yValue.InsertionPoint = vLine.EndPoint; yValue.TextString = st.ToString("0.00"); if (st > 0) { yValue.Rotation = 270.0d * Math.PI / 180.0d; yValue.InsertionPoint.x -= 0.25d; yValue.InsertionPoint.y -= 0.5d; } else { yValue.Rotation = 90.0d * Math.PI / 180.0d; yValue.InsertionPoint.x += 0.25d; yValue.InsertionPoint.y += 0.5d; } yValue.Height = 1.0d; document.ActiveLayOut.Entities.AddItem(yValue); } document.ShowUCSAxis = false; document.ActiveLayOut.Entities.AddItem(pLine); #endregion #region Draw Rectangle vdRect rect = new vdRect(); rect.SetUnRegisterDocument(document); rect.setDocumentDefaults(); rect.InsertionPoint = new gPoint(sideLine1.StartPoint.x - 2, sideLine1.StartPoint.y - 2); rect.Width = 23.0d; rect.Height = 13.0d; document.ActiveLayOut.Entities.AddItem(rect); #endregion document.Redraw(true); VectorDraw.Professional.ActionUtilities.vdCommandAction.View3D_VTop(document); }
public override void FillShapeEntities(ref vdEntities entities) { //calculate shape entities in ecs gPoint cen = new gPoint(); vdText text = new vdText(); //entities.AddItem(text); //text.MatchProperties(this, Document); text.Style = TextStyle; text.TextString = TextString; text.VerJustify = VdConstVerJust.VdTextVerCen; text.HorJustify = VdConstHorJust.VdTextHorCenter; text.Height = TextHeight; text.InsertionPoint = cen; vdPolyline pl = new vdPolyline(); entities.AddItem(cirStart); entities.AddItem(pl); //entities.AddItem(pl2); pl.MatchProperties(this, Document); cirStart.MatchProperties(this, Document); cirEnd.MatchProperties(this, Document); Vertexes verts = new Vertexes(); double stepangle = Globals.VD_TWOPI / this.NumSides; double sang = 0.0d; for (int i = 0; i < NumSides; i++) { verts.Add(gPoint.Polar(cen, sang, Radius)); sang += stepangle; } pl.VertexList = verts; pl.Flag = VdConstPlineFlag.PlFlagCLOSE; //entities.AddItem(cirEnd); cirStart.Center = cen; cirStart.Radius = mRadius; cirStart.Thickness = PipeHeight; //cirStart.Thickness = cirStart.Center.Distance3D(EndPoint); //cirStart.ExtrusionVector = new Vector(0.0, 1.0, 0.0); //cirStart.ExtrusionVector = Vector.CreateExtrusion(EndPoint, StartPoint); cirStart.ExtrusionVector = Vector.CreateExtrusion(StartPoint, EndPoint); cirEnd.Center = EndPoint; cirEnd.Radius = mRadius; //cirEnd.ExtrusionVector = Vector.CreateExtrusion(cen, EndPoint); //cirEnd.ExtrusionVector = cirStart.ExtrusionVector; // Draw DisNet Pipe gPoints gPts = GetDisNetPipePoints(); //vdPolyline plDisNet = new vdPolyline(); pl.VertexList = new Vertexes(gPts); //entities.AddItem(pl); }
public void DrawBeamMember(vdDocument document, int MemberNo, int LoadCase, BeamForceMomentCollection.eForce ef) { astDoc.BeamAnalysisCalc.InitializeVariable(); //return; int MemberIndex = -1; int MemberLoadIndex = -1; int MemberPropIndex = -1; int MemberPostProcIndex = -1; MemberIndex = astDoc.Members.IndexOf(MemberNo); MemberLoadCollection mLoadCol = astDoc.MemberLoads.GetAllMemberLoad(MemberNo, LoadCase); MemberLoadIndex = astDoc.MemberLoads.IndexOf(MemberNo, LoadCase); MemberPropIndex = astDoc.MemberProperties.IndexOf(MemberNo); MemberPostProcIndex = beamMomentCol.IndexOf(MemberNo, LoadCase); if (MemberIndex != -1) { astDoc.BeamAnalysisCalc.Length = astDoc.Members[MemberIndex].StartNode.Point.Distance3D( astDoc.Members[MemberIndex].EndNode.Point); } if (MemberLoadIndex != -1) { //if (astDoc.MemberLoads[MemberLoadIndex].LoadType == MemberLoad.eLoadType.Concentrate) //{ // BeamAnalysisCalculator.ConcentrateLoad cLoad = new BeamAnalysisCalculator.ConcentrateLoad(); // cLoad.Distance = astDoc.MemberLoads[MemberLoadIndex].DistanceFromStartNode; // cLoad.Force = astDoc.MemberLoads[MemberLoadIndex].Value; // astDoc.BeamAnalysisCalc.ConsLoads.Add(cLoad); //} //else //{ // astDoc.BeamAnalysisCalc.UdlLoad = astDoc.MemberLoads[MemberLoadIndex].Value; //} astDoc.BeamAnalysisCalc.ConsLoads.Clear(); for (int ii = 0; ii < mLoadCol.Count; ii++) { if (mLoadCol[ii].LoadType == MemberLoad.eLoadType.Concentrate && mLoadCol[ii].Member.MemberNo == MemberNo) { BeamAnalysisCalculator.ConcentrateLoad cLoad = new BeamAnalysisCalculator.ConcentrateLoad(); cLoad.Distance = mLoadCol[ii].DistanceFromStartNode; cLoad.Force = mLoadCol[ii].Value; astDoc.BeamAnalysisCalc.ConsLoads.Add(cLoad); } else { astDoc.BeamAnalysisCalc.UdlLoad = astDoc.MemberLoads[MemberLoadIndex].Value; } } } if (MemberPropIndex != -1) { } if (MemberPostProcIndex != -1) { switch (ef) { case BeamForceMomentCollection.eForce.M1: astDoc.BeamAnalysisCalc.StartMoment = beamMomentCol[MemberPostProcIndex].StartForceMoment.M1; astDoc.BeamAnalysisCalc.EndMoment = beamMomentCol[MemberPostProcIndex].EndForceMoment.M1; break; case BeamForceMomentCollection.eForce.M2: astDoc.BeamAnalysisCalc.StartMoment = beamMomentCol[MemberPostProcIndex].StartForceMoment.M2; astDoc.BeamAnalysisCalc.EndMoment = beamMomentCol[MemberPostProcIndex].EndForceMoment.M2; break; case BeamForceMomentCollection.eForce.M3: astDoc.BeamAnalysisCalc.StartMoment = beamMomentCol[MemberPostProcIndex].StartForceMoment.M3; astDoc.BeamAnalysisCalc.EndMoment = beamMomentCol[MemberPostProcIndex].EndForceMoment.M3; break; } } try { gPoints gps = astDoc.BeamAnalysisCalc.GetPoints(10, astDoc.LoadUnitFactor); if (astDoc.Members[MemberIndex].StartNode.Point.y == astDoc.Members[MemberIndex].EndNode.Point.y) { beamMomentCol.DrawBeamForceMoment_Bending(document, MemberNo, LoadCase, ef, gps); } else { beamMomentCol.DrawBeamForceMoment(document, MemberNo, ef, LoadCase); } } catch (Exception exx) { } }
bool Merge3DFace(vdPolyface vdp) { int II = int.MaxValue; Int32Array i32 = vdp.FaceList; Dictionary <int, int> deleteID = new Dictionary <int, int>(); Dictionary <int, int> kk1 = new Dictionary <int, int>(); Dictionary <int, int> kk2 = new Dictionary <int, int>(); //合并三角形 #region 合并三角形 for (int i = 0; i < i32.Count; i = i + 5) { if (i32[i + 4] != II && i32[i] == i32[i + 3]) //一定是没有被合并过的,说明是三角形 { int i1 = i32[i]; int i2 = i32[i + 1]; int i3 = i32[i + 2]; kk1.Clear(); kk1.Add(i1, i1); kk1.Add(i2, i2); kk1.Add(i3, i3); for (int j = i + 5; j < i32.Count; j = j + 5) { if (i32[j + 4] != II && i32[j] == i32[j + 3]) //剔除已经处理过的 { int j1 = i32[j]; int j2 = i32[j + 1]; int j3 = i32[j + 2]; //kk2.Clear(); //kk2.Add(j1, j1); //kk2.Add(j2, j2); //kk2.Add(j3, j3); int k1 = 0; int k2 = 0; int k3 = 0; int k4 = 0; //找到公共边 if ((i1 == j1 || i1 == j2 || i1 == j3) && (i2 == j1 || i2 == j2 || i2 == j3)) { k1 = i3; k2 = i1; k4 = i2; } else if ((i2 == j1 || i2 == j2 || i2 == j3) && (i3 == j1 || i3 == j2 || i3 == j3)) { k1 = i1; k2 = i2; k4 = i3; } else if ((i1 == j1 || i1 == j2 || i1 == j3) && (i3 == j1 || i3 == j2 || i3 == j3)) { k1 = i2; k2 = i3; k4 = i1; } else { continue; } if (!kk1.ContainsKey(j1)) { k3 = j1; } if (!kk1.ContainsKey(j2)) { k3 = j2; } if (!kk1.ContainsKey(j3)) { k3 = j3; } //检查是否共面 gPoints gps3 = new gPoints(); //gps3.Add(vdp.VertexList[i1 - 1]); //gps3.Add(vdp.VertexList[i2 - 1]); //gps3.Add(vdp.VertexList[i3 - 1]); gps3.Add(vdp.VertexList[k1 - 1]); gps3.Add(vdp.VertexList[k2 - 1]); gps3.Add(vdp.VertexList[k4 - 1]); Vector vec = gps3.GetNormal(); // 导出时,下面计算dist的方法有异常OutOfRange异常抛出,特加以下判断 if (k3 > vdp.VertexList.Count || k1 > vdp.VertexList.Count || k3 <= 0 || k1 <= 0) { continue; } double dist = Globals.DistancePointToPlane(vdp.VertexList[k3 - 1], vec, vdp.VertexList[k1 - 1]); if (Math.Abs(dist) > Globals.VD_ZERO6) { continue; } //判断是否是凹多边形 凹多边形有显示问题 ////判断是否构成了三角形 gps3.InsertAt(3, vdp.VertexList[k3 - 1]); //gPoints gps4=gps3.Clone() as gPoints; //gps3.makeClosed(); //gps4.makeClosed(); //gps4.RemoveInLinePoints(); //if (gps3.Count != gps4.Count) continue; double area1 = GetArea3D(gps3[0], gps3[1], gps3[2]); double area2 = GetArea3D(gps3[3], gps3[1], gps3[2]); double area3 = GetArea3D(gps3[0], gps3[1], gps3[3]); double area4 = GetArea3D(gps3[0], gps3[2], gps3[3]); double area = Math.Max(area3, area4); if (area1 + area2 <= area) //凹多边形 { continue; } i32[i] = k4; i32[i + 1] = k1; i32[i + 2] = k2; i32[i + 3] = k3;//这里放到第3个点经常出现问题 i32[j + 4] = II; break; } } } } #endregion #region 生成新的polyface Int32Array iii32 = new Int32Array(); for (int i = 0; i < vdp.FaceList.Count; i = i + 5) { if (vdp.FaceList[i + 4] != II) { iii32.Add(i32[i]); iii32.Add(i32[i + 1]); iii32.Add(i32[i + 2]); iii32.Add(i32[i + 3]); iii32.Add(i32[i + 4]); } } vdp.FaceList = iii32; vdp.Invalidate(); #endregion return(true); }