Salome HOME
Migration to OCCT 7.0
[plugins/blsurfplugin.git] / src / BLSURFPlugin / BLSURFPlugin_BLSURF.cxx
index fbb7a8f20d418d769f4a4fefdb5e9528bbce3aa1..2af416456290e3282b25b40c3ebc10551c8a3b5d 100644 (file)
@@ -1,4 +1,4 @@
-// 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
@@ -96,6 +96,8 @@ extern "C"{
 #include <fenv.h>
 #endif
 
+using namespace std;
+
 /* ==================================
  * ===========  PYTHON ==============
  * ==================================*/
@@ -578,7 +580,7 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction
   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)
@@ -1169,7 +1171,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp,
         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){
@@ -1769,7 +1771,7 @@ namespace
 
         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 );
@@ -1855,7 +1857,7 @@ namespace
         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 );
@@ -1866,8 +1868,8 @@ namespace
         }
         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;
@@ -1888,7 +1890,6 @@ namespace
     double *      _progress;
   };
 
-
 } // namespace
 
 status_t curv_fun(real t, real *uv, real *dt, real *dtt, void *user_data);
@@ -1912,10 +1913,15 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
 
   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
 
@@ -2105,7 +2111,11 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh&         aMesh,
      * (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 : */
@@ -2360,7 +2370,11 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh&         aMesh,
       }
 
       /* 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 : */
@@ -3092,7 +3106,6 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh&         aMesh,
   }
 
   // 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 );