FEDEM Model Database  R8.0
Source code of the FEDEM model database
FmSubAssembly.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 
13 #ifndef FM_SUB_ASSEMBLY_H
14 #define FM_SUB_ASSEMBLY_H
15 
17 
18 class FmRingStart;
19 class FmFuncTree;
20 class FaVec3;
21 
22 
28 {
32 
33  using FmHeadMap = std::map<int,FmRingStart*>;
34 
35 public:
37  FmSubAssembly(bool isDummy = false);
38 
40  static bool readAndConnect(std::istream& is, std::ostream& os = std::cout);
41 
42  // From FmBase
43  std::ostream& writeFMF(std::ostream& os = std::cout) override;
44  bool clone(FmBase* obj, int depth) override;
45  const char* getUITypeName() const override { return "Sub Assembly"; }
46 
48  virtual bool isListable(bool resultView = false) const;
50  virtual bool isCopyable() const { return true; }
51 
53  bool hasObjects(int typeId) const;
54 
56  const FmHeadMap* getHeadMap() const { return &myHeadMap; }
57 
59  virtual void updateLocation(char = 'A') {}
61  virtual double getMass(FaVec3&, bool = true) const { return 0.0; }
62 
63  // From FmModelMemberBase
64  FmBase* duplicate() const override { return this->duplicate(NULL); }
65 
67  static bool readFMF(const std::string& fileName,
68  FmSubAssembly** subAss = NULL);
69 
71  void resolveAfterRead();
72 
73 protected:
75  virtual ~FmSubAssembly();
76 
80  FmSubAssembly* duplicate(FmSubAssembly* parent) const;
81 
83  bool writeFMF(const std::string& fileName) const;
84 
85  // From FmBase
86  bool cloneLocal(FmBase* obj, int depth) override;
87  bool eraseOptions() override;
88 
89 public:
91 
92  static std::string mainFilePath;
93  static std::string newLinkRepo;
94 
95  static std::pair<int,int> old2newAssID;
96 
98 
99 private:
102 };
103 
104 #endif
Base class for all model data objects.
#define Fmd_DB_HEADER_INIT()
Macro enabling type checking for a class.
Definition: FmTypeCheck.H:24
Class for point vectors in 3D space.
Definition: FFaVec3.H:40
Base parent class for the model data structure entries.
Definition: FmBase.H:37
Definition: FmFuncTree.H:34
Base class for all model data objects.
Definition: FmModelMemberBase.H:34
Definition: FmRingStart.H:16
Base class for all sub-assembly objects.
Definition: FmSubAssembly.H:28
std::map< int, FmRingStart * > FmHeadMap
Convenience type alias.
Definition: FmSubAssembly.H:33
static std::string mainFilePath
Model file for storing the sub-assembly.
Definition: FmSubAssembly.H:92
FmHeadMap myHeadMap
The sub-assemblys typeID to ring start map.
Definition: FmSubAssembly.H:100
static bool readAndConnect(std::istream &is, std::ostream &os=std::cout)
Creates a new sub-assembly object by reading data from a stream.
Definition: FmSubAssembly.C:263
static FmHeadMap * tmpHeadMap
Temporary ring start map used during import.
Definition: FmSubAssembly.H:97
FmBase * duplicate() const override
Returns a connected copy of this object.
Definition: FmSubAssembly.H:64
bool clone(FmBase *obj, int depth) override
Copies the fields of another object into *this.
Definition: FmSubAssembly.C:95
FFaField< std::string > myModelFile
Definition: FmSubAssembly.H:90
bool cloneLocal(FmBase *obj, int depth) override
Clones the data fields of *obj into *this.
Definition: FmSubAssembly.C:101
static std::string newLinkRepo
Model link repository of imported model.
Definition: FmSubAssembly.H:93
bool hasObjects(int typeId) const
Returns true if this sub-assembly has objects of the given type.
Definition: FmSubAssembly.C:213
virtual bool isListable(bool resultView=false) const
Returns true if this object should be visible in the tree views.
Definition: FmSubAssembly.C:219
bool eraseOptions() override
Hook for class-specific tasks before deleting *this in erase().
Definition: FmSubAssembly.C:71
void resolveAfterRead()
Resolves topological cross-references after finished parsing.
Definition: FmSubAssembly.C:459
std::ostream & writeFMF(std::ostream &os=std::cout) override
Writes out this object in the model database file format.
Definition: FmSubAssembly.C:228
FmSubAssembly(bool isDummy=false)
Default constructor.
Definition: FmSubAssembly.C:47
bool mergeOldHeadMapAndConnect()
Merges existing sub-assembly with same ID (if any) into this one.
Definition: FmSubAssembly.C:196
static bool readFMF(const std::string &fileName, FmSubAssembly **subAss=NULL)
Creates sub-assembly members by reading from specified file.
Definition: FmSubAssembly.C:286
virtual void updateLocation(char='A')
Updates the location data for positioned sub-assemblies.
Definition: FmSubAssembly.H:59
FmFuncTree * myFuncTree
Tree structure for functions.
Definition: FmSubAssembly.H:101
static std::pair< int, int > old2newAssID
Parent sub-assembly ID switching.
Definition: FmSubAssembly.H:95
const char * getUITypeName() const override
Returns the type name of this object for use in the GUI.
Definition: FmSubAssembly.H:45
virtual bool isCopyable() const
Returns true if this sub-assembly object can be copied.
Definition: FmSubAssembly.H:50
const FmHeadMap * getHeadMap() const
Returns a pointer to the myHeadMap member of this sub-assembly.
Definition: FmSubAssembly.H:56
virtual double getMass(FaVec3 &, bool=true) const
Returns the total mass of this sub-assembly.
Definition: FmSubAssembly.H:61
virtual ~FmSubAssembly()
The destructor disconnects the object from the model database.
Definition: FmSubAssembly.C:65