-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <sstream>
#include <numeric>
-using namespace ParaMEDMEM;
+using namespace MEDCoupling;
MEDCouplingCurveLinearMesh::MEDCouplingCurveLinearMesh():_coords(0),_structure(0)
{
if(deepCopy)
{
if((const DataArrayDouble *)other._coords)
- _coords=other._coords->deepCpy();
+ _coords=other._coords->deepCopy();
}
else
_coords=other._coords;
return ret;
}
-MEDCouplingMesh *MEDCouplingCurveLinearMesh::deepCpy() const
+MEDCouplingCurveLinearMesh *MEDCouplingCurveLinearMesh::deepCopy() const
{
return clone(true);
}
return ret;
}
-std::vector<const BigMemoryObject *> MEDCouplingCurveLinearMesh::getDirectChildren() const
+std::vector<const BigMemoryObject *> MEDCouplingCurveLinearMesh::getDirectChildrenWithNull() const
{
std::vector<const BigMemoryObject *> ret;
- if((const DataArrayDouble *)_coords)
- ret.push_back((const DataArrayDouble *)_coords);
+ ret.push_back((const DataArrayDouble *)_coords);
return ret;
}
}
/*!
- * Nothing is done here (except to check that the other is a ParaMEDMEM::MEDCouplingCurveLinearMesh instance too).
- * The user intend that the nodes are the same, so by construction of ParaMEDMEM::MEDCouplingCurveLinearMesh, \a this and \a other are the same !
+ * Nothing is done here (except to check that the other is a MEDCoupling::MEDCouplingCurveLinearMesh instance too).
+ * The user intend that the nodes are the same, so by construction of MEDCoupling::MEDCouplingCurveLinearMesh, \a this and \a other are the same !
*/
void MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith(const MEDCouplingMesh *other, int cellCompPol, double prec,
DataArrayInt *&cellCor) const
throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkDeepEquivalOnSameNodesWith : Meshes are not the same !");
}
-void MEDCouplingCurveLinearMesh::checkCoherency() const
+void MEDCouplingCurveLinearMesh::checkConsistencyLight() const
{
std::size_t sz=_structure.size(),i=0,nbOfNodes=1;
if(sz<1)
- throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkCoherency : structure should have a lgth of size 1 at least !");
+ throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkConsistencyLight : structure should have a lgth of size 1 at least !");
for(std::vector<int>::const_iterator it=_structure.begin();it!=_structure.end();it++,i++)
{
if((*it)<1)
- { std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::checkCoherency : At pos #" << i << " of structure value is " << *it << "should be >= 1 !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); }
+ { std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::checkConsistencyLight : At pos #" << i << " of structure value is " << *it << "should be >= 1 !"; throw INTERP_KERNEL::Exception(oss.str().c_str()); }
nbOfNodes*=*it;
}
if(!((const DataArrayDouble *)_coords))
- throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkCoherency : the array is not set !");
+ throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkConsistencyLight : the array is not set !");
if(!_coords->isAllocated())
- throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkCoherency : the array is not allocated !");
+ throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkConsistencyLight : the array is not allocated !");
if(_coords->getNumberOfComponents()<1)
- throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkCoherency : the array should have >= 1 components !");
+ throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::checkConsistencyLight : the array should have >= 1 components !");
if(_coords->getNumberOfTuples()!=(int)nbOfNodes)
{
- std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::checkCoherency : structure said that number of nodes should be equal to " << nbOfNodes << " but number of tuples in array is equal to " << _coords->getNumberOfTuples() << " !";
+ std::ostringstream oss; oss << "MEDCouplingCurveLinearMesh::checkConsistencyLight : structure said that number of nodes should be equal to " << nbOfNodes << " but number of tuples in array is equal to " << _coords->getNumberOfTuples() << " !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
}
-void MEDCouplingCurveLinearMesh::checkCoherency1(double eps) const
-{
- checkCoherency();
-}
-
-void MEDCouplingCurveLinearMesh::checkCoherency2(double eps) const
+void MEDCouplingCurveLinearMesh::checkConsistency(double eps) const
{
- checkCoherency1(eps);
+ checkConsistencyLight();
}
int MEDCouplingCurveLinearMesh::getNumberOfCells() const
{
- checkCoherency();
+ checkConsistencyLight();
return MEDCouplingStructuredMesh::getNumberOfCells();
}
int MEDCouplingCurveLinearMesh::getNumberOfNodes() const
{
- checkCoherency();
+ checkConsistencyLight();
return MEDCouplingStructuredMesh::getNumberOfNodes();
}
-void MEDCouplingCurveLinearMesh::getSplitCellValues(int *res) const
-{
- int meshDim=getMeshDimension();
- for(int l=0;l<meshDim;l++)
- {
- int val=1;
- for(int p=0;p<meshDim-l-1;p++)
- val*=_structure[p]-1;
- res[meshDim-l-1]=val;
- }
-}
-
-void MEDCouplingCurveLinearMesh::getSplitNodeValues(int *res) const
-{
- int meshDim=getMeshDimension();
- for(int l=0;l<meshDim;l++)
- {
- int val=1;
- for(int p=0;p<meshDim-l-1;p++)
- val*=_structure[p];
- res[meshDim-l-1]=val;
- }
-}
-
void MEDCouplingCurveLinearMesh::getNodeGridStructure(int *res) const
{
std::copy(_structure.begin(),_structure.end(),res);
MEDCouplingStructuredMesh *MEDCouplingCurveLinearMesh::buildStructuredSubPart(const std::vector< std::pair<int,int> >& cellPart) const
{
- checkCoherency();
+ checkConsistencyLight();
int dim(getSpaceDimension());
std::vector<int> dims(getMeshDimension());
if(dim!=(int)cellPart.size())
std::vector< std::pair<int,int> > nodePartFormat(cellPart);
for(std::vector< std::pair<int,int> >::iterator it=nodePartFormat.begin();it!=nodePartFormat.end();it++)
(*it).second++;
- MEDCouplingAutoRefCountObjectPtr<DataArrayInt> tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat));
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingCurveLinearMesh> ret(dynamic_cast<MEDCouplingCurveLinearMesh *>(deepCpy()));
+ MCAuto<DataArrayInt> tmp1(BuildExplicitIdsFrom(getNodeGridStructure(),nodePartFormat));
+ MCAuto<MEDCouplingCurveLinearMesh> ret(dynamic_cast<MEDCouplingCurveLinearMesh *>(deepCopy()));
const DataArrayDouble *coo(ret->getCoords());
if(coo)
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo2(coo->selectByTupleIdSafe(tmp1->begin(),tmp1->end()));
+ MCAuto<DataArrayDouble> coo2(coo->selectByTupleIdSafe(tmp1->begin(),tmp1->end()));
ret->setCoords(coo2);
}
for(int i=0;i<dim;i++)
MEDCouplingFieldDouble *MEDCouplingCurveLinearMesh::getMeasureField(bool isAbs) const
{
- checkCoherency();
+ checkConsistencyLight();
int meshDim=getMeshDimension();
std::string name="MeasureOfMesh_"; name+=getName();
- MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+ MCAuto<MEDCouplingFieldDouble> field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
field->setName(name); field->setMesh(const_cast<MEDCouplingCurveLinearMesh *>(this)); field->synchronizeTimeWithMesh();
switch(meshDim)
{
{
int nbnodes=getNumberOfNodes();
int spaceDim=getSpaceDimension();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
+ MCAuto<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
if(nbnodes==0)
{ arr->alloc(0,1); return; }
if(spaceDim==1)
}
else
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp=DataArrayDouble::New(); tmp->alloc(nbnodes-1,spaceDim);
+ MCAuto<DataArrayDouble> tmp=DataArrayDouble::New(); tmp->alloc(nbnodes-1,spaceDim);
std::transform(_coords->begin()+spaceDim,_coords->end(),_coords->begin(),tmp->getPointer(),std::minus<double>());
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> tmp2=tmp->magnitude(); field->setArray(tmp2);
+ MCAuto<DataArrayDouble> tmp2=tmp->magnitude(); field->setArray(tmp2);
}
}
int spaceDim=getSpaceDimension();
if(spaceDim!=2 && spaceDim!=3)
throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim2 : with meshDim 2 only space dimension 2 and 3 are possible !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
+ MCAuto<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
arr->alloc(nbcells,1);
double *pt=arr->getPointer();
const double *coords=_coords->begin();
int spaceDim=getSpaceDimension();
if(spaceDim!=3)
throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getMeasureFieldMeshDim3 : with meshDim 3 only space dimension 3 is possible !");
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
+ MCAuto<DataArrayDouble> arr=DataArrayDouble::New(); field->setArray(arr);
arr->alloc(nbcells,1);
double *pt=arr->getPointer();
const double *coords=_coords->begin();
/// @cond INTERNAL
-namespace ParaMEDMEM
+namespace MEDCoupling
{
template<const int SPACEDIMM>
class DummyClsMCL
int MEDCouplingCurveLinearMesh::getCellContainingPoint(const double *pos, double eps) const
{
- checkCoherency();
+ checkConsistencyLight();
int spaceDim=getSpaceDimension();
const double *coords=_coords->getConstPointer();
int nodeId=-1;
int nbNodes=_coords->getNumberOfTuples();
double *coords=_coords->getPointer();
if(spaceDim==3)
- MEDCouplingPointSet::Rotate3DAlg(center,vector,angle,nbNodes,coords);
+ DataArrayDouble::Rotate3DAlg(center,vector,angle,nbNodes,coords,coords);
else if(spaceDim==2)
- MEDCouplingPointSet::Rotate2DAlg(center,angle,nbNodes,coords);
+ DataArrayDouble::Rotate2DAlg(center,angle,nbNodes,coords,coords);
else
throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::rotate : invalid space dim for rotation must be 2 or 3");
_coords->declareAsNew();
return ret;
}
-DataArrayDouble *MEDCouplingCurveLinearMesh::getBarycenterAndOwner() const
+DataArrayDouble *MEDCouplingCurveLinearMesh::computeCellCenterOfMass() const
{
- checkCoherency();
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> ret=DataArrayDouble::New();
+ checkConsistencyLight();
+ MCAuto<DataArrayDouble> ret=DataArrayDouble::New();
int spaceDim=getSpaceDimension();
int meshDim=getMeshDimension();
int nbOfCells=getNumberOfCells();
case 1:
{ getBarycenterAndOwnerMeshDim1(ret); return ret.retn(); }
default:
- throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::getBarycenterAndOwner : mesh dimension must be in [1,2,3] !");
+ throw INTERP_KERNEL::Exception("MEDCouplingCurveLinearMesh::computeCellCenterOfMass : mesh dimension must be in [1,2,3] !");
}
}
DataArrayDouble *MEDCouplingCurveLinearMesh::computeIsoBarycenterOfNodesPerCell() const
{
- return MEDCouplingCurveLinearMesh::getBarycenterAndOwner();
+ return MEDCouplingCurveLinearMesh::computeCellCenterOfMass();
}
/*!
* \param [in,out] bary Barycenter array feeded with good values.
- * \sa MEDCouplingCurveLinearMesh::getBarycenterAndOwner
+ * \sa MEDCouplingCurveLinearMesh::computeCellCenterOfMass
*/
void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim3(DataArrayDouble *bary) const
{
/*!
* \param [in,out] bary Barycenter array feeded with good values.
- * \sa MEDCouplingCurveLinearMesh::getBarycenterAndOwner
+ * \sa MEDCouplingCurveLinearMesh::computeCellCenterOfMass
*/
void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim2(DataArrayDouble *bary) const
{
/*!
* \param [in,out] bary Barycenter array feeded with good values.
- * \sa MEDCouplingCurveLinearMesh::getBarycenterAndOwner
+ * \sa MEDCouplingCurveLinearMesh::computeCellCenterOfMass
*/
void MEDCouplingCurveLinearMesh::getBarycenterAndOwnerMeshDim1(DataArrayDouble *bary) const
{
_coords->writeVTK(ofs,8,"Points",byteData);
else
{
- MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coo=_coords->changeNbOfComponents(3,0.);
+ MCAuto<DataArrayDouble> coo=_coords->changeNbOfComponents(3,0.);
coo->writeVTK(ofs,8,"Points",byteData);
}
ofs << " </Points>\n";
{ stream << std::endl << "No coordinates set !"; return ; }
if(!coo->isAllocated())
{ stream << std::endl << "Coordinates set but not allocated !"; return ; }
- int nbOfCompo=coo->getNumberOfComponents();
- if(nbOfCompo!=(int)_structure.size())
+ int nbOfCompo(coo->getNumberOfComponents());
+ int nbOfCompoExp(-1);
+ try
+ {
+ nbOfCompoExp=getSpaceDimension();
+ }
+ catch(INTERP_KERNEL::Exception& e)
+ {
+ }
+ if(nbOfCompo!=nbOfCompoExp)
{ stream << std::endl << "Coordinates set and allocated but mismatch number of components !"; return ; }
stream << std::endl << "Coordinates ( number of tuples = " << coo->getNumberOfTuples() << " ) : ";
coo->reprQuickOverviewData(stream,200);
}
+std::string MEDCouplingCurveLinearMesh::getVTKFileExtension() const
+{
+ return std::string("vts");
+}
+
std::string MEDCouplingCurveLinearMesh::getVTKDataSetType() const
{
return std::string("StructuredGrid");