]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Some missing tiny services for implementation of a general implementation of MEDCoupl...
authorageay <ageay>
Tue, 10 Dec 2013 11:07:10 +0000 (11:07 +0000)
committerageay <ageay>
Tue, 10 Dec 2013 11:07:10 +0000 (11:07 +0000)
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx

index fc64730dbf88e8468005fe8be5b483e69845400c..b866dac1e86ea6d3d06d081dd8e5d0232e8b2c17 100644 (file)
@@ -431,56 +431,8 @@ void ComposedEdge::getBarycenter(double *bary, double& weigh) const
  */
 bool ComposedEdge::isInOrOut(Node *nodeToTest) const
 {
-  Bounds b; b.prepareForAggregation();
-  fillBounds(b);
-  if(b.nearlyWhere((*nodeToTest)[0],(*nodeToTest)[1])==OUT)
-    return false;
-  // searching for e1
-  std::set<Node *> nodes;
-  getAllNodes(nodes);
-  std::set<double> radialDistributionOfNodes;
-  std::set<Node *>::const_iterator iter;
-  for(iter=nodes.begin();iter!=nodes.end();iter++)
-    radialDistributionOfNodes.insert(nodeToTest->getSlope(*(*iter)));
-  std::vector<double> radialDistrib(radialDistributionOfNodes.begin(),radialDistributionOfNodes.end());
-  radialDistributionOfNodes.clear();
-  std::vector<double> radialDistrib2(radialDistrib.size());
-  copy(radialDistrib.begin()+1,radialDistrib.end(),radialDistrib2.begin());
-  radialDistrib2.back()=M_PI+radialDistrib.front();
-  std::vector<double> radialDistrib3(radialDistrib.size());
-  std::transform(radialDistrib2.begin(),radialDistrib2.end(),radialDistrib.begin(),radialDistrib3.begin(),std::minus<double>());
-  std::vector<double>::iterator iter3=max_element(radialDistrib3.begin(),radialDistrib3.end());
-  int i=iter3-radialDistrib3.begin();
-  // ok for e1 - Let's go.
-  EdgeInfLin *e1=new EdgeInfLin(nodeToTest,radialDistrib[i]+radialDistrib3[i]/2.);
-  double ref=e1->getCharactValue(*nodeToTest);
   std::set< IntersectElement > inOutSwitch;
-  for(std::list<ElementaryEdge *>::const_iterator iter4=_sub_edges.begin();iter4!=_sub_edges.end();iter4++)
-    {
-      ElementaryEdge *val=(*iter4);
-      if(val)
-        {
-          Edge *e=val->getPtr();
-          std::auto_ptr<EdgeIntersector> intersc(Edge::BuildIntersectorWith(e1,e));
-          bool obviousNoIntersection,areOverlapped;
-          intersc->areOverlappedOrOnlyColinears(0,obviousNoIntersection,areOverlapped);
-          if(obviousNoIntersection)
-            {
-              continue;
-            }
-          if(!areOverlapped)
-            {
-              std::list< IntersectElement > listOfIntesc=intersc->getIntersectionsCharacteristicVal();
-              for(std::list< IntersectElement >::iterator iter2=listOfIntesc.begin();iter2!=listOfIntesc.end();iter2++)
-                if((*iter2).isIncludedByBoth())
-                  inOutSwitch.insert(*iter2);
-              }
-          //if overlapped we can forget
-        }
-      else
-        throw Exception("Invalid use of ComposedEdge::isInOrOut : only one level supported !");
-    }
-  e1->decrRef();
+  double ref(isInOrOutAlg(nodeToTest,inOutSwitch));
   bool ret=false;
   for(std::set< IntersectElement >::iterator iter4=inOutSwitch.begin();iter4!=inOutSwitch.end();iter4++)
     {
@@ -503,6 +455,30 @@ bool ComposedEdge::isInOrOut(Node *nodeToTest) const
  * \sa ComposedEdge::isInOrOut
  */
 bool ComposedEdge::isInOrOut2(Node *nodeToTest) const
+{
+  std::set< IntersectElement > inOutSwitch;
+  double ref(isInOrOutAlg(nodeToTest,inOutSwitch));
+  bool ret=false;
+  for(std::set< IntersectElement >::iterator iter4=inOutSwitch.begin();iter4!=inOutSwitch.end();iter4++)
+    {
+      double val((*iter4).getVal1());
+      if(fabs(val-ref)>=QUADRATIC_PLANAR::_precision)
+        {
+          if(val<ref)
+            {
+              if((*iter4).getNodeOnly()->getLoc()==ON_1)
+                ret=!ret;
+            }
+          else
+            break;
+        }
+      else
+        return true;
+    }
+  return ret;
+}
+
+double ComposedEdge::isInOrOutAlg(Node *nodeToTest, std::set< IntersectElement >& inOutSwitch) const
 {
   Bounds b; b.prepareForAggregation();
   fillBounds(b);
@@ -527,7 +503,6 @@ bool ComposedEdge::isInOrOut2(Node *nodeToTest) const
   // ok for e1 - Let's go.
   EdgeInfLin *e1=new EdgeInfLin(nodeToTest,radialDistrib[i]+radialDistrib3[i]/2.);
   double ref=e1->getCharactValue(*nodeToTest);
-  std::set< IntersectElement > inOutSwitch;
   for(std::list<ElementaryEdge *>::const_iterator iter4=_sub_edges.begin();iter4!=_sub_edges.end();iter4++)
     {
       ElementaryEdge *val=(*iter4);
@@ -551,27 +526,10 @@ bool ComposedEdge::isInOrOut2(Node *nodeToTest) const
           //if overlapped we can forget
         }
       else
-        throw Exception("Invalid use of ComposedEdge::isInOrOut : only one level supported !");
+        throw Exception("Invalid use of ComposedEdge::isInOrOutAlg : only one level supported !");
     }
   e1->decrRef();
-  bool ret=false;
-  for(std::set< IntersectElement >::iterator iter4=inOutSwitch.begin();iter4!=inOutSwitch.end();iter4++)
-    {
-      double val((*iter4).getVal1());
-      if(fabs(val-ref)>=QUADRATIC_PLANAR::_precision)
-        {
-          if(val<ref)
-            {
-              if((*iter4).getNodeOnly()->getLoc()==ON_1)
-                ret=!ret;
-            }
-          else
-            break;
-        }
-      else
-        return true;
-    }
-  return ret;
+  return ref;
 }
 
 /*bool ComposedEdge::isInOrOut(Node *aNodeOn, Node *nodeToTest) const
index 545cc45440a03f4bc91a7d8d12ea2e5bbe2a4364..3e5221ee3adc3d3a1efe0174a6b71fe16ecaa061 100644 (file)
@@ -22,6 +22,7 @@
 #define __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__
 
 #include "INTERPKERNELDefines.hxx"
+#include "InterpKernelGeo2DEdge.hxx"
 
 #include <set>
 #include <list>
@@ -95,6 +96,7 @@ namespace INTERP_KERNEL
     INTERPKERNEL_EXPORT bool intresincEqCoarse(const Edge *other) const;
   private:
     std::list<ElementaryEdge *>* getListBehind() { return &_sub_edges; }
+    double isInOrOutAlg(Node *nodeToTest, std::set< IntersectElement >& inOutSwitch) const;
   protected:
     ~ComposedEdge();
   private:
index 41c4240c26a24c711d3f132033e90b56f6f2a74c..fcecc407a47593e7557e45249469c0e6b52b0eaf 100644 (file)
@@ -23,6 +23,7 @@
 #include "InterpKernelGeo2DEdgeInfLin.hxx"
 //#include "EdgeParabol.hxx"
 #include "InterpKernelGeo2DEdgeArcCircle.hxx"
+#include "InterpKernelGeo2DComposedEdge.hxx"
 #include "InterpKernelException.hxx"
 
 #include <algorithm>
index d646efc3ce86572091efc7b1631af2c286d1151e..9159299b05651bab7962afcf1892ce0d9026d8f4 100644 (file)
@@ -22,7 +22,6 @@
 #define __INTERPKERNELGEO2DEDGE_HXX__
 
 #include "INTERPKERNELDefines.hxx"
-#include "InterpKernelGeo2DComposedEdge.hxx"
 #include "InterpKernelException.hxx"
 #include "InterpKernelGeo2DBounds.hxx"
 #include "InterpKernelGeo2DNode.hxx"
@@ -94,6 +93,8 @@ namespace INTERP_KERNEL
     unsigned _ass2End2    : 1;
   };
 
+  class Edge;
+  class ComposedEdge;
   /*!
    * This class is in charge to store an intersection point as result of \b non oververlapping edge intersection.
    * This class manages the cases when intersect element is one of the extrimities of edge1 and/or edge2.
index ba69360f23071df11d9b7d13f0103c875a95fc7c..f5870d6a7749f3fb6f7d2d59f7c19c7fd1192e11 100644 (file)
@@ -21,6 +21,7 @@
 #include "InterpKernelGeo2DElementaryEdge.hxx"
 #include "InterpKernelException.hxx"
 #include "InterpKernelGeo2DEdge.hxx"
+#include "InterpKernelGeo2DComposedEdge.hxx"
 
 using namespace INTERP_KERNEL;