]> OCCT Git - occt.git/commitdiff
0033751: Shape Healing - Use static values in case of an absent Resource file IR-2024-07-05
authoranv <anv@opencascade.com>
Thu, 27 Jun 2024 15:09:48 +0000 (16:09 +0100)
committerPasukhin Dmitry <44947322+dpasukhi@users.noreply.github.com>
Mon, 8 Jul 2024 15:28:00 +0000 (17:28 +0200)
If a Resource file with parameters for ShapeFix is absent, use static parameters instead if possible.

src/Resource/Resource_Manager.cxx
src/Resource/Resource_Manager.hxx
src/XSAlgo/XSAlgo_AlgoContainer.cxx

index e773d624d6f9e0ec16f88e743c6744ab6ad14105..7526211ce6b59aaacdc83d00b73f98c21314cd24 100644 (file)
@@ -62,7 +62,8 @@ Resource_Manager::Resource_Manager (const TCollection_AsciiString& theName,
                                     const TCollection_AsciiString& theUserDefaultsDirectory,
                                     const Standard_Boolean theIsVerbose)
 : myName (theName),
-  myVerbose (theIsVerbose)
+  myVerbose (theIsVerbose),
+  myInitialized(Standard_False)
 {
   if (!theDefaultsDirectory.IsEmpty())
   {
@@ -102,7 +103,7 @@ Resource_Manager::Resource_Manager (const TCollection_AsciiString& theName,
 }
 
 Resource_Manager::Resource_Manager(const Standard_CString aName,
-                                  const Standard_Boolean Verbose) : myName(aName), myVerbose(Verbose)
+                                  const Standard_Boolean Verbose) : myName(aName), myVerbose(Verbose), myInitialized(Standard_False)
 {
   OSD_Environment envDebug("ResourceDebug");
   Debug = (!envDebug.Value().IsEmpty()) ;
@@ -157,6 +158,7 @@ void Resource_Manager::Load(const TCollection_AsciiString& thePath,
           << "\". File not found or permission denied." << std::endl;
     return;
   }
+  myInitialized = Standard_True;
   Standard_Integer LineNumber = 1;
   while ((aKind = WhatKindOfLine(File, Token1, Token2)) != Resource_KOL_End) {
     switch (aKind) {
index 0072a4c71fb89337b253f8473c9f91ef65033bfc..6e31ae1e98cc4e43e14d2514a8665f8ddacdef3d 100644 (file)
@@ -116,6 +116,9 @@ public:
 
   //! Returns internal Ref or User map with parameters 
   Standard_EXPORT Resource_DataMapOfAsciiStringAsciiString& GetMap(Standard_Boolean theRefMap = Standard_True);
+
+  //! Returns true if Resource have been found
+  Standard_Boolean IsInitialized() const { return myInitialized; }
   
 private:
 
@@ -129,6 +132,7 @@ private:
   Resource_DataMapOfAsciiStringAsciiString myUserMap;
   Resource_DataMapOfAsciiStringExtendedString myExtStrMap;
   Standard_Boolean myVerbose;
+  Standard_Boolean myInitialized;
 
 };
 
index 9f639cbd687db2f46647d6bce832ab8fcd0d7616..d329d85a01335944c4e974b784cadcfee04acd4c 100644 (file)
@@ -104,17 +104,12 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape(const TopoDS_Shape& theShape,
   if (aContext.IsNull())
   {
     Standard_CString aRscfile = Interface_Static::CVal(thePrscfile);
-    if (aRscfile != nullptr && strlen(aRscfile) == 0)
+    aContext = new ShapeProcess_ShapeContext(theShape, aRscfile);
+    if (!aContext->ResourceManager()->IsInitialized())
     {
-      aContext = new ShapeProcess_ShapeContext(theShape, nullptr);
+      // If resource file wasn't found, use static values instead
       Interface_Static::FillMap(aContext->ResourceManager()->GetMap());
     }
-    else
-    {
-      if (!aRscfile)
-        aRscfile = thePrscfile;
-      aContext = new ShapeProcess_ShapeContext(theShape, aRscfile);
-    }
     aContext->SetDetalisation(theDetalisationLevel);
   }
   aContext->SetNonManifold(theNonManifold);