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