Changeset 3703:585fdac3954d in orange


Ignore:
Timestamp:
05/28/07 09:41:45 (7 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
df6fd67e2cd61c06fa5678f111db2252d5c907e6
Message:

* empty log message *

Location:
source/orangeom
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • source/orangeom/networkoptimization.cpp

    r3691 r3703  
    472472    Py_INCREF(graph->coors); 
    473473    return (PyObject *)graph->coors;   
     474} 
     475 
     476PyObject *NetworkOptimization_closestVertex(PyObject *self, PyObject *args) PYARGS(METH_VARARGS, "(x, y) -> Ndx") 
     477{ 
     478    double x; 
     479    double y; 
     480 
     481    if (!PyArg_ParseTuple(args, "dd:NetworkOptimization.closestVertex", &x, &y)) 
     482        return NULL; 
     483 
     484    CAST_TO(TNetworkOptimization, graph); 
     485 
     486    int i; 
     487    double min = 100000000; 
     488    int ndx = -1; 
     489    for (i=0; i < graph->nVertices; i++) 
     490    { 
     491        double dX = graph->pos[i][0] - x; 
     492        double dY = graph->pos[i][1] - y; 
     493        double d = dX*dX + dY*dY; 
     494 
     495        if (d < min) 
     496        { 
     497            min = d; 
     498            ndx = i; 
     499        } 
     500    } 
     501 
     502    return Py_BuildValue("id", ndx, sqrt(min)); 
    474503} 
    475504 
  • source/orangeom/networkoptimization.hpp

    r3691 r3703  
    8686    } 
    8787 
    88     double k; //PR 
    89     double k2; //PR 
     88    double k;  
     89    double k2;  
    9090    double temperature; 
    9191    double coolFactor; 
    92     double width; //P 
    93     double height; //PR 
     92    double width;  
     93    double height;  
    9494    PyArrayObject *coors; 
    9595 
Note: See TracChangeset for help on using the changeset viewer.