本文整理汇总了C++中setDensity函数的典型用法代码示例。如果您正苦于以下问题:C++ setDensity函数的具体用法?C++ setDensity怎么用?C++ setDensity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setDensity函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(TransferParticlesToPointCloudBehaviorTests, UpdateTest)
{
auto runtime = std::make_shared<Framework::Runtime>();
runtime->addManager(std::make_shared<Framework::BehaviorManager>());
runtime->addManager(std::make_shared<Physics::PhysicsManager>());
auto sceneElement = std::make_shared<Framework::BasicSceneElement>("Element");
auto particles = std::make_shared<Particles::SphRepresentation>("Particles");
particles->setMaxParticles(10);
particles->setMassPerParticle(1.0);
particles->setDensity(1.0);
particles->setGasStiffness(1.0);
particles->setKernelSupport(1.0);
for (size_t particleId = 0; particleId < 10; particleId++)
{
particles->addParticle(Vector3d(static_cast<double>(particleId), 0.0, 0.0), Vector3d::Zero(), 100000);
}
sceneElement->addComponent(particles);
auto pointCloud = std::make_shared<Graphics::OsgPointCloudRepresentation>("Graphics");
sceneElement->addComponent(pointCloud);
auto behavior = std::make_shared<TransferParticlesToPointCloudBehavior>("Behavior");
behavior->setSource(particles);
behavior->setTarget(pointCloud);
sceneElement->addComponent(behavior);
auto scene = runtime->getScene();
scene->addSceneElement(sceneElement);
particles->update(0.1);
behavior->update(0.1);
auto sourceVertices = particles->getParticles().safeGet()->getVertices();
auto targetVertices = pointCloud->getVertices()->getVertices();
ASSERT_EQ(sourceVertices.size(), targetVertices.size());
auto sourceVertex = sourceVertices.begin();
auto targetVertex = targetVertices.begin();
for (; sourceVertex != sourceVertices.end(); ++sourceVertex, ++targetVertex)
{
EXPECT_TRUE(sourceVertex->position.isApprox(targetVertex->position));
}
particles->removeParticle(0);
particles->removeParticle(1);
particles->update(0.1);
behavior->update(0.1);
sourceVertices = particles->getParticles().safeGet()->getVertices();
targetVertices = pointCloud->getVertices()->getVertices();
ASSERT_EQ(sourceVertices.size(), targetVertices.size());
sourceVertex = sourceVertices.begin();
targetVertex = targetVertices.begin();
for (; sourceVertex != sourceVertices.end(); ++sourceVertex, ++targetVertex)
{
EXPECT_TRUE(sourceVertex->position.isApprox(targetVertex->position));
}
}
开发者ID:simquest,项目名称:opensurgsim,代码行数:60,代码来源:TransferParticlesToPointCloudBehaviorTests.cpp
示例2: main
int main(int argc, char *argv[])
{
// Problem setup
Tutorial7 problem; // instantiate an object of class Tutorial 6
problem.setName("Tutorial7");
problem.setSystemDimensions(2);
problem.setGravity(Vec3D(0.0,0.0,0.0));
problem.setXMax(1);
problem.setYMax(0.5);
problem.setTimeMax(5.0);
//! [T7:speciesProp]
// The normal spring stiffness and normal dissipation is computed and set as
// For collision time tc=0.005 and restitution coefficeint rc=1.0,
auto species = problem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
species->setDensity(2500.0); // sets the species type-0 density
species->setStiffness(258.5);// sets the spring stiffness
species->setDissipation(0.0);// sets the dissipation
//! [T7:speciesProp]
problem.setSaveCount(10);
problem.dataFile.setFileType(FileType::ONE_FILE);
problem.restartFile.setFileType(FileType::ONE_FILE);
problem.fStatFile.setFileType(FileType::NO_FILE);
problem.eneFile.setFileType(FileType::NO_FILE);
problem.setXBallsAdditionalArguments("-solidf -v0 -s .85");
problem.setTimeStep(0.005/50.0);// (collision time)/50.0
problem.solve(argc, argv);
return 0;
}
开发者ID:gladk,项目名称:MercuryDPM,代码行数:34,代码来源:Tutorial7.cpp
示例3: cRealBox
void cCritterViewer::resetAndMatchMoveBox(cGame *pgame)
{
_proportionofworldtoshow = cCritterViewer::PROPORTIONOFWORLDTOSHOW;
_aspect = 4.0/3.0;
_fieldofviewangle = cCritterViewer::STARTFIELDOFVIEWANGLE;
_trackplayer = FALSE;
_perspective = FALSE; //Will be reset by setViewpoint,
_foveaproportion = cCritterViewer::FOVEAPROPORTION;
_wrapflag = cCritter::CLAMP; /* I had WRAP, which was a big mistake,
as sometimes I'd back way up above the world and then suddenly be
under it. */
_dragbox = _movebox = cRealBox(pgame->border().center(),
MOVEBOXTOGAMEBORDERRATIO * pgame->border().maxsize()); /* Put the
viewer in a cube (or square in the 2D case) whose edge is a multiple
of the world's largest dimension. */
//We will set _znear and _zfar in the cCritterViewer::setZClipPlanes call.
setViewpoint(); /* Default viewpoint is up the z axis looking down at the origin.
This call also initializes some of the remaining vairables. */
zoom(1.0); //Matches _fieldofviewangle to _proportionofworldtoshow
/* Don't bother to set a listener, as the various cGame::initializeView will do
that indirectly via a setGraphicsClass call, and then possibly with a
direct call to change the listener again. */
setDensity(0.0); //so you don't move things you bump into.
setAbsorberflag(TRUE); //So you don't bounce when you bump things.
psprite()->setRadius(0.1); /* Although this guy is invisible, it seems to be
good to have a radius of 1.0 for use in the COLLIDEVIEWER code. */
}
开发者ID:jstty,项目名称:OlderProjects,代码行数:27,代码来源:critterviewer.cpp
示例4: getDoubleFromQuantity
bool MasslessOpaqueMaterial_Impl::setDensity(const Quantity& density) {
OptionalDouble value = getDoubleFromQuantity(OS_MaterialFields::Density,density);
if (!value) {
return false;
}
return setDensity(value.get());
}
开发者ID:CUEBoxer,项目名称:OpenStudio,代码行数:7,代码来源:MasslessOpaqueMaterial.cpp
示例5: CanteraError
void MineralEQ3::initThermoXML(XML_Node& phaseNode, const std::string& id_)
{
/*
* Find the Thermo XML node
*/
if (!phaseNode.hasChild("thermo")) {
throw CanteraError("HMWSoln::initThermoXML",
"no thermo XML node");
}
std::vector<const XML_Node*> xspecies = speciesData();
const XML_Node* xsp = xspecies[0];
XML_Node* aStandardState = 0;
if (xsp->hasChild("standardState")) {
aStandardState = &xsp->child("standardState");
} else {
throw CanteraError("MineralEQ3::initThermoXML",
"no standard state mode");
}
doublereal volVal = 0.0;
string smodel = (*aStandardState)["model"];
if (smodel != "constantVolume") {
throw CanteraError("MineralEQ3::initThermoXML",
"wrong standard state mode");
}
if (aStandardState->hasChild("V0_Pr_Tr")) {
XML_Node& aV = aStandardState->child("V0_Pr_Tr");
string Aunits = "";
double Afactor = toSI("cm3/gmol");
if (aV.hasAttrib("units")) {
Aunits = aV.attrib("units");
Afactor = toSI(Aunits);
}
volVal = ctml::getFloat(*aStandardState, "V0_Pr_Tr");
m_V0_pr_tr= volVal;
volVal *= Afactor;
m_speciesSize[0] = volVal;
} else {
throw CanteraError("MineralEQ3::initThermoXML",
"wrong standard state mode");
}
doublereal rho = molecularWeight(0) / volVal;
setDensity(rho);
const XML_Node& sThermo = xsp->child("thermo");
const XML_Node& MinEQ3node = sThermo.child("MinEQ3");
m_deltaG_formation_pr_tr =
ctml::getFloatDefaultUnits(MinEQ3node, "DG0_f_Pr_Tr", "cal/gmol", "actEnergy");
m_deltaH_formation_pr_tr =
ctml::getFloatDefaultUnits(MinEQ3node, "DH0_f_Pr_Tr", "cal/gmol", "actEnergy");
m_Entrop_pr_tr = ctml::getFloatDefaultUnits(MinEQ3node, "S0_Pr_Tr", "cal/gmol/K");
m_a = ctml::getFloatDefaultUnits(MinEQ3node, "a", "cal/gmol/K");
m_b = ctml::getFloatDefaultUnits(MinEQ3node, "b", "cal/gmol/K2");
m_c = ctml::getFloatDefaultUnits(MinEQ3node, "c", "cal-K/gmol");
convertDGFormation();
}
开发者ID:athlonshi,项目名称:cantera,代码行数:60,代码来源:MineralEQ3.cpp
示例6: mrc_to_gd
/**
* void mrc_to_gd(MRC *mrc, int ** tpixels, int pmin, int pmax) {
*/
void mrc_to_gd(MRC *mrc, gdImagePtr im, int pmin, int pmax) {
float *data_array;
float fmin=mrc->header.amin,
fmax=mrc->header.amax,
scale = fmax - fmin,
nmin, nmax,
nscale,
f_val;
int w=mrc->header.nx, h=mrc->header.ny,
i,j;
int densitymax = DENSITY_MAX;
long n=w*h, ij;
data_array = (float *)mrc->pbyData;
nmin = fmin + pmin * scale / densitymax;
nmax = fmin + pmax * scale / densitymax;
nscale = nmax - nmin;
if (nscale != 0)
for (j = 0; j < h; ++j) {
for (i = 0; i < w; ++i) {
ij = i + j*w;
f_val = data_array[ij];
f_val = (f_val-nmin)*densitymax/nscale;
gdImageSetPixel (im, i, j, setDensity(f_val));
}
}
}
开发者ID:leschzinerlab,项目名称:myami-3.2-freeHand,代码行数:37,代码来源:gd_mrc.c
示例7: setDensity
FORCEINLINE void TVoxelData::initializeDensity() {
const int s = voxel_num * voxel_num * voxel_num;
density_data = new unsigned char[s];
for (auto x = 0; x < voxel_num; x++) {
for (auto y = 0; y < voxel_num; y++) {
for (auto z = 0; z < voxel_num; z++) {
if (density_state == TVoxelDataFillState::FULL) {
setDensity(x, y, z, 1);
}
if (density_state == TVoxelDataFillState::ZERO) {
setDensity(x, y, z, 0);
}
}
}
}
}
开发者ID:bw2012,项目名称:UnrealSandboxTerrain,代码行数:17,代码来源:VoxelData.cpp
示例8: CRigidBody
CRigidBox::CRigidBox(S32 parent, CSceneObject *so, const CVector3 &d ) : CRigidBody(parent, so) {
if(parent == 0) parent = (S32)space;
mGeomID = dCreateBox((dSpaceID)parent, TO_PHYSICS(d.x), TO_PHYSICS(d.y), TO_PHYSICS(d.z));
mBodyID = dBodyCreate(world);
dGeomSetBody(mGeomID, mBodyID);
dGeomSetData(mGeomID, static_cast<void *>(this));
mDimentions = d;
setDensity(0.0001);
}
开发者ID:harkal,项目名称:sylphis3d,代码行数:9,代码来源:rigidbox.cpp
示例9: setDensity
void SingleSpeciesTP::setState_SV(doublereal s, doublereal v,
doublereal tol)
{
doublereal dt;
if (v == 0.0) {
setDensity(1.0E100);
} else {
setDensity(1.0/v);
}
for (int n = 0; n < 50; n++) {
dt = clip((s - entropy_mass())*temperature()/cv_mass(), -100.0, 100.0);
setTemperature(temperature() + dt);
if (fabs(dt) < tol) {
return;
}
}
throw CanteraError("setState_SV","no convergence. dt = " + fp2str(dt));
}
开发者ID:hgossler,项目名称:cantera,代码行数:18,代码来源:SingleSpeciesTP.cpp
示例10: setDensity
void f2CircleShape::init(float32 density)
{
setDensity(density);
setOrient(0.0f);
type = e_circle;
position.zero();
}
开发者ID:BentleyBlanks,项目名称:Floekr2d,代码行数:10,代码来源:f2CircleShape.cpp
示例11: setDensity
/** Initializes a new power-up object with the supplied position and index. */
bool Powerup::init(const Vec2& pos, const PowerupType& t, int i) {
if (CapsuleObstacle::init(pos)) {
_type = t;
_index = i;
setDensity(0.0f);
setFriction(0.0f);
setFixedRotation(true);
return true;
}
return false;
};
开发者ID:obuehler,项目名称:shadegame,代码行数:12,代码来源:M_Powerup.cpp
示例12: buildScene
//private
void TilemapDemoState::buildScene()
{
if (m_tilemap.load("assets/maps/platform.tmx"))
{
auto entity = xy::Entity::create(m_messageBus);
const auto& layers = m_tilemap.getLayers();
for (const auto& l : layers)
{
if (l->getType() == xy::tmx::Layer::Type::Object)
{
xy::Logger::log("found object layer - attempting to create physics components", xy::Logger::Type::Info);
auto rb = m_tilemap.createRigidBody(m_messageBus, *l);
entity->addComponent(rb);
}
else
{
auto drawable = m_tilemap.getDrawable(m_messageBus, *l, m_textureResource, m_shaderResource);
if (drawable)
{
xy::Logger::log("created layer drawable, adding to scene...");
entity->addComponent(drawable);
}
}
}
m_scene.addEntity(entity, xy::Scene::Layer::BackFront);
static const float radius = 30.f;
auto body = xy::Component::create<xy::Physics::RigidBody>(m_messageBus, xy::Physics::BodyType::Dynamic);
auto cs = xy::Physics::CollisionCircleShape(radius);
cs.setDensity(0.9f);
cs.setRestitution(1.f);
body->addCollisionShape(cs);
auto drawable = xy::Component::create<xy::SfDrawableComponent<sf::CircleShape>>(m_messageBus);
drawable->getDrawable().setRadius(radius);
drawable->getDrawable().setOrigin({ radius, radius });
drawable->getDrawable().setFillColor({ 255, 255, 255, 200 });
drawable->getDrawable().setOutlineThickness(2.f);
auto cam = xy::Component::create<xy::Camera>(m_messageBus, getContext().defaultView);
cam->lockTransform(xy::Camera::TransformLock::Rotation, true);
cam->lockBounds(m_tilemap.getBounds());
entity = xy::Entity::create(m_messageBus);
entity->setPosition(800.f, 400.f);
entity->addComponent(body);
entity->addComponent(drawable);
auto camPtr = entity->addComponent(cam);
ent = m_scene.addEntity(entity, xy::Scene::Layer::FrontFront);
m_scene.setActiveCamera(camPtr);
}
}
开发者ID:fallahn,项目名称:xygine,代码行数:55,代码来源:TilemapDemoState.cpp
示例13: setMassFractions_NoNorm
void Phase::restoreState(size_t lenstate, const doublereal* state)
{
if (lenstate >= nSpecies() + 2) {
setMassFractions_NoNorm(state + 2);
setTemperature(state[0]);
setDensity(state[1]);
} else {
throw ArraySizeError("Phase::restoreState",
lenstate,nSpecies()+2);
}
}
开发者ID:MrKingKong,项目名称:cantera,代码行数:11,代码来源:Phase.cpp
示例14: setDensity
GroundFog::~GroundFog() {
// Disable passes.
setDensity(0);
mDomeNode->detachObject(mDomeEntity);
mScene->destroyEntity(mDomeEntity);
mDomeEntity = 0;
static_cast<Ogre::SceneNode*>(mDomeNode->getParent())->removeAndDestroyChild(mDomeNode->getName());
mDomeNode = 0;
mScene = 0;
Ogre::MaterialManager::getSingletonPtr()->remove(mDomeMaterial->getHandle());
}
开发者ID:ghoulsblade,项目名称:vegaogre,代码行数:11,代码来源:GroundFog.cpp
示例15: CanteraError
void MetalSHEelectrons::setParametersFromXML(const XML_Node& eosdata)
{
if ( eosdata["model"] != "MetalSHEelectrons") {
throw CanteraError("MetalSHEelectrons::setParametersFromXML",
"thermo model attribute must be MetalSHEelectrons");
}
doublereal rho = 2.65E3;
if (eosdata.hasChild("density")) {
rho = getFloat(eosdata, "density", "toSI");
}
setDensity(rho);
}
开发者ID:JasonChunZheng,项目名称:cantera,代码行数:12,代码来源:MetalSHEelectrons.cpp
示例16: setTexture
void IconSprite::setIcon(const Icon &icon) {
if (icon != _icon) {
_icon = icon;
if (icon) {
setTexture(_icon.getTexture());
setTextureRect(_icon.getTextureRect());
setDensity(_icon.getDensity());
} else {
setTexture(nullptr);
}
}
}
开发者ID:SBKarr,项目名称:stappler,代码行数:13,代码来源:SPIconSprite.cpp
示例17: CanteraError
void MineralEQ3::initThermoXML(XML_Node& phaseNode, const std::string& id_)
{
// Find the Thermo XML node
if (!phaseNode.hasChild("thermo")) {
throw CanteraError("HMWSoln::initThermoXML",
"no thermo XML node");
}
const XML_Node* xsp = speciesData()[0];
XML_Node* aStandardState = 0;
if (xsp->hasChild("standardState")) {
aStandardState = &xsp->child("standardState");
} else {
throw CanteraError("MineralEQ3::initThermoXML",
"no standard state mode");
}
doublereal volVal = 0.0;
if (aStandardState->attrib("model") != "constantVolume") {
throw CanteraError("MineralEQ3::initThermoXML",
"wrong standard state mode");
}
if (aStandardState->hasChild("V0_Pr_Tr")) {
XML_Node& aV = aStandardState->child("V0_Pr_Tr");
double Afactor = toSI("cm3/gmol");
if (aV.hasAttrib("units")) {
Afactor = toSI(aV.attrib("units"));
}
volVal = getFloat(*aStandardState, "V0_Pr_Tr");
m_V0_pr_tr= volVal;
volVal *= Afactor;
} else {
throw CanteraError("MineralEQ3::initThermoXML",
"wrong standard state mode");
}
setDensity(molecularWeight(0) / volVal);
const XML_Node& MinEQ3node = xsp->child("thermo").child("MinEQ3");
m_deltaG_formation_pr_tr =
getFloat(MinEQ3node, "DG0_f_Pr_Tr", "actEnergy") / actEnergyToSI("cal/gmol");
m_deltaH_formation_pr_tr =
getFloat(MinEQ3node, "DH0_f_Pr_Tr", "actEnergy") / actEnergyToSI("cal/gmol");
m_Entrop_pr_tr = getFloat(MinEQ3node, "S0_Pr_Tr", "toSI") / toSI("cal/gmol/K");
m_a = getFloat(MinEQ3node, "a", "toSI") / toSI("cal/gmol/K");
m_b = getFloat(MinEQ3node, "b", "toSI") / toSI("cal/gmol/K2");
m_c = getFloat(MinEQ3node, "c", "toSI") / toSI("cal-K/gmol");
convertDGFormation();
}
开发者ID:arghdos,项目名称:cantera,代码行数:50,代码来源:MineralEQ3.cpp
示例18: mType
DrawProfiler::DrawProfiler()
: mType(kNone)
, mDensity(0)
, mData(NULL)
, mDataSize(0)
, mCurrentFrame(-1)
, mPreviousTime(0)
, mVerticalUnit(0)
, mHorizontalUnit(0)
, mThresholdStroke(0)
, mShowDirtyRegions(false)
, mFlashToggle(false) {
setDensity(1);
}
开发者ID:AOSP-JF,项目名称:platform_frameworks_base,代码行数:14,代码来源:DrawProfiler.cpp
示例19: LoadException
void TrussMaterial::loadFromXML ( const QDomElement& materialElem )
/*throw (LoadException)*/
{
XMLSerializableObject::loadFromXML( materialElem );
/**
* Set name
**************/
if ( ! materialElem.hasAttribute( "name" ) )
throw LoadException();
QString name = materialElem.attribute( "name" );
setMaterialName( name );
/**
* Set working stress
***************************/
if ( ! materialElem.hasAttribute( "workingStress" ) )
throw LoadException();
bool ok;
double stress = materialElem.attribute( "workingStress" ).toDouble( &ok );
if ( !ok ) throw LoadException();
setWorkingStress( stress );
/**
* Set elasticity module
***************************/
if ( ! materialElem.hasAttribute( "elasticityModule" ) )
throw LoadException();
double elast =
materialElem.attribute( "elasticityModule" ).toDouble( &ok );
if ( !ok ) throw LoadException();
setElasticityModule( elast );
/**
* Set density
******************/
if ( ! materialElem.hasAttribute( "density" ) )
throw LoadException();
double dens = materialElem.attribute( "density" ).toDouble( &ok );
if ( !ok ) throw LoadException();
setDensity( dens );
}
开发者ID:rouming,项目名称:FermaNext,代码行数:49,代码来源:TrussMaterial.cpp
示例20: setDensity
void SingleSpeciesTP::setState_SV(doublereal s, doublereal v,
doublereal tol) {
doublereal dt;
setDensity(1.0/v);
for (int n = 0; n < 50; n++) {
dt = (s - entropy_mass())*temperature()/cv_mass();
if (dt > 100.0) dt = 100.0;
else if (dt < -100.0) dt = -100.0;
setTemperature(temperature() + dt);
if (fabs(dt) < tol) {
return;
}
}
throw CanteraError("setState_SV","no convergence. dt = " + fp2str(dt));
}
开发者ID:anujg1991,项目名称:cantera,代码行数:15,代码来源:SingleSpeciesTP.cpp
注:本文中的setDensity函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论