static void _get_local_tolerance(const cs_real_t vtx_coords[], double vtx_tolerance[], const cs_int_t n_faces, const cs_int_t face_vtx_idx[], const cs_int_t face_vtx_lst[], double fraction) { cs_lnum_t j, k, start, end, face_id, vtx_id1, vtx_id2; cs_real_t length, tolerance; cs_real_t a[3], b[3]; for (face_id = 0; face_id < n_faces; face_id++) { start = face_vtx_idx[face_id]; end = face_vtx_idx[face_id + 1]; /* Loop on the vertices of the face */ for (j = start; j < end - 1; j++) { vtx_id1 = face_vtx_lst[j]; vtx_id2 = face_vtx_lst[j+1]; for (k = 0; k < 3; k++) { a[k] = vtx_coords[3*vtx_id1 + k]; b[k] = vtx_coords[3*vtx_id2 + k]; } length = _compute_distance(a, b); tolerance = length * fraction; vtx_tolerance[vtx_id1] = CS_MIN(vtx_tolerance[vtx_id1], tolerance); vtx_tolerance[vtx_id2] = CS_MIN(vtx_tolerance[vtx_id2], tolerance); } /* Case end - start */ vtx_id1 = face_vtx_lst[end-1]; vtx_id2 = face_vtx_lst[start]; for (k = 0; k < 3; k++) { a[k] = vtx_coords[3*vtx_id1 + k]; b[k] = vtx_coords[3*vtx_id2 + k]; } length = _compute_distance(a, b); tolerance = length * fraction; vtx_tolerance[vtx_id1] = CS_MIN(vtx_tolerance[vtx_id1], tolerance); vtx_tolerance[vtx_id2] = CS_MIN(vtx_tolerance[vtx_id2], tolerance); } /* End of loop on faces */ }
static PyObject* compute(PyObject* self, PyObject* args) { const char* lat1; const char* long1; const char* lat2; const char* long2; if (!PyArg_ParseTuple(args, "ssss", &lat1, &long1, &lat2, &long2)) return NULL; return Py_BuildValue("f", _compute_distance(lat1, long1,lat2, long2)); }