]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Intersect bug fix : quad point was not inserted in the map even when used as an extremity
authorabn <adrien.bruneton@cea.fr>
Mon, 14 Jan 2019 12:07:45 +0000 (13:07 +0100)
committerabn <adrien.bruneton@cea.fr>
Mon, 14 Jan 2019 14:49:45 +0000 (15:49 +0100)
for another seg.

src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx
src/MEDCoupling/MEDCouplingUMesh.cxx

index ee286fd397178cb31896205a360cb6f4e45e9b4b..dd786fc37b8bc4cf5bf1b40e798ae97f7d5f9287 100644 (file)
@@ -35,6 +35,9 @@ namespace INTERP_KERNEL
   class Edge;
   class MergePoints;
 
+  enum NodeUsage { USAGE_UNKNOWN, USAGE_LINEAR, USAGE_QUADRATIC_ONLY };
+  typedef std::pair<INTERP_KERNEL::Node *,NodeUsage> NodeWithUsage;
+
   /**
    * A set of quadratic or linear edges, not necessarily connected to form a closed polygon.
    * Some methods however requires a closed form.
index f9697711f73e4b73f2c7dc224657ff96065d9bac..8b155dfeef872fd61d8c3cdd125983711792f237 100644 (file)
@@ -4363,9 +4363,13 @@ namespace ParaMEDMEM
     return ret;
   }
 
-  INTERP_KERNEL::Edge *MEDCouplingUMeshBuildQPFromEdge(INTERP_KERNEL::NormalizedCellType typ, std::map<int, std::pair<INTERP_KERNEL::Node *,bool> >& mapp2, const int *bg)
+  INTERP_KERNEL::Edge *MEDCouplingUMeshBuildQPFromEdge(INTERP_KERNEL::NormalizedCellType typ, std::map<int, INTERP_KERNEL::NodeWithUsage >& mapp2, const int *bg)
   {
     INTERP_KERNEL::Edge *ret=0;
+
+    mapp2[bg[0]].second = INTERP_KERNEL::USAGE_LINEAR;
+    mapp2[bg[1]].second = INTERP_KERNEL::USAGE_LINEAR;
+
     switch(typ)
     {
       case INTERP_KERNEL::NORM_SEG2:
@@ -4385,7 +4389,8 @@ namespace ParaMEDMEM
             ret=new INTERP_KERNEL::EdgeLin(mapp2[bg[0]].first,mapp2[bg[1]].first);
           else
             ret=new INTERP_KERNEL::EdgeArcCircle(mapp2[bg[0]].first,mapp2[bg[2]].first,mapp2[bg[1]].first);
-          mapp2[bg[2]].second=false;
+          if (mapp2[bg[2]].second != INTERP_KERNEL::USAGE_LINEAR) // switch the node usage to quadratic only if it is not used as an extreme point for another edge
+            mapp2[bg[2]].second = INTERP_KERNEL::USAGE_QUADRATIC_ONLY;
           break;
         }
       default:
@@ -4404,7 +4409,7 @@ namespace ParaMEDMEM
                                                                    std::map<INTERP_KERNEL::Node *,int>& mapp)
   {
     mapp.clear();
-    std::map<int, std::pair<INTERP_KERNEL::Node *,bool> > mapp2;//bool is for a flag specifying if node is boundary (true) or only a middle for SEG3.
+    std::map<int, INTERP_KERNEL::NodeWithUsage > mapp2;  // the last var is a flag specifying if node is an extreme node of the seg (LINEAR) or only a middle for SEG3 (QUADRATIC_ONLY).
     const double *coo=mDesc->getCoords()->getConstPointer();
     const int *c=mDesc->getNodalConnectivity()->getConstPointer();
     const int *cI=mDesc->getNodalConnectivityIndex()->getConstPointer();
@@ -4414,7 +4419,7 @@ namespace ParaMEDMEM
     for(std::set<int>::const_iterator it2=s.begin();it2!=s.end();it2++)
       {
         INTERP_KERNEL::Node *n=new INTERP_KERNEL::Node(coo[2*(*it2)],coo[2*(*it2)+1]);
-        mapp2[*it2]=std::pair<INTERP_KERNEL::Node *,bool>(n,true);
+        mapp2[*it2]=INTERP_KERNEL::NodeWithUsage(n,INTERP_KERNEL::USAGE_UNKNOWN);
       }
     INTERP_KERNEL::QuadraticPolygon *ret=new INTERP_KERNEL::QuadraticPolygon;
     for(std::vector<int>::const_iterator it=candidates.begin();it!=candidates.end();it++)
@@ -4422,13 +4427,12 @@ namespace ParaMEDMEM
         INTERP_KERNEL::NormalizedCellType typ=(INTERP_KERNEL::NormalizedCellType)c[cI[*it]];
         ret->pushBack(MEDCouplingUMeshBuildQPFromEdge(typ,mapp2,c+cI[*it]+1));
       }
-    for(std::map<int, std::pair<INTERP_KERNEL::Node *,bool> >::const_iterator it2=mapp2.begin();it2!=mapp2.end();it2++)
+    for(std::map<int, INTERP_KERNEL::NodeWithUsage >::const_iterator it2=mapp2.begin();it2!=mapp2.end();it2++)
       {
-        if((*it2).second.second)
+        if((*it2).second.second == INTERP_KERNEL::USAGE_LINEAR)
           mapp[(*it2).second.first]=(*it2).first;
         ((*it2).second.first)->decrRef();
       }
-    return ret;
   }
 
   INTERP_KERNEL::Node *MEDCouplingUMeshBuildQPNode(int nodeId, const double *coo1, int offset1, const double *coo2, int offset2, const std::vector<double>& addCoo)
@@ -10709,17 +10713,17 @@ void MEDCouplingUMesh::BuildIntersectEdges(const MEDCouplingUMesh *m1, const MED
     {
       const std::vector<int>& divs=subDiv[i];
       int nnode=cI[1]-cI[0]-1;
-      std::map<int, std::pair<INTERP_KERNEL::Node *,bool> > mapp2;
+      std::map<int, INTERP_KERNEL::NodeWithUsage > mapp2;
       std::map<INTERP_KERNEL::Node *, int> mapp22;
       for(int j=0;j<nnode;j++)
         {
           INTERP_KERNEL::Node *nn=new INTERP_KERNEL::Node(coo[2*c[(*cI)+j+1]],coo[2*c[(*cI)+j+1]+1]);
           int nnid=c[(*cI)+j+1];
-          mapp2[nnid]=std::pair<INTERP_KERNEL::Node *,bool>(nn,true);
+          mapp2[nnid]=INTERP_KERNEL::NodeWithUsage(nn,INTERP_KERNEL::USAGE_UNKNOWN);
           mapp22[nn]=nnid+offset1;
         }
       INTERP_KERNEL::Edge *e=MEDCouplingUMeshBuildQPFromEdge((INTERP_KERNEL::NormalizedCellType)c[*cI],mapp2,c+(*cI)+1);
-      for(std::map<int, std::pair<INTERP_KERNEL::Node *,bool> >::const_iterator it=mapp2.begin();it!=mapp2.end();it++)
+      for(std::map<int, INTERP_KERNEL::NodeWithUsage >::const_iterator it=mapp2.begin();it!=mapp2.end();it++)
         ((*it).second.first)->decrRef();
       std::vector<INTERP_KERNEL::Node *> addNodes(divs.size());
       std::map<INTERP_KERNEL::Node *,int> mapp3;