X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FINTERP_KERNEL%2FGeometric2DIntersector.txx;h=1952deb28b69fb1d48b492ceb7396b5b1a4bf1d9;hb=1a9af3cb21941312cdda3f0466677b61beba7ade;hp=d997fa7be7500ce103d7277fb0ded05135c501c9;hpb=48782c06022ca2caa36f849cb5a29ea4fe2aaa83;p=tools%2Fmedcoupling.git diff --git a/src/INTERP_KERNEL/Geometric2DIntersector.txx b/src/INTERP_KERNEL/Geometric2DIntersector.txx index d997fa7be..1952deb28 100644 --- a/src/INTERP_KERNEL/Geometric2DIntersector.txx +++ b/src/INTERP_KERNEL/Geometric2DIntersector.txx @@ -1,47 +1,57 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D +// Copyright (C) 2007-2013 CEA/DEN, EDF R&D // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Anthony Geay (CEA/DEN) #ifndef __GEOMETRIC2DINTERSECTOR_TXX__ #define __GEOMETRIC2DINTERSECTOR_TXX__ #include "Geometric2DIntersector.hxx" #include "PlanarIntersectorP0P0.txx" +#include "Planar2D1DIntersectorP0P0.txx" #include "PlanarIntersectorP0P1.txx" #include "PlanarIntersectorP1P0.txx" +#include "PlanarIntersectorP1P1.txx" +#include "PlanarIntersectorP1P0Bary.txx" +#include "PlanarIntersectorP0P1Bary.txx" #include "CellModel.hxx" -#include "QuadraticPolygon.hxx" -#include "EdgeArcCircle.hxx" -#include "EdgeLin.hxx" -#include "Node.hxx" +#include "InterpKernelGeo2DQuadraticPolygon.hxx" +#include "InterpKernelGeo2DEdgeArcCircle.hxx" +#include "InterpKernelGeo2DEdgeLin.hxx" +#include "InterpKernelGeo2DNode.hxx" + +#define GEO2D_INTERSECTOR Geometric2DIntersector +#define INTERSECTOR_TEMPLATE template class InterpType> namespace INTERP_KERNEL { - template class InterpType> - Geometric2DIntersector::Geometric2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS, - double dimCaracteristic, double medianPlane, double precision, int orientation): - InterpType >(meshT,meshS,dimCaracteristic, precision, medianPlane, true, orientation, 0) + INTERSECTOR_TEMPLATE + GEO2D_INTERSECTOR::Geometric2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS, + double dimCaracteristic, double md3DSurf, double minDot3DSurf, double medianPlane, + double precision, int orientation): + InterpType(meshT,meshS,dimCaracteristic, precision, md3DSurf, minDot3DSurf, medianPlane, true, orientation, 0) { - QUADRATIC_PLANAR::_precision=dimCaracteristic*precision; + QUADRATIC_PLANAR::_precision=precision; } - template class InterpType> - double Geometric2DIntersector::intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS) + INTERSECTOR_TEMPLATE + double GEO2D_INTERSECTOR::intersectGeometry(ConnType icellT, ConnType icellS, + ConnType nbNodesT, ConnType nbNodesS) { int orientation = 1; std::vector CoordsT; @@ -51,13 +61,33 @@ 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; + return orientation*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=buildPolygonOfOneEdgeFrom(CoordsS,tS); + double ret=p1->intersectWithAbs1D(*p2, isColinear); + delete p1; delete p2; + return orientation*ret; } - template class InterpType> - double Geometric2DIntersector::intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector& sourceCoords, bool isSourceQuad) + INTERSECTOR_TEMPLATE + double GEO2D_INTERSECTOR::intersectGeometryWithQuadrangle(const double * quadrangle, + const std::vector& sourceCoords, + bool isSourceQuad) { std::vector nodes(4); nodes[0]=new Node(quadrangle[0],quadrangle[1]); @@ -68,54 +98,152 @@ namespace INTERP_KERNEL std::vector nodes2(nbOfSourceNodes); for(int i=0;iintersectWith(*p2); + p2=QuadraticPolygon::BuildArcCirclePolygon(nodes2); + double ret=p1->intersectWithAbs(*p2); delete p1; delete p2; return ret; } - template class InterpType> - QuadraticPolygon *Geometric2DIntersector::buildPolygonFrom(const std::vector& coords, NormalizedCellType type) + INTERSECTOR_TEMPLATE + double GEO2D_INTERSECTOR::intersectGeometryGeneral(const std::vector& targetCoords, + const std::vector& sourceCoords) + { + int nbOfTargetNodes=targetCoords.size()/SPACEDIM; + std::vector nodes(nbOfTargetNodes); + for(int i=0;i nodes2(nbOfSourceNodes); + for(int i=0;iintersectWithAbs(*p2); + delete p1; delete p2; + return ret; + } + + //================================================================================ + /*! + * \brief Intersect a triangle and a polygon for P1P0 barycentric algorithm + * \param targetCell - list of coordinates of target polygon in full interlace + * \param targetCellQuadratic - specifies if target polygon is quadratic or not + * \param sourceTria - list of coordinates of source triangle + * \param res - coefficients a,b and c associated to nodes of sourceTria + */ + //================================================================================ + + INTERSECTOR_TEMPLATE + double GEO2D_INTERSECTOR::intersectGeoBary(const std::vector& targetCell, + bool targetCellQuadratic, + const double * sourceTria, + std::vector& res) + { + std::vector nodes(3); + nodes[0]=new Node(sourceTria[0*SPACEDIM],sourceTria[0*SPACEDIM+1]); + nodes[1]=new Node(sourceTria[1*SPACEDIM],sourceTria[1*SPACEDIM+1]); + nodes[2]=new Node(sourceTria[2*SPACEDIM],sourceTria[2*SPACEDIM+1]); + int nbOfTargetNodes=targetCell.size()/SPACEDIM; + std::vector nodes2(nbOfTargetNodes); + for(int i=0;iintersectWithAbs(*p2,barycenter); + delete p1; delete p2; + if ( ret > std::numeric_limits::min() ) + { + std::vector sourceCell(3); + sourceCell[0] = &sourceTria[0]; + sourceCell[1] = &sourceTria[SPACEDIM]; + sourceCell[2] = &sourceTria[SPACEDIM*2]; + res.resize(3); + barycentric_coords( sourceCell, barycenter, &res[0]); + res[0] *= ret; + res[1] *= ret; + res[2] *= ret; + } + else + { + ret = 0; + } + return ret; + } + + INTERSECTOR_TEMPLATE + QuadraticPolygon *GEO2D_INTERSECTOR::buildPolygonFrom(const std::vector& coords, NormalizedCellType type) { int nbNodes=coords.size()/SPACEDIM; std::vector nodes(nbNodes); for(int i=0;i& coords, NormalizedCellType type) + { + if(type==NORM_SEG2) + { + Node *node0=new Node(coords[0],coords[1]); + Node *node1=new Node(coords[SPACEDIM],coords[SPACEDIM+1]); + QuadraticPolygon *ret=new QuadraticPolygon; + ret->pushBack(new EdgeLin(node0,node1)); + node0->decrRef(); node1->decrRef(); + return ret; + } + else if(type==NORM_SEG3) + { + Node *nodeBg=new Node(coords[0],coords[1]); + Node *nodeEnd=new Node(coords[SPACEDIM],coords[SPACEDIM+1]); + Node *nodeMiddle=new Node(coords[2*SPACEDIM],coords[2*SPACEDIM+1]); + QuadraticPolygon *ret=new QuadraticPolygon; + ret->pushBack(new EdgeArcCircle(nodeBg,nodeMiddle,nodeEnd)); + nodeBg->decrRef(); nodeEnd->decrRef(); nodeMiddle->decrRef(); + return ret; + } else - return QuadraticPolygon::buildArcCirclePolygon(nodes); + throw INTERP_KERNEL::Exception("buildPolygonOfOneEdgeFrom : trying to build such non close QuadraticPolygon with 1D type !"); } - template class InterpType> - QuadraticPolygon *Geometric2DIntersector::buildPolygonAFrom(ConnType cell, int nbOfPoints, NormalizedCellType type) + INTERSECTOR_TEMPLATE + QuadraticPolygon *GEO2D_INTERSECTOR::buildPolygonAFrom(ConnType cell, int nbOfPoints, NormalizedCellType type) { const ConnType *startOfCellNodeConn=PlanarIntersector::_connectT+OTT::conn2C(PlanarIntersector::_connIndexT[OTT::ind2C(cell)]); std::vector nodes(nbOfPoints); for(int i=0;i::_coordsT+OTT::coo2C(startOfCellNodeConn[i])*SPACEDIM); - if(CellModel::getCellModel(type).isQuadratic()) - return QuadraticPolygon::buildLinearPolygon(nodes); + if(CellModel::GetCellModel(type).isQuadratic()) + return QuadraticPolygon::BuildLinearPolygon(nodes); else - return QuadraticPolygon::buildArcCirclePolygon(nodes); + return QuadraticPolygon::BuildArcCirclePolygon(nodes); } - template class InterpType> - QuadraticPolygon *Geometric2DIntersector::buildPolygonBFrom(ConnType cell, int nbOfPoints, NormalizedCellType type) + INTERSECTOR_TEMPLATE + QuadraticPolygon *GEO2D_INTERSECTOR::buildPolygonBFrom(ConnType cell, int nbOfPoints, NormalizedCellType type) { const ConnType *startOfCellNodeConn=PlanarIntersector::_connectS+OTT::conn2C(PlanarIntersector::_connIndexS[OTT::ind2C(cell)]); std::vector nodes(nbOfPoints); for(int i=0;i::_coordsS+OTT::coo2C(startOfCellNodeConn[i])*SPACEDIM); - if(type!=NORM_TRI6 && type!=NORM_QUAD8) - return QuadraticPolygon::buildLinearPolygon(nodes); + const CellModel& cm=CellModel::GetCellModel(type); + if(!cm.isQuadratic()) + return QuadraticPolygon::BuildLinearPolygon(nodes); else - return QuadraticPolygon::buildArcCirclePolygon(nodes); + return QuadraticPolygon::BuildArcCirclePolygon(nodes); } }