+
+ if (HasSizeMapOnFace){
+// MESSAGE("A size map is defined on a face")
+// std::cout << "A size map is defined on a face" << std::endl;
+ // Classic size map
+ faceKey = FacesWithSizeMap.FindIndex(f);
+
+
+ if (FaceId2SizeMap.find(faceKey)!=FaceId2SizeMap.end()){
+ MESSAGE("A size map is defined on face :"<<faceKey)
+ theSizeMapStr = FaceId2SizeMap[faceKey];
+ // check if function ends with "return"
+ if (theSizeMapStr.find(bad_end) == (theSizeMapStr.size()-bad_end.size()-1))
+ continue;
+ // Expr To Python function, verification is performed at validation in GUI
+ PyObject * obj = NULL;
+ obj= PyRun_String(theSizeMapStr.c_str(), Py_file_input, main_dict, NULL);
+ Py_DECREF(obj);
+ PyObject * func = NULL;
+ func = PyObject_GetAttrString(main_mod, "f");
+ FaceId2PythonSmp[iface]=func;
+ FaceId2SizeMap.erase(faceKey);
+ }
+
+ // Specific size map = Attractor
+ std::map<int,std::vector<double> >::iterator attractor_iter = FaceId2AttractorCoords.begin();
+ int iatt=0;
+ for (; attractor_iter != FaceId2AttractorCoords.end(); ++attractor_iter) {
+ if (attractor_iter->first == faceKey) {
+ MESSAGE("Face indice: " << iface);
+ MESSAGE("Adding attractor");
+
+ double xyzCoords[3] = {attractor_iter->second[2],
+ attractor_iter->second[3],
+ attractor_iter->second[4]};
+
+ MESSAGE("Check position of vertex =(" << xyzCoords[0] << "," << xyzCoords[1] << "," << xyzCoords[2] << ")");
+ gp_Pnt P(xyzCoords[0],xyzCoords[1],xyzCoords[2]);
+ BRepClass_FaceClassifier scl(f,P,1e-7);
+ // scl.Perform() is bugged. The function was rewritten
+// scl.Perform();
+ BRepClass_FaceClassifierPerform(&scl,f,P,1e-7);
+ TopAbs_State result = scl.State();
+ MESSAGE("Position of point on face: "<<result);
+ if ( result == TopAbs_OUT )
+ MESSAGE("Point is out of face: node is not created");
+ if ( result == TopAbs_UNKNOWN )
+ MESSAGE("Point position on face is unknown: node is not created");
+ if ( result == TopAbs_ON )
+ MESSAGE("Point is on border of face: node is not created");
+ if ( result == TopAbs_IN )
+ {
+ // Point is inside face and not on border
+ MESSAGE("Point is in face: node is created");
+ double uvCoords[2] = {attractor_iter->second[0],attractor_iter->second[1]};
+ iatt++;
+ MESSAGE("Add cad point on (u,v)=(" << uvCoords[0] << "," << uvCoords[1] << ") with id = " << iatt);
+ cad_point_t* point_p = cad_point_new(fce, iatt, uvCoords);
+ cad_point_set_tag(point_p, iatt);
+ }
+ FaceId2AttractorCoords.erase(faceKey);
+ }
+ }
+
+ // Class Attractors
+ std::map<int,BLSURFPlugin_Attractor* >::iterator clAttractor_iter = FaceId2ClassAttractor.find(faceKey);
+ if (clAttractor_iter != FaceId2ClassAttractor.end()){
+ MESSAGE("Face indice: " << iface);
+ MESSAGE("Adding attractor");
+ FaceIndex2ClassAttractor[iface]=clAttractor_iter->second;
+ FaceId2ClassAttractor.erase(clAttractor_iter);
+ }
+ }
+
+ // Enforced Vertices
+ faceKey = FacesWithEnforcedVertices.FindIndex(f);
+ std::map<int,BLSURFPlugin_Hypothesis::TEnfVertexCoordsList >::const_iterator evmIt = FaceId2EnforcedVertexCoords.find(faceKey);
+ if (evmIt != FaceId2EnforcedVertexCoords.end()) {
+ MESSAGE("Some enforced vertices are defined");
+ BLSURFPlugin_Hypothesis::TEnfVertexCoordsList evl;
+ MESSAGE("Face indice: " << iface);
+ MESSAGE("Adding enforced vertices");
+ evl = evmIt->second;
+ MESSAGE("Number of vertices to add: "<< evl.size());
+ BLSURFPlugin_Hypothesis::TEnfVertexCoordsList::const_iterator evlIt = evl.begin();
+ for (; evlIt != evl.end(); ++evlIt) {
+ BLSURFPlugin_Hypothesis::TEnfVertexCoords xyzCoords;
+ xyzCoords.push_back(evlIt->at(2));
+ xyzCoords.push_back(evlIt->at(3));
+ xyzCoords.push_back(evlIt->at(4));
+ MESSAGE("Check position of vertex =(" << xyzCoords[0] << "," << xyzCoords[1] << "," << xyzCoords[2] << ")");
+ gp_Pnt P(xyzCoords[0],xyzCoords[1],xyzCoords[2]);
+ BRepClass_FaceClassifier scl(f,P,1e-7);
+ // scl.Perform() is bugged. The function was rewritten
+// scl.Perform();
+ BRepClass_FaceClassifierPerform(&scl,f,P,1e-7);
+ TopAbs_State result = scl.State();
+ MESSAGE("Position of point on face: "<<result);
+ if ( result == TopAbs_OUT ) {
+ MESSAGE("Point is out of face: node is not created");
+ if (EnfVertexCoords2ProjVertex.find(xyzCoords) != EnfVertexCoords2ProjVertex.end()) {
+ EnfVertexCoords2ProjVertex.erase(xyzCoords);
+ EnfVertexCoords2EnfVertexList.erase(xyzCoords);
+ }
+ }
+ if ( result == TopAbs_UNKNOWN ) {
+ MESSAGE("Point position on face is unknown: node is not created");
+ if (EnfVertexCoords2ProjVertex.find(xyzCoords) != EnfVertexCoords2ProjVertex.end()) {
+ EnfVertexCoords2ProjVertex.erase(xyzCoords);
+ EnfVertexCoords2EnfVertexList.erase(xyzCoords);
+ }
+ }
+ if ( result == TopAbs_ON ) {
+ MESSAGE("Point is on border of face: node is not created");
+ if (EnfVertexCoords2ProjVertex.find(xyzCoords) != EnfVertexCoords2ProjVertex.end()) {
+ EnfVertexCoords2ProjVertex.erase(xyzCoords);
+ EnfVertexCoords2EnfVertexList.erase(xyzCoords);
+ }
+ }
+ if ( result == TopAbs_IN )
+ {
+ // Point is inside face and not on border
+ MESSAGE("Point is in face: node is created");
+ double uvCoords[2] = {evlIt->at(0),evlIt->at(1)};
+ ienf++;
+ MESSAGE("Add cad point on (u,v)=(" << uvCoords[0] << "," << uvCoords[1] << ") with id = " << ienf);
+ cad_point_t* point_p = cad_point_new(fce, ienf, uvCoords);
+ cad_point_set_tag(point_p, ienf);
+ }
+ }
+ FaceId2EnforcedVertexCoords.erase(faceKey);
+ }
+// else
+// std::cout << "No enforced vertex defined" << std::endl;
+// }
+
+
+ /****************************************************************************************
+ EDGES
+ now create the edges associated to this face
+ *****************************************************************************************/
+ int edgeKey = -1;