`compute bounding box` C++ Examples
7 C++ code examples are found related to "compute bounding box".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: cubemodel.cpp From gelectron with MIT License | 6 votes |
bool ComputeBoundingBox(ID3DXMesh* mesh, D3DUtils::BoundingBox* box) { HRESULT hr = 0; BYTE* v = 0; mesh->LockVertexBuffer(0, (void**)&v); hr = D3DXComputeBoundingBox( (D3DXVECTOR3*)v, mesh->GetNumVertices(), D3DXGetFVFVertexSize(mesh->GetFVF()), &box->_min, &box->_max); mesh->UnlockVertexBuffer(); if (FAILED(hr)) return false; return true; }
Example 2
Source File: Submesh.cpp From RaZ with MIT License | 6 votes |
const AABB& Submesh::computeBoundingBox() { Vec3f maxPos(std::numeric_limits<float>::lowest()); Vec3f minPos(std::numeric_limits<float>::max()); for (const Vertex& vert : m_vbo.getVertices()) { maxPos[0] = std::max(maxPos[0], vert.position[0]); maxPos[1] = std::max(maxPos[1], vert.position[1]); maxPos[2] = std::max(maxPos[2], vert.position[2]); minPos[0] = std::min(minPos[0], vert.position[0]); minPos[1] = std::min(minPos[1], vert.position[1]); minPos[2] = std::min(minPos[2], vert.position[2]); } m_boundingBox = AABB(minPos, maxPos); return m_boundingBox; }
Example 3
Source File: MeshShape.cpp From RaZ with MIT License | 6 votes |
const AABB& Mesh::computeBoundingBox() { Vec3f maxPos(std::numeric_limits<float>::lowest()); Vec3f minPos(std::numeric_limits<float>::max()); for (Submesh& submesh : m_submeshes) { const AABB& boundingBox = submesh.computeBoundingBox(); maxPos[0] = std::max(maxPos[0], boundingBox.getRightTopFrontPos()[0]); maxPos[1] = std::max(maxPos[1], boundingBox.getRightTopFrontPos()[1]); maxPos[2] = std::max(maxPos[2], boundingBox.getRightTopFrontPos()[2]); minPos[0] = std::min(minPos[0], boundingBox.getLeftBottomBackPos()[0]); minPos[1] = std::min(minPos[1], boundingBox.getLeftBottomBackPos()[1]); minPos[2] = std::min(minPos[2], boundingBox.getLeftBottomBackPos()[2]); } m_boundingBox = AABB(minPos, maxPos); return m_boundingBox; }
Example 4
Source File: SDFFunctions.cpp From SPlisHSPlasH with MIT License | 5 votes |
AlignedBox3r SDFFunctions::computeBoundingBox(const unsigned int numVertices, const Vector3r *vertices) { AlignedBox3r box; // compute bounding box box.min() = vertices[0]; box.max() = box.min(); box.setEmpty(); for (unsigned int i = 1; i < numVertices; ++i) { const Vector3r& p = vertices[i]; box.extend(p); } return box; }
Example 5
Source File: Object3D.cpp From three.cpp with MIT License | 5 votes |
Box3 Object3D::computeBoundingBox() { Box3 box; updateMatrixWorld( true ); traverse([&box] (Object3D &node) { auto geom = node.geometry(); if (geom) { if (LinearGeometry *geometry = geom->typer) { for (Vector3 vertex : geometry->vertices()) { vertex.apply(node.matrixWorld()); box.expandByPoint( vertex ); } } else if (BufferGeometry *geometry = geom->typer) { auto position = geometry->position(); if ( position ) { for (unsigned i = 0, l = position->itemCount(); i < l; i ++ ) { Vector3 vertex = position->item_at<Vector3>(i); vertex.apply(node.matrixWorld()); box.expandByPoint(vertex); } } } } }); return box; }
Example 6
Source File: FinalizeGrid.cpp From UrbanReconstruction with MIT License | 5 votes |
void CFinalizeGrid::ComputeBoundingBox() { fprintf_s( stderr, "==================== Pass 1, compute bounding box ====================\n" ); CParamManager * manager = CParamManager::GetParamManager(); m_nCellDepth = manager->m_nCellDepth; m_dbGridLength = manager->m_dbGridLength; m_cBoundingBox.Reset(); for ( int i = 0; i < ( int )manager->m_vecInputFiles.size(); i++ ) { fprintf_s( stderr, "Reading header of %s ... ", manager->m_vecInputFiles[ i ].name ); LASFile file( std::string( manager->m_vecInputFiles[ i ].name ) ); const LASHeader & header = file.GetHeader(); double dbTemp[3]; dbTemp[0] = header.GetMinX() * manager->m_dbScale; dbTemp[1] = header.GetMinY() * manager->m_dbScale; dbTemp[2] = header.GetMinZ() * manager->m_dbScale; m_cBoundingBox.Push( dbTemp ); dbTemp[0] = header.GetMaxX() * manager->m_dbScale; dbTemp[1] = header.GetMaxY() * manager->m_dbScale; dbTemp[2] = header.GetMaxZ() * manager->m_dbScale; m_cBoundingBox.Push( dbTemp ); fprintf_s( stderr, "succeed!\n" ); } m_cBoundingBox.PrintInfo(); ComputeGridLength(); fprintf_s( stderr, "\n" ); }
Example 7
Source File: image_proc.cpp From OpenTracker with GNU General Public License v3.0 | 4 votes |
void ComputeCropPadImageLocation(const BoundingBox& bbox_tight, const cv::Mat& image, BoundingBox* pad_image_location) { // Get the bounding box center. const double bbox_center_x = bbox_tight.get_center_x(); const double bbox_center_y = bbox_tight.get_center_y(); // Get the image size. const double image_width = image.cols; const double image_height = image.rows; // Get size of output image, which is given by the bounding box + some padding. const double output_width = bbox_tight.compute_output_width(); const double output_height = bbox_tight.compute_output_height(); // The output image is centered on the bounding box center but has a size given by (output_width, output_height) // to account for additional padding. // The output image location is also limited by the edge of the image. // Get the output image corner. const double roi_left = std::max(0.0, bbox_center_x - output_width / 2); const double roi_bottom = std::max(0.0, bbox_center_y - output_height / 2); // Compute the output image size, limiting the output to within the borders of the original image. // The left half of the output has a width of output_width / 2, unless it is bounded by the left image border, // in which case it has a width of bbox_center_x. const double left_half = std::min(output_width / 2, bbox_center_x); // The right half of the output has a width of output_width / 2, unless it is bounded by the right image border, // in which case it has a width of (image_width - bbox_center_x). const double right_half = std::min(output_width / 2, image_width - bbox_center_x); // The total width of the output is the sum of the widths of the two halves, but cannot be smaller than 1 pixel. const double roi_width = std::max(1.0, left_half + right_half); // The top half of the output has a height of output_height / 2, unless it is bounded by the top image border. const double top_half = std::min(output_height / 2, bbox_center_y); // The bottom half of the output has a height of output_height / 2, unless it is bounded by the bottom image border. const double bottom_half = std::min(output_height / 2, image_height - bbox_center_y); // The total height of the output is the sum of the heights of the two halves, but cannot be smaller than 1 pixel. const double roi_height = std::max(1.0, top_half + bottom_half); // Set the output image coordinates. pad_image_location->x1_ = roi_left; pad_image_location->y1_ = roi_bottom; pad_image_location->x2_ = roi_left + roi_width; pad_image_location->y2_ = roi_bottom + roi_height; }