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);
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);
*/
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++)
{
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.
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;
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
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;
}
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;
}
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;
}
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() )
{