From: gdd Date: Thu, 27 Jan 2011 13:42:37 +0000 (+0000) Subject: rnc: added a parameter for attractors on faces X-Git-Tag: Geodesic_attractor_20110218~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1337d823581adca5fdd6ad913a1adfc733fa93db;p=plugins%2Fblsurfplugin.git rnc: added a parameter for attractors on faces --- diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index b2df4ad..12d7146 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -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-("<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); } } diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 1a3758e..33569f0 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -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;