Changeset 8055


Ignore:
Timestamp:
Oct 29, 2010, 11:01:25 AM (13 years ago)
Author:
habili
Message:

Changed function names from "polyline" to "line"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/utilities/polygon_ext.c

    r8046 r8055  
    440440
    441441
    442 int __triangle_polyline_overlap(double* polyline,
    443                                 double* triangle)
     442int __triangle_line_intersect(double* line,
     443                              double* triangle)
    444444{
    445445    int j, jj, A, B;
     
    450450    double a, b;
    451451   
    452     p0_x = polyline[0];
    453     p0_y = polyline[1];
    454     p1_x = polyline[2];
    455     p1_y = polyline[3];
     452    p0_x = line[0];
     453    p0_y = line[1];
     454    p1_x = line[2];
     455    p1_y = line[3];
    456456   
    457457    pp_x = -(p1_y - p0_y);
     
    494494            if (a >= 0.0f && a <= 1.0f && b >=0.0f && b <=1.0f)
    495495            {
    496                 return 1; //overlap
     496                return 1; //intersect
    497497            }
    498498           
     
    514514    if (A >= 1 && B >= 1)
    515515    {
    516         return 1; //overlap
     516        return 1; //polygon sits completely inside a triangle
    517517    }
    518518   
    519     return 0; //no overlap
     519    return 0; //no intersection
    520520}
    521521                 
    522522
    523 int __polyline_overlap(double* polyline,
    524                       double* triangles,
    525                       long* indices,
    526                       int M) //number of triangles
     523int __line_intersect(double* line,
     524                     double* triangles,
     525                     long* indices,
     526                     int M) //number of triangles
    527527{
    528528    double* triangle;
    529529    int i, inside_index, outside_index;
    530530   
    531     inside_index = 0;    // Keep track of triangles that overlap
    532     outside_index = M - 1; // Keep track of triangles that don't overlap (starting from end)
     531    inside_index = 0;    // Keep track of triangles that intersect
     532    outside_index = M - 1; // Keep track of triangles that don't intersect (starting from end)
    533533   
    534534    for (i = 0; i < M; i++)
     
    536536        triangle = triangles + 6*i;
    537537       
    538         if (__triangle_polyline_overlap(polyline,
    539                                         triangle))
     538        if (__triangle_line_intersect(line,
     539                                      triangle))
    540540        {
    541541            indices[inside_index] = i;
     
    854854}
    855855
    856 PyObject *_polyline_overlap(PyObject *self, PyObject *args)
     856PyObject *_line_intersect(PyObject *self, PyObject *args)
    857857{
    858858  //
     
    900900 
    901901  PyArrayObject
    902     *polyline,
     902    *line,
    903903    *triangles,
    904904    *indices;
     
    910910  // Convert Python arguments to C
    911911  if (!PyArg_ParseTuple(args, "OOO",
    912                         &polyline,
     912                        &line,
    913913                        &triangles,
    914914            &indices)) {
     
    920920
    921921  // Call underlying routine
    922   res = __polyline_overlap((double*) polyline->data,
    923                              (double*) triangles->data,
    924                  (long*) indices->data,
    925                  (int) triangles->dimensions[0]/3);                                                   
     922  res = __line_intersect((double*) line->data,
     923                                     (double*) triangles->data,
     924                         (long*) indices->data,
     925                         (int) triangles->dimensions[0]/3);                                                   
    926926
    927927
     
    11031103  {"_polygon_overlap", _polygon_overlap,
    11041104                                 METH_VARARGS, "Print out"},
    1105   {"_polyline_overlap", _polyline_overlap,
     1105  {"_line_intersect", _line_intersect,
    11061106                                 METH_VARARGS, "Print out"},                               
    11071107  {"_is_inside_triangle", _is_inside_triangle,
Note: See TracChangeset for help on using the changeset viewer.