From: ageay Date: Thu, 8 Aug 2013 07:58:46 +0000 (+0000) Subject: abstraction of MEDCouplingPointSet::getBoundingBoxForBBTree X-Git-Tag: DBugPolyhIntersector~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=072d0c4d3c83e1757b7d1968b4aefaa8bf13f563;p=modules%2Fmed.git abstraction of MEDCouplingPointSet::getBoundingBoxForBBTree --- diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx index c882ea914..c838c975c 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.cxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.cxx @@ -1781,6 +1781,50 @@ MEDCoupling1DGTUMesh *MEDCoupling1SGTUMesh::computeDualMesh2D() const throw(INTE return ret.retn(); } +/*! + * This method aggregate the bbox of each cell and put it into bbox + * + * \return DataArrayDouble * - having \a this number of cells tuples and 2*spacedim components. + * + * \throw If \a this is not fully set (coordinates and connectivity). + * \throw If a cell in \a this has no valid nodeId. + */ +DataArrayDouble *MEDCoupling1SGTUMesh::getBoundingBoxForBBTree() const +{ + int spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()),nbOfNodesPerCell(getNumberOfNodesPerCell()); + MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); + double *bbox(ret->getPointer()); + for(int i=0;i::max(); + bbox[2*i+1]=-std::numeric_limits::max(); + } + const double *coordsPtr(_coords->getConstPointer()); + const int *conn(_conn->getConstPointer()); + for(int i=0;i=0 && nodeId ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); + double *bbox(ret->getPointer()); + for(int i=0;i::max(); + bbox[2*i+1]=-std::numeric_limits::max(); + } + const double *coordsPtr(_coords->getConstPointer()); + const int *conn(_conn->getConstPointer()),*connI(_conn_indx->getConstPointer()); + for(int i=0;i=0 && nodeId MEDCoupling1DGTUMesh::BuildAPolygonFromParts(const std::vector< std::vector >& parts) throw(INTERP_KERNEL::Exception) { std::vector ret; diff --git a/src/MEDCoupling/MEDCoupling1GTUMesh.hxx b/src/MEDCoupling/MEDCoupling1GTUMesh.hxx index 4725da20f..6af8c0ef2 100644 --- a/src/MEDCoupling/MEDCoupling1GTUMesh.hxx +++ b/src/MEDCoupling/MEDCoupling1GTUMesh.hxx @@ -129,6 +129,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N); MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const; MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree() const; // overload of MEDCoupling1GTUMesh MEDCOUPLING_EXPORT void checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception); @@ -212,6 +213,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void renumberNodesInConn(const int *newNodeNumbersO2N); MEDCOUPLING_EXPORT void fillCellIdsToKeepFromNodeIds(const int *begin, const int *end, bool fullyIn, DataArrayInt *&cellIdsKeptArr) const; MEDCOUPLING_EXPORT int getNumberOfNodesInCell(int cellId) const throw(INTERP_KERNEL::Exception); + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree() const; // overload of MEDCoupling1GTUMesh MEDCOUPLING_EXPORT void checkCoherencyOfConnectivity() const throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT void allocateCells(int nbOfCells=0) throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling/MEDCouplingPointSet.hxx b/src/MEDCoupling/MEDCouplingPointSet.hxx index dae6c4925..3faefb9b0 100644 --- a/src/MEDCoupling/MEDCouplingPointSet.hxx +++ b/src/MEDCoupling/MEDCouplingPointSet.hxx @@ -129,6 +129,7 @@ namespace ParaMEDMEM void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); + virtual DataArrayDouble *getBoundingBoxForBBTree() const = 0; virtual DataArrayInt *getCellsInBoundingBox(const double *bbox, double eps) const = 0; virtual DataArrayInt *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox& bbox, double eps) = 0; virtual DataArrayInt *zipCoordsTraducer() throw(INTERP_KERNEL::Exception); diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index d594c82ab..88cbe90bc 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -3877,13 +3877,13 @@ DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, MEDCouplingAutoRefCountObjectPtr ret1=DataArrayInt::New(); ret1->alloc(nbOfPts,1); const int *nc=_nodal_connec->begin(),*ncI=_nodal_connec_index->begin(); const double *coords=_coords->begin(); double *ret0Ptr=ret0->getPointer(); int *ret1Ptr=ret1->getPointer(); const double *ptsPtr=pts->begin(); - std::vector bbox; - getBoundingBoxForBBTree(bbox); + MEDCouplingAutoRefCountObjectPtr bboxArr(getBoundingBoxForBBTree()); + const double *bbox(bboxArr->begin()); switch(spaceDim) { case 3: { - BBTreeDst<3> myTree(&bbox[0],0,0,nbCells); + BBTreeDst<3> myTree(bbox,0,0,nbCells); for(int i=0;i::max(); @@ -3896,7 +3896,7 @@ DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, } case 2: { - BBTreeDst<2> myTree(&bbox[0],0,0,nbCells); + BBTreeDst<2> myTree(bbox,0,0,nbCells); for(int i=0;i::max(); @@ -4156,11 +4156,11 @@ template void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints, double eps, std::vector& elts, std::vector& eltsIndex) const { - std::vector bbox; eltsIndex.resize(nbOfPoints+1); eltsIndex[0]=0; elts.clear(); - getBoundingBoxForBBTree(bbox); + MEDCouplingAutoRefCountObjectPtr bboxArr(getBoundingBoxForBBTree()); + const double *bbox(bboxArr->begin()); int nbOfCells=getNumberOfCells(); const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); @@ -6176,21 +6176,25 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getSkewField() const throw(INTERP_KERN /*! * This method aggregate the bbox of each cell and put it into bbox parameter. - * \param bbox out parameter of size 2*spacedim*nbOfcells. + * + * \return DataArrayDouble * - having \a this number of cells tuples and 2*spacedim components. + * + * \throw If \a this is not fully set (coordinates and connectivity). + * \throw If a cell in \a this has no valid nodeId. */ -void MEDCouplingUMesh::getBoundingBoxForBBTree(std::vector& bbox) const +DataArrayDouble *MEDCouplingUMesh::getBoundingBoxForBBTree() const { - int spaceDim=getSpaceDimension(); - int nbOfCells=getNumberOfCells(); - bbox.resize(2*nbOfCells*spaceDim); + checkFullyDefined(); + int spaceDim(getSpaceDimension()),nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes()); + MEDCouplingAutoRefCountObjectPtr ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim); + double *bbox(ret->getPointer()); for(int i=0;i::max(); bbox[2*i+1]=-std::numeric_limits::max(); } - const double *coordsPtr=_coords->getConstPointer(); - const int *conn=_nodal_connec->getConstPointer(); - const int *connI=_nodal_connec_index->getConstPointer(); + const double *coordsPtr(_coords->getConstPointer()); + const int *conn(_nodal_connec->getConstPointer()),*connI(_nodal_connec_index->getConstPointer()); for(int i=0;i& bbox) const for(int j=0;j=0) - for(int k=0;k=0 && nodeId& addCoordsQuadratic, std::vector& cr, std::vector& crI, std::vector& cNb1, std::vector& cNb2) { static const int SPACEDIM=2; - std::vector bbox1,bbox2; const double *coo1=m1->getCoords()->getConstPointer(); const int *conn1=m1->getNodalConnectivity()->getConstPointer(); const int *connI1=m1->getNodalConnectivityIndex()->getConstPointer(); @@ -8251,15 +8264,15 @@ void MEDCouplingUMesh::BuildIntersecting2DCellsFromEdges(double eps, const MEDCo const int *connI2=m2->getNodalConnectivityIndex()->getConstPointer(); int offset2=offset1+m2->getNumberOfNodes(); int offset3=offset2+((int)addCoords.size())/2; - m1->getBoundingBoxForBBTree(bbox1); - m2->getBoundingBoxForBBTree(bbox2); - BBTree myTree(&bbox2[0],0,0,m2->getNumberOfCells(),eps); + MEDCouplingAutoRefCountObjectPtr bbox1Arr(m1->getBoundingBoxForBBTree()),bbox2Arr(m2->getBoundingBoxForBBTree()); + const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin()); + BBTree myTree(bbox2,0,0,m2->getNumberOfCells(),eps); int ncell1=m1->getNumberOfCells(); crI.push_back(0); for(int i=0;i candidates2; - myTree.getIntersectingElems(&bbox1[i*2*SPACEDIM],candidates2); + myTree.getIntersectingElems(bbox1+i*2*SPACEDIM,candidates2); std::map mapp; std::map mappRev; INTERP_KERNEL::QuadraticPolygon pol1; @@ -8334,22 +8347,21 @@ void MEDCouplingUMesh::IntersectDescending2DMeshes(const MEDCouplingUMesh *m1, c MEDCouplingAutoRefCountObjectPtr dd9(m1Desc),dd10(m2Desc); const int *c1=m1Desc->getNodalConnectivity()->getConstPointer(); const int *ci1=m1Desc->getNodalConnectivityIndex()->getConstPointer(); - std::vector bbox1,bbox2; - m1Desc->getBoundingBoxForBBTree(bbox1); - m2Desc->getBoundingBoxForBBTree(bbox2); + MEDCouplingAutoRefCountObjectPtr bbox1Arr(m1Desc->getBoundingBoxForBBTree()),bbox2Arr(m2Desc->getBoundingBoxForBBTree()); + const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin()); int ncell1=m1Desc->getNumberOfCells(); int ncell2=m2Desc->getNumberOfCells(); intersectEdge1.resize(ncell1); colinear2.resize(ncell2); subDiv2.resize(ncell2); - BBTree myTree(&bbox2[0],0,0,m2Desc->getNumberOfCells(),-eps); + BBTree myTree(bbox2,0,0,m2Desc->getNumberOfCells(),-eps); std::vector candidates1(1); int offset1=m1->getNumberOfNodes(); int offset2=offset1+m2->getNumberOfNodes(); for(int i=0;i candidates2; - myTree.getIntersectingElems(&bbox1[i*2*SPACEDIM],candidates2); + myTree.getIntersectingElems(bbox1+i*2*SPACEDIM,candidates2); if(!candidates2.empty()) { std::map map1,map2; diff --git a/src/MEDCoupling/MEDCouplingUMesh.hxx b/src/MEDCoupling/MEDCouplingUMesh.hxx index 5729dcdad..64db7ce57 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.hxx +++ b/src/MEDCoupling/MEDCouplingUMesh.hxx @@ -163,7 +163,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT DataArrayInt *convexEnvelop2D() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *findAndCorrectBadOriented3DExtrudedCells() throw(INTERP_KERNEL::Exception); MEDCOUPLING_EXPORT DataArrayInt *findAndCorrectBadOriented3DCells() throw(INTERP_KERNEL::Exception); - MEDCOUPLING_EXPORT void getBoundingBoxForBBTree(std::vector& bbox) const; + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree() const; MEDCOUPLING_EXPORT MEDCouplingUMesh *buildExtrudedMesh(const MEDCouplingUMesh *mesh1D, int policy); MEDCOUPLING_EXPORT bool isFullyQuadratic() const; MEDCOUPLING_EXPORT bool isPresenceOfQuadratic() const; diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx index 4301475f6..4279fe86b 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.cxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.cxx @@ -306,6 +306,11 @@ void MEDCouplingUMeshDesc::unserialization(const std::vector& tinyInfoD, setMeshDimension(tinyInfo[2]); } +DataArrayDouble *MEDCouplingUMeshDesc::getBoundingBoxForBBTree() const +{ + throw INTERP_KERNEL::Exception("MEDCouplingUMeshDesc::getBoundingBoxForBBTree : not implemented yet !"); +} + DataArrayInt *MEDCouplingUMeshDesc::getCellsInBoundingBox(const double *bbox, double eps) const { MEDCouplingAutoRefCountObjectPtr elems=DataArrayInt::New(); elems->alloc(0,1); diff --git a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx index 71e5e0f7d..093698e77 100644 --- a/src/MEDCoupling/MEDCouplingUMeshDesc.hxx +++ b/src/MEDCoupling/MEDCouplingUMeshDesc.hxx @@ -71,6 +71,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void resizeForUnserialization(const std::vector& tinyInfo, DataArrayInt *a1, DataArrayDouble *a2, std::vector& littleStrings) const; MEDCOUPLING_EXPORT void serialize(DataArrayInt *&a1, DataArrayDouble *&a2) const; MEDCOUPLING_EXPORT void unserialization(const std::vector& tinyInfoD, const std::vector& tinyInfo, const DataArrayInt *a1, DataArrayDouble *a2, const std::vector& littleStrings); + MEDCOUPLING_EXPORT DataArrayDouble *getBoundingBoxForBBTree() const; MEDCOUPLING_EXPORT DataArrayInt *getCellsInBoundingBox(const double *bbox, double eps) const; MEDCOUPLING_EXPORT DataArrayInt *getCellsInBoundingBox(const INTERP_KERNEL::DirectedBoundingBox &bbox, double eps); MEDCOUPLING_EXPORT MEDCouplingPointSet *mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const; diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 6f8a20de7..49b1903c4 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -394,6 +394,7 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::MEDCouplingPointSet::fillCellIdsToKeepFromNodeIds; %newobject ParaMEDMEM::MEDCouplingPointSet::getCellIdsLyingOnNodes; %newobject ParaMEDMEM::MEDCouplingPointSet::deepCpyConnectivityOnly; +%newobject ParaMEDMEM::MEDCouplingPointSet::getBoundingBoxForBBTree; %newobject ParaMEDMEM::MEDCouplingPointSet::__getitem__; %newobject ParaMEDMEM::MEDCouplingUMesh::New; %newobject ParaMEDMEM::MEDCouplingUMesh::getNodalConnectivity; @@ -1160,6 +1161,7 @@ namespace ParaMEDMEM virtual void checkFullyDefined() const throw(INTERP_KERNEL::Exception); virtual bool isEmptyMesh(const std::vector& tinyInfo) const throw(INTERP_KERNEL::Exception); virtual MEDCouplingPointSet *deepCpyConnectivityOnly() const throw(INTERP_KERNEL::Exception); + virtual DataArrayDouble *getBoundingBoxForBBTree() const throw(INTERP_KERNEL::Exception); %extend { std::string __str__() const throw(INTERP_KERNEL::Exception)