1 // Copyright (C) 2007-2016 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 (EDF R&D)
21 #include "OrientationInverter.hxx"
22 #include "InterpKernelException.hxx"
27 using namespace INTERP_KERNEL;
29 void OrientationInverterChecker::check(int *beginPt, int *endPt) const
31 if(std::distance(beginPt,endPt)!=getNbNodes())
33 std::ostringstream oss; oss << "OrientationInverterChecker::check : length of nodal connectivity mismatches ! Expecting " << getNbNodes() << " having " << std::distance(beginPt,endPt) << " !";
34 throw INTERP_KERNEL::Exception(oss.str());
38 void OrientationInverterSEG2::operateAndShutUp(int *beginPt) const
40 std::swap(beginPt[0],beginPt[1]);
43 void OrientationInverterSEG3::operateAndShutUp(int *beginPt) const
45 std::swap(beginPt[0],beginPt[2]);
48 void OrientationInverter2DLinear::operateAndShutUp(int *beginPt) const
50 std::reverse(beginPt+1,beginPt+getNbNodes());
53 void OrientationInverter2DQuadratic::operateAndShutUp(int *beginPt) const
55 int nbNodes(getNbNodes());
56 std::reverse(beginPt+1,beginPt+nbNodes/2);
57 std::reverse(beginPt+nbNodes/2,beginPt+nbNodes);
60 void OrientationInverterPolygon::operate(int *beginPt, int *endPt) const
62 std::reverse(beginPt+1,endPt);
65 void OrientationInverterQPolygon::operate(int *beginPt, int *endPt) const
67 std::size_t sz(std::distance(beginPt,endPt));
68 std::reverse(beginPt+1,beginPt+sz/2);
69 std::reverse(beginPt+sz/2,endPt);
72 void OrientationInverterTetra4::operateAndShutUp(int *beginPt) const
74 std::swap(beginPt[1],beginPt[2]);
77 void OrientationInverterTetra10::operateAndShutUp(int *beginPt) const
79 std::swap(beginPt[1],beginPt[2]);
80 std::swap(beginPt[4],beginPt[6]);
81 std::swap(beginPt[8],beginPt[9]);
84 void OrientationInverterPyra5::operateAndShutUp(int *beginPt) const
86 std::reverse(beginPt+1,beginPt+4);
89 void OrientationInverterPyra13::operateAndShutUp(int *beginPt) const
91 std::reverse(beginPt+1,beginPt+4);
92 std::reverse(beginPt+5,beginPt+9);
93 std::swap(beginPt[10],beginPt[12]);
96 void OrientationInverter3DExtrusionLinear::operateAndShutUp(int *beginPt) const
98 int nbNodes(getNbNodes());
99 std::reverse(beginPt+1,beginPt+nbNodes/2);
100 std::reverse(beginPt+nbNodes/2+1,beginPt+nbNodes);
103 void OrientationInverter3DExtrusionQuadratic::operateAndShutUp(int *beginPt) const
105 int nbNodes(getNbNodes()),nbNodesLinearBase(nbNodes/5);
106 std::reverse(beginPt+1,beginPt+nbNodesLinearBase);
107 std::reverse(beginPt+nbNodesLinearBase+1,beginPt+2*nbNodesLinearBase);
108 std::reverse(beginPt+2*nbNodesLinearBase,beginPt+3*nbNodesLinearBase);
109 std::reverse(beginPt+3*nbNodesLinearBase,beginPt+4*nbNodesLinearBase);
110 std::reverse(beginPt+4*nbNodesLinearBase+1,beginPt+5*nbNodesLinearBase);