MG_ADAPT.hxx
SMESH_Homard.hxx
SMESH_DriverMesh.hxx
- SMESH_DriverStep.hxx
+ SMESH_DriverShape.hxx
)
# --- sources ---
MG_ADAPT.cxx
SMESH_Homard.cxx
SMESH_DriverMesh.cxx
- SMESH_DriverStep.cxx
+ SMESH_DriverShape.cxx
)
# --- rules ---
--- /dev/null
+// Copyright (C) 2007-2021 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
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SMESH_DriverShape.cxx
+// Author : Yoann AUDOUIN, EDF
+// Module : SMESH
+//
+
+#include "SMESH_DriverShape.hxx"
+
+// step include
+#include <STEPControl_Reader.hxx>
+#include <STEPControl_Writer.hxx>
+#include <Interface_Static.hxx>
+
+// Brep include
+#include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+
+//Occ include
+#include <TopoDS.hxx>
+
+#include <boost/filesystem.hpp>
+#include <boost/algorithm/string.hpp>
+namespace fs = boost::filesystem;
+
+/**
+ * @brief Import the content of a shape file (STEP) into a TopDS_Shape object
+ *
+ * @param shape_file the shape file
+ * @param aShape the object
+ *
+ * @return error code
+ */
+int importSTEPShape(const std::string shape_file, TopoDS_Shape& aShape){
+
+ std::cout << "Importing STEP shape from " << shape_file << std::endl;
+ STEPControl_Reader reader;
+ // Forcing Unit in meter
+ Interface_Static::SetCVal("xstep.cascade.unit","M");
+ Interface_Static::SetIVal("read.step.ideas", 1);
+ Interface_Static::SetIVal("read.step.nonmanifold", 1);
+ IFSelect_ReturnStatus aStat = reader.ReadFile(shape_file.c_str());
+ if(aStat != IFSelect_RetDone)
+ std::cout << "Reading error for " << shape_file << std::endl;
+
+ int NbTrans = reader.TransferRoots();
+ // There should be only one shape within the file
+ assert(NbTrans==1);
+ aShape = reader.OneShape();
+
+ return true;
+}
+
+/**
+ * @brief Export the content of a TopoDS_Shape into a shape file (STEP)
+ *
+ * @param shape_file the shape file
+ * @param aShape the object
+ *
+ * @return error code
+ */
+int exportSTEPShape(const std::string shape_file, const TopoDS_Shape& aShape){
+
+ std::cout << "Exporting STEP shape to " << shape_file << std::endl;
+
+ STEPControl_Writer aWriter;
+ // Forcing Unit in meter
+ Interface_Static::SetCVal("xstep.cascade.unit","M");
+ Interface_Static::SetCVal("write.step.unit","M");
+ Interface_Static::SetIVal("write.step.nonmanifold", 1);
+
+ IFSelect_ReturnStatus aStat = aWriter.Transfer(aShape,STEPControl_AsIs);
+ if(aStat != IFSelect_RetDone)
+ std::cout << "Transfer error for " << shape_file << std::endl;
+
+ aStat = aWriter.Write(shape_file.c_str());
+
+ if(aStat != IFSelect_RetDone)
+ std::cout << "Writing error for " << shape_file << std::endl;
+
+ return aStat;
+}
+
+/**
+ * @brief Import the content of a shape file (BREP) into a TopDS_Shape object
+ *
+ * @param shape_file the shape file
+ * @param aShape the object
+ *
+ * @return error code
+ */
+int importBREPShape(const std::string shape_file, TopoDS_Shape& aShape){
+
+ std::cout << "Importing BREP shape from " << shape_file << std::endl;
+ BRep_Builder builder;
+ BRepTools::Read(aShape, shape_file.c_str(), builder);
+
+ return true;
+}
+
+/**
+ * @brief Export the content of a TopoDS_Shape into a shape file (BREP)
+ *
+ * @param shape_file the shape file
+ * @param aShape the object
+ *
+ * @return error code
+ */
+int exportBREPShape(const std::string shape_file, const TopoDS_Shape& aShape){
+
+ std::cout << "Exporting BREP shape to " << shape_file << std::endl;
+ BRepTools::Write(aShape, shape_file.c_str());
+
+ return true;
+}
+
+/**
+ * @brief Import the content of a shape file into a TopDS_Shape object
+ *
+ * @param shape_file the shape file
+ * @param aShape the object
+ *
+ * @return error code
+ */
+int importShape(const std::string shape_file, TopoDS_Shape& aShape){
+ std::string type = fs::path(shape_file).extension().string();
+ boost::algorithm::to_lower(type);
+ if (type == ".brep"){
+ return importBREPShape(shape_file, aShape);
+ } else if (type == ".step"){
+ return importSTEPShape(shape_file, aShape);
+ } else {
+ std::cout << "Unknow format: " << type << std::endl;
+ return false;
+ }
+}
+
+/**
+ * @brief Import the content of a shape file into a TopDS_Shape object
+ *
+ * @param shape_file the shape file
+ * @param aShape the object
+ *
+ * @return error code
+ */
+int exportShape(const std::string shape_file, const TopoDS_Shape& aShape){
+ std::string type = fs::path(shape_file).extension().string();
+ boost::algorithm::to_lower(type);
+ if (type == ".brep"){
+ return exportBREPShape(shape_file, aShape);
+ } else if (type == ".step"){
+ return exportSTEPShape(shape_file, aShape);
+ } else {
+ std::cout << "Unknow format: " << type << std::endl;
+ return false;
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2021 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
+//
+// 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, or (at your option) any later version.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SMESH_DriverShape.hxx
+// Author : Yoann AUDOUIN, EDF
+// Module : SMESH
+//
+
+#ifndef _SMESH_DRIVERSHAPE_HXX_
+#define _SMESH_DRIVERSHAPE_HXX_
+
+#include <string>
+#include <cassert>
+
+class TopoDS_Shape;
+
+int importShape(const std::string shape_file, TopoDS_Shape& aShape);
+int exportShape(const std::string shape_file, const TopoDS_Shape& aShape);
+
+#endif
\ No newline at end of file
+++ /dev/null
-// Copyright (C) 2007-2021 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
-//
-// 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, or (at your option) any later version.
-//
-// 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
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File : SMESH_DriverStep.cxx
-// Author : Yoann AUDOUIN, EDF
-// Module : SMESH
-//
-
-#include "SMESH_DriverStep.hxx"
-
-#include <STEPControl_Reader.hxx>
-#include <STEPControl_Writer.hxx>
-#include <Interface_Static.hxx>
-
-//Occ include
-#include <TopoDS.hxx>
-
-
-/**
- * @brief Compares two shape file (STEP)
- *
- * @param file1 first file
- * @param file2 second file
- *
- * @return true if the files are the same
- */
-bool diffStepFile(std::string file1, std::string file2){
- std::ifstream sfile1(file1);
- std::ifstream sfile2(file2);
- std::string line1, line2;
- int nb_lines = 0;
-
- while(!sfile1.eof() && !sfile2.eof()){
- std::getline(sfile1, line1);
- std::getline(sfile2, line2);
- nb_lines++;
- // Skipping 4th line contain date of creation
- if (nb_lines==4){
- std::cout << "Skipping line" << std::endl;
- continue;
- }
-
- // if lines are different end of read
- if(line1 != line2){
- return false;
- }
-
- }
- // True if we reached the end of both files
- return sfile1.eof() && sfile2.eof();
-}
-
-/**
- * @brief Import the content of a shape file (STEP) into a TopDS_Shape object
- *
- * @param shape_file the shape file
- * @param aShape the object
- *
- * @return error code
- */
-int importShape(const std::string shape_file, TopoDS_Shape& aShape){
-
- std::cout << "Importing shape from " << shape_file << std::endl;
- STEPControl_Reader reader;
- // Forcing Unit in meter
- Interface_Static::SetCVal("xstep.cascade.unit","M");
- Interface_Static::SetIVal("read.step.ideas", 1);
- Interface_Static::SetIVal("read.step.nonmanifold", 1);
- IFSelect_ReturnStatus aStat = reader.ReadFile(shape_file.c_str());
- if(aStat != IFSelect_RetDone)
- std::cout << "Reading error for " << shape_file << std::endl;
-
- int NbTrans = reader.TransferRoots();
- // There should be only one shape within the file
- assert(NbTrans==1);
- aShape = reader.OneShape();
-
- return true;
-}
-
-/**
- * @brief Export the content of a TopoDS_Shape into a shape file (STEP)
- *
- * @param shape_file the shape file
- * @param aShape the object
- *
- * @return error code
- */
-int exportShape(const std::string shape_file, const TopoDS_Shape& aShape){
-
- std::cout << "Exporting shape to " << shape_file << std::endl;
-
- STEPControl_Writer aWriter;
- // Forcing Unit in meter
- Interface_Static::SetCVal("xstep.cascade.unit","M");
- Interface_Static::SetCVal("write.step.unit","M");
- Interface_Static::SetIVal("write.step.nonmanifold", 1);
-
- IFSelect_ReturnStatus aStat = aWriter.Transfer(aShape,STEPControl_AsIs);
- if(aStat != IFSelect_RetDone)
- std::cout << "Transfer error for " << shape_file << std::endl;
-
- aStat = aWriter.Write(shape_file.c_str());
-
- if(aStat != IFSelect_RetDone)
- std::cout << "Writing error for " << shape_file << std::endl;
-
- return aStat;
-}
+++ /dev/null
-// Copyright (C) 2007-2021 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
-//
-// 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, or (at your option) any later version.
-//
-// 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
-//
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-// File : SMESH_DriverStep.hxx
-// Author : Yoann AUDOUIN, EDF
-// Module : SMESH
-//
-
-#ifndef _SMESH_DRIVERSTEP_HXX_
-#define _SMESH_DRIVERSTEP_HXX_
-
-#include <string>
-#include <cassert>
-
-class TopoDS_Shape;
-
-int importShape(const std::string shape_file, TopoDS_Shape& aShape);
-int exportShape(const std::string shape_file, const TopoDS_Shape& aShape);
-bool diffStepFile(std::string file1, std::string file2);
-
-
-#endif
\ No newline at end of file
#define MAX_MED_GROUP_NAME_LENGTH 80
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
int result=pthread_create(&thread, NULL, deleteMeshDS, (void*)_meshDS);
#endif
- fs::remove_all(tmp_folder);
+ //fs::remove_all(tmp_folder);
}
}