UniquePtr<Elem> InfPrism6::build_edge (const unsigned int i) const { libmesh_assert_less (i, n_edges()); if (i < 3) return UniquePtr<Elem>(new SideEdge<Edge2,InfPrism6>(this,i)); return UniquePtr<Elem>(new SideEdge<InfEdge2,InfPrism6>(this,i)); }
bool Pyramid14::is_node_on_edge(const unsigned int n, const unsigned int e) const { libmesh_assert_less (e, n_edges()); return std::find(std::begin(edge_nodes_map[e]), std::end(edge_nodes_map[e]), n) != std::end(edge_nodes_map[e]); }
bool InfPrism6::is_node_on_edge(const unsigned int n, const unsigned int e) const { libmesh_assert_less (e, n_edges()); for (unsigned int i = 0; i != 2; ++i) if (edge_nodes_map[e][i] == n) return true; return false; }
bool Tet10::is_node_on_edge(const unsigned int n, const unsigned int e) const { libmesh_assert(e < n_edges()); for (unsigned int i = 0; i != 3; ++i) if (edge_nodes_map[e][i] == n) return true; return false; }
void make_biconnected_planar(Graph& g, PlanarEmbedding embedding, EdgeIndexMap em, AddEdgeVisitor& vis ) { typedef typename graph_traits<Graph>::vertex_descriptor vertex_t; typedef typename graph_traits<Graph>::edge_descriptor edge_t; typedef typename graph_traits<Graph>::edges_size_type edge_size_t; typedef typename property_traits<PlanarEmbedding>::value_type embedding_value_t; typedef typename embedding_value_t::const_iterator embedding_iterator_t; typedef iterator_property_map <std::vector<std::size_t>::iterator, EdgeIndexMap> component_map_t; edge_size_t n_edges(num_edges(g)); std::vector<vertex_t> articulation_points; std::vector<edge_size_t> component_vector(n_edges); component_map_t component_map(component_vector.begin(), em); biconnected_components(g, component_map, std::back_inserter(articulation_points)); typename std::vector<vertex_t>::iterator ap, ap_end; ap_end = articulation_points.end(); for(ap = articulation_points.begin(); ap != ap_end; ++ap) { vertex_t v(*ap); embedding_iterator_t pi = embedding[v].begin(); embedding_iterator_t pi_end = embedding[v].end(); edge_size_t previous_component(n_edges + 1); vertex_t previous_vertex = graph_traits<Graph>::null_vertex(); for(; pi != pi_end; ++pi) { edge_t e(*pi); vertex_t e_source(source(e,g)); vertex_t e_target(target(e,g)); //Skip self-loops and parallel edges if (e_source == e_target || previous_vertex == e_target) continue; vertex_t current_vertex = e_source == v ? e_target : e_source; edge_size_t current_component = component_map[e]; if (previous_vertex != graph_traits<Graph>::null_vertex() && current_component != previous_component) { vis.visit_vertex_pair(current_vertex, previous_vertex, g); } previous_vertex = current_vertex; previous_component = current_component; } } }
void Node::calculateForces(const double *map,int width,int height,int W,int H,float x,float y,float friction_factor) { if (!scene() || scene()->mouseGrabberItem() == this) { newPos = pos(); return; } // Sum up all forces pushing this item away qreal xforce = 0; qreal yforce = 0; float dei=0.0f ; float dej=0.0f ; static float *e = NULL ; static const int KS = 5 ; if(e == NULL) { e = new float[(2*KS+1)*(2*KS+1)] ; for(int i=-KS;i<=KS;++i) for(int j=-KS;j<=KS;++j) e[i+KS+(2*KS+1)*(j+KS)] = exp( -(i*i+j*j)/30.0 ) ; // can be precomputed } for(int i=-KS;i<=KS;++i) for(int j=-KS;j<=KS;++j) { int X = std::min(W-1,std::max(0,(int)rint(x))) ; int Y = std::min(H-1,std::max(0,(int)rint(y))) ; float val = map[2*((i+X+W)%W + W*((j+Y+H)%H))] ; dei += i * e[i+KS+(2*KS+1)*(j+KS)] * val ; dej += j * e[i+KS+(2*KS+1)*(j+KS)] * val ; } xforce = REPULSION_FACTOR * dei/25.0; yforce = REPULSION_FACTOR * dej/25.0; // Now subtract all forces pulling items together double weight = (n_edges() + 1) ; foreach (Edge *edge, edgeList) { QPointF pos; double w2 ; // This factor makes the edge length depend on connectivity, so clusters of friends tend to stay in the // same location. // if (edge->sourceNode() == this) { pos = mapFromItem(edge->destNode(), 0, 0); w2 = sqrtf(std::min(n_edges(),edge->destNode()->n_edges())) ; } else { pos = mapFromItem(edge->sourceNode(), 0, 0); w2 = sqrtf(std::min(n_edges(),edge->sourceNode()->n_edges())) ; } float dist = sqrtf(pos.x()*pos.x() + pos.y()*pos.y()) ; float val = dist - graph->edgeLength() * w2 ; xforce += 0.01*pos.x() * val / weight; yforce += 0.01*pos.y() * val / weight; }