//------------------------------------------------------------------------- // Purpose : Check if loops are spatially equal. // // Special Notes : // // Creator : Jason Kraftcheck // // Creation Date : 04/01/04 //------------------------------------------------------------------------- CubitBoolean Loop::about_spatially_equal( DLIList<CoEdge*>& other_coedges, CubitSense relative_sense, double tolerance_factor, CubitBoolean notify_refEntity ) { DLIList<CoEdge*> this_coedges(other_coedges.size()); // Loops must have same number of coedges to match. this->ordered_co_edges( this_coedges ); if (this_coedges.size() != other_coedges.size()) return CUBIT_FALSE; // Want to compare coedges in order, so make sure we have // them in the correct order. if (relative_sense == CUBIT_REVERSED) this_coedges.reverse(); // Try to match all coedges. Begin with the first coedge // in this loop. For each coedge in the other loop that // it matches, check if all the other coedges match in the // correct order. int other_loop_index = 0; this_coedges.reset(); other_coedges.reset(); CoEdge* this_coedge = this_coedges.get_and_step(); for (int i = other_coedges.size(); i--; ) { // Loop until we find a matching CoEdge CoEdge* other_coedge = other_coedges.get_and_step(); if (!this_coedge->about_spatially_equal( other_coedge, relative_sense, tolerance_factor, notify_refEntity )) continue; // Found a matching coedge. Now try to match all the // others in the correct order. bool match = true; other_loop_index = other_coedges.get_index(); for (int j = other_coedges.size() - 1; j-- && match; ) { this_coedge = this_coedges.get_and_step(); other_coedge = other_coedges.get_and_step(); match = this_coedge->about_spatially_equal( other_coedge, relative_sense, tolerance_factor, notify_refEntity ); } // Matched all coedges, in order. Done. if (match) return CUBIT_TRUE; // Try again, as perhaps the first coedge of this loop // also matches some other one in the second loop and // if we start with that one, the remaining coedges will // also match. this_coedges.reset(); this_coedge = this_coedges.get_and_step(); other_coedges.reset(); other_coedges.step( other_loop_index ); } // If here, loops didn't match. return CUBIT_FALSE; }