several comp. geometry functions rewritten in C++

several comp. geometry functions rewritten in C++. This PR is the first one on way 2.4->2.5