/// <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> /// 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); }