//##################################################################### // Function Find_And_Append_Adjacent_Elements //##################################################################### // find adjacent simplices that contains face and append them to the adjacency list template<int d> void SIMPLEX_MESH<d>:: Find_And_Append_Adjacent_Elements(const int simplex,const VECTOR<int,d>& face) { int first_node=face[1];VECTOR<int,d-1> other_nodes=face.Remove_Index(1); for(int t=1;t<=(*incident_elements)(first_node).m;t++){ int simplex2=(*incident_elements)(first_node)(t); if(simplex2!=simplex && Nodes_In_Simplex(other_nodes,simplex2)) (*adjacent_elements)(simplex).Append_Unique(simplex2);} }
//##################################################################### // Function Simplices_On_Subsimplex //##################################################################### template<int d> template<int d2> void SIMPLEX_MESH<d>:: Simplices_On_Subsimplex(const VECTOR<int,d2>& subsimplex_nodes,ARRAY<int>& simplices_on_subsimplex) const { assert(incident_elements); const ARRAY<int>& incident=(*incident_elements)(subsimplex_nodes[1]); VECTOR<int,d2-1> other_nodes=subsimplex_nodes.Remove_Index(1); for(int i=1;i<=incident.m;i++){ int simplex=incident(i); if(Nodes_In_Simplex(other_nodes,simplex)) simplices_on_subsimplex.Append(simplex);} }
//##################################################################### // Function Simplex //##################################################################### // requires incident_elements // returns the simplex containing these nodes - returns 0 if no simplex contains these nodes template<int d> int SIMPLEX_MESH<d>:: Simplex(const VECTOR<int,d+1>& nodes) const { assert(incident_elements); // find shortest list of elements int short_list=nodes[1];VECTOR<int,d> check=nodes.Remove_Index(1); for(int i=1;i<=d;i++)if((*incident_elements)(check[i]).m < (*incident_elements)(short_list).m) exchange(short_list,check[i]); // search short list for other nodes for(int k=1;k<=(*incident_elements)(short_list).m;k++){int t=(*incident_elements)(short_list)(k); if(Nodes_In_Simplex(check,t)) return t;} return 0; }