FEDEM Model Database  R8.0
Source code of the FEDEM model database
FmLink.H
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2023 SAP SE
2 //
3 // SPDX-License-Identifier: Apache-2.0
4 //
5 // This file is part of FEDEM - https://openfedem.org
7 
8 #ifndef FM_LINK_H
9 #define FM_LINK_H
10 
13 
14 #include "vpmDB/FmColor.H"
16 
17 
19 template<>
21 {
22  return !this->isDefault();
23 }
25 
26 
28 class FFaFieldUnsignedInt : public FFaField<int>
29 {
30 public:
31  bool isPrintable() const final { return this->myData >= 0; }
32 };
33 
34 
35 class FmTriad;
36 class FmJointBase;
37 class FmMMJointBase;
38 class FmSMJointBase;
39 class VTFAFile;
40 
41 
42 class FmLink : public FmIsPositionedBase
43 {
47 
48 public:
49 
50  // 3D display values
51 
52  const FmColor& getLineRGBColor() const { return myLineRGBColor.getValue(); }
53  bool setLineRGBColor(const FmColor& col);
54 
55  double getShininess() const { return myShininess.getValue(); }
56  bool setShininess(double var);
57 
58  const FmColor& getRGBColor() const { return myRGBColor.getValue(); }
59  bool setRGBColor(const FmColor& col);
60  bool setRGBColor(float r, float g, float b);
61 
62  double getTransparency() const { return myTransparency.getValue(); }
63  bool setTransparency(double var);
64 
66  enum Detail { FULL = 0, SURFACE = 1, REDUCED = 2,
67  BBOX = 3, OFF = 4, RED_FULL = 5,
69 
71  FFaEnumEntry(FULL, "FULL");
72  FFaEnumEntry(SURFACE, "SURFACE");
73  FFaEnumEntry(REDUCED, "REDUCED");
74  FFaEnumEntry(BBOX, "BBOX");
75  FFaEnumEntry(OFF, "OFF");
76  FFaEnumEntry(RED_FULL, "RED_FULL");
77  FFaEnumEntry(REDUCED_NO1D, "REDUCED_NO1D");
78  FFaEnumEntry(SIMPLIFIED, "SIMPLIFIED");
80  };
81 
82  Detail getMeshType() const { return myMeshType.getValue(); }
83  bool setMeshType(Detail detailType);
84 
85  Detail getModelType() const { return myModelType.getValue(); }
86  bool setModelType(Detail detailType);
87 
88  // From FmIsRenderedBase
89  bool highlight(bool trueOrFalse) override;
90 
91  // Utility methods
92 
93  // From FmModelMemberBase
94  bool interactiveErase() override;
95 
97  bool isEarthLink() const { return this->getID() == -1; }
98 
100  virtual bool isAttachable() const { return false; }
102  virtual bool isDisabled() const { return false; }
104  virtual bool isSuppressed() const { return false; }
106  virtual bool isGenericPart() const { return false; }
108  virtual bool isFEPart(bool = false) const { return false; }
109 
111  FmTriad* getTriadAtPoint(const FaVec3& point, double tolerance,
112  bool globalPoint = false,
113  bool unconnectedOnly = false) const;
114 
116  FaVec3 getExtents() const;
118  virtual bool getBBox(FaVec3& max, FaVec3& min) const;
119 
120  // From FmIsRenderedBase
121  void updateChildrenDisplayTopology() override;
122 
124  bool attach(FmBase* attachObject, bool isSilent = false);
125 
126  // From FmIsPositionedBase
127  std::string getLinkIDString(bool objPrefix = false) const override;
128 
129  // DB Topology
130 
132  virtual int getNumberOfTriads() const = 0;
134  virtual FmTriad* findTriad(int baseID) const = 0;
136  virtual void getTriads(std::vector<FmTriad*>& toFill,
137  bool sortOnId = false) const = 0;
139  void getJoints(std::vector<FmJointBase*>& toFill) const;
140 
142  virtual bool getRefPoints(FmTriad*& node1, FmTriad*& node2, FmTriad*& node3,
143  FaVec3& offset1, FaVec3& offset2, FaVec3& offset3) const;
144 
146  virtual double getMass() const = 0;
148  virtual FaMat34 getPositionCG(bool globalCS = true) const = 0;
150  virtual FmModelMemberBase* getProperty() const { return NULL; }
151 
152  // File handling
153 
154  // Hook for VTF output of the FE model of this link.
155  virtual bool writeToVTF(VTFAFile& file, IntVec* = NULL, IntVec* = NULL) = 0;
156  // Hook for writing solver input file entries for beam elements.
157  virtual int printSolverEntry(FILE*, int) { return 0; }
158  // From FmModelMemberBase
159  int printSolverEntry(FILE* f) override { return this->printSolverEntry(f,0); }
160 
162  bool openCadData();
164  bool saveCadData();
166  bool isCADLoaded() const;
168  bool isUsingGenPartVis() const;
170  void updateGPVisualization();
171 
173  virtual std::string getAbsFilePath(bool createDir = false) const;
175  std::string getBaseCadFile(bool createDir = false) const;
177  std::string getGeometryFile() const;
178 
180  int getStructDmpEngineId() const;
181 
183  static bool readAndConnect(std::istream& is, std::ostream& os = std::cout);
184 
185 protected:
187  FmLink(const FaVec3& globalPos = FaVec3());
189  FmLink(bool);
191  virtual ~FmLink();
192 
193  // From FmBase
194  bool cloneLocal(FmBase* obj, int depth) override;
195 
196  static bool localParse(const char* keyWord, std::istream& activeStatement,
197  FmLink* obj);
198 
200  bool attachTriad(FmTriad* attachTr, bool isSilent, bool doUpdate = true);
202  virtual bool attachSMJoint(FmSMJointBase* attachJnt, bool isSilent = false);
204  virtual bool attachMMJoint(FmMMJointBase* attachJnt, bool isSilent = false);
206  virtual bool attachTriad(FmTriad* attachTr, FmTriad* oldTr, bool silence);
207 
209  bool isTriadAttachable(FmTriad*& existingTriad,
210  FmTriad* attachTr, bool isSilent = false);
211 
213  virtual std::pair<FmTriad*,bool> getExistingTriad(const FmTriad* triad);
214 
215 public:
222 
223  // Structural damping properties
226 
227  // Scaling of dynamic properties
230 
237  };
238 
240  FFaEnumEntry(MODEL_DEFAULT, "MODEL_DEFAULT");
241  FFaEnumEntry(MAX_TRI_UNIT_OFFSET, "MAX_TRI_UNIT_OFFSET");
242  FFaEnumEntry(MAX_TRI_LINK_SCALE_OFFSET,"MAX_TRI_LINK_SCALE_OFFSET");
243  FFaEnumEntry(MASS_BASED_AVERAGE, "MASS_BASED_AVERAGE");
245  };
246 
248 
250 
251 protected:
252  // 3D display variables
259 };
260 
261 #endif
Enum variables with text representations.
#define FFaEnumEntryEnd
Defines the end of an enum mapping definition.
Definition: FFaEnum.H:237
#define FFaEnumEntry(Value, Text)
Adds one entry to the current enum mapping definition.
Definition: FFaEnum.H:234
Conversion of units for physical property parameters.
std::vector< int > IntVec
Convenience type alias.
Definition: FFaFieldContainer.H:45
Same as FFaField<int>, but hiding negative-valued instances.
Definition: FmLink.H:29
bool isPrintable() const final
Returns true, if this field should be printed.
Definition: FmLink.H:31
Template class for field representation in the FEDEM model database.
Definition: FFaField.H:39
bool isDefault() const final
Returns true, if the field value equals its default value.
Definition: FFaField.H:92
int myData
Current field value.
Definition: FFaField.H:130
bool isPrintable() const override
Returns true, if this field should be printed.
Definition: FFaField.H:94
const ValueT & getValue() const
Returns a const reference to myData.
Definition: FFaField.H:56
Class for positions in 3D space.
Definition: FFaMat34.H:32
Class for point vectors in 3D space.
Definition: FFaVec3.H:40
Base parent class for the model data structure entries.
Definition: FmBase.H:37
int getID() const
Returns the user ID of this object.
Definition: FmBase.H:66
Representation of a RGB color by floats in range [0.0,1.0].
Definition: FmColor.H:24
Definition: FmIsPositionedBase.H:31
Definition: FmJointBase.H:22
Definition: FmMMJointBase.H:16
Base class for all model data objects.
Definition: FmModelMemberBase.H:34
Definition: FmSMJointBase.H:17
Definition: FmTriad.H:48
Definition: FFlVTFWriter.C:21