1 // Copyright (C) 2007-2012 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
20 #include "InterpKernelGeo2DElementaryEdge.hxx"
21 #include "InterpKernelException.hxx"
22 #include "InterpKernelGeo2DEdge.hxx"
24 using namespace INTERP_KERNEL;
26 ElementaryEdge::ElementaryEdge(const ElementaryEdge& other):_direction(other._direction),_ptr(other._ptr)
31 ElementaryEdge::~ElementaryEdge()
37 bool ElementaryEdge::isNodeIn(Node *n) const
39 return _ptr->getStartNode()==n || _ptr->getEndNode()==n;
43 * \b WARNING contrary to INTERP_KERNEL::Edge::getBarycenterOfZone method called,
44 * this one is cumulative.
46 void ElementaryEdge::getBarycenterOfZone(double *bary) const
49 _ptr->getBarycenterOfZone(tmp);
62 void ElementaryEdge::fillBounds(Bounds& output) const
64 output.aggregate(_ptr->getBounds());
67 void ElementaryEdge::getAllNodes(std::set<Node *>& output) const
69 output.insert(_ptr->getStartNode());
70 output.insert(_ptr->getEndNode());
73 void ElementaryEdge::getBarycenter(double *bary, double& weigh) const
75 _ptr->getBarycenter(bary);
76 weigh=_ptr->getCurveLength();
79 ElementaryEdge *ElementaryEdge::clone() const
81 return new ElementaryEdge(*this);
84 void ElementaryEdge::initLocations() const
90 * WARNING use this method if and only if this is so that it is completely in/out/on of @param pol.
92 TypeOfEdgeLocInPolygon ElementaryEdge::locateFullyMySelf(const ComposedEdge& pol, TypeOfEdgeLocInPolygon precEdgeLoc) const
94 if(getLoc()!=FULL_UNKNOWN)
97 if(precEdgeLoc==FULL_IN_1)
99 if(getStartNode()->getLoc()==ON_1)
104 else if(getStartNode()->getLoc()==IN_1 || getStartNode()->getLoc()==ON_TANG_1)
110 if(precEdgeLoc==FULL_OUT_1)
112 if(getStartNode()->getLoc()==ON_1)
117 else if(getStartNode()->getLoc()==IN_1 || getStartNode()->getLoc()==ON_TANG_1)
123 if(getStartNode()->getLoc()==IN_1 || getEndNode()->getLoc()==IN_1)
128 if(getStartNode()->getLoc()==OUT_1 || getEndNode()->getLoc()==OUT_1)
133 //a seek is requested
134 return locateFullyMySelfAbsolute(pol);
137 TypeOfEdgeLocInPolygon ElementaryEdge::locateFullyMySelfAbsolute(const ComposedEdge& pol) const
139 Node *node=_ptr->buildRepresentantOfMySelf();
140 if(pol.isInOrOut(node))
148 Node *ElementaryEdge::getEndNode() const
151 return _ptr->getEndNode();
152 else return _ptr->getStartNode();
155 Node *ElementaryEdge::getStartNode() const
158 return _ptr->getStartNode();
160 return _ptr->getEndNode();
163 bool ElementaryEdge::changeEndNodeWith(Node *node) const
166 return _ptr->changeEndNodeWith(node);
168 return _ptr->changeStartNodeWith(node);
171 bool ElementaryEdge::changeStartNodeWith(Node *node) const
174 return _ptr->changeStartNodeWith(node);
176 return _ptr->changeEndNodeWith(node);
179 void ElementaryEdge::dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const
181 _ptr->dumpInXfigFile(stream,_direction,resolution,box);
184 bool ElementaryEdge::intresicEqual(const ElementaryEdge *other) const
186 return _ptr==other->_ptr;
189 bool ElementaryEdge::intresicEqualDirSensitive(const ElementaryEdge *other) const
191 return ( _direction==other->_direction ) && (_ptr==other->_ptr);
194 bool ElementaryEdge::intresincEqCoarse(const Edge *other) const
199 bool ElementaryEdge::isEqual(const ElementaryEdge& other) const
201 return _ptr->isEqual(*other._ptr);
205 * Called by QuadraticPolygon::splitAbs method.
207 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,
208 std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const
210 _ptr->fillGlobalInfoAbs(_direction,mapThis,mapOther,offset1,offset2,fact,baryX,baryY,edgesThis,addCoo,mapAddCoo);
214 * 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
215 * unsorted because the "other" mesh is not subdivided yet.
217 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,
218 std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const
220 _ptr->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,edgesOther,addCoo,mapAddCoo);
224 * 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
225 * orientation of edge. Called by QuadraticPolygon::buildFromCrudeDataArray.
227 ElementaryEdge *ElementaryEdge::BuildEdgeFromCrudeDataArray(bool direction, INTERP_KERNEL::Node *start, INTERP_KERNEL::Node *end)
229 Edge *ptr=Edge::BuildEdgeFrom(start,end);
230 return new ElementaryEdge(ptr,direction);