]> SALOME platform Git repositories - plugins/blsurfplugin.git/commitdiff
Salome HOME
Remove empty directory
authorgdd <gdd>
Fri, 18 Feb 2011 09:21:20 +0000 (09:21 +0000)
committergdd <gdd>
Fri, 18 Feb 2011 09:21:20 +0000 (09:21 +0000)
src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx
src/PluginUtils/EMPTY [new file with mode: 0644]

index a854ba395bac663b46d98e671b7492f4b78d7c7f..cb5ec5cb292b4af31bfeebce270a180d7329dcc6 100644 (file)
@@ -130,8 +130,8 @@ static PyMethodDef PyStdOut_methods[] = {
 };
 
 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 */
 };
 
@@ -534,15 +534,17 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction
   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
@@ -554,7 +556,7 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction
   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) {
@@ -571,14 +573,20 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction
   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
@@ -600,7 +608,11 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction
   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());
 
@@ -1681,15 +1693,15 @@ status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data)
     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);
@@ -1716,15 +1728,15 @@ status_t size_on_edge(integer edge_id, real t, real *size, void *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);
@@ -1750,15 +1762,15 @@ status_t size_on_vertex(integer point_id, real *size, void *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);
diff --git a/src/PluginUtils/EMPTY b/src/PluginUtils/EMPTY
new file mode 100644 (file)
index 0000000..e69de29