]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Improvement coding style
authorJérôme <jerome.lucas@cesgenslab.fr>
Wed, 7 Oct 2020 16:21:26 +0000 (18:21 +0200)
committerJérôme <jerome.lucas@cesgenslab.fr>
Wed, 7 Oct 2020 16:21:26 +0000 (18:21 +0200)
src/ExchangeAPI/ExchangeAPI_Export.cpp
src/ExchangeAPI/ExchangeAPI_Export.h
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/ExchangePlugin/export_widget.xml
src/GeomAlgoAPI/GeomAlgoAPI_STLExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STLExport.h

index 4e9b4b9c3a179b7483b33ff121301d5f3690df0e..ba11e392054ea5fe888d107ed58c6e8463061d62 100644 (file)
@@ -199,7 +199,7 @@ void ExchangeAPI_Export::dump(ModelHighAPI_Dumper& theDumper) const
       aBase->selection(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED());
 
     theDumper<<","<< aShapeSelected;
-    
+
     theDumper <<","<<  stlabsolute() <<","<< stlrelative();
 
     if (stldeflectionType()->value() == ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE_RELATIVE()) {
@@ -208,7 +208,7 @@ void ExchangeAPI_Export::dump(ModelHighAPI_Dumper& theDumper) const
     else {
       theDumper <<","<< "False";
     }
-    
+
     if (stlfileType()->value() == ExchangePlugin_ExportFeature::STL_FILE_TYPE_BINARY()) {
       theDumper << "False";
     }
@@ -255,10 +255,10 @@ ExportPtr exportToXAO(const std::shared_ptr<ModelAPI_Document> & thePart,
 ExportPtr exportToSTL(const std::shared_ptr<ModelAPI_Document> & thePart,
       const std::string & theFilePath,
       const ModelHighAPI_Selection& theSelectedShape,
-      double  aDeflectionRelative,
-      double  aDeflectionAbsolute,
-      const bool anIsRelative, 
-      const bool anIsASCII)
+      double  theDeflectionRelative,
+      double  theDeflectionAbsolute,
+      const bool theIsRelative,
+      const bool theIsASCII)
 {
   apply(); // finish previous operation to make sure all previous operations are done
   std::shared_ptr<ModelAPI_Feature> aFeature =
@@ -267,10 +267,10 @@ ExportPtr exportToSTL(const std::shared_ptr<ModelAPI_Document> & thePart,
   return ExportPtr(new ExchangeAPI_Export(aFeature,
                                           theFilePath,
                                           theSelectedShape,
-                                          aDeflectionRelative,
-                                          aDeflectionAbsolute,
-                                          anIsRelative,
-                                          anIsASCII));                                    
+                                          theDeflectionRelative,
+                                          theDeflectionAbsolute,
+                                          theIsRelative,
+                                          theIsASCII));                                    
 }
 
 ExportPtr exportToXAO(const std::shared_ptr<ModelAPI_Document> & thePart,
index d867da1bff66feaacdbbcc285e2b00458078122d..89f360a07bd641a2945edc7f62b6083e49b3063f 100644 (file)
@@ -57,18 +57,18 @@ public:
     explicit ExchangeAPI_Export(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                 const std::string & theFilePath,
                                 const ModelHighAPI_Selection& theSelectedShape,
-                                double  aDeflectionRelative ,
-                                double  aDeflectionAbsolute,
-                                const bool anIsRelative, 
-                                const bool anIsASCII);
+                                double theDeflectionRelative ,
+                                double theDeflectionAbsolute,
+                                const bool theIsRelative,
+                                const bool theIsASCII);
 
   /// 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
@@ -126,30 +126,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  aDeflectionRelative,
-      double  aDeflectionAbsolute,
-      const bool anIsRelative, 
-      const bool anIsASCII);
+                      const std::string & theFilePath,
+                      const ModelHighAPI_Selection& theSelectedShape,
+                      double theDeflectionRelative,
+                      double theDeflectionAbsolute,
+                      const bool theIsRelative,
+                      const bool theIsASCII);
 
 /**\ingroup CPPHighAPI
 * \brief Exports to XAO file the selected result with groups parts related to it only.
index 0d38d857ca1723dc2dcb588318fa9312bab4d1c7..0205960b13861c868af22444da08a71768953a6d 100644 (file)
@@ -103,17 +103,17 @@ void ExchangePlugin_ExportFeature::initAttributes()
     ModelAPI_AttributeSelectionList::typeId());
   data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID(),
     ModelAPI_AttributeString::typeId());
-  data()->addAttribute(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(), 
+  data()->addAttribute(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(),
     ModelAPI_AttributeSelection::typeId());
   data()->addAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE(),
    ModelAPI_AttributeString::typeId());
-  data()->addAttribute(ExchangePlugin_ExportFeature::STL_RELATIVE(), 
+  data()->addAttribute(ExchangePlugin_ExportFeature::STL_RELATIVE(),
     ModelAPI_AttributeDouble::typeId());
    
   double defelection = Config_PropManager::real("Visualization", "body_deflection");
   real(ExchangePlugin_ExportFeature::STL_RELATIVE())->setValue(defelection);
 
-  data()->addAttribute(ExchangePlugin_ExportFeature::STL_ABSOLUTE(), 
+  data()->addAttribute(ExchangePlugin_ExportFeature::STL_ABSOLUTE(),
     ModelAPI_AttributeDouble::typeId());
   data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE(),
    ModelAPI_AttributeString::typeId());
@@ -368,16 +368,15 @@ void ExchangePlugin_ExportFeature::exportSTL(const std::string& theFileName)
 
   if (string(STL_FILE_TYPE())->value() == STL_FILE_TYPE_ASCII()) {
     anIsASCII = true;
-  }            
+  }
   // Perform the export
   std::string anError;
   bool aResult = false;
 
   aResult = STLExport(theFileName,
-                      "STL",
                       aShape,
                       aValue,
-                      anIsRelative, 
+                      anIsRelative,
                       anIsASCII,
                       anError);
 
index d77786ee58dd10b5d03c32907c74c23260c0f9e0..d0fcd396732e1af826ff698174cf181b34d2a8ee 100644 (file)
@@ -42,7 +42,7 @@
       <shape_selector id="stl_object_selected"
                           label="Object"
                           tooltip="Object to export."
-                          shape_types="vertices edges wires faces shells solids compsolids compounds">
+                          shape_types="faces shells solids compsolids compounds">
             <validator id="GeomValidators_Finite"/>
       </shape_selector>
       <groupbox title="Deflection">
@@ -62,8 +62,7 @@
               tooltip="Value indicate by user">
             <doublevalue id="stl_absolute"
               tooltip="Absolute value."
-              min="0.0"
-              max="1.0"
+              min="1e-12"
               step="0.1"
               default="0.5">
             </doublevalue>
           </radio>
         </radiobox>
       </groupbox >
-      <!--stringvalue id="xao_author"
-                   label="Author"
-                   placeholder="Please input the author">
-      </stringvalue>
-      <stringvalue id="xao_geometry_name"
-                   label="Geometry name"
-                   placeholder="Please input the geometry name">
-      </stringvalue-->
     </case>
   </switch>
 </source>
index e7d82b642a068582c46b2cd49f70f944c0123c1c..bf30792b239f5cda3d8ad52c507b0615cc37a8bf 100644 (file)
 #define MAX3(X, Y, Z)   ( MAX2 ( MAX2(X, Y) , Z ) )
 
 bool STLExport(const std::string& theFileName,
-                const std::string& /*theFormatName*/,
-                const std::shared_ptr<GeomAPI_Shape>& theShape,
-                const double aDeflection,
-                const bool anIsRelative, 
-                const bool anIsASCII,
-                std::string& theError)
+               const std::shared_ptr<GeomAPI_Shape>& theShape,
+               const double theDeflection,
+               const bool theIsRelative,
+               const bool theIsASCII,
+               std::string& theError)
 {
   #ifdef _DEBUG
   std::cout << "Export STl into file " << theFileName << std::endl;
@@ -56,25 +55,22 @@ bool STLExport(const std::string& theFileName,
 
   try
   {
-    // Set "C" numeric locale to save numbers correctly
-    GeomAlgoAPI_Tools::Localizer loc;
 
-    double lDeflection = aDeflection;
+    double lDeflection = theDeflection;
     StlAPI_Writer aWriter;
     // copy source shape
     BRepBuilderAPI_Copy aCopy( theShape->impl<TopoDS_Shape>(), Standard_False );
     TopoDS_Shape aCopyShape = aCopy.Shape();
     // ASCII mode
-    aWriter.ASCIIMode() = anIsASCII;
-    if ( anIsRelative ) {
+    aWriter.ASCIIMode() = theIsASCII;
+    if ( theIsRelative ) {
       Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
       Bnd_Box bndBox;
       BRepBndLib::Add( theShape->impl<TopoDS_Shape>(), bndBox );
       bndBox.Get( aXmin, aYmin, aZmin, aXmax, aYmax, aZmax );
-      lDeflection = MAX3( aXmax-aXmin, aYmax-aYmin, aZmax-aZmin ) * aDeflection;
+      lDeflection = MAX3( aXmax-aXmin, aYmax-aYmin, aZmax-aZmin ) * theDeflection;
     }
     //Compute triangulation
-    BRepTools::Clean( aCopyShape );
     BRepMesh_IncrementalMesh aMesh( aCopyShape, lDeflection );
     aWriter.Write( aCopyShape, theFileName.c_str() );
 
index 327dce41e127e009f344d196cc515e8b1b1a00a2..a08549e06247831f5558b3aa6d40991c5829ee44 100644 (file)
 /// Implementation of the export STL files algorithms
 GEOMALGOAPI_EXPORT
 bool STLExport(const std::string& theFileName,
-                const std::string& /*theFormatName*/,
-                const std::shared_ptr<GeomAPI_Shape>& theShape,
-                const double aDeflection,
-                const bool anIsRelative, 
-                const bool anIsASCII,
-                std::string& theError);
+               const std::shared_ptr<GeomAPI_Shape>& theShape,
+               const double theDeflection,
+               const bool theIsRelative, 
+               const bool theIsASCII,
+               std::string& theError);
 
 #endif /* GEOMALGOAPI_STLEXPORT_H_ */