// Created on: 2013-12-20 // Created by: Denis BOGOLEPOV // Copyright (c) 2013-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include // ======================================================================= // function : Clear // purpose : // ======================================================================= template void BVH_Box::Clear() { myIsInited = Standard_False; } // ======================================================================= // function : Clear // purpose : // ======================================================================= template Standard_Boolean BVH_Box::IsValid() const { return myIsInited; } // ======================================================================= // function : Add // purpose : // ======================================================================= template void BVH_Box::Add (const BVH_VecNt& thePoint) { if (!myIsInited) { myMinPoint = thePoint; myMaxPoint = thePoint; myIsInited = Standard_True; } else { myMinPoint = myMinPoint.cwiseMin (thePoint); myMaxPoint = myMaxPoint.cwiseMax (thePoint); } } // ======================================================================= // function : Combine // purpose : // ======================================================================= template void BVH_Box::Combine (const BVH_Box& theBox) { if (theBox.myIsInited) { if (!myIsInited) { myMinPoint = theBox.myMinPoint; myMaxPoint = theBox.myMaxPoint; myIsInited = Standard_True; } else { BVH::BoxMinMax::CwiseMin (myMinPoint, theBox.myMinPoint); BVH::BoxMinMax::CwiseMax (myMaxPoint, theBox.myMaxPoint); } } } // ======================================================================= // function : Area // purpose : // ======================================================================= template T BVH_Box::Area() const { return !myIsInited ? static_cast (0.0) : BVH::SurfaceCalculator::Area (myMaxPoint - myMinPoint); } // ======================================================================= // function : CornerMin // purpose : // ======================================================================= template const typename BVH_Box::BVH_VecNt& BVH_Box::CornerMin() const { return myMinPoint; } // ======================================================================= // function : CornerMax // purpose : // ======================================================================= template const typename BVH_Box::BVH_VecNt& BVH_Box::CornerMax() const { return myMaxPoint; } // ======================================================================= // function : CornerMin // purpose : // ======================================================================= template typename BVH_Box::BVH_VecNt& BVH_Box::CornerMin() { return myMinPoint; } // ======================================================================= // function : CornerMax // purpose : // ======================================================================= template typename BVH_Box::BVH_VecNt& BVH_Box::CornerMax() { return myMaxPoint; } // ======================================================================= // function : Size // purpose : // ======================================================================= template typename BVH_Box::BVH_VecNt BVH_Box::Size() const { return myMaxPoint - myMinPoint; } // ======================================================================= // function : Center // purpose : // ======================================================================= template typename BVH_Box::BVH_VecNt BVH_Box::Center() const { return (myMinPoint + myMaxPoint) * static_cast (0.5); } // ======================================================================= // function : Center // purpose : // ======================================================================= template T BVH_Box::Center (const Standard_Integer theAxis) const { return BVH::CenterAxis::Center (*this, theAxis); }