package d2isometricimg

import 

// Subtract a flat caption area from its own already dashed wire and casing.
// Clipping the actual triangles keeps the original dash phase, joins,
// and full authored stroke width, including diagonal segments. Each half-plane
// emits an exterior piece and passes only the remaining interior to the next;
// the emitted pieces never overlap, including for translucent source ink.
func ( *meshBuilder) ( int,  labelSurface) {
	if .width <= 0 || .depth <= 0 ||  == len(.triangles) {
		return
	}
	 := append([]Triangle(nil), .triangles[:]...)
	.triangles = .triangles[:]
	,  := math.Cos(.angle), math.Sin(.angle)
	 := captionProjection(.center)
	 := [4]float64{-.width / 2, .width / 2, -.depth / 2, .depth / 2}
	for ,  := range  {
		if .err != nil {
			return
		}
		if %1024 == 0 {
			if  := .ctx.Err();  != nil {
				.err = 
				return
			}
		}
		var  [8]Vertex
		copy([:], .V[:])
		 := 3
		for ,  := range  {
			if  < 3 {
				break
			}
			 := func( Vertex) float64 {
				 := captionProjection(.Position)
				,  := .x-.x, .z-.z
				,  := *+*, -*+*
				switch  {
				case 0:
					return  - 
				case 1:
					return  - 
				case 2:
					return  - 
				default:
					return  - 
				}
			}
			var ,  [8]Vertex
			,  := 0, 0
			 := [-1]
			 := ()
			for ,  := range [:] {
				 := ()
				if ( >= 0) != ( >= 0) {
					 :=  / ( - )
					 := Vertex{Position: nlerp(.Position, .Position, ), Normal: nlerp(.Normal, .Normal, ), U: .U + (.U-.U)*, V: .V + (.V-.V)*}
					if  != 0 &&  != 0 {
						[],  = , +1
					}
					[],  = , +1
				}
				if  >= 0 {
					[],  = , +1
				} else {
					[],  = , +1
				}
				,  = , 
			}
			for  := 1; +1 < ; ++ {
				if nlen(ncross(nsub([].Position, [0].Position), nsub([+1].Position, [0].Position))) > 1e-18 {
					 := len(.triangles)
					.triangle([0], [], [+1], .Material, .CastShadow)
					if len(.triangles) >  {
						 := 
						.V = .triangles[].V
						.triangles[] = 
					}
				}
			}
			,  = , 
		}
	}
}