1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 // File : BLSURFPlugin_BLSURF.cxx
22 // Authors : Francis KLOSS (OCC) & Patrick LAUG (INRIA) & Lioka RAZAFINDRAZAKA (CEA)
23 // & Aurelien ALLEAUME (DISTENE)
24 // Size maps developement: Nicolas GEIMER (OCC) & Gilles DAVID (EURIWARE)
27 #include "BLSURFPlugin_BLSURF.hxx"
28 #include "BLSURFPlugin_Hypothesis.hxx"
31 #include <distene/api.h>
32 #include <distene/blsurf.h>
35 #include <structmember.h>
38 #include <Basics_Utils.hxx>
40 #include <SMESH_Gen.hxx>
41 #include <SMESH_Mesh.hxx>
42 #include <SMESH_ControlsDef.hxx>
43 #include <SMDSAbs_ElementType.hxx>
44 #include "SMESHDS_Group.hxx"
45 #include "SMESH_Group.hxx"
47 #include <utilities.h>
55 // OPENCASCADE includes
56 #include <BRep_Tool.hxx>
58 #include <TopExp_Explorer.hxx>
60 #include <NCollection_Map.hxx>
62 #include <Geom_Surface.hxx>
63 #include <Handle_Geom_Surface.hxx>
64 #include <Geom2d_Curve.hxx>
65 #include <Handle_Geom2d_Curve.hxx>
66 #include <Geom_Curve.hxx>
67 #include <Handle_Geom_Curve.hxx>
68 #include <Handle_AIS_InteractiveObject.hxx>
69 #include <TopoDS_Vertex.hxx>
70 #include <TopoDS_Edge.hxx>
71 #include <TopoDS_Wire.hxx>
72 #include <TopoDS_Face.hxx>
74 #include <gp_Pnt2d.hxx>
75 #include <TopTools_IndexedMapOfShape.hxx>
76 #include <TopoDS_Shape.hxx>
77 #include <BRep_Builder.hxx>
78 #include <BRepTools.hxx>
80 #include <TopTools_DataMapOfShapeInteger.hxx>
81 #include <GProp_GProps.hxx>
82 #include <BRepGProp.hxx>
88 #include <Standard_ErrorHandler.hxx>
89 #include <GeomAPI_ProjectPointOnCurve.hxx>
90 #include <GeomAPI_ProjectPointOnSurf.hxx>
93 // #include <BRepClass_FaceClassifier.hxx>
94 #include <TopTools_MapOfShape.hxx>
96 /* ==================================
97 * =========== PYTHON ==============
98 * ==================================*/
107 PyStdOut_dealloc(PyStdOut *self)
113 PyStdOut_write(PyStdOut *self, PyObject *args)
117 if (!PyArg_ParseTuple(args, "t#:write",&c, &l))
121 *(self->out)=*(self->out)+c;
127 static PyMethodDef PyStdOut_methods[] = {
128 {"write", (PyCFunction)PyStdOut_write, METH_VARARGS,
129 PyDoc_STR("write(string) -> None")},
130 {NULL, NULL} /* sentinel */
133 static PyMemberDef PyStdOut_memberlist[] = {
134 {"softspace", T_INT, offsetof(PyStdOut, softspace), 0,
135 "flag indicating that a space needs to be printed; used by print"},
136 {NULL} /* Sentinel */
139 static PyTypeObject PyStdOut_Type = {
140 /* The ob_type field must be initialized in the module init function
141 * to be portable to Windows without using C++. */
142 PyObject_HEAD_INIT(NULL)
145 sizeof(PyStdOut), /*tp_basicsize*/
148 (destructor)PyStdOut_dealloc, /*tp_dealloc*/
155 0, /*tp_as_sequence*/
160 PyObject_GenericGetAttr, /*tp_getattro*/
161 /* softspace is writable: we must supply tp_setattro */
162 PyObject_GenericSetAttr, /* tp_setattro */
164 Py_TPFLAGS_DEFAULT, /*tp_flags*/
168 0, /*tp_richcompare*/
169 0, /*tp_weaklistoffset*/
172 PyStdOut_methods, /*tp_methods*/
173 PyStdOut_memberlist, /*tp_members*/
187 PyObject * newPyStdOut( std::string& out )
190 self = PyObject_New(PyStdOut, &PyStdOut_Type);
195 return (PyObject*)self;
199 ////////////////////////END PYTHON///////////////////////////
201 //////////////////MY MAPS////////////////////////////////////////
202 TopTools_IndexedMapOfShape FacesWithSizeMap;
203 std::map<int,string> FaceId2SizeMap;
204 TopTools_IndexedMapOfShape EdgesWithSizeMap;
205 std::map<int,string> EdgeId2SizeMap;
206 TopTools_IndexedMapOfShape VerticesWithSizeMap;
207 std::map<int,string> VertexId2SizeMap;
209 std::map<int,PyObject*> FaceId2PythonSmp;
210 std::map<int,PyObject*> EdgeId2PythonSmp;
211 std::map<int,PyObject*> VertexId2PythonSmp;
213 std::map<int,std::vector<double> > FaceId2AttractorCoords;
215 TopTools_IndexedMapOfShape FacesWithEnforcedVertices;
216 std::map< int, std::set< std::vector<double> > > FaceId2EnforcedVertexCoords;
217 std::map< std::vector<double>, std::vector<double> > EnfVertex2ProjVertex;
219 bool HasSizeMapOnFace=false;
220 bool HasSizeMapOnEdge=false;
221 bool HasSizeMapOnVertex=false;
223 //=============================================================================
227 //=============================================================================
229 BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId, int studyId,
231 : SMESH_2D_Algo(hypId, studyId, gen)
233 MESSAGE("BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF");
236 _shapeType = (1 << TopAbs_FACE); // 1 bit /shape type
237 _compatibleHypothesis.push_back("BLSURF_Parameters");
238 _requireDescretBoundary = false;
239 _onlyUnaryInput = false;
242 smeshGen_i = SMESH_Gen_i::GetSMESHGen();
243 CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
244 SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
246 MESSAGE("studyid = " << _studyId);
249 myStudy = aStudyMgr->GetStudyByID(_studyId);
251 MESSAGE("myStudy->StudyId() = " << myStudy->StudyId());
253 /* Initialize the Python interpreter */
254 assert(Py_IsInitialized());
255 PyGILState_STATE gstate;
256 gstate = PyGILState_Ensure();
259 main_mod = PyImport_AddModule("__main__");
262 main_dict = PyModule_GetDict(main_mod);
264 PyRun_SimpleString("from math import *");
265 PyGILState_Release(gstate);
267 FacesWithSizeMap.Clear();
268 FaceId2SizeMap.clear();
269 EdgesWithSizeMap.Clear();
270 EdgeId2SizeMap.clear();
271 VerticesWithSizeMap.Clear();
272 VertexId2SizeMap.clear();
273 FaceId2PythonSmp.clear();
274 EdgeId2PythonSmp.clear();
275 VertexId2PythonSmp.clear();
276 FaceId2AttractorCoords.clear();
277 FacesWithEnforcedVertices.Clear();
278 FaceId2EnforcedVertexCoords.clear();
279 EnfVertex2ProjVertex.clear();
282 //=============================================================================
286 //=============================================================================
288 BLSURFPlugin_BLSURF::~BLSURFPlugin_BLSURF()
290 MESSAGE("BLSURFPlugin_BLSURF::~BLSURFPlugin_BLSURF");
294 //=============================================================================
298 //=============================================================================
300 bool BLSURFPlugin_BLSURF::CheckHypothesis
302 const TopoDS_Shape& aShape,
303 SMESH_Hypothesis::Hypothesis_Status& aStatus)
307 list<const SMESHDS_Hypothesis*>::const_iterator itl;
308 const SMESHDS_Hypothesis* theHyp;
310 const list<const SMESHDS_Hypothesis*>& hyps = GetUsedHypothesis(aMesh, aShape);
311 int nbHyp = hyps.size();
314 aStatus = SMESH_Hypothesis::HYP_OK;
315 return true; // can work with no hypothesis
319 theHyp = (*itl); // use only the first hypothesis
321 string hypName = theHyp->GetName();
323 if (hypName == "BLSURF_Parameters")
325 _hypothesis = static_cast<const BLSURFPlugin_Hypothesis*> (theHyp);
327 if ( _hypothesis->GetPhysicalMesh() == BLSURFPlugin_Hypothesis::DefaultSize &&
328 _hypothesis->GetGeometricMesh() == BLSURFPlugin_Hypothesis::DefaultGeom )
329 // hphy_flag = 0 and hgeo_flag = 0 is not allowed (spec)
330 aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
332 aStatus = SMESH_Hypothesis::HYP_OK;
335 aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE;
337 return aStatus == SMESH_Hypothesis::HYP_OK;
340 //=============================================================================
342 * Pass parameters to BLSURF
344 //=============================================================================
346 inline std::string to_string(double d)
348 std::ostringstream o;
353 inline std::string to_string(int i)
355 std::ostringstream o;
360 double _smp_phy_size;
361 status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data);
362 status_t size_on_edge(integer edge_id, real t, real *size, void *user_data);
363 status_t size_on_vertex(integer vertex_id, real *size, void *user_data);
365 double my_u_min=1e6,my_v_min=1e6,my_u_max=-1e6,my_v_max=-1e6;
371 /////////////////////////////////////////////////////////
372 projectionPoint getProjectionPoint(const TopoDS_Face& face, const gp_XYZ& point)
374 projectionPoint myPoint;
375 Handle(Geom_Surface) surface = BRep_Tool::Surface(face);
376 GeomAPI_ProjectPointOnSurf projector( point, surface );
377 if ( !projector.IsDone() || projector.NbPoints()==0 )
378 throw "getProjectionPoint: Can't project";
380 Quantity_Parameter u,v;
381 projector.LowerDistanceParameters(u,v);
382 myPoint.uv = gp_XY(u,v);
383 gp_Pnt aPnt = projector.NearestPoint();
384 myPoint.xyz = gp_XYZ(aPnt.X(),aPnt.Y(),aPnt.Z());
388 /////////////////////////////////////////////////////////
390 /////////////////////////////////////////////////////////
391 double getT(const TopoDS_Edge& edge, const gp_XYZ& point)
394 Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, f,l);
395 GeomAPI_ProjectPointOnCurve projector( point, curve);
396 if ( projector.NbPoints() == 0 )
398 return projector.LowerDistanceParameter();
401 /////////////////////////////////////////////////////////
402 TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry)
404 MESSAGE("BLSURFPlugin_BLSURF::entryToShape "<<entry );
405 GEOM::GEOM_Object_var aGeomObj;
406 TopoDS_Shape S = TopoDS_Shape();
407 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
408 SALOMEDS::GenericAttribute_var anAttr;
410 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) {
411 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
412 CORBA::String_var aVal = anIOR->Value();
413 CORBA::Object_var obj = myStudy->ConvertIORToObject(aVal);
414 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
416 if ( !aGeomObj->_is_nil() )
417 S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
421 /////////////////////////////////////////////////////////
422 void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList)
425 std::vector<double> coords;
426 std::vector<double> s_coords;
427 std::vector<double> enfVertex;
428 // BLSURFPlugin_Hypothesis::TEnfVertex enfVertex;
429 BLSURFPlugin_Hypothesis::TEnfVertexList::const_iterator evlIt = enfVertexList.begin();
431 for( ; evlIt != enfVertexList.end() ; ++evlIt ) {
438 MESSAGE("Enforced Vertex: " << xe << ", " << ye << ", " << ze);
439 // Get the (u,v) values of the enforced vertex on the face
440 projectionPoint myPoint = getProjectionPoint(TopoDS::Face(GeomShape),gp_XYZ(xe,ye,ze));
441 gp_XY uvPoint = myPoint.uv;
442 gp_XYZ xyzPoint = myPoint.xyz;
443 Standard_Real u0 = uvPoint.X();
444 Standard_Real v0 = uvPoint.Y();
445 Standard_Real x0 = xyzPoint.X();
446 Standard_Real y0 = xyzPoint.Y();
447 Standard_Real z0 = xyzPoint.Z();
448 MESSAGE("Projected Vertex: " << x0 << ", " << y0 << ", " << z0);
449 MESSAGE("Parametric coordinates: " << u0 << ", " << v0 );
450 coords.push_back(u0);
451 coords.push_back(v0);
452 coords.push_back(x0);
453 coords.push_back(y0);
454 coords.push_back(z0);
456 s_coords.push_back(x0);
457 s_coords.push_back(y0);
458 s_coords.push_back(z0);
460 // Save pair projected vertex / enf vertex
461 MESSAGE("Storing pair projected vertex / enf vertex:");
462 MESSAGE("("<< x0 << ", " << y0 << ", " << z0 <<") / (" << xe << ", " << ye << ", " << ze<<")");
463 EnfVertex2ProjVertex[s_coords] = enfVertex;
466 if (! FacesWithEnforcedVertices.Contains(TopoDS::Face(GeomShape))) {
467 key = FacesWithEnforcedVertices.Add(TopoDS::Face(GeomShape));
470 key = FacesWithEnforcedVertices.FindIndex(TopoDS::Face(GeomShape));
473 // If a node is already created by an attractor, do not create enforced vertex
474 int attractorKey = FacesWithSizeMap.FindIndex(TopoDS::Face(GeomShape));
475 bool sameAttractor = false;
476 if (attractorKey >= 0)
477 if (FaceId2AttractorCoords.count(attractorKey) > 0)
478 if (FaceId2AttractorCoords[attractorKey] == coords)
479 sameAttractor = true;
481 if (FaceId2EnforcedVertexCoords.find(key) != FaceId2EnforcedVertexCoords.end()) {
482 MESSAGE("Map of enf. vertex has key " << key)
483 MESSAGE("Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size())
485 FaceId2EnforcedVertexCoords[key].insert(coords); // there should be no redondant coords here (see std::set management)
487 MESSAGE("An attractor node is already defined: I don't add the enforced vertex");
488 MESSAGE("New Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size())
491 MESSAGE("Map of enf. vertex has not key " << key << ": creating it")
492 if (! sameAttractor) {
493 std::set< std::vector<double> > ens;
495 FaceId2EnforcedVertexCoords[key] = ens;
498 MESSAGE("An attractor node is already defined: I don't add the enforced vertex");
503 /////////////////////////////////////////////////////////
504 void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction)
506 MESSAGE("Attractor function: "<< AttractorFunction);
507 double xa, ya, za; // Coordinates of attractor point
508 double a, b; // Attractor parameter
509 bool createNode=false; // To create a node on attractor projection
511 const char *sep = ";";
512 // atIt->second has the following pattern:
513 // ATTRACTOR(xa;ya;za;a;b)
515 // xa;ya;za : coordinates of attractor
516 // a : desired size on attractor
517 // b : distance of influence of attractor
519 // We search the parameters in the string
521 pos1 = AttractorFunction.find(sep);
522 if (pos1!=string::npos)
523 xa = atof(AttractorFunction.substr(10, pos1-10).c_str());
525 pos2 = AttractorFunction.find(sep, pos1+1);
526 if (pos2!=string::npos) {
527 ya = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
531 pos2 = AttractorFunction.find(sep, pos1+1);
532 if (pos2!=string::npos) {
533 za = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
537 pos2 = AttractorFunction.find(sep, pos1+1);
538 if (pos2!=string::npos) {
539 a = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
543 pos2 = AttractorFunction.find(sep, pos1+1);
544 if (pos2!=string::npos) {
545 b = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
549 pos2 = AttractorFunction.find(")");
550 if (pos2!=string::npos) {
551 string createNodeStr = AttractorFunction.substr(pos1+1, pos2-pos1-1);
552 MESSAGE("createNode: " << createNodeStr);
553 createNode = (AttractorFunction.substr(pos1+1, pos2-pos1-1) == "True");
556 // Get the (u,v) values of the attractor on the face
557 projectionPoint myPoint = getProjectionPoint(TopoDS::Face(GeomShape),gp_XYZ(xa,ya,za));
558 gp_XY uvPoint = myPoint.uv;
559 gp_XYZ xyzPoint = myPoint.xyz;
560 Standard_Real u0 = uvPoint.X();
561 Standard_Real v0 = uvPoint.Y();
562 Standard_Real x0 = xyzPoint.X();
563 Standard_Real y0 = xyzPoint.Y();
564 Standard_Real z0 = xyzPoint.Z();
565 std::vector<double> coords;
566 coords.push_back(u0);
567 coords.push_back(v0);
568 coords.push_back(x0);
569 coords.push_back(y0);
570 coords.push_back(z0);
571 // We construct the python function
572 ostringstream attractorFunctionStream;
573 attractorFunctionStream << "def f(u,v): return ";
574 attractorFunctionStream << _smp_phy_size << "-(" << _smp_phy_size <<"-" << a << ")";
575 attractorFunctionStream << "*exp(-((u-("<<u0<<"))*(u-("<<u0<<"))+(v-("<<v0<<"))*(v-("<<v0<<")))/(" << b << "*" << b <<"))";
577 MESSAGE("Python function for attractor:" << std::endl << attractorFunctionStream.str());
580 if (! FacesWithSizeMap.Contains(TopoDS::Face(GeomShape))) {
581 key = FacesWithSizeMap.Add(TopoDS::Face(GeomShape));
584 key = FacesWithSizeMap.FindIndex(TopoDS::Face(GeomShape));
586 FaceId2SizeMap[key] =attractorFunctionStream.str();
588 MESSAGE("Creating node on ("<<x0<<","<<y0<<","<<z0<<")");
589 FaceId2AttractorCoords[key] = coords;
593 /////////////////////////////////////////////////////////
595 void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp,
596 blsurf_session_t * bls,
599 int _topology = BLSURFPlugin_Hypothesis::GetDefaultTopology();
600 int _physicalMesh = BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh();
601 double _phySize = BLSURFPlugin_Hypothesis::GetDefaultPhySize();
602 int _geometricMesh = BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh();
603 double _angleMeshS = BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS();
604 double _angleMeshC = BLSURFPlugin_Hypothesis::GetDefaultAngleMeshC();
605 double _gradation = BLSURFPlugin_Hypothesis::GetDefaultGradation();
606 bool _quadAllowed = BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed();
607 bool _decimesh = BLSURFPlugin_Hypothesis::GetDefaultDecimesh();
608 int _verb = BLSURFPlugin_Hypothesis::GetDefaultVerbosity();
611 MESSAGE("BLSURFPlugin_BLSURF::SetParameters");
612 _topology = (int) hyp->GetTopology();
613 _physicalMesh = (int) hyp->GetPhysicalMesh();
614 _phySize = hyp->GetPhySize();
615 _geometricMesh = (int) hyp->GetGeometricMesh();
616 _angleMeshS = hyp->GetAngleMeshS();
617 _angleMeshC = hyp->GetAngleMeshC();
618 _gradation = hyp->GetGradation();
619 _quadAllowed = hyp->GetQuadAllowed();
620 _decimesh = hyp->GetDecimesh();
621 _verb = hyp->GetVerbosity();
623 if ( hyp->GetPhyMin() != ::BLSURFPlugin_Hypothesis::undefinedDouble() )
624 blsurf_set_param(bls, "hphymin", to_string(hyp->GetPhyMin()).c_str());
625 if ( hyp->GetPhyMax() != ::BLSURFPlugin_Hypothesis::undefinedDouble() )
626 blsurf_set_param(bls, "hphymax", to_string(hyp->GetPhyMax()).c_str());
627 if ( hyp->GetGeoMin() != ::BLSURFPlugin_Hypothesis::undefinedDouble() )
628 blsurf_set_param(bls, "hgeomin", to_string(hyp->GetGeoMin()).c_str());
629 if ( hyp->GetGeoMax() != ::BLSURFPlugin_Hypothesis::undefinedDouble() )
630 blsurf_set_param(bls, "hgeomax", to_string(hyp->GetGeoMax()).c_str());
632 const BLSURFPlugin_Hypothesis::TOptionValues & opts = hyp->GetOptionValues();
633 BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt;
634 for ( opIt = opts.begin(); opIt != opts.end(); ++opIt )
635 if ( !opIt->second.empty() ) {
636 MESSAGE("blsurf_set_param(): " << opIt->first << " = " << opIt->second);
637 blsurf_set_param(bls, opIt->first.c_str(), opIt->second.c_str());
641 //0020968: EDF1545 SMESH: Problem in the creation of a mesh group on geometry
642 // GetDefaultPhySize() sometimes leads to computation failure
643 _phySize = mesh.GetShapeDiagonalSize() / _gen->GetBoundaryBoxSegmentation();
644 MESSAGE("BLSURFPlugin_BLSURF::SetParameters using defaults");
646 _smp_phy_size = _phySize;
647 blsurf_set_param(bls, "topo_points", _topology > 0 ? "1" : "0");
648 blsurf_set_param(bls, "topo_curves", _topology > 0 ? "1" : "0");
649 blsurf_set_param(bls, "topo_project", _topology > 0 ? "1" : "0");
650 blsurf_set_param(bls, "clean_boundary", _topology > 1 ? "1" : "0");
651 blsurf_set_param(bls, "close_boundary", _topology > 1 ? "1" : "0");
652 blsurf_set_param(bls, "hphy_flag", to_string(_physicalMesh).c_str());
653 // blsurf_set_param(bls, "hphy_flag", "2");
654 if ((to_string(_physicalMesh))=="2"){
655 TopoDS_Shape GeomShape;
656 TopAbs_ShapeEnum GeomType;
658 // Standard Size Maps
660 MESSAGE("Setting a Size Map");
661 const BLSURFPlugin_Hypothesis::TSizeMap sizeMaps = BLSURFPlugin_Hypothesis::GetSizeMapEntries(hyp);
662 BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt = sizeMaps.begin();
663 for ( ; smIt != sizeMaps.end(); ++smIt ) {
664 if ( !smIt->second.empty() ) {
665 MESSAGE("blsurf_set_sizeMap(): " << smIt->first << " = " << smIt->second);
666 GeomShape = entryToShape(smIt->first);
667 GeomType = GeomShape.ShapeType();
668 MESSAGE("Geomtype is " << GeomType);
671 if (GeomType == TopAbs_COMPOUND){
672 for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){
674 if (it.Value().ShapeType() == TopAbs_FACE){
675 HasSizeMapOnFace = true;
676 if (! FacesWithSizeMap.Contains(TopoDS::Face(it.Value()))) {
677 key = FacesWithSizeMap.Add(TopoDS::Face(it.Value()));
680 key = FacesWithSizeMap.FindIndex(TopoDS::Face(it.Value()));
681 // MESSAGE("Face with key " << key << " already in map");
683 FaceId2SizeMap[key] = smIt->second;
686 if (it.Value().ShapeType() == TopAbs_EDGE){
687 HasSizeMapOnEdge = true;
688 HasSizeMapOnFace = true;
689 if (! EdgesWithSizeMap.Contains(TopoDS::Edge(it.Value()))) {
690 key = EdgesWithSizeMap.Add(TopoDS::Edge(it.Value()));
693 key = EdgesWithSizeMap.FindIndex(TopoDS::Edge(it.Value()));
694 // MESSAGE("Edge with key " << key << " already in map");
696 EdgeId2SizeMap[key] = smIt->second;
699 if (it.Value().ShapeType() == TopAbs_VERTEX){
700 HasSizeMapOnVertex = true;
701 HasSizeMapOnEdge = true;
702 HasSizeMapOnFace = true;
703 if (! VerticesWithSizeMap.Contains(TopoDS::Vertex(it.Value()))) {
704 key = VerticesWithSizeMap.Add(TopoDS::Vertex(it.Value()));
707 key = VerticesWithSizeMap.FindIndex(TopoDS::Vertex(it.Value()));
708 MESSAGE("Group of vertices with key " << key << " already in map");
710 MESSAGE("Group of vertices with key " << key << " has a size map: " << smIt->second);
711 VertexId2SizeMap[key] = smIt->second;
716 if (GeomType == TopAbs_FACE){
717 HasSizeMapOnFace = true;
718 if (! FacesWithSizeMap.Contains(TopoDS::Face(GeomShape))) {
719 key = FacesWithSizeMap.Add(TopoDS::Face(GeomShape));
722 key = FacesWithSizeMap.FindIndex(TopoDS::Face(GeomShape));
723 // MESSAGE("Face with key " << key << " already in map");
725 FaceId2SizeMap[key] = smIt->second;
728 if (GeomType == TopAbs_EDGE){
729 HasSizeMapOnEdge = true;
730 HasSizeMapOnFace = true;
731 if (! EdgesWithSizeMap.Contains(TopoDS::Edge(GeomShape))) {
732 key = EdgesWithSizeMap.Add(TopoDS::Edge(GeomShape));
735 key = EdgesWithSizeMap.FindIndex(TopoDS::Edge(GeomShape));
736 // MESSAGE("Edge with key " << key << " already in map");
738 EdgeId2SizeMap[key] = smIt->second;
741 if (GeomType == TopAbs_VERTEX){
742 HasSizeMapOnVertex = true;
743 HasSizeMapOnEdge = true;
744 HasSizeMapOnFace = true;
745 if (! VerticesWithSizeMap.Contains(TopoDS::Vertex(GeomShape))) {
746 key = VerticesWithSizeMap.Add(TopoDS::Vertex(GeomShape));
749 key = VerticesWithSizeMap.FindIndex(TopoDS::Vertex(GeomShape));
750 MESSAGE("Vertex with key " << key << " already in map");
752 MESSAGE("Vertex with key " << key << " has a size map: " << smIt->second);
753 VertexId2SizeMap[key] = smIt->second;
761 MESSAGE("Setting Attractors");
762 const BLSURFPlugin_Hypothesis::TSizeMap attractors = BLSURFPlugin_Hypothesis::GetAttractorEntries(hyp);
763 BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
764 for ( ; atIt != attractors.end(); ++atIt ) {
765 if ( !atIt->second.empty() ) {
766 MESSAGE("blsurf_set_attractor(): " << atIt->first << " = " << atIt->second);
767 GeomShape = entryToShape(atIt->first);
768 GeomType = GeomShape.ShapeType();
770 if (GeomType == TopAbs_COMPOUND){
771 for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){
772 if (it.Value().ShapeType() == TopAbs_FACE){
773 HasSizeMapOnFace = true;
774 createAttractorOnFace(it.Value(), atIt->second);
779 if (GeomType == TopAbs_FACE){
780 HasSizeMapOnFace = true;
781 createAttractorOnFace(GeomShape, atIt->second);
784 if (GeomType == TopAbs_EDGE){
785 HasSizeMapOnEdge = true;
786 HasSizeMapOnFace = true;
787 EdgeId2SizeMap[TopoDS::Edge(GeomShape).HashCode(IntegerLast())] = atIt->second;
789 if (GeomType == TopAbs_VERTEX){
790 HasSizeMapOnVertex = true;
791 HasSizeMapOnEdge = true;
792 HasSizeMapOnFace = true;
793 VertexId2SizeMap[TopoDS::Vertex(GeomShape).HashCode(IntegerLast())] = atIt->second;
803 MESSAGE("Setting Enforced Vertices");
804 const BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap entryEnfVertexListMap = BLSURFPlugin_Hypothesis::GetAllEnforcedVertices(hyp);
805 BLSURFPlugin_Hypothesis::TEntryEnfVertexListMap::const_iterator enfIt = entryEnfVertexListMap.begin();
806 for ( ; enfIt != entryEnfVertexListMap.end(); ++enfIt ) {
807 if ( !enfIt->second.empty() ) {
808 GeomShape = entryToShape(enfIt->first);
809 GeomType = GeomShape.ShapeType();
811 if (GeomType == TopAbs_COMPOUND){
812 for (TopoDS_Iterator it (GeomShape); it.More(); it.Next()){
813 if (it.Value().ShapeType() == TopAbs_FACE){
814 HasSizeMapOnFace = true;
815 createEnforcedVertexOnFace(it.Value(), enfIt->second);
820 if (GeomType == TopAbs_FACE){
821 HasSizeMapOnFace = true;
822 createEnforcedVertexOnFace(GeomShape, enfIt->second);
827 // if (HasSizeMapOnFace){
828 // In all size map cases (hphy_flag = 2), at least map on face must be defined
829 MESSAGE("Setting Size Map on FACES ");
830 blsurf_data_set_sizemap_iso_cad_face(bls, size_on_surface, &_smp_phy_size);
833 if (HasSizeMapOnEdge){
834 MESSAGE("Setting Size Map on EDGES ");
835 blsurf_data_set_sizemap_iso_cad_edge(bls, size_on_edge, &_smp_phy_size);
837 if (HasSizeMapOnVertex){
838 MESSAGE("Setting Size Map on VERTICES ");
839 blsurf_data_set_sizemap_iso_cad_point(bls, size_on_vertex, &_smp_phy_size);
842 blsurf_set_param(bls, "hphydef", to_string(_phySize).c_str());
843 blsurf_set_param(bls, "hgeo_flag", to_string(_geometricMesh).c_str());
844 blsurf_set_param(bls, "relax_size", _decimesh ? "0": to_string(_geometricMesh).c_str());
845 blsurf_set_param(bls, "angle_meshs", to_string(_angleMeshS).c_str());
846 blsurf_set_param(bls, "angle_meshc", to_string(_angleMeshC).c_str());
847 blsurf_set_param(bls, "gradation", to_string(_gradation).c_str());
848 blsurf_set_param(bls, "patch_independent", _decimesh ? "1" : "0");
849 blsurf_set_param(bls, "element", _quadAllowed ? "q1.0" : "p1");
850 blsurf_set_param(bls, "verb", to_string(_verb).c_str());
853 status_t curv_fun(real t, real *uv, real *dt, real *dtt, void *user_data);
854 status_t surf_fun(real *uv, real *xyz, real*du, real *dv,
855 real *duu, real *duv, real *dvv, void *user_data);
856 status_t message_cb(message_t *msg, void *user_data);
857 status_t interrupt_cb(integer *interrupt_status, void *user_data);
859 //=============================================================================
863 //=============================================================================
865 bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) {
867 MESSAGE("BLSURFPlugin_BLSURF::Compute");
869 // if (aShape.ShapeType() == TopAbs_COMPOUND) {
870 // MESSAGE(" the shape is a COMPOUND");
873 // MESSAGE(" the shape is UNKNOWN");
876 // Fix problem with locales
877 Kernel_Utils::Localizer aLocalizer;
879 /* create a distene context (generic object) */
880 status_t status = STATUS_ERROR;
882 context_t *ctx = context_new();
884 /* Set the message callback in the working context */
885 context_set_message_callback(ctx, message_cb, &_comment);
886 context_set_interrupt_callback(ctx, interrupt_cb, NULL);
888 /* create the CAD object we will work on. It is associated to the context ctx. */
889 cad_t *c = cad_new(ctx);
891 blsurf_session_t *bls = blsurf_session_new(ctx);
893 FacesWithSizeMap.Clear();
894 FaceId2SizeMap.clear();
895 EdgesWithSizeMap.Clear();
896 EdgeId2SizeMap.clear();
897 VerticesWithSizeMap.Clear();
898 VertexId2SizeMap.clear();
900 MESSAGE("BEGIN SetParameters");
901 SetParameters(_hypothesis, bls, aMesh);
902 MESSAGE("END SetParameters");
904 /* Now fill the CAD object with data from your CAD
905 * environement. This is the most complex part of a successfull
909 // needed to prevent the opencascade memory managmement from freeing things
910 vector<Handle(Geom2d_Curve)> curves;
911 vector<Handle(Geom_Surface)> surfaces;
916 TopTools_IndexedMapOfShape fmap;
917 TopTools_IndexedMapOfShape emap;
918 TopTools_IndexedMapOfShape pmap;
921 FaceId2PythonSmp.clear();
923 EdgeId2PythonSmp.clear();
925 VertexId2PythonSmp.clear();
927 assert(Py_IsInitialized());
928 PyGILState_STATE gstate;
929 gstate = PyGILState_Ensure();
931 string theSizeMapStr;
933 /****************************************************************************************
935 *****************************************************************************************/
937 string bad_end = "return";
940 for (TopExp_Explorer face_iter(aShape,TopAbs_FACE);face_iter.More();face_iter.Next()) {
941 TopoDS_Face f=TopoDS::Face(face_iter.Current());
943 // make INTERNAL face oriented FORWARD (issue 0020993)
944 if (f.Orientation() != TopAbs_FORWARD && f.Orientation() != TopAbs_REVERSED )
945 f.Orientation(TopAbs_FORWARD);
947 if (fmap.FindIndex(f) > 0)
952 surfaces.push_back(BRep_Tool::Surface(f));
954 /* create an object representing the face for blsurf */
955 /* where face_id is an integer identifying the face.
956 * surf_function is the function that defines the surface
957 * (For this face, it will be called by blsurf with your_face_object_ptr
960 cad_face_t *fce = cad_face_new(c, iface, surf_fun, surfaces.back());
962 /* by default a face has no tag (color). The following call sets it to the same value as the face_id : */
963 cad_face_set_tag(fce, iface);
965 /* Set face orientation (optional if you want a well oriented output mesh)*/
966 if(f.Orientation() != TopAbs_FORWARD){
967 cad_face_set_orientation(fce, CAD_ORIENTATION_REVERSED);
969 cad_face_set_orientation(fce, CAD_ORIENTATION_FORWARD);
972 if (HasSizeMapOnFace){
973 // std::cout << "A size map is defined on a face" << std::endl;
975 faceKey = FacesWithSizeMap.FindIndex(f);
977 if (FaceId2SizeMap.find(faceKey)!=FaceId2SizeMap.end()){
978 theSizeMapStr = FaceId2SizeMap[faceKey];
979 // check if function ends with "return"
980 if (theSizeMapStr.find(bad_end) == (theSizeMapStr.size()-bad_end.size()-1))
982 // Expr To Python function, verification is performed at validation in GUI
983 PyObject * obj = NULL;
984 obj= PyRun_String(theSizeMapStr.c_str(), Py_file_input, main_dict, NULL);
986 PyObject * func = NULL;
987 func = PyObject_GetAttrString(main_mod, "f");
988 FaceId2PythonSmp[iface]=func;
989 FaceId2SizeMap.erase(faceKey);
992 // Specific size map = Attractor
993 std::map<int,std::vector<double> >::iterator attractor_iter = FaceId2AttractorCoords.begin();
995 for (; attractor_iter != FaceId2AttractorCoords.end(); ++attractor_iter) {
996 if (attractor_iter->first == faceKey) {
997 MESSAGE("Face indice: " << iface);
998 MESSAGE("Adding attractor");
1000 double xyzCoords[3] = {attractor_iter->second[2],
1001 attractor_iter->second[3],
1002 attractor_iter->second[4]};
1004 MESSAGE("Check position of vertex =(" << xyzCoords[0] << "," << xyzCoords[1] << "," << xyzCoords[2] << ")");
1005 gp_Pnt P(xyzCoords[0],xyzCoords[1],xyzCoords[2]);
1006 BRepClass_FaceClassifier scl(f,P,1e-7);
1007 // scl.Perform() is bugged. The function was rewritten
1009 BRepClass_FaceClassifierPerform(&scl,f,P,1e-7);
1010 TopAbs_State result = scl.State();
1011 MESSAGE("Position of point on face: "<<result);
1012 if ( result == TopAbs_OUT )
1013 MESSAGE("Point is out of face: node is not created");
1014 if ( result == TopAbs_UNKNOWN )
1015 MESSAGE("Point position on face is unknown: node is not created");
1016 if ( result == TopAbs_ON )
1017 MESSAGE("Point is on border of face: node is not created");
1018 if ( result == TopAbs_IN )
1020 // Point is inside face and not on border
1021 MESSAGE("Point is in face: node is created");
1022 double uvCoords[2] = {attractor_iter->second[0],attractor_iter->second[1]};
1024 MESSAGE("Add cad point on (u,v)=(" << uvCoords[0] << "," << uvCoords[1] << ") with id = " << iatt);
1025 cad_point_t* point_p = cad_point_new(fce, iatt, uvCoords);
1026 cad_point_set_tag(point_p, iatt);
1028 FaceId2AttractorCoords.erase(faceKey);
1032 // Enforced Vertices
1033 faceKey = FacesWithEnforcedVertices.FindIndex(f);
1034 std::map<int,std::set<std::vector<double> > >::const_iterator evmIt = FaceId2EnforcedVertexCoords.find(faceKey);
1035 if (evmIt != FaceId2EnforcedVertexCoords.end()) {
1036 MESSAGE("Some enforced vertices are defined");
1038 std::set<std::vector<double> > evl;
1039 // std::vector<double> ev;
1040 MESSAGE("Face indice: " << iface);
1041 MESSAGE("Adding enforced vertices");
1042 evl = evmIt->second;
1043 MESSAGE("Number of vertices to add: "<< evl.size());
1044 std::set< std::vector<double> >::const_iterator evlIt = evl.begin();
1045 for (; evlIt != evl.end(); ++evlIt) {
1046 std::vector<double> xyzCoords;
1047 xyzCoords.push_back(evlIt->at(2));
1048 xyzCoords.push_back(evlIt->at(3));
1049 xyzCoords.push_back(evlIt->at(4));
1050 // double xyzCoords[3] = {evlIt->at(2), evlIt->at(3), evlIt->at(4)};
1051 MESSAGE("Check position of vertex =(" << xyzCoords[0] << "," << xyzCoords[1] << "," << xyzCoords[2] << ")");
1052 gp_Pnt P(xyzCoords[0],xyzCoords[1],xyzCoords[2]);
1053 BRepClass_FaceClassifier scl(f,P,1e-7);
1054 // scl.Perform() is bugged. The function was rewritten
1056 BRepClass_FaceClassifierPerform(&scl,f,P,1e-7);
1057 TopAbs_State result = scl.State();
1058 MESSAGE("Position of point on face: "<<result);
1059 if ( result == TopAbs_OUT ) {
1060 MESSAGE("Point is out of face: node is not created");
1061 if (EnfVertex2ProjVertex.find(xyzCoords) != EnfVertex2ProjVertex.end())
1062 EnfVertex2ProjVertex.erase(xyzCoords);
1064 if ( result == TopAbs_UNKNOWN ) {
1065 MESSAGE("Point position on face is unknown: node is not created");
1066 if (EnfVertex2ProjVertex.find(xyzCoords) != EnfVertex2ProjVertex.end())
1067 EnfVertex2ProjVertex.erase(xyzCoords);
1069 if ( result == TopAbs_ON ) {
1070 MESSAGE("Point is on border of face: node is not created");
1071 if (EnfVertex2ProjVertex.find(xyzCoords) != EnfVertex2ProjVertex.end())
1072 EnfVertex2ProjVertex.erase(xyzCoords);
1074 if ( result == TopAbs_IN )
1076 // Point is inside face and not on border
1077 MESSAGE("Point is in face: node is created");
1078 // double uvCoords[2] = {ev[0],ev[1]};
1079 double uvCoords[2] = {evlIt->at(0),evlIt->at(1)};
1081 MESSAGE("Add cad point on (u,v)=(" << uvCoords[0] << "," << uvCoords[1] << ") with id = " << ienf);
1082 cad_point_t* point_p = cad_point_new(fce, ienf, uvCoords);
1083 cad_point_set_tag(point_p, ienf);
1086 FaceId2EnforcedVertexCoords.erase(faceKey);
1089 // std::cout << "No enforced vertex defined" << std::endl;
1093 /****************************************************************************************
1095 now create the edges associated to this face
1096 *****************************************************************************************/
1098 for (TopExp_Explorer edge_iter(f,TopAbs_EDGE);edge_iter.More();edge_iter.Next()) {
1099 TopoDS_Edge e = TopoDS::Edge(edge_iter.Current());
1100 int ic = emap.FindIndex(e);
1105 curves.push_back(BRep_Tool::CurveOnSurface(e, f, tmin, tmax));
1107 if (HasSizeMapOnEdge){
1108 edgeKey = EdgesWithSizeMap.FindIndex(e);
1109 if (EdgeId2SizeMap.find(edgeKey)!=EdgeId2SizeMap.end()) {
1110 MESSAGE("Sizemap defined on edge with index " << edgeKey);
1111 theSizeMapStr = EdgeId2SizeMap[edgeKey];
1112 if (theSizeMapStr.find(bad_end) == (theSizeMapStr.size()-bad_end.size()-1))
1114 // Expr To Python function, verification is performed at validation in GUI
1115 PyObject * obj = NULL;
1116 obj= PyRun_String(theSizeMapStr.c_str(), Py_file_input, main_dict, NULL);
1118 PyObject * func = NULL;
1119 func = PyObject_GetAttrString(main_mod, "f");
1120 EdgeId2PythonSmp[ic]=func;
1121 EdgeId2SizeMap.erase(edgeKey);
1125 /* attach the edge to the current blsurf face */
1126 cad_edge_t *edg = cad_edge_new(fce, ic, tmin, tmax, curv_fun, curves.back());
1128 /* by default an edge has no tag (color). The following call sets it to the same value as the edge_id : */
1129 cad_edge_set_tag(edg, ic);
1131 /* by default, an edge does not necessalry appear in the resulting mesh,
1132 unless the following property is set :
1134 cad_edge_set_property(edg, EDGE_PROPERTY_SOFT_REQUIRED);
1136 /* by default an edge is a boundary edge */
1137 if (e.Orientation() == TopAbs_INTERNAL)
1138 cad_edge_set_property(edg, EDGE_PROPERTY_INTERNAL);
1142 gp_Pnt2d e0 = curves.back()->Value(tmin);
1143 gp_Pnt ee0 = surfaces.back()->Value(e0.X(), e0.Y());
1144 Standard_Real d1=0,d2=0;
1147 /****************************************************************************************
1149 *****************************************************************************************/
1151 for (TopExp_Explorer ex_edge(e ,TopAbs_VERTEX); ex_edge.More(); ex_edge.Next()) {
1152 TopoDS_Vertex v = TopoDS::Vertex(ex_edge.Current());
1156 d1 = ee0.SquareDistance(BRep_Tool::Pnt(v));
1159 d2 = ee0.SquareDistance(BRep_Tool::Pnt(v));
1161 *ip = pmap.FindIndex(v);
1165 //vertexKey = VerticesWithSizeMap.FindIndex(v);
1166 if (HasSizeMapOnVertex){
1167 vertexKey = VerticesWithSizeMap.FindIndex(v);
1168 if (VertexId2SizeMap.find(vertexKey)!=VertexId2SizeMap.end()){
1169 theSizeMapStr = VertexId2SizeMap[vertexKey];
1170 //MESSAGE("VertexId2SizeMap[faceKey]: " << VertexId2SizeMap[vertexKey]);
1171 if (theSizeMapStr.find(bad_end) == (theSizeMapStr.size()-bad_end.size()-1))
1173 // Expr To Python function, verification is performed at validation in GUI
1174 PyObject * obj = NULL;
1175 obj= PyRun_String(theSizeMapStr.c_str(), Py_file_input, main_dict, NULL);
1177 PyObject * func = NULL;
1178 func = PyObject_GetAttrString(main_mod, "f");
1179 VertexId2PythonSmp[*ip]=func;
1180 VertexId2SizeMap.erase(vertexKey); // do not erase if using a vector
1185 // should not happen
1186 MESSAGE("An edge does not have 2 extremities.");
1189 // This defines the curves extremity connectivity
1190 cad_edge_set_extremities(edg, ip1, ip2);
1191 /* set the tag (color) to the same value as the extremity id : */
1192 cad_edge_set_extremities_tag(edg, ip1, ip2);
1195 cad_edge_set_extremities(edg, ip2, ip1);
1196 cad_edge_set_extremities_tag(edg, ip2, ip1);
1203 PyGILState_Release(gstate);
1205 blsurf_data_set_cad(bls, c);
1207 std::cout << std::endl;
1208 std::cout << "Beginning of Surface Mesh generation" << std::endl;
1209 std::cout << std::endl;
1211 // Issue 0019864. On DebianSarge, FE signals do not obey to OSD::SetSignal(false)
1213 feclearexcept( FE_ALL_EXCEPT );
1214 int oldFEFlags = fedisableexcept( FE_ALL_EXCEPT );
1220 status = blsurf_compute_mesh(bls);
1223 catch ( std::exception& exc ) {
1224 _comment += exc.what();
1226 catch (Standard_Failure& ex) {
1227 _comment += ex.DynamicType()->Name();
1228 if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) {
1230 _comment += ex.GetMessageString();
1234 if ( _comment.empty() )
1235 _comment = "Exception in blsurf_compute_mesh()";
1237 if ( status != STATUS_OK) {
1238 // There was an error while meshing
1239 blsurf_session_delete(bls);
1241 context_delete(ctx);
1243 return error(_comment);
1246 std::cout << std::endl;
1247 std::cout << "End of Surface Mesh generation" << std::endl;
1248 std::cout << std::endl;
1251 blsurf_data_get_mesh(bls, &msh);
1253 blsurf_session_delete(bls);
1255 context_delete(ctx);
1257 return error(_comment);
1261 /* retrieve mesh data (see distene/mesh.h) */
1262 integer nv, ne, nt, nq, vtx[4], tag;
1265 mesh_get_vertex_count(msh, &nv);
1266 mesh_get_edge_count(msh, &ne);
1267 mesh_get_triangle_count(msh, &nt);
1268 mesh_get_quadrangle_count(msh, &nq);
1271 SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
1272 SMDS_MeshNode** nodes = new SMDS_MeshNode*[nv+1];
1273 bool* tags = new bool[nv+1];
1275 /* enumerated vertices */
1276 for(int iv=1;iv<=nv;iv++) {
1277 mesh_get_vertex_coordinates(msh, iv, xyz);
1278 mesh_get_vertex_tag(msh, iv, &tag);
1279 // Issue 0020656. Use vertex coordinates
1280 if ( tag > 0 && tag <= pmap.Extent() ) {
1281 TopoDS_Vertex v = TopoDS::Vertex(pmap(tag));
1282 double tol = BRep_Tool::Tolerance( v );
1283 gp_Pnt p = BRep_Tool::Pnt( v );
1284 if ( p.IsEqual( gp_Pnt( xyz[0], xyz[1], xyz[2]), 2*tol))
1285 xyz[0] = p.X(), xyz[1] = p.Y(), xyz[2] = p.Z();
1287 tag = 0; // enforced or attracted vertex
1289 nodes[iv] = meshDS->AddNode(xyz[0], xyz[1], xyz[2]);
1292 // Create group of enforced vertices if requested
1294 std::vector<double> projVertex;
1295 projVertex.push_back((double)xyz[0]);
1296 projVertex.push_back((double)xyz[1]);
1297 projVertex.push_back((double)xyz[2]);
1298 std::map< std::vector<double>, std::vector<double> >::const_iterator projIt = EnfVertex2ProjVertex.find(projVertex);
1299 if (projIt != EnfVertex2ProjVertex.end()) {
1300 double x = (projIt->second)[0];
1301 double y = (projIt->second)[1];
1302 double z = (projIt->second)[2];
1303 BLSURFPlugin_Hypothesis::TEnfVertex enfVertex;
1304 enfVertex.push_back(x);
1305 enfVertex.push_back(y);
1306 enfVertex.push_back(z);
1308 BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap groupNameMap = _hypothesis->_GetEnforcedVertexGroupNameMap();
1309 BLSURFPlugin_Hypothesis::TEnfVertexGroupNameMap::const_iterator groupNameMapIt = groupNameMap.find(enfVertex);
1310 if (groupNameMapIt != groupNameMap.end()) {
1311 MESSAGE("Found enforced vertex @ " << xyz[0] << ", " << xyz[1] << ", " << xyz[2])
1312 BLSURFPlugin_Hypothesis::TEnfGroupName groupName = groupNameMapIt->second;
1313 if (groupName != "") {
1314 bool groupDone = false;
1315 const set<SMESHDS_GroupBase*>& allGroups = meshDS->GetGroups();
1316 set<SMESHDS_GroupBase*>::const_iterator grIt;
1317 MESSAGE("Parsing the groups of the mesh");
1318 for ( grIt = allGroups.begin(); grIt != allGroups.end(); ++grIt ) {
1319 SMESHDS_Group* group = dynamic_cast<SMESHDS_Group*>( *grIt );
1320 MESSAGE("Group: " << group->GetStoreName());
1321 if ( group && group->SMDSGroup().GetType()==SMDSAbs_Node
1322 && groupName.compare(group->GetStoreName())==0) {
1323 group->SMDSGroup().Add(nodes[iv]);
1324 // int id = // recuperer l'id SMESH du noeud
1325 // _hypothesis->AddEnfVertexIDs(groupName,id)
1327 MESSAGE("Successfully added enforced vertex to existing group " << groupName);
1334 SMESH_Group* aGroup = aMesh.AddGroup(SMDSAbs_Node, groupName.c_str(), groupId);
1336 SMESHDS_Group* aGroupDS = dynamic_cast<SMESHDS_Group*>( aGroup->GetGroupDS() );
1338 aGroupDS->SetStoreName( groupName.c_str() );
1339 aGroupDS->SMDSGroup().Add(nodes[iv]);
1340 MESSAGE("Successfully created enforced vertex group " << groupName);
1346 throw SALOME_Exception(LOCALIZED("A enforced vertex node was not added to a group"));
1349 MESSAGE("Group name is empty: '"<<groupName<<"' => group is not created");
1352 MESSAGE("No group name for projected vertex ("<<x<<","<<y<<","<<z<<")")
1355 // MESSAGE("No group name for vertex ("<<xyz[0]<<","<<xyz[1]<<","<<xyz[2]<<")")
1359 // internal point are tagged to zero
1360 if(tag > 0 && tag <= pmap.Extent() ){
1361 meshDS->SetNodeOnVertex(nodes[iv], TopoDS::Vertex(pmap(tag)));
1368 /* enumerate edges */
1369 for(int it=1;it<=ne;it++) {
1370 mesh_get_edge_vertices(msh, it, vtx);
1371 SMDS_MeshEdge* edg = meshDS->AddEdge(nodes[vtx[0]], nodes[vtx[1]]);
1372 mesh_get_edge_tag(msh, it, &tag);
1375 Set_NodeOnEdge(meshDS, nodes[vtx[0]], emap(tag));
1376 tags[vtx[0]] = false;
1379 Set_NodeOnEdge(meshDS, nodes[vtx[1]], emap(tag));
1380 tags[vtx[1]] = false;
1382 meshDS->SetMeshElementOnShape(edg, TopoDS::Edge(emap(tag)));
1386 /* enumerate triangles */
1387 for(int it=1;it<=nt;it++) {
1388 mesh_get_triangle_vertices(msh, it, vtx);
1389 SMDS_MeshFace* tri = meshDS->AddFace(nodes[vtx[0]], nodes[vtx[1]], nodes[vtx[2]]);
1390 mesh_get_triangle_tag(msh, it, &tag);
1391 meshDS->SetMeshElementOnShape(tri, TopoDS::Face(fmap(tag)));
1393 meshDS->SetNodeOnFace(nodes[vtx[0]], TopoDS::Face(fmap(tag)));
1394 tags[vtx[0]] = false;
1397 meshDS->SetNodeOnFace(nodes[vtx[1]], TopoDS::Face(fmap(tag)));
1398 tags[vtx[1]] = false;
1401 meshDS->SetNodeOnFace(nodes[vtx[2]], TopoDS::Face(fmap(tag)));
1402 tags[vtx[2]] = false;
1406 /* enumerate quadrangles */
1407 for(int it=1;it<=nq;it++) {
1408 mesh_get_quadrangle_vertices(msh, it, vtx);
1409 SMDS_MeshFace* quad = meshDS->AddFace(nodes[vtx[0]], nodes[vtx[1]], nodes[vtx[2]], nodes[vtx[3]]);
1410 mesh_get_quadrangle_tag(msh, it, &tag);
1411 meshDS->SetMeshElementOnShape(quad, TopoDS::Face(fmap(tag)));
1413 meshDS->SetNodeOnFace(nodes[vtx[0]], TopoDS::Face(fmap(tag)));
1414 tags[vtx[0]] = false;
1417 meshDS->SetNodeOnFace(nodes[vtx[1]], TopoDS::Face(fmap(tag)));
1418 tags[vtx[1]] = false;
1421 meshDS->SetNodeOnFace(nodes[vtx[2]], TopoDS::Face(fmap(tag)));
1422 tags[vtx[2]] = false;
1425 meshDS->SetNodeOnFace(nodes[vtx[3]], TopoDS::Face(fmap(tag)));
1426 tags[vtx[3]] = false;
1430 // SetIsAlwaysComputed( true ) to sub-meshes of degenerated EDGEs
1431 TopLoc_Location loc; double f,l;
1432 for (int i = 1; i <= emap.Extent(); i++)
1433 if ( BRep_Tool::Curve(TopoDS::Edge( emap( i )), loc, f,l).IsNull() )
1434 if ( SMESH_subMesh* sm = aMesh.GetSubMeshContaining( emap( i )))
1435 sm->SetIsAlwaysComputed( true );
1439 /* release the mesh object */
1440 blsurf_data_regain_mesh(bls, msh);
1442 /* clean up everything */
1443 blsurf_session_delete(bls);
1446 context_delete(ctx);
1448 // Issue 0019864. On DebianSarge, FE signals do not obey to OSD::SetSignal(false)
1450 if ( oldFEFlags > 0 )
1451 feenableexcept( oldFEFlags );
1452 feclearexcept( FE_ALL_EXCEPT );
1456 std::cout << "FacesWithSizeMap" << std::endl;
1457 FacesWithSizeMap.Statistics(std::cout);
1458 std::cout << "EdgesWithSizeMap" << std::endl;
1459 EdgesWithSizeMap.Statistics(std::cout);
1460 std::cout << "VerticesWithSizeMap" << std::endl;
1461 VerticesWithSizeMap.Statistics(std::cout);
1462 std::cout << "FacesWithEnforcedVertices" << std::endl;
1463 FacesWithEnforcedVertices.Statistics(std::cout);
1469 //=============================================================================
1473 //=============================================================================
1475 void BLSURFPlugin_BLSURF::Set_NodeOnEdge(SMESHDS_Mesh* meshDS, SMDS_MeshNode* node, const TopoDS_Shape& ed) {
1476 const TopoDS_Edge edge = TopoDS::Edge(ed);
1478 gp_Pnt pnt(node->X(), node->Y(), node->Z());
1480 Standard_Real p0 = 0.0;
1481 Standard_Real p1 = 1.0;
1482 TopLoc_Location loc;
1483 Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, loc, p0, p1);
1485 if ( !loc.IsIdentity() ) pnt.Transform( loc.Transformation().Inverted() );
1486 GeomAPI_ProjectPointOnCurve proj(pnt, curve, p0, p1);
1489 if ( proj.NbPoints() > 0 )
1491 pa = (double)proj.LowerDistanceParameter();
1492 // Issue 0020656. Move node if it is too far from edge
1493 gp_Pnt curve_pnt = curve->Value( pa );
1494 double dist2 = pnt.SquareDistance( curve_pnt );
1495 double tol = BRep_Tool::Tolerance( edge );
1496 if ( 1e-12 < dist2 && dist2 <= 2*tol*tol ) // large enough and within tolerance
1498 curve_pnt.Transform( loc );
1499 meshDS->MoveNode( node, curve_pnt.X(), curve_pnt.Y(), curve_pnt.Z() );
1502 // GProp_GProps LProps;
1503 // BRepGProp::LinearProperties(ed, LProps);
1504 // double lg = (double)LProps.Mass();
1506 meshDS->SetNodeOnEdge(node, edge, pa);
1509 //=============================================================================
1513 //=============================================================================
1515 ostream & BLSURFPlugin_BLSURF::SaveTo(ostream & save)
1520 //=============================================================================
1524 //=============================================================================
1526 istream & BLSURFPlugin_BLSURF::LoadFrom(istream & load)
1531 //=============================================================================
1535 //=============================================================================
1537 ostream & operator << (ostream & save, BLSURFPlugin_BLSURF & hyp)
1539 return hyp.SaveTo( save );
1542 //=============================================================================
1546 //=============================================================================
1548 istream & operator >> (istream & load, BLSURFPlugin_BLSURF & hyp)
1550 return hyp.LoadFrom( load );
1553 /* Curve definition function See cad_curv_t in file distene/cad.h for
1555 * NOTE : if when your CAD systems evaluates second
1556 * order derivatives it also computes first order derivatives and
1557 * function evaluation, you can optimize this example by making only
1558 * one CAD call and filling the necessary uv, dt, dtt arrays.
1560 status_t curv_fun(real t, real *uv, real *dt, real *dtt, void *user_data)
1562 /* t is given. It contains the t (time) 1D parametric coordintaes
1563 of the point PreCAD/BLSurf is querying on the curve */
1565 /* user_data identifies the edge PreCAD/BLSurf is querying
1566 * (see cad_edge_new later in this example) */
1567 const Geom2d_Curve*pargeo = (const Geom2d_Curve*) user_data;
1570 /* BLSurf is querying the function evaluation */
1573 uv[0]=P.X(); uv[1]=P.Y();
1577 /* query for the first order derivatives */
1580 dt[0]=V1.X(); dt[1]=V1.Y();
1584 /* query for the second order derivatives */
1587 dtt[0]=V2.X(); dtt[1]=V2.Y();
1593 /* Surface definition function.
1594 * See cad_surf_t in file distene/cad.h for more information.
1595 * NOTE : if when your CAD systems evaluates second order derivatives it also
1596 * computes first order derivatives and function evaluation, you can optimize
1597 * this example by making only one CAD call and filling the necessary xyz, du, dv, etc..
1600 status_t surf_fun(real *uv, real *xyz, real*du, real *dv,
1601 real *duu, real *duv, real *dvv, void *user_data)
1603 /* uv[2] is given. It contains the u,v coordinates of the point
1604 * PreCAD/BLSurf is querying on the surface */
1606 /* user_data identifies the face PreCAD/BLSurf is querying (see
1607 * cad_face_new later in this example)*/
1608 const Geom_Surface* geometry = (const Geom_Surface*) user_data;
1612 P=geometry->Value(uv[0],uv[1]); // S.D0(U,V,P);
1613 xyz[0]=P.X(); xyz[1]=P.Y(); xyz[2]=P.Z();
1620 geometry->D1(uv[0],uv[1],P,D1U,D1V);
1621 du[0]=D1U.X(); du[1]=D1U.Y(); du[2]=D1U.Z();
1622 dv[0]=D1V.X(); dv[1]=D1V.Y(); dv[2]=D1V.Z();
1625 if(duu && duv && dvv){
1629 gp_Vec D2U,D2V,D2UV;
1631 geometry->D2(uv[0],uv[1],P,D1U,D1V,D2U,D2V,D2UV);
1632 duu[0]=D2U.X(); duu[1]=D2U.Y(); duu[2]=D2U.Z();
1633 duv[0]=D2UV.X(); duv[1]=D2UV.Y(); duv[2]=D2UV.Z();
1634 dvv[0]=D2V.X(); dvv[1]=D2V.Y(); dvv[2]=D2V.Z();
1641 status_t size_on_surface(integer face_id, real *uv, real *size, void *user_data)
1644 if (my_u_min > uv[0]) {
1647 if (my_v_min > uv[1]) {
1650 if (my_u_max < uv[0]) {
1653 if (my_v_max < uv[1]) {
1658 if (FaceId2PythonSmp.count(face_id) != 0){
1659 PyObject * pyresult = NULL;
1660 PyObject* new_stderr = NULL;
1661 assert(Py_IsInitialized());
1662 PyGILState_STATE gstate;
1663 gstate = PyGILState_Ensure();
1664 pyresult = PyObject_CallFunction(FaceId2PythonSmp[face_id],"(f,f)",uv[0],uv[1]);
1666 if ( pyresult == NULL){
1668 string err_description="";
1669 new_stderr = newPyStdOut(err_description);
1670 PySys_SetObject("stderr", new_stderr);
1672 PySys_SetObject("stderr", PySys_GetObject("__stderr__"));
1673 Py_DECREF(new_stderr);
1674 MESSAGE("Can't evaluate f(" << uv[0] << "," << uv[1] << ")" << " error is " << err_description);
1675 result = *((double*)user_data);
1678 result = PyFloat_AsDouble(pyresult);
1679 Py_DECREF(pyresult);
1682 //MESSAGE("f(" << uv[0] << "," << uv[1] << ")" << " = " << result);
1683 PyGILState_Release(gstate);
1686 *size = *((double*)user_data);
1691 status_t size_on_edge(integer edge_id, real t, real *size, void *user_data)
1693 if (EdgeId2PythonSmp.count(edge_id) != 0){
1694 PyObject * pyresult = NULL;
1695 PyObject* new_stderr = NULL;
1696 assert(Py_IsInitialized());
1697 PyGILState_STATE gstate;
1698 gstate = PyGILState_Ensure();
1699 pyresult = PyObject_CallFunction(EdgeId2PythonSmp[edge_id],"(f)",t);
1701 if ( pyresult == NULL){
1703 string err_description="";
1704 new_stderr = newPyStdOut(err_description);
1705 PySys_SetObject("stderr", new_stderr);
1707 PySys_SetObject("stderr", PySys_GetObject("__stderr__"));
1708 Py_DECREF(new_stderr);
1709 MESSAGE("Can't evaluate f(" << t << ")" << " error is " << err_description);
1710 result = *((double*)user_data);
1713 result = PyFloat_AsDouble(pyresult);
1714 Py_DECREF(pyresult);
1717 PyGILState_Release(gstate);
1720 *size = *((double*)user_data);
1725 status_t size_on_vertex(integer point_id, real *size, void *user_data)
1727 if (VertexId2PythonSmp.count(point_id) != 0){
1728 PyObject * pyresult = NULL;
1729 PyObject* new_stderr = NULL;
1730 assert(Py_IsInitialized());
1731 PyGILState_STATE gstate;
1732 gstate = PyGILState_Ensure();
1733 pyresult = PyObject_CallFunction(VertexId2PythonSmp[point_id],"");
1735 if ( pyresult == NULL){
1737 string err_description="";
1738 new_stderr = newPyStdOut(err_description);
1739 PySys_SetObject("stderr", new_stderr);
1741 PySys_SetObject("stderr", PySys_GetObject("__stderr__"));
1742 Py_DECREF(new_stderr);
1743 MESSAGE("Can't evaluate f()" << " error is " << err_description);
1744 result = *((double*)user_data);
1747 result = PyFloat_AsDouble(pyresult);
1748 Py_DECREF(pyresult);
1751 PyGILState_Release(gstate);
1754 *size = *((double*)user_data);
1760 * The following function will be called for PreCAD/BLSurf message
1761 * printing. See context_set_message_callback (later in this
1762 * template) for how to set user_data.
1764 status_t message_cb(message_t *msg, void *user_data)
1766 integer errnumber = 0;
1768 message_get_number(msg, &errnumber);
1769 message_get_description(msg, &desc);
1770 if ( errnumber < 0 ) {
1771 string * error = (string*)user_data;
1772 // if ( !error->empty() )
1774 // remove ^A from the tail
1775 int len = strlen( desc );
1776 while (len > 0 && desc[len-1] != '\n')
1778 error->append( desc, len );
1781 std::cout << desc << std::endl;
1786 /* This is the interrupt callback. PreCAD/BLSurf will call this
1787 * function regularily. See the file distene/interrupt.h
1789 status_t interrupt_cb(integer *interrupt_status, void *user_data)
1791 integer you_want_to_continue = 1;
1793 if(you_want_to_continue)
1794 *interrupt_status = INTERRUPT_CONTINUE;
1795 else /* you want to stop BLSurf */
1796 *interrupt_status = INTERRUPT_STOP;
1801 //=============================================================================
1805 //=============================================================================
1806 bool BLSURFPlugin_BLSURF::Evaluate(SMESH_Mesh& aMesh,
1807 const TopoDS_Shape& aShape,
1808 MapShapeNbElems& aResMap)
1810 int _physicalMesh = BLSURFPlugin_Hypothesis::GetDefaultPhysicalMesh();
1811 double _phySize = BLSURFPlugin_Hypothesis::GetDefaultPhySize();
1812 //int _geometricMesh = BLSURFPlugin_Hypothesis::GetDefaultGeometricMesh();
1813 //double _angleMeshS = BLSURFPlugin_Hypothesis::GetDefaultAngleMeshS();
1814 double _angleMeshC = BLSURFPlugin_Hypothesis::GetDefaultAngleMeshC();
1815 bool _quadAllowed = BLSURFPlugin_Hypothesis::GetDefaultQuadAllowed();
1817 _physicalMesh = (int) _hypothesis->GetPhysicalMesh();
1818 _phySize = _hypothesis->GetPhySize();
1819 //_geometricMesh = (int) hyp->GetGeometricMesh();
1820 //_angleMeshS = hyp->GetAngleMeshS();
1821 _angleMeshC = _hypothesis->GetAngleMeshC();
1822 _quadAllowed = _hypothesis->GetQuadAllowed();
1825 bool IsQuadratic = false;
1830 TopTools_DataMapOfShapeInteger EdgesMap;
1831 double fullLen = 0.0;
1832 double fullNbSeg = 0;
1833 for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) {
1834 TopoDS_Edge E = TopoDS::Edge( exp.Current() );
1835 if( EdgesMap.IsBound(E) )
1837 SMESH_subMesh *sm = aMesh.GetSubMesh(E);
1838 double aLen = SMESH_Algo::EdgeLength(E);
1841 if(_physicalMesh==1) {
1842 nb1d = (int)( aLen/_phySize + 1 );
1847 Handle(Geom_Curve) C = BRep_Tool::Curve(E,f,l);
1848 double fullAng = 0.0;
1849 double dp = (l-f)/200;
1854 for(int j=2; j<=200; j++) {
1857 fullAng += fabs(V1.Angle(V2));
1861 nb1d = (int)( fullAng/_angleMeshC + 1 );
1864 std::vector<int> aVec(SMDSEntity_Last);
1865 for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
1866 if( IsQuadratic > 0 ) {
1867 aVec[SMDSEntity_Node] = 2*nb1d - 1;
1868 aVec[SMDSEntity_Quad_Edge] = nb1d;
1871 aVec[SMDSEntity_Node] = nb1d - 1;
1872 aVec[SMDSEntity_Edge] = nb1d;
1874 aResMap.insert(std::make_pair(sm,aVec));
1875 EdgesMap.Bind(E,nb1d);
1877 double ELen = fullLen/fullNbSeg;
1881 // try to evaluate as in MEFISTO
1882 for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
1883 TopoDS_Face F = TopoDS::Face( exp.Current() );
1884 SMESH_subMesh *sm = aMesh.GetSubMesh(F);
1886 BRepGProp::SurfaceProperties(F,G);
1887 double anArea = G.Mass();
1889 std::vector<int> nb1dVec;
1890 for (TopExp_Explorer exp1(F,TopAbs_EDGE); exp1.More(); exp1.Next()) {
1891 int nbSeg = EdgesMap.Find(exp1.Current());
1893 nb1dVec.push_back( nbSeg );
1896 int nbTria = (int) ( anArea/( ELen*ELen*sqrt(3.) / 4 ) );
1897 int nbNodes = (int) ( ( nbTria*3 - (nb1d-1)*2 ) / 6 + 1 );
1900 if ( nb1dVec.size() == 4 ) // quadrangle geom face
1902 int n1 = nb1dVec[0], n2 = nb1dVec[ nb1dVec[1] == nb1dVec[0] ? 2 : 1 ];
1904 nbNodes = (n1 + 1) * (n2 + 1);
1909 nbTria = nbQuad = nbTria / 3 + 1;
1912 std::vector<int> aVec(SMDSEntity_Last,0);
1914 int nb1d_in = (nbTria*3 - nb1d) / 2;
1915 aVec[SMDSEntity_Node] = nbNodes + nb1d_in;
1916 aVec[SMDSEntity_Quad_Triangle] = nbTria;
1917 aVec[SMDSEntity_Quad_Quadrangle] = nbQuad;
1920 aVec[SMDSEntity_Node] = nbNodes;
1921 aVec[SMDSEntity_Triangle] = nbTria;
1922 aVec[SMDSEntity_Quadrangle] = nbQuad;
1924 aResMap.insert(std::make_pair(sm,aVec));
1931 BRepGProp::VolumeProperties(aShape,G);
1932 double aVolume = G.Mass();
1933 double tetrVol = 0.1179*ELen*ELen*ELen;
1934 int nbVols = int(aVolume/tetrVol);
1935 int nb1d_in = int(( nbVols*6 - fullNbSeg ) / 6 );
1936 std::vector<int> aVec(SMDSEntity_Last);
1937 for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
1939 aVec[SMDSEntity_Node] = nb1d_in/3 + 1 + nb1d_in;
1940 aVec[SMDSEntity_Quad_Tetra] = nbVols;
1943 aVec[SMDSEntity_Node] = nb1d_in/3 + 1;
1944 aVec[SMDSEntity_Tetra] = nbVols;
1946 SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
1947 aResMap.insert(std::make_pair(sm,aVec));
1952 //=============================================================================
1954 * Rewritting of the BRepClass_FaceClassifier::Perform function which is bugged (CAS 6.3sp6)
1955 * Following line was added:
1956 * myExtrem.Perform(P);
1958 //=============================================================================
1959 void BLSURFPlugin_BLSURF::BRepClass_FaceClassifierPerform(BRepClass_FaceClassifier* fc,
1960 const TopoDS_Face& face,
1962 const Standard_Real Tol)
1964 //-- Voir BRepExtrema_ExtPF.cxx
1965 BRepAdaptor_Surface Surf(face);
1966 Standard_Real U1, U2, V1, V2;
1967 BRepTools::UVBounds(face, U1, U2, V1, V2);
1968 Extrema_ExtPS myExtrem;
1969 myExtrem.Initialize(Surf, U1, U2, V1, V2, Tol, Tol);
1970 myExtrem.Perform(P);
1971 //----------------------------------------------------------
1972 //-- On cherche le point le plus proche , PUIS
1973 //-- On le classifie.
1974 Standard_Integer nbv = 0; // xpu
1975 Standard_Real MaxDist = RealLast();
1976 Standard_Integer indice = 0;
1977 if(myExtrem.IsDone()) {
1978 nbv = myExtrem.NbExt();
1979 for (Standard_Integer i = 1; i <= nbv; i++) {
1980 Standard_Real d = myExtrem.Value(i);
1990 Standard_Real U1,U2;
1991 myExtrem.Point(indice).Parameter(U1, U2);
1992 Puv.SetCoord(U1, U2);
1993 fc->Perform(face, Puv, Tol);
1996 fc->Perform(face, gp_Pnt2d(U1-1.0,V1 - 1.0), Tol); //-- NYI etc BUG PAS BEAU En attendant l acces a rejected
1997 //-- le resultat est TopAbs_OUT;