X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingUMesh_intersection.cxx;h=b233f1dcb7ad980485d086f9edabbe54671b3a25;hb=3e9ebc98a6bc02022900a8b2295e1a775d78ece0;hp=7a6fa91598e72e4f8da729350f81f5fc2865cb96;hpb=3531e8f47b047f0176ec094e51ab2474284f3cd9;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx b/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx index 7a6fa9159..b233f1dcb 100644 --- a/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh_intersection.cxx @@ -282,7 +282,7 @@ namespace MEDCoupling } /** - * Construct a mapping between set of Nodes and the standart MEDCoupling connectivity format (c, cI). + * Construct a mapping between set of Nodes and the standard MEDCoupling connectivity format (c, cI). */ void MEDCouplingUMeshBuildQPFromMesh3(const double *coo1, int offset1, const double *coo2, int offset2, const std::vector& addCoo, const int *desc1Bg, const int *desc1End, const std::vector >& intesctEdges1, @@ -337,7 +337,7 @@ bool MEDCouplingUMesh::Colinearize2DCell(const double *coords, const int *connBg // This initializes posBaseElt. if(nbOfTurn==0) { - for(unsigned i=1;i& edges, const std::vector< MCAuto >& edgesPtr); std::size_t size() const { return _pool.size(); } int getPositionOf(double eps, const MEDCouplingUMesh *mesh) const; - void setMeshAt(int pos, const MCAuto& mesh, int istart, int iend, const MCAuto& mesh1DInCase, const std::vector< std::vector >& edges, const std::vector< std::vector< MCAuto > >& edgePtrs); + void setMeshAt(std::size_t pos, const MCAuto& mesh, int istart, int iend, const MCAuto& mesh1DInCase, const std::vector< std::vector >& edges, const std::vector< std::vector< MCAuto > >& edgePtrs); const std::vector& getConnOf(int pos) const { return get(pos)._edges; } const std::vector< MCAuto >& getEdgePtrOf(int pos) const { return get(pos)._edges_ptr; } MCAuto getZeMesh() const { return _ze_mesh; } @@ -900,7 +900,7 @@ int VectorOfCellInfo::getPositionOf(double eps, const MEDCouplingUMesh *mesh) co return zeMesh->getCellContainingPoint(barys->begin(),eps); } -void VectorOfCellInfo::setMeshAt(int pos, const MCAuto& mesh, int istart, int iend, const MCAuto& mesh1DInCase, const std::vector< std::vector >& edges, const std::vector< std::vector< MCAuto > >& edgePtrs) +void VectorOfCellInfo::setMeshAt(std::size_t pos, const MCAuto& mesh, int istart, int iend, const MCAuto& mesh1DInCase, const std::vector< std::vector >& edges, const std::vector< std::vector< MCAuto > >& edgePtrs) { get(pos);//to check pos bool isFast(pos==0 && _pool.size()==1); @@ -912,7 +912,7 @@ void VectorOfCellInfo::setMeshAt(int pos, const MCAuto& mesh, _edge_info.push_back(EdgeInfo(istart,iend,pos,edgePtrs[0].back())); // std::vector pool(_pool.size()-1+sz); - for(int i=0;i >& intersectEdge1, std::vector< std::vector >& colinear2, std::vector< std::vector >& subDiv2, std::vector& addCoo, std::map& mergedNodes) { static const int SPACEDIM=2; - INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps; - INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps; + INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision arcPrec(eps); const int *c1(m1Desc->getNodalConnectivity()->begin()),*ci1(m1Desc->getNodalConnectivityIndex()->begin()); // Build BB tree of all edges in the tool mesh (second mesh) - MCAuto bbox1Arr(m1Desc->getBoundingBoxForBBTree()),bbox2Arr(m2Desc->getBoundingBoxForBBTree()); + MCAuto bbox1Arr(m1Desc->getBoundingBoxForBBTree(eps)),bbox2Arr(m2Desc->getBoundingBoxForBBTree(eps)); const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin()); int nDescCell1(m1Desc->getNumberOfCells()),nDescCell2(m2Desc->getNumberOfCells()); intersectEdge1.resize(nDescCell1); @@ -1269,7 +1269,7 @@ void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCo const int *conn2(m2->getNodalConnectivity()->begin()),*connI2(m2->getNodalConnectivityIndex()->begin()); int offset2(offset1+m2->getNumberOfNodes()); int offset3(offset2+((int)addCoords.size())/2); - MCAuto bbox1Arr(m1->getBoundingBoxForBBTree()),bbox2Arr(m2->getBoundingBoxForBBTree()); + MCAuto bbox1Arr(m1->getBoundingBoxForBBTree(eps)),bbox2Arr(m2->getBoundingBoxForBBTree(eps)); const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin()); // Here a BBTree on 2D-cells, not on segments: BBTree myTree(bbox2,0,0,m2->getNumberOfCells(),eps); @@ -1431,7 +1431,7 @@ void MEDCouplingUMesh::buildSubCellsFromCut(const std::vector< std::paircheckFullyDefined(); m2->checkFullyDefined(); + INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision arcPrec(eps); if(m1->getMeshDimension()!=2 || m1->getSpaceDimension()!=2 || m2->getMeshDimension()!=2 || m2->getSpaceDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Intersect2DMeshes works on umeshes m1 AND m2 with meshdim equal to 2 and spaceDim equal to 2 too!"); @@ -1617,7 +1619,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1 /*! * Partitions the first given 2D mesh using the second given 1D mesh as a tool. * Thus the final result contains the aggregation of nodes of \a mesh2D, then nodes of \a mesh1D, then new nodes that are the result of the intersection - * and finaly, in case of quadratic polygon the centers of edges new nodes. + * and finally, in case of quadratic polygon the centers of edges new nodes. * The meshes should be in 2D space. In addition, returns two arrays mapping cells of the resulting mesh to cells of the input. * * \param [in] mesh2D - the 2D mesh (spacedim=meshdim=2) to be intersected using \a mesh1D tool. The mesh must be so that each point in the space covered by \a mesh2D @@ -1647,8 +1649,8 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, // Step 1: compute all edge intersections (new nodes) std::vector< std::vector > intersectEdge1, colinear2, subDiv2; std::vector addCoo,addCoordsQuadratic; // coordinates of newly created nodes - INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps; - INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps; + INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision arcPrec(eps); // // Build desc connectivity DataArrayInt *desc1(DataArrayInt::New()),*descIndx1(DataArrayInt::New()),*revDesc1(DataArrayInt::New()),*revDescIndx1(DataArrayInt::New()); @@ -1702,7 +1704,9 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, MCAuto baryRet1(ret1NonCol->computeCellCenterOfMass()); MCAuto elts,eltsIndex; mesh2D->getCellsContainingPoints(baryRet1->begin(),baryRet1->getNumberOfTuples(),eps,elts,eltsIndex); - MCAuto eltsIndex2(eltsIndex->deltaShiftIndex()); + MCAuto eltsIndex2(DataArrayInt::New()); eltsIndex2->alloc(0,1); + if (eltsIndex->getNumberOfTuples() > 1) + eltsIndex2 = eltsIndex->deltaShiftIndex(); MCAuto eltsIndex3(eltsIndex2->findIdsEqual(1)); if(eltsIndex2->count(0)+eltsIndex3->getNumberOfTuples()!=ret1NonCol->getNumberOfCells()) throw INTERP_KERNEL::Exception("Intersect2DMeshWith1DLine : internal error 1 !"); @@ -1775,7 +1779,7 @@ void MEDCouplingUMesh::Intersect2DMeshWith1DLine(const MEDCouplingUMesh *mesh2D, MCAuto splitOfOneCell(BuildMesh2DCutFrom(eps,*it,m1Desc,partOfMesh1CuttingCur2DCell,dd1->begin()+dd2->getIJ(*it,0),dd1->begin()+dd2->getIJ((*it)+1,0),intersectEdge1,ret2->getNumberOfTuples(),partOfRet3)); ret3->setPartOfValues3(partOfRet3,idsNonColPerCell2->begin(),idsNonColPerCell2->end(),0,2,1,true); outMesh2DSplit.push_back(splitOfOneCell); - for(int i=0;igetNumberOfCells();i++) + for(std::size_t i=0;igetNumberOfCells();i++) ret2->pushBackSilent(*it); } // @@ -1836,14 +1840,14 @@ DataArrayInt *MEDCouplingUMesh::conformize2D(double eps) MCAuto desc1(DataArrayInt::New()),descIndx1(DataArrayInt::New()),revDesc1(DataArrayInt::New()),revDescIndx1(DataArrayInt::New()); MCAuto mDesc(buildDescendingConnectivity(desc1,descIndx1,revDesc1,revDescIndx1)); const int *c(mDesc->getNodalConnectivity()->begin()),*ci(mDesc->getNodalConnectivityIndex()->begin()),*rd(revDesc1->begin()),*rdi(revDescIndx1->begin()); - MCAuto bboxArr(mDesc->getBoundingBoxForBBTree()); + MCAuto bboxArr(mDesc->getBoundingBoxForBBTree(eps)); const double *bbox(bboxArr->begin()),*coords(getCoords()->begin()); int nCell(getNumberOfCells()),nDescCell(mDesc->getNumberOfCells()); std::vector< std::vector > intersectEdge(nDescCell),overlapEdge(nDescCell); std::vector addCoo; BBTree myTree(bbox,0,0,nDescCell,-eps); - INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps; - INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps; + INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision arcPrec(eps); for(int i=0;i candidates; @@ -1970,8 +1974,8 @@ DataArrayInt *MEDCouplingUMesh::colinearize2D(double eps) checkConsistencyLight(); if(getSpaceDimension()!=2 || getMeshDimension()!=2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::colinearize2D : This method only works for meshes with spaceDim=2 and meshDim=2 !"); - INTERP_KERNEL::QUADRATIC_PLANAR::_arc_detection_precision=eps; - INTERP_KERNEL::QUADRATIC_PLANAR::_precision=eps; + INTERP_KERNEL::QuadraticPlanarPrecision prec(eps); + INTERP_KERNEL::QuadraticPlanarArcDetectionPrecision arcPrec(eps); int nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()); const int *cptr(_nodal_connec->begin()),*ciptr(_nodal_connec_index->begin()); MCAuto newc(DataArrayInt::New()),newci(DataArrayInt::New()); newci->alloc(nbOfCells+1,1); newc->alloc(0,1); newci->setIJ(0,0,0); @@ -2084,7 +2088,7 @@ void MEDCouplingUMesh::ReplaceEdgeInFace(const int * sIdxConn, const int * sIdxC throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ReplaceEdgeInFace: internal error, should never happen!"); int d = distance(startPos, endPos); if (d == 1 || d == (1-dst)) // don't use modulo, for neg numbers, result is implementation defined ... - modifiedFace.insert(++startPos, ++insidePoints.begin(), --insidePoints.end()); // insidePoints also contains start and end node. Those dont need to be inserted. + modifiedFace.insert(++startPos, ++insidePoints.begin(), --insidePoints.end()); // insidePoints also contains start and end node. Those don't need to be inserted. else modifiedFace.insert(++endPos, ++insidePoints.rbegin(), --insidePoints.rend()); } @@ -2138,7 +2142,7 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) MCAuto connSlaDesc(MEDCouplingSkyLineArray::New(mDesc->getNodalConnectivityIndex(), mDesc->getNodalConnectivity())); // Build BBTree - MCAuto bboxArr(mDesc->getBoundingBoxForBBTree()); + MCAuto bboxArr(mDesc->getBoundingBoxForBBTree(eps)); const double *bbox(bboxArr->begin()); getCoords()->begin(); int nDescCell(mDesc->getNumberOfCells()); BBTree myTree(bbox,0,0,nDescCell,-eps); @@ -2151,17 +2155,18 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) const double * normalsP = normals->getConstPointer(); // Sort faces by decreasing surface: - vector> S; - for(int i=0;i < surfs->getNumberOfTuples();i++){ + vector< pair > S; + for(std::size_t i=0;i < surfs->getNumberOfTuples();i++) + { pair p = make_pair(surfs->begin()[i], i); S.push_back(p); - } + } sort(S.rbegin(),S.rend()); // reverse sort vector hit(nDescCell); fill(hit.begin(), hit.end(), false); vector hitPoly; // the final result: which 3D cells have been modified. - for( vector>::const_iterator it = S.begin(); it != S.end(); it++) + for( vector >::const_iterator it = S.begin(); it != S.end(); it++) { int faceIdx = (*it).second; if (hit[faceIdx]) continue; @@ -2188,9 +2193,9 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) MCAuto mPartCand(mDesc->buildPartOfMySelf(&cands2[0], &cands2[0]+cands2.size(), false)); // false=zipCoords is called double * cooPartRef(mPartRef->_coords->getPointer()); double * cooPartCand(mPartCand->_coords->getPointer()); - for (int ii = 0; ii < mPartRef->_coords->getNumberOfTuples(); ii++) + for (std::size_t ii = 0; ii < mPartRef->_coords->getNumberOfTuples(); ii++) rotation.transform_vector(cooPartRef+SPACEDIM*ii); - for (int ii = 0; ii < mPartCand->_coords->getNumberOfTuples(); ii++) + for (std::size_t ii = 0; ii < mPartCand->_coords->getNumberOfTuples(); ii++) rotation.transform_vector(cooPartCand+SPACEDIM*ii); // Localize faces in 2D thanks to barycenters @@ -2307,7 +2312,7 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) // mDesc2->writeVTK("/tmp/toto_desc2_confInter.vtu"); const int *revDescIP2(revDescI2->getConstPointer()), *revDescP2(revDesc2->getConstPointer()); const int *cDesc2(mDesc2->getNodalConnectivity()->begin()),*cIDesc2(mDesc2->getNodalConnectivityIndex()->begin()); - MCAuto bboxArr(mDesc2->getBoundingBoxForBBTree()); + MCAuto bboxArr(mDesc2->getBoundingBoxForBBTree(eps)); const double *bbox2(bboxArr->begin()); int nDesc2Cell=mDesc2->getNumberOfCells(); BBTree myTree2(bbox2,0,0,nDesc2Cell,-eps); @@ -2317,17 +2322,18 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) DataArrayDouble * lens = lenF->getArray(); // Sort edges by decreasing length: - vector> S; - for(int i=0;i < lens->getNumberOfTuples();i++){ + vector > S; + for(std::size_t i=0;i < lens->getNumberOfTuples();i++) + { pair p = make_pair(lens->getIJ(i, 0), i); S.push_back(p); - } + } sort(S.rbegin(),S.rend()); // reverse sort vector hit(nDesc2Cell); fill(hit.begin(), hit.end(), false); - for( vector>::const_iterator it = S.begin(); it != S.end(); it++) + for( vector >::const_iterator it = S.begin(); it != S.end(); it++) { int eIdx = (*it).second; if (hit[eIdx]) @@ -2371,9 +2377,9 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) MCAuto nodeMapInv = nodeMap->invertArrayO2N2N2O(nbElemsNotM1); double * cooPartRef(mPartRef->_coords->getPointer()); double * cooPartCand(mPartCand->_coords->getPointer()); - for (int ii = 0; ii < mPartRef->_coords->getNumberOfTuples(); ii++) + for (std::size_t ii = 0; ii < mPartRef->_coords->getNumberOfTuples(); ii++) rotation.transform_vector(cooPartRef+SPACEDIM*ii); - for (int ii = 0; ii < mPartCand->_coords->getNumberOfTuples(); ii++) + for (std::size_t ii = 0; ii < mPartCand->_coords->getNumberOfTuples(); ii++) rotation.transform_vector(cooPartCand+SPACEDIM*ii); @@ -2395,7 +2401,7 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) mPartCand->getNodalConnectivity()->begin(), mPartCand->getNodalConnectivityIndex()->begin(), idsGoodLine->begin(), idsGoodLine->end(), /*out*/insidePoints, hitSegs); - // Optim: smaller segments completly included in eIdx and not split won't need any further treatment: + // Optim: smaller segments completely included in eIdx and not split won't need any further treatment: for (vector::const_iterator its=hitSegs.begin(); its != hitSegs.end(); ++its) hit[cands2[*its]] = true; @@ -2431,7 +2437,7 @@ DataArrayInt *MEDCouplingUMesh::conformize3D(double eps) MCAuto idx(DataArrayInt::New()); idx->alloc(1); idx->fillWithValue(0); MCAuto vals(DataArrayInt::New()); vals->alloc(0); newConn->set3(superIdx, idx, vals); - for(int ii = 0; ii < getNumberOfCells(); ii++) + for(std::size_t ii = 0; ii < getNumberOfCells(); ii++) for (int jj=descIP[ii]; jj < descIP[ii+1]; jj++) { int sz, faceIdx = abs(descP[jj])-1;