From: bph Date: Fri, 26 Aug 2011 14:01:20 +0000 (+0000) Subject: Intersection 2D1D X-Git-Tag: EndWorkDidier~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e54f6d06d12020d50505714efedc43e943472596;p=tools%2Fmedcoupling.git Intersection 2D1D --- diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx index e75778c09..509694609 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx @@ -844,3 +844,8 @@ bool Edge::splitOverlappedEdges(const Edge *e1, const Edge *e2, Node *nS, Node * throw Exception("Unexpected situation of overlapping edges : internal error occurs ! "); } } + +bool Edge::isEqual(const Edge& other) const +{ + return _start->isEqual(*other._start) && _end->isEqual(*other._end); +} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx index 933a0250e..28207b13d 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx @@ -255,6 +255,7 @@ namespace INTERP_KERNEL static void interpolate1DLin(const std::vector& distrib1, const std::vector& distrib2, std::map >& result); virtual void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const = 0; + bool isEqual(const Edge& other) const; protected: Edge():_cnt(1),_loc(FULL_UNKNOWN),_start(0),_end(0) { } virtual ~Edge(); diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx index 200078ffb..4369f2486 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx @@ -195,3 +195,8 @@ bool ElementaryEdge::intresincEqCoarse(const Edge *other) const { return _ptr==other; } + +bool ElementaryEdge::isEqual(const ElementaryEdge& other) const +{ + return _ptr->isEqual(*other._ptr); +} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx index 1b0a8ca17..e70dfd0ba 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx @@ -64,6 +64,7 @@ namespace INTERP_KERNEL void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const; bool getDirection() const { return _direction; } bool intresincEqCoarse(const Edge *other) const; + bool isEqual(const ElementaryEdge& other) const; private: bool _direction; Edge *_ptr; diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx index 2b6d38993..4efc349d4 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx @@ -207,6 +207,39 @@ double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other) return ret*fact*fact; } +/*! + * Warning This method is \b NOT const. 'this' and 'other' are modified after call of this method. + */ +double QuadraticPolygon::intersectWithAbs1D(QuadraticPolygon& other, bool& isColinear) +{ + double ret = 0., xBaryBB, yBaryBB; + double fact = normalize(&other, xBaryBB, yBaryBB); + + QuadraticPolygon cpyOfThis(*this); + QuadraticPolygon cpyOfOther(other); + int nbOfSplits = 0; + splitPolygonsEachOther(cpyOfThis, cpyOfOther, nbOfSplits); + //At this point cpyOfThis and cpyOfOther have been splited at maximum edge so that in/out can been done. + performLocatingOperation(cpyOfOther); + + std::list cpyOfOtherZip = cpyOfOther.zipConsecutiveInSegments(); + + isColinear = false; + if (cpyOfOtherZip.size() == 1) + { + QuadraticPolygon& poly = *cpyOfOtherZip.front(); + if (poly.size() == 2 && poly.front()->isEqual(*poly.back())) + isColinear = true; + } + + for (std::list::iterator iter = cpyOfOtherZip.begin(); iter != cpyOfOtherZip.end(); iter++) + { + ret += fabs((*iter)->getPerimeter()); + delete *iter; + } + return ret * fact / 2.; +} + /*! * Warning contrary to intersectWith method this method is \b NOT const. 'this' and 'other' are modified after call of this method. */ diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx index 7d865782d..5b9e2bc6e 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx @@ -51,6 +51,7 @@ namespace INTERP_KERNEL void dumpInXfigFileWithOther(const ComposedEdge& other, const char *fileName) const; //! Before intersecting as intersectWith a normalization is done. double intersectWithAbs(QuadraticPolygon& other); + double intersectWithAbs1D(QuadraticPolygon& other, bool& isColinear); //! Before intersecting as intersectWith a normalization is done. double intersectWithAbs(QuadraticPolygon& other, double* barycenter); double intersectWith(const QuadraticPolygon& other) const; diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.hxx b/src/INTERP_KERNEL/Geometric2DIntersector.hxx index 76b7b51a8..4385e7046 100644 --- a/src/INTERP_KERNEL/Geometric2DIntersector.hxx +++ b/src/INTERP_KERNEL/Geometric2DIntersector.hxx @@ -42,6 +42,8 @@ namespace INTERP_KERNEL Geometric2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation); double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS); + double intersectGeometry1D(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS, + bool& isColinear); double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector& sourceCoords, bool isSourceQuad); double intersectGeometryGeneral(const std::vector& targetCoords, const std::vector& sourceCoords); double intersectGeoBary(const std::vector& targetCell, bool targetCellQuadratic, const double *sourceCell, std::vector& res); diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.txx b/src/INTERP_KERNEL/Geometric2DIntersector.txx index 7f2d47675..7f12f5b63 100644 --- a/src/INTERP_KERNEL/Geometric2DIntersector.txx +++ b/src/INTERP_KERNEL/Geometric2DIntersector.txx @@ -21,6 +21,7 @@ #include "Geometric2DIntersector.hxx" #include "PlanarIntersectorP0P0.txx" +#include "Planar2D1DIntersectorP0P0.txx" #include "PlanarIntersectorP0P1.txx" #include "PlanarIntersectorP1P0.txx" #include "PlanarIntersectorP1P1.txx" @@ -63,6 +64,24 @@ namespace INTERP_KERNEL return ret; } + INTERSECTOR_TEMPLATE + double GEO2D_INTERSECTOR::intersectGeometry1D(ConnType icellT, ConnType icellS, + ConnType nbNodesT, ConnType nbNodesS, + bool& isColinear) + { + int orientation = 1; + std::vector CoordsT; + std::vector CoordsS; + PlanarIntersector::getRealCoordinates(icellT,icellS,nbNodesT,nbNodesS,CoordsT,CoordsS,orientation); + NormalizedCellType tT=PlanarIntersector::_meshT.getTypeOfElement(icellT); + NormalizedCellType tS=PlanarIntersector::_meshS.getTypeOfElement(icellS); + QuadraticPolygon *p1=buildPolygonFrom(CoordsT,tT); + QuadraticPolygon *p2=buildPolygonFrom(CoordsS,tS); + double ret=p1->intersectWithAbs1D(*p2, isColinear); + delete p1; delete p2; + return ret; + } + INTERSECTOR_TEMPLATE double GEO2D_INTERSECTOR::intersectGeometryWithQuadrangle(const double * quadrangle, const std::vector& sourceCoords, diff --git a/src/INTERP_KERNEL/Makefile.am b/src/INTERP_KERNEL/Makefile.am index 5c64b6653..fa7a68c40 100644 --- a/src/INTERP_KERNEL/Makefile.am +++ b/src/INTERP_KERNEL/Makefile.am @@ -51,6 +51,8 @@ Interpolation2D.hxx \ Interpolation2D.txx \ Interpolation3D.hxx \ Interpolation3D.txx \ +Interpolation2D1D.hxx \ +Interpolation2D1D.txx \ Interpolation3D2D.hxx \ Interpolation3D2D.txx \ Interpolation3DSurf.hxx \ @@ -91,6 +93,8 @@ MeshUtils.hxx \ PointLocatorAlgos.txx \ PlanarIntersector.hxx \ PlanarIntersector.txx \ +Planar2D1DIntersectorP0P0.hxx \ +Planar2D1DIntersectorP0P0.txx \ PlanarIntersectorP0P0.hxx \ PlanarIntersectorP0P0.txx \ PlanarIntersectorP0P1.hxx \ diff --git a/src/INTERP_KERNEL/PlanarIntersector.hxx b/src/INTERP_KERNEL/PlanarIntersector.hxx index 12a3455ad..395ff8b39 100644 --- a/src/INTERP_KERNEL/PlanarIntersector.hxx +++ b/src/INTERP_KERNEL/PlanarIntersector.hxx @@ -23,6 +23,9 @@ #include "TargetIntersector.hxx" #include "NormalizedUnstructuredMesh.hxx" +#include +#include + namespace INTERP_KERNEL { class TranslationRotationMatrix; @@ -35,6 +38,7 @@ namespace INTERP_KERNEL static const int MESHDIM=MyMeshType::MY_MESHDIM; typedef typename MyMeshType::MyConnType ConnType; static const NumberingPolicy numPol=MyMeshType::My_numPol; + typedef typename std::map > DuplicateFacesType; public: //! \addtogroup InterpKerGrpIntPlan @{ PlanarIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel); @@ -45,6 +49,10 @@ namespace INTERP_KERNEL inline void getElemBB(double* bb, const MyMeshType& mesh, ConnType iP, ConnType nb_nodes); static int projection(double *Coords_A, double *Coords_B, int nb_NodesA, int nb_NodesB, double epsilon, double md3DSurf, double median_plane, bool do_rotate); + virtual const DuplicateFacesType* getIntersectFaces() const + { + return NULL; + } protected : int projectionThis(double *Coords_A, double *Coords_B, int nb_NodesA, int nb_NodesB); void getRealTargetCoordinates(ConnType icellT, std::vector& coordsT);