]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
PAL11544. optimize a little
authoreap <eap@opencascade.com>
Wed, 8 Feb 2006 09:49:11 +0000 (09:49 +0000)
committereap <eap@opencascade.com>
Wed, 8 Feb 2006 09:49:11 +0000 (09:49 +0000)
src/SMESH/SMESH_Gen.cxx
src/SMESH/SMESH_Mesh.cxx

index c5a611a29665559d8e7f5b6ec2fcb4d5065a3b1a..a93b1a4b41b60abe8e628323567f59a9b4a2676d 100644 (file)
@@ -702,37 +702,20 @@ void SMESH_Gen::Close(int studyId)
 
 int SMESH_Gen::GetShapeDim(const TopAbs_ShapeEnum & aShapeType)
 {
-       int shapeDim = -1;                      // Shape dimension: 0D, 1D, 2D, 3D
-       int type = aShapeType;//.ShapeType();
-       switch (type)
-       {
-       case TopAbs_COMPOUND:
-       case TopAbs_COMPSOLID:
-       case TopAbs_SOLID:
-       case TopAbs_SHELL:
-       {
-               shapeDim = 3;
-               break;
-       }
-               //    case TopAbs_SHELL:
-       case TopAbs_FACE:
-       {
-               shapeDim = 2;
-               break;
-       }
-       case TopAbs_WIRE:
-       case TopAbs_EDGE:
-       {
-               shapeDim = 1;
-               break;
-       }
-       case TopAbs_VERTEX:
-       {
-               shapeDim = 0;
-               break;
-       }
-       }
-       return shapeDim;
+  static vector<int> dim;
+  if ( dim.empty() )
+  {
+    dim.resize( TopAbs_SHAPE, -1 );
+    dim[ TopAbs_COMPOUND ]  = 3;
+    dim[ TopAbs_COMPSOLID ] = 3;
+    dim[ TopAbs_SOLID ]     = 3;
+    dim[ TopAbs_SHELL ]     = 3;
+    dim[ TopAbs_FACE  ]     = 2;
+    dim[ TopAbs_WIRE ]      = 1;
+    dim[ TopAbs_EDGE ]      = 1;
+    dim[ TopAbs_VERTEX ]    = 0;
+  }
+  return dim[ aShapeType ];
 }
 
 //=============================================================================
index a4b5f80af0208839134f0186cbbaf490fe628adb..e6aabf149902b1a71d63ee308252bebe0114c6f3 100644 (file)
@@ -149,7 +149,7 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape)
   // fill _mapAncestors
   _mapAncestors.Clear();
   int desType, ancType;
-  for ( desType = TopAbs_EDGE; desType > TopAbs_COMPOUND; desType-- )
+  for ( desType = TopAbs_VERTEX; desType > TopAbs_COMPOUND; desType-- )
     for ( ancType = desType - 1; ancType >= TopAbs_COMPOUND; ancType-- )
       TopExp::MapShapesAndAncestors ( aShape,
                                      (TopAbs_ShapeEnum) desType,
@@ -616,12 +616,12 @@ SMESH_Gen *SMESH_Mesh::GetGen()
 //=============================================================================
 
 SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape)
-throw(SALOME_Exception)
+  throw(SALOME_Exception)
 {
   Unexpect aCatch(SalomeException);
   SMESH_subMesh *aSubMesh;
   int index = _myMeshDS->ShapeToIndex(aSubShape);
-  
+
   // for submeshes on GEOM Group
   if ( !index && aSubShape.ShapeType() == TopAbs_COMPOUND ) {
     TopoDS_Iterator it( aSubShape );
@@ -629,15 +629,16 @@ throw(SALOME_Exception)
       index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() );
   }
 
-  if (_mapSubMesh.find(index) != _mapSubMesh.end())
-    {
-      aSubMesh = _mapSubMesh[index];
-    }
+  map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(index);
+  if ( i_sm != _mapSubMesh.end())
+  {
+    aSubMesh = i_sm->second;
+  }
   else
-    {
-      aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
-      _mapSubMesh[index] = aSubMesh;
-    }
+  {
+    aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape);
+    _mapSubMesh[index] = aSubMesh;
+  }
   return aSubMesh;
 }
 
@@ -649,20 +650,17 @@ throw(SALOME_Exception)
 //=============================================================================
 
 SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape)
-throw(SALOME_Exception)
+  throw(SALOME_Exception)
 {
   Unexpect aCatch(SalomeException);
-  bool isFound = false;
   SMESH_subMesh *aSubMesh = NULL;
   
   int index = _myMeshDS->ShapeToIndex(aSubShape);
-  if (_mapSubMesh.find(index) != _mapSubMesh.end())
-    {
-      aSubMesh = _mapSubMesh[index];
-      isFound = true;
-    }
-  if (!isFound)
-    aSubMesh = NULL;
+
+  map <int, SMESH_subMesh *>::iterator i_sm = _mapSubMesh.find(index);
+  if ( i_sm != _mapSubMesh.end())
+    aSubMesh = i_sm->second;
+
   return aSubMesh;
 }
 
@@ -1152,7 +1150,7 @@ void SMESH_Mesh::CleanMeshOnPropagationChain (const TopoDS_Shape& theMainEdge)
     SMESH_subMesh *subMesh = GetSubMesh(anEdge);
     SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS();
     if (subMeshDS && subMeshDS->NbElements() > 0) {
-      subMesh->ComputeStateEngine(SMESH_subMesh::CLEANDEP);
+      subMesh->ComputeStateEngine(SMESH_subMesh::CLEAN);
     }
   }
 }