Salome HOME
PAL16229 (Issue in order to mesh with Hexahedron algorithms)
[modules/smesh.git] / src / StdMeshers / StdMeshers_Prism_3D.cxx
index bed35f9d349c674b2959576dcfad410b3f0a6fc2..6d28721e3246bbfd1dd45bb366f8a4ebca28a134 100644 (file)
@@ -185,7 +185,7 @@ bool StdMeshers_Prism_3D::CheckHypothesis(SMESH_Mesh&                          a
                                           SMESH_Hypothesis::Hypothesis_Status& aStatus)
 {
   // Check shape geometry
-
+/*  PAL16229
   aStatus = SMESH_Hypothesis::HYP_BAD_GEOMETRY;
 
   // find not quadrangle faces
@@ -216,7 +216,7 @@ bool StdMeshers_Prism_3D::CheckHypothesis(SMESH_Mesh&                          a
     if ( nbFace != nbEdge + 2 )
       RETURN_BAD_RESULT("Bad nb of faces: " << nbFace << " but must be " << nbEdge + 2);
   }
-
+*/
   // no hypothesis
   aStatus = SMESH_Hypothesis::HYP_OK;
   return true;
@@ -383,12 +383,44 @@ void StdMeshers_Prism_3D::AddPrisms( vector<const TNodeColumn*> & columns,
   int shapeID = helper->GetSubShapeID();
 
   int nbNodes = columns.size();
+  int nbZ     = columns[0]->size();
+  if ( nbZ < 2 ) return;
+
+  // find out orientation
+  bool isForward = true;
+  SMDS_VolumeTool vTool;
+  int z = 1;
+  switch ( nbNodes ) {
+  case 3: {
+    const SMDS_MeshNode* botNodes[3] = { (*columns[0])[z-1],
+                                         (*columns[1])[z-1],
+                                         (*columns[2])[z-1] };
+    const SMDS_MeshNode* topNodes[3] = { (*columns[0])[z],
+                                         (*columns[1])[z],
+                                         (*columns[2])[z] };
+    SMDS_VolumeOfNodes tmpVol ( botNodes[0], botNodes[1], botNodes[2],
+                                topNodes[0], topNodes[1], topNodes[2]);
+    vTool.Set( &tmpVol );
+    isForward  = vTool.IsForward();
+    break;
+  }
+  case 4: {
+    const SMDS_MeshNode* botNodes[4] = { (*columns[0])[z-1], (*columns[1])[z-1],
+                                         (*columns[2])[z-1], (*columns[3])[z-1] };
+    const SMDS_MeshNode* topNodes[4] = { (*columns[0])[z], (*columns[1])[z],
+                                         (*columns[2])[z], (*columns[3])[z] };
+    SMDS_VolumeOfNodes tmpVol ( botNodes[0], botNodes[1], botNodes[2], botNodes[3],
+                                topNodes[0], topNodes[1], topNodes[2], topNodes[3]);
+    vTool.Set( &tmpVol );
+    isForward  = vTool.IsForward();
+    break;
+  }
+  }
 
   // vertical loop on columns
-  for ( int z = 1; z < columns[0]->size(); ++z)
+  for ( z = 1; z < nbZ; ++z )
   {
     SMDS_MeshElement* vol = 0;
-    SMDS_VolumeTool vTool;
     switch ( nbNodes ) {
 
     case 3: {
@@ -398,11 +430,7 @@ void StdMeshers_Prism_3D::AddPrisms( vector<const TNodeColumn*> & columns,
       const SMDS_MeshNode* topNodes[3] = { (*columns[0])[z],
                                            (*columns[1])[z],
                                            (*columns[2])[z] };
-      // assure good orientation
-      SMDS_VolumeOfNodes tmpVol ( botNodes[0], botNodes[1], botNodes[2],
-                                  topNodes[0], topNodes[1], topNodes[2]);
-      vTool.Set( &tmpVol );
-      if ( vTool.IsForward() )
+      if ( isForward )
         vol = helper->AddVolume( botNodes[0], botNodes[1], botNodes[2],
                                  topNodes[0], topNodes[1], topNodes[2]);
       else
@@ -415,11 +443,7 @@ void StdMeshers_Prism_3D::AddPrisms( vector<const TNodeColumn*> & columns,
                                            (*columns[2])[z-1], (*columns[3])[z-1] };
       const SMDS_MeshNode* topNodes[4] = { (*columns[0])[z], (*columns[1])[z],
                                            (*columns[2])[z], (*columns[3])[z] };
-      // assure good orientation
-      SMDS_VolumeOfNodes tmpVol ( botNodes[0], botNodes[1], botNodes[2], botNodes[3],
-                                  topNodes[0], topNodes[1], topNodes[2], topNodes[3]);
-      vTool.Set( &tmpVol );
-      if ( vTool.IsForward() )
+      if ( isForward )
         vol = helper->AddVolume( botNodes[0], botNodes[1], botNodes[2], botNodes[3],
                                  topNodes[0], topNodes[1], topNodes[2], topNodes[3]);
       else
@@ -529,8 +553,8 @@ bool StdMeshers_Prism_3D::assocOrProjBottom2Top()
         paramHint = prevTNode.GetParams();
       if ( !myBlock.ComputeParameters( bN.GetCoords(), bN.ChangeParams(),
                                        ID_BOT_FACE, paramHint ))
-        return error(TCom("Can't compute normalized parameters ")
-                     << "for node " << botNode->GetID() << " on the face #"<< botSM->GetId() );
+        return error(TCom("Can't compute normalized parameters for node ")
+                     << botNode->GetID() << " on the face #"<< botSM->GetId() );
       prevTNode = bN;
     }
     // create node column
@@ -584,8 +608,8 @@ bool StdMeshers_Prism_3D::projectBottomToTop()
       paramHint = prevTNode.GetParams();
     if ( !myBlock.ComputeParameters( bN.GetCoords(), bN.ChangeParams(),
                                      ID_BOT_FACE, paramHint ))
-      return error(TCom("Can't compute normalized parameters ")
-                   << "for node " << botNode->GetID() << " on the face #"<< botSM->GetId() );
+      return error(TCom("Can't compute normalized parameters for node ")
+                   << botNode->GetID() << " on the face #"<< botSM->GetId() );
     prevTNode = bN;
     // compute top node coords
     gp_XYZ topXYZ; gp_XY topUV;
@@ -851,11 +875,11 @@ bool StdMeshers_PrismAsBlock::Init(SMESH_MesherHelper* helper,
   // detect bad cases
   if ( nbNotQuad > 0 && nbNotQuad != 2 )
     return error(COMPERR_BAD_SHAPE,
-                 TCom("More than 2 not quadrilateral faces ")
+                 TCom("More than 2 not quadrilateral faces: ")
                  <<nbNotQuad);
   if ( nbNotQuadMeshed > 2 )
     return error(COMPERR_BAD_INPUT_MESH,
-                 TCom("More than 2 faces meshed with not quadrangle elements ")
+                 TCom("More than 2 faces with not quadrangle elements: ")
                  <<nbNotQuadMeshed);
 
   // get found submeshes