void FloodFillState::addPoint( unsigned int const x, unsigned int const y, RawPixel const & pix ) { if ( x < bBox().topLeft().x() ) { bBox().topLeft().setX( x ); } if ( y < bBox().topLeft().y() ) { bBox().topLeft().setY( y ); } if ( x > bBox().bottomRight().x() ) { bBox().bottomRight().setX( x ); } if ( y > bBox().bottomRight().y() ) { bBox().bottomRight().setY( y ); } _avgRed = _avgRed + pix.red; _avgGreen = _avgGreen + pix.green; _avgBlue = _avgBlue + pix.blue; _size = _size + 1; _sumX = _sumX + x; _sumY = _sumY + y; }
void FloodFillState::initialize( void ) { _sumX = 0; _sumY = 0; _size = 0; _avgRed = 0; _avgGreen = 0; _avgBlue = 0; bBox().topLeft() = Point(65536, 65536); bBox().bottomRight() = Point(0,0); }
int getMemoryRequirement( const TRectD &rect, double frame, const TRenderSettings &info) { TRectD bBox(rect); this->get_render_enlarge(frame, info.m_affine, bBox); return TRasterFx::memorySize(bBox, info.m_bpp); }
float ScanLocator::oobbOverlap(const OBBf &a, const OBBf &b) { //float radius = (b.getCenter() - a.getCenter()).length(); //return (a.getExtent().length() + b.getExtent().length() - radius); bbox3f aBox(a), bBox(b); if (aBox.intersects(bBox)) return 1.0f; return -1.0f; }
void libcdr::CDRContentCollector::collectBBox(double x0, double y0, double x1, double y1) { CDRBox bBox(x0, y0, x1, y1); if (m_currentVectLevel && m_page.width == 0.0 && m_page.height == 0.0) { m_page.width = bBox.getWidth(); m_page.height = bBox.getHeight(); m_page.offsetX = bBox.getMinX(); m_page.offsetY = bBox.getMinY(); } m_currentBBox = bBox; }
QImage Camera::printScreen(Terrain &t,const Vector2D& a, const Vector2D& b, const Vector3D& s, int l, int h) { QImage im(l,h,QImage::Format_ARGB32); double min=t.getHauteurMin(a,b); double max=t.getHauteurMax(a,b); Vector3D aBox(a.x(),min,a.y()); Vector3D bBox(b.x(),max*1.5,b.y()); for(int i=0; i<l; ++i) { for(int j=0; j<h; ++j) { im.setPixel(i,h-1-j,ptScreen(t,aBox,bBox,s,i,j,l,h)); } } return im; }
MBoundingBox curveColliderLocator::boundingBox() const { // Start with the bounding box of the curve, then expand it by the largest radius value MObject thisNode = thisMObject(); MPlug curvePlug(thisNode, colliderCurveIn); MPlugArray inputCrvArray; curvePlug.connectedTo(inputCrvArray, true, false); // if inputCrvArray is empty, no curves are connected, so return an empty bounding box if(inputCrvArray.length() == 0){ MBoundingBox emptyBBox; return emptyBBox; } MObject crvColliderObj = inputCrvArray[0].node(); MFnDagNode crvDagNode(crvColliderObj); // find the largest radius value MPlug radiusPlug(thisNode, colliderRadiusIn); MPlug radiusElement; float maxRadius = 0; float currentRadius; for(int radiusItr = 0; radiusItr < radiusPlug.numElements(); radiusItr++){ radiusElement = radiusPlug.elementByPhysicalIndex(radiusItr); radiusElement.getValue(currentRadius); if (currentRadius > maxRadius){maxRadius = currentRadius;} } MPoint bBoxMin = crvDagNode.boundingBox().min(); MPoint bBoxMax = crvDagNode.boundingBox().max(); // expand the min and max points by the radius bBoxMin.x = bBoxMin.x - maxRadius; bBoxMin.y = bBoxMin.y - maxRadius; bBoxMin.z = bBoxMin.z - maxRadius; bBoxMax.x = bBoxMax.x + maxRadius; bBoxMax.y = bBoxMax.y + maxRadius; bBoxMax.z = bBoxMax.z + maxRadius; MBoundingBox bBox(bBoxMin, bBoxMax); return bBox; }
void reGroup::load( std::istream& is, reMaterialSet& materials ) { int matID; reBBox abBox; is.read((char*)&matID, sizeof(matID)); material = materials.materialById(matID); isTransparent = material && material->isTransparent; unsigned int count; is.read((char*)&count, sizeof(count)); for (unsigned int i=0; i<count; i++) { reFace face; face.load(is); faces.push_back(face); for (unsigned int i=0; i<3; i++) { abBox.addPoint(face.vertices[i].pos); } } bufferChanged = true; bBox(abBox); }
BBOX MESHINSTANCE::GetBoundingBox() { if(m_pMesh == NULL || m_pMesh->m_pMesh == NULL)return BBOX(); if(m_pMesh->m_pMesh->GetFVF() != ObjectVertex::FVF) // XYZ and NORMAL and UV return BBOX(); BBOX bBox(D3DXVECTOR3(-10000.0f, -10000.0f, -10000.0f), D3DXVECTOR3(10000.0f, 10000.0f, 10000.0f)); D3DXMATRIX World = GetWorldMatrix(); //Lock vertex buffer of the object ObjectVertex* vertexBuffer = NULL; m_pMesh->m_pMesh->LockVertexBuffer(0,(void**)&vertexBuffer); //For each vertex in the mesh for(int i=0;i<(int)m_pMesh->m_pMesh->GetNumVertices();i++) { //Transform vertex to world space using the MESHINSTANCE //world matrix, i.e. the position, rotation and scale D3DXVECTOR3 pos; D3DXVec3TransformCoord(&pos, &vertexBuffer[i]._pos, &World); // Check if the vertex is outside the bounds // if so, then update the bounding volume if(pos.x < bBox.min.x)bBox.min.x = pos.x; if(pos.x > bBox.max.x)bBox.max.x = pos.x; if(pos.y < bBox.min.y)bBox.min.y = pos.y; if(pos.y > bBox.max.y)bBox.max.y = pos.y; if(pos.z < bBox.min.z)bBox.min.z = pos.z; if(pos.z > bBox.max.z)bBox.max.z = pos.z; } m_pMesh->m_pMesh->UnlockVertexBuffer(); return bBox; }
void SoColorShape::compute() { enableNotify(false); // alles schoen auf nichts zurücksetzen if (_vertexPropArray) { delete[] _vertexPropArray; _vertexPropArray = 0; } if (_sizeCoordinate3) { delete[] _sizeCoordinate3; _sizeCoordinate3 = 0; } if (_vertexSet) { for (int index = 0; index < (_extentX * _extentY * _extentZ); index++) _vertexSet[index].clear(); delete[] _vertexSet; _vertexSet = 0; } if (_triangleSet) { for (int index = 0; index < (_extentX * _extentY * _extentZ); index++) _triangleSet[index].clear(); delete[] _triangleSet; _triangleSet = 0; } if (_edgeSet) { for (int index = 0; index < (_extentX * _extentY * _extentZ); index++) _edgeSet[index].clear(); delete[] _edgeSet; _edgeSet = 0; } removeAllChildren(); if (input.getValue() != 0) { // Bounding Box bestimmen SoComputeBoundingBox* bbact = new SoComputeBoundingBox; SoTranslation *min = new SoTranslation, *max = new SoTranslation; min->ref(); max->ref(); bbact->ref(); bbact->node = input.getValue(); min->translation.connectFrom(&bbact->min); max->translation.connectFrom(&bbact->max); SbBox3f bBox(min->translation.getValue(), max->translation.getValue()); min->unref(), max->unref(); bbact->unref(); // Eingang hat sich geändert if (!bBox.isEmpty()) { // Array fuer _edgeSet und _triangleSet set-Instanzen initialisieren float xSize, ySize, zSize; bBox.getSize(xSize, ySize, zSize); _offSet = bBox.getMin(); _extentX = xSize / (float) HASH_PARTITION + 1; _extentY = ySize / (float) HASH_PARTITION + 1; _extentZ = zSize / (float) HASH_PARTITION + 1; _vertexSet = new std::set<Vertex*, ltVertex>[_extentX * _extentY * _extentZ]; _edgeSet = new std::set<Edge*, ltEdge >[_extentX * _extentY * _extentZ]; _triangleSet = new std::set<Triangle* >[_extentX * _extentY * _extentZ]; _vertexPropArray = new SoVertexProperty*[_extentX * _extentY * _extentZ]; int index = 0; for (index = 0; index < (_extentX * _extentY * _extentZ); index++) _vertexPropArray[index] = 0; _sizeCoordinate3 = new int[_extentX * _extentY * _extentZ]; for (index = 0; index < (_extentX * _extentY * _extentZ); index++) _sizeCoordinate3[index] = -1; // Dreiecke aufsammeln _myAction->apply(input.getValue()); // SoIndexedTriangleStripSet erstellen generateITSS(); } } enableNotify(true); touch(); }
void reMeshRenderable::mesh( reMesh* val ) { _mesh = val; boneLinks = _mesh->boneLinks; bBox(val->bBox()); }
multiBBox::multiBBox( jLib::graphics::entity::entityG *p, unsigned int xMax, unsigned int yMax, unsigned int zMax ) : pointArray( p ), _xMax( xMax ), _yMax( yMax ), _zMax( zMax ) { JFLOAT eSprConstant = 300; JFLOAT dSprConstant = 100; JFLOAT vSprConstant = 100; for( unsigned int z=0; z<=zMax; z++ ) { for( unsigned int y=0; y<=yMax; y++ ) { for( unsigned int x=0; x<=xMax; x++ ) { _particles.push_back( cal::particle( 1, sseTriple( x, y, z ) ) ); } } } for( unsigned int z=0; z<=zMax; z++ ) { for( unsigned int y=0; y<=yMax; y++ ) { for( unsigned int x=0; x<=xMax; x++ ) { if( x < xMax ) { _springs.push_back( doubleSpring( ) ); _springs.back().primary = &(particleAt( x, y, z )); _springs.back().secondary = &(particleAt( x+1, y, z )); _springs.back().restLength = 1; _springs.back().constant = eSprConstant; } if( y < yMax ) { _springs.push_back( doubleSpring( ) ); _springs.back().primary = &(particleAt( x, y, z )); _springs.back().secondary = &(particleAt( x, y+1, z )); _springs.back().restLength = 1; _springs.back().constant = eSprConstant; } if( z < zMax ) { _springs.push_back( doubleSpring( ) ); _springs.back().primary = &(particleAt( x, y, z )); _springs.back().secondary = &(particleAt( x, y, z+1 )); _springs.back().restLength = 1; _springs.back().constant = eSprConstant; } if( x < xMax && y < yMax ) { _springs.push_back( doubleSpring( ) ); _springs.back().primary = &(particleAt( x, y, z )); _springs.back().secondary = &(particleAt( x+1, y+1, z )); _springs.back().restLength = sqrt( 2 ); _springs.back().constant = dSprConstant; } if( x < xMax && z < zMax ) { _springs.push_back( doubleSpring( ) ); _springs.back().primary = &(particleAt( x, y, z )); _springs.back().secondary = &(particleAt( x+1, y, z+1 )); _springs.back().restLength = sqrt( 2 ); _springs.back().constant = dSprConstant; } if( y < yMax && z < zMax ) { _springs.push_back( doubleSpring( ) ); _springs.back().primary = &(particleAt( x, y, z )); _springs.back().secondary = &(particleAt( x, y+1, z+1 )); _springs.back().restLength = sqrt( 2 ); _springs.back().constant = dSprConstant; } if( x < xMax && y < yMax && z < zMax ) { _springs.push_back( doubleSpring( ) ); _springs.back().primary = &(particleAt( x, y, z )); _springs.back().secondary = &(particleAt( x+1, y+1, z+1 )); _springs.back().restLength = sqrt( 3 ); _springs.back().constant = vSprConstant; _springs.push_back( doubleSpring( ) ); _springs.back().primary = &(particleAt( x, y+1, z )); _springs.back().secondary = &(particleAt( x+1, y, z+1 )); _springs.back().restLength = sqrt( 3 ); _springs.back().constant = vSprConstant; _springs.push_back( doubleSpring( ) ); _springs.back().primary = &(particleAt( x+1, y, z )); _springs.back().secondary = &(particleAt( x, y+1, z+1 )); _springs.back().restLength = sqrt( 3 ); _springs.back().constant = vSprConstant; _springs.push_back( doubleSpring( ) ); _springs.back().primary = &(particleAt( x+1, y+1, z )); _springs.back().secondary = &(particleAt( x, y, z+1 )); _springs.back().restLength = sqrt( 3 ); _springs.back().constant = vSprConstant; } } } } for( unsigned int z=0; z<zMax; z++ ) { for( unsigned int y=0; y<yMax; y++ ) { for( unsigned int x=0; x<xMax; x++ ) { _boxes.push_back( bBox( particleAt( x, y, z ), particleAt( x+1, y, z ), particleAt( x+1, y, z+1 ), particleAt( x, y, z+1 ), particleAt( x, y+1, z ), particleAt( x+1, y+1, z ), particleAt( x+1, y+1, z+1 ), particleAt( x, y+1, z+1 ) ) ); } } } }