I'm trying to optimize the following code below to avoid having to copy and paste and just use SlaveForce and SlavePos properly, which are float[6] type, and baseForce and basePos are vector type:
typedef struct _NodeCoord
{
float coords[6];
} NodeCoord;
int main()
{
...
memcpy(tempNodeCoord.coords, SlaveForce, 6*sizeof(float));
baseForce.push_back(tempNodeCoord);
memcpy(tempNodeCoord.coords, SlavePos, 6*sizeof(float));
basePos.push_back(tempNodeCoord);
...
}
I have tried some test codes. Only this appear to work:
std::vector<NodeCoord> tallon;
NodeCoord m;
memset(m.coords, 0, sizeof(m.coords));
tallon.push_back(m);
while this is along the lines of what I want to accomplish, but it doesn't work:
std::vector<float[6]> ed;
float e[6];
tallon.push_back(e);
I also tried writing a "typedef float[6] mytype;" line before the main function, but it doesn't work well either. Is there anything that I can do to eliminate the memcpy function calls (or rather push_back the float[6] variables directly)? Thanks in advance.