]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix bugs
authorJérôme <jerome.lucas@cesgenslab.fr>
Fri, 9 Oct 2020 12:12:38 +0000 (14:12 +0200)
committerJérôme <jerome.lucas@cesgenslab.fr>
Fri, 9 Oct 2020 12:12:38 +0000 (14:12 +0200)
src/ExchangeAPI/CMakeLists.txt
src/ExchangeAPI/ExchangeAPI_Export.cpp
src/ExchangeAPI/ExchangeAPI_Export.h
src/ExchangePlugin/CMakeLists.txt
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/ExchangePlugin/export_widget.xml
src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h

index bdf5bcb345ffd454bd8bde502f7e3765f6bacb81..b61f22ce9a20a675cce9f89aa4cca82e82da9b13 100644 (file)
@@ -33,12 +33,14 @@ SET(PROJECT_SOURCES
 SET(PROJECT_LIBRARIES
   ModelAPI
   ModelHighAPI
+  GeomAlgoAPI
 )
 
 INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/Events
   ${PROJECT_SOURCE_DIR}/src/ModelAPI
   ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
+  ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI
 )
 
 # Plugin headers dependency
index ba11e392054ea5fe888d107ed58c6e8463061d62..d1266f3f71c76ee2b79a87140b77bc1c9724fd2c 100644 (file)
@@ -59,38 +59,39 @@ ExchangeAPI_Export::ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>&
                                        const ModelHighAPI_Selection& theSelectedShape,
                                        double aDeflectionRelative,
                                        double aDeflectionAbsolute,
-                                       const bool anIsRelative, 
+                                       const bool anIsRelative,
                                        const bool anIsASCII)
   : ModelHighAPI_Interface(theFeature)
 {
   initialize();
   fillAttribute("STL", theFeature->string(ExchangePlugin_ExportFeature::EXPORT_TYPE_ID()));
   fillAttribute(theFilePath, theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID()));
-   
+
   if (anIsRelative) {
-    fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(), 
+    fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(),
       theFeature->string(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE()) );
-    fillAttribute(aDeflectionRelative, 
-      theFeature->real(ExchangePlugin_ExportFeature::STL_RELATIVE()) ); 
+    fillAttribute(aDeflectionRelative,
+      theFeature->real(ExchangePlugin_ExportFeature::STL_RELATIVE()) );
   }
   else {
-    fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(), 
+    fillAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(),
       theFeature->string(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE()) );
-    fillAttribute(aDeflectionAbsolute, 
+    fillAttribute(aDeflectionAbsolute,
       theFeature->real(ExchangePlugin_ExportFeature::STL_ABSOLUTE()) );
   }
 
   if(anIsASCII){
-    fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_ASCII(), 
+    fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_ASCII(),
       theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_TYPE()));
   }
   else
   {
-    fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_BINARY(), 
+    fillAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE_BINARY(),
       theFeature->string(ExchangePlugin_ExportFeature::STL_FILE_TYPE()));
   }
-  
-  fillAttribute(theSelectedShape,theFeature->selection(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED()));
+
+  fillAttribute(theSelectedShape,
+                theFeature->selection(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED()));
   fillAttribute("STL", theFeature->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID()));
   execute();
   apply(); // finish operation to make sure the export is done on the current state of the history
@@ -202,7 +203,8 @@ void ExchangeAPI_Export::dump(ModelHighAPI_Dumper& theDumper) const
 
     theDumper <<","<<  stlabsolute() <<","<< stlrelative();
 
-    if (stldeflectionType()->value() == ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE()) {
+    if (stldeflectionType()->value()
+         == ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE()){
       theDumper <<","<< "True";
     }
     else {
@@ -270,7 +272,7 @@ ExportPtr exportToSTL(const std::shared_ptr<ModelAPI_Document> & thePart,
                                           theDeflectionRelative,
                                           theDeflectionAbsolute,
                                           theIsRelative,
-                                          theIsASCII));                                    
+                                          theIsASCII));
 }
 
 ExportPtr exportToXAO(const std::shared_ptr<ModelAPI_Document> & thePart,
index 89f360a07bd641a2945edc7f62b6083e49b3063f..fb6784f57938ba3ff413813d88a993c5e404d350 100644 (file)
@@ -51,24 +51,24 @@ public:
                               const std::string & theFilePath,
                               const std::string & theAuthor = std::string(),
                               const std::string & theGeometryName = std::string());
-  
+
   /// Constructor with values for STL of selected result export.
   EXCHANGEAPI_EXPORT
     explicit ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                 const std::string & theFilePath,
                                 const ModelHighAPI_Selection& theSelectedShape,
-                                double theDeflectionRelative ,
-                                double theDeflectionAbsolute,
-                                const bool theIsRelative,
-                                const bool theIsASCII);
+                                double  aDeflectionRelative ,
+                                double  aDeflectionAbsolute,
+                                const bool anIsRelative,
+                                const bool anIsASCII);
 
   /// Constructor with values for XAO of selected result export.
   EXCHANGEAPI_EXPORT
     explicit ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                const std::string & theFilePath,
-                                const ModelHighAPI_Selection& theResult,
-                                const std::string & theAuthor,
-                                const std::string & theGeometryName = std::string());
+      const std::string & theFilePath,
+      const ModelHighAPI_Selection& theResult,
+      const std::string & theAuthor,
+      const std::string & theGeometryName = std::string());
 
   /// Constructor with values for export in other formats than XAO.
   EXCHANGEAPI_EXPORT
@@ -108,9 +108,11 @@ public:
              ModelAPI_AttributeDouble, /** Absolute */,
              stlfileType, ExchangePlugin_ExportFeature::STL_FILE_TYPE(),
              ModelAPI_AttributeString, /** Type of the stl file*/,
-             stldeflectionTypeabsolute, ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(),
+             stldeflectionTypeabsolute,
+                      ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_ABSOLUTE(),
              ModelAPI_AttributeString, /** Type of the defelection */,
-             stldeflectionTyperelative, ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(),
+             stldeflectionTyperelative,
+                      ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE(),
              ModelAPI_AttributeString, /** Type of the defelection */)
 
   /// Dump wrapped feature
@@ -126,30 +128,30 @@ typedef std::shared_ptr<ExchangeAPI_Export> ExportPtr;
  */
 EXCHANGEAPI_EXPORT
 ExportPtr exportToFile(const std::shared_ptr<ModelAPI_Document> & thePart,
-                       const std::string & theFilePath,
-                       const std::list<ModelHighAPI_Selection> & theSelectionList,
-                       const std::string & theFileFormat = std::string());
+                  const std::string & theFilePath,
+                  const std::list<ModelHighAPI_Selection> & theSelectionList,
+                  const std::string & theFileFormat = std::string());
 
 /**\ingroup CPPHighAPI
  * \brief Exports to XAO file all results of the current document
  */
 EXCHANGEAPI_EXPORT
 ExportPtr exportToXAO(const std::shared_ptr<ModelAPI_Document> & thePart,
-                      const std::string & theFilePath,
-                      const std::string & theAuthor = std::string(),
-                      const std::string & theGeometryName = std::string());
+                 const std::string & theFilePath,
+                 const std::string & theAuthor = std::string(),
+                 const std::string & theGeometryName = std::string());
 
 /**\ingroup CPPHighAPI
  * \brief Exports to STL file the result of the current document
  */
 EXCHANGEAPI_EXPORT
 ExportPtr exportToSTL(const std::shared_ptr<ModelAPI_Document> & thePart,
-                      const std::string & theFilePath,
-                      const ModelHighAPI_Selection& theSelectedShape,
-                      double theDeflectionRelative,
-                      double theDeflectionAbsolute,
-                      const bool theIsRelative,
-                      const bool theIsASCII);
+      const std::string & theFilePath,
+      const ModelHighAPI_Selection& theSelectedShape,
+      double  aDeflectionRelative,
+      double  aDeflectionAbsolute,
+      const bool anIsRelative,
+      const bool anIsASCII);
 
 /**\ingroup CPPHighAPI
 * \brief Exports to XAO file the selected result with groups parts related to it only.
index 67880c8e64ff524ad3394591e577cbc9ae9a4117..3df98beceac4beaa7da4148038a009671167d085 100644 (file)
@@ -31,6 +31,7 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Events
                     ${PROJECT_SOURCE_DIR}/src/XAO
                     ${PROJECT_SOURCE_DIR}/src/ConstructionPlugin
                     ${PROJECT_SOURCE_DIR}/src/PartSetPlugin
+                    ${OpenCASCADE_INCLUDE_DIR}
 )
 
 SET(PROJECT_HEADERS
index 0205960b13861c868af22444da08a71768953a6d..e81ae860df0abb368483973b515c6d042e66be8b 100644 (file)
@@ -109,7 +109,7 @@ void ExchangePlugin_ExportFeature::initAttributes()
    ModelAPI_AttributeString::typeId());
   data()->addAttribute(ExchangePlugin_ExportFeature::STL_RELATIVE(),
     ModelAPI_AttributeDouble::typeId());
-   
+
   double defelection = Config_PropManager::real("Visualization", "body_deflection");
   real(ExchangePlugin_ExportFeature::STL_RELATIVE())->setValue(defelection);
 
index d0fcd396732e1af826ff698174cf181b34d2a8ee..83b9aba4d627ce67e2b655512c2131e9fb49763e 100644 (file)
@@ -52,7 +52,7 @@
               tooltip="Calculate by size of shape">
             <doublevalue id="stl_relative"
               tooltip="Relative value."
-              min="0.0"
+              min="1e-12"
               step="0.001"
               default="0.001">
             </doublevalue>
index bf30792b239f5cda3d8ad52c507b0615cc37a8bf..a11aa6565795f9bf2e52aec8eba559da10606d78 100644 (file)
@@ -72,8 +72,10 @@ bool STLExport(const std::string& theFileName,
     }
     //Compute triangulation
     BRepMesh_IncrementalMesh aMesh( aCopyShape, lDeflection );
-    aWriter.Write( aCopyShape, theFileName.c_str() );
-
+    if (!aWriter.Write( aCopyShape, theFileName.c_str())) {
+      theError = "STL Export failed";
+      return false;
+    }
     return true;
   }
   catch( Standard_Failure )
index a08549e06247831f5558b3aa6d40991c5829ee44..7c36584b17a5ddbc0f8750afd1ed871eed8d751b 100644 (file)
@@ -31,7 +31,7 @@ GEOMALGOAPI_EXPORT
 bool STLExport(const std::string& theFileName,
                const std::shared_ptr<GeomAPI_Shape>& theShape,
                const double theDeflection,
-               const bool theIsRelative, 
+               const bool theIsRelative,
                const bool theIsASCII,
                std::string& theError);