本文整理汇总了C++中RefMap类的典型用法代码示例。如果您正苦于以下问题:C++ RefMap类的具体用法?C++ RefMap怎么用?C++ RefMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RefMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
void ReturnByRef::apply()
{
RefMap map;
RefMap::iterator iter;
FnSet asgnUpdates;
returnByRefCollectCalls(map, asgnUpdates);
for (iter = map.begin(); iter != map.end(); iter++)
iter->second->transform();
for_set(FnSymbol, fn, asgnUpdates)
updateAssignments(fn);
for (int i = 0; i < virtualMethodTable.n; i++)
{
if (virtualMethodTable.v[i].key)
{
int numFns = virtualMethodTable.v[i].value->n;
for (int j = 0; j < numFns; j++)
{
FnSymbol* fn = virtualMethodTable.v[i].value->v[j];
TransformationKind tfKind = transformableFunctionKind(fn);
if (tfKind == TF_FULL)
transformFunction(fn);
else if (tfKind == TF_ASGN)
updateAssignments(fn);
}
}
}
}
示例2: integrate_over_wall
// Custom function to calculate drag coefficient.
double integrate_over_wall(MeshFunction* meshfn, int marker)
{
Quad2D* quad = &g_quad_2d_std;
meshfn->set_quad_2d(quad);
double integral = 0.0;
Element* e;
Mesh* mesh = meshfn->get_mesh();
for_all_active_elements(e, mesh)
{
for(int edge = 0; edge < e->nvert; edge++)
{
if ((e->en[edge]->bnd) && (e->en[edge]->marker == marker))
{
update_limit_table(e->get_mode());
RefMap* ru = meshfn->get_refmap();
meshfn->set_active_element(e);
int eo = quad->get_edge_points(edge);
meshfn->set_quad_order(eo, H2D_FN_VAL);
scalar *uval = meshfn->get_fn_values();
double3* pt = quad->get_points(eo);
double3* tan = ru->get_tangent(edge);
for (int i = 0; i < quad->get_num_points(eo); i++)
integral += pt[i][2] * uval[i] * tan[i][2];
}
}
}
return integral * 0.5;
}
示例3: get_peak
// Calculates maximum of a given function, including its coordinates.
Extremum get_peak(MeshFunction *sln)
{
Quad2D* quad = &g_quad_2d_std;
sln->set_quad_2d(quad);
Element* e;
Mesh* mesh = sln->get_mesh();
scalar peak = 0.0;
double pos_x = 0.0;
double pos_y = 0.0;
for_all_active_elements(e, mesh)
{
update_limit_table(e->get_mode());
sln->set_active_element(e);
RefMap* ru = sln->get_refmap();
int o = sln->get_fn_order() + ru->get_inv_ref_order();
limit_order(o);
sln->set_quad_order(o, H2D_FN_VAL);
scalar *uval = sln->get_fn_values();
int np = quad->get_num_points(o);
double* x = ru->get_phys_x(o);
double* y = ru->get_phys_y(o);
for (int i = 0; i < np; i++)
if (uval[i] > peak) {
peak = uval[i];
pos_x = x[i];
pos_y = y[i];
}
}
示例4: CalculateBoundaryLength
//------------------------------------------------------------------------------
// Compute marked boundary length
//
double CalculateBoundaryLength(Mesh* mesh, int bdryMarker)
{
// Variables declaration.
Element* e;
double length = 0;
RefMap rm;
rm.set_quad_2d(&g_quad_2d_std);
Quad2D * quad = rm.get_quad_2d();
int points_location;
double3* points;
int np;
double3* tangents;
// Loop through all boundary faces of all active elements.
for_all_active_elements(e, mesh) {
for(int edge = 0; edge < e->nvert; ++edge) {
if ((e->en[edge]->bnd) && (e->en[edge]->marker == bdryMarker)) {
rm.set_active_element(e);
points_location = quad->get_edge_points(edge);
points = quad->get_points(points_location);
np = quad->get_num_points(points_location);
tangents = rm.get_tangent(edge, points_location);
for(int i = 0; i < np; i++) {
// Weights sum up to two on every edge, therefore the division by two must be present.
length += 0.5 * points[i][2] * tangents[i][2];
}
}
}
}
return length;
} // end of CalculateBoundaryLength()
示例5: calc_error
/// Calculates the absolute error between sln1 and sln2 using function fn
double calc_error(double (*fn)(MeshFunction*, MeshFunction*, int, QuadPt3D*), MeshFunction *sln1, MeshFunction *sln2) {
_F_
Mesh *meshes[2] = { sln1->get_mesh(), sln2->get_mesh() };
Transformable *tr[2] = { sln1, sln2 };
Traverse trav;
trav.begin(2, meshes, tr);
double error = 0.0;
Element **ee;
while ((ee = trav.get_next_state(NULL, NULL)) != NULL) {
ElementMode3D mode = ee[0]->get_mode();
RefMap *ru = sln1->get_refmap();
Ord3 order = max(sln1->get_fn_order(), sln2->get_fn_order()) + ru->get_inv_ref_order();
order.limit();
Quad3D *quad = get_quadrature(mode);
int np = quad->get_num_points(order);
QuadPt3D *pt = quad->get_points(order);
error += fn(sln1, sln2, np, pt);
}
trav.finish();
return error > H3D_TINY ? sqrt(error) : error; // do not ruin the precision by taking the sqrt
}
示例6: registerEntryInRefMap
void CacheGitDirectory::registerEntryInRefMap(const std::string& hash,
RefMap& refMap) {
assert(isInRef());
/* Find the cache entry that corresponds to this hash.
* Create a new entry if not found. */
auto itFind = gitHashMap_.find(hash);
GitCacheEntry* entry;
if (itFind == gitHashMap_.end()) {
entry = new GitCacheEntry();
entry->hash = hash;
gitHashMap_[hash] = entry;
} else {
entry = itFind->second;
}
/* Look in the refMap for any CacheEntry that was already linked to the
* current git ref. */
auto itPrevEntry = refMap.find(currentGitRef_);
if (itPrevEntry != refMap.end()) {
GitCacheEntry* prevEntry = itPrevEntry->second;
assert(prevEntry->numGitRefs > 0);
prevEntry->numGitRefs--;
if (prevEntry->numGitRefs == 0 && prevEntry != entry) {
DLOG(INFO) << "deleting " << prevEntry->hash;
cacheFs_.delEntry(prevEntry->hash);
gitHashMap_.erase(prevEntry->hash);
delete prevEntry;
}
}
refMap[currentGitRef_] = entry;
entry->numGitRefs++;
}
示例7: loadNiTriShapeData
void loadNiTriShapeData(Niflib::NiTriShapeRef parent, Niflib::NiTriShapeDataRef data,
RefMap& refmap) {
Renderable *result;
if (parent->GetSkinInstance()) {
SkinnedMesh *mesh = new SkinnedMesh(true);
loadNiTriShapeVertices(mesh, data);
loadNiTriShapeMaterial(mesh, parent);
loadNiSkinInstance(mesh, parent->GetSkinInstance(), refmap);
mesh->parent = refmap.getNode(parent);
result = mesh;
}
else {
Mesh *mesh = new Mesh(true);
loadNiTriShapeVertices(mesh, data);
loadNiTriShapeMaterial(mesh, parent);
mesh->parent = refmap.getNode(parent);
result = mesh;
}
refmap.currentModel->addRenderable(result);
}
示例8: integrate
// Integral over the active core.
double integrate(MeshFunction<double>* sln, std::string area)
{
Quad2D* quad = &g_quad_2d_std;
sln->set_quad_2d(quad);
double integral = 0.0;
Element* e;
Mesh* mesh = const_cast<Mesh*>(sln->get_mesh());
int marker = mesh->get_element_markers_conversion().get_internal_marker(area).marker;
for_all_active_elements(e, mesh)
{
if (e->marker == marker)
{
update_limit_table(e->get_mode());
sln->set_active_element(e);
RefMap* ru = sln->get_refmap();
int o = sln->get_fn_order() + ru->get_inv_ref_order();
limit_order(o, e->get_mode());
sln->set_quad_order(o, H2D_FN_VAL);
double *uval = sln->get_fn_values();
double* x = ru->get_phys_x(o);
double result = 0.0;
h1_integrate_expression(x[i] * uval[i]);
integral += result;
}
}
return 2.0 * M_PI * integral;
}
示例9: extractReferences
// Insert pairs into available copies map
// Also, record references when they are created.
static void extractReferences(Expr* expr,
RefMap& refs)
{
// We're only interested in call expressions.
if (CallExpr* call = toCallExpr(expr))
{
// Only the move primitive creates an available pair.
if (call->isPrimitive(PRIM_MOVE) || call->isPrimitive(PRIM_ASSIGN))
{
SymExpr* lhe = toSymExpr(call->get(1)); // Left-Hand Expression
Symbol* lhs = lhe->var; // Left-Hand Symbol
if (SymExpr* rhe = toSymExpr(call->get(2))) // Right-Hand Expression
{
Symbol* rhs = rhe->var; // Right-Hand Symbol
if (lhs->type->symbol->hasFlag(FLAG_REF) &&
rhs->type->symbol->hasFlag(FLAG_REF))
{
// This is a ref <- ref assignment.
// Which means that the lhs is now also a reference to whatever the
// rhs refers to.
RefMap::iterator refDef = refs.find(rhs);
// Refs can come from outside the function (e.g. through arguments),
// so are not necessarily defined within the function.
if (refDef != refs.end())
{
Symbol* val = refDef->second;
#if DEBUG_CP
if (debug > 0)
printf("Creating ref (%s[%d], %s[%d])\n",
lhs->name, lhs->id, val->name, val->id);
#endif
refs.insert(RefMapElem(lhs, val));
}
}
}
if (CallExpr* rhc = toCallExpr(call->get(2)))
{
if (rhc->isPrimitive(PRIM_ADDR_OF))
{
SymExpr* rhe = toSymExpr(rhc->get(1));
// Create the pair lhs <- &rhs.
Symbol* lhs = lhe->var;
Symbol* rhs = rhe->var;
#if DEBUG_CP
if (debug > 0)
printf("Creating ref (%s[%d], %s[%d])\n",
lhs->name, lhs->id, rhs->name, rhs->id);
#endif
refs.insert(RefMapElem(lhs, rhs));
}
}
}
}
}
示例10: loadNiKeyframeController
void loadNiKeyframeController(Niflib::NiKeyframeControllerRef obj, RefMap& refmap)
{
//make a new animation controller
KeyframeAnimationObject *result = new KeyframeAnimationObject();
//load data
result->length = obj->GetStopTime();
Niflib::NiKeyframeDataRef data = Niflib::DynamicCast<Niflib::NiKeyframeData>(obj->GetData());
for (Niflib::Key<Niflib::Vector3> key: data->GetTranslateKeys()) {
result->positionKeys.addKey(key.time, NifToGlmVec3(key.data));
}
for (Niflib::Key<Niflib::Quaternion> key: data->GetQuatRotateKeys()) {
result->rotationKeys.addKey(key.time, NifToGlmQuat(key.data));
}
for (Niflib::Key<float> key: data->GetScaleKeys()) {
result->scaleKeys.addKey(key.time, glm::vec3(key.data, key.data, key.data));
}
result->setTarget(refmap.getNode(obj->GetTarget()));
refmap.currentModel->addController(result);
}
示例11: loadNiSkinInstance
void loadNiSkinInstance(SkinnedMesh *mesh, Niflib::NiSkinInstanceRef skin, RefMap& refmap)
{
Niflib::NiSkinDataRef skindata = skin->GetSkinData();
for (unsigned int ibone=0; ibone<skin->GetBoneCount(); ibone++) {
mesh->bones.push_back(refmap.getNode(skin->GetBones()[ibone]));
Niflib::Matrix44 offset = skindata->GetBoneTransform(ibone);
mesh->boneOffsets.push_back(NifToGlmMat4(offset));
for (Niflib::SkinWeight weight: skindata->GetBoneWeights(ibone)) {
mesh->vertices->get(weight.index).addBone(ibone, weight.weight);
}
}
mesh->root = refmap.getNode(skin->GetSkeletonRoot());
}
示例12: calc_norm
/// Calculates the norm of sln using function fn
double calc_norm(double (*fn)(MeshFunction*, int, QuadPt3D*), MeshFunction *sln) {
_F_
double norm = 0.0;
Mesh *mesh = sln->get_mesh();
FOR_ALL_ACTIVE_ELEMENTS(eid, mesh) {
Element *e = mesh->elements[eid];
sln->set_active_element(e);
RefMap *ru = sln->get_refmap();
order3_t o = sln->get_fn_order() + ru->get_inv_ref_order();
o.limit();
Quad3D *quad = get_quadrature(e->get_mode());
int np = quad->get_num_points(o);
QuadPt3D *pt = quad->get_points(o);
norm += fn(sln, np, pt);
}
示例13: forv_Vec
void ReturnByRef::returnByRefCollectCalls(RefMap& calls, FnSet& fns)
{
RefMap::iterator iter;
forv_Vec(CallExpr, call, gCallExprs)
{
// Only transform calls that are still in the AST tree
// (defer statement bodies have been removed at this point
// in this pass)
if (call->inTree()) {
// Only transform calls to transformable functions
// The common case is a user-level call to a resolved function
// Also handle the PRIMOP for a virtual method call
if (FnSymbol* fn = call->resolvedOrVirtualFunction()) {
TransformationKind tfKind = transformableFunctionKind(fn);
if (tfKind == TF_FULL)
{
RefMap::iterator iter = calls.find(fn->id);
ReturnByRef* info = NULL;
if (iter == calls.end())
{
info = new ReturnByRef(fn);
calls[fn->id] = info;
}
else
{
info = iter->second;
}
info->addCall(call);
}
else if (tfKind == TF_ASGN)
{
fns.insert(fn);
}
}
}
}
}
示例14: loadNiNode
void loadNiNode(Niflib::NiAVObjectRef node, RefMap& refmap) {
//make a new node
Node *result = refmap.getNode(node);
//load data
result->setName(node->GetName());
result->setPosition(NifToGlmVec3(node->GetLocalTranslation()));
result->setRotation(NifToGlmQuat(node->GetLocalRotation().AsQuaternion()));
result->setScale(glm::vec3(node->GetLocalScale(),node->GetLocalScale(),node->GetLocalScale()));
for (Niflib::NiExtraDataRef& extradata: node->GetExtraData()) {
if (extradata->GetType().IsSameType(Niflib::NiStringExtraData::TYPE)) {
Niflib::NiStringExtraDataRef strdata = Niflib::DynamicCast<Niflib::NiStringExtraData>(
extradata);
if (strdata->GetData() == "NCO") {
refmap.hasCollision = false;
}
}
}
if (node->GetType().IsSameType(Niflib::NiTriShape::TYPE)) {
Niflib::NiTriShapeRef temp = Niflib::DynamicCast<Niflib::NiTriShape>(node);
Niflib::NiTriShapeDataRef tempdata = Niflib::DynamicCast<Niflib::NiTriShapeData>(temp->GetData());
loadNiTriShapeData(temp, tempdata, refmap);
}
else if (node->GetType().IsSameType(Niflib::RootCollisionNode::TYPE)) {
refmap.collisionnode = Niflib::DynamicCast<Niflib::RootCollisionNode>(node);
}
result->isVisible = node->GetVisibility();
//attach this node to its parent
Niflib::NiNodeRef parent = node->GetParent();
if (parent) {
Node *parnode = refmap.getNode(parent);
parnode->addChild(result);
}
refmap.currentModel->addNamedNode(node->GetName(), result);
}
示例15: memset
void DiscreteProblem::precalc_equi_coefs()
{
int i, m;
memset(equi, 0, sizeof(double) * ndofs);
verbose("Precalculating equilibration coefficients...");
RefMap refmap;
AsmList al;
Element* e;
for (m = 0; m < neq; m++)
{
PrecalcShapeset* fu = pss[m];
BiForm* bf = biform[m] + m;
Mesh* mesh = spaces[m]->get_mesh();
for_all_active_elements(e, mesh)
{
update_limit_table(e->get_mode());
fu->set_active_element(e);
refmap.set_active_element(e);
spaces[m]->get_element_assembly_list(e, &al);
for (i = 0; i < al.cnt; i++)
{
if (al.dof[i] < 0) continue;
fu->set_active_shape(al.idx[i]);
scalar sy = 0.0, un = 0.0;
if (bf->unsym) un = bf->unsym(fu, fu, &refmap, &refmap);
if (bf->sym) sy = bf->sym (fu, fu, &refmap, &refmap);
#ifndef COMPLEX
equi[al.dof[i]] += (sy + un) * sqr(al.coef[i]);
#else
equi[al.dof[i]] += 0;//std::norm(sy + un) * sqr(al.coef[i]);
#endif
}
}
}