From f3ea1132a27fad72c9e28b9d6489ac98dae97dc6 Mon Sep 17 00:00:00 2001 From: gdd Date: Tue, 26 Jul 2011 17:19:50 +0000 Subject: [PATCH] Add PreCAD TODO: GUI to PreCAD options --- adm_local/unix/config_files/check_BLSURF.m4 | 4 +- idl/BLSURFPlugin_Algorithm.idl | 1 + src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx | 121 ++++++++++++++---- src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx | 3 +- src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx | 62 +++++++++ src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx | 27 +++- src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx | 8 +- src/GUI/BLSURFPlugin_msg_en.ts | 4 + src/GUI/BLSURFPlugin_msg_fr.ts | 4 + 9 files changed, 202 insertions(+), 32 deletions(-) diff --git a/adm_local/unix/config_files/check_BLSURF.m4 b/adm_local/unix/config_files/check_BLSURF.m4 index 37558e2..7c813cc 100644 --- a/adm_local/unix/config_files/check_BLSURF.m4 +++ b/adm_local/unix/config_files/check_BLSURF.m4 @@ -60,10 +60,10 @@ if test "$with_blsurf" != "no" ; then echo LOCAL_INCLUDES="-I$BLSURF_HOME/include" - LOCAL_LIBS="-L$BLSURF_HOME/lib -lBLSurf" + LOCAL_LIBS="-L$BLSURF_HOME/lib -lBLSurf -lPreCAD" if test $(`which arch`) = x86_64 ; then if test -f $BLSURF_HOME/lib/Linux_64/libBLSurf.so ; then - LOCAL_LIBS="-L$BLSURF_HOME/lib/Linux_64 -lBLSurf -ldistene" + LOCAL_LIBS="-L$BLSURF_HOME/lib/Linux_64 -lBLSurf -ldistene -lPreCAD" fi fi diff --git a/idl/BLSURFPlugin_Algorithm.idl b/idl/BLSURFPlugin_Algorithm.idl index 9a3cae1..ddfdeca 100644 --- a/idl/BLSURFPlugin_Algorithm.idl +++ b/idl/BLSURFPlugin_Algorithm.idl @@ -123,6 +123,7 @@ module BLSURFPlugin * Sets topology usage way defining how mesh conformity is assured * value=0 - mesh conformity is assured by conformity of a shape * value=1,2 - mesh conformity is assured by pre-processing a CAD model + * value=3 - mesh conformity is assured by pre-processing a CAD model with Pre-CAD */ void SetTopology(in long way); long GetTopology(); diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index 779fcb0..8a10a63 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -31,6 +31,7 @@ extern "C"{ #include #include +#include } #include @@ -665,7 +666,10 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_session_t * bls, - SMESH_Mesh& mesh) + precad_session_t * pcs, + SMESH_Mesh& mesh, + bool * use_precad + ) { int _topology = BLSURFPlugin_Hypothesis::GetDefaultTopology(); int _physicalMesh = BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh(); @@ -678,6 +682,13 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, bool _decimesh = BLSURFPlugin_Hypothesis::GetDefaultDecimesh(); int _verb = BLSURFPlugin_Hypothesis::GetDefaultVerbosity(); + // PreCAD + int _precadOptimCad = BLSURFPlugin_Hypothesis::GetDefaultPreCADOptimCAD(); + int _precadDiscardInput = BLSURFPlugin_Hypothesis::GetDefaultPreCADDiscardInput(); + int _precadManifoldGeom = BLSURFPlugin_Hypothesis::GetDefaultPreCADManifoldGeom(); + int _precadClosedGeom = BLSURFPlugin_Hypothesis::GetDefaultPreCADClosedGeom(); + + if (hyp) { MESSAGE("BLSURFPlugin_BLSURF::SetParameters"); _topology = (int) hyp->GetTopology(); @@ -690,7 +701,6 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, _quadAllowed = hyp->GetQuadAllowed(); _decimesh = hyp->GetDecimesh(); _verb = hyp->GetVerbosity(); - if ( hyp->GetPhyMin() != ::BLSURFPlugin_Hypothesis::undefinedDouble() ) blsurf_set_param(bls, "hphymin", to_string(hyp->GetPhyMin()).c_str()); if ( hyp->GetPhyMax() != ::BLSURFPlugin_Hypothesis::undefinedDouble() ) @@ -708,21 +718,47 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_set_param(bls, opIt->first.c_str(), opIt->second.c_str()); } + // PreCAD + _precadOptimCad = hyp->GetPreCADOptimCAD(); + _precadDiscardInput = hyp->GetPreCADDiscardInput(); + _precadManifoldGeom = hyp->GetPreCADManifoldGeom(); + _precadClosedGeom = hyp->GetPreCADClosedGeom(); + } else { //0020968: EDF1545 SMESH: Problem in the creation of a mesh group on geometry // GetDefaultPhySize() sometimes leads to computation failure _phySize = mesh.GetShapeDiagonalSize() / _gen->GetBoundaryBoxSegmentation(); MESSAGE("BLSURFPlugin_BLSURF::SetParameters using defaults"); } + + // PreCAD + if (_topology == BLSURFPlugin_Hypothesis::PreCAD) { + *use_precad = true; + precad_set_param(pcs, "verbose", to_string(_verb).c_str()); + + precad_set_param(pcs, "merge_edges", _precadOptimCad > 0 ? "1" : "0"); + precad_set_param(pcs, "remove_nano_edges", _precadOptimCad > 0 ? "1" : "0"); + precad_set_param(pcs, "discard_input_topology", _precadDiscardInput ? "1" : "0"); + precad_set_param(pcs, "manifold_geometry", _precadManifoldGeom ? "1" : "0"); + precad_set_param(pcs, "closed_geometry", _precadClosedGeom ? "1" : "0"); + /* + precad_set_param(pcs, "merge_edges", "0"); + precad_set_param(pcs, "remove_nano_edges", "0"); + precad_set_param(pcs, "discard_input_topology", "0"); + precad_set_param(pcs, "manifold_geometry", "0"); + precad_set_param(pcs, "closed_geometry", "0"); + */ + } + _smp_phy_size = _phySize; - blsurf_set_param(bls, "topo_points", _topology > 0 ? "1" : "0"); - blsurf_set_param(bls, "topo_curves", _topology > 0 ? "1" : "0"); - blsurf_set_param(bls, "topo_project", _topology > 0 ? "1" : "0"); - blsurf_set_param(bls, "clean_boundary", _topology > 1 ? "1" : "0"); - blsurf_set_param(bls, "close_boundary", _topology > 1 ? "1" : "0"); + blsurf_set_param(bls, "topo_points", _topology == BLSURFPlugin_Hypothesis::Process || _topology == BLSURFPlugin_Hypothesis::Process2 ? "1" : "0"); + blsurf_set_param(bls, "topo_curves", _topology == BLSURFPlugin_Hypothesis::Process || _topology == BLSURFPlugin_Hypothesis::Process2 ? "1" : "0"); + blsurf_set_param(bls, "topo_project", _topology == BLSURFPlugin_Hypothesis::Process || _topology == BLSURFPlugin_Hypothesis::Process2 ? "1" : "0"); + blsurf_set_param(bls, "clean_boundary", _topology == BLSURFPlugin_Hypothesis::Process2 ? "1" : "0"); + blsurf_set_param(bls, "close_boundary", _topology == BLSURFPlugin_Hypothesis::Process2 ? "1" : "0"); blsurf_set_param(bls, "hphy_flag", to_string(_physicalMesh).c_str()); -// blsurf_set_param(bls, "hphy_flag", "2"); - if ((to_string(_physicalMesh))=="2"){ + + if (_physicalMesh == BLSURFPlugin_Hypothesis::SizeMap){ TopoDS_Shape GeomShape; TopoDS_Shape AttShape; TopAbs_ShapeEnum GeomType; @@ -976,9 +1012,9 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_set_param(bls, "patch_independent", _decimesh ? "1" : "0"); blsurf_set_param(bls, "element", _quadAllowed ? "q1.0" : "p1"); blsurf_set_param(bls, "verb", to_string(_verb).c_str()); -#ifdef _DEBUG_ - blsurf_set_param(bls, "debug", "1"); -#endif +// #ifdef _DEBUG_ +// blsurf_set_param(bls, "debug", "1"); +// #endif } status_t curv_fun(real t, real *uv, real *dt, real *dtt, void *user_data); @@ -1024,8 +1060,6 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) /* create the CAD object we will work on. It is associated to the context ctx. */ cad_t *c = cad_new(ctx); - blsurf_session_t *bls = blsurf_session_new(ctx); - FacesWithSizeMap.Clear(); FaceId2SizeMap.clear(); FaceId2ClassAttractor.clear(); @@ -1035,15 +1069,26 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) VerticesWithSizeMap.Clear(); VertexId2SizeMap.clear(); - MESSAGE("BEGIN SetParameters"); - SetParameters(_hypothesis, bls, aMesh); - MESSAGE("END SetParameters"); /* Now fill the CAD object with data from your CAD * environement. This is the most complex part of a successfull * integration. */ + // PreCAD + // If user requests it, send the CAD through Distene preprocessor : PreCAD + cad_t *cleanc = NULL; + precad_session_t *pcs = precad_session_new(ctx); + precad_data_set_cad(pcs, c); + + blsurf_session_t *bls = blsurf_session_new(ctx); + + MESSAGE("BEGIN SetParameters"); + bool use_precad = false; + SetParameters(_hypothesis, bls, pcs, aMesh, &use_precad); + MESSAGE("END SetParameters"); + + // needed to prevent the opencascade memory managmement from freeing things vector curves; vector surfaces; @@ -1074,7 +1119,9 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) int iface = 0; string bad_end = "return"; int faceKey = -1; - int ienf = 0; + TopTools_IndexedMapOfShape _map; + TopExp::MapShapes(aShape,TopAbs_VERTEX,_map); + int ienf = _map.Extent(); BLSURFPlugin_Attractor myAttractor; for (TopExp_Explorer face_iter(aShape,TopAbs_FACE);face_iter.More();face_iter.Next()) { TopoDS_Face f=TopoDS::Face(face_iter.Current()); @@ -1116,7 +1163,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) if (FaceId2SizeMap.find(faceKey)!=FaceId2SizeMap.end()){ - MESSAGE("A size map is defined on face :"<grpName<<"' => group is not created"); } } -#ifdef _DEBUG_ - else - MESSAGE("No enforced vertex found @ " << xyz[0] << ", " << xyz[1] << ", " << xyz[2]); -#endif - // internal point are tagged to zero diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index 6e81b2a..4c90a3c 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -49,6 +49,7 @@ extern "C"{ #include "distene/blsurf.h" #include "distene/api.h" +#include "distene/precad.h" } #include @@ -70,7 +71,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,SMESH_Mesh& aMesh); + void SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_session_t *bls, precad_session_t *pcs, SMESH_Mesh& aMesh, bool *use_precad); virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx index 41d3d05..7fb73c9 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx @@ -55,6 +55,10 @@ BLSURFPlugin_Hypothesis::BLSURFPlugin_Hypothesis(int hypId, int studyId, SMESH_G _quadAllowed(GetDefaultQuadAllowed()), _decimesh(GetDefaultDecimesh()), _verb(GetDefaultVerbosity()), + _preCADOptimCAD(GetDefaultPreCADOptimCAD()), + _preCADDiscardInput(GetDefaultPreCADDiscardInput()), + _preCADManifoldGeom(GetDefaultPreCADManifoldGeom()), + _preCADClosedGeom(GetDefaultPreCADClosedGeom()), _sizeMap(GetDefaultSizeMap()), _attractors(GetDefaultSizeMap()), _classAttractors(GetDefaultAttractorMap()), @@ -260,6 +264,39 @@ void BLSURFPlugin_Hypothesis::SetVerbosity(int theVal) { NotifySubMeshesHypothesisModification(); } } + +//============================================================================= +void BLSURFPlugin_Hypothesis::SetPreCADOptimCAD(bool theVal) { + if (theVal != _preCADOptimCAD) { + _preCADOptimCAD = theVal; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +void BLSURFPlugin_Hypothesis::SetPreCADDiscardInput(bool theVal) { + if (theVal != _preCADDiscardInput) { + _preCADDiscardInput = theVal; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +void BLSURFPlugin_Hypothesis::SetPreCADManifoldGeom(bool theVal) { + if (theVal != _preCADManifoldGeom) { + _preCADManifoldGeom = theVal; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +void BLSURFPlugin_Hypothesis::SetPreCADClosedGeom(bool theVal) { + if (theVal != _preCADClosedGeom) { + _preCADClosedGeom = theVal; + NotifySubMeshesHypothesisModification(); + } +} + //============================================================================= void BLSURFPlugin_Hypothesis::SetOptionValue(const std::string& optionName, const std::string& optionValue) throw (std::invalid_argument) { @@ -918,6 +955,7 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save) { save << " " << (int) _topology << " " << (int) _physicalMesh << " " << (int) _geometricMesh << " " << _phySize << " " << _angleMeshS << " " << _gradation << " " << (int) _quadAllowed << " " << (int) _decimesh; save << " " << _phyMin << " " << _phyMax << " " << _angleMeshC << " " << _hgeoMin << " " << _hgeoMax << " " << _verb; + save << " " << (int) _preCADOptimCAD << " " << (int) _preCADDiscardInput << " " << (int) _preCADManifoldGeom << " " << (int) _preCADClosedGeom; TOptionValues::iterator op_val = _option2value.begin(); if (op_val != _option2value.end()) { @@ -1105,6 +1143,30 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load) { else load.clear(std::ios::badbit | load.rdstate()); + isOK = (load >> i); + if (isOK) + _preCADOptimCAD = (bool) i; + else + load.clear(std::ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + _preCADDiscardInput = (bool) i; + else + load.clear(std::ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + _preCADManifoldGeom = (bool) i; + else + load.clear(std::ios::badbit | load.rdstate()); + + isOK = (load >> i); + if (isOK) + _preCADClosedGeom = (bool) i; + else + load.clear(std::ios::badbit | load.rdstate()); + std::string option_or_sm; bool hasOptions = false; bool hasSizeMap = false; diff --git a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx index f136089..c268148 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx @@ -48,7 +48,8 @@ public: enum Topology { FromCAD, Process, - Process2 + Process2, + PreCAD }; enum PhysicalMesh { @@ -109,6 +110,18 @@ public: void ClearEntry(const std::string& entry); void ClearSizeMaps(); + void SetPreCADOptimCAD(bool theVal); + bool GetPreCADOptimCAD() const { return _preCADOptimCAD; } + + void SetPreCADDiscardInput(bool theVal); + bool GetPreCADDiscardInput() const { return _preCADDiscardInput; } + + void SetPreCADManifoldGeom(bool theVal); + bool GetPreCADManifoldGeom() const { return _preCADManifoldGeom; } + + void SetPreCADClosedGeom(bool theVal); + bool GetPreCADClosedGeom() const { return _preCADClosedGeom; } + typedef std::map TSizeMap; void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap ); @@ -272,6 +285,12 @@ public: static bool GetDefaultQuadAllowed(); static bool GetDefaultDecimesh(); static int GetDefaultVerbosity() { return 10; } + // PreCAD + static bool GetDefaultPreCADOptimCAD() { return false; } + static bool GetDefaultPreCADDiscardInput() { return false; } + static bool GetDefaultPreCADManifoldGeom() { return false; } + static bool GetDefaultPreCADClosedGeom() { return false; } + static TSizeMap GetDefaultSizeMap() { return TSizeMap();} static TAttractorMap GetDefaultAttractorMap() { return TAttractorMap(); } @@ -330,6 +349,12 @@ private: bool _quadAllowed; bool _decimesh; int _verb; + + bool _preCADOptimCAD; + bool _preCADDiscardInput; + bool _preCADManifoldGeom; + bool _preCADClosedGeom; + TOptionValues _option2value; TOptionNames _doubleOptions, _charOptions; TSizeMap _sizeMap; diff --git a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx index 628681e..6828af0 100644 --- a/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx @@ -84,7 +84,8 @@ enum Topology { FromCAD, Process, - Process2 + Process2, + PreCAD } ; enum PhysicalMesh @@ -734,7 +735,10 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame() myTopology = new QComboBox( myAdvGroup ); QStringList topologyTypes; - topologyTypes << tr( "BLSURF_TOPOLOGY_CAD" ) << tr( "BLSURF_TOPOLOGY_PROCESS" ) << tr( "BLSURF_TOPOLOGY_PROCESS2" ); + topologyTypes << tr( "BLSURF_TOPOLOGY_CAD" ) + << tr( "BLSURF_TOPOLOGY_PROCESS" ) + << tr( "BLSURF_TOPOLOGY_PROCESS2" ) + << tr( "BLSURF_TOPOLOGY_PRECAD" ); myTopology->addItems( topologyTypes ); myVerbosity = new QSpinBox( myAdvGroup ); diff --git a/src/GUI/BLSURFPlugin_msg_en.ts b/src/GUI/BLSURFPlugin_msg_en.ts index fecda28..864b039 100644 --- a/src/GUI/BLSURFPlugin_msg_en.ts +++ b/src/GUI/BLSURFPlugin_msg_en.ts @@ -99,6 +99,10 @@ BLSURF_TOPOLOGY_PROCESS2 Pre-process++ + + BLSURF_TOPOLOGY_PRECAD + PreCAD + BLSURF_VERBOSITY Verbosity level diff --git a/src/GUI/BLSURFPlugin_msg_fr.ts b/src/GUI/BLSURFPlugin_msg_fr.ts index 9e46651..20d4904 100755 --- a/src/GUI/BLSURFPlugin_msg_fr.ts +++ b/src/GUI/BLSURFPlugin_msg_fr.ts @@ -99,6 +99,10 @@ BLSURF_TOPOLOGY_PROCESS2 Prétraitement++ + + BLSURF_TOPOLOGY_PRECAD + PreCAD + BLSURF_VERBOSITY Niveau de verbosité -- 2.39.2