template<class MyMeshType, class MyMatrix>
void PolyhedronIntersectorP0P0<MyMeshType,MyMatrix>::intersectCells(ConnType targetCell, const std::vector<ConnType>& srcCells, MyMatrix& res)
{
- int nbOfNodesT=Intersector3D<MyMeshType,MyMatrix>::_target_mesh.getNumberOfNodesOfElement(OTT<ConnType,numPol>::indFC(targetCell));
releaseArrays();
- _split.splitTargetCell(targetCell,nbOfNodesT,_tetra);
+ _split.splitTargetCell2(targetCell,_tetra);
for(typename std::vector<ConnType>::const_iterator iterCellS=srcCells.begin();iterCellS!=srcCells.end();iterCellS++)
{
double volume = 0.;
SplitterTetra(const MyMeshType& srcMesh, const double** tetraCorners, const typename MyMeshType::MyConnType *nodesId);
+ SplitterTetra(const MyMeshType& srcMesh, const double tetraCorners[12]);
+
~SplitterTetra();
double intersectSourceCell(typename MyMeshType::MyConnType srcCell, double* baryCentre=0);
SplitterTetra2(const MyMeshTypeT& targetMesh, const MyMeshTypeS& srcMesh, SplittingPolicy policy);
~SplitterTetra2();
void releaseArrays();
+ void splitTargetCell2(typename MyMeshTypeT::MyConnType targetCell, typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);
void splitTargetCell(typename MyMeshTypeT::MyConnType targetCell, typename MyMeshTypeT::MyConnType nbOfNodesT,
- typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);
- void fiveSplit(const int* const subZone, typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);
- void sixSplit(const int* const subZone, typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);
- void calculateGeneral24Tetra(typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);
- void calculateGeneral48Tetra(typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);
- void splitPyram5(typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);
- void splitConvex(typename MyMeshTypeT::MyConnType targetCell,
- typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);
- void calculateSubNodes(const MyMeshTypeT& targetMesh, typename MyMeshTypeT::MyConnType targetCell);
- inline const double* getCoordsOfSubNode(typename MyMeshTypeT::MyConnType node);
- inline const double* getCoordsOfSubNode2(typename MyMeshTypeT::MyConnType node, typename MyMeshTypeT::MyConnType& nodeId);
+ typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);//to suppress
+ void fiveSplit(const int* const subZone, typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);//to suppress
+ void sixSplit(const int* const subZone, typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);//to suppress
+ void calculateGeneral24Tetra(typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);//to suppress
+ void calculateGeneral48Tetra(typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);//to suppress
+ void splitPyram5(typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);//to suppress
+ void splitConvex(typename MyMeshTypeT::MyConnType targetCell,//to suppress
+ typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra);//to suppress
+ void calculateSubNodes(const MyMeshTypeT& targetMesh, typename MyMeshTypeT::MyConnType targetCell);//to suppress
+ inline const double* getCoordsOfSubNode(typename MyMeshTypeT::MyConnType node);//to suppress
+ inline const double* getCoordsOfSubNode2(typename MyMeshTypeT::MyConnType node, typename MyMeshTypeT::MyConnType& nodeId);//to suppress
//template<int n>
- inline void calcBarycenter(int n, double* barycenter, const typename MyMeshTypeT::MyConnType* pts);
+ inline void calcBarycenter(int n, double* barycenter, const typename MyMeshTypeT::MyConnType* pts);//to suppress
private:
const MyMeshTypeT& _target_mesh;
const MyMeshTypeS& _src_mesh;
// create the affine transform
_t=new TetraAffineTransform(_coords);
}
+
+ /**
+ * SplitterTetra class computes for a list of cell ids of a given mesh \a srcMesh (badly named) the intersection with a
+ * single TETRA4 cell given by \a tetraCorners (of length 4) and \a nodesId (of length 4 too). \a nodedIds is given only to establish
+ * if a partial computation of a triangle has already been performed (to increase performance).
+ *
+ * The \a srcMesh can contain polyhedron cells.
+ *
+ *
+ * Constructor creating object from the four corners of the tetrahedron.
+ *
+ * \param [in] srcMesh mesh containing the source elements
+ * \param [in] tetraCorners array 4*3 doubles containing corners of input tetrahedron (P0X,P0Y,P0Y,P1X,P1Y,P1Z,P2X,P2Y,P2Z,P3X,P3Y,P3Z).
+ */
+ template<class MyMeshType>
+ SplitterTetra<MyMeshType>::SplitterTetra(const MyMeshType& srcMesh, const double tetraCorners[12]): _t(0),_src_mesh(srcMesh)
+ {
+ _conn[0]=0; _conn[1]=1; _conn[2]=2; _conn[3]=3;
+ _coords[0]=tetraCorners[0]; _coords[1]=tetraCorners[1]; _coords[2]=tetraCorners[2]; _coords[3]=tetraCorners[3]; _coords[4]=tetraCorners[4]; _coords[5]=tetraCorners[5];
+ _coords[6]=tetraCorners[6]; _coords[7]=tetraCorners[7]; _coords[8]=tetraCorners[8]; _coords[9]=tetraCorners[9]; _coords[10]=tetraCorners[10]; _coords[11]=tetraCorners[11];
+ // create the affine transform
+ _t=new TetraAffineTransform(_coords);
+ }
/**
* Destructor
}
_nodes.clear();
}
+
+ /*!
+ * \param [in] targetCell in C mode.
+ * \param [out] tetra is the output result tetra containers.
+ */
+ template<class MyMeshTypeT, class MyMeshTypeS>
+ void SplitterTetra2<MyMeshTypeT, MyMeshTypeS>::splitTargetCell2(typename MyMeshTypeT::MyConnType targetCell, typename std::vector< SplitterTetra<MyMeshTypeS>* >& tetra)
+ {
+ const int *refConn(_target_mesh.getConnectivityPtr());
+ const int *cellConn(refConn+_target_mesh.getConnectivityIndexPtr()[targetCell]);
+ INTERP_KERNEL::NormalizedCellType gt(_target_mesh.getTypeOfElement(targetCell));
+ std::vector<int> tetrasNodalConn;
+ std::vector<double> addCoords;
+ const double *coords(_target_mesh.getCoordinatesPtr());
+ SplitIntoTetras(_splitting_pol,gt,cellConn,refConn+_target_mesh.getConnectivityIndexPtr()[targetCell+1],coords,tetrasNodalConn,addCoords);
+ std::size_t nbTetras(tetrasNodalConn.size()/4); tetra.resize(nbTetras);
+ double tmp[12];
+ for(std::size_t i=0;i<nbTetras;i++)
+ {
+ for(int j=0;j<4;j++)
+ {
+ int cellId(tetrasNodalConn[4*i+j]);
+ if(cellId>=0)
+ {
+ tmp[j*3+0]=coords[3*cellId+0];
+ tmp[j*3+1]=coords[3*cellId+1];
+ tmp[j*3+2]=coords[3*cellId+2];
+ }
+ else
+ {
+ tmp[j*3+0]=addCoords[3*(-cellId-1)+0];
+ tmp[j*3+1]=addCoords[3*(-cellId-1)+1];
+ tmp[j*3+2]=addCoords[3*(-cellId-1)+2];
+ }
+ }
+ tetra[i]=new SplitterTetra<MyMeshTypeS>(_src_mesh,tmp);
+ }
+ }
/*!
* @param targetCell in C mode.
MEDCouplingNormalizedCartesianMesh(const ParaMEDMEM::MEDCouplingCMesh *mesh);
//void getBoundingBox(double *boundingBox) const;
//INTERP_KERNEL::NormalizedCellType getTypeOfElement(int eltId) const;
- //unsigned char getNumberOfNodesOfElement(int eltId) const;
- //unsigned long getNumberOfNodes() const;
+ //int getNumberOfNodesOfElement(int eltId) const;
+ //int getNumberOfNodes() const;
unsigned long getNumberOfElements() const;
unsigned long nbCellsAlongAxis(int axis) const;
const double * getCoordsAlongAxis(int axis) const;
MEDCouplingNormalizedUnstructuredMesh(const ParaMEDMEM::MEDCouplingUMesh *mesh);
void getBoundingBox(double *boundingBox) const;
INTERP_KERNEL::NormalizedCellType getTypeOfElement(int eltId) const;
- unsigned char getNumberOfNodesOfElement(int eltId) const;
- unsigned long getNumberOfElements() const;
- unsigned long getNumberOfNodes() const;
+ int getNumberOfNodesOfElement(int eltId) const;
+ int getNumberOfElements() const;
+ int getNumberOfNodes() const;
const int *getConnectivityPtr() const;
const double *getCoordinatesPtr() const;
const int *getConnectivityIndexPtr() const;
}
template<int SPACEDIM,int MESHDIM>
-unsigned char MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodesOfElement(int eltId) const
+int MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodesOfElement(int eltId) const
{
return _mesh->getNumberOfNodesInCell(eltId);
}
template<int SPACEDIM,int MESHDIM>
-unsigned long MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfElements() const
+int MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfElements() const
{
return _mesh->getNumberOfCells();
}
template<int SPACEDIM,int MESHDIM>
-unsigned long MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodes() const
+int MEDCouplingNormalizedUnstructuredMesh<SPACEDIM,MESHDIM>::getNumberOfNodes() const
{
return _mesh->getNumberOfNodes();
}
std::vector<std::map<int,double> > matrx(remapper.getCrudeMatrix());
CPPUNIT_ASSERT_EQUAL(1,(int)matrx.size());
CPPUNIT_ASSERT_EQUAL(1,(int)matrx[0].size());
- std::cerr << std::endl << matrx[0][0] << std::endl;
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(valExpected,matrx[0][0],1e-13);
//
srcMesh->decrRef(); trgMesh->decrRef();
}