All day and into the night, the police were being taunted. Insults and sometimes water bottles were hurled their way. Cameras were pointed at them from every direction.

Yet, as they have done throughout the downtown drama known as Occupy D.C., the U.S. Park Police and D.C. officers displayed remarkable discipline and restraint Sunday during their confrontation with protesters in McPherson Square. Even as they arrested 31 Occupiers, the officers didn’t become a laughingstock Internet meme. They didn’t succumb to the brutality we witnessed in Oakland, or the appallingly brazen pepper-spraying that was filmed at the University of California at Davis.

And that’s saying something, given the reality-show-style stunt the police were asked to pull off Sunday night, after park protesters living in tents erected the bones of a small barn.

For any structure in the square to be legal, it has to be temporary. But there was nothing temporary about the sturdy two-by-fours that made up the new building’s bones.

Its construction was pure provocation of a police force that has already been stunningly accommodating and patient with the Occupy protesters.

Police asked them to take the barn down. They said no. Instead, some of them climbed up to the top, where they prostrated themselves, crucifixion style, on the rafters or straddled them like jungle gym bars and occasionally fist-pumped to the crowd below.

So authorities called in a building inspector to check it for safety.

Within minutes of arriving, the inspector slapped orange “Danger” stickers on the building and police closed in to take it down. The protesters got a few more warnings to leave.

Like a game of wills between parent and toddler, the police counted — one, two, three. And they began arresting the ones who remained inside the barn.

Then there was the challenge of safely arresting the ones who remained clinging to the rafters while dozens of cameras recorded their every move. The police pulled up a tactical vehicle and stood on the roof, hoping to get them off that way. No dice. The Occupiers scrambled to the other side.

They had a giant inflatable mattress that two guys eventually jumped onto (that would’ve been my choice — it looked fun). Finally, there was a huge cherry picker, which maneuvered around the structure cornering each protester. The two cops inside it harnessed, roped and very precariously hauled each remaining Occupier into the bucket.

It was sort of like rodeo meets Cirque du Soleil.

The cost of this little passion play had to be staggering, although no one has put a dollar figure on it yet. I counted dozens of officers, a tiny herd of horses, at least two tactical vehicles, a forklift, a cherry picker, plus that moonbounce thing.

Mark Francis Nickens, 51, stood outside the police barricade, watching the confrontation get more and more tense. Nickens has been hanging with the protesters for weeks. In fact, he’s got one of the most visible structures; the tepee that’s closest to the White House is his doing. But on Sunday, he was fuming, certain the the hubris of lumber and nails would spell the end of their stay.

“This was not what was supposed to happen,” said the musician and dog walker from Takoma Park. “You don’t just go and antagonize the cops for nothing.”

But that’s exactly what they were doing. Young protesters hopped up on empowerment and anything else that could be found in those tents randomly spit insults at officers who were standing nearby, simply doing their jobs. Park Police officers, who make starting salaries of $52,000 a year, are firmly part of that 99 percent the movement keeps talking about.

U.S. Park Police spokesman Sgt. David Schlosser said the officers are trained to stay professional, to see the insults as “meaningless.” They got called pigs and po-po, but the officers were as poker-faced as beefeaters.

The protesters are blatantly violating the law on a daily basis in the park, cooking, showering, sleeping, occupying. Yet they also have a righteous message about the nation’s widening wealth gap that a good chunk of the 99 percent agree with. The protests are making people think and talk about the nation’s housing and unemployment crises. Many people are just as angry as the protesters. They are ready for change and hungry for solutions.

The protesters have a powerful platform and a silent blessing from a police force that has looked the other way on loads of petty stuff. Taunting those officers undermines the very message the Occupiers are trying to deliver. It’s cowardly and ridiculous, especially when there are so many real villains to holler at.