From 70d32528cd01055fd752faa3ec9b7c45afcf0473 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Wed, 23 Dec 2020 11:16:38 +0100 Subject: [PATCH] Added new utility conversions DbU::toMicrons() & DbU::fromMicrons(). --- hurricane/src/hurricane/hurricane/DbU.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/hurricane/src/hurricane/hurricane/DbU.h b/hurricane/src/hurricane/hurricane/DbU.h index c65a7cbc..be2f830b 100644 --- a/hurricane/src/hurricane/hurricane/DbU.h +++ b/hurricane/src/hurricane/hurricane/DbU.h @@ -29,13 +29,10 @@ // +-----------------------------------------------------------------+ -#ifndef HURRICANE_DBU_H -#define HURRICANE_DBU_H - - -#include -#include -#include "hurricane/Commons.h" +#pragma once +#include +#include +#include "hurricane/Commons.h" namespace Hurricane { @@ -78,6 +75,8 @@ namespace Hurricane { static inline Unit fromGrid ( double value ); static inline Unit fromLambda ( double value ); static inline Unit fromPhysical ( double value, UnitPower p ); + static inline Unit fromMicrons ( double value ); + static inline Unit fromNanos ( double value ); // Old naming scheme (was not very clear). static inline Unit db ( Unit value ); static inline Unit grid ( double value ); @@ -116,6 +115,8 @@ namespace Hurricane { static inline double toLambda ( double u ); static inline double toPhysical ( Unit u, UnitPower p ); static inline double toPhysical ( double u, UnitPower p ); + static inline double toMicrons ( Unit u ); + static inline double toNanos ( Unit u ); // Old naming scheme (not very clear). static inline Unit getDb ( Unit u ); static inline double getGrid ( Unit u ); @@ -161,6 +162,8 @@ namespace Hurricane { inline DbU::Unit DbU::fromGrid ( double value ) { checkGridBound (value); return (Unit)rint( value/_resolution ); } inline DbU::Unit DbU::fromLambda ( double value ) { checkLambdaBound (value); return fromGrid(value*_gridsPerLambda); } inline DbU::Unit DbU::fromPhysical ( double value, UnitPower p ) { checkPhysicalBound(value,p); return fromGrid((value*getUnitPower(p))/_physicalsPerGrid); } + inline DbU::Unit DbU::fromMicrons ( double value ) { return fromPhysical(value,UnitPower::Micro); } + inline DbU::Unit DbU::fromNanos ( double value ) { return fromPhysical(value,UnitPower::Nano); } inline DbU::Unit DbU::toDb ( DbU::Unit u ) { return u; } inline double DbU::toGrid ( DbU::Unit u ) { return _resolution*(double)u; } inline double DbU::toGrid ( double u ) { return _resolution*u; } @@ -168,6 +171,8 @@ namespace Hurricane { inline double DbU::toLambda ( double u ) { return toGrid(u)/_gridsPerLambda; } inline double DbU::toPhysical ( DbU::Unit u, UnitPower p ) { return (_physicalsPerGrid*_resolution*(double)u)/getUnitPower(p); } inline double DbU::toPhysical ( double u, UnitPower p ) { return (_physicalsPerGrid*_resolution*u)/getUnitPower(p); } + inline double DbU::toMicrons ( Unit u ) { return toPhysical(u,UnitPower::Micro); } + inline double DbU::toNanos ( Unit u ) { return toPhysical(u,UnitPower::Nano); } inline DbU::Unit DbU::getPolygonStep () { return _polygonStep; } // Old converter naming scheme. @@ -255,6 +260,3 @@ inline Hurricane::Record* getRecord ( const std::vector* v } return record; } - - -#endif // HURRICANE_DBU_H