本文整理汇总了C++中MESH::node_begin方法的典型用法代码示例。如果您正苦于以下问题:C++ MESH::node_begin方法的具体用法?C++ MESH::node_begin怎么用?C++ MESH::node_begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MESH
的用法示例。
在下文中一共展示了MESH::node_begin方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
void operator()(MESH& m, double t) {
(void) t;
double distance;
double r;
Point directionVector;
Point pos;
Point c;
Point R;
Point velocity;
Node node1;
Node node2;
for(auto it=m.node_begin(); it != m.node_end(); ++ it)
{
node1 = (*it);
c = node1.position();
r = 0.0;
// iterate through connected edges and set r equal to
// the length of the shortest connected edge
for(auto edge_it = node1.edge_begin(); edge_it != node1.edge_end(); ++edge_it)
{
if (r == 0.0 || (*edge_it).length() < r)
r = (*edge_it).length();
}
// now iterate through all of the other nodes and see if any of
// them are within distance r
for(auto it2=m.node_begin(); it2 != m.node_end(); ++it2)
{
node2 = (*it2);
pos = node2.position();
distance = norm(pos-c);
if (distance < r && node1 != node2)
{
// SET POSITION TO NEAREST POINT ON SURFACE OF SPHERE
// get the direction vector from the center to our node
directionVector = pos-c;
//normalize that vector
directionVector = directionVector/norm(directionVector);
// set pos to the direction vector time the sphere's radius
// which should get us to the point on the sphere closest
// to the node's current position
pos = c+directionVector*(r);
node2.set_position(pos);
// SET THE COMPONENT OF VELOCITY THAT IS NORMAL TO THE
// SPHERE'S SURFACE TO ZERO
R = (pos-c)/norm(pos-c);
velocity = node2.value().velocity;
node2.value().velocity = velocity - inner_prod(velocity,R)*R;
}
}
}
}
示例2: post_process
Point post_process(MESH& m, FORCE force, CONSTRAINT& c, double t, double dt, uint water_nodes) {
static double ball_bottom = std::numeric_limits<double>::max();
double water_dis = std::numeric_limits<double>::max();
double dh = 0;
static double submerged_height = 0;
Point bottom_loc;
Point water_loc;
for (auto n_it = m.node_begin(); n_it != m.node_end(); ++n_it) {
// handles the shallow water
if ((*n_it).index() < water_nodes) {
double sum_area = 0;
QVar value = QVar(0,0,0);
for (auto tri_it = m.adj_triangle_begin((*n_it).uid()); tri_it != m.adj_triangle_end((*n_it).uid()); ++tri_it) {
value += (*tri_it).value().q_bar * (*tri_it).area();
sum_area += (*tri_it).area();
}
(*n_it).value().q = value * 1.0/(sum_area);
}
// handles the ball
else {
(*n_it).set_position((*n_it).position() + (*n_it).value().velocity*dt);
dh = (*n_it).value().q.h - (*n_it).position().z;
(*n_it).value().q.h = (*n_it).position().z;
(*n_it).value().velocity += force(m,(*n_it),t)*dt/(*n_it).value().mass;
if ((*n_it).value().q.h < ball_bottom) {
ball_bottom = (*n_it).position().z;
bottom_loc = (*n_it).position();
}
}
}
// find the water node closest to the bottom of the ball
for (auto n_it = m.node_begin(); (*n_it).index() != water_nodes; ++n_it) {
if (norm(Point((*n_it).position().x,(*n_it).position().y,0)-Point(bottom_loc.x,bottom_loc.y,0)) < water_dis){
water_dis = norm(Point((*n_it).position().x,(*n_it).position().y,0)-Point(bottom_loc.x,bottom_loc.y,0));
water_loc = Point((*n_it).position().x,(*n_it).position().y,(*n_it).value().q.h);
}
}
// apply contraints of neccessary
c(m,ball_bottom);
// determines if the ball fell below shallow water and updates height submerged
if (bottom_loc.z < water_loc.z)
submerged_height += dh;
return Point(bottom_loc.x, bottom_loc.y, submerged_height);
}
示例3: get_center
Point get_center(MESH& m)
{
Point center = Point(0,0,0);
for(auto it=m.node_begin(); it != m.node_end(); ++ it)
center += (*it).position();
center /= m.num_nodes();
return center;
}
示例4: post_process
void post_process(MESH& m) {
// HW4B: Post-processing step
// Translate the triangle-averaged values to node-averaged values
// Implement Equation 9 from your pseudocode here
for (auto it = m.node_begin(); it != m.node_end(); ++it){
double sumarea=0;
QVar sumQ = QVar(0, 0, 0);
for(auto j = m.triangle_begin(*it); j != m.triangle_end(*it); ++j){
sumarea += (*j).area();
sumQ += (*j).value().Q * (*j).area();
}
(*it).value().Q = sumQ/sumarea;
}
}
示例5: post_process
void post_process(MESH& m) {
// HW4B: Post-processing step
// Translate the triangle-averaged values to node-averaged values
// Implement Equation 9 from your pseudocode here
for (auto nit = m.node_begin(); nit != m.node_end(); ++nit) {
double total_area = 0;
QVar Q_tot(0, 0, 0);
int count = 0;
for (auto tri_it = m.adjacent_triangle_begin(*nit); tri_it != m.adjacent_triangle_end(*nit); ++tri_it) {
Q_tot = Q_tot + (*tri_it).value() * (*tri_it).area();
total_area += (*tri_it).area();
++count;
}
(*nit).value() = Q_tot / total_area;
}
}
示例6: post_process
/*
* post process of a mesh instance to update the values of all the nodes values
* @pre: a valid mesh instance
* @post: update the nodes values based on approximation of the average of neighbours values
refer to equation 9 on the notes
*/
void post_process(MESH& m) {
// Translate the triangle-averaged values to node-averaged values
// Implement Equation 8 from your pseudocode here
// iterate through all the nodes
for ( auto it = m.node_begin(); it!= m.node_end(); ++it)
{
QVar sum = QVar(0,0,0);
double sumTriArea = 0;
// for each node, iterate through its adjacent triangles
for (auto adji = m.vertex_begin((*it).index()); adji != m.vertex_end((*it).index()); ++ adji)
{
auto tri = (*adji);
sum += tri.area() * tri.value();
sumTriArea += tri.area();
}
(*it).value() = sum/sumTriArea; // update nodes value
}
}
示例7: operator
void operator()(MESH& m, double z_bottom) {
if (z_bottom < plane_)
for(auto it=m.node_begin(); it != m.node_end(); ++it)
(*it).value().velocity = Point(0,0,0);
}