From 8385c8dc8bcbcb2630484016bc5e97e926f8f835 Mon Sep 17 00:00:00 2001 From: Christophe Bourcier Date: Wed, 6 Jul 2016 11:45:02 +0200 Subject: [PATCH] CEA_1537: remove deprecated precad to be able to use MeshGems 2.3 - removing calls to PreCAD process - PreCAD options are called as CADSurf Options - adding remove_duplicate_cad_faces option as standard option to disable it by default since we can't deactivate all preprocessing tasks as before - removing deprecated basic periodicity --- adm_local/cmake_files/FindMESHGEMS.cmake | 2 - .../config_files/check_MESHGEMS_CADSURF.m4 | 2 +- .../gui/BLSURFPLUGIN/input/blsurf_hypo.doc | 29 +- .../input/blsurfplugin_python_interface.doc | 10 +- idl/BLSURFPlugin_Algorithm.idl | 10 +- src/BLSURFPlugin/BLSURFPluginBuilder.py | 125 +----- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 381 ++---------------- src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx | 12 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 70 +--- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 13 +- .../BLSURFPlugin_Hypothesis_i.cxx | 187 ++------- .../BLSURFPlugin_Hypothesis_i.hxx | 26 +- src/GUI/BLSURFPluginGUI_AdvWidget_QTD.ui | 19 +- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 6 + src/GUI/BLSURFPluginGUI_HypothesisCreator.h | 2 +- src/GUI/BLSURFPlugin_msg_en.ts | 4 + src/GUI/BLSURFPlugin_msg_fr.ts | 4 + tests/test_periodicity.py | 156 ------- tests/test_periodicity_2D.py | 116 ------ tests/test_periodicity_reflexion.py | 128 ------ tests/test_periodicity_reflexion_2D.py | 111 ----- tests/test_precad_intersections.py | 4 +- tests/test_precad_keep_gaps.py | 7 +- tests/test_proximity.py | 7 +- tests/test_quadrangles_gradation.py | 13 +- 25 files changed, 155 insertions(+), 1289 deletions(-) delete mode 100644 tests/test_periodicity.py delete mode 100644 tests/test_periodicity_2D.py delete mode 100644 tests/test_periodicity_reflexion.py delete mode 100644 tests/test_periodicity_reflexion_2D.py diff --git a/adm_local/cmake_files/FindMESHGEMS.cmake b/adm_local/cmake_files/FindMESHGEMS.cmake index 079f0c3..2e62b45 100644 --- a/adm_local/cmake_files/FindMESHGEMS.cmake +++ b/adm_local/cmake_files/FindMESHGEMS.cmake @@ -48,13 +48,11 @@ ELSE() ENDIF(WIN32) FIND_LIBRARY(MESHGEMS_LIBRARY_mg-cadsurf NAMES mg-cadsurf PATH_SUFFIXES ${_plt}) -FIND_LIBRARY(MESHGEMS_LIBRARY_mg-precad NAMES mg-precad PATH_SUFFIXES ${_plt}) FIND_LIBRARY(MESHGEMS_LIBRARY_meshgems NAMES meshgems PATH_SUFFIXES ${_plt}) # TODO: search all components SET(MESHGEMS_LIBRARIES) SET(MESHGEMS_LIBRARIES ${MESHGEMS_LIBRARIES} ${MESHGEMS_LIBRARY_mg-cadsurf}) -SET(MESHGEMS_LIBRARIES ${MESHGEMS_LIBRARIES} ${MESHGEMS_LIBRARY_mg-precad}) IF(MESHGEMS_LIBRARY_meshgems) SET(MESHGEMS_LIBRARIES ${MESHGEMS_LIBRARIES} ${MESHGEMS_LIBRARY_meshgems}) ENDIF(MESHGEMS_LIBRARY_meshgems) diff --git a/adm_local/unix/config_files/check_MESHGEMS_CADSURF.m4 b/adm_local/unix/config_files/check_MESHGEMS_CADSURF.m4 index 6baabd3..2a555a0 100644 --- a/adm_local/unix/config_files/check_MESHGEMS_CADSURF.m4 +++ b/adm_local/unix/config_files/check_MESHGEMS_CADSURF.m4 @@ -74,7 +74,7 @@ if test "$with-meshgems" != "no" ; then if test $archtest = "x86_64" ; then LOCAL_LIBS="-L$MESHGEMS_CADSURF_HOME/lib/Linux_64" fi - LOCAL_LIBS="${LOCAL_LIBS} -lmeshgems -lmg-cadsurf -lmg-precad" + LOCAL_LIBS="${LOCAL_LIBS} -lmeshgems -lmg-cadsurf" CPPFLAGS_old="$CPPFLAGS" CXXFLAGS_old="$CXXFLAGS" diff --git a/doc/salome/gui/BLSURFPLUGIN/input/blsurf_hypo.doc b/doc/salome/gui/BLSURFPLUGIN/input/blsurf_hypo.doc index 81f4075..07ebef7 100644 --- a/doc/salome/gui/BLSURFPLUGIN/input/blsurf_hypo.doc +++ b/doc/salome/gui/BLSURFPLUGIN/input/blsurf_hypo.doc @@ -444,9 +444,7 @@ A group can optionnaly be defined on those enforced vertices. Periodicity is used to have the same discretization on two faces (in 3D) or two edges (in 2D). This is useful for instance for a Representative Volume Element so that the translated meshes share the same nodes on the common faces. -In GUI, periodicity association uses PreCAD (optional MG-CADSurf add-on). You must have a PreCAD license to be able to use it. - -In TUI, advanced users can use CADSurf periodicity via \ref periodicity_tui_basic_api_usage "the basic API" or \ref periodicity_tui_advanced_api_usage "the advanced API". It requires to disable PreCAD. We strongly advise to use PreCAD periodicity instead. +Periodicity association uses PreCAD (MG-CADSurf preprocessor). You don't need an extra PreCAD license. It is included in MG-CADSurf since MeshGems V2.2. \image html blsurf_periodicity_translation.png "Two periodic faces (translation)" @@ -472,36 +470,13 @@ Otherwise, for instance a rotation, the user has to define 3 non-colinear vertic The two methods to define periodicity with PreCAD are (the former name of MG-CADSurf is \a BLSURF and names of the corresponding classes and modules still include \a "BLSURF"): -- BLSURFPluginBuilder.BLSURF_Algorithm.AddPreCadFacesPeriodicity +- BLSURFPluginBuilder.BLSURF_Algorithm.AddPreCadFacesPeriodicity - BLSURFPluginBuilder.BLSURF_Algorithm.AddPreCadEdgesPeriodicity List of source and target vertices to define a transformation are optional. \sa Sample TUI Script of the definition of MG-CADSurf periodicity \ref tui_blsurf_periodicity_preCAD "using preCAD". -\subsection periodicity_tui_basic_api_usage TUI Basic API usage - -In the CADSurf basic API, only available in TUI, the periodicity must be defined face by face, edge by edge and vertex by vertex. - -You must disable PreCAD to use it. Hence, shapes with seam edges will not be meshed correctly. - -The methods are: -- BLSURFPluginBuilder.BLSURF_Algorithm.AddFacePeriodicity -- BLSURFPluginBuilder.BLSURF_Algorithm.AddEdgePeriodicity -- BLSURFPluginBuilder.BLSURF_Algorithm.AddEdgePeriodicityWithoutFaces -- BLSURFPluginBuilder.BLSURF_Algorithm.AddVertexPeriodicity - -Sample TUI Script of the definition of MG-CADSurf periodicity \ref tui_blsurf_periodicity_basic "using basic API (without preCAD)". - -\subsection periodicity_tui_advanced_api_usage TUI Advanced API usage - -To ease the periodicity description, the basic API methods can be called through two advanced methods, given two geom groups and a python geom transformation: - -- BLSURFPluginBuilder.BLSURF_Algorithm.AddAdvancedFacesPeriodicity (in 3D) -- BLSURFPluginBuilder.BLSURF_Algorithm.AddAdvancedEdgesPeriodicity (in 2D) - -Sample TUI Script of the definition of MG-CADSurf periodicity \ref tui_blsurf_periodicity_advanced "using advanced API (without preCAD)". - \ref blsurf_top "Back to top" For more information on MeshGems-CADSurf, you can read its documentation at $MESHGEMS_ROOT_DIR/Docs/mg-cadsurf_user_manual.pdf diff --git a/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc b/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc index 5a4471a..710043e 100644 --- a/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc +++ b/doc/salome/gui/BLSURFPLUGIN/input/blsurfplugin_python_interface.doc @@ -22,19 +22,11 @@ Below you can see examples of usage of this class for 2D mesh generation. \anchor tui_blsurf \anchor example_BLSURFPlugin -

Example of mesh generation with MG-CADSurf algorithm:

+

Example of mesh generation with MG-CADSurf algorithm

\tui_script{blsurfdemo.py} \anchor tui_blsurf_periodicity_preCAD

Example of periodicity definition with preCAD

\tui_script{test_periodicity_precad.py} -\anchor tui_blsurf_periodicity_basic -

Example of basic periodicity definition (without preCAD)

-\tui_script{test_periodicity.py} - -\anchor tui_blsurf_periodicity_advanced -

Example of advanced periodicity definition (without preCAD)

-\tui_script{test_periodicity_reflexion_advanced.py} - */ diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 5310803..aaeb540 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -277,6 +277,12 @@ module BLSURFPlugin void SetPreCADMergeEdges(in boolean toMergeEdges); boolean GetPreCADMergeEdges(); + /*! + * To remove duplicate CAD faces. + */ + void SetPreCADRemoveDuplicateCADFaces(in boolean toRemoveDuplicateCADFaces); + boolean GetPreCADRemoveDuplicateCADFaces(); + /*! * To process 3D topology. */ @@ -457,10 +463,6 @@ module BLSURFPlugin void AddPreCadEdgesPeriodicity(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theEdge2) raises (SALOME::SALOME_Exception); void AddPreCadEdgesPeriodicityWithVertices(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theEdge2, in GEOM::ListOfGO theSourceVertices, in GEOM::ListOfGO theTargetVertices) raises (SALOME::SALOME_Exception); void AddPreCadEdgesPeriodicityEntry(in TEntry theEdge1, in TEntry theEdge2, in TEntryList theSourceVertices, in TEntryList theTargetVertices) raises (SALOME::SALOME_Exception); - void AddFacePeriodicity(in GEOM::GEOM_Object theFace1, in GEOM::GEOM_Object theFace2) raises (SALOME::SALOME_Exception); - void AddEdgePeriodicity(in GEOM::GEOM_Object theFace1, in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theFace2, in GEOM::GEOM_Object theEdge2, in long edge_orientation) raises (SALOME::SALOME_Exception); - void AddEdgePeriodicityWithoutFaces(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theEdge2, in long edge_orientation) raises (SALOME::SALOME_Exception); - void AddVertexPeriodicity(in GEOM::GEOM_Object theEdge1, in GEOM::GEOM_Object theVertex1, in GEOM::GEOM_Object theEdge2, in GEOM::GEOM_Object theVertex2) raises (SALOME::SALOME_Exception); TPeriodicityList GetPreCadFacesPeriodicityVector(); TPeriodicityList GetPreCadEdgesPeriodicityVector(); /////////////////////// diff --git a/src/BLSURFPlugin/BLSURFPluginBuilder.py b/src/BLSURFPlugin/BLSURFPluginBuilder.py index 36e522e..44a8a24 100644 --- a/src/BLSURFPlugin/BLSURFPluginBuilder.py +++ b/src/BLSURFPlugin/BLSURFPluginBuilder.py @@ -199,6 +199,14 @@ class BLSURF_Algorithm(Mesh_Algorithm): self.Parameters().SetPreCADMergeEdges(toMergeEdges) pass + ## To remove duplicate CAD Faces + # @param toRemoveDuplicateCADFaces "merge edges" flag value + def SetPreCADRemoveDuplicateCADFaces(self, toRemoveDuplicateCADFaces=False): + if self.Parameters().GetTopology() != PreCAD: + self.SetTopology(PreCAD) + self.Parameters().SetPreCADRemoveDuplicateCADFaces(toRemoveDuplicateCADFaces) + pass + ## To process 3D topology. # @param toProcess "PreCAD process 3D" flag value def SetPreCADProcess3DTopology(self, toProcess=False): @@ -502,123 +510,6 @@ class BLSURF_Algorithm(Mesh_Algorithm): self.Parameters().AddPreCadEdgesPeriodicity(theEdge1, theEdge2) pass - - #----------------------------------------- - # Periodicity (BLSURF without PreCAD) - #----------------------------------------- - - - ## Defines periodicity between two faces, without using PreCAD. - # User has to call AddEdgePeriodicity with the edges of the face, - # and AddVertexPeriodicity with the vertices of each edge. - # @param theFace1 : GEOM face to associate with theFace2 - # @param theFace2 : GEOM face associated with theFace1 - def AddFacePeriodicity(self, theFace1, theFace2): - self.Parameters().AddFacePeriodicity(theFace1, theFace2) - pass - - ## Defines periodicity between two edges belonging to two periodic faces, without using PreCAD. - # To be used with AddFacePeriodicity. - # User has to call AddVertexPeriodicity with the vertices of each edge - # @param theFace1 : GEOM face to associate with theFace2 - # @param theEdge1 : GEOM edge to associate with theEdge2 - # @param theFace2 : GEOM face associated with theFace1 - # @param theEdge2 : GEOM edge associated with theEdge1 - # @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward) - def AddEdgePeriodicity(self, theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation=0): - self.Parameters().AddEdgePeriodicity(theFace1, theEdge1, theFace2, theEdge2, theEdgeOrientation) - pass - - ## Defines periodicity between two edges without face periodicity, without using PreCAD. - # User has to call AddVertexPeriodicity with the vertices of each edge. - # @param theEdge1 : GEOM edge to associate with theEdge2 - # @param theEdge2 : GEOM edge associated with theEdge1 - # @param theEdgeOrientation : -1 (reversed), 0 (unknown) or 1 (forward) - def AddEdgePeriodicityWithoutFaces(self, theEdge1, theEdge2, theEdgeOrientation=0): - self.Parameters().AddEdgePeriodicityWithoutFaces(theEdge1, theEdge2, theEdgeOrientation) - pass - - ## Defines periodicity between two vertices. - # To be used with AddFacePeriodicity and AddEdgePeriodicity. - # @param theEdge1 : GEOM edge to associate with theEdge2 - # @param theVertex1 : GEOM face to associate with theVertex2 - # @param theEdge2 : GEOM edge associated with theEdge1 - # @param theVertex2 : GEOM face associated with theVertex1 - def AddVertexPeriodicity(self, theEdge1, theVertex1, theEdge2, theVertex2): - self.Parameters().AddVertexPeriodicity(theEdge1, theVertex1, theEdge2, theVertex2) - pass - - ## Define periodicity between two groups of faces, given a transformation function. - # This uses the basic BLSURF API for each face, each edge, and each vertex. - # @param theFace1 : GEOM face (or group, compound) to associate with theFace2 - # @param theFace2 : GEOM face (or group, compound) associated with theFace1 - # @param f_transf : python function defining the transformation between an object of theFace1 - # into an object of theFace2 - def AddAdvancedFacesPeriodicity(self, theFace1, theFace2, f_transf): - source_faces = self.geompyD.SubShapeAll(theFace1, self.geompyD.ShapeType["FACE"]) - i = 0 - j = 0 - k = 0 - for source_face in source_faces: - self.geompyD.addToStudyInFather(theFace1, source_face, "source_face_%i"%i) - p_source = self.geompyD.MakeVertexInsideFace(source_face) - p_target = f_transf(p_source) - target_face = self.geompyD.GetFaceNearPoint(theFace2, p_target) - self.geompyD.addToStudyInFather(theFace2, target_face, "target_face_%i"%i) - self.AddFacePeriodicity(source_face, target_face) - i += 1 - - source_edges = self.geompyD.SubShapeAll(source_face, self.geompyD.ShapeType["EDGE"]) - for source_edge in source_edges: - self.geompyD.addToStudyInFather(theFace1, source_edge, "source_edge_%i"%(j)) - p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5) - p_target = f_transf(p_source) - target_edge = self.geompyD.GetEdgeNearPoint(theFace2, p_target) - self.geompyD.addToStudyInFather(theFace2, target_edge, "target_edge_%i"%(j)) - self.AddEdgePeriodicity(source_face, source_edge, target_face, target_edge, 1) - j += 1 - - source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"]) - for source_vertex in source_vertices: - self.geompyD.addToStudyInFather(theFace1, source_vertex, "source_vertex_%i"%(k)) - target_vertex_tmp = f_transf(source_vertex) - target_vertex = self.geompyD.GetSame(theFace2, target_vertex_tmp) - self.geompyD.addToStudyInFather(theFace2, target_vertex, "target_vertex_%i"%(k)) - self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex) - k += 1 - pass - - ## Define periodicity between two groups of edges, without faces, given a transformation function. - # This uses the basic BLSURF API for each edge and each vertex. - # @param theEdge1 : GEOM edge (or group, compound) to associate with theEdge2 - # @param theEdge2 : GEOM edge (or group, compound) associated with theEdge1 - # @param f_transf : python function defining the transformation between an object of theEdge1 - # into an object of theFace2 - def AddAdvancedEdgesPeriodicity(self, theEdge1, theEdge2, f_transf): - source_edges = self.geompyD.SubShapeAll(theEdge1, self.geompyD.ShapeType["EDGE"]) - j = 0 - k = 0 - for source_edge in source_edges: - self.geompyD.addToStudyInFather(theEdge1, source_edge, "source_edge_%i"%j) - p_source = self.geompyD.MakeVertexOnCurve(source_edge, 0.5) - p_target = f_transf(p_source) - target_edge = self.geompyD.GetEdgeNearPoint(theEdge2, p_target) - self.geompyD.addToStudyInFather(theEdge2, target_edge, "target_edge_%i"%j) - self.AddEdgePeriodicityWithoutFaces(source_edge, target_edge) - - j += 1 - - source_vertices = self.geompyD.SubShapeAll(source_edge, self.geompyD.ShapeType["VERTEX"]) - for source_vertex in source_vertices: - self.geompyD.addToStudyInFather(theEdge1, source_vertex, "source_vertex_%i"%k) - target_vertex_tmp = f_transf(source_vertex) - target_vertex = self.geompyD.GetSame(theEdge2, target_vertex_tmp) - self.geompyD.addToStudyInFather(theEdge2, target_vertex, "target_vertex_%i"%k) - self.AddVertexPeriodicity(source_edge, source_vertex, target_edge, target_vertex) - - k += 1 - pass - #===================== # Obsolete methods #===================== diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 2af4164..521f127 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -31,7 +31,6 @@ extern "C"{ #include #include -#include } #include @@ -768,7 +767,7 @@ void BLSURFPlugin_BLSURF::addCoordsFromVertex(BLSURFPlugin_Hypothesis::TEntry th ///////////////////////////////////////////////////////// void BLSURFPlugin_BLSURF::createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity) { - MESSAGE("BLSURFPlugin_BLSURF::createFacesPeriodicity"); + MESSAGE("BLSURFPlugin_BLSURF::createPreCadFacesPeriodicity"); TopoDS_Shape geomShape1 = entryToShape(preCadPeriodicity.shape1Entry); TopoDS_Shape geomShape2 = entryToShape(preCadPeriodicity.shape2Entry); @@ -791,14 +790,14 @@ void BLSURFPlugin_BLSURF::createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape _preCadFacesIDsPeriodicityVector.push_back(preCadFacesPeriodicityIDs); MESSAGE("_preCadFacesIDsPeriodicityVector.size() = " << _preCadFacesIDsPeriodicityVector.size()); - MESSAGE("BLSURFPlugin_BLSURF::createFacesPeriodicity END"); + MESSAGE("BLSURFPlugin_BLSURF::createPreCadFacesPeriodicity END"); } ///////////////////////////////////////////////////////// void BLSURFPlugin_BLSURF::createPreCadEdgesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity) { - MESSAGE("BLSURFPlugin_BLSURF::createEdgesPeriodicity"); + MESSAGE("BLSURFPlugin_BLSURF::createPreCadEdgesPeriodicity"); TopoDS_Shape geomShape1 = entryToShape(preCadPeriodicity.shape1Entry); TopoDS_Shape geomShape2 = entryToShape(preCadPeriodicity.shape2Entry); @@ -815,125 +814,16 @@ void BLSURFPlugin_BLSURF::createPreCadEdgesPeriodicity(TopoDS_Shape theGeomShape _preCadEdgesIDsPeriodicityVector.push_back(preCadEdgesPeriodicityIDs); MESSAGE("_preCadEdgesIDsPeriodicityVector.size() = " << _preCadEdgesIDsPeriodicityVector.size()); - MESSAGE("BLSURFPlugin_BLSURF::createEdgesPeriodicity END"); - -} - -///////////////////////////////////////////////////////// -void BLSURFPlugin_BLSURF::createFacesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theFace1, BLSURFPlugin_Hypothesis::TEntry theFace2) -{ - MESSAGE("BLSURFPlugin_BLSURF::createFacesPeriodicity"); - - TopoDS_Shape GeomShape1 = entryToShape(theFace1); - TopoDS_Shape GeomShape2 = entryToShape(theFace2); - - TListOfIDs theFace1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomShape1, TopAbs_FACE); - TListOfIDs theFace2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomShape2, TopAbs_FACE); - - // Only one face id, since only a face can be selected - int theFace1_id = theFace1_ids[0]; - int theFace2_id = theFace2_ids[0]; - - std::pair pairOfFacesID = std::make_pair(theFace1_id, theFace2_id); - - _facesIDsPeriodicityVector.push_back(pairOfFacesID); - MESSAGE("_facesIDsPeriodicityVector.size() = " << _facesIDsPeriodicityVector.size()); - MESSAGE("BLSURFPlugin_BLSURF::createFacesPeriodicity END"); + MESSAGE("BLSURFPlugin_BLSURF::createPreCadEdgesPeriodicity END"); } -///////////////////////////////////////////////////////// -void BLSURFPlugin_BLSURF::createEdgesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theFace1, BLSURFPlugin_Hypothesis::TEntry theEdge1, - BLSURFPlugin_Hypothesis::TEntry theFace2, BLSURFPlugin_Hypothesis::TEntry theEdge2, int edge_orientation) -{ - MESSAGE("BLSURFPlugin_BLSURF::createEdgesPeriodicity"); - - TEdgePeriodicityIDs edgePeriodicityIDs; - - if (theFace1 != "") - { - TopoDS_Shape GeomFace1 = entryToShape(theFace1); - TListOfIDs theFace1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomFace1, TopAbs_FACE); - // Only one face id, since only a face can be selected - edgePeriodicityIDs.theFace1ID = theFace1_ids[0]; - } - else - edgePeriodicityIDs.theFace1ID = 0; - if (theFace2 != "") - { - TopoDS_Shape GeomFace2 = entryToShape(theFace2); - TListOfIDs theFace2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomFace2, TopAbs_FACE); - edgePeriodicityIDs.theFace2ID = theFace2_ids[0]; - } - else - edgePeriodicityIDs.theFace2ID = 0; - - TopoDS_Shape GeomEdge1 = entryToShape(theEdge1); - TopoDS_Shape GeomEdge2 = entryToShape(theEdge2); - - TListOfIDs theEdge1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge1, TopAbs_EDGE); - TListOfIDs theEdge2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge2, TopAbs_EDGE); - - if (edge_orientation == 0 && GeomEdge1.Closed()) - { - // if edge is closed, we have to set its orientation - MESSAGE("GeomEdge1.Orientation() = " << GeomEdge1.Orientation()); - MESSAGE("GeomEdge2.Orientation() = " << GeomEdge2.Orientation()); - if(GeomEdge1.Orientation() == TopAbs_FORWARD) - edge_orientation = CAD_ORIENTATION_REVERSED; - else - edge_orientation = CAD_ORIENTATION_FORWARD; - } - - // Only one edge id, since only a edge can be selected - edgePeriodicityIDs.theEdge1ID = theEdge1_ids[0]; - edgePeriodicityIDs.theEdge2ID = theEdge2_ids[0]; - edgePeriodicityIDs.edge_orientation = edge_orientation; - - _edgesIDsPeriodicityVector.push_back(edgePeriodicityIDs); - MESSAGE("_edgesIDsPeriodicityVector.size() = " << _edgesIDsPeriodicityVector.size()); - MESSAGE("BLSURFPlugin_BLSURF::createEdgesPeriodicity END"); - -} - - -///////////////////////////////////////////////////////// -void BLSURFPlugin_BLSURF::createVerticesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theEdge1, BLSURFPlugin_Hypothesis::TEntry theVertex1, - BLSURFPlugin_Hypothesis::TEntry theEdge2, BLSURFPlugin_Hypothesis::TEntry theVertex2) -{ - MESSAGE("BLSURFPlugin_BLSURF::createVerticesPeriodicity"); - - TopoDS_Shape GeomEdge1 = entryToShape(theEdge1); - TopoDS_Shape GeomVertex1 = entryToShape(theVertex1); - TopoDS_Shape GeomEdge2 = entryToShape(theEdge2); - TopoDS_Shape GeomVertex2 = entryToShape(theVertex2); - - TListOfIDs theEdge1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge1, TopAbs_EDGE); - TListOfIDs vertices1_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomVertex1, TopAbs_VERTEX); - TListOfIDs theEdge2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomEdge2, TopAbs_EDGE); - TListOfIDs vertices2_ids = _getSubShapeIDsInMainShape(theGeomShape, GeomVertex2, TopAbs_VERTEX); - - // Only one vertex id, since only a vertex can be selected - TVertexPeriodicityIDs vertexPeriodicityIDs; - vertexPeriodicityIDs.theEdge1ID = theEdge1_ids[0]; - vertexPeriodicityIDs.theVertex1ID = vertices1_ids[0]; - vertexPeriodicityIDs.theEdge2ID = theEdge2_ids[0]; - vertexPeriodicityIDs.theVertex2ID = vertices2_ids[0]; - - _verticesIDsPeriodicityVector.push_back(vertexPeriodicityIDs); - MESSAGE("_verticesIDsPeriodicityVector.size() = " << _verticesIDsPeriodicityVector.size()); - MESSAGE("BLSURFPlugin_BLSURF::createVerticesPeriodicity END"); - -} - ///////////////////////////////////////////////////////// void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, cadsurf_session_t * css, - precad_session_t * pcs, - const TopoDS_Shape& theGeomShape, - bool * use_precad + const TopoDS_Shape& theGeomShape ) { // rnc : Bug 1457 @@ -967,6 +857,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, // PreCAD int _precadMergeEdges = BLSURFPlugin_Hypothesis::GetDefaultPreCADMergeEdges(); + int _precadRemoveDuplicateCADFaces = BLSURFPlugin_Hypothesis::GetDefaultPreCADRemoveDuplicateCADFaces(); int _precadProcess3DTopology = BLSURFPlugin_Hypothesis::GetDefaultPreCADProcess3DTopology(); int _precadDiscardInput = BLSURFPlugin_Hypothesis::GetDefaultPreCADDiscardInput(); @@ -1012,6 +903,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, _topology = (int) hyp->GetTopology(); // PreCAD _precadMergeEdges = hyp->GetPreCADMergeEdges(); + _precadRemoveDuplicateCADFaces = hyp->GetPreCADRemoveDuplicateCADFaces(); _precadProcess3DTopology = hyp->GetPreCADProcess3DTopology(); _precadDiscardInput = hyp->GetPreCADDiscardInput(); @@ -1033,17 +925,15 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, const BLSURFPlugin_Hypothesis::TOptionValues& preCADopts = hyp->GetPreCADOptionValues(); for ( opIt = preCADopts.begin(); opIt != preCADopts.end(); ++opIt ) if ( !opIt->second.empty() ) { - *use_precad = true; - MESSAGE("precad_set_param(): " << opIt->first << " = " << opIt->second); - precad_set_param(pcs, opIt->first.c_str(), opIt->second.c_str()); + MESSAGE("cadsurf_set_param(): " << opIt->first << " = " << opIt->second); + set_param(css, opIt->first.c_str(), opIt->second.c_str()); } const BLSURFPlugin_Hypothesis::TOptionValues& custom_preCADopts = hyp->GetCustomPreCADOptionValues(); for ( opIt = custom_preCADopts.begin(); opIt != custom_preCADopts.end(); ++opIt ) if ( !opIt->second.empty() ) { - *use_precad = true; - MESSAGE("precad_set_param(): " << opIt->first << " = " << opIt->second); - precad_set_param(pcs, opIt->first.c_str(), opIt->second.c_str()); + MESSAGE("cadsurf_set_param(): " << opIt->first << " = " << opIt->second); + set_param(css, opIt->first.c_str(), opIt->second.c_str()); } } // else { @@ -1058,14 +948,12 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, // MESSAGE("BLSURFPlugin_BLSURF::SetParameters using defaults"); // } - // PreCAD - if (_topology == BLSURFPlugin_Hypothesis::PreCAD) { - *use_precad = true; - precad_set_param(pcs, "verbose", val_to_string(_verb).c_str()); - precad_set_param(pcs, "merge_edges", _precadMergeEdges ? "1" : "0"); - precad_set_param(pcs, "process_3d_topology", _precadProcess3DTopology ? "1" : "0"); - precad_set_param(pcs, "discard_input_topology", _precadDiscardInput ? "1" : "0"); - } + // PreProcessor (formerly PreCAD) + set_param(css, "merge_edges", _precadMergeEdges ? "yes" : "no"); + set_param(css, "remove_duplicate_cad_faces", _precadRemoveDuplicateCADFaces ? "yes" : "no"); + set_param(css, "process_3d_topology", _precadProcess3DTopology ? "1" : "0"); + set_param(css, "discard_input_topology", _precadDiscardInput ? "1" : "0"); + // unlimit mesh size (issue 0022266) set_param(css, "max_number_of_points_per_patch", "1000000"); @@ -1417,36 +1305,15 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, } MESSAGE("Setting Size Map on FACES "); -// #if BLSURF_VERSION_LONG < "3.1.1" - cadsurf_data_set_sizemap_iso_cad_face(css, size_on_surface, &_smp_phy_size); -// #else -// if (*use_precad) -// iso_sizemap_f = sizemap_new(c, distene_sizemap_type_iso_cad_face, (void *)size_on_surface, NULL); -// else -// clean_iso_sizemap_f = sizemap_new(c, distene_sizemap_type_iso_cad_face, (void *)size_on_surface, NULL); -// #endif + cadsurf_set_sizemap_iso_cad_face(css, size_on_surface, &_smp_phy_size); if (HasSizeMapOnEdge){ MESSAGE("Setting Size Map on EDGES "); -// #if BLSURF_VERSION_LONG < "3.1.1" - cadsurf_data_set_sizemap_iso_cad_edge(css, size_on_edge, &_smp_phy_size); -// #else -// if (*use_precad) -// iso_sizemap_e = sizemap_new(c, distene_sizemap_type_iso_cad_edge, (void *)size_on_edge, NULL); -// else -// clean_iso_sizemap_e = sizemap_new(c, distene_sizemap_type_iso_cad_edge, (void *)size_on_edge, NULL); -// #endif + cadsurf_set_sizemap_iso_cad_edge(css, size_on_edge, &_smp_phy_size); } if (HasSizeMapOnVertex){ MESSAGE("Setting Size Map on VERTICES "); -// #if BLSURF_VERSION_LONG < "3.1.1" - cadsurf_data_set_sizemap_iso_cad_point(css, size_on_vertex, &_smp_phy_size); -// #else -// if (*use_precad) -// iso_sizemap_p = sizemap_new(c, distene_sizemap_type_iso_cad_point, (void *)size_on_vertex, NULL); -// else -// clean_iso_sizemap_p = sizemap_new(c, distene_sizemap_type_iso_cad_point, (void *)size_on_vertex, NULL); -// #endif + cadsurf_set_sizemap_iso_cad_point(css, size_on_vertex, &_smp_phy_size); } } @@ -1455,9 +1322,6 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, // reset vectors _preCadFacesIDsPeriodicityVector.clear(); _preCadEdgesIDsPeriodicityVector.clear(); - _facesIDsPeriodicityVector.clear(); - _edgesIDsPeriodicityVector.clear(); - _verticesIDsPeriodicityVector.clear(); MESSAGE("SetParameters preCadFacesPeriodicityVector"); const BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadFacesPeriodicityVector = BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(hyp); @@ -1477,44 +1341,6 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, } MESSAGE("_preCadEdgesIDsPeriodicityVector.size() = " << _preCadEdgesIDsPeriodicityVector.size()); - if ( _preCadFacesIDsPeriodicityVector.size() > 0 || _preCadEdgesIDsPeriodicityVector.size() > 0 ) - { - MESSAGE("USING PRECAD FOR PERIODICITY") - *use_precad = true; - precad_set_param(pcs, "verbose", val_to_string(_verb).c_str()); - } - - MESSAGE("SetParameters facesPeriodicityVector"); - const BLSURFPlugin_Hypothesis::TFacesPeriodicityVector facesPeriodicityVector = BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(hyp); - - for (std::size_t i = 0; i_error - // => No need to append msg to _comment - if (status > 0) - { - // TODO: fix the SIGSEGV of COMPERR_WARNING with 2 launches - error(COMPERR_WARNING, _comment); - } - if (status < 0) - { - error(_comment); - } - } - else { - // retrieve the pre-processed CAD object - - // dcad - cleandc = precad_new_dcad(pcs); - if(!cleandc){ - cout << "Unable to retrieve PreCAD result on dcad \n"; - } - else - cout << "PreCAD processing successfull on dcad \n"; - - // cad - cleanc = precad_new_cad(pcs); - if(!cleanc){ - cout << "Unable to retrieve PreCAD result on cad \n"; - } - else - cout << "PreCAD processing successfull on cad \n"; - - // #if BLSURF_VERSION_LONG >= "3.1.1" - // /* We can now get the updated sizemaps (if any) */ - // // if(geo_sizemap_e) - // // clean_geo_sizemap_e = precad_new_sizemap(pcs, geo_sizemap_e); - // // - // // if(geo_sizemap_f) - // // clean_geo_sizemap_f = precad_new_sizemap(pcs, geo_sizemap_f); - // - // if(iso_sizemap_p) - // clean_iso_sizemap_p = precad_new_sizemap(pcs, iso_sizemap_p); - // - // if(iso_sizemap_e) - // clean_iso_sizemap_e = precad_new_sizemap(pcs, iso_sizemap_e); - // - // if(iso_sizemap_f) - // clean_iso_sizemap_f = precad_new_sizemap(pcs, iso_sizemap_f); - // #endif - } - // Now we can delete the PreCAD session - precad_session_delete(pcs); - } - - if (cleandc) { - cout << "Give the pre-processed dcad object to the current MG-CADSurf session \n"; - cadsurf_data_set_dcad(css, cleandc); - } - else { - // Use the original one - cadsurf_data_set_dcad(css, dcad); - } + + // TODO: be able to use a mesh in input. + // See imsh usage in Products/templates/mg-cadsurf_template_common.cpp + // => cadsurf_set_mesh + + // Use the original dcad + cadsurf_set_dcad(css, dcad); - if (cleanc) { - // Give the pre-processed CAD object to the current MG-CADSurf session - cout << "Give the pre-processed CAD object to the current MG-CADSurf session \n"; - cadsurf_data_set_cad(css, cleanc); - } - else { - // Use the original one - cadsurf_data_set_cad(css, c); - } + // Use the original cad + cadsurf_set_cad(css, c); std::cout << std::endl; std::cout << "Beginning of Surface Mesh generation" << std::endl; @@ -2800,10 +2491,10 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, std::cout << std::endl; mesh_t *msh = NULL; - cadsurf_data_get_mesh(css, &msh); + cadsurf_get_mesh(css, &msh); if(!msh){ /* release the mesh object */ - cadsurf_data_regain_mesh(css, msh); + cadsurf_regain_mesh(css, msh); return error(_comment); } @@ -3059,7 +2750,7 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, } /* release the mesh object, the rest is released by cleaner */ - cadsurf_data_regain_mesh(css, msh); + cadsurf_regain_mesh(css, msh); if ( needMerge ) // sew mesh computed by MG-CADSurf with pre-existing mesh { diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index 4b7cd5c..1a98332 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -62,7 +62,6 @@ extern "C"{ #include #include -#include } #include @@ -84,7 +83,7 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { const TopoDS_Shape& aShape, SMESH_Hypothesis::Hypothesis_Status& aStatus); - void SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_session_t *bls, precad_session_t *pcs, const TopoDS_Shape& shape, bool *use_precad); + void SetParameters(const BLSURFPlugin_Hypothesis* hyp, cadsurf_session_t *css, const TopoDS_Shape& shape); virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); @@ -137,10 +136,6 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { TPreCadIDsPeriodicityVector _preCadFacesIDsPeriodicityVector; TPreCadIDsPeriodicityVector _preCadEdgesIDsPeriodicityVector; - TShapesIDsPeriodicityVector _facesIDsPeriodicityVector; - TEdgesIDsPeriodicityVector _edgesIDsPeriodicityVector; - TVerticesIDsPeriodicityVector _verticesIDsPeriodicityVector; - private: bool compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, @@ -156,11 +151,6 @@ class BLSURFPlugin_BLSURF: public SMESH_2D_Algo { void createEnforcedVertexOnFace(TopoDS_Shape FaceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList); void createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity); void createPreCadEdgesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity); - void createFacesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theFace1, BLSURFPlugin_Hypothesis::TEntry theFace2); - void createEdgesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theFace1, BLSURFPlugin_Hypothesis::TEntry theEdge1, - BLSURFPlugin_Hypothesis::TEntry theFace2, BLSURFPlugin_Hypothesis::TEntry theEdge2, int edge_orientation = 0); - void createVerticesPeriodicity(TopoDS_Shape theGeomShape, BLSURFPlugin_Hypothesis::TEntry theEdge1, BLSURFPlugin_Hypothesis::TEntry theVertex1, - BLSURFPlugin_Hypothesis::TEntry theEdge2, BLSURFPlugin_Hypothesis::TEntry theVertex2); void Set_NodeOnEdge(SMESHDS_Mesh* meshDS, const SMDS_MeshNode* node, const TopoDS_Shape& ed); void BRepClass_FaceClassifierPerform(BRepClass_FaceClassifier* fc, const TopoDS_Face& face, const gp_Pnt& P, const Standard_Real Tol); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 607bf09..aad7b60 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -65,6 +65,7 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G _verb(GetDefaultVerbosity()), _topology(GetDefaultTopology()), _preCADMergeEdges(GetDefaultPreCADMergeEdges()), + _preCADRemoveDuplicateCADFaces(GetDefaultPreCADRemoveDuplicateCADFaces()), _preCADProcess3DTopology(GetDefaultPreCADProcess3DTopology()), _preCADDiscardInput(GetDefaultPreCADDiscardInput()), _sizeMap(GetDefaultSizeMap()), @@ -391,6 +392,15 @@ void BLSURFPlugin_Hypothesis::SetPreCADMergeEdges(bool theVal) { } } +//============================================================================= +void BLSURFPlugin_Hypothesis::SetPreCADRemoveDuplicateCADFaces(bool theVal) { + if (theVal != _preCADRemoveDuplicateCADFaces) { +// SetTopology(PreCAD); + _preCADRemoveDuplicateCADFaces = theVal; + NotifySubMeshesHypothesisModification(); + } +} + //============================================================================= void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal) { if (theVal != _preCADProcess3DTopology) { @@ -1359,58 +1369,6 @@ void BLSURFPlugin_Hypothesis::AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TE NotifySubMeshesHypothesisModification(); } -//======================================================================= -//function : AddFacePeriodicity -//======================================================================= -void BLSURFPlugin_Hypothesis::AddFacePeriodicity(TEntry theFace1Entry, TEntry theFace2Entry) { - - std::pair< TEntry, TEntry > pairOfFacesEntries = std::make_pair(theFace1Entry, theFace2Entry); - - _facesPeriodicityVector.push_back(pairOfFacesEntries); - - // Removed for performance reason since AddFacePeriodicity is called multiple times (one time for each face) - // Does not affect the behaviour since it is only called via python, not via GUI. - //NotifySubMeshesHypothesisModification(); -} - - -//======================================================================= -//function : AddEdgePeriodicity -//======================================================================= -void BLSURFPlugin_Hypothesis::AddEdgePeriodicity(TEntry theFace1Entry, TEntry theEdge1Entry, TEntry theFace2Entry, TEntry theEdge2Entry, int edge_orientation) { - - TEdgePeriodicity edgePeriodicity; - edgePeriodicity.theFace1Entry = theFace1Entry; - edgePeriodicity.theEdge1Entry = theEdge1Entry; - edgePeriodicity.theFace2Entry = theFace2Entry; - edgePeriodicity.theEdge2Entry = theEdge2Entry; - edgePeriodicity.edge_orientation = edge_orientation; - - _edgesPeriodicityVector.push_back(edgePeriodicity); - - // Removed for performance reason since AddEdgePeriodicity is called multiple times (one time for each edge) - // Does not affect the behaviour since it is only called via python, not via GUI. - //NotifySubMeshesHypothesisModification(); -} - -//======================================================================= -//function : AddVertexPeriodicity -//======================================================================= -void BLSURFPlugin_Hypothesis::AddVertexPeriodicity(TEntry theEdge1Entry, TEntry theVertex1Entry, TEntry theEdge2Entry, TEntry theVertex2Entry) { - - TVertexPeriodicity vertexPeriodicity; - vertexPeriodicity.theEdge1Entry = theEdge1Entry; - vertexPeriodicity.theVertex1Entry = theVertex1Entry; - vertexPeriodicity.theEdge2Entry = theEdge2Entry; - vertexPeriodicity.theVertex2Entry = theVertex2Entry; - - _verticesPeriodicityVector.push_back(vertexPeriodicity); - - // Removed for performance reason since AddVertexPeriodicity is called multiple times (one time for each vertex) - // Does not affect the behaviour since it is only called via python, not via GUI. - //NotifySubMeshesHypothesisModification(); -} - //============================================================================= std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) { // We must keep at least the same number of arguments when increasing the SALOME version @@ -1449,7 +1407,7 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) { save << " " << (int) _phySizeRel << " " << (int) _minSizeRel << " " << (int) _maxSizeRel << " " << _chordalError ; save << " " << (int) _anisotropic << " " << _anisotropicRatio << " " << (int) _removeTinyEdges << " " << _tinyEdgeLength ; save << " " << (int) _badElementRemoval << " " << _badElementAspectRatio << " " << (int) _optimizeMesh << " " << (int) _quadraticMesh ; - save << " " << (int) _preCADProcess3DTopology; + save << " " << (int) _preCADProcess3DTopology << " " << (int) _preCADRemoveDuplicateCADFaces; op_val = _option2value.begin(); if (op_val != _option2value.end()) { @@ -1987,6 +1945,12 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { else load.clear(std::ios::badbit | load.rdstate()); + isOK = static_cast(load >> i); + if (isOK) + _preCADRemoveDuplicateCADFaces = (bool) i; + else + load.clear(std::ios::badbit | load.rdstate()); + } diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index bd0ba59..0988a6e 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -134,6 +134,9 @@ public: void SetPreCADMergeEdges(bool theVal); bool GetPreCADMergeEdges() const { return _preCADMergeEdges; } + void SetPreCADRemoveDuplicateCADFaces(bool theVal); + bool GetPreCADRemoveDuplicateCADFaces() const { return _preCADRemoveDuplicateCADFaces; } + void SetPreCADProcess3DTopology(bool theVal); bool GetPreCADProcess3DTopology() const { return _preCADProcess3DTopology; } @@ -365,8 +368,9 @@ public: static int GetDefaultVerbosity() { return 3; } static Topology GetDefaultTopology() { return FromCAD; } // PreCAD - static bool GetDefaultPreCADMergeEdges() { return true; } - static bool GetDefaultPreCADProcess3DTopology() { return true; } + static bool GetDefaultPreCADMergeEdges() { return false; } + static bool GetDefaultPreCADRemoveDuplicateCADFaces() { return false; } + static bool GetDefaultPreCADProcess3DTopology() { return false; } static bool GetDefaultPreCADDiscardInput() { return false; } static TSizeMap GetDefaultSizeMap() { return TSizeMap();} @@ -416,10 +420,6 @@ public: void AddPreCadEdgesPeriodicity(TEntry theEdge1Entry, TEntry theEdge2Entry, std::vector &theSourceVerticesEntries, std::vector &theTargetVerticesEntries); - void AddFacePeriodicity(TEntry theFace1Entry, TEntry theFace2Entry); - void AddEdgePeriodicity(TEntry theFace1Entry, TEntry theEdge1Entry, TEntry theFace2Entry, TEntry theEdge2Entry, int edge_orientation = 0); - void AddVertexPeriodicity(TEntry theEdge1Entry, TEntry theVertex1Entry, TEntry theEdge2Entry, TEntry theVertex2Entry); - static double undefinedDouble() { return -1.0; } typedef std::map< std::string, std::string > TOptionValues; @@ -496,6 +496,7 @@ private: Topology _topology; bool _preCADMergeEdges; + bool _preCADRemoveDuplicateCADFaces; bool _preCADProcess3DTopology; bool _preCADDiscardInput; double _preCADEpsNano; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx index 07daee8..a8f3cd0 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx @@ -644,6 +644,34 @@ CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADMergeEdges() { return this->GetImpl()->GetPreCADMergeEdges(); } +//============================================================================= +/*! + * BLSURFPlugin_Hypothesis_i::SetPreCADRemoveDuplicateCADFaces + * + * Set true or false + */ +//============================================================================= +void BLSURFPlugin_Hypothesis_i::SetPreCADRemoveDuplicateCADFaces(CORBA::Boolean theValue) { + // MESSAGE("BLSURFPlugin_Hypothesis_i::SetPreCADRemoveDuplicateCADFaces"); + ASSERT(myBaseImpl); + this->GetImpl()->SetPreCADRemoveDuplicateCADFaces(theValue); + std::string theValueStr = theValue ? "True" : "False"; + SMESH::TPythonDump() << _this() << ".SetPreCADRemoveDuplicateCADFaces( " << theValueStr.c_str() << " )"; +} + +//============================================================================= +/*! + * BLSURFPlugin_Hypothesis_i::GetPreCADRemoveDuplicateCADFaces + * + * Get true or false + */ +//============================================================================= +CORBA::Boolean BLSURFPlugin_Hypothesis_i::GetPreCADRemoveDuplicateCADFaces() { + // MESSAGE("BLSURFPlugin_Hypothesis_i::GetPreCADRemoveDuplicateCADFaces"); + ASSERT(myBaseImpl); + return this->GetImpl()->GetPreCADRemoveDuplicateCADFaces(); +} + //============================================================================= /*! * BLSURFPlugin_Hypothesis_i::SetPreCADProcess3DTopology @@ -3070,165 +3098,6 @@ void BLSURFPlugin_Hypothesis_i::AddPreCadEdgesPeriodicityEntry(const char* theEd MESSAGE("IDL : AddPreCadEdgesPeriodicityEntry END"); } -void BLSURFPlugin_Hypothesis_i::AddFacePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2) - throw (SALOME::SALOME_Exception) -{ - ASSERT(myBaseImpl); - - string prefix1 = "Source_face_"; - CheckShapeType(theFace1, GEOM::FACE); - string theFace1Entry = PublishIfNeeded(theFace1, GEOM::FACE, prefix1); - string prefix2 = "Target_face_"; - CheckShapeType(theFace2, GEOM::FACE); - string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix2); - - MESSAGE("IDL : theFace1->GetName : " << theFace1->GetName()); - MESSAGE("IDL : theFace2->GetName : " << theFace2->GetName()); - MESSAGE("IDL : AddFacePeriodicity( "<< theFace1Entry << ", " << theFace2Entry << ")"); - try { - AddFacePeriodicityEntry(theFace1Entry.c_str(), theFace2Entry.c_str()); - } catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } - - -} - -void BLSURFPlugin_Hypothesis_i::AddFacePeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry) - throw (SALOME::SALOME_Exception){ - - ASSERT(myBaseImpl); - - MESSAGE("IDL : AddFacePeriodicityEntry(" << theFace1Entry << ", " << theFace2Entry << ")"); - this->GetImpl()->AddFacePeriodicity(theFace1Entry, theFace2Entry); - SMESH::TPythonDump pd; - pd << _this() << ".AddFacePeriodicity(" << theFace1Entry << ", " << theFace2Entry << ")"; - MESSAGE("IDL : AddFacePeriodicityEntry END"); -} - - -void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theEdge1, - GEOM::GEOM_Object_ptr theFace2, GEOM::GEOM_Object_ptr theEdge2, - CORBA::Long edge_orientation) - throw (SALOME::SALOME_Exception){ - ASSERT(myBaseImpl); - - string prefix_theFace1 = "Source_face_"; - CheckShapeType(theFace1, GEOM::FACE); - string theFace1Entry = PublishIfNeeded(theFace1, GEOM::FACE, prefix_theFace1); - string prefix_theFace2 = "Target_face_"; - CheckShapeType(theFace2, GEOM::FACE); - string theFace2Entry = PublishIfNeeded(theFace2, GEOM::FACE, prefix_theFace2); - - string prefix_theEdge1 = "Source_edge_"; - CheckShapeType(theEdge1, GEOM::EDGE); - string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix_theEdge1); - string prefix_theEdge2 = "Target_edge_"; - CheckShapeType(theEdge2, GEOM::EDGE); - string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix_theEdge2); - - MESSAGE("IDL : theFace1->GetName : " << theFace1->GetName()); - MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName()); - MESSAGE("IDL : theFace2->GetName : " << theFace2->GetName()); - MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName()); - MESSAGE("IDL : AddEdgePeriodicity( "<< theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", " << theEdge2Entry << ", " << edge_orientation << ")"); - try { - AddEdgePeriodicityEntry(theFace1Entry.c_str(), theEdge1Entry.c_str(), theFace2Entry.c_str(), theEdge2Entry.c_str(), edge_orientation); - } catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } - - -} - -void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicityWithoutFaces(GEOM::GEOM_Object_ptr theEdge1, - GEOM::GEOM_Object_ptr theEdge2, - CORBA::Long edge_orientation) - throw (SALOME::SALOME_Exception){ - ASSERT(myBaseImpl); - - string theFace1Entry = ""; - string theFace2Entry = ""; - - string prefix_theEdge1 = "Source_edge_"; - CheckShapeType(theEdge1, GEOM::EDGE); - string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix_theEdge1); - string prefix_theEdge2 = "Target_edge_"; - CheckShapeType(theEdge2, GEOM::EDGE); - string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix_theEdge2); - - MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName()); - MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName()); - MESSAGE("IDL : AddEdgePeriodicity( "<< theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", " << theEdge2Entry << ", " << edge_orientation << ")"); - try { - AddEdgePeriodicityEntry(theFace1Entry.c_str(), theEdge1Entry.c_str(), theFace2Entry.c_str(), theEdge2Entry.c_str(), edge_orientation); - } catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } - - -} - -void BLSURFPlugin_Hypothesis_i::AddEdgePeriodicityEntry(const char* theFace1Entry, const char* theEdge1Entry, const char* theFace2Entry, const char* theEdge2Entry, const long edge_orientation) - throw (SALOME::SALOME_Exception){ - - ASSERT(myBaseImpl); - - MESSAGE("IDL : AddEdgePeriodicityEntry(" << theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", " << theEdge2Entry << ", " << edge_orientation << ")"); - this->GetImpl()->AddEdgePeriodicity(theFace1Entry, theEdge1Entry, theFace2Entry, theEdge2Entry, edge_orientation); - SMESH::TPythonDump pd; - if (theFace1Entry) - pd << _this() << ".AddEdgePeriodicity(" << theFace1Entry << ", " << theEdge1Entry << ", " << theFace2Entry << ", " << theEdge2Entry << ", " << edge_orientation <<")"; - else - pd << _this() << ".AddEdgePeriodicityWithoutFaces(" << theEdge1Entry << ", " << theEdge2Entry << ", " << edge_orientation <<")"; - MESSAGE("IDL : AddEdgePeriodicityEntry END"); -} - -void BLSURFPlugin_Hypothesis_i::AddVertexPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theVertex1, - GEOM::GEOM_Object_ptr theEdge2, GEOM::GEOM_Object_ptr theVertex2) - throw (SALOME::SALOME_Exception){ - ASSERT(myBaseImpl); - - string prefix_theEdge1 = "Source_edge_"; - CheckShapeType(theEdge1, GEOM::EDGE); - string theEdge1Entry = PublishIfNeeded(theEdge1, GEOM::EDGE, prefix_theEdge1); - string prefix_theEdge2 = "Target_edge_"; - CheckShapeType(theEdge2, GEOM::EDGE); - string theEdge2Entry = PublishIfNeeded(theEdge2, GEOM::EDGE, prefix_theEdge2); - - string prefix_theVertex1 = "Source_vertex_"; - CheckShapeType(theVertex1, GEOM::VERTEX); - string theVertex1Entry = PublishIfNeeded(theVertex1, GEOM::VERTEX, prefix_theVertex1); - string prefix_theVertex2 = "Target_vertex_"; - CheckShapeType(theVertex2, GEOM::VERTEX); - string theVertex2Entry = PublishIfNeeded(theVertex2, GEOM::VERTEX, prefix_theVertex2); - - MESSAGE("IDL : theEdge1->GetName : " << theEdge1->GetName()); - MESSAGE("IDL : theVertex1->GetName : " << theVertex1->GetName()); - MESSAGE("IDL : theEdge2->GetName : " << theEdge2->GetName()); - MESSAGE("IDL : theVertex2->GetName : " << theVertex2->GetName()); - MESSAGE("IDL : AddVertexPeriodicity( "<< theEdge1Entry << ", " << theVertex1Entry << ", " << theEdge2Entry << ", " << theVertex2Entry << ")"); - try { - AddVertexPeriodicityEntry(theEdge1Entry.c_str(), theVertex1Entry.c_str(), theEdge2Entry.c_str(), theVertex2Entry.c_str()); - } catch (SALOME_Exception& ex) { - THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM ); - } - - -} - -void BLSURFPlugin_Hypothesis_i::AddVertexPeriodicityEntry(const char* theEdge1Entry, const char* theVertex1Entry, const char* theEdge2Entry, const char* theVertex2Entry) - throw (SALOME::SALOME_Exception){ - - ASSERT(myBaseImpl); - - MESSAGE("IDL : AddVertexPeriodicityEntry(" << theEdge1Entry << ", " << theVertex1Entry << ", " << theEdge2Entry << ", " << theVertex2Entry << ")"); - this->GetImpl()->AddVertexPeriodicity(theEdge1Entry, theVertex1Entry, theEdge2Entry, theVertex2Entry); - SMESH::TPythonDump pd; - pd << _this() << ".AddVertexPeriodicity(" << theEdge1Entry << ", " << theVertex1Entry << ", " << theEdge2Entry << ", " << theVertex2Entry << ")"; - MESSAGE("IDL : AddVertexPeriodicityEntry END"); -} - //================================================================================ /*! diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx index ead28e4..2d7de6c 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx @@ -111,6 +111,9 @@ public: void SetPreCADMergeEdges(CORBA::Boolean theValue); CORBA::Boolean GetPreCADMergeEdges(); + void SetPreCADRemoveDuplicateCADFaces(CORBA::Boolean theValue); + CORBA::Boolean GetPreCADRemoveDuplicateCADFaces(); + void SetPreCADProcess3DTopology(CORBA::Boolean theValue); CORBA::Boolean GetPreCADProcess3DTopology(); @@ -294,29 +297,6 @@ public: const BLSURFPlugin::TEntryList& theSourceVerticesEntries, const BLSURFPlugin::TEntryList& theTargetVerticesEntries) throw (SALOME::SALOME_Exception); - void AddFacePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theFace2) - throw (SALOME::SALOME_Exception); - - void AddFacePeriodicityEntry(const char* theFace1Entry, const char* theFace2Entry) - throw (SALOME::SALOME_Exception); - - void AddEdgePeriodicity(GEOM::GEOM_Object_ptr theFace1, GEOM::GEOM_Object_ptr theEdge1, - GEOM::GEOM_Object_ptr theFace2, GEOM::GEOM_Object_ptr theEdge2, CORBA::Long edge_orientation = 0) - throw (SALOME::SALOME_Exception); - - void AddEdgePeriodicityWithoutFaces(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theEdge2, CORBA::Long edge_orientation = 0) - throw (SALOME::SALOME_Exception); - - void AddEdgePeriodicityEntry(const char* theFace1Entry, const char* theEdge1Entry, const char* theFace2Entry, const char* theEdge2Entry, const long edge_orientation = 0) - throw (SALOME::SALOME_Exception); - - void AddVertexPeriodicity(GEOM::GEOM_Object_ptr theEdge1, GEOM::GEOM_Object_ptr theVertex1, - GEOM::GEOM_Object_ptr theEdge2, GEOM::GEOM_Object_ptr theVertex2) - throw (SALOME::SALOME_Exception); - - void AddVertexPeriodicityEntry(const char* theEdge1Entry, const char* theVertex1Entry, const char* theEdge2Entry, const char* theVertex2Entry) - throw (SALOME::SALOME_Exception); - /////////////////////// /*! diff --git a/src/GUI/BLSURFPluginGUI_AdvWidget_QTD.ui b/src/GUI/BLSURFPluginGUI_AdvWidget_QTD.ui index 613e221..76d3935 100644 --- a/src/GUI/BLSURFPluginGUI_AdvWidget_QTD.ui +++ b/src/GUI/BLSURFPluginGUI_AdvWidget_QTD.ui @@ -6,7 +6,7 @@ 0 0 - 646 + 653 226 @@ -16,7 +16,7 @@ Qt::Horizontal - + @@ -70,7 +70,7 @@ - + 0 @@ -81,7 +81,7 @@ BLSURF_PRECAD_GROUP - true + false false @@ -114,6 +114,16 @@ + + + + BLSURF_PRECAD_REMOVE_DUPLICATE_CAD_FACES + + + true + + + @@ -169,6 +179,7 @@ rmBtn myPreCADGroupBox myPreCADMergeEdges + myPreCADRemoveDuplicateCADFaces myPreCADProcess3DTopology myPreCADDiscardInput myVerbosity diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 1fe4352..18eec64 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -1835,6 +1835,7 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const myAdvWidget->myVerbosity->setValue( data.myVerbosity ); myAdvWidget->myPreCADGroupBox->setChecked(data.myTopology == PreCAD); myAdvWidget->myPreCADMergeEdges->setChecked( data.myPreCADMergeEdges ); + myAdvWidget->myPreCADRemoveDuplicateCADFaces->setChecked( data.myPreCADRemoveDuplicateCADFaces ); myAdvWidget->myPreCADProcess3DTopology->setChecked( data.myPreCADProcess3DTopology ); myAdvWidget->myPreCADDiscardInput->setChecked( data.myPreCADDiscardInput ); @@ -2065,6 +2066,7 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData h_data.myVerbosity = h->GetVerbosity(); h_data.myTopology = (int) h->GetTopology(); h_data.myPreCADMergeEdges = h->GetPreCADMergeEdges(); + h_data.myPreCADRemoveDuplicateCADFaces = h->GetPreCADRemoveDuplicateCADFaces(); h_data.myPreCADProcess3DTopology = h->GetPreCADProcess3DTopology(); h_data.myPreCADDiscardInput = h->GetPreCADDiscardInput(); @@ -2332,6 +2334,8 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi h->SetTopology( (int) h_data.myTopology ); if ( h->GetPreCADMergeEdges() != h_data.myPreCADMergeEdges ) h->SetPreCADMergeEdges( h_data.myPreCADMergeEdges ); + if ( h->GetPreCADRemoveDuplicateCADFaces() != h_data.myPreCADRemoveDuplicateCADFaces ) + h->SetPreCADRemoveDuplicateCADFaces( h_data.myPreCADRemoveDuplicateCADFaces ); if ( h->GetPreCADProcess3DTopology() != h_data.myPreCADProcess3DTopology ) h->SetPreCADProcess3DTopology( h_data.myPreCADProcess3DTopology ); if ( h->GetPreCADDiscardInput() != h_data.myPreCADDiscardInput ) @@ -2528,6 +2532,7 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes h_data.myVerbosity = myAdvWidget->myVerbosity->value(); h_data.myTopology = myAdvWidget->myPreCADGroupBox->isChecked() ? PreCAD : FromCAD; h_data.myPreCADMergeEdges = myAdvWidget->myPreCADMergeEdges->isChecked(); + h_data.myPreCADRemoveDuplicateCADFaces = myAdvWidget->myPreCADRemoveDuplicateCADFaces->isChecked(); h_data.myPreCADProcess3DTopology = myAdvWidget->myPreCADProcess3DTopology->isChecked(); h_data.myPreCADDiscardInput = myAdvWidget->myPreCADDiscardInput->isChecked(); @@ -2558,6 +2563,7 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes guiHyp += tr("BLSURF_TOPOLOGY") + " = " + QString::number( h_data.myTopology ) + "; "; guiHyp += tr("BLSURF_PRECAD_MERGE_EDGES") + " = " + QString(h_data.myPreCADMergeEdges ? "yes" : "no") + "; "; + guiHyp += tr("BLSURF_PRECAD_REMOVE_DUPLICATE_CAD_FACES") + " = " + QString(h_data.myPreCADRemoveDuplicateCADFaces ? "yes" : "no") + "; "; guiHyp += tr("BLSURF_PRECAD_REMOVE_NANO_EDGES") + " = " + QString(h_data.myPreCADProcess3DTopology ? "yes" : "no") + "; "; guiHyp += tr("BLSURF_PRECAD_DISCARD_INPUT") + " = " + QString(h_data.myPreCADDiscardInput ? "yes" : "no") + "; "; diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h index 48f8675..f2dc0ed 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.h +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.h @@ -169,7 +169,7 @@ typedef struct double myAnisotropicRatio, myTinyEdgeLength, myBadElementAspectRatio; bool myOptimizeMesh, myQuadraticMesh; bool myAllowQuadrangles, mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex,myInternalEnforcedVerticesAllFaces; - bool myPreCADMergeEdges, myPreCADProcess3DTopology, myPreCADDiscardInput; + bool myPreCADMergeEdges, myPreCADRemoveDuplicateCADFaces, myPreCADProcess3DTopology, myPreCADDiscardInput; // bool myGMFFileMode; std::string myGMFFileName, myInternalEnforcedVerticesAllFacesGroup; TEnfVertexList enfVertexList; diff --git a/src/GUI/BLSURFPlugin_msg_en.ts b/src/GUI/BLSURFPlugin_msg_en.ts index 2db2607..4c51af9 100644 --- a/src/GUI/BLSURFPlugin_msg_en.ts +++ b/src/GUI/BLSURFPlugin_msg_en.ts @@ -250,6 +250,10 @@ The smaller this distance is, the closer the mesh is to the exact surface (only BLSURF_PRECAD_MERGE_EDGES Merge edges + + BLSURF_PRECAD_REMOVE_DUPLICATE_CAD_FACES + Remove duplicate CAD Faces + BLSURF_PRECAD_PROCESS_3D_TOPOLOGY Process 3D topology diff --git a/src/GUI/BLSURFPlugin_msg_fr.ts b/src/GUI/BLSURFPlugin_msg_fr.ts index 6bc4feb..e8e71d5 100755 --- a/src/GUI/BLSURFPlugin_msg_fr.ts +++ b/src/GUI/BLSURFPlugin_msg_fr.ts @@ -254,6 +254,10 @@ Plus la distance est petite, plus le maillage sera proche de la surface (disponi BLSURF_PRECAD_MERGE_EDGES Fusionner des arêtes + + BLSURF_PRECAD_REMOVE_DUPLICATE_CAD_FACES + Supprime les faces CAO en double + BLSURF_PRECAD_PROCESS_3D_TOPOLOGY Nettoyer la CAO diff --git a/tests/test_periodicity.py b/tests/test_periodicity.py deleted file mode 100644 index 2828322..0000000 --- a/tests/test_periodicity.py +++ /dev/null @@ -1,156 +0,0 @@ -# -*- coding: utf-8 -*- - -import salome - -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New(salome.myStudy) - -import math - -simple = False - -r = 10 -dist = 10 - -p1 = geompy.MakeVertex(0., 0., 0.) -p2 = geompy.MakeVertex(100., 100., 100.) -box = geompy.MakeBoxTwoPnt(p1, p2) -geompy.addToStudy(box, "box") - -p3 = geompy.MakeVertex(25., 5., 25.) -sphere1 = geompy.MakeSpherePntR(p3, 15.) -geompy.addToStudy(sphere1, "sphere1") - -sphere1_trans = geompy.MakeTranslation(sphere1, 0, 100, 0) -geompy.addToStudy(sphere1_trans, "sphere1_trans") - -sphere1_trans = geompy.MakeTranslation(sphere1, 0, 100, 0) -geompy.addToStudy(sphere1_trans, "sphere1_trans") - -p4 = geompy.MakeVertex(5, 50, 90) -sphere2 = geompy.MakeSpherePntR(p4, 20.) - -sphere2_trans = geompy.MakeTranslation(sphere2, 100, 0, 0) -geompy.addToStudy(sphere2_trans, "sphere2_trans") - -sphere2_trans2 = geompy.MakeTranslation(sphere2, 0, 0, -100) -geompy.addToStudy(sphere2_trans2, "sphere2_trans2") - -sphere2_trans3 = geompy.MakeTranslation(sphere2, 100, 0, -100) -geompy.addToStudy(sphere2_trans3, "sphere2_trans3") - -if simple: - part = box -else: - part = geompy.MakePartition([box], [sphere1, sphere1_trans, sphere2, sphere2_trans, sphere2_trans2, sphere2_trans3]) -geompy.addToStudy(part, "part") - -Vx = geompy.MakeVectorDXDYDZ(1, 0, 0) -Vy = geompy.MakeVectorDXDYDZ(0, 1, 0) -Vz = geompy.MakeVectorDXDYDZ(0, 0, 1) - -left_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vy, GEOM.ST_ON) -left = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(left, left_faces) -geompy.addToStudyInFather(part, left, "left") - -right_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vy, p2, GEOM.ST_ON) -right = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(right, right_faces) -geompy.addToStudyInFather(part, right, "right") - -back_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vx, GEOM.ST_ON) -back = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(back, back_faces) -geompy.addToStudyInFather(part, back, "back") - -front_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vx, p2, GEOM.ST_ON) -front = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(front, front_faces) -geompy.addToStudyInFather(part, front, "front") - -bottom_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vz, GEOM.ST_ON) -bottom = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(bottom, bottom_faces) -geompy.addToStudyInFather(part, bottom, "bottom") - -top_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vz, p2, GEOM.ST_ON) -top = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(top, top_faces) -geompy.addToStudyInFather(part, top, "top") - -sources = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(sources, left_faces) -geompy.UnionList(sources, back_faces) -geompy.UnionList(sources, top_faces) -geompy.addToStudyInFather(part, sources, "sources") - - -# Mesh -# ==== - -import SMESH -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New(salome.myStudy) - -from salome.BLSURFPlugin import BLSURFPluginBuilder - -Mesh = smesh.Mesh(part, "Mesh") - -algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf) -algo2d.SetGeometricMesh( 1 ) -algo2d.SetAngleMesh( 4 ) -algo2d.SetPhySize( 8 ) -algo2d.SetOptionValue( 'periodic_tolerance', '1e-2' ) -# Deactivate PreCAD -algo2d.SetTopology(BLSURFPluginBuilder.FromCAD) - -def proj_x(shape1): - shape2 = geompy.MakeTranslation(shape1, 100, 0., 0) - return shape2 - -def proj_y(shape1): - shape2 = geompy.MakeTranslation(shape1, 0, 100., 0) - return shape2 - -def proj_z(shape1): - shape2 = geompy.MakeTranslation(shape1, 0, 0, 100.) - return shape2 - -algo2d.AddAdvancedFacesPeriodicity(back, front, proj_x) -algo2d.AddAdvancedFacesPeriodicity(left, right, proj_y) -algo2d.AddAdvancedFacesPeriodicity(bottom, top, proj_z) - -gr_left = Mesh.Group(left) -gr_right = Mesh.Group(right) -gr_front = Mesh.Group(front) -gr_back = Mesh.Group(back) -gr_bottom = Mesh.Group(bottom) -gr_top = Mesh.Group(top) - -Mesh.Compute() - -left_translated = Mesh.TranslateObjectMakeMesh( gr_left, SMESH.DirStruct( SMESH.PointStruct ( 0, 100, 0 )), 0, 'left_translated' ) -front_translated = Mesh.TranslateObjectMakeMesh( gr_front, SMESH.DirStruct( SMESH.PointStruct ( -100, 0, 0 )), 0, 'front_translated' ) -bottom_translated = Mesh.TranslateObjectMakeMesh( gr_bottom, SMESH.DirStruct( SMESH.PointStruct ( 0, 0, 100 )), 0, 'bottom_translated' ) - -def checkProjection(gr, mesh_translated, tol=1e-7): - name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0] - mesh_source = smesh.CopyMesh(gr, gr.GetName()) - mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name) - ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol) - coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist] - mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes) - mesh_nodes = mesh_check.GetNodesId() - if len(ll_coincident_nodes) != mesh_translated.NbNodes(): - non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes)) - mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes) - raise Exception("Projection failed for %s"%name) - -checkProjection(gr_right, left_translated) -checkProjection(gr_back, front_translated) -checkProjection(gr_top, bottom_translated) - -salome.sg.updateObjBrowser(0) - diff --git a/tests/test_periodicity_2D.py b/tests/test_periodicity_2D.py deleted file mode 100644 index d5a07bc..0000000 --- a/tests/test_periodicity_2D.py +++ /dev/null @@ -1,116 +0,0 @@ -# -*- coding: iso-8859-1 -*- - -import salome - -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New(salome.myStudy) - -import math - -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) - -Face_1 = geompy.MakeFaceHW(10, 10, 1) -geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) -Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 ) -vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True) -Curve_1 = geompy.MakeInterpol(vertices, True, True) - -part = geompy.MakePartition([Face_1], [Curve_1], Limit=geompy.ShapeType["FACE"]) -geompy.addToStudy(part, "part") - -Vx = geompy.MakeVectorDXDYDZ(1, 0, 0) -Vy = geompy.MakeVectorDXDYDZ(0, 1, 0) -Vz = geompy.MakeVectorDXDYDZ(0, 0, 1) - -p1 = geompy.MakeVertex(-5, -5, 0) -p2 = geompy.MakeVertex(5, 5, 0) -left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON) -left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) -geompy.UnionList(left, left_edges) -geompy.addToStudyInFather(part, left, "left") - -right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON) -right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) -geompy.UnionList(right, right_edges) -geompy.addToStudyInFather(part, right, "right") - -bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON) -bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) -geompy.UnionList(bottom, bottom_edges) -geompy.addToStudyInFather(part, bottom, "bottom") - -top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON) -top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) -geompy.UnionList(top, top_edges) -geompy.addToStudyInFather(part, top, "top") - - -# Mesh -# ==== - -import SMESH -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New(salome.myStudy) - -from salome.BLSURFPlugin import BLSURFPluginBuilder - -Mesh = smesh.Mesh(part, "Mesh") - -algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf) -algo2d.SetVerbosity(10) -#algo2d.SetTopology(smesh.PreCAD) -algo2d.SetGeometricMesh( 1 ) -algo2d.SetAngleMesh( 4 ) -algo2d.SetPhySize( 8 ) -#algo2d.SetGradation(1.05) -algo2d.SetOptionValue( 'periodic_tolerance', '1e-2' ) -# Deactivate PreCAD -algo2d.SetTopology(BLSURFPluginBuilder.FromCAD) - -# Periodicity - -def proj_x(shape1): - shape2 = geompy.MakeTranslation(shape1, 10, 0., 0) - return shape2 - -def proj_y(shape1): - shape2 = geompy.MakeTranslation(shape1, 0, 10., 0) - return shape2 - -algo2d.AddAdvancedEdgesPeriodicity(left, right, proj_x) -algo2d.AddAdvancedEdgesPeriodicity(bottom, top, proj_y) - -Mesh.Compute() - -gr_left = Mesh.Group(left) -gr_right = Mesh.Group(right) -gr_bottom = Mesh.Group(bottom) -gr_top = Mesh.Group(top) - -Mesh.Compute() - -left_translated = Mesh.TranslateObjectMakeMesh( gr_left, SMESH.DirStruct( SMESH.PointStruct ( 10, 0, 0 )), 0, 'left_translated' ) -bottom_translated = Mesh.TranslateObjectMakeMesh( gr_bottom, SMESH.DirStruct( SMESH.PointStruct ( 0, 10, 0 )), 0, 'bottom_translated' ) - -def checkProjection(gr, mesh_translated, tol=1e-7): - name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0] - mesh_source = smesh.CopyMesh(gr, gr.GetName()) - mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name) - ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol) - coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist] - mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes) - mesh_nodes = mesh_check.GetNodesId() - if len(ll_coincident_nodes) != mesh_translated.NbNodes(): - non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes)) - mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes) - raise Exception("Projection failed for %s"%name) - -checkProjection(gr_right, left_translated) -checkProjection(gr_top, bottom_translated) - -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1) diff --git a/tests/test_periodicity_reflexion.py b/tests/test_periodicity_reflexion.py deleted file mode 100644 index 91b79b5..0000000 --- a/tests/test_periodicity_reflexion.py +++ /dev/null @@ -1,128 +0,0 @@ -# -*- coding: utf-8 -*- - -import salome - -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New(salome.myStudy) - -import math - -simple = False - -r = 10 -dist = 10 - -p1 = geompy.MakeVertex(0., 0., 0.) -p2 = geompy.MakeVertex(100., 100., 100.) -box = geompy.MakeBoxTwoPnt(p1, p2) -geompy.addToStudy(box, "box") - -p3 = geompy.MakeVertex(25., 5., 25.) -sphere1 = geompy.MakeSpherePntR(p3, 15.) -geompy.addToStudy(sphere1, "sphere1") - -Vx = geompy.MakeVectorDXDYDZ(1, 0, 0) -Vy = geompy.MakeVectorDXDYDZ(0, 1, 0) -Vz = geompy.MakeVectorDXDYDZ(0, 0, 1) - -p4 = geompy.MakeVertex(100., 0., 0.) -axe = geompy.MakePrismVecH(p4, Vz, 1) -geompy.addToStudy(axe, "axe") - -sphere1_rota = geompy.MakeRotation(sphere1, axe, -math.pi/2.) -geompy.addToStudy(sphere1_rota, "sphere1_rota") - -part = geompy.MakePartition([box], [sphere1, sphere1_rota]) -geompy.addToStudy(part, "part") - -left_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vy, GEOM.ST_ON) -left = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(left, left_faces) -geompy.addToStudyInFather(part, left, "left") - -right_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vy, p2, GEOM.ST_ON) -right = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(right, right_faces) -geompy.addToStudyInFather(part, right, "right") - -back_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vx, GEOM.ST_ON) -back = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(back, back_faces) -geompy.addToStudyInFather(part, back, "back") - -front_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vx, p2, GEOM.ST_ON) -front = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(front, front_faces) -geompy.addToStudyInFather(part, front, "front") - -bottom_faces = geompy.GetShapesOnPlane(part, geompy.ShapeType["FACE"], Vz, GEOM.ST_ON) -bottom = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(bottom, bottom_faces) -geompy.addToStudyInFather(part, bottom, "bottom") - -top_faces = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["FACE"], Vz, p2, GEOM.ST_ON) -top = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(top, top_faces) -geompy.addToStudyInFather(part, top, "top") - -sources = geompy.CreateGroup(part, geompy.ShapeType["FACE"]) -geompy.UnionList(sources, left_faces) -geompy.UnionList(sources, back_faces) -geompy.UnionList(sources, top_faces) -geompy.addToStudyInFather(part, sources, "sources") - - -# Mesh -# ==== - -import SMESH -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New(salome.myStudy) - -from salome.BLSURFPlugin import BLSURFPluginBuilder - -Mesh = smesh.Mesh(part, "Mesh") - -algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf) -algo2d.SetGeometricMesh( 1 ) -algo2d.SetAngleMesh( 4 ) -algo2d.SetPhySize( 8 ) -algo2d.SetOptionValue( 'periodic_tolerance', '1e-2' ) -# Deactivate PreCAD -algo2d.SetTopology(BLSURFPluginBuilder.FromCAD) - -def rota_z(shape1): - shape2 = geompy.MakeRotation(shape1, axe, -math.pi/2) - return shape2 - -algo2d.AddAdvancedFacesPeriodicity(left, front, rota_z) - -gr_left = Mesh.Group(left) -gr_right = Mesh.Group(right) -gr_front = Mesh.Group(front) -gr_back = Mesh.Group(back) -gr_bottom = Mesh.Group(bottom) -gr_top = Mesh.Group(top) - -Mesh.Compute() - -left_rotated = Mesh.RotateObjectMakeMesh( gr_left, axe, -math.pi/2, NewMeshName='left_rotated' ) - -def checkProjection(gr, mesh_translated, tol=1e-7): - name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0] - mesh_source = smesh.CopyMesh(gr, gr.GetName()) - mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name) - ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol) - coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist] - mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes) - mesh_nodes = mesh_check.GetNodesId() - if len(ll_coincident_nodes) != mesh_translated.NbNodes(): - non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes)) - mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes) - raise Exception("Projection failed for %s"%name) - -checkProjection(gr_front, left_rotated) - -salome.sg.updateObjBrowser(0) - diff --git a/tests/test_periodicity_reflexion_2D.py b/tests/test_periodicity_reflexion_2D.py deleted file mode 100644 index 7f9f639..0000000 --- a/tests/test_periodicity_reflexion_2D.py +++ /dev/null @@ -1,111 +0,0 @@ -# -*- coding: iso-8859-1 -*- - -import salome - -import GEOM -from salome.geom import geomBuilder -geompy = geomBuilder.New(salome.myStudy) - -import math - -O = geompy.MakeVertex(0, 0, 0) -OX = geompy.MakeVectorDXDYDZ(1, 0, 0) -OY = geompy.MakeVectorDXDYDZ(0, 1, 0) -OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) - -Face_1 = geompy.MakeFaceHW(10, 10, 1) -geomObj_1 = geompy.MakeMarker(0, 0, 0, 1, 0, 0, 0, 1, 0) -Sketch_1 = geompy.MakeSketcherOnPlane("Sketcher:F -2.5209155082703 -1.4416453838348:TT -1.1105282306671 -2.9872753620148:TT 0.76354801654816 -2.3303825855255:TT 1.9614112377167 -3.0838770866394:TT 3.8354876041412 -1.2677619457245:TT 4.2218952178955 0.644955098629:TT 3.2751967906952 2.5576722621918:TT 0.58966463804245 3.5430111885071:TT -3.7380990982056 3.2338852882385:TT -4.433632850647 0.85747921466827:WW", Face_1 ) -vertices = geompy.ExtractShapes(Sketch_1, geompy.ShapeType["VERTEX"], True) -Curve_1 = geompy.MakeInterpol(vertices, True, True) - -part = geompy.MakePartition([Face_1], [Curve_1], Limit=geompy.ShapeType["FACE"]) -geompy.addToStudy(part, "part") - -Vx = geompy.MakeVectorDXDYDZ(1, 0, 0) -Vy = geompy.MakeVectorDXDYDZ(0, 1, 0) -Vz = geompy.MakeVectorDXDYDZ(0, 0, 1) - -p1 = geompy.MakeVertex(-5, -5, 0) -p2 = geompy.MakeVertex(5, 5, 0) -left_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p1, GEOM.ST_ON) -left = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) -geompy.UnionList(left, left_edges) -geompy.addToStudyInFather(part, left, "left") - -right_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vx, p2, GEOM.ST_ON) -right = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) -geompy.UnionList(right, right_edges) -geompy.addToStudyInFather(part, right, "right") - -bottom_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p1, GEOM.ST_ON) -bottom = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) -geompy.UnionList(bottom, bottom_edges) -geompy.addToStudyInFather(part, bottom, "bottom") - -top_edges = geompy.GetShapesOnPlaneWithLocation(part, geompy.ShapeType["EDGE"], Vy, p2, GEOM.ST_ON) -top = geompy.CreateGroup(part, geompy.ShapeType["EDGE"]) -geompy.UnionList(top, top_edges) -geompy.addToStudyInFather(part, top, "top") - - -# Mesh -# ==== - -import SMESH -from salome.smesh import smeshBuilder -smesh = smeshBuilder.New(salome.myStudy) - -from salome.BLSURFPlugin import BLSURFPluginBuilder - -Mesh = smesh.Mesh(part, "Mesh") - -algo2d = Mesh.Triangle(algo=smeshBuilder.MG_CADSurf) -algo2d.SetVerbosity(1) -#algo2d.SetTopology(smesh.PreCAD) -algo2d.SetGeometricMesh( 1 ) -algo2d.SetAngleMesh( 4 ) -algo2d.SetPhySize( 8 ) -#algo2d.SetGradation(1.05) -algo2d.SetOptionValue( 'periodic_tolerance', '1e-2' ) -# Deactivate PreCAD -algo2d.SetTopology(BLSURFPluginBuilder.FromCAD) - -# Periodicity - -p_axe = geompy.MakeVertex(5, -5, 0) -axe = geompy.MakePrismVecH(p_axe, Vz, 1) -def rota_z(shape1): - shape2 = geompy.MakeRotation(shape1, axe, -math.pi/2) - return shape2 - -algo2d.AddAdvancedEdgesPeriodicity(bottom, right, rota_z) - -Mesh.Compute() - -gr_left = Mesh.Group(left) -gr_right = Mesh.Group(right) -gr_bottom = Mesh.Group(bottom) -gr_top = Mesh.Group(top) - -Mesh.Compute() - -bottom_rotated = Mesh.RotateObjectMakeMesh( gr_bottom, axe, -math.pi/2, NewMeshName='bottom_rotated' ) - -def checkProjection(gr, mesh_translated, tol=1e-7): - name = gr.GetName() + "_" + mesh_translated.GetName().split("_")[0] - mesh_source = smesh.CopyMesh(gr, gr.GetName()) - mesh_check = smesh.Concatenate([mesh_source.GetMesh(), mesh_translated.GetMesh()], 0, name=name) - ll_coincident_nodes = mesh_check.FindCoincidentNodes(tol) - coincident_nodes = [item for sublist in ll_coincident_nodes for item in sublist] - mesh_check.MakeGroupByIds("coincident_nodes", SMESH.NODE, coincident_nodes) - mesh_nodes = mesh_check.GetNodesId() - if len(ll_coincident_nodes) != mesh_translated.NbNodes(): - non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes)) - mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes) - raise Exception("Projection failed for %s"%name) - -checkProjection(gr_right, bottom_rotated) - -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1) diff --git a/tests/test_precad_intersections.py b/tests/test_precad_intersections.py index c4e991b..f492dba 100644 --- a/tests/test_precad_intersections.py +++ b/tests/test_precad_intersections.py @@ -59,7 +59,9 @@ for p in vertices: id_node = Mesh_1.FindNodeClosestTo(x, y, z) nodes.append(id_node) -nodes = set(nodes) +nodes = list(set(nodes)) + +Mesh_1.MakeGroupByIds("nodes", SMESH.NODE, nodes) assert(len(nodes) == 1) diff --git a/tests/test_precad_keep_gaps.py b/tests/test_precad_keep_gaps.py index b23102c..592ce3f 100644 --- a/tests/test_precad_keep_gaps.py +++ b/tests/test_precad_keep_gaps.py @@ -51,15 +51,18 @@ BLSURF_Parameters.SetPhySize( 5 ) Mesh_1.Compute() # Check that vertices are not merged by preCAD preprocessing +# when no preprocessing option has been explicitely called nodes = [] for p in vertices: x, y, z = geompy.PointCoordinates(p) id_node = Mesh_1.FindNodeClosestTo(x, y, z) nodes.append(id_node) -nodes = set(nodes) +nodes = list(set(nodes)) -assert(len(nodes) == 2) +Mesh_1.MakeGroupByIds("nodes", SMESH.NODE, nodes) + +assert len(nodes) == 3, "We should have 3 nodes. We got %i. => The preprocessing has done something, but we did not ask him to."%len(nodes) if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) diff --git a/tests/test_proximity.py b/tests/test_proximity.py index 730f382..ced3cb5 100644 --- a/tests/test_proximity.py +++ b/tests/test_proximity.py @@ -78,14 +78,11 @@ gr_mesh_box = Mesh_1.Group(gr_box_faces) gr_mesh_spheres = Mesh_1.Group(gr_spheres_faces) # Check the minimal area of the box faces to check the proximity -box_ids = gr_mesh_box.GetIDs() -box_areas = [Mesh_1.GetArea(i) for i in box_ids] - -min_area = min(box_areas) +min_area, max_area = Mesh_1.GetMinMax(SMESH.FT_Area, gr_mesh_box) print "min_area: ", min_area -if min_area > 1: +if min_area > 1.5: raise Exception("Wrong minimal area on box. Proximity has not worked.") if salome.sg.hasDesktop(): diff --git a/tests/test_quadrangles_gradation.py b/tests/test_quadrangles_gradation.py index b7fac3c..965e201 100644 --- a/tests/test_quadrangles_gradation.py +++ b/tests/test_quadrangles_gradation.py @@ -8,15 +8,12 @@ geompy = geomBuilder.New(salome.myStudy) import math -area_tolerance = 1e-3 -nb_faces_tolerance = 10 +area_tolerance = 1e-2 +nb_faces_tolerance = 20 ## Return the min and max areas of a mesh def getMinMaxArea(mesh): - faces = mesh.GetElementsByType(SMESH.FACE) - areas = [mesh.GetArea(face) for face in faces] - mini = min(areas) - maxi = max(areas) + mini, maxi = mesh.GetMinMax(SMESH.FT_Area) return mini, maxi O = geompy.MakeVertex(0, 0, 0) @@ -105,14 +102,14 @@ maxi_1_ref = 0.530 if abs(mini_1-mini_1_ref) > area_tolerance: raise Exception("Min area of Mesh_1 incorrect") -if abs(maxi_1-maxi_1_ref) > area_tolerance: +if maxi_1 > maxi_1_ref: raise Exception("Max area of Mesh_1 incorrect") # Check the number of faces of Mesh_1 nb_faces_1 = Mesh_1.NbFaces() nb_faces_1_ref = 1208 -if abs(nb_faces_1-nb_faces_1_ref) > nb_faces_tolerance: +if nb_faces_1 < nb_faces_1_ref: raise Exception("Number of faces of Mesh_1 incorrect") -- 2.39.2