OpenLexocad  27.0
NurbsOptions.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <Topo/Shape.h>
4 #include <Topo/topo_defines.h>
5 
6 namespace Topo
7 {
9 {
10 protected:
11  NurbsOptions() = default;
12  virtual ~NurbsOptions() = default;
13  virtual void init() = 0;
14 };
15 
16 // SB - Acis options about skinning are a little bit "confused". There are different methods to skin wires, but not all methods accept all parameters,
17 // that's why I'm trying to make different classes, each one that fits only a particular method, with only the parameters that are taken into account.
19 {
20 public:
22  virtual ~SkinningOptions(void) override = default;
23 
24  void setWiresU(const std::vector<pConstShape>& in) { setWires(_uWires, in); }
25  void setWiresU(const std::vector<pConstWire>& in) { _uWires = in; }
26  std::vector<pConstWire> getWiresU() const { return _uWires; }
27 
28  enum class ClosedMode
29  {
30  OPEN = 0,
31  CLOSED = 1,
32  LOOP = 2,
33  SOLID = 3
34  };
35  void setClosedMode(const ClosedMode& mode) { _closedMode = mode; };
36  ClosedMode getClosedMode() const { return _closedMode == ClosedMode::SOLID ? ClosedMode::OPEN : _closedMode; }
37 
38  void setSolid(const bool& solid) { _closedMode = solid ? ClosedMode::SOLID : ClosedMode::OPEN; }
39  bool getSolid() const { return _closedMode == ClosedMode::SOLID; }
40 
41  void setUniformUV(const bool& uniform) { _arc_length = _arc_length_u = _merge_wirecoedges = uniform; }
42  bool getArcLen() const { return _arc_length; }
43  bool getArcLenU() const { return _arc_length_u; }
44  bool getMerge() const { return _merge_wirecoedges; }
45 
46  // These values are intentionally "readonly", since it is not clear when it would be useful to alter them.
47  bool getAllowUV() const { return _allow_same_uv; }
48  bool getSelfIntersect() const { return _self_int_test; }
49  bool getSimplify() const { return _simplify; }
50 
51 protected:
52  bool _allow_same_uv = true; // SB 2011.12.16 - Very special case!
53  // http://doc.spatial.com/index.php/Skinning_and_Lofting_Options/Surface_Checks#allow_same_uv_.28false.29
54  bool _arc_length = true; // SB 2013.05.07 - http://doc.spatial.com/index.php/Skinning_and_Lofting_Options/Surface_Parameterization
55  bool _arc_length_u = true;
56  bool _merge_wirecoedges = true;
57  bool _self_int_test = false; // SB 2012.06.05 - When FALSE allow creation of self-intersecting surfaces:
58  // http://doc.spatial.com/index.php/Skinning_and_Lofting_Options/Surface_Checks#self_int_test_.281.29. No exception
59  // is thrown, NURBS is created (probably rubbish) and "selfIntersect" property can be detected later.
60  bool _simplify =
61  false; // SB 2012.06.14 - Leave to FALSE or ACIS will try to build a simpler surface (if possible). For example, if set to TRUE and the
62  // surface is exactly a cylinder, ACIS will not make a NURBS but a cylinder and the "api_accurate_bs3_approximation" won't work! See
63  // http://doc.spatial.com/index.php/Skinning_and_Lofting_Options/Simplification
64  ClosedMode _closedMode = ClosedMode::OPEN;
65 
66  std::vector<pConstWire> _uWires = {};
67 
68  virtual void init() override = 0;
69 
70  // template <typename T> void setWires(std::vector<pConstWire> &u_or_vWires, T &in)
71  //{
72  // u_or_vWires.clear();
73 
74  // for (auto element_or_geometry : in)
75  // {
76  // if (auto wire = Topo::ShapeTool::isSingleWire(element_or_geometry->getShape())) // If an App::Element is passed, then its transformation is
77  //taken into account. If an Core::DocObject is passed, it has to be transformed before (geometry does not carry transformation info)
78  // u_or_vWires.push_back(wire);
79  // if (auto face = Topo::ShapeTool::isSingleFace(element_or_geometry->getShape())) // If an App::Element is passed, then its transformation is
80  //taken into account. If an Core::DocObject is passed, it has to be transformed before (geometry does not carry transformation info) if (auto wire
81  //= Topo::FaceTool::getOuterBoundary(face)) u_or_vWires.push_back(wire);
82  // }
83  //}
84 
85  void setWires(std::vector<pConstWire>& u_or_vWires, const std::vector<pConstShape>& in);
86 };
87 
89 {
90 public:
92  virtual ~BasicSkinningOptions(void) override = default;
93 
94 protected:
95  void init() override {}
96 };
97 
99 {
100 public:
102  virtual ~DraftSkinningOptions(void) override = default;
103 
104  enum class GapMode
105  {
106  EXTENDED = 0,
107  ROUNDED = 1,
108  CHAMFERED = 2
109  }; // SB - Pls match values in "skin_opts.hxx" => skin_gap_type
110  void setGapMode(GapMode mode) { _gapMode = mode; };
111  GapMode getGapMode() const { return _gapMode; }
112 
113  double startAngle = 0.;
114  double startMagnitude = 0.;
115  double endAngle = 0.;
116  double endMagnitude = 0.;
117 
118 protected:
119  GapMode _gapMode = GapMode::EXTENDED;
120 
121  void init() override {}
122 };
123 
125 {
126 public:
128  virtual ~GuideSkinningOptions(void) override = default;
129 
130  void setWiresV(const std::vector<pConstShape>& in) { setWires(_vWires, in); }
131  void setWiresV(std::vector<pConstWire> in) { _vWires = in; }
132  std::vector<pConstWire> getWiresV() const { return _vWires; }
133 
134  void setVirtualGuides(const bool& virtualGuides) { _virtualGuides = virtualGuides; }
135  bool getVirtualGuides() const { return _virtualGuides; }
136 
137 protected:
138  bool _virtualGuides = false; // SB 2012.05.07 - http://doc.spatial.com/index.php/Skinning_and_Lofting_Options/Guide-related
139 
140  std::vector<pConstWire> _vWires = {};
141 
142  void init() override {}
143 };
144 
146 {
147 public:
149  virtual ~LinearSkinningOptions(void) override = default;
150 
151 protected:
152  void init() override {}
153 };
154 
156 {
157 public:
159  virtual ~PathSkinningOptions(void) override = default;
160 
161  void setPath(pConstWire in) { _path = in; }
162  pConstWire getPath() const { return _path; }
163 
164 protected:
165  pConstWire _path = nullptr;
166 
167  void init() override {}
168 };
169 
171 {
172 public:
174  virtual ~PlanarSkinningOptions(void) override = default;
175 
176  enum class NormalsMode
177  {
178  FIRST = 0,
179  LAST = 1,
180  ENDS = 2,
181  ALL = 3
182  }; // SB - Pls match values in "skin_opts.hxx" => skinning_normals
183  void setNormalsMode(NormalsMode mode) { _normalsMode = mode; };
184  NormalsMode getNormalsMode() const { return _normalsMode; }
185 
186 protected:
187  NormalsMode _normalsMode = NormalsMode::ALL;
188 
189  void init() override {}
190 };
191 
193 {
194 public:
196  ~SweepingOptions() override = default;
197 
198  void setShapeU(pConstShape in);
199  void setShapeU(pConstFace in);
200  void setShapeU(pConstWire in);
201  pConstShape getShapeU() const { return _uShape; }
202 
203  void setToShape(pConstShape shape) { _toShape = shape; }
204  pConstShape getToShape() const { return _toShape; }
205 
206  void setSolid(const bool& solid) { _solid = solid; }
207  bool getSolid() const { return _solid; }
208 
209  // These values are intentionally "readonly", since it is not clear when it would be useful to alter them.
210  bool getSelfIntersect() const { return _selfIntTest; }
211  bool getSimplify() const { return _simplify; }
212 
213 protected:
214  bool _selfIntTest = false; // SB 2012.06.05 - When FALSE allow creation of self-intersecting surfaces:
215  // http://doc.spatial.com/index.php/Skinning_and_Lofting_Options/Surface_Checks#self_int_test_.281.29. No exception is
216  // thrown, NURBS is created (probably rubbish) and "selfIntersect" property can be detected later.
217  bool _simplify =
218  false; // SB 2012.06.14 - Leave to FALSE or ACIS will try to build a simpler surface (if possible). For example, if set to TRUE and the
219  // surface is exactly a cylinder, ACIS will not make a NURBS but a cylinder and the "api_accurate_bs3_approximation" won't work! See
220  // http://doc.spatial.com/index.php/Skinning_and_Lofting_Options/Simplification
221  bool _solid = false;
222 
223  pConstShape _uShape = nullptr;
224  pConstShape _toShape = nullptr;
225 
226  void init() override = 0;
227 };
228 
230 {
231 public:
233  ~PathSweepingOptions() override = default;
234 
235  void setShapeV(pConstShape in);
236  void setShapeV(pConstWire in);
237  pConstShape getShapeV() const { return _vShape; }
238 
239  void setFinalTwistAngle(const double& angleInDeg) { _finalTwistAngle = angleInDeg; }
240  double getFinalTwistAngle() const { return _finalTwistAngle; }
241 
242  void setRigid(const bool& rigid) { _rigid = rigid; }
243  bool getRigid() const { return _rigid; }
244 
245  void setUseRail(const bool& rail, const Geom::Dir railDir = Geom::Dir(0., 0., 1.))
246  {
247  _rail = rail;
248  _railDir = railDir;
249  }
250  bool getUseRail(Geom::Dir& railDir) const
251  {
252  railDir = _railDir;
253  return _rail;
254  }
255 
256 protected:
257  double _finalTwistAngle = 0.;
258  bool _rigid = false;
259  bool _rail = false;
260  Geom::Dir _railDir = Geom::Dir(0., 0., 1.);
261 
262  pConstShape _vShape = nullptr;
263 
264  void init() override {}
265 };
266 } // namespace Topo
std::shared_ptr< Topo::Wire const > pConstWire
Definition: Shape.h:98
void setWiresV(const std::vector< pConstShape > &in)
Definition: NurbsOptions.h:130
void init() override
Definition: NurbsOptions.h:189
std::vector< pConstWire > getWiresU() const
Definition: NurbsOptions.h:26
Definition: NurbsOptions.h:124
NormalsMode getNormalsMode() const
Definition: NurbsOptions.h:184
bool getAllowUV() const
Definition: NurbsOptions.h:47
void setPath(pConstWire in)
Definition: NurbsOptions.h:161
#define TOPO_EXPORT
Definition: topo_defines.h:8
void setGapMode(GapMode mode)
Definition: NurbsOptions.h:110
bool getSimplify() const
Definition: NurbsOptions.h:49
void init() override
Definition: NurbsOptions.h:167
void setUniformUV(const bool &uniform)
Definition: NurbsOptions.h:41
bool getSelfIntersect() const
Definition: NurbsOptions.h:210
pConstShape getToShape() const
Definition: NurbsOptions.h:204
Definition: NurbsOptions.h:155
SweepingOptions()
Definition: NurbsOptions.h:195
void setNormalsMode(NormalsMode mode)
Definition: NurbsOptions.h:183
GapMode
Definition: NurbsOptions.h:104
std::shared_ptr< Topo::Face const > pConstFace
Definition: Shape.h:97
NormalsMode
Definition: NurbsOptions.h:176
ClosedMode
Definition: NurbsOptions.h:28
Definition: NurbsOptions.h:98
void setToShape(pConstShape shape)
Definition: NurbsOptions.h:203
void setFinalTwistAngle(const double &angleInDeg)
Definition: NurbsOptions.h:239
void setSolid(const bool &solid)
Definition: NurbsOptions.h:38
void setWiresU(const std::vector< pConstShape > &in)
Definition: NurbsOptions.h:24
GapMode getGapMode() const
Definition: NurbsOptions.h:111
bool getSolid() const
Definition: NurbsOptions.h:39
void setWiresV(std::vector< pConstWire > in)
Definition: NurbsOptions.h:131
void setVirtualGuides(const bool &virtualGuides)
Definition: NurbsOptions.h:134
bool getUseRail(Geom::Dir &railDir) const
Definition: NurbsOptions.h:250
pConstShape getShapeV() const
Definition: NurbsOptions.h:237
pConstShape getShapeU() const
Definition: NurbsOptions.h:201
Definition: NurbsOptions.h:229
Definition: Dir.h:46
bool getMerge() const
Definition: NurbsOptions.h:44
ClosedMode getClosedMode() const
Definition: NurbsOptions.h:36
pConstWire getPath() const
Definition: NurbsOptions.h:162
void setClosedMode(const ClosedMode &mode)
Definition: NurbsOptions.h:35
Definition: NurbsOptions.h:145
PathSkinningOptions(void)
Definition: NurbsOptions.h:158
Definition: NurbsOptions.h:8
Definition: Variant.h:70
bool getSimplify() const
Definition: NurbsOptions.h:211
std::vector< pConstWire > getWiresV() const
Definition: NurbsOptions.h:132
Definition: NurbsOptions.h:192
bool getVirtualGuides() const
Definition: NurbsOptions.h:135
void init() override
Definition: NurbsOptions.h:121
Definition: NurbsOptions.h:18
void init() override
Definition: NurbsOptions.h:152
double getFinalTwistAngle() const
Definition: NurbsOptions.h:240
bool getSolid() const
Definition: NurbsOptions.h:207
void setWiresU(const std::vector< pConstWire > &in)
Definition: NurbsOptions.h:25
Definition: NurbsOptions.h:88
void init() override
Definition: NurbsOptions.h:95
bool getArcLenU() const
Definition: NurbsOptions.h:43
LinearSkinningOptions(void)
Definition: NurbsOptions.h:148
PlanarSkinningOptions(void)
Definition: NurbsOptions.h:173
DraftSkinningOptions(void)
Definition: NurbsOptions.h:101
SkinningOptions(void)
Definition: NurbsOptions.h:21
std::shared_ptr< Topo::Shape const > pConstShape
Definition: Variant.h:81
void init() override
Definition: NurbsOptions.h:142
void init() override
Definition: NurbsOptions.h:264
BasicSkinningOptions(void)
Definition: NurbsOptions.h:91
PathSweepingOptions()
Definition: NurbsOptions.h:232
bool getRigid() const
Definition: NurbsOptions.h:243
void setSolid(const bool &solid)
Definition: NurbsOptions.h:206
void setUseRail(const bool &rail, const Geom::Dir railDir=Geom::Dir(0., 0., 1.))
Definition: NurbsOptions.h:245
bool getArcLen() const
Definition: NurbsOptions.h:42
Definition: NurbsOptions.h:170
bool getSelfIntersect() const
Definition: NurbsOptions.h:48
void setRigid(const bool &rigid)
Definition: NurbsOptions.h:242
GuideSkinningOptions(void)
Definition: NurbsOptions.h:127