本文整理汇总了C++中Array2D::set方法的典型用法代码示例。如果您正苦于以下问题:C++ Array2D::set方法的具体用法?C++ Array2D::set怎么用?C++ Array2D::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array2D
的用法示例。
在下文中一共展示了Array2D::set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void Strand2dFCBlockMesh::initialize(const int& level0,
const int& meshOrder0,
const int& nSurfElem0,
const int& nSurfNodeG,
const int& nBndNode0,
const int& nStrandNodeG,
const int& nCompBd0,
int** surfElemG,
const Array1D<int>& bndNodeG,
const Array2D<double>& surfXG,
const Array1D<double>& strandXG,
const Array1D<int>& surfElemTagG,
const Array1D<int>& bndNodeTagG,
const Array2D<double>& bndNodeNormalG)
{
// copy dimensions for this block
level = level0;
meshOrder = meshOrder0;
nSurfElem = nSurfElem0;
nBndNode = nBndNode0;
nCompBd = nCompBd0;
// allocate space for the mesh data, and copy the known data
surfElem.allocate(nSurfElem,meshOrder+1);
surfElemTag.allocate(nSurfElem);
bndNode.allocate(nBndNode);
bndNodeTag.allocate(nBndNode);
bndNodeNormal.allocate(nBndNode,2);
for (int n=0; n<nSurfElem; n++) surfElemTag(n) = surfElemTagG(n);
for (int n=0; n<nBndNode; n++){
bndNodeTag(n) = bndNodeTagG(n);
bndNodeNormal(n,0) = bndNodeNormalG(n,0);
bndNodeNormal(n,1) = bndNodeNormalG(n,1);
}
// form surface elements of the desired order, count surface nodes
int n1,n2;
Array1D<int> flag(nSurfNodeG);
flag.set(-1);
nSurfNode = 0;
for (int n=0; n<nSurfElem; n++){ //add element end points first
n1 = surfElemG[n][1];
n2 = surfElemG[n][2];
if (flag(n1) == -1) flag(n1) = nSurfNode++;
if (flag(n2) == -1) flag(n2) = nSurfNode++;
surfElem(n,0) = flag(n1);
surfElem(n,1) = flag(n2);
}
for (int n=0; n<nSurfElem; n++) //add interior dofs next
for (int j=2; j<meshOrder+1; j++) surfElem(n,j) = nSurfNode++;
// point the bndNode array to the new node numbers
for (int n=0; n<nBndNode; n++) bndNode(n) = flag(bndNodeG(n));
// find surface mesh coordinates based on mappings from the mesh file
Array1D<double> ss(meshOrder+1);
int spacing=0; // assume equal spacing for now
solutionPoints1D(meshOrder, //find s-locations based on desired spacing
spacing,
&ss(0));
surfX.allocate(nSurfNode,2);
surfX.set(0.);
bool test=false;
int orderM;
double lm;
Array1D<double> sM;
Array2D<double> lcM;
flag.deallocate();
flag.allocate(nSurfNode);
flag.set(-1);
for (int n=0; n<nSurfElem; n++){
orderM = surfElemG[n][0];
// s-locations using numbering consistent with the mesh
sM.allocate(orderM+1);
solutionPoints1D(orderM,
spacing,
&sM(0));
// lagrange polynomials at the sM locations
lcM.allocate(orderM+1,orderM+1);
lagrangePoly1D(test,
orderM,
&sM(0),
&lcM(0,0));
// evaluate the x-coordinates at the local solution points
for (int i=0; i<meshOrder+1; i++) //ith local point
if (flag(surfElem(n,i)) == -1){//haven't computed this location yet
for (int m=0; m<orderM+1; m++){ //mth Lagrange poly. used in mapping
lm = 0.;
for (int k=0; k<orderM+1; k++) lm += pow(ss(i),k)*lcM(m,k);
surfX(surfElem(n,i),0) += lm*surfXG(surfElemG[n][m+1],0);
surfX(surfElem(n,i),1) += lm*surfXG(surfElemG[n][m+1],1);
}
flag(surfElem(n,i)) = 0;
//.........这里部分代码省略.........
示例2: buildPositionMatrix
bool Skeleton::buildPositionMatrix(Array2D<float>& pmat)
{
if (motion_controller == NULL)
{
char s[1000];
sprintf(s, "AnimSkeleton::buildPositionMatrix failed - skeleton %s has no motion controller", getId());
logout << s << endl;
throw AnimationException(s);
return false;
}
// DANGEROUS! - (but this is only special case code)
RawMotionController* rawctrl = (RawMotionController*)motion_controller;
int num_frames = rawctrl->numFrames();
pmat.resize(num_frames, 3*num_bones);
for (int frame=0; frame<num_frames; frame++)
{
// compute skeletal transform for offsets
Matrix4x4 translation_xform = Matrix4x4::translationXYZ(offset_position);
Matrix4x4 rotation_xform = Matrix4x4::rotationRPY(offset_rotation);
world_xform = translation_xform*rotation_xform;
for (short id=0; id<num_bones; id++)
{
Bone* bone = bone_array[id];
if (bone != NULL)
{
short bid = bone->getID();
Vector3D p, a;
CHANNEL_ID cx(BONE_ID(bid),CT_TX);
CHANNEL_ID cy(BONE_ID(bid),CT_TY);
CHANNEL_ID cz(BONE_ID(bid),CT_TZ);
CHANNEL_ID cpitch(BONE_ID(bid),CT_RX);
CHANNEL_ID cyaw(BONE_ID(bid),CT_RY);
CHANNEL_ID croll(BONE_ID(bid),CT_RZ);
if (rawctrl->isValidChannel(cx))
p.x = rawctrl->getValueByFrame(cx, frame);
if (rawctrl->isValidChannel(cy))
p.y = rawctrl->getValueByFrame(cy, frame);
if (rawctrl->isValidChannel(cz))
p.z = rawctrl->getValueByFrame(cz, frame);
if (rawctrl->isValidChannel(cpitch))
a.pitch = rawctrl->getValueByFrame(cpitch, frame);
if (rawctrl->isValidChannel(cyaw))
a.yaw = rawctrl->getValueByFrame(cyaw, frame);
if (rawctrl->isValidChannel(croll))
a.roll = rawctrl->getValueByFrame(croll, frame);
if (id==0) p += offset_position;
bone->setPose(p, a);
}
}
bone_array[0]->update();
// now cycle through bones and record positions
for (short id=0; id<num_bones; id++)
{
Vector3D start, end;
getBonePositions(id, start, end);
pmat.set(frame, id*3, end.x);
pmat.set(frame, id*3+1, end.y);
pmat.set(frame, id*3+2, end.z);
}
}
return true;
}