Your latest snippet does not have digitalWrite(outPin,HIGH);. If it's the same as the first sketch you posted, you moved it to the wrong spot. Now you're setting it high on each pass through loop, not just each increment up the ramp. That's the opposite of what you need to do. You need to write the pin less often, not more. Once per pulse, not once per loop.
if(Pwm==pwmMax)
{
digitalWrite(outPin,LOW);
delay(ramplength);
}
Why are you delaying here? This is what is causing the triangle to turn into a trapezoid. You have the right idea writing the pin LOW here, just ditch the delay.
do
{
digitalWrite(outPin, LOW);
} while((Dir==-1) && (Dir != +1));
Why did you try a do-while loop here? Since you don't change any of the variables in the condition inside the loop, it will either exit after one run or never exit. The second half of the && expression is also redundant; It is logically impossible for Dir to be equal to both -1 and +1, so the result is determined completely by the first half of the expression.
You are close. Home stretch.