Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

ShapeAnalysis.cpp

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00018 
00021 #include <ImLib3D/ShapeAnalysis.hpp>
00022 #include <ImLib3D/Draw.hpp>
00023 #include <ImLib3D/Display.hpp>
00024 #include <ImLib3D/TestPatterns.hpp>
00025 
00026 
00027 void
00028 IP3D::BoundingBox(const Mask3D& mask, RectZone3Di &bbox)
00029 {
00030     //      RectZone3Di box(_Base::Height(), _Base::Width(), _Base::Depth(), 0, 0, 0);
00031     bbox.SetP0(Vect3Di(mask.Height(), mask.Width(), mask.Depth()));
00032     bbox.SetP1(Vect3Di(0, 0, 0));
00033     Mask3D::const_iteratorXYZ p;
00034     bool noValues = true;
00035     for (p=mask.begin(); p!=mask.end(); p++)
00036     {
00037         if ((*p)>0)
00038         {
00039             if (p.x < bbox.x0)
00040             bbox.x0 = p.x;
00041             if (p.y < bbox.y0)
00042             bbox.y0 = p.y;
00043             if (p.z < bbox.z0)
00044             bbox.z0 = p.z;
00045             noValues = false;
00046         }
00047     }
00048     int n = mask.GetNVoxels();
00049     p=mask.begin(); p+=n-1;//No p=end() assignment possible at the moment
00050     for (; p!=mask.begin(); p--)
00051     {
00052         if ((*p)>0)
00053         {
00054             if (p.x > bbox.x1)
00055             bbox.x1 = p.x;
00056             if (p.y > bbox.y1)
00057             bbox.y1 = p.y;
00058             if (p.z > bbox.z1)
00059             bbox.z1 = p.z;
00060             noValues = false;
00061         }
00062     }
00063     if (noValues)
00064     {
00065         bbox.x0 = 0; bbox.y0 = 0; bbox.z0 = 0;
00066     }
00067 }

Generated on Fri Jun 17 13:36:06 2005 for ImLib3D by  doxygen 1.4.2