/// <summary> /// Start empty data struct /// This constructor is good only when you insert the triangles manually /// </summary> public DataStructHE( IFaceTree faceTree ) { // init the face tree this.faceTree = faceTree; // ini the min max boundary BoundaryMinMax = new BoundaryNodeMaxMin(); }
/// <summary> /// Recursive correction of triangles /// the common edge is the edge of the other triangle /// </summary> /// <param name="CommonEdge"></param> /// <param name="faceTree"></param> public void DelaunayCorrection( Half_Edge CommonEdge, IFaceTree faceTree ) { if (CommonEdge != null && this.InCircle(CommonEdge.NextEdge.NextEdge.StartVertex)) { // remove the faces from the tree before to change them faceTree.Remove(CommonEdge.Face); faceTree.Remove(CommonEdge.TwinEdge.Face); // swap the common edge CommonEdge.Swap(); // add the face again with the new parameters faceTree.Add(CommonEdge.Face); faceTree.Add(CommonEdge.TwinEdge.Face); // run correction for the next 2 triangles if(CommonEdge.StartVertex == this.StartVertex){ CommonEdge.DelaunayCorrection(CommonEdge.NextEdge.TwinEdge, faceTree); CommonEdge.TwinEdge.NextEdge.DelaunayCorrection(CommonEdge.TwinEdge.NextEdge.NextEdge.TwinEdge, faceTree); }else{ CommonEdge.NextEdge.DelaunayCorrection(CommonEdge.NextEdge.NextEdge.TwinEdge, faceTree); CommonEdge.TwinEdge.DelaunayCorrection(CommonEdge.TwinEdge.NextEdge.TwinEdge, faceTree); } } }
/// <summary> /// Init the data Struct with Predefine triangle /// And give the prefer tree struct for the faces. /// </summary> /// <param name="ver1"></param> /// <param name="ver2"></param> /// <param name="ver3"></param> public DataStructHE(IVertex<float> ver1, IVertex<float> ver2, IVertex<float> ver3, IFaceTree faceTree) { Init(ver1, ver2, ver3, faceTree); }
/// <summary> /// Init the internal state /// </summary> /// <param name="ver1"></param> /// <param name="ver2"></param> /// <param name="ver3"></param> /// <param name="faceTree"></param> private void Init(IVertex<float> ver1, IVertex<float> ver2, IVertex<float> ver3, IFaceTree faceTree) { // init the face tree this.faceTree = faceTree; // ini the min max boundary BoundaryMinMax = new BoundaryNodeMaxMin(); // add the 3 half edge Half_Edge he1, he2, he3; // crate the triangle Half_Edge.CreateTriangle(ver1, ver2, ver3, out he1, out he2, out he3); // create and link the boundary list { // create the boundary list RootBoundaryNode = new BoundaryNode(he1, true); BoundaryNode nextBoundaryNode1 = new BoundaryNode(he1.NextEdge); BoundaryNode nextBoundaryNode2 = new BoundaryNode(he1.NextEdge.NextEdge); // link the root with the next node RootBoundaryNode.NextNode = nextBoundaryNode1; nextBoundaryNode1.PrevNode = RootBoundaryNode; // link the root with the next node nextBoundaryNode1.NextNode = nextBoundaryNode2; nextBoundaryNode2.PrevNode = nextBoundaryNode1; // link the first with the last one nextBoundaryNode2.NextNode = RootBoundaryNode; RootBoundaryNode.PrevNode = nextBoundaryNode2; // select the min/max nodes { // init min/max BoundaryMinMax.X_Max = RootBoundaryNode; BoundaryMinMax.X_Min = RootBoundaryNode; BoundaryMinMax.Y_Max = RootBoundaryNode; BoundaryMinMax.Y_Min = RootBoundaryNode; // set the start node and move to the next one // because we use the first for init BoundaryNode tmpNode = RootBoundaryNode; tmpNode = tmpNode.NextNode; while (true) { // update the boundary max/min UpdateBoundaryMaxMin(tmpNode); // move to the next node tmpNode = tmpNode.NextNode; // break if we are in the start if (tmpNode.IsTheRoot) break; } } } // create a face base on the 3 vertex Face newFace = new Face(he1); // add the face to the tree faceTree.Add(newFace); }