From cf707f97833f90252742469712bc1597c65bcd4f Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 7 Sep 2016 20:55:07 +0300 Subject: [PATCH] 23339: [CEA 1944] PreCAD is not called when an advanced PreCAD option is activated --- src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 16 ++++++++--- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 28 +++++++++++++++++--- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 6 +++-- tests/test_precad_intersections.py | 4 +-- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 00cd2e0..4fa2bec 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -866,7 +866,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, //int _precadMergeEdges = BLSURFPlugin_Hypothesis::GetDefaultPreCADMergeEdges(); int _precadRemoveTinyUVEdges = BLSURFPlugin_Hypothesis::GetDefaultPreCADRemoveTinyUVEdges(); //int _precadRemoveDuplicateCADFaces = BLSURFPlugin_Hypothesis::GetDefaultPreCADRemoveDuplicateCADFaces(); - int _precadProcess3DTopology = BLSURFPlugin_Hypothesis::GetDefaultPreCADProcess3DTopology(); + //int _precadProcess3DTopology = BLSURFPlugin_Hypothesis::GetDefaultPreCADProcess3DTopology(); //int _precadDiscardInput = BLSURFPlugin_Hypothesis::GetDefaultPreCADDiscardInput(); @@ -923,7 +923,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, //_precadMergeEdges = hyp->GetPreCADMergeEdges(); _precadRemoveTinyUVEdges = hyp->GetPreCADRemoveTinyUVEdges(); //_precadRemoveDuplicateCADFaces = hyp->GetPreCADRemoveDuplicateCADFaces(); - _precadProcess3DTopology = hyp->GetPreCADProcess3DTopology(); + //_precadProcess3DTopology = hyp->GetPreCADProcess3DTopology(); //_precadDiscardInput = hyp->GetPreCADDiscardInput(); const BLSURFPlugin_Hypothesis::TOptionValues& opts = hyp->GetOptionValues(); @@ -949,11 +949,15 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, } } + if ( BLSURFPlugin_Hypothesis::HasPreCADOptions( hyp )) + { + cadsurf_set_param(css, "use_precad", "yes" ); // for young versions + } // PreProcessor (formerly PreCAD) -- commented params are preCADoptions (since 0023307) //set_param(css, "merge_edges", _precadMergeEdges ? "yes" : "no"); set_param(css, "remove_tiny_uv_edges", _precadRemoveTinyUVEdges ? "yes" : "no"); //set_param(css, "remove_duplicate_cad_faces", _precadRemoveDuplicateCADFaces ? "yes" : "no"); - set_param(css, "process_3d_topology", _precadProcess3DTopology ? "1" : "0"); + //set_param(css, "process_3d_topology", _precadProcess3DTopology ? "1" : "0"); //set_param(css, "discard_input_topology", _precadDiscardInput ? "1" : "0"); //set_param(css, "max_number_of_points_per_patch", "1000000"); @@ -1362,6 +1366,10 @@ void BLSURFPlugin_BLSURF::set_param(cadsurf_session_t *css, const char * option_value) { status_t status = cadsurf_set_param(css, option_name, option_value ); + + if ( _hypothesis && _hypothesis->GetVerbosity() > _hypothesis->GetDefaultVerbosity() ) + cout << option_name << " = " << option_value << endl; + if ( status != MESHGEMS_STATUS_OK ) { if ( status == MESHGEMS_STATUS_UNKNOWN_PARAMETER ) { @@ -2802,7 +2810,7 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, // Remove free nodes that can appear e.g. if "remove tiny edges"(IPAL53235) for(int iv=1;iv<=nv;iv++) - if ( tags[iv] && nodes[iv] && nodes[iv]->NbInverseElements() == 0 ) + if ( nodes[iv] && nodes[iv]->NbInverseElements() == 0 ) meshDS->RemoveFreeNode( nodes[iv], 0, /*fromGroups=*/false ); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 386d726..d7c494f 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -721,6 +721,7 @@ void BLSURFPlugin_Hypothesis::SetPreCADProcess3DTopology(bool theVal) if (theVal != _preCADProcess3DTopology) { // SetTopology(PreCAD); _preCADProcess3DTopology = theVal; + AddPreCADOption("process_3d_topology", theVal ? "yes" : "no" ); NotifySubMeshesHypothesisModification(); } } @@ -736,6 +737,25 @@ void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal) } } +//============================================================================= +// Return true if any PreCAD option is activated +bool BLSURFPlugin_Hypothesis::HasPreCADOptions(const BLSURFPlugin_Hypothesis* hyp) +{ + if ( !hyp ) + { + return false; + } + bool orDefault, isOk; + return ( ToBool( hyp->GetPreCADOptionValue("closed_geometry" , &orDefault )) || + ToBool( hyp->GetPreCADOptionValue("discard_input_topology" , &orDefault )) || + ToBool( hyp->GetPreCADOptionValue("merge_edges" , &orDefault )) || + ToBool( hyp->GetPreCADOptionValue("remove_duplicate_cad_faces", &orDefault )) || + ToBool( hyp->GetPreCADOption ("process_3d_topology") , &isOk ) || + ToBool( hyp->GetPreCADOption ("manifold_geometry") , &isOk ) || + hyp->GetPreCADOptionValue("sewing_tolerance") != "5e-4*D" || + hyp->GetPreCADProcess3DTopology() ); +} + //============================================================================= // void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName, bool isBinary) void BLSURFPlugin_Hypothesis::SetGMFFile(const std::string& theFileName) @@ -997,9 +1017,9 @@ void BLSURFPlugin_Hypothesis::AddPreCADOption(const std::string& optionName, con } //============================================================================= -std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName) +std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName) const { - TOptionValues::iterator op_val = _customOption2value.find(optionName); + TOptionValues::const_iterator op_val = _customOption2value.find(optionName); if (op_val != _customOption2value.end()) return op_val->second; else @@ -1007,9 +1027,9 @@ std::string BLSURFPlugin_Hypothesis::GetOption(const std::string& optionName) } //============================================================================= -std::string BLSURFPlugin_Hypothesis::GetPreCADOption(const std::string& optionName) +std::string BLSURFPlugin_Hypothesis::GetPreCADOption(const std::string& optionName) const { - TOptionValues::iterator op_val = _customOption2value.find(optionName); + TOptionValues::const_iterator op_val = _customOption2value.find(optionName); if (op_val != _customOption2value.end()) return op_val->second; else diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index b8302b7..d719193 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -200,6 +200,8 @@ public: void SetPreCADDiscardInput(bool theVal); bool GetPreCADDiscardInput() const { return _preCADDiscardInput; } + + static bool HasPreCADOptions(const BLSURFPlugin_Hypothesis* hyp); typedef std::map TSizeMap; @@ -506,8 +508,8 @@ public: void AddOption(const std::string& optionName, const std::string& optionValue); void AddPreCADOption(const std::string& optionName, const std::string& optionValue); - std::string GetOption(const std::string& optionName); - std::string GetPreCADOption(const std::string& optionName); + std::string GetOption(const std::string& optionName) const; + std::string GetPreCADOption(const std::string& optionName) const; static bool ToBool(const std::string& str, bool* isOk=0) throw (std::invalid_argument); static double ToDbl(const std::string& str, bool* isOk=0) throw (std::invalid_argument); diff --git a/tests/test_precad_intersections.py b/tests/test_precad_intersections.py index f492dba..884fbf4 100644 --- a/tests/test_precad_intersections.py +++ b/tests/test_precad_intersections.py @@ -61,9 +61,9 @@ for p in vertices: nodes = list(set(nodes)) -Mesh_1.MakeGroupByIds("nodes", SMESH.NODE, nodes) +nodesGroup = Mesh_1.MakeGroupByIds("nodes", SMESH.NODE, nodes) -assert(len(nodes) == 1) +assert nodesGroup.Size() == 1, nodesGroup.GetIDs() if salome.sg.hasDesktop(): salome.sg.updateObjBrowser(1) -- 2.39.2