setCoords(other._coords);
}
+/*!
+ * This method is expecting to be called for meshes so that getSpaceDimension() returns 3.
+ * This method returns in 'nodes' output all the nodes that are at a distance lower than epsilon from plane
+ * defined by the point 'pt' and the vector 'vec'.
+ * @param pt points to an array of size 3 and represents a point that owns to plane.
+ * @param vec points to an array of size 3 and represents the normal vector of the plane. The norm of the vector is not compulsory equal to 1. But norm must be greater than 10*abs(eps)
+ * @param eps is the maximal distance around the plane where node in this->_coords will be picked.
+ * @param nodes is the output of the method. The vector is not compulsory empty before call. The nodes that fulfills the condition will be added at the end of the nodes.
+ */
+void MEDCouplingPointSet::findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector<int>& nodes) const throw(INTERP_KERNEL::Exception)
+{
+ if(getSpaceDimension()!=3)
+ throw INTERP_KERNEL::Exception("Invalid spacedim to be applied on this ! Must be equal to 3 !");
+ int nbOfNodes=getNumberOfNodes();
+ double a=vec[0],b=vec[1],c=vec[2],d=-pt[0]*vec[0]-pt[1]*vec[1]-pt[2]*vec[2];
+ double deno=sqrt(a*a+b*b+c*c);
+ const double *work=_coords->getConstPointer();
+ for(int i=0;i<nbOfNodes;i++)
+ {
+ if(std::abs(a*work[0]+b*work[1]+c*work[2]+d)/deno<eps)
+ nodes.push_back(i);
+ work+=3;
+ }
+}
+
/*!
* merge _coords arrays of m1 and m2 and returns the union. The returned instance is newly created with ref count == 1.
*/
void translate(const double *vector);
void scale(const double *point, double factor);
void tryToShareSameCoords(const MEDCouplingPointSet& other, double epsilon) throw(INTERP_KERNEL::Exception);
+ void findNodesOnPlane(const double *pt, const double *vec, double eps, std::vector<int>& nodes) const throw(INTERP_KERNEL::Exception);
static DataArrayDouble *mergeNodesArray(const MEDCouplingPointSet *m1, const MEDCouplingPointSet *m2);
static MEDCouplingPointSet *buildInstanceFromMeshType(MEDCouplingMeshType type);
static void rotate2DAlg(const double *center, double angle, int nbNodes, double *coords);
static void rotate3DAlg(const double *center, const double *vect, double angle, int nbNodes, double *coords);
virtual MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const = 0;
virtual MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0;
+ virtual MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const = 0;
virtual void findBoundaryNodes(std::vector<int>& nodes) const = 0;
virtual MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const = 0;
virtual void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
return buildPartOfMySelf(&cellIdsKept[0],&cellIdsKept[0]+cellIdsKept.size(),true);
}
+/*!
+ * Contrary to MEDCouplingUMesh::buildPartOfMySelfNode method this method a mesh with a meshDimension equal to
+ * this->getMeshDimension()-1. The return newly allocated mesh will share the same coordinates as 'this'.
+ * Parameter 'fullyIn' specifies if a face that has part of its nodes in ids array is kept or not.
+ * If 'fullyIn' is true only faces whose ids are \b fully contained in ['start','end') tab will be kept.
+ */
+MEDCouplingPointSet *MEDCouplingUMesh::buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const
+{
+ DataArrayInt *desc,*descIndx,*revDesc,*revDescIndx;
+ desc=DataArrayInt::New(); descIndx=DataArrayInt::New(); revDesc=DataArrayInt::New(); revDescIndx=DataArrayInt::New();
+ MEDCouplingUMesh *subMesh=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
+ desc->decrRef(); descIndx->decrRef(); revDesc->decrRef(); revDescIndx->decrRef();
+ MEDCouplingUMesh *ret=(MEDCouplingUMesh *)subMesh->buildPartOfMySelfNode(start,end,fullyIn);
+ subMesh->decrRef();
+ return ret;
+}
+
/*!
* This method returns a mesh with meshDim=this->getMeshDimension()-1.
* This returned mesh contains cells that are linked with one and only one cell of this.
MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged);
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const;
+ MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const;
MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector<int>& nodes) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
return 0;
}
+MEDCouplingPointSet *MEDCouplingUMeshDesc::buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const
+{
+ //not implemented yet
+ return 0;
+}
+
void MEDCouplingUMeshDesc::findBoundaryNodes(std::vector<int>& nodes) const
{
//not implemented yet
MEDCOUPLING_EXPORT DataArrayInt *mergeNodes(double precision, bool& areNodesMerged);
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelf(const int *start, const int *end, bool keepCoords) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildPartOfMySelfNode(const int *start, const int *end, bool fullyIn) const;
+ MEDCOUPLING_EXPORT MEDCouplingPointSet *buildFacePartOfMySelfNode(const int *start, const int *end, bool fullyIn) const;
MEDCOUPLING_EXPORT void findBoundaryNodes(std::vector<int>& nodes) const;
MEDCOUPLING_EXPORT MEDCouplingPointSet *buildBoundaryMesh(bool keepCoords) const;
MEDCOUPLING_EXPORT void renumberNodes(const int *newNodeNumbers, int newNbOfNodes);
CPPUNIT_TEST( testCMesh0 );
CPPUNIT_TEST( testScale );
CPPUNIT_TEST( testTryToShareSameCoords );
+ CPPUNIT_TEST( testFindNodeOnPlane );
CPPUNIT_TEST( test2DInterpP0P0_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_1 );
CPPUNIT_TEST( test2DInterpP0P0PL_2 );
void testCMesh0();
void testScale();
void testTryToShareSameCoords();
+ void testFindNodeOnPlane();
void test2DInterpP0P0_1();
void test2DInterpP0P0PL_1();
void test2DInterpP0P0PL_2();
void MEDCouplingBasicsTest::testTryToShareSameCoords()
{
+ MEDCouplingUMesh *m1=build2DTargetMesh_1();
+ MEDCouplingUMesh *m2=build2DTargetMesh_1();
+ CPPUNIT_ASSERT(m1->getCoords()!=m2->getCoords());
+ m1->tryToShareSameCoords(*m2,1e-12);
+ CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords());
+ m1->tryToShareSameCoords(*m2,1e-12);
+ CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords());
+ m2->tryToShareSameCoords(*m1,1e-12);
+ CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords());
+ m1->decrRef();
+ m2->decrRef();
+ //
+ m1=build2DTargetMesh_1();
+ m2=build2DTargetMesh_2();
+ CPPUNIT_ASSERT(m1->getCoords()!=m2->getCoords());
+ m1->tryToShareSameCoords(*m2,1e-12);
+ CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords());
+ m1->tryToShareSameCoords(*m2,1e-12);
+ CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords());
+ m2->tryToShareSameCoords(*m1,1e-12);
+ CPPUNIT_ASSERT(m1->getCoords()==m2->getCoords());
+ m1->decrRef();
+ m2->decrRef();
+ //
+ m1=build2DTargetMesh_1();
+ m2=build2DSourceMesh_1();
+ CPPUNIT_ASSERT(m1->getCoords()!=m2->getCoords());
+ CPPUNIT_ASSERT_THROW(m1->tryToShareSameCoords(*m2,1e-12),INTERP_KERNEL::Exception);
+ m1->decrRef();
+ m2->decrRef();
+}
+
+void MEDCouplingBasicsTest::testFindNodeOnPlane()
+{
+
}