for(std::size_t i=0;i<sz;i++)
{
double tmp[2];
- edges[(i+1)%sz]->getMiddleOfPoints(coo+2*conn[i],coo+2*conn[(i+1)%sz],tmp);
+ edges[(i+1)%sz]->getMiddleOfPoints(coo+2*conn[i],coo+2*conn[(i+1)%sz],tmp);// tony a chier i+1 -> i
addCoo.insert(addCoo.end(),tmp,tmp+2);
conn2.push_back(offset+(int)i);
}
/*!
* \b WARNING edges in out1 coming from \a splitMesh1D are \b NOT oriented because only used for equation of curve.
+ *
+ * This method cuts in 2 parts the input 2D cell given using boundaries description (\a edge1Bis and \a edge1BisPtr) using
+ * a set of edges defined in \a splitMesh1D.
*/
void BuildMesh2DCutInternal2(const MEDCouplingUMesh *splitMesh1D, const std::vector<int>& edge1Bis, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& edge1BisPtr,
std::vector< std::vector<int> >& out0, std::vector< std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > >& out1)
for(std::size_t k=ii;k<jj+1;k++)
{ connOutLeft.push_back(edge1Bis[2*k+1]); eleft.push_back(edge1BisPtr[2*k+1]); }
std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> > ees(iEnd);
- for(int ik=iEnd-1;ik>=0;ik--)
+ for(int ik=0;ik<iEnd;ik++)
{
std::map< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Node>,int> m;
MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> ee(MEDCouplingUMeshBuildQPFromEdge2((INTERP_KERNEL::NormalizedCellType)cSplitPtr[ciSplitPtr[ik]],cSplitPtr+ciSplitPtr[ik]+1,splitMesh1D->getCoords()->begin(),m));
- ees[iEnd-1-ik]=ee;
+ ees[ik]=ee;
}
for(int ik=iEnd-1;ik>=0;ik--)
connOutLeft.push_back(cSplitPtr[ciSplitPtr[ik]+1]);
for(std::size_t k=jj+1;k<nbOfEdgesOf2DCellSplit+ii;k++)
{ connOutRight.push_back(edge1Bis[2*k+1]); eright.push_back(edge1BisPtr[2*k+1]); }
- eleft.insert(eleft.end(),ees.begin(),ees.end());
+ eleft.insert(eleft.end(),ees.rbegin(),ees.rend());
for(int ik=0;ik<iEnd;ik++)
connOutRight.push_back(cSplitPtr[ciSplitPtr[ik]+2]);
- eright.insert(eright.end(),ees.rbegin(),ees.rend());
+ eright.insert(eright.end(),ees.begin(),ees.end());
}
}
for(std::size_t i=0;i<nbe;i++)
{
edges2[2*i]=edges[i]; edges2[2*i+1]=edges[(i+1)%nbe];
- edgesPtr2[2*i]=edgesPtr[i]; edgesPtr2[2*i+1]=edgesPtr[i];
+ edgesPtr2[2*i]=edgesPtr[(i+1)%nbe]; edgesPtr2[2*i+1]=edgesPtr[(i+1)%nbe];//tony a chier
}
_edges.resize(4*nbe); _edges_ptr.resize(4*nbe);
std::copy(edges2.begin(),edges2.end(),_edges.begin()); std::copy(edges2.begin(),edges2.end(),_edges.begin()+2*nbe);
for(std::size_t j=0;j<sz;j++)
pool[pos+j]=CellInfo(edges[j],edgePtrs[j]);
for(int i=pos+1;i<(int)_pool.size();i++)
- pool[pos+sz-1]=_pool[i];
+ pool[i+sz-1]=_pool[i];
_pool=pool;
//
if(sz==2)
return _pool[pos];
}
+/*!
+ * Given :
+ * - a \b closed set of edges ( \a allEdges and \a allEdgesPtr ) that defines the split descending 2D cell.
+ * - \a splitMesh1D a split 2D curve mesh contained into 2D cell defined above.
+ *
+ * This method returns the 2D mesh and feeds \a idsLeftRight using offset.
+ *
+ * Algorithm : \a splitMesh1D is cut into contiguous parts. Each contiguous parts will build incrementally the output 2D cells.
+ *
+ * \param [in] allEdges a list of pairs (beginNode, endNode). Linked with \a allEdgesPtr to get the equation of edge.
+ */
MEDCouplingUMesh *BuildMesh2DCutInternal(double eps, const MEDCouplingUMesh *splitMesh1D, const std::vector<int>& allEdges, const std::vector< MEDCouplingAutoRefCountObjectPtr<INTERP_KERNEL::Edge> >& allEdgesPtr, int offset,
MEDCouplingAutoRefCountObjectPtr<DataArrayInt>& idsLeftRight)
{
from MEDCouplingDataForTest import MEDCouplingDataForTest
import rlcompleter,readline # this line has to be here, to ensure a usability of MEDCoupling/MEDLoader. B4 removing it please notify to anthony.geay@cea.fr
-class MEDCouplingBasicsTest(unittest.TestCase):
+class MEDCouplingBasicsTest:
def testArray2(self):
arr=DataArrayDouble.New()
arr.setValues([12.,11.,10.,9.,8.,7.,6.,5.,4.,3.,2.,1.],3,4)
self.assertEqual(amr[1][0].getBLTRRangeRelativeToGF(),[(9,15),(21,24)])
pass
+class MEDCouplingBasicsTest(unittest.TestCase):
def testSwig2Intersect2DMeshWith1DLine1(self):
"""A basic test with no colinearity between m1 and m2."""
i=MEDCouplingIMesh("mesh",2,[5,5],[0.,0.],[1.,1.])
self.assertTrue(a.getCoords().getHiddenCppPointer()==b.getCoords().getHiddenCppPointer())
self.assertEqual([0, 0], c.getValues())
self.assertEqual([-1, -1, 0, 1, -1, -1], d.getValues())
-
+#class MEDCouplingBasicsTest(unittest.TestCase):
def testSwig2Intersect2DMeshWith1DLine11(self):
""" Quad line re-entering a square cell """
eps = 1.0e-8
m_line = MEDCouplingUMesh.New("seg", 1)
m_line.setCoords(DataArrayDouble(coords2, len(coords2)/2, 2))
m_line.setConnectivity(DataArrayInt(connec2), DataArrayInt(cI2))
-
-# m_line2 = m_line.deepCpy()
-# m2 = m.deepCpy()
-# m_line2.tessellate2DCurve(0.1)
-# m2.tessellate2D(0.1)
-# m_line2.writeVTK("/tmp/m1d_11.vtu")
-# m2.writeVTK("/tmp/m2d_11.vtu")
-
+
a, b, c, d = MEDCouplingUMesh.Intersect2DMeshWith1DLine(m, m_line, eps)
-# a.mergeNodes(1.0e-8)
-# a.tessellate2D(0.1)
-# b.tessellate2DCurve(0.1)
-# a.writeVTK("/tmp/m2d_fine_11.vtu")
-# b.writeVTK("/tmp/m1d_fine_11.vtu")
-
- self.assertEqual([], a.getNodalConnectivity().getValues())
- self.assertEqual([], a.getNodalConnectivityIndex().getValues())
- self.assertEqual([], b.getNodalConnectivity().getValues())
- self.assertEqual([], b.getNodalConnectivityIndex().getValues())
- self.assertTrue(a.getCoords()[:8].isEqual(m.getCoords(),1e-12))
- self.assertTrue(a.getCoords()[8:10].isEqual(m_line.getCoords(),1e-12))
- coo_tgt = DataArrayDouble([])
- self.assertTrue(a.getCoords().isEqualWithoutConsideringStr(coo_tgt, 1.0e-12))
self.assertTrue(a.getCoords().getHiddenCppPointer()==b.getCoords().getHiddenCppPointer())
- self.assertEqual([], c.getValues())
- self.assertEqual([], d.getValues())
+ self.assertEqual([32,9,11,2,3,12,10,29,30,31,32,33,34,32,0,10,12,35,36,37,32,1,11,9,26,27,28],a.getNodalConnectivity().getValues())
+ self.assertEqual([0,13,20,27],a.getNodalConnectivityIndex().getValues())
+ self.assertEqual([2,4,11,13,2,11,9,14,2,9,5,15,2,5,10,16,2,10,12,17,2,12,7,18],b.getNodalConnectivity().getValues())
+ self.assertEqual([0,4,8,12,16,20,24],b.getNodalConnectivityIndex().getValues())
+ self.assertTrue(a.getCoords()[:4].isEqual(m.getCoords(),1e-12))
+ self.assertTrue(a.getCoords()[4:9].isEqual(m_line.getCoords(),1e-12))
+ self.assertTrue(DataArrayInt([0,0,0]).isEqual(c))
+ self.assertTrue(DataArrayInt([(-1,-1),(0,2),(-1,-1),(-1,-1),(0,1),(-1,-1)]).isEqual(d))
pass
-
+
+class MEDCouplingBasicsTest2:
def testSwig2Intersect2DMeshWith1DLine12(self):
""" Two squares one in the other intersected by an horizontal line """
eps = 1.0e-8
self.assertEqual([], d.getValues())
pass
+class MEDCouplingBasicsTest2:
def testOrderConsecutiveCells1D1(self):
"""A line in several unconnected pieces:"""
m2 = MEDCouplingUMesh.New("bla", 1)