return sqrt(X*X+Y*Y);
}
+ inline void mid_of_seg2(const double P1[2], const double P2[2], double MID[2])
+ {
+ MID[0]=(P1[0]+P2[0])/2.;
+ MID[1]=(P1[1]+P1[1])/2.;
+ }
+
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
/* calcul le cos et le sin de l'angle P1P2,P1P3 */
/*_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ */
#define _MEDCOUPLING_HXX_
#ifdef WIN32
-# if defined(medcoupling_EXPORTS) || defined(medcouplingcpp_EXPORTS) || defined(MEDCOUPLING_WIN32_SWIG)
+# if defined(medcoupling_EXPORTS) || defined(medcouplingcpp_EXPORTS)
# define MEDCOUPLING_EXPORT __declspec( dllexport )
# else
# define MEDCOUPLING_EXPORT __declspec( dllimport )
baseOfPlane[6]=normalVector[0]/ni; baseOfPlane[7]=normalVector[1]/ni; baseOfPlane[8]=normalVector[2]/ni;
}
+/*!
+ * \param [in] seg2 : coordinates of input seg2 expected to have spacedim==2
+ * \param [in] tri3 : coordinates of input tri3 also expected to have spacedim==2
+ * \param [out] coeffs : the result of integration normalized to 1. along \a seg2 inside tri3 sorted by the node id of \a tri3
+ * \param [out] length : the length of seg2. That is too say the length of integration
+ */
+void DataArrayDouble::ComputeIntegralOfSeg2IntoTri3(const double seg2[4], const double tri3[6], double coeffs[3], double& length)
+{
+ length=INTERP_KERNEL::norme_vecteur(seg2,seg2+2);
+ constexpr double eps(std::numeric_limits<double>::min());
+ double n2(INTERP_KERNEL::norme_vecteur(tri3,tri3+2));
+ n2=std::min(n2,INTERP_KERNEL::norme_vecteur(tri3+2,tri3+4)); n2=std::min(n2,INTERP_KERNEL::norme_vecteur(tri3+4,tri3));
+ double myeps(eps*n2);
+ if(length>myeps*1000.)
+ {
+ constexpr unsigned NB_EVAL=10;
+ constexpr double NB_EVAL_FL=(double)NB_EVAL;
+ constexpr double INTEG_LEN(1./NB_EVAL_FL);
+ double curPt[2],curBaryCoo[3];
+ double dirVect[2]={seg2[2]-seg2[0],seg2[3]-seg2[1]};
+ coeffs[0]=0.; coeffs[1]=0.; coeffs[2]=0.;
+ for(unsigned i=0;i<NB_EVAL;i++)
+ {
+ curPt[0]=seg2[0]+(0.5+(double)i)*INTEG_LEN*dirVect[0];
+ curPt[1]=seg2[1]+(0.5+(double)i)*INTEG_LEN*dirVect[1];
+ INTERP_KERNEL::barycentric_coords<2>(tri3,curPt,curBaryCoo);
+ curBaryCoo[0]*=INTEG_LEN; curBaryCoo[1]*=INTEG_LEN; curBaryCoo[2]*=INTEG_LEN;
+ coeffs[0]+=curBaryCoo[0]; coeffs[1]+=curBaryCoo[1]; coeffs[2]+=curBaryCoo[2];
+ }
+ }
+ else
+ {
+ double mid[2];
+ INTERP_KERNEL::mid_of_seg2(seg2,seg2+2,mid);
+ INTERP_KERNEL::barycentric_coords<2>(tri3,mid,coeffs);
+ }
+}
+
/*!
* Low static method that operates 3D rotation of \a nbNodes 3D nodes whose coordinates are arranged in \a coords
* around the center point \a center and with angle \a angle.
MEDCOUPLING_EXPORT static void Rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, const double *coordsIn, double *coordsOut);
MEDCOUPLING_EXPORT static void Symmetry3DPlane(const double point[3], const double normalVector[3], int nbNodes, const double *coordsIn, double *coordsOut);
MEDCOUPLING_EXPORT static void GiveBaseForPlane(const double normalVector[3], double baseOfPlane[9]);
+ MEDCOUPLING_EXPORT static void ComputeIntegralOfSeg2IntoTri3(const double seg2[4], const double tri3[6], double coeffs[3], double& length);
public:
MEDCOUPLING_EXPORT void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
MEDCOUPLING_EXPORT void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
return convertDblArrToPyListOfTuple<double>(vals,nbOfComp,nbOfTuples);
}
+ static PyObject *ComputeIntegralOfSeg2IntoTri3(PyObject *seg2, PyObject *tri3) throw(INTERP_KERNEL::Exception)
+ {
+ const char msg[]="Python wrap of DataArrayDouble::ComputeIntegralOfSeg2IntoTri3 : ";
+ double val,val2;
+ DataArrayDouble *a,*a2;
+ DataArrayDoubleTuple *aa,*aa2;
+ std::vector<double> bb,bb2;
+ int sw;
+ const double *seg2Ptr(convertObjToPossibleCpp5_Safe(seg2,sw,val,a,aa,bb,msg,2,2,true));
+ const double *tri3Ptr(convertObjToPossibleCpp5_Safe(tri3,sw,val2,a2,aa2,bb2,msg,3,2,true));
+ //
+ double res0[3],res1;
+ DataArrayDouble::ComputeIntegralOfSeg2IntoTri3(seg2Ptr,tri3Ptr,res0,res1);
+ PyObject *ret(PyTuple_New(2)),*ret0(PyTuple_New(3));
+ PyTuple_SetItem(ret0,0,PyFloat_FromDouble(res0[0]));
+ PyTuple_SetItem(ret0,1,PyFloat_FromDouble(res0[1]));
+ PyTuple_SetItem(ret0,2,PyFloat_FromDouble(res0[2]));
+ PyTuple_SetItem(ret,0,ret0);
+ PyTuple_SetItem(ret,1,PyFloat_FromDouble(res1));
+ return ret;
+ }
+
DataArrayDouble *symmetry3DPlane(PyObject *point, PyObject *normalVector) throw(INTERP_KERNEL::Exception)
{
const char msg[]="Python wrap of DataArrayDouble::symmetry3DPlane : ";