From 14f84af8dfcd0f44c7e1db607cd87fcf91203488 Mon Sep 17 00:00:00 2001 From: ageay Date: Mon, 14 Dec 2009 10:35:04 +0000 Subject: [PATCH] *** empty log message *** --- .../Geometric2D/ComposedEdge.cxx | 3 +- .../Geometric2D/ComposedEdge.hxx | 2 +- .../Geometric2D/QuadraticPolygon.cxx | 31 +++++++++++++++++-- .../Geometric2D/QuadraticPolygon.hxx | 2 ++ src/INTERP_KERNEL/Geometric2DIntersector.txx | 10 +++--- 5 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/INTERP_KERNEL/Geometric2D/ComposedEdge.cxx b/src/INTERP_KERNEL/Geometric2D/ComposedEdge.cxx index 3e7ecaeb5..e883760f3 100644 --- a/src/INTERP_KERNEL/Geometric2D/ComposedEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/ComposedEdge.cxx @@ -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); diff --git a/src/INTERP_KERNEL/Geometric2D/ComposedEdge.hxx b/src/INTERP_KERNEL/Geometric2D/ComposedEdge.hxx index d83ee9e87..ae7c6f6a2 100644 --- a/src/INTERP_KERNEL/Geometric2D/ComposedEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/ComposedEdge.hxx @@ -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); diff --git a/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.cxx index 2dc7614af..8299995a6 100644 --- a/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.cxx +++ b/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.cxx @@ -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 polygs=intersectMySelfWith(other); for(vector::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 polygs=intersectMySelfWith(other); + for(vector::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::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. diff --git a/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.hxx b/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.hxx index fba577d8b..6595ccbe9 100644 --- a/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.hxx +++ b/src/INTERP_KERNEL/Geometric2D/QuadraticPolygon.hxx @@ -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 intersectMySelfWith(const QuadraticPolygon& other) const; diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.txx b/src/INTERP_KERNEL/Geometric2DIntersector.txx index 44991812e..c26e48083 100644 --- a/src/INTERP_KERNEL/Geometric2DIntersector.txx +++ b/src/INTERP_KERNEL/Geometric2DIntersector.txx @@ -43,7 +43,7 @@ namespace INTERP_KERNEL double precision, int orientation): InterpType(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::_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::min() ) { -- 2.39.2