]> SALOME platform Git repositories - plugins/blsurfplugin.git/commitdiff
Salome HOME
rnc: added a parameter for attractors on faces
authorgdd <gdd>
Thu, 27 Jan 2011 13:42:37 +0000 (13:42 +0000)
committergdd <gdd>
Thu, 27 Jan 2011 13:42:37 +0000 (13:42 +0000)
src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx

index b2df4adc09d7454401114eae9c67b50aa9a64967..12d714699b4801bb1548c67e121c5bb24d804901 100644 (file)
@@ -506,15 +506,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
@@ -526,7 +528,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) {
@@ -543,14 +545,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
@@ -572,7 +580,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());
 
index cca2d9ac6972a8c007f6afb166f9b725e343889d..df1f3213684c5eec803ed7c0acdfcbdc3ccb7d42 100644 (file)
@@ -553,9 +553,10 @@ void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char*
   try {
     valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
     if ( valueChanged ) {
-      boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$");
+      //boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$");
+      boost::regex re("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$");
       if (!boost::regex_match(string(attractor), re))
-        throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False)");
+        throw std::invalid_argument("Error: an attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False;d(opt.))");
       this->GetImpl()->SetAttractorEntry(entry, attractor);
     }
   }
index 1a3758e10eae12277298fa7c49706c8c81d7476f..33569f015c51013e43a04aa4138749082e1198e0 100644 (file)
@@ -2063,13 +2063,14 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt
   }
   else if (that->mySMPMap[myEntry].startsWith("ATTRACTOR")) {
 //     MESSAGE("Attractor" );
-    if ((that->mySMPMap[myEntry].count(QRegExp("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$")) != 1)) {
+//  if ((that->mySMPMap[myEntry].count(QRegExp("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)\\)$")) != 1)) {
+    if ((that->mySMPMap[myEntry].count(QRegExp("^ATTRACTOR\\((?:(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+);){5}(True|False)(?:;(-?0(\\.\\d*)*|-?[1-9]+\\d*(\\.\\d*)*|-?\\.(\\d)+))?\\)$")) != 1)) {
 //     if ((that->mySMPMap[myEntry].count('(') != 1) or
 //         (that->mySMPMap[myEntry].count(')') != 1) or
 //         (that->mySMPMap[myEntry].count(';') != 4) or
 //         (that->mySMPMap[myEntry].size() == 15)){
       if (displayError)
-        SUIT_MessageBox::warning( dlg(),"Definition of attractor : Error" ,"An attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False)" );
+        SUIT_MessageBox::warning( dlg(),"Definition of attractor : Error" ,"An attractor is defined with the following pattern: ATTRACTOR(xa;ya;za;a;b;True|False[;d])" );
       return false;
     }
     return true;