本文整理汇总了C++中setDensity函数的典型用法代码示例。如果您正苦于以下问题:C++ setDensity函数的具体用法?C++ setDensity怎么用?C++ setDensity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setDensity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
}
示例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;
}
示例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. */
}
示例4: getDoubleFromQuantity
bool MasslessOpaqueMaterial_Impl::setDensity(const Quantity& density) {
OptionalDouble value = getDoubleFromQuantity(OS_MaterialFields::Density,density);
if (!value) {
return false;
}
return setDensity(value.get());
}
示例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();
}
示例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));
}
}
}
示例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);
}
}
}
}
}
示例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);
}
示例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));
}
示例10: setDensity
void f2CircleShape::init(float32 density)
{
setDensity(density);
setOrient(0.0f);
type = e_circle;
position.zero();
}
示例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;
};
示例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);
}
}
示例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);
}
}
示例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());
}
示例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);
}