Salome HOME
Mantis issue 0021837: [CEA 654] Add new method to make any point inside a face.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_IInsertOperations.cxx
index 1d262172b1eb76cc6845710510c3ffdc5af9c4e6..2a83dd58de47f54c4b43d3ac11d040c41cb8b378 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 
 //=============================================================================
 /*!
- *   constructor:
+ *  constructor
  */
 //=============================================================================
-
 GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, int theDocID)
 : GEOM_IOperations(theEngine, theDocID)
 {
@@ -75,20 +74,17 @@ GEOMImpl_IInsertOperations::GEOMImpl_IInsertOperations(GEOM_Engine* theEngine, i
  *  destructor
  */
 //=============================================================================
-
 GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations()
 {
   MESSAGE("GEOMImpl_IInsertOperations::~GEOMImpl_IInsertOperations");
 }
 
-
-
 //=============================================================================
 /*!
  *  MakeCopy
  */
 //=============================================================================
-Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy(Handle(GEOM_Object) theOriginal)
+Handle(GEOM_Object) GEOMImpl_IInsertOperations::MakeCopy (Handle(GEOM_Object) theOriginal)
 {
   SetErrorCode(KO);
 
@@ -230,7 +226,6 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
   aCI.SetFileName(theFileName);
   aCI.SetFormatName(theFormatName);
   aCI.SetPluginName(aLibName);
-  //cout<<"IIO: theFormatName = "<<theFormatName.ToCString()<<endl;
 
   //Perform the Import
   try {
@@ -256,7 +251,8 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
 
   SetErrorCode(OK);
 
-  if( theFormatName == "IGES_UNIT" ) {
+  // OLD CODE: begin
+  if (theFormatName == "IGES_UNIT") {
     TopoDS_Shape S = aFunction->GetValue();
     TopoDS_Vertex V = TopoDS::Vertex(S);
     gp_Pnt P = BRep_Tool::Pnt(V);
@@ -269,10 +265,42 @@ Handle(GEOM_Object) GEOMImpl_IInsertOperations::Import
     //cout<<"IIO: aUnitName = "<<aUnitName.ToCString()<<endl;
     SetErrorCode(aUnitName);
   }
+  // OLD CODE: end
 
   return result;
 }
 
+//=============================================================================
+/*!
+ *  ReadValue
+ */
+//=============================================================================
+TCollection_AsciiString GEOMImpl_IInsertOperations::ReadValue
+                                 (const TCollection_AsciiString& theFileName,
+                                  const TCollection_AsciiString& theFormatName,
+                                  const TCollection_AsciiString& theParameterName)
+{
+  SetErrorCode(KO);
+
+  TCollection_AsciiString aValue, anError;
+
+  if (theFileName.IsEmpty() || theFormatName.IsEmpty() || theParameterName.IsEmpty()) return aValue;
+
+  Handle(TCollection_HAsciiString) aHLibName;
+  if (!IsSupported(Standard_True, theFormatName.SubString(1,4), aHLibName)) {
+    return aValue;
+  }
+  TCollection_AsciiString aLibName = aHLibName->String();
+
+  aValue = GEOMImpl_ImportDriver::ReadValue(theFileName, aLibName, theParameterName, anError);
+  if (anError.IsEmpty())
+    SetErrorCode(OK);
+  else
+    SetErrorCode(anError.ToCString());
+
+  return aValue;
+}
+
 //=============================================================================
 /*!
  *  ImportTranslators