From: ageay Date: Tue, 10 Dec 2013 11:07:10 +0000 (+0000) Subject: Some missing tiny services for implementation of a general implementation of MEDCoupl... X-Git-Tag: V7_3_0~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e13c98d5267fb61e3d59053059b5826532f806e2;p=modules%2Fmed.git Some missing tiny services for implementation of a general implementation of MEDCouplingUMesh::getCellsContainingPoints --- diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx index fc64730db..b866dac1e 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx @@ -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 nodes; - getAllNodes(nodes); - std::set radialDistributionOfNodes; - std::set::const_iterator iter; - for(iter=nodes.begin();iter!=nodes.end();iter++) - radialDistributionOfNodes.insert(nodeToTest->getSlope(*(*iter))); - std::vector radialDistrib(radialDistributionOfNodes.begin(),radialDistributionOfNodes.end()); - radialDistributionOfNodes.clear(); - std::vector radialDistrib2(radialDistrib.size()); - copy(radialDistrib.begin()+1,radialDistrib.end(),radialDistrib2.begin()); - radialDistrib2.back()=M_PI+radialDistrib.front(); - std::vector radialDistrib3(radialDistrib.size()); - std::transform(radialDistrib2.begin(),radialDistrib2.end(),radialDistrib.begin(),radialDistrib3.begin(),std::minus()); - std::vector::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::const_iterator iter4=_sub_edges.begin();iter4!=_sub_edges.end();iter4++) - { - ElementaryEdge *val=(*iter4); - if(val) - { - Edge *e=val->getPtr(); - std::auto_ptr 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(valgetLoc()==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::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(valgetLoc()==ON_1) - ret=!ret; - } - else - break; - } - else - return true; - } - return ret; + return ref; } /*bool ComposedEdge::isInOrOut(Node *aNodeOn, Node *nodeToTest) const diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx index 545cc4544..3e5221ee3 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx @@ -22,6 +22,7 @@ #define __INTERPKERNELGEO2DCOMPOSEDNODE_HXX__ #include "INTERPKERNELDefines.hxx" +#include "InterpKernelGeo2DEdge.hxx" #include #include @@ -95,6 +96,7 @@ namespace INTERP_KERNEL INTERPKERNEL_EXPORT bool intresincEqCoarse(const Edge *other) const; private: std::list* getListBehind() { return &_sub_edges; } + double isInOrOutAlg(Node *nodeToTest, std::set< IntersectElement >& inOutSwitch) const; protected: ~ComposedEdge(); private: diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx index 41c4240c2..fcecc407a 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx @@ -23,6 +23,7 @@ #include "InterpKernelGeo2DEdgeInfLin.hxx" //#include "EdgeParabol.hxx" #include "InterpKernelGeo2DEdgeArcCircle.hxx" +#include "InterpKernelGeo2DComposedEdge.hxx" #include "InterpKernelException.hxx" #include diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx index d646efc3c..9159299b0 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx @@ -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. diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx index ba69360f2..f5870d6a7 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx @@ -21,6 +21,7 @@ #include "InterpKernelGeo2DElementaryEdge.hxx" #include "InterpKernelException.hxx" #include "InterpKernelGeo2DEdge.hxx" +#include "InterpKernelGeo2DComposedEdge.hxx" using namespace INTERP_KERNEL;