Field mainly realizes data transfer between nodes and modules by encapsulating typical data types. As shown in the figure below, GLPointVisualNode passes point cloud data to InputFieldTest for use by defining Field of type FInstance.
The connection and disconnection between fields mainly depend on the implementation of the following two functions:
virtual bool connect(FBase* dst) = 0;
virtual bool disconnect(FBase* dst);
As the base class of all Fields, FBase mainly manages the connection status of Fields in a unified manner.
connect(FBase* dst) is a pure virtual function defined in FBase, so its specific implementation depends on a specific Field. The design is mainly to ensure the validity of the data connection, and to simulate connecting the data to the wrong type.
Assuming that there are three Field types of data A, B, and C, their connection relationship is set to A->B->C. At this time, in order to reduce the data conversion and storage overhead, when we operate the data of C, it will return the data pointer at the top (corresponding to A) according to the connection relationship.
FVar: Inherited from FBase, it is a package for a single data type, including scalar data, such as int, float, double; vector data, such as Vec3f; and second-order tensors, such as Mat3f. Nodes and modules can be defined by using macro definitions such as DEF_VAR/DEF_VAR_IN
DEF_VAR(Real, RestDensity, 1000, "Rest Density");
其中Real代表数据类型,RestDesntiy代表数据名称,1000代表初值,“Rest Density"则表示数据的说明。通过DEF_VAR定义的数据实际使用过程中可以通var+数据名称的方式对数据进行操作,假设我们需要将上述Field连接到另一个功能模块,则可以调用如下接口进行
this->varRestDensity()->connect(...);
FArray:The encapsulation of the one-dimensional array defined in Core/Array.h, similar to the vector in STL. According to its different functions in nodes/modules, we adopt the following three definitions:
DEF_ARRAY_IN(Coord, Position, DeviceType::GPU, "Output"); //input
The access method of input data is in+data name, that is, inPosition()
DEF_ARRAY_OUT(Coord, Position, DeviceType::GPU, "Output"); //ouput
The access method of input data is out+data name, namely outPosition()
DEF_ARRAY_STATE(Coord, Position, DeviceType::GPU, "Internal state"); //internal state variable
The access method of the state variable is state+data name, statePosition()
FArrayList:Encapsulation of Core/ArrayList.h data to support CPU/GPU compatible dynamic data types. It is defined in a similar way to FArray, i.e.
DEF_ARRAYLIST_IN(Coord, Position, DeviceType::GPU, "Input"); //input
The access method of input data is in+data name, that is, inPosition()
DEF_ARRAYLIST_OUT(Coord, Position, DeviceType::GPU, "Output"); //ouput
The access method of input data is out+data name, namely outPosition()
DEF_ARRAYLIST_STATE(Coord, Position, DeviceType::GPU, "Internal state"); //internal state variable
The access method of the state variable is state+data name, statePosition()
FInstance:Mainly to support the connection between data with inheritance relationship, the typical application is to use FInstance to define different topology data
DEF_INSTANCE_IN(PointSet<TDataType>, PointSet, "PointSet is derived from TopologyModule"); //input
The access method of input data is in+data name, and any correspondence inherited from PointSet can be connected to this data.
DEF_INSTANCE_OUT(PointSet<TDataType>, PointSet, "Output"); //output
The access method of input data is out+data name
DEF_INSTANCE_STATE(PointSet<TDataType>, PointSet, "Internal state"); //internal state variable
The access method of the state variable is state+data name
Reference code src/Framework/FBase.h.