-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
extern "C"{
#include <meshgems/meshgems.h>
#include <meshgems/cadsurf.h>
-#include <meshgems/precad.h>
}
#include <structmember.h>
#include <fenv.h>
#endif
+using namespace std;
+
/* ==================================
* =========== PYTHON ==============
* ==================================*/
-typedef struct {
- PyObject_HEAD
- int softspace;
- std::string *out;
- } PyStdOut;
-
-static void
-PyStdOut_dealloc(PyStdOut *self)
+namespace
{
- PyObject_Del(self);
-}
+ typedef struct {
+ PyObject_HEAD
+ int softspace;
+ std::string *out;
+ } PyStdOut;
+
+ static void
+ PyStdOut_dealloc(PyStdOut *self)
+ {
+ PyObject_Del(self);
+ }
-static PyObject *
-PyStdOut_write(PyStdOut *self, PyObject *args)
-{
- char *c;
- int l;
- if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
- return NULL;
+ static PyObject *
+ PyStdOut_write(PyStdOut *self, PyObject *args)
+ {
+ char *c;
+ int l;
+ if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
+ return NULL;
- //std::cerr << c ;
- *(self->out)=*(self->out)+c;
+ *(self->out)=*(self->out)+c;
- Py_INCREF(Py_None);
- return Py_None;
-}
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
-static PyMethodDef PyStdOut_methods[] = {
- {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
- PyDoc_STR("write(string) -> None")},
- {NULL, NULL} /* sentinel */
-};
-
-static PyMemberDef PyStdOut_memberlist[] = {
- {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
- (char*)"flag indicating that a space needs to be printed; used by print"},
- {NULL} /* Sentinel */
-};
-
-static PyTypeObject PyStdOut_Type = {
- /* The ob_type field must be initialized in the module init function
- * to be portable to Windows without using C++. */
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "PyOut", /*tp_name*/
- sizeof(PyStdOut), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- /* methods */
- (destructor)PyStdOut_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- 0, /*tp_getattr*/
- 0, /*tp_setattr*/
- 0, /*tp_compare*/
- 0, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
- 0, /*tp_hash*/
- 0, /*tp_call*/
- 0, /*tp_str*/
- PyObject_GenericGetAttr, /*tp_getattro*/
- /* softspace is writable: we must supply tp_setattro */
- PyObject_GenericSetAttr, /* tp_setattro */
- 0, /*tp_as_buffer*/
- Py_TPFLAGS_DEFAULT, /*tp_flags*/
- 0, /*tp_doc*/
- 0, /*tp_traverse*/
- 0, /*tp_clear*/
- 0, /*tp_richcompare*/
- 0, /*tp_weaklistoffset*/
- 0, /*tp_iter*/
- 0, /*tp_iternext*/
- PyStdOut_methods, /*tp_methods*/
- PyStdOut_memberlist, /*tp_members*/
- 0, /*tp_getset*/
- 0, /*tp_base*/
- 0, /*tp_dict*/
- 0, /*tp_descr_get*/
- 0, /*tp_descr_set*/
- 0, /*tp_dictoffset*/
- 0, /*tp_init*/
- 0, /*tp_alloc*/
- 0, /*tp_new*/
- 0, /*tp_free*/
- 0, /*tp_is_gc*/
-};
-
-PyObject * newPyStdOut( std::string& out )
-{
- PyStdOut *self;
- self = PyObject_New(PyStdOut, &PyStdOut_Type);
- if (self == NULL)
- return NULL;
- self->softspace = 0;
- self->out=&out;
- return (PyObject*)self;
+ static PyMethodDef PyStdOut_methods[] = {
+ {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
+ PyDoc_STR("write(string) -> None")},
+ {NULL, NULL} /* sentinel */
+ };
+
+ static PyMemberDef PyStdOut_memberlist[] = {
+ {(char*)"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
+ (char*)"flag indicating that a space needs to be printed; used by print"},
+ {NULL} /* Sentinel */
+ };
+
+ static PyTypeObject PyStdOut_Type = {
+ /* The ob_type field must be initialized in the module init function
+ * to be portable to Windows without using C++. */
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "PyOut", /*tp_name*/
+ sizeof(PyStdOut), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ /* methods */
+ (destructor)PyStdOut_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ PyObject_GenericGetAttr, /*tp_getattro*/
+ /* softspace is writable: we must supply tp_setattro */
+ PyObject_GenericSetAttr, /* tp_setattro */
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /*tp_doc*/
+ 0, /*tp_traverse*/
+ 0, /*tp_clear*/
+ 0, /*tp_richcompare*/
+ 0, /*tp_weaklistoffset*/
+ 0, /*tp_iter*/
+ 0, /*tp_iternext*/
+ PyStdOut_methods, /*tp_methods*/
+ PyStdOut_memberlist, /*tp_members*/
+ 0, /*tp_getset*/
+ 0, /*tp_base*/
+ 0, /*tp_dict*/
+ 0, /*tp_descr_get*/
+ 0, /*tp_descr_set*/
+ 0, /*tp_dictoffset*/
+ 0, /*tp_init*/
+ 0, /*tp_alloc*/
+ 0, /*tp_new*/
+ 0, /*tp_free*/
+ 0, /*tp_is_gc*/
+ };
+
+ PyObject * newPyStdOut( std::string& out )
+ {
+ PyStdOut* self = PyObject_New(PyStdOut, &PyStdOut_Type);
+ if (self) {
+ self->softspace = 0;
+ self->out=&out;
+ }
+ return (PyObject*)self;
+ }
}
*/
//=============================================================================
-inline std::string to_string(double d)
+inline std::string val_to_string(double d)
{
std::ostringstream o;
o << d;
return o.str();
}
-inline std::string to_string_rel(double d)
+inline std::string val_to_string_rel(double d)
{
std::ostringstream o;
o << d;
return o.str();
}
-inline std::string to_string(int i)
+inline std::string val_to_string(int i)
{
std::ostringstream o;
o << i;
return o.str();
}
-inline std::string to_string_rel(int i)
+inline std::string val_to_string_rel(int i)
{
std::ostringstream o;
o << i;
double a, b; // Attractor parameter
double d = 0.;
bool createNode=false; // To create a node on attractor projection
- int pos1, pos2;
+ size_t pos1, pos2;
const char *sep = ";";
// atIt->second has the following pattern:
// ATTRACTOR(xa;ya;za;a;b;True|False;d)
/////////////////////////////////////////////////////////
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);
_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);
_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<int, int> pairOfFacesID = std::make_pair(theFace1_id, theFace2_id);
-
- _facesIDsPeriodicityVector.push_back(pairOfFacesID);
- MESSAGE("_facesIDsPeriodicityVector.size() = " << _facesIDsPeriodicityVector.size());
- MESSAGE("BLSURFPlugin_BLSURF::createFacesPeriodicity 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");
+ MESSAGE("BLSURFPlugin_BLSURF::createPreCadEdgesPeriodicity 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
bool _minSizeRel = BLSURFPlugin_Hypothesis::GetDefaultMinSizeRel();
double _maxSize = BLSURFPlugin_Hypothesis::GetDefaultMaxSize(diagonal);
bool _maxSizeRel = BLSURFPlugin_Hypothesis::GetDefaultMaxSizeRel();
+ double _use_gradation = BLSURFPlugin_Hypothesis::GetDefaultUseGradation();
double _gradation = BLSURFPlugin_Hypothesis::GetDefaultGradation();
+ double _use_volume_gradation = BLSURFPlugin_Hypothesis::GetDefaultUseVolumeGradation();
+ double _volume_gradation = BLSURFPlugin_Hypothesis::GetDefaultVolumeGradation();
bool _quadAllowed = BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed();
double _angleMesh = BLSURFPlugin_Hypothesis::GetDefaultAngleMesh();
double _chordalError = BLSURFPlugin_Hypothesis::GetDefaultChordalError(diagonal);
double _anisotropicRatio = BLSURFPlugin_Hypothesis::GetDefaultAnisotropicRatio();
bool _removeTinyEdges = BLSURFPlugin_Hypothesis::GetDefaultRemoveTinyEdges();
double _tinyEdgeLength = BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(diagonal);
+ bool _optimiseTinyEdges = BLSURFPlugin_Hypothesis::GetDefaultOptimiseTinyEdges();
+ double _tinyEdgeOptimisLength = BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeOptimisationLength(diagonal);
+ bool _correctSurfaceIntersec= BLSURFPlugin_Hypothesis::GetDefaultCorrectSurfaceIntersection();
+ double _corrSurfaceIntersCost = BLSURFPlugin_Hypothesis::GetDefaultCorrectSurfaceIntersectionMaxCost();
bool _badElementRemoval = BLSURFPlugin_Hypothesis::GetDefaultBadElementRemoval();
double _badElementAspectRatio = BLSURFPlugin_Hypothesis::GetDefaultBadElementAspectRatio();
bool _optimizeMesh = BLSURFPlugin_Hypothesis::GetDefaultOptimizeMesh();
bool _quadraticMesh = BLSURFPlugin_Hypothesis::GetDefaultQuadraticMesh();
int _verb = BLSURFPlugin_Hypothesis::GetDefaultVerbosity();
- int _topology = BLSURFPlugin_Hypothesis::GetDefaultTopology();
+ //int _topology = BLSURFPlugin_Hypothesis::GetDefaultTopology();
// PreCAD
- int _precadMergeEdges = BLSURFPlugin_Hypothesis::GetDefaultPreCADMergeEdges();
+ //int _precadMergeEdges = BLSURFPlugin_Hypothesis::GetDefaultPreCADMergeEdges();
+ int _precadRemoveTinyUVEdges = BLSURFPlugin_Hypothesis::GetDefaultPreCADRemoveTinyUVEdges();
+ //int _precadRemoveDuplicateCADFaces = BLSURFPlugin_Hypothesis::GetDefaultPreCADRemoveDuplicateCADFaces();
int _precadProcess3DTopology = BLSURFPlugin_Hypothesis::GetDefaultPreCADProcess3DTopology();
- int _precadDiscardInput = BLSURFPlugin_Hypothesis::GetDefaultPreCADDiscardInput();
+ //int _precadDiscardInput = BLSURFPlugin_Hypothesis::GetDefaultPreCADDiscardInput();
if (hyp) {
// if max size is not explicitly specified, "relative" flag is ignored
_maxSizeRel = hyp->IsMaxSizeRel();
}
- if (hyp->GetGradation() > 0)
+ _use_gradation = hyp->GetUseGradation();
+ if (hyp->GetGradation() > 0 && _use_gradation)
_gradation = hyp->GetGradation();
+ _use_volume_gradation = hyp->GetUseVolumeGradation();
+ if (hyp->GetVolumeGradation() > 0 && _use_volume_gradation )
+ _volume_gradation = hyp->GetVolumeGradation();
_quadAllowed = hyp->GetQuadAllowed();
if (hyp->GetAngleMesh() > 0)
_angleMesh = hyp->GetAngleMesh();
_removeTinyEdges = hyp->GetRemoveTinyEdges();
if (hyp->GetTinyEdgeLength() > 0)
_tinyEdgeLength = hyp->GetTinyEdgeLength();
+ _optimiseTinyEdges = hyp->GetOptimiseTinyEdges();
+ if (hyp->GetTinyEdgeOptimisationLength() > 0)
+ _tinyEdgeOptimisLength = hyp->GetTinyEdgeOptimisationLength();
+ _correctSurfaceIntersec = hyp->GetCorrectSurfaceIntersection();
+ if (hyp->GetCorrectSurfaceIntersectionMaxCost() > 0)
+ _corrSurfaceIntersCost = hyp->GetCorrectSurfaceIntersectionMaxCost();
_badElementRemoval = hyp->GetBadElementRemoval();
if (hyp->GetBadElementAspectRatio() >= 0)
_badElementAspectRatio = hyp->GetBadElementAspectRatio();
_optimizeMesh = hyp->GetOptimizeMesh();
_quadraticMesh = hyp->GetQuadraticMesh();
_verb = hyp->GetVerbosity();
- _topology = (int) hyp->GetTopology();
+ //_topology = (int) hyp->GetTopology();
// PreCAD
- _precadMergeEdges = hyp->GetPreCADMergeEdges();
+ //_precadMergeEdges = hyp->GetPreCADMergeEdges();
+ _precadRemoveTinyUVEdges = hyp->GetPreCADRemoveTinyUVEdges();
+ //_precadRemoveDuplicateCADFaces = hyp->GetPreCADRemoveDuplicateCADFaces();
_precadProcess3DTopology = hyp->GetPreCADProcess3DTopology();
- _precadDiscardInput = hyp->GetPreCADDiscardInput();
+ //_precadDiscardInput = hyp->GetPreCADDiscardInput();
const BLSURFPlugin_Hypothesis::TOptionValues& opts = hyp->GetOptionValues();
BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt;
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());
- }
-
- 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 {
-// //0020968: EDF1545 SMESH: Problem in the creation of a mesh group on geometry
-// // GetDefaultPhySize() sometimes leads to computation failure
-// // GDD 26/07/2012 From Distene documentation, global physical size default value = diag/100
-// _phySize = BLSURFPlugin_Hypothesis::GetDefaultPhySize(diagonal);
-// _minSize = BLSURFPlugin_Hypothesis::GetDefaultMinSize(diagonal);
-// _maxSize = BLSURFPlugin_Hypothesis::GetDefaultMaxSize(diagonal);
-// _chordalError = BLSURFPlugin_Hypothesis::GetDefaultChordalError(diagonal);
-// _tinyEdgeLength = BLSURFPlugin_Hypothesis::GetDefaultTinyEdgeLength(diagonal);
-// 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", _precadMergeEdges ? "1" : "0");
- precad_set_param(pcs, "process_3d_topology", _precadProcess3DTopology ? "1" : "0");
- precad_set_param(pcs, "discard_input_topology", _precadDiscardInput ? "1" : "0");
- }
- // unlimit mesh size (issue 0022266)
- set_param(css, "max_number_of_points_per_patch", "1000000");
+ // 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, "discard_input_topology", _precadDiscardInput ? "1" : "0");
+ //set_param(css, "max_number_of_points_per_patch", "1000000");
bool useGradation = false;
switch (_physicalMesh)
{
case BLSURFPlugin_Hypothesis::PhysicalGlobalSize:
set_param(css, "physical_size_mode", "global");
- set_param(css, "global_physical_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str());
+ set_param(css, "global_physical_size", _phySizeRel ? val_to_string_rel(_phySize).c_str() : val_to_string(_phySize).c_str());
break;
case BLSURFPlugin_Hypothesis::PhysicalLocalSize:
set_param(css, "physical_size_mode", "local");
- set_param(css, "global_physical_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str());
+ set_param(css, "global_physical_size", _phySizeRel ? val_to_string_rel(_phySize).c_str() : val_to_string(_phySize).c_str());
useGradation = true;
break;
default:
{
case BLSURFPlugin_Hypothesis::GeometricalGlobalSize:
set_param(css, "geometric_size_mode", "global");
- set_param(css, "geometric_approximation", to_string(_angleMesh).c_str());
- set_param(css, "chordal_error", to_string(_chordalError).c_str());
+ set_param(css, "geometric_approximation", val_to_string(_angleMesh).c_str());
+ set_param(css, "chordal_error", val_to_string(_chordalError).c_str());
useGradation = true;
break;
case BLSURFPlugin_Hypothesis::GeometricalLocalSize:
set_param(css, "geometric_size_mode", "local");
- set_param(css, "geometric_approximation", to_string(_angleMesh).c_str());
- set_param(css, "chordal_error", to_string(_chordalError).c_str());
+ set_param(css, "geometric_approximation", val_to_string(_angleMesh).c_str());
+ set_param(css, "chordal_error", val_to_string(_chordalError).c_str());
useGradation = true;
break;
default:
double mins = _minSizeRel ? _minSize * diagonal : _minSize;
// - min size should not be greater than user size
if ( _phySize < mins )
- set_param(css, "min_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str());
+ set_param(css, "min_size", _phySizeRel ? val_to_string_rel(_phySize).c_str() : val_to_string(_phySize).c_str());
else
- set_param(css, "min_size", _minSizeRel ? to_string_rel(_minSize).c_str() : to_string(_minSize).c_str());
+ set_param(css, "min_size", _minSizeRel ? val_to_string_rel(_minSize).c_str() : val_to_string(_minSize).c_str());
// - compute absolute max size
double maxs = _maxSizeRel ? _maxSize * diagonal : _maxSize;
// - max size should not be less than user size
if ( _phySize > maxs )
- set_param(css, "max_size", _phySizeRel ? to_string_rel(_phySize).c_str() : to_string(_phySize).c_str());
+ set_param(css, "max_size", _phySizeRel ? val_to_string_rel(_phySize).c_str() : val_to_string(_phySize).c_str());
else
- set_param(css, "max_size", _maxSizeRel ? to_string_rel(_maxSize).c_str() : to_string(_maxSize).c_str());
+ set_param(css, "max_size", _maxSizeRel ? val_to_string_rel(_maxSize).c_str() : val_to_string(_maxSize).c_str());
}
else {
// user size is not explicitly specified
// - if minsize is not explicitly specified, we pass default value computed automatically, in this case "relative" flag is ignored
- set_param(css, "min_size", _minSizeRel ? to_string_rel(_minSize).c_str() : to_string(_minSize).c_str());
+ set_param(css, "min_size", _minSizeRel ? val_to_string_rel(_minSize).c_str() : val_to_string(_minSize).c_str());
// - if maxsize is not explicitly specified, we pass default value computed automatically, in this case "relative" flag is ignored
- set_param(css, "max_size", _maxSizeRel ? to_string_rel(_maxSize).c_str() : to_string(_maxSize).c_str());
+ set_param(css, "max_size", _maxSizeRel ? val_to_string_rel(_maxSize).c_str() : val_to_string(_maxSize).c_str());
}
// anisotropic and quadrangle mesh requires disabling gradation
if ( _anisotropic && _quadAllowed )
useGradation = false; // limitation of V1.3
- if ( useGradation )
- set_param(css, "gradation", to_string(_gradation).c_str());
+ if ( useGradation && _use_gradation )
+ set_param(css, "gradation", val_to_string(_gradation).c_str());
+ if ( useGradation && _use_volume_gradation )
+ set_param(css, "volume_gradation", val_to_string(_volume_gradation).c_str());
set_param(css, "element_generation", _quadAllowed ? "quad_dominant" : "triangle");
set_param(css, "metric", _anisotropic ? "anisotropic" : "isotropic");
if ( _anisotropic )
- set_param(css, "anisotropic_ratio", to_string(_anisotropicRatio).c_str());
+ set_param(css, "anisotropic_ratio", val_to_string(_anisotropicRatio).c_str());
set_param(css, "remove_tiny_edges", _removeTinyEdges ? "1" : "0");
if ( _removeTinyEdges )
- set_param(css, "tiny_edge_length", to_string(_tinyEdgeLength).c_str());
+ set_param(css, "tiny_edge_length", val_to_string(_tinyEdgeLength).c_str());
+ set_param(css, "optimise_tiny_edges", _optimiseTinyEdges ? "1" : "0");
+ if ( _optimiseTinyEdges )
+ set_param(css, "tiny_edge_optimisation_length", val_to_string(_tinyEdgeOptimisLength).c_str());
+ set_param(css, "correct_surface_intersections", _correctSurfaceIntersec ? "1" : "0");
+ if ( _correctSurfaceIntersec )
+ set_param(css, "surface_intersections_processing_max_cost", val_to_string(_corrSurfaceIntersCost ).c_str());
set_param(css, "force_bad_surface_element_removal", _badElementRemoval ? "1" : "0");
if ( _badElementRemoval )
- set_param(css, "bad_surface_element_aspect_ratio", to_string(_badElementAspectRatio).c_str());
+ set_param(css, "bad_surface_element_aspect_ratio", val_to_string(_badElementAspectRatio).c_str());
set_param(css, "optimisation", _optimizeMesh ? "yes" : "no");
set_param(css, "element_order", _quadraticMesh ? "quadratic" : "linear");
- set_param(css, "verbose", to_string(_verb).c_str());
+ set_param(css, "verbose", val_to_string(_verb).c_str());
_smp_phy_size = _phySizeRel ? _phySize*diagonal : _phySize;
if ( _verb > 0 )
MESSAGE("Geomtype is " << GeomType);
int key = -1;
// Group Management
- if (GeomType == TopAbs_COMPOUND){
+ if (GeomType == TopAbs_COMPOUND) {
for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){
// Group of faces
if (it.Value().ShapeType() == TopAbs_FACE){
}
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);
}
}
// reset vectors
_preCadFacesIDsPeriodicityVector.clear();
_preCadEdgesIDsPeriodicityVector.clear();
- _facesIDsPeriodicityVector.clear();
- _edgesIDsPeriodicityVector.clear();
- _verticesIDsPeriodicityVector.clear();
MESSAGE("SetParameters preCadFacesPeriodicityVector");
const BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadFacesPeriodicityVector = BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(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", to_string(_verb).c_str());
- }
-
- MESSAGE("SetParameters facesPeriodicityVector");
- const BLSURFPlugin_Hypothesis::TFacesPeriodicityVector facesPeriodicityVector = BLSURFPlugin_Hypothesis::GetFacesPeriodicityVector(hyp);
-
- for (std::size_t i = 0; i<facesPeriodicityVector.size(); i++){
- MESSAGE("SetParameters facesPeriodicityVector[" << i << "]");
- createFacesPeriodicity(theGeomShape, facesPeriodicityVector[i].first, facesPeriodicityVector[i].second);
- }
- MESSAGE("_facesIDsPeriodicityVector.size() = " << _facesIDsPeriodicityVector.size());
-
-
- MESSAGE("SetParameters edgesPeriodicityVector");
- const BLSURFPlugin_Hypothesis::TEdgesPeriodicityVector edgesPeriodicityVector = BLSURFPlugin_Hypothesis::GetEdgesPeriodicityVector(hyp);
-
- for (std::size_t i = 0; i<edgesPeriodicityVector.size(); i++){
- MESSAGE("SetParameters edgesPeriodicityVector[" << i << "]");
- // TODO: passer directement en paramètre edgesPeriodicityVector[i] plutôt que tous ces attributs
- createEdgesPeriodicity(theGeomShape, edgesPeriodicityVector[i].theFace1Entry, edgesPeriodicityVector[i].theEdge1Entry,
- edgesPeriodicityVector[i].theFace2Entry, edgesPeriodicityVector[i].theEdge2Entry, edgesPeriodicityVector[i].edge_orientation);
- }
- MESSAGE("_edgesIDsPeriodicityVector.size() = " << _edgesIDsPeriodicityVector.size());
-
- MESSAGE("SetParameters verticesPeriodicityVector");
- const BLSURFPlugin_Hypothesis::TVerticesPeriodicityVector verticesPeriodicityVector = BLSURFPlugin_Hypothesis::GetVerticesPeriodicityVector(hyp);
-
- for (std::size_t i = 0; i<verticesPeriodicityVector.size(); i++){
- MESSAGE("SetParameters verticesPeriodicityVector[" << i << "]");
- // TODO: passer directement en paramètre verticesPeriodicityVector[i] plutôt que tous ces attributs
- createVerticesPeriodicity(theGeomShape, verticesPeriodicityVector[i].theEdge1Entry, verticesPeriodicityVector[i].theVertex1Entry,
- verticesPeriodicityVector[i].theEdge2Entry, verticesPeriodicityVector[i].theVertex2Entry);
- }
- MESSAGE("_verticesIDsPeriodicityVector.size() = " << _verticesIDsPeriodicityVector.size());
}
//================================================================================
cadsurf_session_t* _css;
cad_t * _cad;
dcad_t * _dcad;
- cad_t * _cleanc;
- dcad_t * _cleandc;
public:
BLSURF_Cleaner(context_t * ctx,
cadsurf_session_t* css,
cad_t * cad,
- dcad_t * dcad,
- cad_t * cleanc,
- dcad_t * cleandc)
+ dcad_t * dcad)
: _ctx ( ctx ),
_css ( css ),
_cad ( cad ),
- _dcad( dcad ),
- _cleanc( cleanc ),
- _cleandc( cleandc )
+ _dcad( dcad )
{
}
~BLSURF_Cleaner()
cad_delete(_cad); _cad = 0;
dcad_delete(_dcad); _dcad = 0;
- cad_delete(_cleanc); _cleanc = 0;
- dcad_delete(_cleandc); _cleandc = 0;
if ( !exceptContext )
{
context_delete(_ctx); _ctx = 0;
BRepBuilderAPI_MakePolygon wire;
const size_t i0 = tmpVertex.size();
- for ( size_t iN = 1; iN < wirePoints.size(); ++iN )
+ for ( size_t iN = 0; iN < wirePoints.size(); ++iN )
{
wire.Add( SMESH_TNodeXYZ( wirePoints[ iN ].node ));
origNodes.push_back( wirePoints[ iN ].node );
for ( ; nIt->more(); ++nbN )
{
const SMDS_MeshNode* n = static_cast<const SMDS_MeshNode*>( nIt->next() );
- TN2NMap::iterator n2nIt =
+ TN2NMap::iterator n2nIt =
_tmp2origNN.insert( _tmp2origNN.end(), make_pair( n, nullNode ));
if ( !n2nIt->second ) {
n->GetXYZ( xyz );
}
switch( nbN ) {
case 3: helper.AddFace( nodes[0], nodes[1], nodes[2] ); break;
- // case 6: helper.AddFace( nodes[0], nodes[1], nodes[2],
- // nodes[3], nodes[4], nodes[5]); break;
+ // case 6: helper.AddFace( nodes[0], nodes[1], nodes[2],
+ // nodes[3], nodes[4], nodes[5]); break;
case 4: helper.AddFace( nodes[0], nodes[1], nodes[2], nodes[3] ); break;
// case 9: helper.AddFace( nodes[0], nodes[1], nodes[2], nodes[3],
// nodes[4], nodes[5], nodes[6], nodes[7], nodes[8]); break;
double * _progress;
};
-
} // namespace
status_t curv_fun(real t, real *uv, real *dt, real *dtt, void *user_data);
this->SMESH_Algo::_progress = 1e-3; // prevent progress advancment while computing attractors
- if ( !compute( aMesh, aShape, /*allowSubMeshClearing=*/true ))
- return false;
+ bool viscousLayersMade =
+ ( aShape.ShapeType() == TopAbs_FACE &&
+ StdMeshers_ViscousLayers2D::HasProxyMesh( TopoDS::Face( aShape ), aMesh ));
- if ( _haveViscousLayers )
+ if ( !viscousLayersMade )
+ if ( !compute( aMesh, aShape, /*allowSubMeshClearing=*/true ))
+ return false;
+
+ if ( _haveViscousLayers || viscousLayersMade )
{
// Compute viscous layers
*/
// PreCAD
- // If user requests it, send the CAD through Distene preprocessor : PreCAD
- cad_t *cleanc = NULL; // preprocessed cad
- dcad_t *cleandc = NULL; // preprocessed dcad
- precad_session_t *pcs = precad_session_new(ctx);
- // Give both dcad and cad to precad
- precad_data_set_dcad(pcs, dcad);
- precad_data_set_cad(pcs, c);
cadsurf_session_t *css = cadsurf_session_new(ctx);
// an object that correctly deletes all cadsurf objects at destruction
- BLSURF_Cleaner cleaner( ctx,css,c,dcad,cleanc,cleandc );
+ BLSURF_Cleaner cleaner( ctx,css,c,dcad );
MESSAGE("BEGIN SetParameters");
- bool use_precad = false;
- SetParameters(_hypothesis, css, pcs, aShape, &use_precad);
+ SetParameters(_hypothesis, css, aShape);
MESSAGE("END SetParameters");
MESSAGE("_preCadFacesIDsPeriodicityVector.size() = " << _preCadFacesIDsPeriodicityVector.size());
iface = fmap.Add(f);
// std::string aFileName = "fmap_face_";
-// aFileName.append(to_string(iface));
+// aFileName.append(val_to_string(iface));
// aFileName.append(".brep");
// BRepTools::Write(f,aFileName.c_str());
* (For this face, it will be called by cadsurf with your_face_object_ptr
* as last parameter.
*/
+#if OCC_VERSION_MAJOR < 7
cad_face_t *fce = cad_face_new(c, iface, surf_fun, surfaces.back());
+#else
+ cad_face_t *fce = cad_face_new(c, iface, surf_fun, surfaces.back().get());
+#endif
/* by default a face has no tag (color).
The following call sets it to the same value as the Geom module ID : */
ic = emap.Add(e);
// std::string aFileName = "fmap_edge_";
-// aFileName.append(to_string(ic));
+// aFileName.append(val_to_string(ic));
// aFileName.append(".brep");
// BRepTools::Write(e,aFileName.c_str());
}
/* attach the edge to the current cadsurf face */
+#if OCC_VERSION_MAJOR < 7
cad_edge_t *edg = cad_edge_new(fce, ic, tmin, tmax, curv_fun, curves.back());
+#else
+ cad_edge_t *edg = cad_edge_new(fce, ic, tmin, tmax, curv_fun, curves.back().get());
+#endif
/* by default an edge has no tag (color).
The following call sets it to the same value as the edge_id : */
}
// std::string aFileName = "fmap_vertex_";
-// aFileName.append(to_string(*ip));
+// aFileName.append(val_to_string(*ip));
// aFileName.append(".brep");
// BRepTools::Write(v,aFileName.c_str());
MESSAGE("END PRECAD EDGES PERIODICITY");
}
- if (! _facesIDsPeriodicityVector.empty()){
- MESSAGE("INTO FACE PERIODICITY");
- for (std::size_t i=0; i < _facesIDsPeriodicityVector.size(); i++){
- int theFace1 = _facesIDsPeriodicityVector[i].first;
- int theFace2 = _facesIDsPeriodicityVector[i].second;
- MESSAGE("_facesIDsPeriodicityVector[" << i << "] = (" << theFace1 << ", " << theFace2 << ")");
- status = cad_add_face_periodicity(c, theFace1, theFace2);
- if(status != STATUS_OK){
- cout << "cad_add_face_periodicity failed with error code " << status << "\n";
- }
- }
- MESSAGE("END FACE PERIODICITY");
- }
-
-
- if (! _edgesIDsPeriodicityVector.empty()){
- MESSAGE("INTO EDGE PERIODICITY");
- for (std::size_t i=0; i < _edgesIDsPeriodicityVector.size(); i++){
- int theFace1 = _edgesIDsPeriodicityVector[i].theFace1ID;
- int theEdge1 = _edgesIDsPeriodicityVector[i].theEdge1ID;
- int theFace2 = _edgesIDsPeriodicityVector[i].theFace2ID;
- int theEdge2 = _edgesIDsPeriodicityVector[i].theEdge2ID;
- int edge_orientation = _edgesIDsPeriodicityVector[i].edge_orientation;
- MESSAGE("_edgesIDsPeriodicityVector[" << i << "] = (" << theFace1 << ", " << theEdge1 << ", " << theFace2 << ", " << theEdge2 << ", " << edge_orientation << ")");
- status = cad_add_edge_periodicity(c, theFace1, theEdge1, theFace2, theEdge2, edge_orientation);
- if(status != STATUS_OK){
- cout << "cad_add_edge_periodicity failed with error code " << status << "\n";
- }
- }
- MESSAGE("END EDGE PERIODICITY");
- }
-
- if (! _verticesIDsPeriodicityVector.empty()){
- MESSAGE("INTO VERTEX PERIODICITY");
- for (std::size_t i=0; i < _verticesIDsPeriodicityVector.size(); i++){
- int theEdge1 = _verticesIDsPeriodicityVector[i].theEdge1ID;
- int theVertex1 = _verticesIDsPeriodicityVector[i].theVertex1ID;
- int theEdge2 = _verticesIDsPeriodicityVector[i].theEdge2ID;
- int theVertex2 = _verticesIDsPeriodicityVector[i].theVertex2ID;
- MESSAGE("_verticesIDsPeriodicityVector[" << i << "] = (" << theEdge1 << ", " << theVertex1 << ", " << theEdge2 << ", " << theVertex2 << ")");
- status = cad_add_point_periodicity(c, theEdge1, theVertex1, theEdge2, theVertex2);
- if(status != STATUS_OK){
- cout << "cad_add_vertex_periodicity failed with error code " << status << "\n";
- }
- }
- MESSAGE("END VERTEX PERIODICITY");
- }
-
- ////
-
- if (use_precad) {
- MESSAGE("use_precad");
- /* Now launch the PreCAD process */
- status = precad_process(pcs);
- if(status != STATUS_OK){
- // TODO: raise an error if status < 0.
- cout << "================ WARNING =================== \n";
- stringstream msg;
- msg << "PreCAD processing failed with error code " << status << "\n";
- msg << *mcud._error;
- cout << msg.str();
- cout << "============================================ \n";
- // the text of _comment is set in message_cb by mcud->_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;
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);
}
if (_hypothesis)
GMFFileName = _hypothesis->GetGMFFile();
if (GMFFileName != "") {
- // bool GMFFileMode = _hypothesis->GetGMFFileMode();
bool asciiFound = (GMFFileName.find(".mesh", GMFFileName.length()-5) != std::string::npos);
bool binaryFound = (GMFFileName.find(".meshb",GMFFileName.length()-6) != std::string::npos);
if (!asciiFound && !binaryFound)
GMFFileName.append(".mesh");
mesh_write_mesh(msh, GMFFileName.c_str());
- //cout << GMFFileName << " created = " << SMESH_File(GMFFileName).exists() << endl;
}
/* retrieve mesh data (see meshgems/mesh.h) */
mesh_get_composite_tag_definition(msh, tag, &nb_tag, tags_buff);
if(nb_tag > 1)
tag=tags_buff[nb_tag-1];
- if ( tag > emap.Extent() )
+ if ( tag < 1 || tag > emap.Extent() )
{
std::cerr << "MG-CADSurf BUG:::: Edge tag " << tag
- << " more than nb CAD egdes (" << emap.Extent() << ")" << std::endl;
+ << " does not point to a CAD edge (nb edges " << emap.Extent() << ")" << std::endl;
continue;
}
if (tags[vtx[0]]) {
}
/* 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
{
}
// SetIsAlwaysComputed( true ) to sub-meshes of EDGEs w/o mesh
- TopLoc_Location loc; double f,l;
for (int i = 1; i <= emap.Extent(); i++)
if ( SMESH_subMesh* sm = aMesh.GetSubMeshContaining( emap( i )))
sm->SetIsAlwaysComputed( true );
status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data)
{
- //MESSAGE("size_on_surface")
TId2ClsAttractorVec::iterator f2attVec;
if (FaceId2PythonSmp.count(face_id) != 0){
- //MESSAGE("A size map is used to calculate size on face : "<<face_id)
- PyObject * pyresult = NULL;
- PyObject* new_stderr = NULL;
assert(Py_IsInitialized());
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
- pyresult = PyObject_CallFunction(FaceId2PythonSmp[face_id],(char*)"(f,f)",uv[0],uv[1]);
+ PyObject* pyresult = PyObject_CallFunction(FaceId2PythonSmp[face_id],(char*)"(f,f)",uv[0],uv[1]);
real result;
if ( pyresult != NULL) {
result = PyFloat_AsDouble(pyresult);
else{
fflush(stderr);
string err_description="";
- new_stderr = newPyStdOut(err_description);
+ PyObject* new_stderr = newPyStdOut(err_description);
+ PyObject* old_stderr = PySys_GetObject((char*)"stderr");
+ Py_INCREF(old_stderr);
PySys_SetObject((char*)"stderr", new_stderr);
PyErr_Print();
- PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+ PySys_SetObject((char*)"stderr", old_stderr);
Py_DECREF(new_stderr);
MESSAGE("Can't evaluate f(" << uv[0] << "," << uv[1] << ")" << " error is " << err_description);
result = *((real*)user_data);
status_t size_on_edge(integer edge_id, real t, real *size, void *user_data)
{
if (EdgeId2PythonSmp.count(edge_id) != 0){
- PyObject * pyresult = NULL;
- PyObject* new_stderr = NULL;
assert(Py_IsInitialized());
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
- pyresult = PyObject_CallFunction(EdgeId2PythonSmp[edge_id],(char*)"(f)",t);
+ PyObject* pyresult = PyObject_CallFunction(EdgeId2PythonSmp[edge_id],(char*)"(f)",t);
real result;
if ( pyresult != NULL) {
result = PyFloat_AsDouble(pyresult);
else{
fflush(stderr);
string err_description="";
- new_stderr = newPyStdOut(err_description);
+ PyObject* new_stderr = newPyStdOut(err_description);
+ PyObject* old_stderr = PySys_GetObject((char*)"stderr");
+ Py_INCREF(old_stderr);
PySys_SetObject((char*)"stderr", new_stderr);
PyErr_Print();
- PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+ PySys_SetObject((char*)"stderr", old_stderr);
Py_DECREF(new_stderr);
MESSAGE("Can't evaluate f(" << t << ")" << " error is " << err_description);
result = *((real*)user_data);
status_t size_on_vertex(integer point_id, real *size, void *user_data)
{
if (VertexId2PythonSmp.count(point_id) != 0){
- PyObject * pyresult = NULL;
- PyObject* new_stderr = NULL;
assert(Py_IsInitialized());
PyGILState_STATE gstate;
gstate = PyGILState_Ensure();
- pyresult = PyObject_CallFunction(VertexId2PythonSmp[point_id],(char*)"");
+ PyObject* pyresult = PyObject_CallFunction(VertexId2PythonSmp[point_id],(char*)"");
real result;
if ( pyresult != NULL) {
result = PyFloat_AsDouble(pyresult);
else {
fflush(stderr);
string err_description="";
- new_stderr = newPyStdOut(err_description);
+ PyObject* new_stderr = newPyStdOut(err_description);
+ PyObject* old_stderr = PySys_GetObject((char*)"stderr");
+ Py_INCREF(old_stderr);
PySys_SetObject((char*)"stderr", new_stderr);
PyErr_Print();
- PySys_SetObject((char*)"stderr", PySys_GetObject((char*)"__stderr__"));
+ PySys_SetObject((char*)"stderr", old_stderr);
Py_DECREF(new_stderr);
MESSAGE("Can't evaluate f()" << " error is " << err_description);
result = *((real*)user_data);