-// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// This library is free software; you can redistribute it and/or
-// modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// Lesser General Public License for more details.
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
//
-// You should have received a copy of the GNU Lesser General Public
-// License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// ---
SalomeApp_Application* anApp = GetSalomeApplication();
if (anApp) {
// MESSAGE("Got Application");
- Engines::Component_var component = anApp->lcc()->FindOrLoad_Component( "FactoryServer","GEOM" );
+ Engines::EngineComponent_var component = anApp->lcc()->FindOrLoad_Component( "FactoryServer","GEOM" );
GEOM::GEOM_Gen_var _geomEngine = GEOM::GEOM_Gen::_narrow(component);
// MESSAGE("Got GEOM engine");
// if the Geom Object is a group
if (aShape->GetType() == GEOM_GROUP){
-// MESSAGE("It's a group");
+// MESSAGE("It's a group");
GEOM::GEOM_IGroupOperations_var aGroupOp = _geomEngine->GetIGroupOperations(myStudy->StudyId());
ShapeType= (TopAbs_ShapeEnum)aGroupOp->GetType(aShape);
- }
+ }
// if not
- else {
+ else {
GEOM_Client* aClient = new GEOM_Client();
if ( aClient && !_geomEngine->_is_nil() ) {
// MESSAGE("GEOM client is OK and GEOM engine is not null");
if (!S.IsNull() && S.ShapeType()==TopAbs_FACE){
TopoDS_Face f=TopoDS::Face(S);
Handle(Geom_Surface) surf = BRep_Tool::Surface(f);
- BRepAdaptor_Surface surf_adap=BRepAdaptor_Surface::BRepAdaptor_Surface(f);
+ BRepAdaptor_Surface surf_adap(f);
/* Global Information */
std::cout << "GLOBAL INFORMATION" << std::endl;
}
+//////////////////////////////////////////
+// Utility functions
+//////////////////////////////////////////
+#include <QLocale>
+#include <QRegExp>
+
+QString PluginUtils::PrintDoubleValue( double theValue, int thePrecision )
+{
+ const double prec = 1e-12;
+
+ if ( qAbs(theValue) < prec )
+ return "0";
+ QString aRes = QLocale().toString( theValue, thePrecision >= 0 ? 'f' : 'g', qAbs( thePrecision ) );
+
+ if ( prec > 0 ) {
+ int p = 0;
+ while ( p < thePrecision ) {
+ QString aRes = QLocale().toString( theValue, thePrecision >= 0 ? 'f' : 'g', qAbs( p++ ) );
+ double v = aRes.toDouble();
+ double err = qAbs( theValue - v );
+ if ( err > 0 && err <= prec )
+ break;
+ }
+ }
+ // remove trailing zeroes
+
+ QRegExp expre( QString( "(%1|%2)[+-]?[0-9]+$" ).arg( QLocale().exponential().toLower(),
+ QLocale().exponential().toUpper() ) );
+
+ int idx = aRes.indexOf( expre );
+ QString aResExp = "";
+ if ( idx >= 0 ) {
+ aResExp = aRes.mid( idx );
+ aRes = aRes.left( idx );
+ }
+
+ if ( aRes.contains( QLocale().decimalPoint() ) )
+ aRes.remove( QRegExp( QString( "(\\%1|0)0*$" ).arg( QLocale().decimalPoint() ) ) );
+
+ return aRes == "-0" ? QString( "0" ) : aRes + aResExp;
+}