}
/*!
- * Allocates memory to store an estimation of the given number of cells. The closer is the estimation to the number of cells effectively inserted,
- * the less will the library need to reallocate memory. If the number of cells to be inserted is not known simply put 0 to this parameter.
- * If a nodal connectivity previouly existed before the call of this method, it will be reset.
+ * Allocates memory to store an estimation of the given number of cells.
+ * The closer the estimation to the number of cells effectively inserted, the less need the library requires
+ * to reallocate memory. If the number of cells to be inserted is not known simply assign 0 to this parameter.
+ * If a nodal connectivity previously existed before the call of this method, it will be reset.
*
* \param [in] nbOfCells - estimation of the number of cell \a this mesh will contain.
*
{
int *neighIdx(neighborsIdx->getPointer());
for(std::vector< std::set<int> >::const_iterator it=st0.begin();it!=st0.end();it++,neighIdx++)
- neighIdx[1]=neighIdx[0]+(*it).size()-1;
+ {
+ if ((*it).empty())
+ neighIdx[1]=neighIdx[0];
+ else
+ neighIdx[1]=neighIdx[0]+(*it).size()-1;
+ }
}
neighbors=DataArrayInt::New(); neighbors->alloc(neighborsIdx->back(),1);
{
connINew->alloc(nbOfCells+1,1);
int *connINewPtr=connINew->getPointer(); *connINewPtr++=0;
MCAuto<DataArrayInt> connNew=DataArrayInt::New(); connNew->alloc(0,1);
+ MCAuto<DataArrayInt> E_Fi(DataArrayInt::New()), E_F(DataArrayInt::New()), F_Ei(DataArrayInt::New()), F_E(DataArrayInt::New());
+ MCAuto<MEDCouplingUMesh> m_faces(buildDescendingConnectivity(E_F, E_Fi, F_E, F_Ei));
bool changed=false;
for(int i=0;i<nbOfCells;i++,connINewPtr++)
{
if(conn[index[i]]==(int)INTERP_KERNEL::NORM_POLYHED)
{
- SimplifyPolyhedronCell(eps,coords,conn+index[i],conn+index[i+1],connNew);
+ SimplifyPolyhedronCell(eps,coords, i,connNew, m_faces, E_Fi, E_F, F_Ei, F_E);
changed=true;
}
else
/*!
* Build a sub part of \b this lying or not on the same coordinates than \b this (regarding value of \b keepCoords).
* By default coordinates are kept. This method is close to MEDCouplingUMesh::buildPartOfMySelf except that here input
- * cellIds is not given explicitely but by a range python like.
+ * cellIds is not given explicitly but by a range python like.
*
* \param start
* \param end
* This method expects that \b this and \b otherDimM1OnSameCoords share the same coordinates array.
* otherDimM1OnSameCoords->getMeshDimension() is expected to be equal to this->getMeshDimension()-1.
* This method searches for nodes needed to be duplicated. These nodes are nodes fetched by \b otherDimM1OnSameCoords which are not part of the boundary of \b otherDimM1OnSameCoords.
- * If a node is in the boundary of \b this \b and in the boundary of \b otherDimM1OnSameCoords this node is considerd as needed to be duplicated.
+ * If a node is in the boundary of \b this \b and in the boundary of \b otherDimM1OnSameCoords this node is considered as needed to be duplicated.
* When the set of node ids \b nodeIdsToDuplicate is computed, cell ids in \b this is searched so that their connectivity includes at least 1 node in \b nodeIdsToDuplicate.
*
* \param [in] otherDimM1OnSameCoords a mesh lying on the same coords than \b this and with a mesh dimension equal to those of \b this minus 1. WARNING this input
* This method operates a modification of the connectivity and coords in \b this.
* Every time that a node id in [ \b nodeIdsToDuplicateBg, \b nodeIdsToDuplicateEnd ) will append in nodal connectivity of \b this
* its ids will be modified to id this->getNumberOfNodes()+std::distance(nodeIdsToDuplicateBg,std::find(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd,id)).
- * More explicitely the renumber array in nodes is not explicitely given in old2new to avoid to build a big array of renumbering whereas typically few node ids needs to be
+ * More explicitly the renumber array in nodes is not explicitly given in old2new to avoid to build a big array of renumbering whereas typically few node ids needs to be
* renumbered. The node id nodeIdsToDuplicateBg[0] will have id this->getNumberOfNodes()+0, node id nodeIdsToDuplicateBg[1] will have id this->getNumberOfNodes()+1,
* node id nodeIdsToDuplicateBg[2] will have id this->getNumberOfNodes()+2...
*
* Coordinates are \b NOT considered here and will remain unchanged by this method. this->_coords can ever been null for the needs of this method.
* Every time that a node id in [ \b nodeIdsToDuplicateBg, \b nodeIdsToDuplicateEnd ) will append in nodal connectivity of \b this
* its ids will be modified to id offset+std::distance(nodeIdsToDuplicateBg,std::find(nodeIdsToDuplicateBg,nodeIdsToDuplicateEnd,id)).
- * More explicitely the renumber array in nodes is not explicitely given in old2new to avoid to build a big array of renumbering whereas typically few node ids needs to be
+ * More explicitly the renumber array in nodes is not explicitly given in old2new to avoid to build a big array of renumbering whereas typically few node ids needs to be
* renumbered. The node id nodeIdsToDuplicateBg[0] will have id offset+0, node id nodeIdsToDuplicateBg[1] will have id offset+1,
* node id nodeIdsToDuplicateBg[2] will have id offset+2...
*
}
/*!
- * This method builds a newly allocated instance (with the same name than \a this) that the caller has the responsability to deal with.
+ * This method builds a newly allocated instance (with the same name than \a this) that the caller has the responsibility to deal with.
* This method returns an instance with all arrays allocated (connectivity, connectivity index, coordinates)
* but with length of these arrays set to 0. It allows to define an "empty" mesh (with nor cells nor nodes but compliant with
* some algos).
/*!
* Returns types of cells of the specified part of \a this mesh.
- * This method avoids computing sub-mesh explicitely to get its types.
+ * This method avoids computing sub-mesh explicitly to get its types.
* \param [in] begin - an array of cell ids of interest.
* \param [in] end - the end of \a begin, i.e. a pointer to its (last+1)-th element.
* \return std::set<INTERP_KERNEL::NormalizedCellType> - a set of enumeration items
* If not an exception will thrown. If this is an empty mesh with no cell an exception will be thrown too.
* No consideration of coordinate is done by this method.
* 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 MEDCoupling::MEDCouplingUMesh::mergeNodes could be usefull.
+ * If not false is returned. In case that false is returned a call to MEDCoupling::MEDCouplingUMesh::mergeNodes could be useful.
*/
bool MEDCouplingUMesh::isContiguous1D() const
{
* \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]==-1 because it has no sense here.
- * This parameter is kept only for compatibility with other methode listed above.
+ * This parameter is kept only for compatibility with other method listed above.
*/
std::vector<int> MEDCouplingUMesh::getDistributionOfTypes() const
{
*
* If all geometric types in \a code are exactly those in \a this null pointer is returned.
* 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.
+ * and a DataArrayInt instance is returned that the user has the responsibility to deallocate.
*/
DataArrayInt *MEDCouplingUMesh::checkTypeConsistencyAndContig(const std::vector<int>& code, const std::vector<const DataArrayInt *>& idsPerType) const
{
/*!
* This method returns 2 newly allocated DataArrayInt instances. The first is an array of size 'this->getNumberOfCells()' with one component,
* 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'.
+ * number of tuples than input type array and with one component. This 2nd output array gives type by type the number of occurrence of type in 'this'.
*/
DataArrayInt *MEDCouplingUMesh::getLevArrPerCellTypes(const INTERP_KERNEL::NormalizedCellType *orderBg, const INTERP_KERNEL::NormalizedCellType *orderEnd, DataArrayInt *&nbPerType) const
{
/*!
* 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 is particulary useful for MED file interaction. It allows to aggregate several meshes and keeping the type sorting
+ * This method is particularly useful for MED file interaction. It allows to aggregate several meshes and keeping the type sorting
* and the track of the permutation by chunk of same geotype cells to retrieve it. The traditional formats old2new and new2old
* are not used here to avoid the build of big permutation array.
*
* Makes all given meshes share the nodal connectivity array. The common connectivity
* array is created by concatenating the connectivity arrays of all given meshes. All
* the given meshes must be of the same space dimension but dimension of cells **can
- * differ**. This method is particulary useful in MEDLoader context to build a \ref
+ * differ**. This method is particularly useful in MEDLoader context to build a \ref
* MEDCoupling::MEDFileUMesh "MEDFileUMesh" instance that expects that underlying
* MEDCouplingUMesh'es of different dimension share the same nodal connectivity array.
* \param [in,out] meshes - a vector of meshes to update.
/*!
* Merges nodes coincident with a given precision within all given meshes that share
* the nodal connectivity array. The given meshes **can be of different** mesh
- * dimension. This method is particulary useful in MEDLoader context to build a \ref
+ * dimension. This method is particularly useful in MEDLoader context to build a \ref
* MEDCoupling::MEDFileUMesh "MEDFileUMesh" instance that expects that underlying
* MEDCouplingUMesh'es of different dimension share the same nodal connectivity array.
* \param [in,out] meshes - a vector of meshes to update.
* \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)
+void MEDCouplingUMesh::SimplifyPolyhedronCell(double eps, const DataArrayDouble *coords, int index, DataArrayInt *res, MEDCouplingUMesh *faces,
+ DataArrayInt *E_Fi, DataArrayInt *E_F, DataArrayInt *F_Ei, DataArrayInt *F_E)
{
- int nbFaces=std::count(begin+1,end,-1)+1;
+ int nbFaces = E_Fi->getIJ(index + 1, 0) - E_Fi->getIJ(index, 0);
MCAuto<DataArrayDouble> v=DataArrayDouble::New(); v->alloc(nbFaces,3);
double *vPtr=v->getPointer();
- MCAuto<DataArrayDouble> p=DataArrayDouble::New(); p->alloc(nbFaces,1);
+ MCAuto<DataArrayDouble> p=DataArrayDouble::New(); p->alloc(nbFaces,2);
double *pPtr=p->getPointer();
- const int *stFaceConn=begin+1;
+ int *e_fi = E_Fi->getPointer(), *e_f = E_F->getPointer(), *f_ei = F_Ei->getPointer(), *f_e = F_E->getPointer();
+ const int *f_idx = faces->getNodalConnectivityIndex()->getPointer(), *f_cnn = faces->getNodalConnectivity()->getPointer();
for(int i=0;i<nbFaces;i++,vPtr+=3,pPtr++)
{
- const int *endFaceConn=std::find(stFaceConn,end,-1);
- ComputeVecAndPtOfFace(eps,coords->begin(),stFaceConn,endFaceConn,vPtr,pPtr);
- stFaceConn=endFaceConn+1;
+ int face = e_f[e_fi[index] + i];
+ ComputeVecAndPtOfFace(eps, coords->begin(), f_cnn + f_idx[face] + 1, f_cnn + f_idx[face + 1], vPtr, pPtr);
+ // to differentiate faces going to different cells:
+ pPtr++, *pPtr = 0;
+ for (int j = f_ei[face]; j < f_ei[face + 1]; j++)
+ *pPtr += f_e[j];
}
pPtr=p->getPointer(); vPtr=v->getPointer();
DataArrayInt *comm1=0,*commI1=0;
v->findCommonTuples(eps,-1,comm1,commI1);
+ for (int i = 0; i < nbFaces; i++)
+ if (comm1->findIdFirstEqual(i) < 0)
+ {
+ comm1->pushBackSilent(i);
+ commI1->pushBackSilent(comm1->getNumberOfTuples());
+ }
MCAuto<DataArrayInt> comm1Auto(comm1),commI1Auto(commI1);
const int *comm1Ptr=comm1->begin();
const int *commI1Ptr=commI1->begin();
int nbOfGrps1=commI1Auto->getNumberOfTuples()-1;
res->pushBackSilent((int)INTERP_KERNEL::NORM_POLYHED);
//
- MCAuto<MEDCouplingUMesh> mm=MEDCouplingUMesh::New("",3);
- mm->setCoords(const_cast<DataArrayDouble *>(coords)); mm->allocateCells(1); mm->insertNextCell(INTERP_KERNEL::NORM_POLYHED,(int)std::distance(begin+1,end),begin+1);
- mm->finishInsertingCells();
- //
for(int i=0;i<nbOfGrps1;i++)
{
int vecId=comm1Ptr[commI1Ptr[i]];
MCAuto<DataArrayDouble> tmpgrp2=p->selectByTupleId(comm1Ptr+commI1Ptr[i],comm1Ptr+commI1Ptr[i+1]);
DataArrayInt *comm2=0,*commI2=0;
tmpgrp2->findCommonTuples(eps,-1,comm2,commI2);
+ for (int j = 0; j < commI1Ptr[i+1] - commI1Ptr[i]; j++)
+ if (comm2->findIdFirstEqual(j) < 0)
+ {
+ comm2->pushBackSilent(j);
+ commI2->pushBackSilent(comm2->getNumberOfTuples());
+ }
MCAuto<DataArrayInt> comm2Auto(comm2),commI2Auto(commI2);
const int *comm2Ptr=comm2->begin();
const int *commI2Ptr=commI2->begin();
int nbOfGrps2=commI2Auto->getNumberOfTuples()-1;
for(int j=0;j<nbOfGrps2;j++)
{
- if(commI2Ptr[j+1]-commI2Ptr[j]<=1)
+ if(commI2Ptr[j+1] == commI2Ptr[j] + 1)
{
- res->insertAtTheEnd(begin,end);
+ int face = e_f[e_fi[index] + comm1Ptr[commI1Ptr[i] + comm2Ptr[commI2Ptr[j]]]]; //hmmm
+ res->insertAtTheEnd(f_cnn + f_idx[face] + 1, f_cnn + f_idx[face + 1]);
res->pushBackSilent(-1);
}
else
int pointId=comm1Ptr[commI1Ptr[i]+comm2Ptr[commI2Ptr[j]]];
MCAuto<DataArrayInt> ids2=comm2->selectByTupleIdSafeSlice(commI2Ptr[j],commI2Ptr[j+1],1);
ids2->transformWithIndArr(comm1Ptr+commI1Ptr[i],comm1Ptr+commI1Ptr[i+1]);
- DataArrayInt *tmp0=DataArrayInt::New(),*tmp1=DataArrayInt::New(),*tmp2=DataArrayInt::New(),*tmp3=DataArrayInt::New();
- MCAuto<MEDCouplingUMesh> mm2=mm->buildDescendingConnectivity(tmp0,tmp1,tmp2,tmp3); tmp0->decrRef(); tmp1->decrRef(); tmp2->decrRef(); tmp3->decrRef();
- MCAuto<MEDCouplingUMesh> mm3=static_cast<MEDCouplingUMesh *>(mm2->buildPartOfMySelf(ids2->begin(),ids2->end(),true));
+ ids2->transformWithIndArr(e_f + e_fi[index], e_f + e_fi[index + 1]);
+ MCAuto<MEDCouplingUMesh> mm3=static_cast<MEDCouplingUMesh *>(faces->buildPartOfMySelf(ids2->begin(),ids2->end(),true));
MCAuto<DataArrayInt> idsNodeTmp=mm3->zipCoordsTraducer();
MCAuto<DataArrayInt> idsNode=idsNodeTmp->invertArrayO2N2N2O(mm3->getNumberOfNodes());
const int *idsNodePtr=idsNode->begin();
- double center[3]; center[0]=pPtr[pointId]*vPtr[3*vecId]; center[1]=pPtr[pointId]*vPtr[3*vecId+1]; center[2]=pPtr[pointId]*vPtr[3*vecId+2];
+ double center[3]; center[0]=pPtr[2*pointId]*vPtr[3*vecId]; center[1]=pPtr[2*pointId]*vPtr[3*vecId+1]; center[2]=pPtr[2*pointId]*vPtr[3*vecId+2];
double vec[3]; vec[0]=vPtr[3*vecId+1]; vec[1]=-vPtr[3*vecId]; vec[2]=0.;
double norm=vec[0]*vec[0]+vec[1]*vec[1]+vec[2]*vec[2];
if(std::abs(norm)>eps)
* 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
* cellIds \b in [ \b idsOfSelectBg , \b idsOfSelectEnd ) a copy coming from the corresponding values in input pair (\b srcArr, \b srcArrIndex).
- * This method is an generalization of MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx that performs the same thing but by without building explicitely a result output arrays.
+ * This method is an generalization of MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx that performs the same thing but by without building explicitly a result output arrays.
*
* \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)
/*!
* This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
- * This method is an specialization of MEDCouplingUMesh::SetPartOfIndexedArrays in the case of assignement do not modify the index in \b arrIndxIn.
+ * This method is an specialization of MEDCouplingUMesh::SetPartOfIndexedArrays in the case of assignment do not modify the index in \b arrIndxIn.
*
* \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)
* 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
* cellIds \b in [\b idsOfSelectBg, \b idsOfSelectEnd) a copy coming from the corresponding values in input pair (\b srcArr, \b srcArrIndex).
- * This method is an generalization of MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx that performs the same thing but by without building explicitely a result output arrays.
+ * This method is an generalization of MEDCouplingUMesh::SetPartOfIndexedArraysSameIdx that performs the same thing but by without building explicitly a result output arrays.
*
* \param [in] start begin of set of ids of the input extraction (included)
* \param [in] end end of set of ids of the input extraction (excluded)
/*!
* This method works on an input pair (\b arrIn, \b arrIndxIn) where \b arrIn indexes is in \b arrIndxIn.
- * This method is an specialization of MEDCouplingUMesh::SetPartOfIndexedArrays in the case of assignement do not modify the index in \b arrIndxIn.
+ * This method is an specialization of MEDCouplingUMesh::SetPartOfIndexedArrays in the case of assignment do not modify the index in \b arrIndxIn.
*
* \param [in] start begin of set of ids of the input extraction (included)
* \param [in] end end of set of ids of the input extraction (excluded)
* 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
+ * \warning This method operates on each cells in this independently ! 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).