// ファイル名： Ch05/BoxLocator/BoxLocator.cc 
#include "./BoxLocator.hh" 
 
BoxLocator::BoxLocator() 
{} 
BoxLocator::~BoxLocator() 
{ 
 for(Box_Position* pBoxPos : allBox_Pos){  
    delete pBoxPos; } 
} 
void BoxLocator::placeBox(Box aBox, Point3D boxPos) 
{  
  Box_Position* pBox_Pos = new Box_Position(aBox, boxPos); 
  allBox_Pos.push_back(pBox_Pos); 
} 
vector<Box> BoxLocator::isPointInBoxes(Point3D testPoint) 
{  
  Box aBox; Point3D boxPosition; Point3D testPointLocal; 
  for(Box_Position* pBoxPos : allBox_Pos){ 
    aBox        = pBoxPos->first; 
    boxPosition = pBoxPos->second; 
    for(int i=0; i<testPoint.size(); i++){  
      testPointLocal[i]=testPoint[i]-boxPosition[i]; }   
    if( aBox.isPointIn(testPointLocal) ) { 
      inBoxes.push_back( aBox ); } 
  } 
  return inBoxes; 
}
