};
static PyMemberDef PyStdOut_memberlist[] = {
- {(char *)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
- (char *)"flag indicating that a space needs to be printed; used by print"},
+ {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
+ (char*)"flag indicating that a space needs to be printed; used by print"},
{NULL} /* Sentinel */
};
MESSAGE("Attractor function: "<< AttractorFunction);
double xa, ya, za; // Coordinates of attractor point
double a, b; // Attractor parameter
+ double d = 0.;
bool createNode=false; // To create a node on attractor projection
int pos1, pos2;
const char *sep = ";";
// atIt->second has the following pattern:
- // ATTRACTOR(xa;ya;za;a;b)
+ // ATTRACTOR(xa;ya;za;a;b;True|False;d)
// where:
// xa;ya;za : coordinates of attractor
// a : desired size on attractor
// b : distance of influence of attractor
+ // d : distance until which the size remains constant
//
// We search the parameters in the string
// xa
if (pos2!=string::npos) {
ya = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
pos1 = pos2;
- }
+ }
// za
pos2 = AttractorFunction.find(sep, pos1+1);
if (pos2!=string::npos) {
pos2 = AttractorFunction.find(sep, pos1+1);
if (pos2!=string::npos) {
b = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
- pos1 = pos2;
+ pos1 = pos2;
}
// createNode
- pos2 = AttractorFunction.find(")");
+ pos2 = AttractorFunction.find(sep, pos1+1);
if (pos2!=string::npos) {
string createNodeStr = AttractorFunction.substr(pos1+1, pos2-pos1-1);
MESSAGE("createNode: " << createNodeStr);
createNode = (AttractorFunction.substr(pos1+1, pos2-pos1-1) == "True");
+ pos1=pos2;
+ }
+ // d
+ pos2 = AttractorFunction.find(")");
+ if (pos2!=string::npos) {
+ d = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
}
// Get the (u,v) values of the attractor on the face
ostringstream attractorFunctionStream;
attractorFunctionStream << "def f(u,v): return ";
attractorFunctionStream << _smp_phy_size << "-(" << _smp_phy_size <<"-" << a << ")";
- attractorFunctionStream << "*exp(-((u-("<<u0<<"))*(u-("<<u0<<"))+(v-("<<v0<<"))*(v-("<<v0<<")))/(" << b << "*" << b <<"))";
+ //attractorFunctionStream << "*exp(-((u-("<<u0<<"))*(u-("<<u0<<"))+(v-("<<v0<<"))*(v-("<<v0<<")))/(" << b << "*" << b <<"))";
+ // rnc make possible to keep the size constant until
+ // a defined distance distance is expressed as the positiv part
+ // of r-d where r is the distance to (u0,v0)
+ attractorFunctionStream << "*exp(-(0.5*(sqrt((u-"<<u0<<")**2+(v-"<<v0<<")**2)-"<<d<<"+abs(sqrt((u-"<<u0<<")**2+(v-"<<v0<<")**2)-"<<d<<"))/(" << b << "))**2)";
MESSAGE("Python function for attractor:" << std::endl << attractorFunctionStream.str());
assert(Py_IsInitialized());
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
- pyresult = PyObject_CallFunction(FaceId2PythonSmp[face_id],(char *)"(f,f)",uv[0],uv[1]);
+ pyresult = PyObject_CallFunction(FaceId2PythonSmp[face_id],(char*)"(f,f)",uv[0],uv[1]);
double result;
if ( pyresult == NULL){
fflush(stderr);
string err_description="";
new_stderr = newPyStdOut(err_description);
- PySys_SetObject((char *)"stderr", new_stderr);
+ PySys_SetObject((char*)"stderr", new_stderr);
PyErr_Print();
- PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__"));
+ PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
Py_DECREF(new_stderr);
MESSAGE("Can't evaluate f(" << uv[0] << "," << uv[1] << ")" << " error is " << err_description);
result = *((double*)user_data);
assert(Py_IsInitialized());
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
- pyresult = PyObject_CallFunction(EdgeId2PythonSmp[edge_id],(char *)"(f)",t);
+ pyresult = PyObject_CallFunction(EdgeId2PythonSmp[edge_id],(char*)"(f)",t);
double result;
if ( pyresult == NULL){
fflush(stderr);
string err_description="";
new_stderr = newPyStdOut(err_description);
- PySys_SetObject((char *)"stderr", new_stderr);
+ PySys_SetObject((char*)"stderr", new_stderr);
PyErr_Print();
- PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__"));
+ PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
Py_DECREF(new_stderr);
MESSAGE("Can't evaluate f(" << t << ")" << " error is " << err_description);
result = *((double*)user_data);
assert(Py_IsInitialized());
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
- pyresult = PyObject_CallFunction(VertexId2PythonSmp[point_id],(char *)"");
+ pyresult = PyObject_CallFunction(VertexId2PythonSmp[point_id],(char*)"");
double result;
if ( pyresult == NULL){
fflush(stderr);
string err_description="";
new_stderr = newPyStdOut(err_description);
- PySys_SetObject((char *)"stderr", new_stderr);
+ PySys_SetObject((char*)"stderr", new_stderr);
PyErr_Print();
- PySys_SetObject((char *)"stderr", PySys_GetObject((char *)"__stderr__"));
+ PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
Py_DECREF(new_stderr);
MESSAGE("Can't evaluate f()" << " error is " << err_description);
result = *((double*)user_data);