#include <iostream>
#include<fstream>
#include <string>
#include "dumbbell.h"
#include <cstdlib>
using namespace std;
Dumbbell::Dumbbell()
{
gp = new SoSeparator;
cp = new SoCylinder;
rgb = new RGBColor;
tr = new Trans;
ro = new Rotate;
}
SoSeparator *Dumbbell::makeDumbbell()
{
int seg[1000][6];
SoSeparator *segment[1000];
SoCylinder *cyl;
Trans *trn;
Rotate *rot;
ifstream input_file("data4d.out");
int n, s=0;
for(int k=0;k<22; k++){
cout << "k=" << k <<endl;
for(int j=0;j<5; j++){
input_file >> n;
for(int i=0; i<n; i++){
seg[s][0]=n;
seg[s][5]=j;
for(int l=1; l<5; l++){
input_file >> seg[s][l];
}
s++;
}
}
}
int smax =s-1;
for(int i=0; i<s; i++){
cout << endl;
for(int j=0;j<6; j++){
cout << "seg[" << i << "][" << j << "]=" << seg[i][j] << endl;
}
}
for(int s=0; s<=smax; s++){
double w=seg[s][3]-seg[s][1];
double h=seg[s][4]-seg[s][2];
double d=seg[s][5];
segment[s] = new SoSeparator;
cyl = new SoCylinder;
trn = new Trans;
rot = new Rotate;
if(seg[s][1] == seg[s][3]){
cyl->radius=0.2;
cyl->height =h;
double a= seg[s][1]/2;
double b=(seg[s][2] + seg[s][4])/2;
double c= seg[s][5];
segment[s] ->addChild(trn->trans(a,b,c));
segment[s]->addChild(rgb->rcolor());
segment[s] ->addChild(rot->rotx_m());
}
if(seg[s][2] == seg[s][4]){
cyl->radius=0.2;
cyl->height =w;
double a= (seg[s][1] + seg[s][3])/2;
double b = seg[s][2]/2;
double c= seg[s][5];
segment[s]->addChild(trn->trans(a,b,c));
segment[s]->addChild(rgb->bcolor());
}
segment[s]->addChild(cyl);
gp->addChild(segment[s]);
}
return (gp);
}
Dumbbell::~Dumbbell()
{
}
ここから1~22までの数字を入力してもらい
その数字と同じkのみを表示させたいのですが手こずっています。
協力お願いします。