#include "BBTreeDst.txx"
#include "SplitterTetra.hxx"
#include "DirectedBoundingBox.hxx"
+#include "InterpKernelMatrixTools.hxx"
#include "InterpKernelMeshQuality.hxx"
#include "InterpKernelCellSimplify.hxx"
#include "InterpKernelGeo2DEdgeArcCircle.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
#include "InterpKernelAutoPtr.hxx"
#include "InterpKernelGeo2DNode.hxx"
#include "InterpKernelGeo2DEdgeLin.hxx"
return new MEDCouplingUMesh(*this,recDeepCpy);
}
-void MEDCouplingUMesh::shallowCopyConnectivityFrom(const MEDCouplingPointSet *other) throw(INTERP_KERNEL::Exception)
+/*!
+ * This method behaves mostly like MEDCouplingUMesh::deepCpy method, except that only nodal connectivity arrays are deeply copied.
+ * The coordinates are shared between \a this and the returned instance.
+ *
+ * \return MEDCouplingUMesh * - A new object instance holding the copy of \a this (deep for connectivity, shallow for coordiantes)
+ * \sa MEDCouplingUMesh::deepCpy
+ */
+MEDCouplingPointSet *MEDCouplingUMesh::deepCpyConnectivityOnly() const
+{
+ checkConnectivityFullyDefined();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=clone(false);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(getNodalConnectivity()->deepCpy()),ci(getNodalConnectivityIndex()->deepCpy());
+ ret->setConnectivity(c,ci);
+ return ret.retn();
+}
+
+void MEDCouplingUMesh::shallowCopyConnectivityFrom(const MEDCouplingPointSet *other)
{
if(!other)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::shallowCopyConnectivityFrom : input pointer is null !");
setConnectivity(otherC2->getNodalConnectivity(),otherC2->getNodalConnectivityIndex(),true);
}
-std::size_t MEDCouplingUMesh::getHeapMemorySize() const
+std::size_t MEDCouplingUMesh::getHeapMemorySizeWithoutChildren() const
{
- std::size_t ret=0;
+ std::size_t ret(MEDCouplingPointSet::getHeapMemorySizeWithoutChildren());
+ return ret;
+}
+
+std::vector<const BigMemoryObject *> MEDCouplingUMesh::getDirectChildren() const
+{
+ std::vector<const BigMemoryObject *> ret(MEDCouplingPointSet::getDirectChildren());
if(_nodal_connec)
- ret+=_nodal_connec->getHeapMemorySize();
+ ret.push_back(_nodal_connec);
if(_nodal_connec_index)
- ret+=_nodal_connec_index->getHeapMemorySize();
- return MEDCouplingPointSet::getHeapMemorySize()+ret;
+ ret.push_back(_nodal_connec_index);
+ return ret;
}
void MEDCouplingUMesh::updateTime() const
* \throw If the connectivity index data array has more than one component.
* \throw If the connectivity index data array has a named component.
*/
-void MEDCouplingUMesh::checkCoherency() const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::checkCoherency() const
{
if(_mesh_dim<-1)
throw INTERP_KERNEL::Exception("No mesh dimension specified !");
* \throw If number of nodes defining an element does not correspond to the type of element.
* \throw If the nodal connectivity includes an invalid node id.
*/
-void MEDCouplingUMesh::checkCoherency1(double eps) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::checkCoherency1(double eps) const
{
checkCoherency();
if(_mesh_dim==-1)
* \throw If number of nodes defining an element does not correspond to the type of element.
* \throw If the nodal connectivity includes an invalid node id.
*/
-void MEDCouplingUMesh::checkCoherency2(double eps) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::checkCoherency2(double eps) const
{
checkCoherency1(eps);
}
* \ref medcouplingcppexamplesUmeshStdBuild1 "Here is a C++ example".<br>
* \ref medcouplingpyexamplesUmeshStdBuild1 "Here is a Python example".
*/
-void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::insertNextCell(INTERP_KERNEL::NormalizedCellType type, int size, const int *nodalConnOfCell)
{
const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(type);
if(_nodal_connec_index==0)
* In this case MEDCouplingUMesh::sortCellsInMEDFileFrmt or MEDCouplingUMesh::rearrange2ConsecutiveCellTypes methods for example can be called before invoking this method.
* Useful for python users.
*/
-MEDCouplingUMeshCellByTypeEntry *MEDCouplingUMesh::cellsByType() throw(INTERP_KERNEL::Exception)
+MEDCouplingUMeshCellByTypeEntry *MEDCouplingUMesh::cellsByType()
{
if(!checkConsecutiveCellTypes())
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::cellsByType : this mesh is not sorted by type !");
* This method is a method that compares \a this and \a other.
* This method compares \b all attributes, even names and component names.
*/
-bool MEDCouplingUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const throw(INTERP_KERNEL::Exception)
+bool MEDCouplingUMesh::isEqualIfNotWhy(const MEDCouplingMesh *other, double prec, std::string& reason) const
{
if(!other)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::isEqualIfNotWhy : input other pointer is null !");
* \param [in] prec - the precision used to compare nodes of the two meshes.
* \throw If the two meshes do not match.
*/
-void MEDCouplingUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::checkFastEquivalWith(const MEDCouplingMesh *other, double prec) const
{
MEDCouplingPointSet::checkFastEquivalWith(other,prec);
const MEDCouplingUMesh *otherC=dynamic_cast<const MEDCouplingUMesh *>(other);
* \ref cpp_mcumesh_getReverseNodalConnectivity "Here is a C++ example".<br>
* \ref py_mcumesh_getReverseNodalConnectivity "Here is a Python example".
*/
-void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::getReverseNodalConnectivity(DataArrayInt *revNodal, DataArrayInt *revNodalIndx) const
{
checkFullyDefined();
int nbOfNodes=getNumberOfNodes();
* \ref py_mcumesh_buildDescendingConnectivity "Here is a Python example".
* \sa buildDescendingConnectivity2()
*/
-MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
{
return buildDescendingConnectivityGen<MinusOneSonsGenerator>(desc,descIndx,revDesc,revDescIndx,MEDCouplingFastNbrer);
}
* This method returns 4 arrays and a mesh as MEDCouplingUMesh::buildDescendingConnectivity does.
* \sa MEDCouplingUMesh::buildDescendingConnectivity
*/
-MEDCouplingUMesh *MEDCouplingUMesh::explode3DMeshTo1D(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::explode3DMeshTo1D(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
{
checkFullyDefined();
if(getMeshDimension()!=3)
* \ref py_mcumesh_buildDescendingConnectivity2 "Here is a Python example".
* \sa buildDescendingConnectivity()
*/
-MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity2(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivity2(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx) const
{
return buildDescendingConnectivityGen<MinusOneSonsGenerator>(desc,descIndx,revDesc,revDescIndx,MEDCouplingOrientationSensitiveNbrer);
}
* parameter allows to select the right part in this array. The number of tuples is equal to the last values in \b neighborsIndx.
* \param [out] neighborsIndx is an array of size this->getNumberOfCells()+1 newly allocated and should be dealt by the caller. This arrays allow to use the first output parameter \b neighbors.
*/
-void MEDCouplingUMesh::computeNeighborsOfCells(DataArrayInt *&neighbors, DataArrayInt *&neighborsIndx) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::computeNeighborsOfCells(DataArrayInt *&neighbors, DataArrayInt *&neighborsIndx) const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc=DataArrayInt::New();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> descIndx=DataArrayInt::New();
* For speed reasons no check of this will be done.
*/
template<class SonsGenerator>
-MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivityGen(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx, DimM1DescNbrer nbrer) const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::buildDescendingConnectivityGen(DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *revDesc, DataArrayInt *revDescIndx, DimM1DescNbrer nbrer) const
{
if(!desc || !descIndx || !revDesc || !revDescIndx)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildDescendingConnectivityGen : present of a null pointer in input !");
* \ref cpp_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a C++ example".<br>
* \ref py_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a Python example".
*/
-void MEDCouplingUMesh::convertExtrudedPolyhedra() throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::convertExtrudedPolyhedra()
{
checkFullyDefined();
if(getMeshDimension()!=3 || getSpaceDimension()!=3)
* \param [in] eps is a relative precision that allows to establish if some 3D plane are coplanar or not. This epsilon is used to recenter around origin to have maximal
* precision.
*/
-void MEDCouplingUMesh::simplifyPolyhedra(double eps) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::simplifyPolyhedra(double eps)
{
checkFullyDefined();
if(getMeshDimension()!=3 || getSpaceDimension()!=3)
* \return a newly allocated DataArrayInt sorted ascendingly of fetched node ids.
* \sa MEDCouplingUMesh::getNodeIdsInUse
*/
-DataArrayInt *MEDCouplingUMesh::computeFetchedNodeIds() const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::computeFetchedNodeIds() const
{
checkConnectivityFullyDefined();
int nbOfCells=getNumberOfCells();
* \param [in,out] nodeIdsInUse an array of size typically equal to nbOfNodes.
* \sa MEDCouplingUMesh::getNodeIdsInUse
*/
-void MEDCouplingUMesh::computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::computeNodeIdsAlg(std::vector<bool>& nodeIdsInUse) const
{
int nbOfNodes=(int)nodeIdsInUse.size();
int nbOfCells=getNumberOfCells();
* \ref py_mcumesh_getNodeIdsInUse "Here is a Python example".
* \sa computeNodeIdsAlg()
*/
-DataArrayInt *MEDCouplingUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::getNodeIdsInUse(int& nbrOfNodesInUse) const
{
nbrOfNodesInUse=-1;
int nbOfNodes=getNumberOfNodes();
* So for pohyhedrons some nodes can be counted several times in the returned result.
*
* \return a newly allocated array
+ * \sa MEDCouplingUMesh::computeEffectiveNbOfNodesPerCell
*/
-DataArrayInt *MEDCouplingUMesh::computeNbOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::computeNbOfNodesPerCell() const
{
checkConnectivityFullyDefined();
int nbOfCells=getNumberOfCells();
return ret.retn();
}
+/*!
+ * This method computes effective number of nodes per cell. That is to say nodes appearing several times in nodal connectivity of a cell,
+ * will be counted only once here whereas it will be counted several times in MEDCouplingUMesh::computeNbOfNodesPerCell method.
+ *
+ * \return DataArrayInt * - new object to be deallocated by the caller.
+ * \sa MEDCouplingUMesh::computeNbOfNodesPerCell
+ */
+DataArrayInt *MEDCouplingUMesh::computeEffectiveNbOfNodesPerCell() const
+{
+ checkConnectivityFullyDefined();
+ int nbOfCells=getNumberOfCells();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
+ ret->alloc(nbOfCells,1);
+ int *retPtr=ret->getPointer();
+ const int *conn=getNodalConnectivity()->getConstPointer();
+ const int *connI=getNodalConnectivityIndex()->getConstPointer();
+ for(int i=0;i<nbOfCells;i++,retPtr++)
+ {
+ std::set<int> s(conn+connI[i]+1,conn+connI[i+1]);
+ if(conn[connI[i]]!=(int)INTERP_KERNEL::NORM_POLYHED)
+ *retPtr=(int)s.size();
+ else
+ {
+ s.erase(-1);
+ *retPtr=(int)s.size();
+ }
+ }
+ return ret.retn();
+}
+
/*!
* This method returns a newly allocated array containing this->getNumberOfCells() tuples and 1 component.
* For each cell in \b this the number of faces constituting (entity of dimension this->getMeshDimension()-1) cell is computed.
*
* \return a newly allocated array
*/
-DataArrayInt *MEDCouplingUMesh::computeNbOfFacesPerCell() const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::computeNbOfFacesPerCell() const
{
checkConnectivityFullyDefined();
int nbOfCells=getNumberOfCells();
* \ref cpp_mcumesh_zipCoordsTraducer "Here is a C++ example".<br>
* \ref py_mcumesh_zipCoordsTraducer "Here is a Python example".
*/
-DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer() throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::zipCoordsTraducer()
{
- int newNbOfNodes=-1;
- DataArrayInt *traducer=getNodeIdsInUse(newNbOfNodes);
- renumberNodes(traducer->getConstPointer(),newNbOfNodes);
- return traducer;
+ return MEDCouplingPointSet::zipCoordsTraducer();
}
/*!
* \return the correspondance array old to new in a newly allocated array.
*
*/
-void MEDCouplingUMesh::findCommonCells(int compType, int startCellId, DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::findCommonCells(int compType, int startCellId, DataArrayInt *& commonCellsArr, DataArrayInt *& commonCellsIArr) const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> revNodal=DataArrayInt::New(),revNodalI=DataArrayInt::New();
getReverseNodalConnectivity(revNodal,revNodalI);
* \sa checkDeepEquivalOnSameNodesWith()
* \sa checkGeoEquivalWith()
*/
-bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception)
+bool MEDCouplingUMesh::areCellsIncludedIn(const MEDCouplingUMesh *other, int compType, DataArrayInt *& arr) const
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MergeUMeshesOnSameCoords(this,other);
int nbOfCells=getNumberOfCells();
}
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> o2n=mesh->zipConnectivityTraducer(compType,nbOfCells);
arr=o2n->substr(nbOfCells);
- arr->setName(other->getName());
+ arr->setName(other->getName().c_str());
int tmp;
if(other->getNumberOfCells()==0)
return true;
* \param arr is an output parameter that returns a \b newly created instance. This array is of size 'other->getNumberOfCells()'.
* \return If \a other is fully included in 'this 'true is returned. If not false is returned.
*/
-bool MEDCouplingUMesh::areCellsIncludedIn2(const MEDCouplingUMesh *other, DataArrayInt *& arr) const throw(INTERP_KERNEL::Exception)
+bool MEDCouplingUMesh::areCellsIncludedIn2(const MEDCouplingUMesh *other, DataArrayInt *& arr) const
{
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MergeUMeshesOnSameCoords(this,other);
DataArrayInt *commonCells=0,*commonCellsI=0;
}
}
}
- arr2->setName(other->getName());
+ arr2->setName(other->getName().c_str());
if(arr2->presenceOfValue(0))
return false;
arr=arr2.retn();
return true;
}
-/*!
- * Merges nodes equal within \a precision and returns an array describing the
- * permutation used to remove duplicate nodes.
- * \param [in] precision - minimal absolute distance between two nodes at which they are
- * considered not coincident.
- * \param [out] areNodesMerged - is set to \c true if any coincident nodes removed.
- * \param [out] newNbOfNodes - number of nodes remaining after the removal.
- * \return DataArrayInt * - the permutation array in "Old to New" mode. For more
- * info on "Old to New" mode see \ref MEDCouplingArrayRenumbering. The caller
- * is to delete this array using decrRef() as it is no more needed.
- * \throw If the coordinates array is not set.
- * \throw If the nodal connectivity of cells is not defined.
- *
- * \ref cpp_mcumesh_mergeNodes "Here is a C++ example".<br>
- * \ref py_mcumesh_mergeNodes "Here is a Python example".
- */
-DataArrayInt *MEDCouplingUMesh::mergeNodes(double precision, bool& areNodesMerged, int& newNbOfNodes)
-{
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=buildPermArrayForMergeNode(precision,-1,areNodesMerged,newNbOfNodes);
- if(areNodesMerged)
- renumberNodes(ret->begin(),newNbOfNodes);
- return ret.retn();
-}
-
-
-/*!
- * Merges nodes equal within \a precision and returns an array describing the
- * permutation used to remove duplicate nodes. In contrast to mergeNodes(), location
- * of merged nodes is changed to be at their barycenter.
- * \param [in] precision - minimal absolute distance between two nodes at which they are
- * considered not coincident.
- * \param [out] areNodesMerged - is set to \c true if any coincident nodes removed.
- * \param [out] newNbOfNodes - number of nodes remaining after the removal.
- * \return DataArrayInt * - the permutation array in "Old to New" mode. For more
- * info on "Old to New" mode see \ref MEDCouplingArrayRenumbering. The caller
- * is to delete this array using decrRef() as it is no more needed.
- * \throw If the coordinates array is not set.
- * \throw If the nodal connectivity of cells is not defined.
- *
- * \ref cpp_mcumesh_mergeNodes "Here is a C++ example".<br>
- * \ref py_mcumesh_mergeNodes "Here is a Python example".
- */
-DataArrayInt *MEDCouplingUMesh::mergeNodes2(double precision, bool& areNodesMerged, int& newNbOfNodes)
-{
- DataArrayInt *ret=buildPermArrayForMergeNode(precision,-1,areNodesMerged,newNbOfNodes);
- if(areNodesMerged)
- renumberNodes2(ret->getConstPointer(),newNbOfNodes);
- return ret;
-}
-
MEDCouplingPointSet *MEDCouplingUMesh::mergeMyselfWithOnSameCoords(const MEDCouplingPointSet *other) const
{
if(!other)
* \warning This method modifies can generate an unstructured mesh whose cells are not sorted by geometric type order.
* In view of the MED file writing, a renumbering of cells of returned unstructured mesh (using MEDCouplingUMesh::sortCellsInMEDFileFrmt) should be necessary.
*/
-MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf2(int start, int end, int step, bool keepCoords) const throw(INTERP_KERNEL::Exception)
+MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelf2(int start, int end, int step, bool keepCoords) const
{
if(getMeshDimension()!=-1)
return MEDCouplingPointSet::buildPartOfMySelf2(start,end,step,keepCoords);
* \param [in] otherOnSameCoordsThanThis an another mesh with same meshdimension than \b this with exactly the same number of cells than cell ids list in [\b cellIdsBg, \b cellIdsEnd ).
* Coordinate pointer of \b this and those of \b otherOnSameCoordsThanThis must be the same
*/
-void MEDCouplingUMesh::setPartOfMySelf(const int *cellIdsBg, const int *cellIdsEnd, const MEDCouplingUMesh& otherOnSameCoordsThanThis) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::setPartOfMySelf(const int *cellIdsBg, const int *cellIdsEnd, const MEDCouplingUMesh& otherOnSameCoordsThanThis)
{
checkConnectivityFullyDefined();
otherOnSameCoordsThanThis.checkConnectivityFullyDefined();
}
}
-void MEDCouplingUMesh::setPartOfMySelf2(int start, int end, int step, const MEDCouplingUMesh& otherOnSameCoordsThanThis) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::setPartOfMySelf2(int start, int end, int step, const MEDCouplingUMesh& otherOnSameCoordsThanThis)
{
checkConnectivityFullyDefined();
otherOnSameCoordsThanThis.checkConnectivityFullyDefined();
* A cell is detected to be on boundary if it contains one or more than one face having only one father.
* This method makes the assumption that \a this is fully defined (coords,connectivity). If not an exception will be thrown.
*/
-DataArrayInt *MEDCouplingUMesh::findCellIdsOnBoundary() const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::findCellIdsOnBoundary() const
{
checkFullyDefined();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc=DataArrayInt::New();
* \param [out] cellIdsRk1 a newly allocated array containing cells ids of s1+s2 \b into \b cellIdsRk0 subset. To get absolute ids of s1+s2 simply invoke
* cellIdsRk1->transformWithIndArr(cellIdsRk0->begin(),cellIdsRk0->end());
*/
-void MEDCouplingUMesh::findCellIdsLyingOn(const MEDCouplingUMesh& otherDimM1OnSameCoords, DataArrayInt *&cellIdsRk0, DataArrayInt *&cellIdsRk1) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::findCellIdsLyingOn(const MEDCouplingUMesh& otherDimM1OnSameCoords, DataArrayInt *&cellIdsRk0, DataArrayInt *&cellIdsRk1) const
{
if(getCoords()!=otherDimM1OnSameCoords.getCoords())
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::findCellIdsLyingOn : coordinates pointer are not the same ! Use tryToShareSameCoords method !");
*
* \return a newly allocated mesh lying on the same coordinates than \b this. The caller has to deal with returned mesh.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::computeSkin() const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::computeSkin() const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc=DataArrayInt::New();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> descIndx=DataArrayInt::New();
return skin->computeFetchedNodeIds();
}
-MEDCouplingUMesh *MEDCouplingUMesh::buildUnstructured() const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::buildUnstructured() const
{
incrRef();
return const_cast<MEDCouplingUMesh *>(this);
* \param [in] nodeIdsToDuplicateBg begin of node ids (included) to be duplicated in connectivity only
* \param [in] nodeIdsToDuplicateEnd end of node ids (excluded) to be duplicated in connectivity only
*/
-void MEDCouplingUMesh::duplicateNodes(const int *nodeIdsToDuplicateBg, const int *nodeIdsToDuplicateEnd) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::duplicateNodes(const int *nodeIdsToDuplicateBg, const int *nodeIdsToDuplicateEnd)
{
int nbOfNodes=getNumberOfNodes();
duplicateNodesInCoords(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd);
*
* \param [in] delta specifies the shift size applied to nodeId in nodal connectivity in \b this.
*/
-void MEDCouplingUMesh::shiftNodeNumbersInConn(int delta) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::shiftNodeNumbersInConn(int delta)
{
checkConnectivityFullyDefined();
int *conn=getNodalConnectivity()->getPointer();
* \param [in] nodeIdsToDuplicateEnd end of node ids (excluded) to be duplicated in connectivity only
* \param [in] offset the offset applied to all node ids in connectivity that are in [ \a nodeIdsToDuplicateBg, \a nodeIdsToDuplicateEnd ).
*/
-void MEDCouplingUMesh::duplicateNodesInConn(const int *nodeIdsToDuplicateBg, const int *nodeIdsToDuplicateEnd, int offset) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::duplicateNodesInConn(const int *nodeIdsToDuplicateBg, const int *nodeIdsToDuplicateEnd, int offset)
{
checkConnectivityFullyDefined();
std::map<int,int> m;
*
* \param [in] old2NewBg is expected to be a dynamically allocated pointer of size at least equal to this->getNumberOfCells()
*/
-void MEDCouplingUMesh::renumberCells(const int *old2NewBg, bool check) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::renumberCells(const int *old2NewBg, bool check)
{
checkConnectivityFullyDefined();
int nbCells=getNumberOfCells();
* \param [in] type the geometric type
* \return cell ids in this having geometric type \a type.
*/
-DataArrayInt *MEDCouplingUMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::giveCellsWithType(INTERP_KERNEL::NormalizedCellType type) const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
* This method returns a C++ code that is a dump of \a this.
* This method will throw if this is not fully defined.
*/
-std::string MEDCouplingUMesh::cppRepr() const throw(INTERP_KERNEL::Exception)
+std::string MEDCouplingUMesh::cppRepr() const
{
static const char coordsName[]="coords";
static const char connName[]="conn";
* This method analyzes the 3 arrays of \a this. For each the following behaviour is done : if the array is null a newly one is created
* with number of tuples set to 0, if not the array is taken as this in the returned instance.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::buildSetInstanceFromThis(int spaceDim) const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::buildSetInstanceFromThis(int spaceDim) const
{
int mdim=getMeshDimension();
if(mdim<0)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildSetInstanceFromThis : invalid mesh dimension ! Should be >= 0 !");
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName(),mdim);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName().c_str(),mdim);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1,tmp2;
bool needToCpyCT=true;
if(!_nodal_connec)
* \throw If the nodal connectivity of cells is not defined.
* \sa getAllTypes()
*/
-std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getTypesOfPart(const int *begin, const int *end) const throw(INTERP_KERNEL::Exception)
+std::set<INTERP_KERNEL::NormalizedCellType> MEDCouplingUMesh::getTypesOfPart(const int *begin, const int *end) const
{
checkFullyDefined();
std::set<INTERP_KERNEL::NormalizedCellType> ret;
/*!
* This method checks that all arrays are set. If yes nothing done if no an exception is thrown.
*/
-void MEDCouplingUMesh::checkFullyDefined() const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::checkFullyDefined() const
{
if(!_nodal_connec_index || !_nodal_connec || !_coords)
throw INTERP_KERNEL::Exception("Reverse nodal connectivity computation requires full connectivity and coordinates set in unstructured mesh.");
/*!
* This method checks that all connectivity arrays are set. If yes nothing done if no an exception is thrown.
*/
-void MEDCouplingUMesh::checkConnectivityFullyDefined() const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::checkConnectivityFullyDefined() const
{
if(!_nodal_connec_index || !_nodal_connec)
throw INTERP_KERNEL::Exception("Reverse nodal connectivity computation requires full connectivity set in unstructured mesh.");
*/
MEDCouplingPointSet *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin, const int *end) const
{
- checkFullyDefined();
+ checkConnectivityFullyDefined();
int ncell=getNumberOfCells();
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New();
ret->_mesh_dim=_mesh_dim;
* \throw If the plane does not intersect any 3D cell of \a this mesh.
* \throw If \a this includes quadratic cells.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3D(const double *origin, const double *vec, double eps, DataArrayInt *&cellIds) const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3D(const double *origin, const double *vec, double eps, DataArrayInt *&cellIds) const
{
checkFullyDefined();
if(getMeshDimension()!=3 || getSpaceDimension()!=3)
* \throw If the plane does not intersect any 2D cell of \a this mesh.
* \throw If \a this includes quadratic cells.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3DSurf(const double *origin, const double *vec, double eps, DataArrayInt *&cellIds) const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::buildSlice3DSurf(const double *origin, const double *vec, double eps, DataArrayInt *&cellIds) const
{
checkFullyDefined();
if(getMeshDimension()!=2 || getSpaceDimension()!=3)
* \throw If magnitude of \a vec is less than 1e-6.
* \sa buildSlice3D()
*/
-DataArrayInt *MEDCouplingUMesh::getCellIdsCrossingPlane(const double *origin, const double *vec, double eps) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::getCellIdsCrossingPlane(const double *origin, const double *vec, double eps) const
{
checkFullyDefined();
if(getSpaceDimension()!=3)
* A 1D mesh is said contiguous if : a cell i with nodal connectivity (k,p) the cell i+1 the nodal connectivity should be (p,m)
* If not false is returned. In case that false is returned a call to ParaMEDMEM::MEDCouplingUMesh::mergeNodes could be usefull.
*/
-bool MEDCouplingUMesh::isContiguous1D() const throw(INTERP_KERNEL::Exception)
+bool MEDCouplingUMesh::isContiguous1D() const
{
if(getMeshDimension()!=1)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::isContiguous1D : this method has a sense only for 1D mesh !");
* dimension - 1.
* \sa DataArrayDouble::distanceToTuple, MEDCouplingUMesh::distanceToPoints
*/
-double MEDCouplingUMesh::distanceToPoint(const double *ptBg, const double *ptEnd, int& cellId) const throw(INTERP_KERNEL::Exception)
+double MEDCouplingUMesh::distanceToPoint(const double *ptBg, const double *ptEnd, int& cellId) const
{
int meshDim=getMeshDimension(),spaceDim=getSpaceDimension();
if(meshDim!=spaceDim-1)
* \throw if mesh dimension of \a this is not equal to space dimension - 1.
* \sa DataArrayDouble::distanceToTuple, MEDCouplingUMesh::distanceToPoint
*/
-DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, DataArrayInt *& cellIds) const throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDCouplingUMesh::distanceToPoints(const DataArrayDouble *pts, DataArrayInt *& cellIds) const
{
if(!pts)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::distanceToPoints : input points pointer is NULL !");
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> 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<double> bbox;
- getBoundingBoxForBBTree(bbox);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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<nbOfPts;i++,ret0Ptr++,ret1Ptr++,ptsPtr+=3)
{
double x=std::numeric_limits<double>::max();
}
case 2:
{
- BBTreeDst<2> myTree(&bbox[0],0,0,nbCells);
+ BBTreeDst<2> myTree(bbox,0,0,nbCells);
for(int i=0;i<nbOfPts;i++,ret0Ptr++,ret1Ptr++,ptsPtr+=2)
{
double x=std::numeric_limits<double>::max();
* \param [out] cellId that corresponds to minimal distance. If the closer node is not linked to any cell in \a this -1 is returned.
* \sa MEDCouplingUMesh::distanceToPoint, MEDCouplingUMesh::distanceToPoints
*/
-void MEDCouplingUMesh::DistanceToPoint3DSurfAlg(const double *pt, const int *cellIdsBg, const int *cellIdsEnd, const double *coords, const int *nc, const int *ncI, double& ret0, int& cellId) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::DistanceToPoint3DSurfAlg(const double *pt, const int *cellIdsBg, const int *cellIdsEnd, const double *coords, const int *nc, const int *ncI, double& ret0, int& cellId)
{
cellId=-1;
ret0=std::numeric_limits<double>::max();
* \param [out] cellId that corresponds to minimal distance. If the closer node is not linked to any cell in \a this -1 is returned.
* \sa MEDCouplingUMesh::distanceToPoint, MEDCouplingUMesh::distanceToPoints
*/
-void MEDCouplingUMesh::DistanceToPoint2DCurveAlg(const double *pt, const int *cellIdsBg, const int *cellIdsEnd, const double *coords, const int *nc, const int *ncI, double& ret0, int& cellId) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::DistanceToPoint2DCurveAlg(const double *pt, const int *cellIdsBg, const int *cellIdsEnd, const double *coords, const int *nc, const int *ncI, double& ret0, int& cellId)
{
cellId=-1;
ret0=std::numeric_limits<double>::max();
* faster.
* \param [in] pos - array of coordinates of the ball central point.
* \param [in] eps - ball radius.
- * \param [in,out] elts - vector returning ids of the found cells. It is cleared
+ * \param [out] elts - vector returning ids of the found cells. It is cleared
* before inserting ids.
* \throw If the coordinates array is not set.
* \throw If \a this->getMeshDimension() != \a this->getSpaceDimension().
*/
void MEDCouplingUMesh::getCellsContainingPoint(const double *pos, double eps, std::vector<int>& elts) const
{
- std::vector<int> eltsIndex;
- getCellsContainingPoints(pos,1,eps,elts,eltsIndex);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> eltsUg,eltsIndexUg;
+ getCellsContainingPoints(pos,1,eps,eltsUg,eltsIndexUg);
+ elts.clear(); elts.insert(elts.end(),eltsUg->begin(),eltsUg->end());
}
/// @cond INTERNAL
template<int SPACEDIM>
void MEDCouplingUMesh::getCellsContainingPointsAlg(const double *coords, const double *pos, int nbOfPoints,
- double eps, std::vector<int>& elts, std::vector<int>& eltsIndex) const
+ double eps, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& elts, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& eltsIndex) const
{
- std::vector<double> bbox;
- eltsIndex.resize(nbOfPoints+1);
- eltsIndex[0]=0;
- elts.clear();
- getBoundingBoxForBBTree(bbox);
+ elts=DataArrayInt::New(); eltsIndex=DataArrayInt::New(); eltsIndex->alloc(nbOfPoints+1,1); eltsIndex->setIJ(0,0,0); elts->alloc(0,1);
+ int *eltsIndexPtr(eltsIndex->getPointer());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bboxArr(getBoundingBoxForBBTree());
+ const double *bbox(bboxArr->begin());
int nbOfCells=getNumberOfCells();
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
BBTree<SPACEDIM,int> myTree(&bbox[0],0,0,nbOfCells,-eps);
for(int i=0;i<nbOfPoints;i++)
{
- eltsIndex[i+1]=eltsIndex[i];
+ eltsIndexPtr[i+1]=eltsIndexPtr[i];
for(int j=0;j<SPACEDIM;j++)
{
bb[2*j]=pos[SPACEDIM*i+j];
(INTERP_KERNEL::NormalizedCellType)conn[connI[*iter]],
coords,conn+connI[*iter]+1,sz,eps))
{
- eltsIndex[i+1]++;
- elts.push_back(*iter);
+ eltsIndexPtr[i+1]++;
+ elts->pushBackSilent(*iter);
}
}
}
* this->getSpaceDimension() * \a nbOfPoints
* \param [in] nbOfPoints - number of points to locate within \a this mesh.
* \param [in] eps - radius of balls (i.e. the precision).
- * \param [in,out] elts - vector returning ids of found cells.
- * \param [in,out] eltsIndex - an array, of length \a nbOfPoints + 1,
+ * \param [out] elts - vector returning ids of found cells.
+ * \param [out] eltsIndex - an array, of length \a nbOfPoints + 1,
* dividing cell ids in \a elts into groups each referring to one
* point. Its every element (except the last one) is an index pointing to the
* first id of a group of cells. For example cells in contact with the *i*-th
* \ref py_mcumesh_getCellsContainingPoints "Here is a Python example".
*/
void MEDCouplingUMesh::getCellsContainingPoints(const double *pos, int nbOfPoints, double eps,
- std::vector<int>& elts, std::vector<int>& eltsIndex) const
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& elts, MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& eltsIndex) const
{
int spaceDim=getSpaceDimension();
int mDim=getMeshDimension();
*
* \return a newly allocated array containing cellIds that have been modified if any. If no cells have been impacted by this method NULL is returned.
*/
-DataArrayInt *MEDCouplingUMesh::convexEnvelop2D() throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::convexEnvelop2D()
{
if(getMeshDimension()!=2 || getSpaceDimension()!=2)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convexEnvelop2D works only for meshDim=2 and spaceDim=2 !");
* if cut3DCurve[i]==-1, it means that cell#i has been already detected to be fully part of plane defined by ('origin','vec').
* This method will throw an exception if \a this contains a non linear segment.
*/
-void MEDCouplingUMesh::split3DCurveWithPlane(const double *origin, const double *vec, double eps, std::vector<int>& cut3DCurve) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::split3DCurveWithPlane(const double *origin, const double *vec, double eps, std::vector<int>& cut3DCurve)
{
checkFullyDefined();
if(getMeshDimension()!=1 || getSpaceDimension()!=3)
* \param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
* \return newCoords new coords filled by this method.
*/
-DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation(const MEDCouplingUMesh *mesh1D, bool isQuad) const throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation(const MEDCouplingUMesh *mesh1D, bool isQuad) const
{
if(mesh1D->getSpaceDimension()==2)
return fillExtCoordsUsingTranslAndAutoRotation2D(mesh1D,isQuad);
* \param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
* \return newCoords new coords filled by this method.
*/
-DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(const MEDCouplingUMesh *mesh1D, bool isQuad) const throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(const MEDCouplingUMesh *mesh1D, bool isQuad) const
{
if(isQuad)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : not implemented for quadratic cells !");
* \param mesh1D is the input 1D mesh used for translation and automatic rotation computation.
* \return newCoords new coords filled by this method.
*/
-DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(const MEDCouplingUMesh *mesh1D, bool isQuad) const throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(const MEDCouplingUMesh *mesh1D, bool isQuad) const
{
if(isQuad)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D : not implemented for quadratic cells !");
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*/
-void MEDCouplingUMesh::convertQuadraticCellsToLinear() throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::convertQuadraticCellsToLinear()
{
checkFullyDefined();
int nbOfCells=getNumberOfCells();
*
* \sa MEDCouplingUMesh::convertQuadraticCellsToLinear
*/
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic(int conversionType) throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic(int conversionType)
{
DataArrayInt *conn=0,*connI=0;
DataArrayDouble *coords=0;
* \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
* \sa MEDCouplingUMesh::convertLinearCellsToQuadratic.
*/
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic1D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic1D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bary=getBarycenterAndOwner();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(0,1);
return ret.retn();
}
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2DAnd3D0(const MEDCouplingUMesh *m1D, const DataArrayInt *desc, const DataArrayInt *descI, DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2DAnd3D0(const MEDCouplingUMesh *m1D, const DataArrayInt *desc, const DataArrayInt *descI, DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn=DataArrayInt::New(); newConn->alloc(0,1);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConnI=DataArrayInt::New(); newConnI->alloc(1,1); newConnI->setIJ(0,0,0);
* \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
* \sa MEDCouplingUMesh::convertLinearCellsToQuadratic.
*/
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc(DataArrayInt::New()),descI(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New());
return convertLinearCellsToQuadratic2DAnd3D0(m1D,desc,descI,conn,connI,coords,types);
}
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic2D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc(DataArrayInt::New()),descI(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New());
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m1D=buildDescendingConnectivity(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0;
* \return a newly created DataArrayInt instance that the caller should deal with containing cell ids of converted cells.
* \sa MEDCouplingUMesh::convertLinearCellsToQuadratic.
*/
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D0(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc(DataArrayInt::New()),descI(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New());
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m1D=explode3DMeshTo1D(desc,descI,tmp2,tmp3); tmp2=0; tmp3=0;
return convertLinearCellsToQuadratic2DAnd3D0(m1D,desc,descI,conn,connI,coords,types);
}
-DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::convertLinearCellsToQuadratic3D1(DataArrayInt *&conn, DataArrayInt *&connI, DataArrayDouble *& coords, std::set<INTERP_KERNEL::NormalizedCellType>& types) const
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> desc2(DataArrayInt::New()),desc2I(DataArrayInt::New()),tmp2(DataArrayInt::New()),tmp3(DataArrayInt::New());
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> m2D=buildDescendingConnectivityGen<MinusOneSonsGeneratorBiQuadratic>(desc2,desc2I,tmp2,tmp3,MEDCouplingFastNbrer); tmp2=0; tmp3=0;
* \throw If \a this->getMeshDimension() != 2.
* \throw If \a this->getSpaceDimension() != 2.
*/
-void MEDCouplingUMesh::tessellate2D(double eps) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::tessellate2D(double eps)
{
checkFullyDefined();
if(getMeshDimension()!=2 || getSpaceDimension()!=2)
* \throw If \a this->getMeshDimension() != 1.
* \throw If \a this->getSpaceDimension() != 2.
*/
-void MEDCouplingUMesh::tessellate2DCurve(double eps) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::tessellate2DCurve(double eps)
{
checkFullyDefined();
if(getMeshDimension()!=1 || getSpaceDimension()!=2)
newConnIPtr[1]=newConnIPtr[0]+3;
}
}
- if(addCoo.empty() && ((int)newConn.size())==_nodal_connec->getNumberOfTuples())//nothing happens during tasselation : no update needed
+ if(addCoo.empty() && ((int)newConn.size())==_nodal_connec->getNumberOfTuples())//nothing happens during tessellation : no update needed
return ;
_types=types;
DataArrayInt::SetArrayIn(newConnI,_nodal_connec_index);
* and \a this->getMeshDimension() != 3.
* \throw If \a policy is not one of the four discussed above.
* \throw If the nodal connectivity of cells is not defined.
+ * \sa MEDCouplingUMesh::tetrahedrize, MEDCoupling1SGTUMesh::sortHexa8EachOther
*/
-DataArrayInt *MEDCouplingUMesh::simplexize(int policy) throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::simplexize(int policy)
{
switch(policy)
{
* \throw If the nodal connectivity of cells is not defined.
* \throw If \a this->getMeshDimension() < 1.
*/
-bool MEDCouplingUMesh::areOnlySimplexCells() const throw(INTERP_KERNEL::Exception)
+bool MEDCouplingUMesh::areOnlySimplexCells() const
{
checkFullyDefined();
int mdim=getMeshDimension();
/*!
* This method implements policy 0 of virtual method ParaMEDMEM::MEDCouplingUMesh::simplexize.
*/
-DataArrayInt *MEDCouplingUMesh::simplexizePol0() throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::simplexizePol0()
{
checkConnectivityFullyDefined();
if(getMeshDimension()!=2)
/*!
* This method implements policy 1 of virtual method ParaMEDMEM::MEDCouplingUMesh::simplexize.
*/
-DataArrayInt *MEDCouplingUMesh::simplexizePol1() throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::simplexizePol1()
{
checkConnectivityFullyDefined();
if(getMeshDimension()!=2)
/*!
* This method implements policy INTERP_KERNEL::PLANAR_FACE_5 of virtual method ParaMEDMEM::MEDCouplingUMesh::simplexize.
*/
-DataArrayInt *MEDCouplingUMesh::simplexizePlanarFace5() throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::simplexizePlanarFace5()
{
checkConnectivityFullyDefined();
if(getMeshDimension()!=3)
/*!
* This method implements policy INTERP_KERNEL::PLANAR_FACE_6 of virtual method ParaMEDMEM::MEDCouplingUMesh::simplexize.
*/
-DataArrayInt *MEDCouplingUMesh::simplexizePlanarFace6() throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::simplexizePlanarFace6()
{
checkConnectivityFullyDefined();
if(getMeshDimension()!=3)
* \param desc is descending connectivity in format specified in MEDCouplingUMesh::buildDescendingConnectivity2
* \param descIndex is descending connectivity index in format specified in MEDCouplingUMesh::buildDescendingConnectivity2
*/
-void MEDCouplingUMesh::subDivide2DMesh(const int *nodeSubdived, const int *nodeIndxSubdived, const int *desc, const int *descIndex) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::subDivide2DMesh(const int *nodeSubdived, const int *nodeIndxSubdived, const int *desc, const int *descIndex)
{
checkFullyDefined();
if(getMeshDimension()!=2)
* \throw If the coordinates array is not set.
* \throw If the nodal connectivity of cells is not defined.
*/
-void MEDCouplingUMesh::convertDegeneratedCells() throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::convertDegeneratedCells()
{
checkFullyDefined();
if(getMeshDimension()<=1)
* \ref cpp_mcumesh_are2DCellsNotCorrectlyOriented "Here is a C++ example".<br>
* \ref py_mcumesh_are2DCellsNotCorrectlyOriented "Here is a Python example".
*/
-void MEDCouplingUMesh::are2DCellsNotCorrectlyOriented(const double *vec, bool polyOnly, std::vector<int>& cells) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::are2DCellsNotCorrectlyOriented(const double *vec, bool polyOnly, std::vector<int>& cells) const
{
if(getMeshDimension()!=2 || getSpaceDimension()!=3)
throw INTERP_KERNEL::Exception("Invalid mesh to apply are2DCellsNotCorrectlyOriented on it : must be meshDim==2 and spaceDim==3 !");
* \ref cpp_mcumesh_are2DCellsNotCorrectlyOriented "Here is a C++ example".<br>
* \ref py_mcumesh_are2DCellsNotCorrectlyOriented "Here is a Python example".
*/
-void MEDCouplingUMesh::orientCorrectly2DCells(const double *vec, bool polyOnly) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::orientCorrectly2DCells(const double *vec, bool polyOnly)
{
if(getMeshDimension()!=2 || getSpaceDimension()!=3)
throw INTERP_KERNEL::Exception("Invalid mesh to apply orientCorrectly2DCells on it : must be meshDim==2 and spaceDim==3 !");
INTERP_KERNEL::NormalizedCellType type=(INTERP_KERNEL::NormalizedCellType)conn[connI[i]];
if(!polyOnly || (type==INTERP_KERNEL::NORM_POLYGON || type==INTERP_KERNEL::NORM_QPOLYG))
{
- bool isQuadratic=INTERP_KERNEL::CellModel::GetCellModel(type).isQuadratic();
+ bool isQuadratic(INTERP_KERNEL::CellModel::GetCellModel(type).isQuadratic());
if(!IsPolygonWellOriented(isQuadratic,vec,conn+connI[i]+1,conn+connI[i+1],coordsPtr))
{
isModified=true;
- std::vector<int> tmp(connI[i+1]-connI[i]-2);
- std::copy(conn+connI[i]+2,conn+connI[i+1],tmp.rbegin());
- std::copy(tmp.begin(),tmp.end(),conn+connI[i]+2);
+ if(!isQuadratic)
+ {
+ std::vector<int> tmp(connI[i+1]-connI[i]-2);
+ std::copy(conn+connI[i]+2,conn+connI[i+1],tmp.rbegin());
+ std::copy(tmp.begin(),tmp.end(),conn+connI[i]+2);
+ }
+ else
+ {
+ int sz(((int)(connI[i+1]-connI[i]-1))/2);
+ std::vector<int> tmp0(sz-1),tmp1(sz);
+ std::copy(conn+connI[i]+2,conn+connI[i]+1+sz,tmp0.rbegin());
+ std::copy(conn+connI[i]+1+sz,conn+connI[i+1],tmp1.rbegin());
+ std::copy(tmp0.begin(),tmp0.end(),conn+connI[i]+2);
+ std::copy(tmp1.begin(),tmp1.end(),conn+connI[i]+1+sz);
+ }
}
}
}
* \ref cpp_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a C++ example".<br>
* \ref py_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a Python example".
*/
-void MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented(std::vector<int>& cells) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented(std::vector<int>& cells) const
{
if(getMeshDimension()!=3 || getSpaceDimension()!=3)
throw INTERP_KERNEL::Exception("Invalid mesh to apply arePolyhedronsNotCorrectlyOriented on it : must be meshDim==3 and spaceDim==3 !");
* \ref py_mcumesh_arePolyhedronsNotCorrectlyOriented "Here is a Python example".
* \sa MEDCouplingUMesh::findAndCorrectBadOriented3DCells
*/
-void MEDCouplingUMesh::orientCorrectlyPolyhedrons() throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::orientCorrectlyPolyhedrons()
{
if(getMeshDimension()!=3 || getSpaceDimension()!=3)
throw INTERP_KERNEL::Exception("Invalid mesh to apply orientCorrectlyPolyhedrons on it : must be meshDim==3 and spaceDim==3 !");
* \ref py_mcumesh_findAndCorrectBadOriented3DExtrudedCells "Here is a Python example".
* \sa MEDCouplingUMesh::findAndCorrectBadOriented3DCells
*/
-DataArrayInt *MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells() throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells()
{
const char msg[]="check3DCellsWellOriented detection works only for 3D cells !";
if(getMeshDimension()!=3)
* \ret a newly allocated int array with one components containing cell ids renumbered to fit the convention of MED (MED file and MEDCoupling)
* \sa MEDCouplingUMesh::orientCorrectlyPolyhedrons,
*/
-DataArrayInt *MEDCouplingUMesh::findAndCorrectBadOriented3DCells() throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::findAndCorrectBadOriented3DCells()
{
if(getMeshDimension()!=3 || getSpaceDimension()!=3)
throw INTERP_KERNEL::Exception("Invalid mesh to apply findAndCorrectBadOriented3DCells on it : must be meshDim==3 and spaceDim==3 !");
* \param vec output of size at least 3 used to store the normal vector (with norm equal to Area ) of searched plane.
* \param pos output of size at least 3 used to store a point owned of searched plane.
*/
-void MEDCouplingUMesh::getFastAveragePlaneOfThis(double *vec, double *pos) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::getFastAveragePlaneOfThis(double *vec, double *pos) const
{
if(getMeshDimension()!=2 || getSpaceDimension()!=3)
throw INTERP_KERNEL::Exception("Invalid mesh to apply getFastAveragePlaneOfThis on it : must be meshDim==2 and spaceDim==3 !");
* \throw If \a this->getSpaceDimension() is neither 2 nor 3.
* \throw If \a this mesh includes cells of type different from the ones enumerated above.
*/
-MEDCouplingFieldDouble *MEDCouplingUMesh::getEdgeRatioField() const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingUMesh::getEdgeRatioField() const
{
checkCoherency();
int spaceDim=getSpaceDimension();
* \throw If \a this->getSpaceDimension() is neither 2 nor 3.
* \throw If \a this mesh includes cells of type different from the ones enumerated above.
*/
-MEDCouplingFieldDouble *MEDCouplingUMesh::getAspectRatioField() const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingUMesh::getAspectRatioField() const
{
checkCoherency();
int spaceDim=getSpaceDimension();
* \throw If \a this->getSpaceDimension() != 3.
* \throw If \a this mesh includes cells of type different from the ones enumerated above.
*/
-MEDCouplingFieldDouble *MEDCouplingUMesh::getWarpField() const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingUMesh::getWarpField() const
{
checkCoherency();
int spaceDim=getSpaceDimension();
* \throw If \a this->getSpaceDimension() != 3.
* \throw If \a this mesh includes cells of type different from the ones enumerated above.
*/
-MEDCouplingFieldDouble *MEDCouplingUMesh::getSkewField() const throw(INTERP_KERNEL::Exception)
+MEDCouplingFieldDouble *MEDCouplingUMesh::getSkewField() const
{
checkCoherency();
int spaceDim=getSpaceDimension();
/*!
* 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 * - newly created object (to be managed by the caller) \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<double>& 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<DataArrayDouble> ret(DataArrayDouble::New()); ret->alloc(nbOfCells,2*spaceDim);
+ double *bbox(ret->getPointer());
for(int i=0;i<nbOfCells*spaceDim;i++)
{
bbox[2*i]=std::numeric_limits<double>::max();
bbox[2*i+1]=-std::numeric_limits<double>::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<nbOfCells;i++)
{
int offset=connI[i]+1;
- int nbOfNodesForCell=connI[i+1]-offset;
+ int nbOfNodesForCell(connI[i+1]-offset),kk(0);
for(int j=0;j<nbOfNodesForCell;j++)
{
int nodeId=conn[offset+j];
- if(nodeId>=0)
- for(int k=0;k<spaceDim;k++)
- {
- bbox[2*spaceDim*i+2*k]=std::min(bbox[2*spaceDim*i+2*k],coordsPtr[spaceDim*nodeId+k]);
- bbox[2*spaceDim*i+2*k+1]=std::max(bbox[2*spaceDim*i+2*k+1],coordsPtr[spaceDim*nodeId+k]);
- }
+ if(nodeId>=0 && nodeId<nbOfNodes)
+ {
+ for(int k=0;k<spaceDim;k++)
+ {
+ bbox[2*spaceDim*i+2*k]=std::min(bbox[2*spaceDim*i+2*k],coordsPtr[spaceDim*nodeId+k]);
+ bbox[2*spaceDim*i+2*k+1]=std::max(bbox[2*spaceDim*i+2*k+1],coordsPtr[spaceDim*nodeId+k]);
+ }
+ kk++;
+ }
+ }
+ if(kk==0)
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::getBoundingBoxForBBTree : cell #" << i << " contains no valid nodeId !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
+ return ret.retn();
}
/// @cond INTERNAL
* This method returns in the same format as code (see MEDCouplingUMesh::checkTypeConsistencyAndContig or MEDCouplingUMesh::splitProfilePerType) how
* \a this is composed in cell types.
* The returned array is of size 3*n where n is the number of different types present in \a this.
- * For every k in [0,n] ret[3*k+2]==0 because it has no sense here.
+ * For every k in [0,n] ret[3*k+2]==-1 because it has no sense here.
* This parameter is kept only for compatibility with other methode listed above.
*/
-std::vector<int> MEDCouplingUMesh::getDistributionOfTypes() const throw(INTERP_KERNEL::Exception)
+std::vector<int> MEDCouplingUMesh::getDistributionOfTypes() const
{
checkConnectivityFullyDefined();
const int *conn=_nodal_connec->getConstPointer();
const int *work=connI;
int nbOfCells=getNumberOfCells();
std::size_t n=getAllTypes().size();
- std::vector<int> ret(3*n,0); //ret[3*k+2]==0 because it has no sense here
+ std::vector<int> ret(3*n,-1); //ret[3*k+2]==-1 because it has no sense here
std::set<INTERP_KERNEL::NormalizedCellType> types;
for(std::size_t i=0;work!=connI+nbOfCells;i++)
{
* If it exists a geometric type in \a this \b not in \a code \b no exception is thrown
* and a DataArrayInt instance is returned that the user has the responsability to deallocate.
*/
-DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const
{
if(code.empty())
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code is empty, should not !");
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code size is NOT %3 !");
std::vector<INTERP_KERNEL::NormalizedCellType> types;
int nb=0;
+ bool isNoPflUsed=true;
for(std::size_t i=0;i<n;i++)
if(std::find(types.begin(),types.end(),(INTERP_KERNEL::NormalizedCellType)code[3*i])==types.end())
{
nb+=code[3*i+1];
if(_types.find((INTERP_KERNEL::NormalizedCellType)code[3*i])==_types.end())
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : expected geo types not in this !");
+ isNoPflUsed=isNoPflUsed && (code[3*i+2]==-1);
}
if(types.size()!=n)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : code contains duplication of types in unstructured mesh !");
- if(idsPerType.empty())
+ if(isNoPflUsed)
{
if(!checkConsecutiveCellTypesAndOrder(&types[0],&types[0]+types.size()))
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : non contiguous type !");
if(types.size()==_types.size())
return 0;
}
- DataArrayInt *ret=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
ret->alloc(nb,1);
int *retPtr=ret->getPointer();
const int *connI=_nodal_connec_index->getConstPointer();
{
i=std::find_if(i,connI+nbOfCells,ParaMEDMEMImpl::ConnReader2(conn,(int)(*it)));
int offset=(int)std::distance(connI,i);
+ const int *j=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)(*it)));
+ int nbOfCellsOfCurType=(int)std::distance(i,j);
if(code[3*kk+2]==-1)
- {
- const int *j=std::find_if(i+1,connI+nbOfCells,ParaMEDMEMImpl::ConnReader(conn,(int)(*it)));
- std::size_t pos2=std::distance(i,j);
- for(std::size_t k=0;k<pos2;k++)
- *retPtr++=(int)k+offset;
- i=j;
- }
+ for(int k=0;k<nbOfCellsOfCurType;k++)
+ *retPtr++=k+offset;
else
{
- retPtr=std::transform(idsPerType[code[3*kk+2]]->getConstPointer(),idsPerType[code[3*kk+2]]->getConstPointer()+idsPerType[code[3*kk+2]]->getNbOfElems(),
- retPtr,std::bind2nd(std::plus<int>(),offset));
+ int idInIdsPerType=code[3*kk+2];
+ if(idInIdsPerType>=0 && idInIdsPerType<(int)idsPerType.size())
+ {
+ const DataArrayInt *zePfl=idsPerType[idInIdsPerType];
+ if(zePfl)
+ {
+ zePfl->checkAllocated();
+ if(zePfl->getNumberOfComponents()==1)
+ {
+ for(const int *k=zePfl->begin();k!=zePfl->end();k++,retPtr++)
+ {
+ if(*k>=0 && *k<nbOfCellsOfCurType)
+ *retPtr=(*k)+offset;
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::checkTypeConsistencyAndContig : the section " << kk << " points to the profile #" << idInIdsPerType;
+ oss << ", and this profile contains a value " << *k << " should be in [0," << nbOfCellsOfCurType << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : presence of a profile with nb of compo != 1 !");
+ }
+ else
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::checkTypeConsistencyAndContig : presence of null profile !");
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::checkTypeConsistencyAndContig : at section " << kk << " of code it points to the array #" << idInIdsPerType;
+ oss << " should be in [0," << idsPerType.size() << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
}
+ i=j;
}
- return ret;
+ return ret.retn();
}
/*!
* This vector can be empty in case of all geometric type cells are fully covered in ascending in the given input \a profile.
* \throw if \a profile has not exactly one component. It throws too, if \a profile contains some values not in [0,getNumberOfCells()) or if \a this is not fully defined
*/
-void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::splitProfilePerType(const DataArrayInt *profile, std::vector<int>& code, std::vector<DataArrayInt *>& idsInPflPerType, std::vector<DataArrayInt *>& idsPerType) const
{
if(!profile)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::splitProfilePerType : input profile is NULL !");
* The following equality should be verified 'nM1LevMesh->getMeshDimension()==this->getMeshDimension()-1'
* This method returns 5+2 elements. 'desc', 'descIndx', 'revDesc', 'revDescIndx' and 'meshnM1' behaves exactly as ParaMEDMEM::MEDCouplingUMesh::buildDescendingConnectivity except the content as described after. The returned array specifies the n-1 mesh reordered by type as MEDMEM does. 'nM1LevMeshIds' contains the ids in returned 'meshnM1'. Finally 'meshnM1Old2New' contains numbering old2new that is to say the cell #k in coarse 'nM1LevMesh' will have the number ret[k] in returned mesh 'nM1LevMesh' MEDMEM reordered.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, DataArrayInt *& nM1LevMeshIds, DataArrayInt *&meshnM1Old2New) const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::emulateMEDMEMBDC(const MEDCouplingUMesh *nM1LevMesh, DataArrayInt *desc, DataArrayInt *descIndx, DataArrayInt *&revDesc, DataArrayInt *&revDescIndx, DataArrayInt *& nM1LevMeshIds, DataArrayInt *&meshnM1Old2New) const
{
checkFullyDefined();
nM1LevMesh->checkFullyDefined();
* this array using decrRef() as it is no more needed.
* \throw If the nodal connectivity of cells is not defined.
*/
-DataArrayInt *MEDCouplingUMesh::sortCellsInMEDFileFrmt() throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::sortCellsInMEDFileFrmt()
{
checkConnectivityFullyDefined();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=getRenumArrForMEDFileFrmt();
*
* \sa MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder
*/
-bool MEDCouplingUMesh::checkConsecutiveCellTypesForMEDFileFrmt() const throw(INTERP_KERNEL::Exception)
+bool MEDCouplingUMesh::checkConsecutiveCellTypesForMEDFileFrmt() const
{
return checkConsecutiveCellTypesAndOrder(MEDMEM_ORDER,MEDMEM_ORDER+N_MEDMEM_ORDER);
}
* that tells for each cell the pos of its type in the array on type given in input parameter. The 2nd output parameter is an array with the same
* number of tuples than input type array and with one component. This 2nd output array gives type by type the number of occurence of type in 'this'.
*/
-DataArrayInt *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayInt *&nbPerType) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayInt *&nbPerType) const
{
checkConnectivityFullyDefined();
int nbOfCells=getNumberOfCells();
*
* \sa MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec, MEDCouplingUMesh::sortCellsInMEDFileFrmt.
*/
-DataArrayInt *MEDCouplingUMesh::getRenumArrForMEDFileFrmt() const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::getRenumArrForMEDFileFrmt() const
{
return getRenumArrForConsecutiveCellTypesSpec(MEDMEM_ORDER,MEDMEM_ORDER+N_MEDMEM_ORDER);
}
* The mesh after this call to MEDCouplingMesh::renumberCells will pass the test of MEDCouplingUMesh::checkConsecutiveCellTypesAndOrder with the same inputs.
* The returned array minimizes the permutations that is to say the order of cells inside same geometric type remains the same.
*/
-DataArrayInt *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::getRenumArrForConsecutiveCellTypesSpec(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd) const
{
DataArrayInt *nbPerType=0;
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmpa=getLevArrPerCellTypes(orderBg,orderEnd,nbPerType);
*/
std::vector<MEDCouplingUMesh *> MEDCouplingUMesh::splitByType() const
{
- checkFullyDefined();
+ checkConnectivityFullyDefined();
const int *conn=_nodal_connec->getConstPointer();
const int *connI=_nodal_connec_index->getConstPointer();
int nbOfCells=getNumberOfCells();
* \throw If the nodal connectivity of \a this is not fully defined.
* \throw If the internal data is not coherent.
*/
-MEDCoupling1GTUMesh *MEDCouplingUMesh::convertIntoSingleGeoTypeMesh() const throw(INTERP_KERNEL::Exception)
+MEDCoupling1GTUMesh *MEDCouplingUMesh::convertIntoSingleGeoTypeMesh() const
{
checkConnectivityFullyDefined();
if(_types.size()!=1)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertIntoSingleGeoTypeMesh : current mesh does not contain exactly one geometric type !");
INTERP_KERNEL::NormalizedCellType typ=*_types.begin();
- int typi=(int)typ;
- MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> ret=MEDCoupling1GTUMesh::New(getName(),typ);
- ret->setCoords(ret->getCoords());
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> ret=MEDCoupling1GTUMesh::New(getName().c_str(),typ);
+ ret->setCoords(getCoords());
MEDCoupling1SGTUMesh *retC=dynamic_cast<MEDCoupling1SGTUMesh *>((MEDCoupling1GTUMesh*)ret);
if(retC)
{
- int nbCells=getNumberOfCells();
- int nbNodesPerCell=retC->getNumberOfNodesPerCell();
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> connOut=DataArrayInt::New(); connOut->alloc(nbCells*nbNodesPerCell,1);
- int *outPtr=connOut->getPointer();
- const int *conn=_nodal_connec->begin();
- const int *connI=_nodal_connec_index->begin();
- nbNodesPerCell++;
- for(int i=0;i<nbCells;i++,connI++)
- {
- if(conn[connI[0]]==typi && connI[1]-connI[0]==nbNodesPerCell)
- outPtr=std::copy(conn+connI[0]+1,conn+connI[1],outPtr);
- else
- {
- std::ostringstream oss; oss << "MEDCouplingUMesh::convertIntoSingleGeoTypeMesh : there something wrong in cell #" << i << " ! The type of cell is not those expected, or the length of nodal connectivity is not those expected (" << nbNodesPerCell-1 << ") !";
- throw INTERP_KERNEL::Exception(oss.str().c_str());
- }
- }
- retC->setNodalConnectivity(connOut);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c=convertNodalConnectivityToStaticGeoTypeMesh();
+ retC->setNodalConnectivity(c);
}
else
- throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertIntoSingleGeoTypeMesh : not implemented yet for non static geometric type !");
+ {
+ MEDCoupling1DGTUMesh *retD=dynamic_cast<MEDCoupling1DGTUMesh *>((MEDCoupling1GTUMesh*)ret);
+ if(!retD)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertIntoSingleGeoTypeMesh : Internal error !");
+ DataArrayInt *c=0,*ci=0;
+ convertNodalConnectivityToDynamicGeoTypeMesh(c,ci);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cs(c),cis(ci);
+ retD->setNodalConnectivity(cs,cis);
+ }
return ret.retn();
}
+DataArrayInt *MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh() const
+{
+ checkConnectivityFullyDefined();
+ if(_types.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh : current mesh does not contain exactly one geometric type !");
+ INTERP_KERNEL::NormalizedCellType typ=*_types.begin();
+ const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(typ);
+ if(cm.isDynamic())
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh : this contains a single geo type (" << cm.getRepr() << ") but ";
+ oss << "this type is dynamic ! Only static geometric type is possible for that type ! call convertNodalConnectivityToDynamicGeoTypeMesh instead !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ int nbCells=getNumberOfCells();
+ int typi=(int)typ;
+ int nbNodesPerCell=(int)cm.getNumberOfNodes();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> connOut=DataArrayInt::New(); connOut->alloc(nbCells*nbNodesPerCell,1);
+ int *outPtr=connOut->getPointer();
+ const int *conn=_nodal_connec->begin();
+ const int *connI=_nodal_connec_index->begin();
+ nbNodesPerCell++;
+ for(int i=0;i<nbCells;i++,connI++)
+ {
+ if(conn[connI[0]]==typi && connI[1]-connI[0]==nbNodesPerCell)
+ outPtr=std::copy(conn+connI[0]+1,conn+connI[1],outPtr);
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::convertNodalConnectivityToStaticGeoTypeMesh : there something wrong in cell #" << i << " ! The type of cell is not those expected, or the length of nodal connectivity is not those expected (" << nbNodesPerCell-1 << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ return connOut.retn();
+}
+
+void MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh(DataArrayInt *&nodalConn, DataArrayInt *&nodalConnIndex) const
+{
+ static const char msg0[]="MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh : nodal connectivity in this are invalid ! Call checkCoherency2 !";
+ checkConnectivityFullyDefined();
+ if(_types.size()!=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::convertNodalConnectivityToDynamicGeoTypeMesh : current mesh does not contain exactly one geometric type !");
+ int nbCells=getNumberOfCells(),lgth=_nodal_connec->getNumberOfTuples();
+ if(lgth<nbCells)
+ throw INTERP_KERNEL::Exception(msg0);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> c(DataArrayInt::New()),ci(DataArrayInt::New());
+ c->alloc(lgth-nbCells,1); ci->alloc(nbCells+1,1);
+ int *cp(c->getPointer()),*cip(ci->getPointer());
+ const int *incp(_nodal_connec->begin()),*incip(_nodal_connec_index->begin());
+ cip[0]=0;
+ for(int i=0;i<nbCells;i++,cip++,incip++)
+ {
+ int strt(incip[0]+1),stop(incip[1]);//+1 to skip geo type
+ int delta(stop-strt);
+ if(delta>=1)
+ {
+ if((strt>=0 && strt<lgth) && (stop>=0 && stop<=lgth))
+ cp=std::copy(incp+strt,incp+stop,cp);
+ else
+ throw INTERP_KERNEL::Exception(msg0);
+ }
+ else
+ throw INTERP_KERNEL::Exception(msg0);
+ cip[1]=cip[0]+delta;
+ }
+ nodalConn=c.retn(); nodalConnIndex=ci.retn();
+}
+
/*!
* This method takes in input a vector of MEDCouplingUMesh instances lying on the same coordinates with same mesh dimensions.
* Each mesh in \b ms must be sorted by type with the same order (typically using MEDCouplingUMesh::sortCellsInMEDFileFrmt).
* This method returns a newly created DataArrayInt instance.
* This method retrieves cell ids in [ \a begin, \a end ) that have the type \a type.
*/
-DataArrayInt *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::keepCellIdsByType(INTERP_KERNEL::NormalizedCellType type, const int *begin, const int *end) const
{
checkFullyDefined();
const int *conn=_nodal_connec->getConstPointer();
* This method makes the assumption that da->getNumberOfTuples()<this->getNumberOfCells(). This method makes the assumption that ids contained in 'da'
* are in [0:getNumberOfCells())
*/
-DataArrayInt *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayInt *da) const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::convertCellArrayPerGeoType(const DataArrayInt *da) const
{
checkFullyDefined();
const int *conn=_nodal_connec->getConstPointer();
* This method returns a vector of size 'this->getNumberOfCells()'.
* This method retrieves for each cell in \a this if it is linear (false) or quadratic(true).
*/
-std::vector<bool> MEDCouplingUMesh::getQuadraticStatus() const throw(INTERP_KERNEL::Exception)
+std::vector<bool> MEDCouplingUMesh::getQuadraticStatus() const
{
int ncell=getNumberOfCells();
std::vector<bool> ret(ncell);
* \throw If \a this is not fully defined (coordinates and connectivity)
* \throw If there is presence in nodal connectivity in \a this of node ids not in [0, \c this->getNumberOfNodes() )
*/
-DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const throw(INTERP_KERNEL::Exception)
+DataArrayDouble *MEDCouplingUMesh::computeIsoBarycenterOfNodesPerCell() const
{
checkFullyDefined();
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
return ret;
}
+/*!
+ * Returns a DataArrayDouble instance giving for each cell in \a this the equation of plane given by "a*X+b*Y+c*Z+d=0".
+ * So the returned instance will have 4 components and \c this->getNumberOfCells() tuples.
+ * So this method expects that \a this has a spaceDimension equal to 3 and meshDimension equal to 2.
+ * The computation of the plane equation is done using each time the 3 first nodes of 2D cells.
+ * This method is useful to detect 2D cells in 3D space that are not coplanar.
+ *
+ * \return DataArrayDouble * - a new instance of DataArrayDouble having 4 components and a number of tuples equal to number of cells in \a this.
+ * \throw If spaceDim!=3 or meshDim!=2.
+ * \throw If connectivity of \a this is invalid.
+ * \throw If connectivity of a cell in \a this points to an invalid node.
+ */
+DataArrayDouble *MEDCouplingUMesh::computePlaneEquationOf3DFaces() const
+{
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret(DataArrayDouble::New());
+ int nbOfCells(getNumberOfCells()),nbOfNodes(getNumberOfNodes());
+ if(getSpaceDimension()!=3 || getMeshDimension()!=2)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::computePlaneEquationOf3DFaces : This method must be applied on a mesh having meshDimension equal 2 and a spaceDimension equal to 3 !");
+ ret->alloc(nbOfCells,4);
+ double *retPtr(ret->getPointer());
+ const int *nodal(_nodal_connec->begin()),*nodalI(_nodal_connec_index->begin());
+ const double *coor(_coords->begin());
+ for(int i=0;i<nbOfCells;i++,nodalI++,retPtr+=4)
+ {
+ double matrix[16]={0,0,0,1,0,0,0,1,0,0,0,1,1,1,1,0},matrix2[16];
+ if(nodalI[1]-nodalI[0]>=3)
+ {
+ for(int j=0;j<3;j++)
+ {
+ int nodeId(nodal[nodalI[0]+1+j]);
+ if(nodeId>=0 && nodeId<nbOfNodes)
+ std::copy(coor+nodeId*3,coor+(nodeId+1)*3,matrix+4*j);
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::computePlaneEquationOf3DFaces : invalid 2D cell #" << i << " ! This cell points to an invalid nodeId : " << nodeId << " !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ }
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::computePlaneEquationOf3DFaces : invalid 2D cell #" << i << " ! Must be constitued by more than 3 nodes !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ INTERP_KERNEL::inverseMatrix(matrix,4,matrix2);
+ retPtr[0]=matrix2[3]; retPtr[1]=matrix2[7]; retPtr[2]=matrix2[11]; retPtr[3]=matrix2[15];
+ }
+ return ret.retn();
+}
+
/*!
* This method expects as input a DataArrayDouble non nul instance 'da' that should be allocated. If not an exception is thrown.
*
*/
-MEDCouplingUMesh *MEDCouplingUMesh::Build0DMeshFromCoords(DataArrayDouble *da) throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::Build0DMeshFromCoords(DataArrayDouble *da)
{
if(!da)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::Build0DMeshFromCoords : instance of DataArrayDouble must be not null !");
* \throw If \a mesh1->getMeshDimension() < 0 or \a mesh2->getMeshDimension() < 0.
* \throw If \a mesh1->getMeshDimension() != \a mesh2->getMeshDimension().
*/
-MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2)
{
std::vector<const MEDCouplingUMesh *> tmp(2);
tmp[0]=const_cast<MEDCouplingUMesh *>(mesh1); tmp[1]=const_cast<MEDCouplingUMesh *>(mesh2);
* \throw If \a a[ *i* ]->getMeshDimension() < 0.
* \throw If the meshes in \a a are of different dimension (getMeshDimension()).
*/
-MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshes(std::vector<const MEDCouplingUMesh *>& a)
{
std::size_t sz=a.size();
if(sz==0)
/// @cond INTERNAL
-MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesLL(std::vector<const MEDCouplingUMesh *>& a) throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesLL(std::vector<const MEDCouplingUMesh *>& a)
{
if(a.empty())
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::MergeUMeshes : input array must be NON EMPTY !");
* \throw If \a mesh1->getMeshDimension() < 0 or \a mesh2->getMeshDimension() < 0.
* \throw If \a mesh1->getMeshDimension() != \a mesh2->getMeshDimension().
*/
-MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2) throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const MEDCouplingUMesh *mesh1, const MEDCouplingUMesh *mesh2)
{
std::vector<const MEDCouplingUMesh *> tmp(2);
tmp[0]=mesh1; tmp[1]=mesh2;
tmp->alloc(curNbOfCells,1);
std::copy(o2nPtr+offset,o2nPtr+offset+curNbOfCells,tmp->getPointer());
offset+=curNbOfCells;
- tmp->setName(meshes[i]->getName());
+ tmp->setName(meshes[i]->getName().c_str());
corr[i]=tmp;
}
return ret.retn();
* \throw If the nodal connectivity of cells is not defined in any of \a meshes.
* \throw If \a meshes are of different space dimension.
*/
-void MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords(const std::vector<MEDCouplingUMesh *>& meshes) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::PutUMeshesOnSameAggregatedCoords(const std::vector<MEDCouplingUMesh *>& meshes)
{
std::size_t sz=meshes.size();
if(sz==0 || sz==1)
* \throw If the \a meshes do not share the same node coordinates array.
* \throw If the nodal connectivity of cells is not defined in any of \a meshes.
*/
-void MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords(const std::vector<MEDCouplingUMesh *>& meshes, double eps) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::MergeNodesOnUMeshesSharingSameCoords(const std::vector<MEDCouplingUMesh *>& meshes, double eps)
{
if(meshes.empty())
return ;
* \param [in] end end of nodal connectivity of a single polyhedron cell (excluded)
* \param [out] res the result is put at the end of the vector without any alteration of the data.
*/
-void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble *coords, const int *begin, const int *end, DataArrayInt *res) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble *coords, const int *begin, const int *end, DataArrayInt *res)
{
int nbFaces=std::count(begin+1,end,-1)+1;
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> v=DataArrayDouble::New(); v->alloc(nbFaces,3);
* \param [out] v the normalized vector of size 3
* \param [out] p the pos of plane
*/
-void MEDCouplingUMesh::ComputeVecAndPtOfFace(double eps, const double *coords, const int *begin, const int *end, double *v, double *p) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::ComputeVecAndPtOfFace(double eps, const double *coords, const int *begin, const int *end, double *v, double *p)
{
std::size_t nbPoints=std::distance(begin,end);
if(nbPoints<3)
* This method tries to obtain a well oriented polyhedron.
* If the algorithm fails, an exception will be thrown.
*/
-void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::TryToCorrectPolyhedronOrientation(int *begin, int *end, const double *coords)
{
std::list< std::pair<int,int> > edgesOK,edgesFinished;
std::size_t nbOfFaces=std::count(begin,end,-1)+1;
*
* \return a newly allocated array containing the connectivity of a polygon type enum included (NORM_POLYGON in pos#0)
*/
-DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMesh() const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::buildUnionOf2DMesh() const
{
if(getMeshDimension()!=2 || getSpaceDimension()!=2)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf2DMesh : meshdimension, spacedimension must be equal to 2 !");
*
* \return a newly allocated array containing the connectivity of a polygon type enum included (NORM_POLYHED in pos#0)
*/
-DataArrayInt *MEDCouplingUMesh::buildUnionOf3DMesh() const throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::buildUnionOf3DMesh() const
{
if(getMeshDimension()!=3 || getSpaceDimension()!=3)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::buildUnionOf3DMesh : meshdimension, spacedimension must be equal to 2 !");
* This method put in zip format into parameter 'zipFrmt' in full interlace mode.
* This format is often asked by INTERP_KERNEL algorithms to avoid many indirections into coordinates array.
*/
-void MEDCouplingUMesh::FillInCompact3DMode(int spaceDim, int nbOfNodesInCell, const int *conn, const double *coo, double *zipFrmt) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::FillInCompact3DMode(int spaceDim, int nbOfNodesInCell, const int *conn, const double *coo, double *zipFrmt)
{
double *w=zipFrmt;
if(spaceDim==3)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::FillInCompact3DMode : Invalid spaceDim specified : must be 2 or 3 !");
}
-void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::writeVTKLL(std::ostream& ofs, const std::string& cellData, const std::string& pointData, DataArrayByte *byteData) const
{
int nbOfCells=getNumberOfCells();
if(nbOfCells<=0)
ofs << " </CellData>\n";
ofs << " <Points>\n";
if(getSpaceDimension()==3)
- _coords->writeVTK(ofs,8,"Points");
+ _coords->writeVTK(ofs,8,"Points",byteData);
else
{
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo=_coords->changeNbOfComponents(3,0.);
- coo->writeVTK(ofs,8,"Points");
+ coo->writeVTK(ofs,8,"Points",byteData);
}
ofs << " </Points>\n";
ofs << " <Cells>\n";
}
}
types->transformWithIndArr(PARAMEDMEM2VTKTYPETRADUCER,PARAMEDMEM2VTKTYPETRADUCER+INTERP_KERNEL::NORM_MAXTYPE);
- types->writeVTK(ofs,8,"UInt8","types");
- offsets->writeVTK(ofs,8,"Int32","offsets");
+ types->writeVTK(ofs,8,"UInt8","types",byteData);
+ offsets->writeVTK(ofs,8,"Int32","offsets",byteData);
if(szFaceOffsets!=0)
{//presence of Polyhedra
connectivity->reAlloc(szConn);
- faceoffsets->writeVTK(ofs,8,"Int32","faceoffsets");
+ faceoffsets->writeVTK(ofs,8,"Int32","faceoffsets",byteData);
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> faces=DataArrayInt::New(); faces->alloc(szFaceOffsets,1);
w1=faces->getPointer();
for(int i=0;i<nbOfCells;i++)
w6=w5+1;
}
}
- faces->writeVTK(ofs,8,"Int32","faces");
+ faces->writeVTK(ofs,8,"Int32","faces",byteData);
}
- connectivity->writeVTK(ofs,8,"Int32","connectivity");
+ connectivity->writeVTK(ofs,8,"Int32","connectivity",byteData);
ofs << " </Cells>\n";
ofs << " </Piece>\n";
ofs << " </" << getVTKDataSetType() << ">\n";
}
-void MEDCouplingUMesh::reprQuickOverview(std::ostream& stream) const throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::reprQuickOverview(std::ostream& stream) const
{
stream << "MEDCouplingUMesh C++ instance at " << this << ". Name : \"" << getName() << "\".";
if(_mesh_dim==-2)
stream << std::endl << "Number of cells : " << lgth-1 << ".";
}
-std::string MEDCouplingUMesh::getVTKDataSetType() const throw(INTERP_KERNEL::Exception)
+std::string MEDCouplingUMesh::getVTKDataSetType() const
{
return std::string("UnstructuredGrid");
}
* \throw If the nodal connectivity of cells is not defined in any of the meshes.
* \throw If any of the meshes is not a 2D mesh in 2D space.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, DataArrayInt *&cellNb1, DataArrayInt *&cellNb2) throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::Intersect2DMeshes(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, double eps, DataArrayInt *&cellNb1, DataArrayInt *&cellNb2)
{
m1->checkFullyDefined();
m2->checkFullyDefined();
std::vector<double>& addCoordsQuadratic, std::vector<int>& cr, std::vector<int>& crI, std::vector<int>& cNb1, std::vector<int>& cNb2)
{
static const int SPACEDIM=2;
- std::vector<double> bbox1,bbox2;
const double *coo1=m1->getCoords()->getConstPointer();
const int *conn1=m1->getNodalConnectivity()->getConstPointer();
const int *connI1=m1->getNodalConnectivityIndex()->getConstPointer();
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<SPACEDIM,int> myTree(&bbox2[0],0,0,m2->getNumberOfCells(),eps);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> bbox1Arr(m1->getBoundingBoxForBBTree()),bbox2Arr(m2->getBoundingBoxForBBTree());
+ const double *bbox1(bbox1Arr->begin()),*bbox2(bbox2Arr->begin());
+ BBTree<SPACEDIM,int> myTree(bbox2,0,0,m2->getNumberOfCells(),eps);
int ncell1=m1->getNumberOfCells();
crI.push_back(0);
for(int i=0;i<ncell1;i++)
{
std::vector<int> candidates2;
- myTree.getIntersectingElems(&bbox1[i*2*SPACEDIM],candidates2);
+ myTree.getIntersectingElems(bbox1+i*2*SPACEDIM,candidates2);
std::map<INTERP_KERNEL::Node *,int> mapp;
std::map<int,INTERP_KERNEL::Node *> mappRev;
INTERP_KERNEL::QuadraticPolygon pol1;
MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> dd9(m1Desc),dd10(m2Desc);
const int *c1=m1Desc->getNodalConnectivity()->getConstPointer();
const int *ci1=m1Desc->getNodalConnectivityIndex()->getConstPointer();
- std::vector<double> bbox1,bbox2;
- m1Desc->getBoundingBoxForBBTree(bbox1);
- m2Desc->getBoundingBoxForBBTree(bbox2);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> 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<SPACEDIM,int> myTree(&bbox2[0],0,0,m2Desc->getNumberOfCells(),-eps);
+ BBTree<SPACEDIM,int> myTree(bbox2,0,0,m2Desc->getNumberOfCells(),-eps);
std::vector<int> candidates1(1);
int offset1=m1->getNumberOfNodes();
int offset2=offset1+m2->getNumberOfNodes();
for(int i=0;i<ncell1;i++)
{
std::vector<int> candidates2;
- myTree.getIntersectingElems(&bbox1[i*2*SPACEDIM],candidates2);
+ myTree.getIntersectingElems(bbox1+i*2*SPACEDIM,candidates2);
if(!candidates2.empty())
{
std::map<INTERP_KERNEL::Node *,int> map1,map2;
INTERP_KERNEL::QuadraticPolygon *pol2=MEDCouplingUMeshBuildQPFromMesh(m2Desc,candidates2,map2);
candidates1[0]=i;
INTERP_KERNEL::QuadraticPolygon *pol1=MEDCouplingUMeshBuildQPFromMesh(m1Desc,candidates1,map1);
+ // this following part is to avoid that a some remove nodes (for example due to a merge between pol1 and pol2) can be replaced by a newlt created one
+ // This trick garanties that Node * are discriminant
+ std::set<INTERP_KERNEL::Node *> nodes;
+ pol1->getAllNodes(nodes); pol2->getAllNodes(nodes);
+ std::size_t szz(nodes.size());
+ std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Node> > nodesSafe(szz);
+ std::set<INTERP_KERNEL::Node *>::const_iterator itt(nodes.begin());
+ for(std::size_t iii=0;iii<szz;iii++,itt++)
+ { (*itt)->incrRef(); nodesSafe[iii]=*itt; }
+ // end of protection
pol1->splitAbs(*pol2,map1,map2,offset1,offset2,candidates2,intersectEdge1[i],i,colinear2,subDiv2,addCoo);
delete pol2;
delete pol1;
* \param m2 is expected to be a mesh of meshDimension equal to 1 and spaceDim equal to 2. No check of that is performed by this method.
* \param addCoo input parameter with additionnal nodes linked to intersection of the 2 meshes.
*/
-void MEDCouplingUMesh::BuildIntersectEdges(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, const std::vector<double>& addCoo, const std::vector< std::vector<int> >& subDiv, std::vector< std::vector<int> >& intersectEdge) throw(INTERP_KERNEL::Exception)
+void MEDCouplingUMesh::BuildIntersectEdges(const MEDCouplingUMesh *m1, const MEDCouplingUMesh *m2, const std::vector<double>& addCoo, const std::vector< std::vector<int> >& subDiv, std::vector< std::vector<int> >& intersectEdge)
{
int offset1=m1->getNumberOfNodes();
int ncell=m2->getNumberOfCells();
*
* \return false if the input connectivity represents already the convex hull, true if the input cell needs to be reordered.
*/
-bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, const int *nodalConnBg, const int *nodalConnEnd, DataArrayInt *nodalConnecOut) throw(INTERP_KERNEL::Exception)
+bool MEDCouplingUMesh::BuildConvexEnvelopOf2DCellJarvis(const double *coords, const int *nodalConnBg, const int *nodalConnEnd, DataArrayInt *nodalConnecOut)
{
std::size_t sz=std::distance(nodalConnBg,nodalConnEnd);
if(sz>=4)
* \param [in] offsetForRemoval (by default 0) offset so that for each i in [0,arrIndx->getNumberOfTuples()-1) removal process will be performed in the following range [arr+arrIndx[i]+offsetForRemoval,arr+arr[i+1])
* \return true if \b arr and \b arrIndx have been modified, false if not.
*/
-bool MEDCouplingUMesh::RemoveIdsFromIndexedArrays(const int *idsToRemoveBg, const int *idsToRemoveEnd, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval) throw(INTERP_KERNEL::Exception)
+bool MEDCouplingUMesh::RemoveIdsFromIndexedArrays(const int *idsToRemoveBg, const int *idsToRemoveEnd, DataArrayInt *arr, DataArrayInt *arrIndx, int offsetForRemoval)
{
if(!arrIndx || !arr)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::RemoveIdsFromIndexedArrays : some input arrays are empty !");
* \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
* \param [out] arrOut the resulting array
* \param [out] arrIndexOut the index array of the resulting array \b arrOut
+ * \sa MEDCouplingUMesh::ExtractFromIndexedArrays2
*/
void MEDCouplingUMesh::ExtractFromIndexedArrays(const int *idsOfSelectBg, const int *idsOfSelectEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut) throw(INTERP_KERNEL::Exception)
{
if(!arrIn || !arrIndxIn)
throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : input pointer is NULL !");
+ arrIn->checkAllocated(); arrIndxIn->checkAllocated();
+ if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : input arrays must have exactly one component !");
std::size_t sz=std::distance(idsOfSelectBg,idsOfSelectEnd);
const int *arrInPtr=arrIn->getConstPointer();
const int *arrIndxPtr=arrIndxIn->getConstPointer();
int nbOfGrps=arrIndxIn->getNumberOfTuples()-1;
+ if(nbOfGrps<0)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !");
int maxSizeOfArr=arrIn->getNumberOfTuples();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arro=DataArrayInt::New();
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arrIo=DataArrayInt::New();
arrIndexOut=arrIo.retn();
}
+/*!
+ * This method works on a pair input (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
+ * This method returns the result of the extraction ( specified by a set of ids with a slice given by \a idsOfSelectStart, \a idsOfSelectStop and \a idsOfSelectStep ).
+ * The selection of extraction is done standardly in new2old format.
+ * This method returns indexed arrays using 2 arrays (arrOut,arrIndexOut).
+ *
+ * \param [in] idsOfSelectBg begin of set of ids of the input extraction (included)
+ * \param [in] idsOfSelectEnd end of set of ids of the input extraction (excluded)
+ * \param [in] arrIn arr origin array from which the extraction will be done.
+ * \param [in] arrIndxIn is the input index array allowing to walk into \b arrIn
+ * \param [out] arrOut the resulting array
+ * \param [out] arrIndexOut the index array of the resulting array \b arrOut
+ * \sa MEDCouplingUMesh::ExtractFromIndexedArrays
+ */
+void MEDCouplingUMesh::ExtractFromIndexedArrays2(int idsOfSelectStart, int idsOfSelectStop, int idsOfSelectStep, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn,
+ DataArrayInt* &arrOut, DataArrayInt* &arrIndexOut) throw(INTERP_KERNEL::Exception)
+{
+ if(!arrIn || !arrIndxIn)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays2 : input pointer is NULL !");
+ arrIn->checkAllocated(); arrIndxIn->checkAllocated();
+ if(arrIn->getNumberOfComponents()!=1 || arrIndxIn->getNumberOfComponents()!=1)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays2 : input arrays must have exactly one component !");
+ int sz=DataArrayInt::GetNumberOfItemGivenBESRelative(idsOfSelectStart,idsOfSelectStop,idsOfSelectStep,"MEDCouplingUMesh::ExtractFromIndexedArrays2 : Input slice ");
+ const int *arrInPtr=arrIn->getConstPointer();
+ const int *arrIndxPtr=arrIndxIn->getConstPointer();
+ int nbOfGrps=arrIndxIn->getNumberOfTuples()-1;
+ if(nbOfGrps<0)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::ExtractFromIndexedArrays2 : The format of \"arrIndxIn\" is invalid ! Its nb of tuples should be >=1 !");
+ int maxSizeOfArr=arrIn->getNumberOfTuples();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arro=DataArrayInt::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arrIo=DataArrayInt::New();
+ arrIo->alloc((int)(sz+1),1);
+ int idsIt=idsOfSelectStart;
+ int *work=arrIo->getPointer();
+ *work++=0;
+ int lgth=0;
+ for(int i=0;i<sz;i++,work++,idsIt+=idsOfSelectStep)
+ {
+ if(idsIt>=0 && idsIt<nbOfGrps)
+ lgth+=arrIndxPtr[idsIt+1]-arrIndxPtr[idsIt];
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays2 : id located on pos #" << i << " value is " << idsIt << " ! Must be in [0," << nbOfGrps << ") !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ if(lgth>=work[-1])
+ *work=lgth;
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays2 : id located on pos #" << i << " value is " << idsIt << " and at this pos arrIndxIn[" << idsIt;
+ oss << "+1]-arrIndxIn[" << idsIt << "] < 0 ! The input index array is bugged !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ arro->alloc(lgth,1);
+ work=arro->getPointer();
+ idsIt=idsOfSelectStart;
+ for(int i=0;i<sz;i++,idsIt+=idsOfSelectStep)
+ {
+ if(arrIndxPtr[idsIt]>=0 && arrIndxPtr[idsIt+1]<=maxSizeOfArr)
+ work=std::copy(arrInPtr+arrIndxPtr[idsIt],arrInPtr+arrIndxPtr[idsIt+1],work);
+ else
+ {
+ std::ostringstream oss; oss << "MEDCouplingUMesh::ExtractFromIndexedArrays2 : id located on pos #" << i << " value is " << idsIt << " arrIndx[" << idsIt << "] must be >= 0 and arrIndx[";
+ oss << idsIt << "+1] <= " << maxSizeOfArr << " (the size of arrIn)!";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ }
+ arrOut=arro.retn();
+ arrIndexOut=arrIo.retn();
+}
+
/*!
* This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
* This method builds an output pair (\b arrOut,\b arrIndexOut) that is a copy from \b arrIn for all cell ids \b not \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) and for
* \return a newly allocated DataArray that stores all ids fetched by the gradually spread process.
* \sa MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed, MEDCouplingUMesh::partitionBySpreadZone
*/
-DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGradually(const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn) throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGradually(const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn)
{
int seed=0,nbOfDepthPeelingPerformed=0;
return ComputeSpreadZoneGraduallyFromSeed(&seed,&seed+1,arrIn,arrIndxIn,-1,nbOfDepthPeelingPerformed);
* \return a newly allocated DataArray that stores all ids fetched by the gradually spread process.
* \sa MEDCouplingUMesh::partitionBySpreadZone
*/
-DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed) throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeed(const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed)
{
nbOfDepthPeelingPerformed=0;
if(!arrIndxIn)
return ComputeSpreadZoneGraduallyFromSeedAlg(fetched,seedBg,seedEnd,arrIn,arrIndxIn,nbOfDepthPeeling,nbOfDepthPeelingPerformed);
}
-DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg(std::vector<bool>& fetched, const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed) throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::ComputeSpreadZoneGraduallyFromSeedAlg(std::vector<bool>& fetched, const int *seedBg, const int *seedEnd, const DataArrayInt *arrIn, const DataArrayInt *arrIndxIn, int nbOfDepthPeeling, int& nbOfDepthPeelingPerformed)
{
nbOfDepthPeelingPerformed=0;
if(!seedBg || !seedEnd || !arrIn || !arrIndxIn)
*
* \return a newly allocated mesh lying on the same coords than \b this with same meshdimension than \b this.
*/
-MEDCouplingUMesh *MEDCouplingUMesh::buildSpreadZonesWithPoly() const throw(INTERP_KERNEL::Exception)
+MEDCouplingUMesh *MEDCouplingUMesh::buildSpreadZonesWithPoly() const
{
checkFullyDefined();
int mdim=getMeshDimension();
std::vector<DataArrayInt *> partition=partitionBySpreadZone();
std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > partitionAuto; partitionAuto.reserve(partition.size());
std::copy(partition.begin(),partition.end(),std::back_insert_iterator<std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > >(partitionAuto));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName(),mdim);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> ret=MEDCouplingUMesh::New(getName().c_str(),mdim);
ret->setCoords(getCoords());
ret->allocateCells((int)partition.size());
//
* This method only needs a well defined connectivity. Coordinates are not considered here.
* This method returns a vector of \b newly allocated arrays that the caller has to deal with.
*/
-std::vector<DataArrayInt *> MEDCouplingUMesh::partitionBySpreadZone() const throw(INTERP_KERNEL::Exception)
+std::vector<DataArrayInt *> MEDCouplingUMesh::partitionBySpreadZone() const
{
- //#if 0
int nbOfCellsCur=getNumberOfCells();
std::vector<DataArrayInt *> ret;
if(nbOfCellsCur<=0)
for(std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> >::iterator it=ret2.begin();it!=ret2.end();it++)
ret.push_back((*it).retn());
return ret;
- //#endif
-#if 0
- int nbOfCellsCur=getNumberOfCells();
- DataArrayInt *neigh=0,*neighI=0;
- computeNeighborsOfCells(neigh,neighI);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> neighAuto(neigh),neighIAuto(neighI);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ids=DataArrayInt::New(); ids->alloc(nbOfCellsCur,1); ids->iota();
- std::vector<DataArrayInt *> ret;
- std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > ret2;
- while(nbOfCellsCur>0)
- {
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp=MEDCouplingUMesh::ComputeSpreadZoneGradually(neighAuto,neighIAuto);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp3=tmp->buildComplement(nbOfCellsCur);
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp2=ids->selectByTupleId(tmp->begin(),tmp->end());
- ret2.push_back(tmp2); ret.push_back(tmp2);
- nbOfCellsCur=tmp3->getNumberOfTuples();
- if(nbOfCellsCur>0)
- {
- ids=ids->selectByTupleId(tmp3->begin(),tmp3->end());
- MEDCouplingUMesh::ExtractFromIndexedArrays(tmp3->begin(),tmp3->end(),neighAuto,neighIAuto,neigh,neighI);
- neighAuto=neigh;
- neighIAuto=neighI;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> renum=tmp3->invertArrayN2O2O2N(nbOfCellsCur+tmp->getNumberOfTuples());
- neighAuto->transformWithIndArr(renum->begin(),renum->end());
- }
- }
- for(std::vector<DataArrayInt *>::const_iterator it=ret.begin();it!=ret.end();it++)
- (*it)->incrRef();
- return ret;
-#endif
}
/*!
* \return a newly allocated DataArrayInt to be managed by the caller.
* \throw In case of \a code has not the right format (typically of size 3*n)
*/
-DataArrayInt *MEDCouplingUMesh::ComputeRangesFromTypeDistribution(const std::vector<int>& code) throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDCouplingUMesh::ComputeRangesFromTypeDistribution(const std::vector<int>& code)
{
MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret=DataArrayInt::New();
std::size_t nb=code.size()/3;
return ret.retn();
}
+/*!
+ * This method expects that \a this a 3D mesh (spaceDim=3 and meshDim=3) with all coordinates and connectivities set.
+ * All cells in \a this are expected to be linear 3D cells.
+ * This method will split **all** 3D cells in \a this into INTERP_KERNEL::NORM_TETRA4 cells and put them in the returned mesh.
+ * It leads to an increase to number of cells.
+ * This method contrary to MEDCouplingUMesh::simplexize can append coordinates in \a this to perform its work.
+ * The \a nbOfAdditionalPoints returned value informs about it. If > 0, the coordinates array in returned mesh will have \a nbOfAdditionalPoints
+ * more tuples (nodes) than in \a this. Anyway, all the nodes in \a this (with the same order) will be in the returned mesh.
+ *
+ * \param [in] policy - the policy of splitting that must be in (PLANAR_FACE_5, PLANAR_FACE_6, GENERAL_24, GENERAL_48). The policy will be used only for INTERP_KERNEL::NORM_HEXA8 cells.
+ * For all other cells, the splitting policy will be ignored.
+ * \param [out] nbOfAdditionalPoints - number of nodes added to \c this->_coords. If > 0 a new coordinates object will be constructed result of the aggregation of the old one and the new points added.
+ * \param [out] n2oCells - A new instance of DataArrayInt holding, for each new cell,
+ * an id of old cell producing it. The caller is to delete this array using
+ * decrRef() as it is no more needed.
+ * \return MEDCoupling1SGTUMesh * - the mesh containing only INTERP_KERNEL::NORM_TETRA4 cells.
+ *
+ * \warning This method operates on each cells in this independantly ! So it can leads to non conform mesh in returned value ! If you expect to have a conform mesh in output
+ * the policy PLANAR_FACE_6 should be used on a mesh sorted with MEDCoupling1SGTUMesh::sortHexa8EachOther.
+ *
+ * \throw If \a this is not a 3D mesh (spaceDim==3 and meshDim==3).
+ * \throw If \a this is not fully constituted with linear 3D cells.
+ * \sa MEDCouplingUMesh::simplexize, MEDCoupling1SGTUMesh::sortHexa8EachOther
+ */
+MEDCoupling1SGTUMesh *MEDCouplingUMesh::tetrahedrize(int policy, DataArrayInt *& n2oCells, int& nbOfAdditionalPoints) const
+{
+ INTERP_KERNEL::SplittingPolicy pol((INTERP_KERNEL::SplittingPolicy)policy);
+ checkConnectivityFullyDefined();
+ if(getMeshDimension()!=3 || getSpaceDimension()!=3)
+ throw INTERP_KERNEL::Exception("MEDCouplingUMesh::tetrahedrize : only available for mesh with meshdim == 3 and spacedim == 3 !");
+ int nbOfCells(getNumberOfCells()),nbNodes(getNumberOfNodes());
+ MEDCouplingAutoRefCountObjectPtr<MEDCoupling1SGTUMesh> ret0(MEDCoupling1SGTUMesh::New(getName().c_str(),INTERP_KERNEL::NORM_TETRA4));
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> ret(DataArrayInt::New()); ret->alloc(nbOfCells,1);
+ int *retPt(ret->getPointer());
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> newConn(DataArrayInt::New()); newConn->alloc(0,1);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> addPts(DataArrayDouble::New()); addPts->alloc(0,1);
+ const int *oldc(_nodal_connec->begin());
+ const int *oldci(_nodal_connec_index->begin());
+ const double *coords(_coords->begin());
+ for(int i=0;i<nbOfCells;i++,oldci++,retPt++)
+ {
+ std::vector<int> a; std::vector<double> b;
+ INTERP_KERNEL::SplitIntoTetras(pol,(INTERP_KERNEL::NormalizedCellType)oldc[oldci[0]],oldc+oldci[0]+1,oldc+oldci[1],coords,a,b);
+ std::size_t nbOfTet(a.size()/4); *retPt=(int)nbOfTet;
+ const int *aa(&a[0]);
+ if(!b.empty())
+ {
+ for(std::vector<int>::iterator it=a.begin();it!=a.end();it++)
+ if(*it<0)
+ *it=(-(*(it))-1+nbNodes);
+ addPts->insertAtTheEnd(b.begin(),b.end());
+ nbNodes+=(int)b.size()/3;
+ }
+ for(std::size_t j=0;j<nbOfTet;j++,aa+=4)
+ newConn->insertAtTheEnd(aa,aa+4);
+ }
+ if(!addPts->empty())
+ {
+ addPts->rearrange(3);
+ nbOfAdditionalPoints=addPts->getNumberOfTuples();
+ addPts=DataArrayDouble::Aggregate(getCoords(),addPts);
+ ret0->setCoords(addPts);
+ }
+ else
+ {
+ nbOfAdditionalPoints=0;
+ ret0->setCoords(getCoords());
+ }
+ ret0->setNodalConnectivity(newConn);
+ //
+ ret->computeOffsets2();
+ n2oCells=ret->buildExplicitArrOfSliceOnScaledArr(0,nbOfCells,1);
+ return ret0.retn();
+}
+
MEDCouplingUMeshCellIterator::MEDCouplingUMeshCellIterator(MEDCouplingUMesh *mesh):_mesh(mesh),_cell(new MEDCouplingUMeshCell(mesh)),
_own_cell(true),_cell_id(-1),_nb_cell(0)
{