How to Transforms a actor's bound from the view's world-space into pixel coordinates with bounding box

How to transforms a actor’s bound from the view’s world-space into pixel coordinates with bounding box like

Rect(x,y,width,height)

X,Y relative to the view’s X,Y (left, top) and

width,height relative to view’s Z and rotation

Here’s a modified excerpt from AHUD::GetActorsInSelectionRectangle, which is doing bounding box comparisons for actors inside rectangle in screen space.

It’s projecting the corners of the actors bounding box into screen space, and using the FBox2D to accumulate the extents of that box in screen space.

//The Actor Bounds Point Mapping
const FVector BoundsPointMapping[8] =
{
	FVector(1, 1, 1),
	FVector(1, 1, -1),
	FVector(1, -1, 1),
	FVector(1, -1, -1),
	FVector(-1, 1, 1),
	FVector(-1, 1, -1),
	FVector(-1, -1, 1),
	FVector(-1, -1, -1)
};
//Get Actor Bounds	casting to base class, checked by template in the .h
const FBox EachActorBounds = Actor->GetComponentsBoundingBox(true); /* All Components */

//Center
const FVector BoxCenter = EachActorBounds.GetCenter();

//Extents
const FVector BoxExtents = EachActorBounds.GetExtent();

// Build 2D bounding box of actor in screen space
FBox2D ActorBox2D(0);
for (uint8 BoundsPointItr = 0; BoundsPointItr < 8; BoundsPointItr++)
{
	// Project vert into screen space.
	const FVector ProjectedWorldLocation = Project(BoxCenter + (BoundsPointMapping[BoundsPointItr] * BoxExtents));
	// Add to 2D bounding box
	ActorBox2D += FVector2D(ProjectedWorldLocation.X, ProjectedWorldLocation.Y);
}

thank you very much

Where should I put these codes? In the files like MyActor.cpp or MyActor.h?