From: abn Date: Wed, 14 May 2014 15:10:08 +0000 (+0200) Subject: Creating OTT2 class: allows switching back and forth between signed Fortran indexing X-Git-Tag: intersect_1D_OK~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7c6a22b7241dd16a0ce0b4be2035687355348f35;p=tools%2Fmedcoupling.git Creating OTT2 class: allows switching back and forth between signed Fortran indexing and unsigned C indexing. --- diff --git a/src/INTERP_KERNEL/InterpolationUtils.hxx b/src/INTERP_KERNEL/InterpolationUtils.hxx index 2a6808c1d..0f1b7b38e 100644 --- a/src/INTERP_KERNEL/InterpolationUtils.hxx +++ b/src/INTERP_KERNEL/InterpolationUtils.hxx @@ -38,6 +38,10 @@ namespace INTERP_KERNEL { + /** + * Utility class performing conversion from Fortran indexing to C indexing. + * ConnType is typically an integer type describing a connectivity. + */ template class OTT//OffsetToolTrait { @@ -47,20 +51,44 @@ namespace INTERP_KERNEL class OTT { public: - static ConnType indFC(ConnType i) { return i; } - static ConnType ind2C(ConnType i) { return i; } - static ConnType conn2C(ConnType i) { return i; } - static ConnType coo2C(ConnType i) { return i; } + static inline ConnType indFC(ConnType i) { return i; } + static inline ConnType ind2C(ConnType i) { return i; } + static inline ConnType conn2C(ConnType i) { return i; } + static inline ConnType coo2C(ConnType i) { return i; } }; template class OTT { public: - static ConnType indFC(ConnType i) { return i+1; } - static ConnType ind2C(ConnType i) { return i-1; } - static ConnType conn2C(ConnType i) { return i-1; } - static ConnType coo2C(ConnType i) { return i-1; } + static inline ConnType indFC(ConnType i) { return i+1; } + static inline ConnType ind2C(ConnType i) { return i-1; } + static inline ConnType conn2C(ConnType i) { return i-1; } + static inline ConnType coo2C(ConnType i) { return i-1; } + }; + + /** + * Very similar to OTT but also deals with orientation along the way. + */ + template + class OTT2 + { + }; + + template + class OTT2 + { + public: + static inline ConnType ind2F(ConnType i, const bool orient) { return orient?(i+1):-(i+1); } + static inline ConnType ind2C(ConnType i, bool & orient) { orient=true; return i; } + }; + + template + class OTT2 + { + public: + static inline ConnType ind2F(ConnType i, const bool orient) { return i; } + static inline ConnType ind2C(ConnType i, bool & orient) { orient=(i>0); return abs(i)-1; } }; /*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */