Nektar++
CADSystem.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: CADSystem.cpp
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: cad object methods.
32 //
33 ////////////////////////////////////////////////////////////////////////////////
34 
39 
40 using namespace std;
41 
42 namespace Nektar
43 {
44 namespace NekMeshUtils
45 {
46 
48 {
49  static EngineFactory instance;
50  return instance;
51 }
52 
54 {
55  static CADVertFactory instance;
56  return instance;
57 }
58 
60 {
61  static CADCurveFactory instance;
62  return instance;
63 }
64 
66 {
67  static CADSurfFactory instance;
68  return instance;
69 }
70 
71 Array<OneD, NekDouble> CADSystem::GetPeriodicTranslationVector(int first,
72  int second)
73 {
74  ASSERTL0(GetNumSurf() == 1, "wont work for multi surfaces yet");
75 
76  CADCurveSharedPtr c1 = GetCurve(first);
77  CADCurveSharedPtr c2 = GetCurve(second);
78 
79  NekDouble tst = c1->GetTotLength() - c2->GetTotLength();
80  ASSERTL0(fabs(tst) < 1e-6, "periodic curves not same length");
81 
82  vector<CADVertSharedPtr> v1 = c1->GetVertex();
83  Array<OneD, NekDouble> p1 = v1[0]->GetLoc();
84 
86  vector<CADVertSharedPtr> v2 = c2->GetVertex();
87  if (c1->GetOrienationWRT(1) == c2->GetOrienationWRT(1))
88  {
89  p2 = v2[1]->GetLoc();
90  }
91  else
92  {
93  p2 = v2[0]->GetLoc();
94  }
95 
97  ret[0] = p2[0] - p1[0];
98  ret[1] = p2[1] - p1[1];
99  ret[2] = p2[2] - p1[2];
100 
101  return ret;
102 }
103 
104 }
105 }
CADCurveFactory & GetCADCurveFactory()
Definition: CADSystem.cpp:59
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
STL namespace.
CADVertFactory & GetCADVertFactory()
Definition: CADSystem.cpp:53
CADSurfFactory & GetCADSurfFactory()
Definition: CADSystem.cpp:65
std::shared_ptr< CADCurve > CADCurveSharedPtr
Definition: CADCurve.h:219
double NekDouble
EngineFactory & GetEngineFactory()
Definition: CADSystem.cpp:47
Provides a generic Factory class.
Definition: NekFactory.hpp:103