void MEDCouplingBasicsTest2::testCellOrientation1()
{
MEDCouplingUMesh *m=build2DTargetMesh_1();
- double vec[3]={0.,0.,1.};
+ double vec[3]={0.,0.,-1.};
std::vector<int> res1;
CPPUNIT_ASSERT_THROW(m->are2DCellsNotCorrectlyOriented(vec,false,res1),INTERP_KERNEL::Exception);
m->changeSpaceDimension(3);
res1.clear();
m->are2DCellsNotCorrectlyOriented(vec,false,res1);
CPPUNIT_ASSERT(res1.empty());
- vec[2]=-1;
+ vec[2]=1;
m->are2DCellsNotCorrectlyOriented(vec,false,res1);
CPPUNIT_ASSERT_EQUAL(5,(int)res1.size());
res1.clear();
//
- vec[2]=1.;
+ vec[2]=-1.;
// connectivity inversion
int *conn=m->getNodalConnectivity()->getPointer();
int tmp=conn[11];
MEDCouplingFieldDouble *f2=m2->getMeasureField(false);
//Test to check global reverse in MEDCouplingUMesh::tryToCorrectPolyhedronOrientation
MEDCouplingUMesh *m3=build2DTargetMesh_1();
- double vec[3]={0.,0.,-1.};//<- important for the test
+ double vec[3]={0.,0.,1.};
m3->changeSpaceDimension(3);
const int ids1[5]={0,1,2,3,4};
std::vector<int> ids2(ids1,ids1+5);
mesh2->decrRef();
mesh->decrRef();
}
+
+void MEDCouplingBasicsTest5::testAre2DCellsNotCorrectlyOriented1()
+{
+ double m1Coords[8]={1.,1.,-1.,-1.,-1.,-1.,1.,-1.};
+ int m1Conn[4]={0,3,1,2};
+ MEDCouplingUMesh *m1=MEDCouplingUMesh::New();
+ m1->setMeshDimension(2);
+ m1->allocateCells(1);
+ m1->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,m1Conn);
+ m1->finishInsertingCells();
+ DataArrayDouble *myCoords1=DataArrayDouble::New();
+ myCoords1->alloc(4,2);
+ std::copy(m1Coords,m1Coords+8,myCoords1->getPointer());
+ m1->setCoords(myCoords1);
+ myCoords1->decrRef();
+ //
+ double vec1[3]={0.,0.,1.};
+ double *vec2=new double[2];
+ for(int i=0;i<18;i++)
+ {
+ vec2[0]=3.*cos(M_PI/9.*i);
+ vec2[1]=3.*sin(M_PI/9.*i);
+ MEDCouplingUMesh *m1Cpy=static_cast<MEDCouplingUMesh *>(m1->deepCpy());
+ m1Cpy->translate(vec2);
+ std::vector<int> res;
+ CPPUNIT_ASSERT_THROW(m1Cpy->are2DCellsNotCorrectlyOriented(vec1,false,res),INTERP_KERNEL::Exception);
+ res.clear();
+ m1Cpy->changeSpaceDimension(3);
+ m1Cpy->are2DCellsNotCorrectlyOriented(vec1,false,res);
+ CPPUNIT_ASSERT_EQUAL(1,(int)res.size());
+ CPPUNIT_ASSERT_EQUAL(0,res[0]);
+ m1Cpy->decrRef();
+ }
+ delete [] vec2;
+ //
+ m1->decrRef();
+}
from MEDCoupling import *
import unittest
-from math import pi,e,sqrt
+from math import pi,e,sqrt,cos,sin
from MEDCouplingDataForTest import MEDCouplingDataForTest
class MEDCouplingBasicsTest(unittest.TestCase):
def testCellOrientation1(self):
m=MEDCouplingDataForTest.build2DTargetMesh_1();
- vec=[0.,0.,1.]
+ vec=[0.,0.,-1.]
self.assertRaises(InterpKernelException,m.are2DCellsNotCorrectlyOriented,vec,False);
m.changeSpaceDimension(3);
res1=m.are2DCellsNotCorrectlyOriented(vec,False);
self.assertTrue(len(res1)==0);
- vec[2]=-1.;
+ vec[2]=1.;
res1=m.are2DCellsNotCorrectlyOriented(vec,False);
self.assertEqual(5,len(res1));
#
- vec[2]=1.;
+ vec[2]=-1.;
# connectivity inversion
conn=m.getNodalConnectivity().getValues();
tmp=conn[11];
f2Ptr=f2.getArray().getValues();
#Test to check global reverse in MEDCouplingUMesh::tryToCorrectPolyhedronOrientation
m3=MEDCouplingDataForTest.build2DTargetMesh_1();
- vec=[0.,0.,-1.]
+ vec=[0.,0.,1.]
m3.changeSpaceDimension(3);
ids2=[0,1,2,3,4]
m3.convertToPolyTypes(ids2);
expected6=[3,8,1,7,3,8,3,1,3,1,3,7,3,7,3,8,3,6,0,8,3,6,2,0,3,0,2,8,3,8,2,6,3,7,4,5,3,7,8,4,3,4,8,5,3,5,8,7,3,6,8,4,3,6,7,8,3,4,7,6,3,8,4,0,3,0,4,6,3,6,3,8,3,7,3,6,3,8,0,1,3,1,0,3,3,3,0,8,3,4,1,5,3,4,8,1,3,1,8,5,3,1,7,5,3,0,2,3,3,3,2,8,3,1,4,0,3,3,2,6]
self.assertEqual(expected6,conn.getValues());
pass
+
+ def testAre2DCellsNotCorrectlyOriented1(self):
+ m1Coords=[1.,1.,-1.,-1.,-1.,-1.,1.,-1.]
+ m1Conn=[0,3,1,2]
+ m1=MEDCouplingUMesh.New();
+ m1.setMeshDimension(2);
+ m1.allocateCells(1);
+ m1.insertNextCell(NORM_QUAD4,4,m1Conn[0:4])
+ m1.finishInsertingCells();
+ myCoords1=DataArrayDouble.New();
+ myCoords1.setValues(m1Coords,4,2);
+ m1.setCoords(myCoords1);
+ #
+ vec1=[0.,0.,1.]
+ for i in xrange(18):
+ vec2=[3.*cos(pi/9.*i),3.*sin(pi/9.*i)];
+ m1Cpy=m1.deepCpy();
+ m1Cpy.translate(vec2);
+ self.assertRaises(InterpKernelException,m1Cpy.are2DCellsNotCorrectlyOriented,vec1,False);
+ m1Cpy.changeSpaceDimension(3);
+ res=m1Cpy.are2DCellsNotCorrectlyOriented(vec1,False)
+ self.assertEqual([0],res);
+ pass
+ pass
def setUp(self):
pass