MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLCSO/CSOTools/CSOMath.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00006 
00011 //----------------------------------------------------------------------------------
00012 
00013 #ifndef __CSOMath_H
00014 #define __CSOMath_H
00015 
00016 #include "MLCSOIncludes.h"
00017 #include "CSOBase/CSO.h"
00018 #include "CSOTools/CSOHeapObject.h"
00019 #include "CSOTools/CSOObjectHeap.h"
00020 #include "CSOTools/CSOGeometry.h"
00021 
00022 #include <mlRotation.h>
00023 
00024 ML_START_NAMESPACE
00025 
00027 
00031 namespace CSOMath 
00032 {
00033 
00034   const double smallNumber = 10e-10;
00035 
00037   MLCSO_EXPORT double computeArea(const std::vector<Vector3>& points, const Vector3& normal);
00048   MLCSO_EXPORT void computeAreaAndCenterOfGravity(const std::vector<Vector3>& points, const Vector3& normal, const Vector3& centerPoint, double& area, Vector3& centerOfGravity);
00049   
00051   MLCSO_EXPORT Vector3 mapWorldToVoxel(const Vector3& worldPos, const CSO* cso);
00053   MLCSO_EXPORT void mapWorldToVoxel(const Vector3& worldPos, Vector3& voxelPos, const CSO* cso);
00054 
00057   MLCSO_EXPORT inline int floorToInt(const double x) {
00058 #if defined(WIN32) && !defined(_WIN64)
00059     const double floored_x = floor(x);
00060     int n;
00061     __asm fld qword ptr floored_x;
00062     __asm fistp dword ptr n;
00063     return n;
00064 #else
00065     return static_cast<int>(floor(x));    
00066 #endif
00067   }
00068 
00071   MLCSO_EXPORT inline int ceilToInt(const double x) {
00072 #if defined(WIN32) && !defined(_WIN64)
00073     const double ceiled_x = ceil(x);
00074     int n;
00075     __asm fld qword ptr ceiled_x;
00076     __asm fistp dword ptr n;
00077     return n;
00078 #else
00079     return static_cast<int>(ceil(x));    
00080 #endif
00081   }
00082 
00085   MLCSO_EXPORT double computeDirectionDotProduct(const Vector3& predPos, const Vector3& middlePos, const Vector3& succPos);
00086   
00087 }; // end CSOMath namespace
00088 
00090 
00091 ML_END_NAMESPACE
00092 
00093 
00094 #endif // __CSOMath_H
00095