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"
23 #include "CellModel.hxx"
28 using namespace INTERP_KERNEL;
30 OrientationInverter *OrientationInverter::BuildInstanceFrom(NormalizedCellType gt)
35 return new OrientationInverterSEG2;
37 return new OrientationInverterSEG3;
39 return new OrientationInverter2DLinear(3u);
41 return new OrientationInverter2DLinear(4u);
43 return new OrientationInverterPolygon;
45 return new OrientationInverter2DQuadratic(6u);
47 return new OrientationInverter2DQuadratic(8u);
49 return new OrientationInverterQPolygon;
51 return new OrientationInverterTetra4;
53 return new OrientationInverterPyra5;
55 return new OrientationInverter3DExtrusionLinear(6u);
57 return new OrientationInverter3DExtrusionLinear(8u);
59 return new OrientationInverterTetra10;
61 return new OrientationInverterPyra13;
63 return new OrientationInverter3DExtrusionQuadratic(15u);
65 return new OrientationInverter3DExtrusionQuadratic(20u);
68 const CellModel& cm(CellModel::GetCellModel(gt));
69 std::ostringstream oss; oss << "OrientationInverter::BuildInstanceFrom : Sorry no inverter for geo type " << cm.getRepr() << " !";
70 throw INTERP_KERNEL::Exception(oss.str());
75 void OrientationInverterChecker::check(int *beginPt, int *endPt) const
77 if(std::distance(beginPt,endPt)!=getNbNodes())
79 std::ostringstream oss; oss << "OrientationInverterChecker::check : length of nodal connectivity mismatches ! Expecting " << getNbNodes() << " having " << std::distance(beginPt,endPt) << " !";
80 throw INTERP_KERNEL::Exception(oss.str());
84 void OrientationInverterSEG2::operateAndShutUp(int *beginPt) const
86 std::swap(beginPt[0],beginPt[1]);
89 void OrientationInverterSEG3::operateAndShutUp(int *beginPt) const
91 std::swap(beginPt[0],beginPt[2]);
94 void OrientationInverter2DLinear::operateAndShutUp(int *beginPt) const
96 std::reverse(beginPt+1,beginPt+getNbNodes());
99 void OrientationInverter2DQuadratic::operateAndShutUp(int *beginPt) const
101 int nbNodes(getNbNodes());
102 std::reverse(beginPt+1,beginPt+nbNodes/2);
103 std::reverse(beginPt+nbNodes/2,beginPt+nbNodes);
106 void OrientationInverterPolygon::operate(int *beginPt, int *endPt) const
108 std::reverse(beginPt+1,endPt);
111 void OrientationInverterQPolygon::operate(int *beginPt, int *endPt) const
113 std::size_t sz(std::distance(beginPt,endPt));
114 std::reverse(beginPt+1,beginPt+sz/2);
115 std::reverse(beginPt+sz/2,endPt);
118 void OrientationInverterTetra4::operateAndShutUp(int *beginPt) const
120 std::swap(beginPt[1],beginPt[2]);
123 void OrientationInverterTetra10::operateAndShutUp(int *beginPt) const
125 std::swap(beginPt[1],beginPt[2]);
126 std::swap(beginPt[4],beginPt[6]);
127 std::swap(beginPt[8],beginPt[9]);
130 void OrientationInverterPyra5::operateAndShutUp(int *beginPt) const
132 std::reverse(beginPt+1,beginPt+4);
135 void OrientationInverterPyra13::operateAndShutUp(int *beginPt) const
137 std::reverse(beginPt+1,beginPt+4);
138 std::reverse(beginPt+5,beginPt+9);
139 std::swap(beginPt[10],beginPt[12]);
142 void OrientationInverter3DExtrusionLinear::operateAndShutUp(int *beginPt) const
144 int nbNodes(getNbNodes());
145 std::reverse(beginPt+1,beginPt+nbNodes/2);
146 std::reverse(beginPt+nbNodes/2+1,beginPt+nbNodes);
149 void OrientationInverter3DExtrusionQuadratic::operateAndShutUp(int *beginPt) const
151 int nbNodes(getNbNodes()),nbNodesLinearBase(nbNodes/5);
152 std::reverse(beginPt+1,beginPt+nbNodesLinearBase);
153 std::reverse(beginPt+nbNodesLinearBase+1,beginPt+2*nbNodesLinearBase);
154 std::reverse(beginPt+2*nbNodesLinearBase,beginPt+3*nbNodesLinearBase);
155 std::reverse(beginPt+3*nbNodesLinearBase,beginPt+4*nbNodesLinearBase);
156 std::reverse(beginPt+4*nbNodesLinearBase+1,beginPt+5*nbNodesLinearBase);