using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingCMesh_getCoordsAt_1]
const double coords[3] = {1.,2.,4.};
- DataArrayDouble* x = DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> x = DataArrayDouble::New();
x->useExternalArrayWithRWAccess( coords, 3, 1 );
- MEDCouplingCMesh *mesh=MEDCouplingCMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingCMesh> mesh=MEDCouplingCMesh::New();
mesh->setCoordsAt(0,x);
const DataArrayDouble* x2=mesh->getCoordsAt(0);
CPPUNIT_ASSERT( x2->isEqual( *x, 1e-13 ));
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_1]
- MEDCouplingUMesh *mesh1=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh1=MEDCouplingUMesh::New();
mesh1->setMeshDimension(2);
mesh1->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh1->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // #3
mesh1->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // #4
mesh1->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
//! [CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_1]
//! [CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_2]
const int cells2[3] = { 4,2,0 }; // even cells selected
- MEDCouplingUMesh* mesh2 = (MEDCouplingUMesh*) mesh1->buildPartOfMySelf( cells2, cells2+3, true );
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh2 =
+ (MEDCouplingUMesh*) mesh1->buildPartOfMySelf( cells2, cells2+3, true );
//! [CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_2]
//! [CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_3]
int compType = 0; // the strongest policy
const int corr1to2Expected[5] = {2, 3, 1, 4, 0};
CPPUNIT_ASSERT(std::equal( corr1to2Expected, corr1to2Expected+5, corr1to2->getConstPointer() ));
//! [CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_4]
- mesh1->decrRef();
- mesh2->decrRef();
corr2to1->decrRef();
corr1to2->decrRef();
}
MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess( coords, 5, 2 );
// coordinates of 5 top nodes
- DataArrayDouble *coordsArr2 = coordsArr->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr2 = coordsArr->deepCpy();
// 3D coordinates of base + top nodes
coordsArr = coordsArr-> changeNbOfComponents( 3, 0 );
coordsArr2 = coordsArr2->changeNbOfComponents( 3, 1 );
coordsArr = DataArrayDouble::Aggregate( coordsArr, coordsArr2 );
// mesh
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
- mesh->setCoords(coordsArr);coordsArr->decrRef();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
+ mesh->setCoords(coordsArr);
mesh->setMeshDimension(3);
mesh->allocateCells(2);
// connectivity of reversed HEXA8 and PENTA6
mesh->finishInsertingCells();
//! [CppSnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_1]
//! [CppSnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_2]
- DataArrayInt* fixedCells = mesh->findAndCorrectBadOriented3DExtrudedCells();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> fixedCells =
+ mesh->findAndCorrectBadOriented3DExtrudedCells();
CPPUNIT_ASSERT( fixedCells->getNumberOfTuples() == 2 ); // 2 cells fixed
fixedCells = mesh->findAndCorrectBadOriented3DExtrudedCells();
CPPUNIT_ASSERT( fixedCells->getNumberOfTuples() == 0 ); // no bad cells
- fixedCells->decrRef();
//! [CppSnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_2]
}
//! [CppSnippet_MEDCouplingUMesh_arePolyhedronsNotCorrectlyOriented_1]
// 2D coordinates of 5 base nodes
const double coords[5*2]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2 };
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess( coords, 5, 2 );
// coordinates of 5 top nodes
- DataArrayDouble *coordsArr2 = coordsArr->deepCpy();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr2 = coordsArr->deepCpy();
// 3D coordinates of base + top nodes
coordsArr = coordsArr-> changeNbOfComponents( 3, 0 );
coordsArr2 = coordsArr2->changeNbOfComponents( 3, 1 );
coordsArr = DataArrayDouble::Aggregate( coordsArr, coordsArr2 );
// mesh
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
- mesh->setCoords(coordsArr);coordsArr->decrRef();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
+ mesh->setCoords(coordsArr);
mesh->setMeshDimension(3);
mesh->allocateCells(2);
// connectivity of a HEXA8 + a reversed PENTA6
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,2,4, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_getCellsContainingPoints_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_getCellsContainingPoint_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_buildPartOrthogonalField_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
//! [CppSnippet_MEDCouplingUMesh_buildPartOrthogonalField_1]
//! [CppSnippet_MEDCouplingUMesh_buildPartOrthogonalField_2]
const int part[4] = {1,2,3,4}; // cell #0 is omitted
- MEDCouplingFieldDouble* vecField=mesh->buildPartOrthogonalField( part, part+4 );
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingFieldDouble> vecField=
+ mesh->buildPartOrthogonalField( part, part+4 );
CPPUNIT_ASSERT ( vecField->getArray()->getNumberOfTuples() == 4 );
CPPUNIT_ASSERT ( vecField->getArray()->getNumberOfComponents() == 3 );
//! [CppSnippet_MEDCouplingUMesh_buildPartOrthogonalField_2]
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_getPartMeasureField_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,2,4, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
//! [CppSnippet_MEDCouplingUMesh_getPartMeasureField_2]
const bool isAbs = true;
const int part[4] = {1,2,3,4}; // cell #0 is omitted
- DataArrayDouble* areaArr=mesh->getPartMeasureField( isAbs, part, part+4 );
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> areaArr=
+ mesh->getPartMeasureField( isAbs, part, part+4 );
CPPUNIT_ASSERT( areaArr->getIJ(0,0) > 0 ); // orientation ignored
areaArr=mesh->getPartMeasureField( !isAbs, part, part+4 );
CPPUNIT_ASSERT( areaArr->getIJ(0,0) < 0 ); // orientation considered
//! [CppSnippet_MEDCouplingUMesh_getPartMeasureField_2]
//! [CppSnippet_MEDCouplingUMesh_getPartMeasureField_3]
const int cellIds[4] = {1,2,3,4}; // cell #0 is omitted
- DataArrayDouble* baryCenters=mesh->getPartBarycenterAndOwner( cellIds, cellIds+4 );
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> baryCenters=
+ mesh->getPartBarycenterAndOwner( cellIds, cellIds+4 );
CPPUNIT_ASSERT( baryCenters->getNumberOfTuples() == 4 );
CPPUNIT_ASSERT( baryCenters->getNumberOfComponents() == mesh->getSpaceDimension() );
//! [CppSnippet_MEDCouplingUMesh_getPartMeasureField_3]
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_getCellsInBoundingBox_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(1);
const double coords[3*2]={0.,0., 0.,1., 1.,1};
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess(coords, 3,2);
mesh->setCoords(coordsArr);
mesh->allocateCells(1);
//! [CppSnippet_MEDCouplingUMesh_getCellsInBoundingBox_1]
//! [CppSnippet_MEDCouplingUMesh_getCellsInBoundingBox_2]
const double bbox[] = {1., 1., 1.001,1.001}; // xMin, xMax, yMin, yMax
- DataArrayInt* cellIdsArr = mesh->getCellsInBoundingBox( bbox, 0.0 );
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> cellIdsArr =
+ mesh->getCellsInBoundingBox( bbox, 0.0 );
CPPUNIT_ASSERT( cellIdsArr->getNumberOfTuples() == 0 );
cellIdsArr = mesh->getCellsInBoundingBox( bbox, 0.1 );
CPPUNIT_ASSERT( cellIdsArr->getNumberOfTuples() == 1 );
- cellIdsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_getCellsInBoundingBox_2]
}
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_renumberNodesInConn_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(1);
const int conn[4]={4,3,2,1};
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_renumberNodes_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
const double coords[4*2]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.3};
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess(coords, 4,2);
mesh->setCoords(coordsArr);
mesh->allocateCells(0);
//! [CppSnippet_MEDCouplingUMesh_renumberNodes_2]
const int newIds[] = { 2,1,0,-1 };
mesh->renumberNodes(newIds, 3);
- coordsArr = mesh->getCoords(); // get a shorten array
+ coordsArr = mesh->getCoordinatesAndOwner(); // get a shorten array
const double coordsExpected[3*2]={0.7,-0.3, 0.2,-0.3, -0.3,-0.3};
- DataArrayDouble *coordsExpectedArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsExpectedArr=DataArrayDouble::New();
coordsExpectedArr->useExternalArrayWithRWAccess(coordsExpected, 3,2);
CPPUNIT_ASSERT( coordsExpectedArr->isEqual( *coordsArr, 1e-13 ));
//! [CppSnippet_MEDCouplingUMesh_renumberNodes_2]
coordsArr->useExternalArrayWithRWAccess(coords, 4,2); // restore old nodes
const int newIds2[] = { 2,1,0,2 };
mesh->renumberNodes2(newIds2, 3);
- coordsArr = mesh->getCoords(); // get a shorten array
+ coordsArr = mesh->getCoordinatesAndOwner(); // get a shorten array
const double coordsExpected2[3*2]={0.7,-0.3, 0.2,-0.3, -0.3, 0.0};
- DataArrayDouble *coordsExpectedArr2=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsExpectedArr2=DataArrayDouble::New();
coordsExpectedArr2->useExternalArrayWithRWAccess(coordsExpected2, 3,2);
CPPUNIT_ASSERT( coordsExpectedArr2->isEqual( *coordsArr, 1e-13 ));
//! [CppSnippet_MEDCouplingUMesh_renumberNodes_3]
- coordsExpectedArr->decrRef();
- coordsExpectedArr2->decrRef();
- mesh->decrRef();
}
void CppExample_MEDCouplingUMesh_findBoundaryNodes()
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_findBoundaryNodes_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
//! [CppSnippet_MEDCouplingUMesh_findBoundaryNodes_1]
//! [CppSnippet_MEDCouplingUMesh_findBoundaryNodes_2]
- DataArrayInt* nodeIdsArr=mesh->findBoundaryNodes();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> nodeIdsArr=mesh->findBoundaryNodes();
CPPUNIT_ASSERT( nodeIdsArr->getNumberOfTuples() == mesh->getNumberOfNodes() - 1 );
//! [CppSnippet_MEDCouplingUMesh_findBoundaryNodes_2]
- nodeIdsArr->decrRef();
- coordsArr->decrRef();
- mesh->decrRef();
}
void CppExample_MEDCouplingUMesh_buildBoundaryMesh()
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_buildBoundaryMesh_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
//! [CppSnippet_MEDCouplingUMesh_buildBoundaryMesh_1]
//! [CppSnippet_MEDCouplingUMesh_buildBoundaryMesh_2]
- MEDCouplingPointSet* mesh1=mesh->buildBoundaryMesh(true);
- MEDCouplingPointSet* mesh2=mesh->buildBoundaryMesh(false);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> mesh1=mesh->buildBoundaryMesh(true);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingPointSet> mesh2=mesh->buildBoundaryMesh(false);
CPPUNIT_ASSERT( coordsArr->isEqual( *mesh1->getCoords(), 1e-13 )); // same nodes
CPPUNIT_ASSERT( !coordsArr->isEqual( *mesh2->getCoords(), 1e-13 )); // different nodes
//! [CppSnippet_MEDCouplingUMesh_buildBoundaryMesh_2]
- coordsArr->decrRef();
- mesh->decrRef();
- mesh1->decrRef();
- mesh2->decrRef();
}
void CppExample_MEDCouplingUMesh_buildFacePartOfMySelfNode()
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_buildFacePartOfMySelfNode_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_buildFacePartOfMySelfNode_1]
//! [CppSnippet_MEDCouplingUMesh_buildFacePartOfMySelfNode_2]
std::vector<int> nodes;
mesh->getNodeIdsOfCell( 0, nodes );
const bool allNodes = true;
- MEDCouplingUMesh* mesh1 = (MEDCouplingUMesh*)mesh->buildFacePartOfMySelfNode( &nodes[0], &nodes[0]+nodes.size(), allNodes);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh1 =
+ (MEDCouplingUMesh*)mesh->buildFacePartOfMySelfNode( &nodes[0],&nodes[0]+nodes.size(),allNodes);
CPPUNIT_ASSERT( mesh1->getNumberOfCells() == 4 ); // 4 segments bounding QUAD4 #0 only
- MEDCouplingUMesh* mesh2 = (MEDCouplingUMesh*)mesh->buildFacePartOfMySelfNode( &nodes[0], &nodes[0]+nodes.size(),!allNodes);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh2 =
+ (MEDCouplingUMesh*)mesh->buildFacePartOfMySelfNode( &nodes[0],&nodes[0]+nodes.size(),!allNodes);
CPPUNIT_ASSERT( mesh2->getNumberOfCells() == 9 ); // more segments added
//! [CppSnippet_MEDCouplingUMesh_buildFacePartOfMySelfNode_2]
- mesh->decrRef();
- mesh1->decrRef();
- mesh2->decrRef();
}
void CppExample_MEDCouplingUMesh_buildPartOfMySelfNode()
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_buildPartOfMySelfNode_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_buildPartOfMySelfNode_1]
//! [CppSnippet_MEDCouplingUMesh_buildPartOfMySelfNode_2]
std::vector<int> nodes;
mesh->getNodeIdsOfCell( 0, nodes );
const bool allNodes = true;
- MEDCouplingUMesh* mesh1 = (MEDCouplingUMesh*)mesh->buildPartOfMySelfNode( &nodes[0], &nodes[0]+nodes.size(), allNodes);
- MEDCouplingUMesh* mesh2 = (MEDCouplingUMesh*)mesh->buildPartOfMySelfNode( &nodes[0], &nodes[0]+nodes.size(),!allNodes);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh1 =
+ (MEDCouplingUMesh*)mesh->buildPartOfMySelfNode( &nodes[0], &nodes[0]+nodes.size(), allNodes);
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh2 =
+ (MEDCouplingUMesh*)mesh->buildPartOfMySelfNode( &nodes[0], &nodes[0]+nodes.size(),!allNodes);
CPPUNIT_ASSERT_EQUAL( mesh1->getNumberOfCells(), 1 );
CPPUNIT_ASSERT_EQUAL( mesh2->getNumberOfCells(), mesh->getNumberOfCells() );
//! [CppSnippet_MEDCouplingUMesh_buildPartOfMySelfNode_2]
- mesh->decrRef();
- mesh1->decrRef();
- mesh2->decrRef();
}
void CppExample_MEDCouplingUMesh_getCellIdsLyingOnNodes()
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_getCellIdsLyingOnNodes_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_getCellIdsLyingOnNodes_1]
//! [CppSnippet_MEDCouplingUMesh_getCellIdsLyingOnNodes_2]
std::vector<int> nodes;
CPPUNIT_ASSERT_EQUAL( cellIdsArr1->getNumberOfTuples(), 1 );
CPPUNIT_ASSERT_EQUAL( cellIdsArr2->getNumberOfTuples(), mesh->getNumberOfCells() );
//! [CppSnippet_MEDCouplingUMesh_getCellIdsLyingOnNodes_2]
- mesh->decrRef();
cellIdsArr1->decrRef();
cellIdsArr2->decrRef();
}
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_getCellIdsFullyIncludedInNodeIds_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_getCellIdsFullyIncludedInNodeIds_1]
//! [CppSnippet_MEDCouplingUMesh_getCellIdsFullyIncludedInNodeIds_2]
const int cellIds[2]={1,2};
DataArrayInt* cellIdsArr = mesh->getCellIdsFullyIncludedInNodeIds( &nodes[0], &nodes[0]+nodes.size());
CPPUNIT_ASSERT(std::equal( cellIds, cellIds+2, cellIdsArr->getPointer() ));
//! [CppSnippet_MEDCouplingUMesh_getCellIdsFullyIncludedInNodeIds_2]
- mesh->decrRef();
cellIdsArr->decrRef();
}
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_buildPartOfMySelf_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
CPPUNIT_ASSERT( nodes1 == nodes2 ); // cell #cellIds[i] was copied
}
//! [CppSnippet_MEDCouplingUMesh_buildPartOfMySelf_2]
- coordsArr->decrRef();
- mesh->decrRef();
mesh2->decrRef();
mesh3->decrRef();
}
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_mergeNodes_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2};
1.1,0.0, // #3
1.1,0.0, // #4 == #3
0.3,-0.303}; // #5 ~~ #0
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(6,2);
std::copy(coords,coords+6*2,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_mergeNodes_1]
//! [CppSnippet_MEDCouplingUMesh_mergeNodes_2]
bool areNodesMerged; int newNbOfNodes;
- DataArrayInt *arr=mesh->mergeNodes(0.004,areNodesMerged,newNbOfNodes);
+ MEDCouplingAutoRefCountObjectPtr<DataArrayInt> arr=
+ mesh->mergeNodes(0.004,areNodesMerged,newNbOfNodes);
const int idsExpected[6] = {0, 1, 0, 2, 2, 0};
CPPUNIT_ASSERT(std::equal(idsExpected,idsExpected+6,arr->getPointer()));
CPPUNIT_ASSERT( areNodesMerged );
//! [CppSnippet_MEDCouplingUMesh_mergeNodes_2]
//! [CppSnippet_MEDCouplingUMesh_mergeNodes_3]
const double* baryCoords2 = coords + 2*2; // initial coordinates of node #2
- coordsArr=mesh->getCoords(); // retrieve a new shorten coord array
+ coordsArr=mesh->getCoordinatesAndOwner(); // retrieve a new shorten coord array
CPPUNIT_ASSERT( fabs( baryCoords2[1] - coordsArr->getIJ(0,1)) > 1e-4 ); // Y of node #0 differs from that of baryCoords2
// restore coordinates
coordsArr->alloc(6,2);
mesh->setCoords(coordsArr);
// call mergeNodes2()
arr = mesh->mergeNodes2(0.004,areNodesMerged,newNbOfNodes);
- coordsArr=mesh->getCoords(); // retrieve a new shorten coord array
+ coordsArr=mesh->getCoordinatesAndOwner(); // retrieve a new shorten coord array
CPPUNIT_ASSERT_DOUBLES_EQUAL( baryCoords2[1], coordsArr->getIJ(0,1), 13 ); // Y of node #0 equals to that of baryCoords2
//! [CppSnippet_MEDCouplingUMesh_mergeNodes_3]
- mesh->decrRef();
- arr->decrRef();
}
void CppExample_MEDCouplingUMesh_zipConnectivityTraducer()
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_zipConnectivityTraducer_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[11]={0,3,4,1, 1,4,2, 4,1,0,3};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+0); // 3 == 0
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+7); // 4 ~~ 0
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_zipConnectivityTraducer_1]
//! [CppSnippet_MEDCouplingUMesh_zipConnectivityTraducer_2]
const int oldNbCells = mesh->getNumberOfCells();
const int idsExpected[5] = {0, 1, 1, 0, 2};
CPPUNIT_ASSERT(std::equal(idsExpected,idsExpected+5,arr->getPointer()));
//! [CppSnippet_MEDCouplingUMesh_zipConnectivityTraducer_2]
- mesh->decrRef();
arr->decrRef();
}
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_zipCoordsTraducer_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_zipCoordsTraducer_1]
//! [CppSnippet_MEDCouplingUMesh_zipCoordsTraducer_2]
const int cellIds[2]={1,2};
const int idsExpected[9] = {-1,0,1,-1,2,3,-1,-1,-1}; // -1 for unused nodes
CPPUNIT_ASSERT(std::equal(idsExpected,idsExpected+9,arr->getPointer()));
//! [CppSnippet_MEDCouplingUMesh_zipCoordsTraducer_2]
- mesh->decrRef();
mesh2->decrRef();
arr->decrRef();
}
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_1]
//! [CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_2]
const int cellIds[2]={1,2};
const int idsExpected2[4] = {1,2,4,5};
CPPUNIT_ASSERT(std::equal(idsExpected2,idsExpected2+4,arr2->getPointer()));
//! [CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_3]
- mesh->decrRef();
mesh2->decrRef();
arr->decrRef();
arr2->decrRef();
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_convertToPolyTypes_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_convertToPolyTypes_1]
//! [CppSnippet_MEDCouplingUMesh_convertToPolyTypes_2]
const int cells[2]={1,3};
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity2_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity2_1]
//! [CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity2_2]
DataArrayInt *desc =DataArrayInt::New();
descIndx->decrRef();
revDesc->decrRef();
revDescIndx->decrRef();
- mesh->decrRef();
mesh2->decrRef();
}
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity_1]
//! [CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity_2]
DataArrayInt *desc =DataArrayInt::New();
descIndx->decrRef();
revDesc->decrRef();
revDescIndx->decrRef();
- mesh->decrRef();
mesh2->decrRef();
}
{
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingUMesh_getReverseNodalConnectivity_1]
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setMeshDimension(2);
mesh->allocateCells(5);
const int conn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+10); // 3
mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn+14); // 4
mesh->finishInsertingCells();
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->alloc(9,2);
const double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
std::copy(coords,coords+18,coordsArr->getPointer());
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingUMesh_getReverseNodalConnectivity_1]
//! [CppSnippet_MEDCouplingUMesh_getReverseNodalConnectivity_2]
DataArrayInt *revNodal=DataArrayInt::New();
//! [CppSnippet_MEDCouplingUMesh_getReverseNodalConnectivity_2]
revNodal->decrRef();
revNodalIndx->decrRef();
- mesh->decrRef();
}
void CppExample_MEDCouplingUMesh_checkDeepEquivalWith()
//! [CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_1]
// mesh 1
MEDCouplingUMesh *mesh1=MEDCouplingUMesh::New();
+ const double coords[4*2]={0.0,0.0, // #0
+ 1.0,0.0, // #1
+ 1.0,1.0, // #2
+ 0.0,1.0}; // #3
{
mesh1->setMeshDimension(2);
- const double coords[4*2]={0.0,0.0, // #0
- 1.0,0.0, // #1
- 1.0,1.0, // #2
- 0.0,1.0}; // #3
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess( coords, 4, 2 );
mesh1->setCoords(coordsArr);
- coordsArr->decrRef();
mesh1->allocateCells(2);
const int conn[6]={0,1,2, 1,2,3};
mesh1->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+0); // #0
}
// mesh 2
MEDCouplingUMesh *mesh2=MEDCouplingUMesh::New();
+ const double coords2[4*2]={0.0,1.0, // #0 = #3
+ 0.0,0.0, // #1 = #0
+ 1.0,0.0, // #2 = #1
+ 1.0,1.001}; // #3 ~ #2
{
mesh2->setMeshDimension(2);
- const double coords[4*2]={0.0,1.0, // #0 = #3
- 0.0,0.0, // #1 = #0
- 1.0,0.0, // #2 = #1
- 1.0,1.001}; // #3 ~ #2
- DataArrayDouble *coordsArr=DataArrayDouble::New();
- coordsArr->useExternalArrayWithRWAccess( coords, 4, 2 );
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
+ coordsArr->useExternalArrayWithRWAccess( coords2, 4, 2 );
mesh2->setCoords(coordsArr);
- coordsArr->decrRef();
mesh2->allocateCells(2);
const int conn[6]={2,3,0, 3,1,2};
mesh2->insertNextCell(INTERP_KERNEL::NORM_TRI3,3, conn+0); // #0 = #1
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingPointSet_scale_1]
double coords[4*2]={0.0,0.0, 1.0,0.0, 1.0,1.0, 0.0,1.0}; // 2D coordinates of 4 nodes
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess(coords, 4,2);
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setCoords(coordsArr);
DataArrayDouble *initCoords = coordsArr->deepCpy();
//! [CppSnippet_MEDCouplingPointSet_scale_1]
CPPUNIT_ASSERT( coordsArr2->isEqualWithoutConsideringStr( *initCoords, 1.0 ));
CPPUNIT_ASSERT( !coordsArr2->isEqualWithoutConsideringStr( *initCoords, 0.9 ));
// release data
- mesh->decrRef();
- coordsArr->decrRef();
initCoords->decrRef();
//! [CppSnippet_MEDCouplingPointSet_scale_3]
}
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingPointSet_translate_1]
double coords[4*2]={0.0,0.0, 1.0,0.0, 1.0,1.0, 0.0,1.0}; // 2D coordinates of 4 nodes
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess(coords, 4,2);
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setCoords(coordsArr);
DataArrayDouble *initCoords = coordsArr->deepCpy();
//! [CppSnippet_MEDCouplingPointSet_translate_1]
CPPUNIT_ASSERT( coordsArr2->isEqualWithoutConsideringStr( *initCoords, 1.0 ));
CPPUNIT_ASSERT( !coordsArr2->isEqualWithoutConsideringStr( *initCoords, 0.9 ));
// release data
- mesh->decrRef();
- coordsArr->decrRef();
initCoords->decrRef();
//! [CppSnippet_MEDCouplingPointSet_translate_3]
}
double coords[4*2]={0.0,0.0, 0.1,0.0, 0.1,0.1, 0.0,0.1}; // 2D coordinates of 4 nodes
double coordsOrig[4*2];
std::copy(coords,coords+sizeof(coords)/sizeof(double),coordsOrig);//keep tracks of initial values
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess(coords, 4,2);
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setCoords(coordsArr);
//! [CppSnippet_MEDCouplingPointSet_rotate_1]
//! [CppSnippet_MEDCouplingPointSet_rotate_2]
const DataArrayDouble * coordsArr2 = mesh->getCoords();
coordsArr->useExternalArrayWithRWAccess(coordsOrig, 4,2);
CPPUNIT_ASSERT( coordsArr2->isEqualWithoutConsideringStr( *coordsArr, 1e-13 ));
- // release data
- mesh->decrRef();
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingPointSet_rotate_4]
}
//! [CppSnippet_MEDCouplingPointSet_getBoundingBox_1]
double cc[2*3]={0.0, 0.1, 0.2, // 3D coordinates of 2 nodes
2.0, 2.1, 2.2};
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess(cc, 2,3);
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingPointSet_getBoundingBox_1]
//! [CppSnippet_MEDCouplingPointSet_getBoundingBox_2]
double bbox[3][2];
mesh->getBoundingBox( (double*) bbox );
- mesh->decrRef();
// check the returned coordinates of extremum points of the bounding box
for ( int i = 0; i < 2; ++i ) // point id
0.3,-0.30002, // #2
1.1,0.0, // #3
0.3,-0.30003};// #4
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess(coords, 5,2);
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoint_1]
//! [CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoint_2]
double point [2]={0.3, -0.3}; // point close to nodes #0, #2 and #4
CPPUNIT_ASSERT_EQUAL(3, okIDs->getNumberOfTuples());
// release data
- mesh->decrRef();
ids->decrRef();
okIDs->decrRef();
//! [CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoint_2]
1.1,0.0, // #4
1.1,0.002, // #5
0.3,-0.303};// #6
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess(coords, 7,2);
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoints_1]
//! [CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoints_2]
const int nbOfPoints = 3;
CPPUNIT_ASSERT_EQUAL(4, okIDs->getNumberOfTuples());
// release data
- mesh->decrRef();
ids->decrRef();
idsIndex->decrRef();
okIDs->decrRef();
1.1,0.0, // 3
1.1,0.0, // 4
0.3,-0.303};// 5
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess(coords, 6,2);
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingPointSet_findCommonNodes_1]
//! [CppSnippet_MEDCouplingPointSet_findCommonNodes_2]
DataArrayInt *com, *comI;
mesh->findCommonNodes(1e-13,-1,com,comI);
CPPUNIT_ASSERT_EQUAL(2, com->getNumberOfTuples());
+ com->decrRef(); comI->decrRef();
mesh->findCommonNodes(0.004,-1,com,comI);
CPPUNIT_ASSERT_EQUAL(5, com->getNumberOfTuples());
//! [CppSnippet_MEDCouplingPointSet_findCommonNodes_2]
- mesh->decrRef();
- com->decrRef();
- comI->decrRef();
+ com->decrRef(); comI->decrRef();
}
void CppExample_MEDCouplingPointSet_getCoordinatesOfNode()
using namespace ParaMEDMEM;
//! [CppSnippet_MEDCouplingPointSet_getCoordinatesOfNode_1]
double coords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3};
- DataArrayDouble *coordsArr=DataArrayDouble::New();
+ MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> coordsArr=DataArrayDouble::New();
coordsArr->useExternalArrayWithRWAccess(coords, 3,2);
- MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
+ MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> mesh=MEDCouplingUMesh::New();
mesh->setCoords(coordsArr);
- coordsArr->decrRef();
//! [CppSnippet_MEDCouplingPointSet_getCoordinatesOfNode_1]
//! [CppSnippet_MEDCouplingPointSet_getCoordinatesOfNode_2]
std::vector<double> coords2;
CPPUNIT_ASSERT_DOUBLES_EQUAL(coords[2],coords2[0],1e-13);
CPPUNIT_ASSERT_DOUBLES_EQUAL(coords[3],coords2[1],1e-13);
//! [CppSnippet_MEDCouplingPointSet_getCoordinatesOfNode_2]
- mesh->decrRef();
}
void CppExample_DataArrayInt_buildPermutationArr()