extern "C"{
#include <distene/api.h>
#include <distene/blsurf.h>
+#include <distene/precad.h>
}
#include <structmember.h>
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();
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();
_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() )
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;
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);
/* 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();
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<Handle(Geom2d_Curve)> curves;
vector<Handle(Geom_Surface)> surfaces;
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());
if (FaceId2SizeMap.find(faceKey)!=FaceId2SizeMap.end()){
- MESSAGE("A size map is defined on face :"<<faceKey)
+ MESSAGE("A size map is defined on face :"<<faceKey)
theSizeMapStr = FaceId2SizeMap[faceKey];
// check if function ends with "return"
if (theSizeMapStr.find(bad_end) == (theSizeMapStr.size()-bad_end.size()-1))
PyGILState_Release(gstate);
-
- blsurf_data_set_cad(bls, c);
+
+ if (use_precad){
+ /* Now launch the PreCAD process */
+ status = precad_process(pcs);
+ if(status != STATUS_OK){
+ cout << "PreCAD processing failed with error code " << status << "\n";
+ // Now we can delete the PreCAD session
+ precad_session_delete(pcs);
+ }
+ else {
+ // retrieve the pre-processed CAD object
+ cleanc = precad_new_cad(pcs);
+ if(!cleanc){
+ cout << "Unable to retrieve PreCAD result \n";
+ }
+
+ // Now we can delete the PreCAD session
+ precad_session_delete(pcs);
+ }
+ }
+
+ if (cleanc) {
+ // Give the pre-processed CAD object to the current BLSurf session
+ blsurf_data_set_cad(bls, cleanc);
+ }
+ else {
+ // Use the original one
+ blsurf_data_set_cad(bls, c);
+ }
std::cout << std::endl;
std::cout << "Beginning of Surface Mesh generation" << std::endl;
MESSAGE("Group name is empty: '"<<currentEnfVertex->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
_quadAllowed(GetDefaultQuadAllowed()),
_decimesh(GetDefaultDecimesh()),
_verb(GetDefaultVerbosity()),
+ _preCADOptimCAD(GetDefaultPreCADOptimCAD()),
+ _preCADDiscardInput(GetDefaultPreCADDiscardInput()),
+ _preCADManifoldGeom(GetDefaultPreCADManifoldGeom()),
+ _preCADClosedGeom(GetDefaultPreCADClosedGeom()),
_sizeMap(GetDefaultSizeMap()),
_attractors(GetDefaultSizeMap()),
_classAttractors(GetDefaultAttractorMap()),
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) {
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()) {
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;