本文整理汇总了C++中Bounds类的典型用法代码示例。如果您正苦于以下问题:C++ Bounds类的具体用法?C++ Bounds怎么用?C++ Bounds使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bounds类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AABox
bool EditorUtility::calculateMeshBounds(const HSceneObject& object, AABox& bounds)
{
bounds = AABox(Vector3::ZERO, Vector3::ZERO);
if (object.isDestroyed())
return false;
bool foundOne = false;
const Vector<HComponent>& components = object->getComponents();
for (auto& component : components)
{
Bounds curBounds;
if (component->calculateBounds(curBounds))
{
if (!foundOne)
{
bounds = curBounds.getBox();
foundOne = true;
}
else
bounds.merge(curBounds.getBox());
}
else
{
if (!foundOne)
bounds = curBounds.getBox();
}
}
return foundOne;
}
示例2: calculateCovarianceSymMatrix
tmv::SymMatrix<double, tmv::FortranStyle|tmv::Upper> calculateCovarianceSymMatrix(
const SBProfile& sbp, const Bounds<int>& bounds, double dx)
{
// Calculate the required dimensions
int idim = 1 + bounds.getXMax() - bounds.getXMin();
int jdim = 1 + bounds.getYMax() - bounds.getYMin();
int covdim = idim * jdim;
int k, ell; // k and l are indices that refer to image pixel separation vectors in the
// correlation func.
double x_k, y_ell; // physical vector separations in the correlation func, dx * k etc.
tmv::SymMatrix<double, tmv::FortranStyle|tmv::Upper> cov = tmv::SymMatrix<
double, tmv::FortranStyle|tmv::Upper>(covdim);
for (int i=1; i<=covdim; i++){ // note that the Image indices use the FITS convention and
// start from 1!!
for (int j=i; j<=covdim; j++){
k = ((j - 1) / jdim) - ((i - 1) / idim); // using integer division rules here
ell = ((j - 1) % jdim) - ((i - 1) % idim);
x_k = double(k) * dx;
y_ell = double(ell) * dx;
Position<double> p = Position<double>(x_k, y_ell);
cov(i, j) = sbp.xValue(p); // fill in the upper triangle with the correct value
}
}
return cov;
}
示例3: RayBounds
bool Intersect::RayBounds (const Vector3f& origin, const Vector3f& dir, const Bounds& bounds)
{
const Vector3f& max = bounds.GetMax();
const Vector3f& center = bounds.GetCenter();
Vector3f ext (max - center);
Vector3f diff (origin - center);
if (Float::Abs(diff.x) > ext.x && Float::IsProductPositive(diff.x, dir.x)) return false;
if (Float::Abs(diff.y) > ext.y && Float::IsProductPositive(diff.y, dir.y)) return false;
if (Float::Abs(diff.z) > ext.z && Float::IsProductPositive(diff.z, dir.z)) return false;
Vector3f adir (Float::Abs(dir.x), Float::Abs(dir.y), Float::Abs(dir.z));
float a = dir.y * diff.z - dir.z * diff.y;
float b = ext.y * adir.z + ext.z * adir.y;
if (Float::Abs(a) > b) return false;
a = dir.z * diff.x - dir.x * diff.z;
b = ext.x * adir.z + ext.z * adir.x;
if (Float::Abs(a) > b) return false;
a = dir.x * diff.y - dir.y * diff.x;
b = ext.x * adir.y + ext.y * adir.x;
return !(Float::Abs(a) > b);
}
示例4: ss
void Font::render(const vec3& pos, const std::string& text) const {
if (simpleLayout_) {
float delta = 0;
std::string line;
std::stringstream ss(text);
std::getline(ss, line);
FTPoint point(static_cast<double>(pos.x),
static_cast<double>(pos.y),
static_cast<double>(pos.z));
FTBBox box = font_->BBox(line.c_str(), -1, point);
delta -= box.Upper().Yf() - box.Lower().Yf(); // height of first line
Bounds bounds = getBounds(pos, text);
float height = bounds.getURB().y - bounds.getLLF().y;
switch(vAlign_) {
case Font::Top:
delta += height;
break;
case Font::Middle:
delta += height * 0.5f;
break;
case Font::Bottom:
break;
}
vec3 dpos = vec3(pos.x, pos.y + delta, pos.z);
glPushMatrix();
glRasterPos3f(dpos.x, dpos.y, dpos.z);
glTranslatef(dpos.x, dpos.y, dpos.z);
simpleLayout_->Render(text.c_str(), -1, FTPoint(dpos.x, dpos.y, dpos.z));
glPopMatrix();
}
}
示例5: inside
bool Bounds::inside(const Bounds& bounds) const {
tgtAssert( isDefined(), "This Box ist not defined.");
tgtAssert(bounds.isDefined(), "Box b ist not defined.");
vec3 llfb = bounds.getLLF();
vec3 urbb = bounds.getURB();
float r0x = min(llf_[0], urb_[0]);
float r1x = max(llf_[0], urb_[0]);
float r0y = min(llf_[1], urb_[1]);
float r1y = max(llf_[1], urb_[1]);
float r0z = min(llf_[2], urb_[2]);
float r1z = max(llf_[2], urb_[2]);
float r2x = min(llfb[0], urbb[0]);
float r3x = max(llfb[0], urbb[0]);
float r2y = min(llfb[1], urbb[1]);
float r3y = max(llfb[1], urbb[1]);
float r2z = min(llfb[2], urbb[2]);
float r3z = max(llfb[2], urbb[2]);
return (r0x >= r2x) && (r1x <= r3x)
&& (r0y >= r2y) && (r1y <= r3y)
&& (r0z >= r2z) && (r1z <= r3z);
}
示例6: remove
bool
remove(const Bounds& area, const Bounds& b)
{
if (m_leaf)
return area.contains(m_data.item);
int cdel = 0;
for (int i = 0; i < 4; ++i)
{
Node** c = m_data.children + i;
if (!*c)
continue;
Bounds cb = b.quadrant(i);
if (area.intersects(cb) && (*c)->remove(area, cb))
{
delete *c;
* c = 0;
++cdel;
}
}
return cdel == 4; // true if all sub-nodes were removed
}
示例7: scale_iter
FilterContext
ScaleFilter::push( FeatureList& input, FilterContext& cx )
{
for( FeatureList::iterator i = input.begin(); i != input.end(); ++i )
{
Feature* input = i->get();
if ( input && input->getGeometry() )
{
Bounds envelope = input->getGeometry()->getBounds();
// now scale and shift everything
GeometryIterator scale_iter( input->getGeometry() );
while( scale_iter.hasMore() )
{
Geometry* geom = scale_iter.next();
for( osg::Vec3dArray::iterator v = geom->begin(); v != geom->end(); v++ )
{
double xr = (v->x() - envelope.xMin()) / envelope.width();
v->x() += (xr - 0.5) * _scale;
double yr = (v->y() - envelope.yMin()) / envelope.height();
v->y() += (yr - 0.5) * _scale;
}
}
}
}
return cx;
}
示例8:
//=================================================================================
/*virtual*/ Node::ValueStringError BoundedPointListNode::SetValueFromString( const std::string& valueString )
{
VarMap varMap;
if( !ConvertValueStringToVarMap( valueString, varMap ) )
return VSE_SYNTAX;
Bounds trialBounds = bounds;
if( varMap.end() != varMap.find( "xMin" ) )
trialBounds.min.set_e1( varMap[ "xMin" ] );
if( varMap.end() != varMap.find( "xMax" ) )
trialBounds.max.set_e1( varMap[ "xMax" ] );
if( varMap.end() != varMap.find( "yMin" ) )
trialBounds.min.set_e2( varMap[ "yMin" ] );
if( varMap.end() != varMap.find( "yMax" ) )
trialBounds.max.set_e2( varMap[ "yMax" ] );
if( trialBounds == bounds )
return VSE_NO_CHANGE;
if( !trialBounds.IsValid() )
return VSE_INVALID;
if( !SetBounds( trialBounds ) )
return VSE_INVALID;
return VSE_NONE;
}
示例9: focus
void ModelViewer::focus( ) {
float fov = ( 5.0f / 12.0f ) * glm::pi<float>( );
uint meshCount = m_model.numMeshes( );
if ( !meshCount ) {
return;
}
// Calculate complete bounds
Bounds bounds = m_model.bounds( );
float height = bounds.max.z - bounds.min.z;
if ( height <= 0 ) {
return;
}
float distance = bounds.min.y - ( ( height * 0.5f ) / ::tanf( fov * 0.5f ) );
if ( distance < 0 ) {
distance *= -1;
}
// Update camera and render
XMFLOAT3 dxBounds;
glm::vec3 glmBounds = bounds.center( );
dxBounds.x = glmBounds.x;
dxBounds.y = glmBounds.y;
dxBounds.z = glmBounds.z;
m_camera.setPivot( dxBounds );
//m_camera.setPivot( bounds.center( ) );
m_camera.setDistance( distance );
this->render( );
}
示例10: seed
int
seed( osg::ArgumentParser& args )
{
//Read the min level
unsigned int minLevel = 0;
while (args.read("--min-level", minLevel));
//Read the max level
unsigned int maxLevel = 5;
while (args.read("--max-level", maxLevel));
std::vector< Bounds > bounds;
// restrict packaging to user-specified bounds.
double xmin=DBL_MAX, ymin=DBL_MAX, xmax=DBL_MIN, ymax=DBL_MIN;
while (args.read("--bounds", xmin, ymin, xmax, ymax ))
{
Bounds b;
b.xMin() = xmin, b.yMin() = ymin, b.xMax() = xmax, b.yMax() = ymax;
bounds.push_back( b );
}
//Read the cache override directory
std::string cachePath;
while (args.read("--cache-path", cachePath));
//Read the cache type
std::string cacheType;
while (args.read("--cache-type", cacheType));
bool verbose = args.read("--verbose");
//Read in the earth file.
osg::ref_ptr<osg::Node> node = osgDB::readNodeFiles( args );
if ( !node.valid() )
return usage( "Failed to read .earth file." );
MapNode* mapNode = MapNode::findMapNode( node.get() );
if ( !mapNode )
return usage( "Input file was not a .earth file" );
CacheSeed seeder;
seeder.setMinLevel( minLevel );
seeder.setMaxLevel( maxLevel );
for (unsigned int i = 0; i < bounds.size(); i++)
{
GeoExtent extent(mapNode->getMapSRS(), bounds[i]);
OE_DEBUG << "Adding extent " << extent.toString() << std::endl;
seeder.addExtent( extent );
}
if (verbose)
{
seeder.setProgressCallback(new ConsoleProgressCallback);
}
seeder.seed( mapNode->getMap() );
return 0;
}
示例11:
Bounds
Geometry::getBounds() const
{
Bounds bounds;
for( const_iterator i = begin(); i != end(); ++i )
bounds.expandBy( i->x(), i->y(), i->z() );
return bounds;
}
示例12: Flush
// TODO: Support transformed bounds using stencil
void UIContext::PushScissor(const Bounds &bounds) {
Flush();
Bounds clipped = bounds;
if (scissorStack_.size())
clipped.Clip(scissorStack_.back());
scissorStack_.push_back(clipped);
ActivateTopScissor();
}
示例13: internal_GetBounds
void ScriptMesh::internal_GetBounds(ScriptMesh* thisPtr, AABox* box, Sphere* sphere)
{
HMesh mesh = thisPtr->getHandle();
Bounds bounds = mesh->getProperties().getBounds();
*box = bounds.getBox();
*sphere = bounds.getSphere();
}
示例14: isValid
bool
Bounds::contains(const Bounds& rhs) const
{
return
isValid() && rhs.isValid() &&
xMin() <= rhs.xMin() && xMax() >= rhs.xMax() &&
yMin() <= rhs.yMin() && yMax() >= rhs.yMax();
}
示例15: main
int
main(int argc, char** argv)
{
osg::ArgumentParser args(&argc,argv);
// verbosity?
bool verbose = !args.read( "--quiet" );
Bounds bounds;
// restrict user-specified bounds.
double xmin=DBL_MAX, ymin=DBL_MAX, xmax=DBL_MIN, ymax=DBL_MIN;
while (args.read("--bounds", xmin, ymin, xmax, ymax ))
{
bounds.set( xmin, ymin, 0, xmax, ymax, 1 );
}
// min level to backfill to
unsigned minLevel = 0;
args.read( "--min-level", minLevel );
// max level to which to generate
unsigned maxLevel = ~0;
args.read( "--max-level", maxLevel );
std::string dbOptions;
args.read("--db-options", dbOptions);
std::string::size_type n = 0;
while ((n=dbOptions.find('"', n))!=dbOptions.npos)
{
dbOptions.erase(n,1);
}
osg::ref_ptr<osgDB::Options> options = new osgDB::Options(dbOptions);
std::string tmsPath;
//Get the first argument that is not an option
for(int pos=1;pos<args.argc();++pos)
{
if (!args.isOption(pos))
{
tmsPath = args[ pos ];
}
}
if (tmsPath.empty())
{
return usage( "Please provide a path to a TMS TileMap" );
}
TMSBackFiller backfiller;
backfiller.setMinLevel( minLevel );
backfiller.setMaxLevel( maxLevel );
backfiller.setBounds( bounds );
backfiller.process( tmsPath, options.get() );
}