replaceVertex method

void replaceVertex(
  1. Vertex oldv,
  2. Vertex newv
)

Implementation

void replaceVertex(Vertex oldv, Vertex newv) {
	if (oldv == this.v1 ) this.v1 = newv;
	else if (oldv == this.v2 ) this.v2 = newv;
	else if (oldv == this.v3 ) this.v3 = newv;

	SMUtil.removeFromArray( oldv.faces, this );
	newv.faces.add(this);


	oldv.removeIfNonNeighbor(this.v1);
	this.v1?.removeIfNonNeighbor(oldv);

	oldv.removeIfNonNeighbor(this.v2);
	this.v2?.removeIfNonNeighbor(oldv);

	oldv.removeIfNonNeighbor(this.v3);
	this.v3?.removeIfNonNeighbor(oldv);

	this.v1?.addUniqueNeighbor(this.v2);
	this.v1?.addUniqueNeighbor(this.v3);

	this.v2?.addUniqueNeighbor(this.v1);
	this.v2?.addUniqueNeighbor(this.v3);

	this.v3?.addUniqueNeighbor(this.v1);
	this.v3?.addUniqueNeighbor(this.v2);

	this.computeNormal();
}