Salome HOME
bos #20256: [CEA 18523] Porting SMESH to int 64 bits
[modules/smesh.git] / src / StdMeshers / StdMeshers_Projection_1D2D.cxx
index 73feed3cc3d910346b2908a9d52b91dce50c5b61..a2d40bf3c43a64cc0f93f7566a2d83a878853cc1 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -25,7 +25,9 @@
 //
 #include "StdMeshers_Projection_1D2D.hxx"
 
+#include "SMESHDS_Mesh.hxx"
 #include "SMESH_Gen.hxx"
+#include "SMESH_Mesh.hxx"
 #include "SMESH_MesherHelper.hxx"
 #include "SMESH_subMesh.hxx"
 #include "SMESH_subMeshEventListener.hxx"
@@ -69,7 +71,7 @@ namespace
   /*!
    * \brief Structure used to temporary remove EventProparatorToEdges from faceSubMesh
    *  in order to prevent propagation of CLEAN event from FACE to EDGEs during 
-   *  StdMeshers_Projection_1D2D::Compute(). The CLEAN event is emmited by Pattern mapper
+   *  StdMeshers_Projection_1D2D::Compute(). The CLEAN event is emitted by Pattern mapper
    *  and causes removal of faces generated on adjacent FACEs.
    */
   struct UnsetterOfEventProparatorToEdges
@@ -91,8 +93,8 @@ namespace
 //purpose  : 
 //=======================================================================
 
-StdMeshers_Projection_1D2D::StdMeshers_Projection_1D2D(int hypId, int studyId, SMESH_Gen* gen)
-  :StdMeshers_Projection_2D(hypId, studyId, gen)
+StdMeshers_Projection_1D2D::StdMeshers_Projection_1D2D(int hypId, SMESH_Gen* gen)
+  :StdMeshers_Projection_2D(hypId, gen)
 {
   _name = "Projection_1D2D";
   _requireDiscreteBoundary = false;
@@ -124,10 +126,42 @@ bool StdMeshers_Projection_1D2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape
   SMESH_MesherHelper helper( theMesh );
   helper.SetSubShape( theShape );
 
+  if ( _quadraticMesh )
+  {
+    // 2a) Move some medium nodes from FACE to EDGES. They are on FACE because
+    // EDGEs are discreteized later than FACE, in this case.
+
+    SMESH_MesherHelper posFixer( theMesh );
+    posFixer.ToFixNodeParameters( true );
+    SMDS_ElemIteratorPtr fIt = faceSubMesh->GetElements();
+    vector< const SMDS_MeshNode* > nodes;
+    double dummyU, tol = 1e-7;
+    while ( fIt->more() ) // loop on mesh faces created by StdMeshers_Projection_2D
+    {
+      const SMDS_MeshElement* f = fIt->next();
+      //if ( !f->IsQuadratic() ) continue;
+      nodes.assign( SMDS_MeshElement::iterator( f->interlacedNodesIterator() ),
+                    SMDS_MeshElement::iterator() );
+      nodes.push_back( nodes[0] );
+      for ( size_t i = 2; i < nodes.size(); i += 2 )
+      {
+        pair<int, TopAbs_ShapeEnum> idType = helper.GetMediumPos( nodes[i], nodes[i-2] );
+        if ( idType.second == TopAbs_EDGE &&
+             idType.first  != nodes[i-1]->getshapeId() )
+        {
+          faceSubMesh->RemoveNode( nodes[i-1] );
+          meshDS->SetNodeOnEdge( nodes[i-1], idType.first );
+          posFixer.SetSubShape( idType.first );
+          posFixer.CheckNodeU( TopoDS::Edge( posFixer.GetSubShape() ),
+                               nodes[i-1], dummyU=0., tol, /*force=*/true );
+        }
+      }
+    }
+  }
   TopoDS_Face F = TopoDS::Face( theShape );
   TError err;
-  TSideVector wires = StdMeshers_FaceSide::GetFaceWires( F, theMesh,
-                                                         /*ignoreMediumNodes=*/false, err);
+  TSideVector wires = StdMeshers_FaceSide::GetFaceWires( F, theMesh, /*ignoreMediumNodes=*/false,
+                                                         err, &helper);
   if ( err && !err->IsOK() )
     return error( err );
 
@@ -217,7 +251,7 @@ bool StdMeshers_Projection_1D2D::Evaluate(SMESH_Mesh&         theMesh,
     TopAbs_ShapeEnum shapeType = srcSM->GetSubShape().ShapeType();
     if ( shapeType == TopAbs_EDGE )
     {
-      std::vector<int> aVec;
+      std::vector<smIdType> aVec;
       SMESHDS_SubMesh* srcSubMeshDS = srcSM->GetSubMeshDS();
       if ( srcSubMeshDS && srcSubMeshDS->NbElements() )
       {