From experience, having a perfect care doesn't mean cleaning up the poop when the smelly waves appear. It's more like, cleaning the poop up before it there are a bunch of mounds. You basically can't let any of the hearts (food or happiness) get empty, or let it get sick. Like the Jstaches said, a care miss is when the alert system gives up and your tama is unhappy for awhile.
Also, on DreamTown, I have learned that it depends on both. Let's say you get perfect Cosmotchi. There are several ways this could go. I'm using the Robot class as an example just because it's easier. If you want Mametchi, you'd have to go to the Robot class a lot, but also have no care misses. If you go to the Robot class and get a lot of care misses, you wouldn't get Mametchi, but maybe someone else, like say, Righttchi, who's still in the Robot class, but not as "perfect" as Mametchi.
Also, it doesn't really depend on previous care miss evolutions. Mostly on what you do with your tama at your current stage. You can get the most perfect teen and make it evolve into a horrible adult if you get a bunch of care misses in the current teen stage.
It's the same in other characters: classes and care misses control which one you get (the growth chart should help). Gender>class>care misses.