MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLTools/include/mlDisc.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //----------------------------------------------------------------------------------
00004 
00009 //----------------------------------------------------------------------------------
00010 #ifndef __mlDisc_H
00011 #define __mlDisc_H
00012 
00013 #ifndef __MLToolsSystem_H
00014 #include "MLToolsSystem.h"
00015 #endif
00016 #ifndef __mlModuleIncludes_H
00017 #include "mlModuleIncludes.h"
00018 #endif
00019 #ifndef __mlPlane_H
00020 #include "mlPlane.h"
00021 #endif
00022 #ifndef __mlTVirtualVolume_H
00023 #include "mlTVirtualVolume.h"
00024 #endif
00025 
00026 ML_START_NAMESPACE
00027 
00029   class Line;
00030 
00031   //----------------------------------------------------------------------------------
00034   //----------------------------------------------------------------------------------
00035   class MLTOOLS_EXPORT Disc
00036   {
00037   public:
00039     Disc();
00040 
00042     Disc(const Vector3 &c, const Vector3 &n, double r);
00043 
00045     inline void setValue(const Vector3 &c, const Vector3 &n, double r) 
00046     { _center = c; _radius = r; setNormal(n); }
00047 
00049     inline void setCenter(const Vector3 &c)  { _center = c; }
00050 
00053     bool setNormal(const Vector3 &n);
00054 
00056     inline void setRadius(double r)       { _radius = r; }
00057 
00059     inline const Vector3 &getCenter() const  { return _center; }
00060 
00062     inline const Vector3 &getNormal() const  { return _normal; }
00063 
00065     inline double getRadius() const       { return _radius; }
00066 
00068     inline bool project(const Vector3 &p, Vector3 &proj) const
00069     { proj = getPlane().getClosestPoint(p); return (proj - _center).length() <= _radius; }
00070 
00072     inline bool intersect(const Line &l, Vector3 &cut) const
00073     { return getPlane().intersect(l, cut); }
00074     
00076     inline Plane getPlane() const
00077     { return Plane(_normal, _center); }
00078 
00081     void getBoundingBox(const Matrix4 &transform, Vector3 &boxMin, Vector3 &boxMax) const;
00082 
00086     SubImageBox getBoundingBox(const MedicalImageProperties &pImg) const;
00087 
00091     void fill(const MedicalImageProperties &pImg, SubImage        &destImg, double fillVal) const;
00092 
00096     void fill(const MedicalImageProperties &pImg, VirtualVolume &destImg, double fillVal) const;
00097 
00098   private:
00099 
00101     Vector3 _center;
00102   
00104     Vector3 _normal;
00105 
00107     double _radius; 
00108   };
00109 
00110 ML_END_NAMESPACE
00111 
00112 #endif // __mlDisc_H
00113