]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorageay <ageay>
Mon, 14 Dec 2009 10:35:04 +0000 (10:35 +0000)
committerageay <ageay>
Mon, 14 Dec 2009 10:35:04 +0000 (10:35 +0000)
src/INTERP_KERNEL/Geometric2D/ComposedEdge.cxx
src/INTERP_KERNEL/Geometric2D/ComposedEdge.hxx
src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.cxx
src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.hxx
src/INTERP_KERNEL/Geometric2DIntersector.txx

index 3e7ecaeb5e95056d4ef3b137cf014cd448bb2631..e883760f31e3e4715611621d0aaa843ba28e6f17 100644 (file)
@@ -196,14 +196,13 @@ void ComposedEdge::getBarycenter(double *bary) const
   bary[1]/=area;
 }
 
-double ComposedEdge::normalize(ComposedEdge *other)
+double ComposedEdge::normalize(ComposedEdge *other, double& xBary, double& yBary)
 {
   Bounds b;
   b.prepareForAggregation();
   fillBounds(b); 
   other->fillBounds(b);
   double dimChar=b.getCaracteristicDim();
-  double xBary,yBary;
   b.getBarycenter(xBary,yBary);
   applyGlobalSimilarity(xBary,yBary,dimChar);
   other->applyGlobalSimilarity(xBary,yBary,dimChar);
index d83ee9e87dac96610f12d4c5b920f9ea4647e963..ae7c6f6a27a467c2b8dde665c53e222d75a1ec69 100644 (file)
@@ -52,7 +52,7 @@ namespace INTERP_KERNEL
     double getPerimeter() const;
     double getHydraulicDiameter() const;
     void getBarycenter(double *bary) const;
-    double normalize(ComposedEdge *other);
+    double normalize(ComposedEdge *other, double& xBary, double& yBary);
     void fillBounds(Bounds& output) const;
     void applySimilarity(double xBary, double yBary, double dimChar);
     void applyGlobalSimilarity(double xBary, double yBary, double dimChar);
index 2dc7614af07551f6d4baa372b7450bae3b15a7eb..8299995a6c4540efa704daea00f07ea7cb35d94a 100644 (file)
@@ -170,8 +170,8 @@ void QuadraticPolygon::dumpInXfigFile(std::ostream& stream, int resolution, cons
  */
 double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other)
 {
-  double ret=0.;
-  double fact=normalize(&other);
+  double ret=0.,xBaryBB,yBaryBB;
+  double fact=normalize(&other,xBaryBB,yBaryBB);
   vector<QuadraticPolygon *> polygs=intersectMySelfWith(other);
   for(vector<QuadraticPolygon *>::iterator iter=polygs.begin();iter!=polygs.end();iter++)
     {
@@ -181,6 +181,33 @@ double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other)
   return ret*fact*fact;
 }
 
+/*!
+ * Warning contrary to intersectWith method this method is \b NOT const. 'this' and 'other' are modified after call of this method.
+ */
+double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other, double* barycenter)
+{
+  double ret=0.,bary[2],area,xBaryBB,yBaryBB;
+  barycenter[0] = barycenter[1] = 0.;
+  double fact=normalize(&other,xBaryBB,yBaryBB);
+  vector<QuadraticPolygon *> polygs=intersectMySelfWith(other);
+  for(vector<QuadraticPolygon *>::iterator iter=polygs.begin();iter!=polygs.end();iter++)
+    {
+      area=fabs((*iter)->getArea());
+      (*iter)->getBarycenter(bary);
+      delete *iter;
+      ret+=area;
+      barycenter[0] += bary[0]*area;
+      barycenter[1] += bary[1]*area;
+    }
+  if ( ret > std::numeric_limits<double>::min() )
+    {
+      barycenter[0]=barycenter[0]/ret*fact+xBaryBB;
+      barycenter[1]=barycenter[1]/ret*fact+yBaryBB;
+      
+    }
+  return ret*fact*fact;
+}
+
 /*!
  * \b WARNING this method is const and other is const too. \b BUT location of Edges in 'this' and 'other' are nevertheless modified.
  * This is possible because loc attribute in Edge class is mutable.
index fba577d8bd781cdac26a81d9b6f2202e04ec69c6..6595ccbe98841ce760a9627f069232eda69a2c4f 100644 (file)
@@ -49,6 +49,8 @@ namespace INTERP_KERNEL
     void dumpInXfigFileWithOther(const ComposedEdge& other, const char *fileName) const;
     //! Before intersecting as intersectWith a normalization is done.
     double intersectWithAbs(QuadraticPolygon& other);
+    //! Before intersecting as intersectWith a normalization is done.
+    double intersectWithAbs(QuadraticPolygon& other, double* barycenter);
     double intersectWith(const QuadraticPolygon& other) const;
     double intersectWith(const QuadraticPolygon& other, double* barycenter) const;
     std::vector<QuadraticPolygon *> intersectMySelfWith(const QuadraticPolygon& other) const;
index 44991812e23c94d138a631d997af97c397ca248e..c26e48083d8bf3ab3dfb852b24e3bd961d4e9d5d 100644 (file)
@@ -43,7 +43,7 @@ namespace INTERP_KERNEL
                                             double precision, int orientation):
     InterpType<MyMeshType,MyMatrix,GEO2D_INTERSECTOR >(meshT,meshS,dimCaracteristic, precision, md3DSurf, medianPlane, true, orientation, 0)
   {
-    QUADRATIC_PLANAR::_precision=dimCaracteristic*precision;
+    QUADRATIC_PLANAR::_precision=precision;
   }
   
   INTERSECTOR_TEMPLATE
@@ -58,7 +58,7 @@ namespace INTERP_KERNEL
     NormalizedCellType tS=PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getTypeOfElement(icellS);
     QuadraticPolygon *p1=buildPolygonFrom(CoordsT,tT);
     QuadraticPolygon *p2=buildPolygonFrom(CoordsS,tS);
-    double ret=p1->intersectWith(*p2);
+    double ret=p1->intersectWithAbs(*p2);
     delete p1; delete p2;
     return ret;
   }
@@ -83,7 +83,7 @@ namespace INTERP_KERNEL
       p2=QuadraticPolygon::buildLinearPolygon(nodes2);
     else
       p2=QuadraticPolygon::buildArcCirclePolygon(nodes2);
-    double ret=p1->intersectWith(*p2);
+    double ret=p1->intersectWithAbs(*p2);
     delete p1; delete p2;
     return ret;
   }
@@ -102,7 +102,7 @@ namespace INTERP_KERNEL
       nodes2[i]=new Node(sourceCoords[i*SPACEDIM],sourceCoords[i*SPACEDIM+1]);
     QuadraticPolygon *p1=QuadraticPolygon::buildLinearPolygon(nodes);
     QuadraticPolygon *p2=QuadraticPolygon::buildLinearPolygon(nodes2);
-    double ret=p1->intersectWith(*p2);
+    double ret=p1->intersectWithAbs(*p2);
     delete p1; delete p2;
     return ret;
   }
@@ -138,7 +138,7 @@ namespace INTERP_KERNEL
     else
       p2=QuadraticPolygon::buildArcCirclePolygon(nodes2);
     double barycenter[2];
-    double ret=p1->intersectWith(*p2,barycenter);
+    double ret=p1->intersectWithAbs(*p2,barycenter);
     delete p1; delete p2;
     if ( ret > std::numeric_limits<double>::min() )
     {