1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "InterpKernelGeo2DElementaryEdge.hxx"
22 #include "InterpKernelException.hxx"
23 #include "InterpKernelGeo2DEdge.hxx"
25 using namespace INTERP_KERNEL;
27 ElementaryEdge::ElementaryEdge(const ElementaryEdge& other):_direction(other._direction),_ptr(other._ptr)
32 ElementaryEdge::~ElementaryEdge()
38 bool ElementaryEdge::isNodeIn(Node *n) const
40 return _ptr->getStartNode()==n || _ptr->getEndNode()==n;
44 * \b WARNING contrary to INTERP_KERNEL::Edge::getBarycenterOfZone method called,
45 * this one is cumulative.
47 void ElementaryEdge::getBarycenterOfZone(double *bary) const
50 _ptr->getBarycenterOfZone(tmp);
63 void ElementaryEdge::fillBounds(Bounds& output) const
65 output.aggregate(_ptr->getBounds());
68 void ElementaryEdge::getAllNodes(std::set<Node *>& output) const
70 output.insert(_ptr->getStartNode());
71 output.insert(_ptr->getEndNode());
74 void ElementaryEdge::getBarycenter(double *bary, double& weigh) const
76 _ptr->getBarycenter(bary);
77 weigh=_ptr->getCurveLength();
80 ElementaryEdge *ElementaryEdge::clone() const
82 return new ElementaryEdge(*this);
85 void ElementaryEdge::initLocations() const
91 * WARNING use this method if and only if this is so that it is completely in/out/on of @param pol.
93 TypeOfEdgeLocInPolygon ElementaryEdge::locateFullyMySelf(const ComposedEdge& pol, TypeOfEdgeLocInPolygon precEdgeLoc) const
95 if(getLoc()!=FULL_UNKNOWN)
98 if(precEdgeLoc==FULL_IN_1)
100 if(getStartNode()->getLoc()==ON_1)
105 else if(getStartNode()->getLoc()==IN_1 || getStartNode()->getLoc()==ON_TANG_1)
111 if(precEdgeLoc==FULL_OUT_1)
113 if(getStartNode()->getLoc()==ON_1)
118 else if(getStartNode()->getLoc()==IN_1 || getStartNode()->getLoc()==ON_TANG_1)
124 if(getStartNode()->getLoc()==IN_1 || getEndNode()->getLoc()==IN_1)
129 if(getStartNode()->getLoc()==OUT_1 || getEndNode()->getLoc()==OUT_1)
134 //a seek is requested
135 return locateFullyMySelfAbsolute(pol);
138 TypeOfEdgeLocInPolygon ElementaryEdge::locateFullyMySelfAbsolute(const ComposedEdge& pol) const
140 Node *node=_ptr->buildRepresentantOfMySelf();
141 if(pol.isInOrOut(node))
149 Node *ElementaryEdge::getEndNode() const
152 return _ptr->getEndNode();
153 else return _ptr->getStartNode();
156 Node *ElementaryEdge::getStartNode() const
159 return _ptr->getStartNode();
161 return _ptr->getEndNode();
164 bool ElementaryEdge::changeEndNodeWith(Node *node) const
167 return _ptr->changeEndNodeWith(node);
169 return _ptr->changeStartNodeWith(node);
172 bool ElementaryEdge::changeStartNodeWith(Node *node) const
175 return _ptr->changeStartNodeWith(node);
177 return _ptr->changeEndNodeWith(node);
180 void ElementaryEdge::dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const
182 _ptr->dumpInXfigFile(stream,_direction,resolution,box);
185 bool ElementaryEdge::intresicEqual(const ElementaryEdge *other) const
187 return _ptr==other->_ptr;
190 bool ElementaryEdge::intresicEqualDirSensitive(const ElementaryEdge *other) const
192 return ( _direction==other->_direction ) && (_ptr==other->_ptr);
195 bool ElementaryEdge::intresincEqCoarse(const Edge *other) const
200 bool ElementaryEdge::isEqual(const ElementaryEdge& other) const
202 return _ptr->isEqual(*other._ptr);
206 * Called by QuadraticPolygon::splitAbs method.
208 void ElementaryEdge::fillGlobalInfoAbs(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
209 std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const
211 _ptr->fillGlobalInfoAbs(_direction,mapThis,mapOther,offset1,offset2,fact,baryX,baryY,edgesThis,addCoo,mapAddCoo);
215 * Called by QuadraticPolygon::splitAbs method. Close to ElementaryEdge::fillGlobalInfoAbs method expect that here edgesOther (that replace edgesThis) is here an in/out parameter that only contains nodes
216 * unsorted because the "other" mesh is not subdivided yet.
218 void ElementaryEdge::fillGlobalInfoAbs2(const std::map<INTERP_KERNEL::Node *,int>& mapThis, const std::map<INTERP_KERNEL::Node *,int>& mapOther, int offset1, int offset2, double fact, double baryX, double baryY,
219 std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const
221 _ptr->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,edgesOther,addCoo,mapAddCoo);
225 * This method builds from descending conn of a quadratic polygon stored in crude mode (MEDCoupling). Descending conn is in FORTRAN relative mode in order to give the
226 * orientation of edge. Called by QuadraticPolygon::buildFromCrudeDataArray.
228 ElementaryEdge *ElementaryEdge::BuildEdgeFromCrudeDataArray(bool direction, INTERP_KERNEL::Node *start, INTERP_KERNEL::Node *end)
230 Edge *ptr=Edge::BuildEdgeFrom(start,end);
231 return new ElementaryEdge(ptr,direction);