A few days ago, I asked
Boars don't care about floors
Boars don't care about walls
Boars CARE about roofs (they don't want them)
Boars will appear happy if they are under a roof, but they will NOT MATE
Boars will NOT GIVE BIRTH under a roof
Wild boars that have just been tamed will try to avoid being under a roof as much as they can. If an opening is found, they will rush to it (can possibly lead to escapes). If food is under a roof, they will wander to it and get it, then return promptly to unsheltered space.
Boars born in captivity don't mind wandering around under the roof as much, although they do seem to prefer standing in unsheltered space most of the time. They will have no issue wandering in and out of sheltered space.
Shelter is ONLY considered Thatched Roofing tiles. Regular floor used as a roof is not considered to provide shelter
Boars can be fooled into thinking they are in open space, if they manage to clip through walls and be partially outside. Baiting them to escape by deconstructing a wall and immediately constructing it can create this situation. On reloading the instance, this can lead to boar escaping (assuming they didn't escape during the act of creating the wall clipping).
A totally closed off barn with a sloped roof is not a viable option to raise boars.
If a barn with a thatched roof is constructed, then an opening needs to be made for boars to wander into and be able to mate.
A thatched roof barn is also a viable option to store boars (if one does not wish reproduction). This could possibly have applications for FPS management inside the base, if the instances of mating are reduced? No idea how helpful it could be in that regard. It could definitely eliminate squealing if one does not wish to listen to that.
A closed barn with regular floor tiles used as a roof is a viable option. This is not as aesthetically pleasing (possibly), but boars will not mind.
Supposition: If the "Sheltered" trait is given to a boar, then they do not mate and do not give birth (even though it will not affect their happiness). Boars only mate and give birth if they do not possess the "Sheltered" trait.
Supposition 2 (of bees and boars): This does not seem to be the same rules as for Bees. Bees seem to be affected by Wall/Vertical Beam on the same x-level and Roof on the y-level. However it seems possible (unless it's a bug – no pun intended) for bees to be happy if a roof is above their heads, as long as they are far away from walls. For boars the check that happens seems to be much simpler, which leads me to Supposition 1