]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Intersection 2D1D
authorbph <bph>
Fri, 26 Aug 2011 14:01:20 +0000 (14:01 +0000)
committerbph <bph>
Fri, 26 Aug 2011 14:01:20 +0000 (14:01 +0000)
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DEdge.hxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DElementaryEdge.hxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.hxx
src/INTERP_KERNEL/Geometric2DIntersector.hxx
src/INTERP_KERNEL/Geometric2DIntersector.txx
src/INTERP_KERNEL/Makefile.am
src/INTERP_KERNEL/PlanarIntersector.hxx

index e75778c09f14464b2f60307d253c122343fa340e..5096946099589364d9f58dea28c2843594489f47 100644 (file)
@@ -844,3 +844,8 @@ bool Edge::splitOverlappedEdges(const Edge *e1, const Edge *e2, Node *nS, Node *
       throw Exception("Unexpected situation of overlapping edges : internal error occurs ! ");
     }
 }
+
+bool Edge::isEqual(const Edge& other) const
+{
+  return _start->isEqual(*other._start) && _end->isEqual(*other._end);
+}
index 933a0250e2e72b278fe6722da2fe8f857dee898f..28207b13d586d242ead1ce7bd41257e58c30edcd 100644 (file)
@@ -255,6 +255,7 @@ namespace INTERP_KERNEL
     static void interpolate1DLin(const std::vector<double>& distrib1, const std::vector<double>& distrib2,
                                  std::map<int, std::map<int,double> >& result);
     virtual void dumpInXfigFile(std::ostream& stream, bool direction, int resolution, const Bounds& box) const = 0;
+    bool isEqual(const Edge& other) const;
   protected:
     Edge():_cnt(1),_loc(FULL_UNKNOWN),_start(0),_end(0) { }
     virtual ~Edge();
index 200078ffbc31f7a9fae1b996b2ffb1b20a082a69..4369f24868e8669909ef61ba0306dfcbedf7c497 100644 (file)
@@ -195,3 +195,8 @@ bool ElementaryEdge::intresincEqCoarse(const Edge *other) const
 {
   return _ptr==other;
 }
+
+bool ElementaryEdge::isEqual(const ElementaryEdge& other) const
+{
+  return _ptr->isEqual(*other._ptr);
+}
index 1b0a8ca17aaad3a605f8ccfc1e04fc6a600f81b8..e70dfd0ba1b0145b7aeca1ebc99c57e6ee77674f 100644 (file)
@@ -64,6 +64,7 @@ namespace INTERP_KERNEL
     void dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const;
     bool getDirection() const { return _direction; }
     bool intresincEqCoarse(const Edge *other) const;
+    bool isEqual(const ElementaryEdge& other) const;
   private:
     bool _direction;
     Edge *_ptr;
index 2b6d389932caac901e5366aa7fcf57a22e9b6c94..4efc349d46391cb0360937dcea94fed17e98e6b5 100644 (file)
@@ -207,6 +207,39 @@ double QuadraticPolygon::intersectWithAbs(QuadraticPolygon& other)
   return ret*fact*fact;
 }
 
+/*!
+ * Warning This method is \b NOT const. 'this' and 'other' are modified after call of this method.
+ */
+double QuadraticPolygon::intersectWithAbs1D(QuadraticPolygon& other, bool& isColinear)
+{
+  double ret = 0., xBaryBB, yBaryBB;
+  double fact = normalize(&other, xBaryBB, yBaryBB);
+
+  QuadraticPolygon cpyOfThis(*this);
+  QuadraticPolygon cpyOfOther(other);
+  int nbOfSplits = 0;
+  splitPolygonsEachOther(cpyOfThis, cpyOfOther, nbOfSplits);
+  //At this point cpyOfThis and cpyOfOther have been splited at maximum edge so that in/out can been done.
+  performLocatingOperation(cpyOfOther);
+
+  std::list<QuadraticPolygon *> cpyOfOtherZip = cpyOfOther.zipConsecutiveInSegments();
+
+  isColinear = false;
+  if (cpyOfOtherZip.size() == 1)
+    {
+      QuadraticPolygon& poly = *cpyOfOtherZip.front();
+      if (poly.size() == 2 && poly.front()->isEqual(*poly.back()))
+        isColinear = true;
+    }
+
+  for (std::list<QuadraticPolygon *>::iterator iter = cpyOfOtherZip.begin(); iter != cpyOfOtherZip.end(); iter++)
+    {
+      ret += fabs((*iter)->getPerimeter());
+      delete *iter;
+    }
+  return ret * fact / 2.;
+}
+
 /*!
  * Warning contrary to intersectWith method this method is \b NOT const. 'this' and 'other' are modified after call of this method.
  */
index 7d865782dbeca4b827ef2e3f579fb42152aeb328..5b9e2bc6ee296f7a4afe84056cc6f9a0a43b54c8 100644 (file)
@@ -51,6 +51,7 @@ namespace INTERP_KERNEL
     void dumpInXfigFileWithOther(const ComposedEdge& other, const char *fileName) const;
     //! Before intersecting as intersectWith a normalization is done.
     double intersectWithAbs(QuadraticPolygon& other);
+    double intersectWithAbs1D(QuadraticPolygon& other, bool& isColinear);
     //! Before intersecting as intersectWith a normalization is done.
     double intersectWithAbs(QuadraticPolygon& other, double* barycenter);
     double intersectWith(const QuadraticPolygon& other) const;
index 76b7b51a8590e9c2bb528ccc4568e6a894b1f7de..4385e7046c7beb1f1a8dd6917c179e7344a04ac3 100644 (file)
@@ -42,6 +42,8 @@ namespace INTERP_KERNEL
     Geometric2DIntersector(const MyMeshType& meshT, const MyMeshType& meshS,
                            double dimCaracteristic, double md3DSurf, double medianPlane, double precision, int orientation);
     double intersectGeometry(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS);
+    double intersectGeometry1D(ConnType icellT, ConnType icellS, ConnType nbNodesT, ConnType nbNodesS,
+                               bool& isColinear);
     double intersectGeometryWithQuadrangle(const double *quadrangle, const std::vector<double>& sourceCoords, bool isSourceQuad);
     double intersectGeometryGeneral(const std::vector<double>& targetCoords, const std::vector<double>& sourceCoords);
     double intersectGeoBary(const std::vector<double>& targetCell, bool targetCellQuadratic, const double *sourceCell, std::vector<double>& res);
index 7f2d4767512450b6bb09ef23558f670faeafe87c..7f12f5b63919bcffa04412fd4a6db6549508db86 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "Geometric2DIntersector.hxx"
 #include "PlanarIntersectorP0P0.txx"
+#include "Planar2D1DIntersectorP0P0.txx"
 #include "PlanarIntersectorP0P1.txx"
 #include "PlanarIntersectorP1P0.txx"
 #include "PlanarIntersectorP1P1.txx"
@@ -63,6 +64,24 @@ namespace INTERP_KERNEL
     return ret;
   }
 
+  INTERSECTOR_TEMPLATE
+  double GEO2D_INTERSECTOR::intersectGeometry1D(ConnType icellT,   ConnType icellS,
+                                                ConnType nbNodesT, ConnType nbNodesS,
+                                                bool& isColinear)
+  {
+    int orientation = 1;
+    std::vector<double> CoordsT;
+    std::vector<double> CoordsS;
+    PlanarIntersector<MyMeshType,MyMatrix>::getRealCoordinates(icellT,icellS,nbNodesT,nbNodesS,CoordsT,CoordsS,orientation);
+    NormalizedCellType tT=PlanarIntersector<MyMeshType,MyMatrix>::_meshT.getTypeOfElement(icellT);
+    NormalizedCellType tS=PlanarIntersector<MyMeshType,MyMatrix>::_meshS.getTypeOfElement(icellS);
+    QuadraticPolygon *p1=buildPolygonFrom(CoordsT,tT);
+    QuadraticPolygon *p2=buildPolygonFrom(CoordsS,tS);
+    double ret=p1->intersectWithAbs1D(*p2, isColinear);
+    delete p1; delete p2;
+    return ret;
+  }
+
   INTERSECTOR_TEMPLATE
   double GEO2D_INTERSECTOR::intersectGeometryWithQuadrangle(const double             * quadrangle,
                                                             const std::vector<double>& sourceCoords,
index 5c64b6653823adb892bf413cb43698468e60c5e0..fa7a68c40ac794b1ab5512f9e94e66ba10f611f2 100644 (file)
@@ -51,6 +51,8 @@ Interpolation2D.hxx                   \
 Interpolation2D.txx                    \
 Interpolation3D.hxx                    \
 Interpolation3D.txx                    \
+Interpolation2D1D.hxx           \
+Interpolation2D1D.txx           \
 Interpolation3D2D.hxx                  \
 Interpolation3D2D.txx                  \
 Interpolation3DSurf.hxx                        \
@@ -91,6 +93,8 @@ MeshUtils.hxx                         \
 PointLocatorAlgos.txx                   \
 PlanarIntersector.hxx                  \
 PlanarIntersector.txx                  \
+Planar2D1DIntersectorP0P0.hxx       \
+Planar2D1DIntersectorP0P0.txx       \
 PlanarIntersectorP0P0.hxx              \
 PlanarIntersectorP0P0.txx              \
 PlanarIntersectorP0P1.hxx              \
index 12a3455ad87c44b2e22f363881a95f68f121a791..395ff8b39990f6355b97f33ba46a856d6723399b 100644 (file)
@@ -23,6 +23,9 @@
 #include "TargetIntersector.hxx"
 #include "NormalizedUnstructuredMesh.hxx"
 
+#include <map>
+#include <set>
+
 namespace INTERP_KERNEL
 {
   class TranslationRotationMatrix;
@@ -35,6 +38,7 @@ namespace INTERP_KERNEL
     static const int MESHDIM=MyMeshType::MY_MESHDIM;
     typedef typename MyMeshType::MyConnType ConnType;
     static const NumberingPolicy numPol=MyMeshType::My_numPol;
+    typedef typename std::map<int,std::set<int> > DuplicateFacesType;
   public:
     //! \addtogroup InterpKerGrpIntPlan @{
     PlanarIntersector(const MyMeshType& meshT, const MyMeshType& meshS, double dimCaracteristic, double precision, double md3DSurf, double medianPlane, bool doRotate, int orientation, int printLevel);
@@ -45,6 +49,10 @@ namespace INTERP_KERNEL
     inline void getElemBB(double* bb, const MyMeshType& mesh, ConnType iP, ConnType nb_nodes);
     static int projection(double *Coords_A, double *Coords_B,
                           int nb_NodesA, int nb_NodesB, double epsilon, double md3DSurf, double median_plane, bool do_rotate);
+    virtual const DuplicateFacesType* getIntersectFaces() const
+    {
+      return NULL;
+    }
   protected :
     int projectionThis(double *Coords_A, double *Coords_B, int nb_NodesA, int nb_NodesB);
     void getRealTargetCoordinates(ConnType icellT, std::vector<double>& coordsT);