$search
00001 /* 00002 * Copyright (C) 2008 00003 * Robert Bosch LLC 00004 * Research and Technology Center North America 00005 * Palo Alto, California 00006 * 00007 * All rights reserved. 00008 * 00009 *------------------------------------------------------------------------------ 00010 * project ....: PUMA: Probablistic Unsupervised Model Acquisition 00011 * file .......: BoundingBox.cpp 00012 * authors ....: Benjamin Pitzer 00013 * organization: Robert Bosch LLC 00014 * creation ...: 08/03/2006 00015 * modified ...: $Date:2008-06-02 19:31:25 -0700 (Mon, 02 Jun 2008) $ 00016 * changed by .: $Author:benjaminpitzer $ 00017 * revision ...: $Revision:298 $ 00018 */ 00019 #ifdef _MSC_VER 00020 # pragma warning(disable: 4244 4267 4311 4305) 00021 #endif 00022 00023 //== INCLUDES ================================================================== 00024 #include "BoundingBox.h" 00025 00026 //== NAMESPACES ================================================================ 00027 namespace rtc { 00028 00029 //== IMPLEMENTATION ============================================================ 00030 bool BoundingBox::apply(const TriMesh& mesh, Point& bbMin, Point& bbMax) 00031 { 00032 TriMesh::ConstVertexIter vIt(mesh.vertices_begin()); 00033 TriMesh::ConstVertexIter vEnd(mesh.vertices_end()); 00034 00035 bbMin = bbMax = mesh.point(vIt); 00036 00037 for (;vIt!=vEnd; ++vIt) 00038 { 00039 bbMin.minimize(mesh.point(vIt)); 00040 bbMax.maximize(mesh.point(vIt)); 00041 } 00042 return true; 00043 } 00044 00045 bool BoundingBox::apply(const std::vector<TriMesh*> meshes, Point& bbMin, Point& bbMax) 00046 { 00047 std::vector<TriMesh*>::const_iterator it, it_end; 00048 for(it=meshes.begin(), it_end=meshes.end(); it!=it_end; ++it) 00049 { 00050 Point bbMin_tmp, bbMax_tmp; 00051 const TriMesh* mesh = *it; 00052 apply(*mesh,bbMin_tmp,bbMax_tmp); 00053 if(it!=meshes.begin()) 00054 { 00055 bbMin.minimize(bbMin_tmp); 00056 bbMax.maximize(bbMax_tmp); 00057 } 00058 else 00059 { 00060 bbMin=bbMin_tmp; 00061 bbMax=bbMax_tmp; 00062 } 00063 } 00064 return true; 00065 } 00066 00067 //============================================================================= 00068 } // namespace Merging 00069 //=============================================================================