1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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"
24 #include "InterpKernelGeo2DComposedEdge.hxx"
26 using namespace INTERP_KERNEL;
28 ElementaryEdge::ElementaryEdge(const ElementaryEdge& other):_direction(other._direction),_ptr(other._ptr)
33 ElementaryEdge::~ElementaryEdge()
39 bool ElementaryEdge::isNodeIn(Node *n) const
41 return _ptr->getStartNode()==n || _ptr->getEndNode()==n;
45 * \b WARNING contrary to INTERP_KERNEL::Edge::getBarycenterOfZone method called,
46 * this one is cumulative.
48 void ElementaryEdge::getBarycenterOfZone(double *bary) const
51 _ptr->getBarycenterOfZone(tmp);
64 void ElementaryEdge::fillBounds(Bounds& output) const
66 output.aggregate(_ptr->getBounds());
69 void ElementaryEdge::getAllNodes(std::set<Node *>& output) const
71 output.insert(_ptr->getStartNode());
72 output.insert(_ptr->getEndNode());
75 void ElementaryEdge::getBarycenter(double *bary, double& weigh) const
77 _ptr->getBarycenter(bary);
78 weigh=_ptr->getCurveLength();
81 ElementaryEdge *ElementaryEdge::clone() const
83 return new ElementaryEdge(*this);
86 void ElementaryEdge::initLocations() const
92 * WARNING use this method if and only if this is so that it is completely in/out/on of @param pol.
94 TypeOfEdgeLocInPolygon ElementaryEdge::locateFullyMySelf(const ComposedEdge& pol, TypeOfEdgeLocInPolygon precEdgeLoc) const
96 if(getLoc()!=FULL_UNKNOWN)
99 if(precEdgeLoc==FULL_IN_1)
101 if(getStartNode()->getLoc()==ON_1)
106 else if(getStartNode()->getLoc()==IN_1 || getStartNode()->getLoc()==ON_TANG_1)
112 if(precEdgeLoc==FULL_OUT_1)
114 if(getStartNode()->getLoc()==ON_1)
119 else if(getStartNode()->getLoc()==IN_1 || getStartNode()->getLoc()==ON_TANG_1)
125 if(getStartNode()->getLoc()==IN_1 || getEndNode()->getLoc()==IN_1)
130 if(getStartNode()->getLoc()==OUT_1 || getEndNode()->getLoc()==OUT_1)
135 //a seek is requested
136 return locateFullyMySelfAbsolute(pol);
139 TypeOfEdgeLocInPolygon ElementaryEdge::locateFullyMySelfAbsolute(const ComposedEdge& pol) const
141 Node *node=_ptr->buildRepresentantOfMySelf(); // build barycenter used to detect if the edge is IN or OUT
142 if(pol.isInOrOut(node))
150 Node *ElementaryEdge::getEndNode() const
153 return _ptr->getEndNode();
154 else return _ptr->getStartNode();
157 Node *ElementaryEdge::getStartNode() const
160 return _ptr->getStartNode();
162 return _ptr->getEndNode();
165 bool ElementaryEdge::changeEndNodeWith(Node *node) const
168 return _ptr->changeEndNodeWith(node);
170 return _ptr->changeStartNodeWith(node);
173 bool ElementaryEdge::changeStartNodeWith(Node *node) const
176 return _ptr->changeStartNodeWith(node);
178 return _ptr->changeEndNodeWith(node);
181 void ElementaryEdge::dumpInXfigFile(std::ostream& stream, int resolution, const Bounds& box) const
183 _ptr->dumpInXfigFile(stream,_direction,resolution,box);
186 bool ElementaryEdge::intresicEqual(const ElementaryEdge *other) const
188 return _ptr==other->_ptr;
191 bool ElementaryEdge::intresicEqualDirSensitive(const ElementaryEdge *other) const
193 return ( _direction==other->_direction ) && (_ptr==other->_ptr);
196 bool ElementaryEdge::intresincEqCoarse(const Edge *other) const
201 bool ElementaryEdge::isEqual(const ElementaryEdge& other) const
203 return _ptr->isEqual(*other._ptr);
207 * Called by QuadraticPolygon::splitAbs method.
209 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,
210 std::vector<int>& edgesThis, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int> mapAddCoo) const
212 _ptr->fillGlobalInfoAbs(_direction,mapThis,mapOther,offset1,offset2,fact,baryX,baryY,edgesThis,addCoo,mapAddCoo);
216 * 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
217 * unsorted because the "other" mesh is not subdivided yet.
219 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,
220 std::vector<int>& edgesOther, std::vector<double>& addCoo, std::map<INTERP_KERNEL::Node *,int>& mapAddCoo) const
222 _ptr->fillGlobalInfoAbs2(mapThis,mapOther,offset1,offset2,fact,baryX,baryY,edgesOther,addCoo,mapAddCoo);
226 * This method builds from a \a start node, an \a end node and a direction a new ElementaryEdge.
228 ElementaryEdge *ElementaryEdge::BuildEdgeFromStartEndDir(bool direction, INTERP_KERNEL::Node *start, INTERP_KERNEL::Node *end)
230 Edge *ptr=Edge::BuildEdgeFrom(start,end);
231 return new ElementaryEdge(ptr,direction);