Base: [skip ci] optimize writing Inventor file
This commit is contained in:
@@ -53,9 +53,9 @@ using namespace Base;
|
||||
* A more elaborate description of the constructor.
|
||||
*/
|
||||
Builder3D::Builder3D()
|
||||
:bStartEndOpen(false)
|
||||
: bStartEndOpen(false)
|
||||
{
|
||||
result << "#Inventor V2.1 ascii " << std::endl << std::endl;
|
||||
result << "#Inventor V2.1 ascii \n\n";
|
||||
result << "Separator { ";
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ void Builder3D::saveToFile(const char* FileName)
|
||||
if(!file)
|
||||
throw FileException("Builder3D::saveToFile(): Can not open file...");
|
||||
|
||||
file << "#Inventor V2.1 ascii " << std::endl;
|
||||
file << "#Inventor V2.1 ascii \n";
|
||||
file << result.str();
|
||||
}
|
||||
|
||||
@@ -338,7 +338,7 @@ InventorBuilder::InventorBuilder(std::ostream& output)
|
||||
: result(output)
|
||||
, indent(0)
|
||||
{
|
||||
result << "#Inventor V2.1 ascii " << std::endl << std::endl;
|
||||
result << "#Inventor V2.1 ascii \n\n";
|
||||
beginSeparator();
|
||||
}
|
||||
|
||||
@@ -357,100 +357,100 @@ void InventorBuilder::close()
|
||||
|
||||
void InventorBuilder::beginSeparator()
|
||||
{
|
||||
result << Base::blanks(indent) << "Separator { " << std::endl;
|
||||
indent+=2;
|
||||
result << Base::blanks(indent) << "Separator { \n";
|
||||
indent += 2;
|
||||
}
|
||||
|
||||
void InventorBuilder::endSeparator()
|
||||
{
|
||||
indent-=2;
|
||||
result << Base::blanks(indent) << "}" << std::endl;
|
||||
result << Base::blanks(indent) << "}\n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addInfo(const char* text)
|
||||
{
|
||||
result << Base::blanks(indent) << "Info { " << std::endl;
|
||||
result << Base::blanks(indent) << " string \"" << text << "\"" << std::endl;
|
||||
result << Base::blanks(indent) << "} " << std::endl;
|
||||
result << Base::blanks(indent) << "Info { \n";
|
||||
result << Base::blanks(indent) << " string \"" << text << "\"\n";
|
||||
result << Base::blanks(indent) << "} \n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addLabel(const char* text)
|
||||
{
|
||||
result << Base::blanks(indent) << "Label { " << std::endl;
|
||||
result << Base::blanks(indent) << " label \"" << text << "\"" << std::endl;
|
||||
result << Base::blanks(indent) << "} " << std::endl;
|
||||
result << Base::blanks(indent) << "Label { \n";
|
||||
result << Base::blanks(indent) << " label \"" << text << "\"\n";
|
||||
result << Base::blanks(indent) << "} \n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addBaseColor(float color_r, float color_g, float color_b)
|
||||
{
|
||||
result << Base::blanks(indent) << "BaseColor { " << std::endl;
|
||||
result << Base::blanks(indent) << "BaseColor { \n";
|
||||
result << Base::blanks(indent) << " rgb "
|
||||
<< color_r << " "<< color_g << " "<< color_b << std::endl;
|
||||
result << Base::blanks(indent) << "} " << std::endl;
|
||||
<< color_r << " " << color_g << " " << color_b << '\n';
|
||||
result << Base::blanks(indent) << "} \n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addMaterial(float color_r, float color_g, float color_b, float color_a)
|
||||
{
|
||||
result << Base::blanks(indent) << "Material { " << std::endl;
|
||||
result << Base::blanks(indent) << "Material { \n";
|
||||
result << Base::blanks(indent) << " diffuseColor "
|
||||
<< color_r << " "<< color_g << " "<< color_b << std::endl;
|
||||
<< color_r << " " << color_g << " " << color_b << '\n';
|
||||
if (color_a > 0)
|
||||
result << Base::blanks(indent) << " transparency " << color_a << std::endl;
|
||||
result << Base::blanks(indent) << "} " << std::endl;
|
||||
result << Base::blanks(indent) << " transparency " << color_a << '\n';
|
||||
result << Base::blanks(indent) << "} \n";
|
||||
}
|
||||
|
||||
void InventorBuilder::beginMaterial()
|
||||
{
|
||||
result << Base::blanks(indent) << "Material { " << std::endl;
|
||||
indent +=2;
|
||||
result << Base::blanks(indent) << "diffuseColor [" << std::endl;
|
||||
indent +=2;
|
||||
result << Base::blanks(indent) << "Material { \n";
|
||||
indent += 2;
|
||||
result << Base::blanks(indent) << "diffuseColor [\n";
|
||||
indent += 2;
|
||||
}
|
||||
|
||||
void InventorBuilder::endMaterial()
|
||||
{
|
||||
indent -=2;
|
||||
result << Base::blanks(indent) << "]" << std::endl;
|
||||
indent -=2;
|
||||
result << Base::blanks(indent) << "}" << std::endl;
|
||||
indent -= 2;
|
||||
result << Base::blanks(indent) << "]\n";
|
||||
indent -= 2;
|
||||
result << Base::blanks(indent) << "}\n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addColor(float color_r, float color_g, float color_b)
|
||||
{
|
||||
result << color_r << " " << color_g << " " << color_b << std::endl;
|
||||
result << color_r << " " << color_g << " " << color_b << '\n';
|
||||
}
|
||||
|
||||
void InventorBuilder::addMaterialBinding(const char* bind)
|
||||
{
|
||||
result << Base::blanks(indent) << "MaterialBinding { value "
|
||||
<< bind << " } " << std::endl;
|
||||
<< bind << " } \n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addDrawStyle(short pointSize, short lineWidth, unsigned short linePattern, const char* style)
|
||||
{
|
||||
result << Base::blanks(indent) << "DrawStyle {" << std::endl
|
||||
<< Base::blanks(indent) << " style " << style << std::endl
|
||||
<< Base::blanks(indent) << " pointSize " << pointSize << std::endl
|
||||
<< Base::blanks(indent) << " lineWidth " << lineWidth << std::endl
|
||||
<< Base::blanks(indent) << " linePattern " << linePattern << std::endl
|
||||
<< Base::blanks(indent) << "}" << std::endl;
|
||||
result << Base::blanks(indent) << "DrawStyle {\n"
|
||||
<< Base::blanks(indent) << " style " << style << '\n'
|
||||
<< Base::blanks(indent) << " pointSize " << pointSize << '\n'
|
||||
<< Base::blanks(indent) << " lineWidth " << lineWidth << '\n'
|
||||
<< Base::blanks(indent) << " linePattern " << linePattern << '\n'
|
||||
<< Base::blanks(indent) << "}\n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addShapeHints(float crease)
|
||||
{
|
||||
result << Base::blanks(indent) << "ShapeHints {" << std::endl
|
||||
<< Base::blanks(indent) << " creaseAngle " << crease << std::endl
|
||||
<< Base::blanks(indent) << "}" << std::endl;
|
||||
result << Base::blanks(indent) << "ShapeHints {\n"
|
||||
<< Base::blanks(indent) << " creaseAngle " << crease << '\n'
|
||||
<< Base::blanks(indent) << "}\n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addPolygonOffset(float factor, float units, const char* styles, bool on)
|
||||
{
|
||||
result << Base::blanks(indent) << "PolygonOffset {" << std::endl
|
||||
<< Base::blanks(indent) << " factor " << factor << std::endl
|
||||
<< Base::blanks(indent) << " units " << units << std::endl
|
||||
<< Base::blanks(indent) << " styles " << styles << std::endl
|
||||
<< Base::blanks(indent) << " on " << (on ? "TRUE" : "FALSE") << std::endl
|
||||
<< Base::blanks(indent) << "}" << std::endl;
|
||||
result << Base::blanks(indent) << "PolygonOffset {\n"
|
||||
<< Base::blanks(indent) << " factor " << factor << '\n'
|
||||
<< Base::blanks(indent) << " units " << units << '\n'
|
||||
<< Base::blanks(indent) << " styles " << styles << '\n'
|
||||
<< Base::blanks(indent) << " on " << (on ? "TRUE" : "FALSE") << '\n'
|
||||
<< Base::blanks(indent) << "}\n";
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
@@ -465,22 +465,22 @@ void InventorBuilder::addPolygonOffset(float factor, float units, const char* st
|
||||
*/
|
||||
void InventorBuilder::beginPoints()
|
||||
{
|
||||
result << Base::blanks(indent) << "Coordinate3 { " << std::endl;
|
||||
result << Base::blanks(indent) << "Coordinate3 { \n";
|
||||
indent += 2;
|
||||
result << Base::blanks(indent) << "point [ " << std::endl;
|
||||
result << Base::blanks(indent) << "point [ \n";
|
||||
indent += 2;
|
||||
}
|
||||
|
||||
/// insert a point in a point set
|
||||
void InventorBuilder::addPoint(float x, float y, float z)
|
||||
{
|
||||
result << Base::blanks(indent) << x << " " << y << " " << z << "," << std::endl;
|
||||
result << Base::blanks(indent) << x << " " << y << " " << z << ",\n";
|
||||
}
|
||||
|
||||
/// add a vector to a point set
|
||||
void InventorBuilder::addPoint(const Vector3f &vec)
|
||||
{
|
||||
addPoint(vec.x,vec.y,vec.z);
|
||||
addPoint(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
void InventorBuilder::addPoints(const std::vector<Vector3f> &vec)
|
||||
@@ -496,9 +496,9 @@ void InventorBuilder::addPoints(const std::vector<Vector3f> &vec)
|
||||
void InventorBuilder::endPoints()
|
||||
{
|
||||
indent -= 2;
|
||||
result << Base::blanks(indent) << "]" << std::endl;
|
||||
result << Base::blanks(indent) << "]\n";
|
||||
indent -= 2;
|
||||
result << Base::blanks(indent) << "}" << std::endl;
|
||||
result << Base::blanks(indent) << "}\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -510,7 +510,7 @@ void InventorBuilder::endPoints()
|
||||
*/
|
||||
void InventorBuilder::addPointSet()
|
||||
{
|
||||
result << Base::blanks(indent) << "PointSet { } " << std::endl;
|
||||
result << Base::blanks(indent) << "PointSet { } \n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -522,7 +522,7 @@ void InventorBuilder::addPointSet()
|
||||
*/
|
||||
void InventorBuilder::addLineSet()
|
||||
{
|
||||
result << Base::blanks(indent) << "LineSet { } " << std::endl;
|
||||
result << Base::blanks(indent) << "LineSet { } \n";
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
@@ -540,13 +540,13 @@ void InventorBuilder::addLineSet()
|
||||
*/
|
||||
void InventorBuilder::addText(float pos_x, float pos_y, float pos_z, const char * text, float color_r, float color_g, float color_b)
|
||||
{
|
||||
result << Base::blanks(indent) << "Separator { " << std::endl
|
||||
result << Base::blanks(indent) << "Separator { \n"
|
||||
<< Base::blanks(indent) << " Material { diffuseColor "
|
||||
<< color_r << " "<< color_g << " "<< color_b << "} " << std::endl
|
||||
<< color_r << " "<< color_g << " "<< color_b << "} \n"
|
||||
<< Base::blanks(indent) << " Transform { translation "
|
||||
<< pos_x << " "<< pos_y << " "<< pos_z << "} " << std::endl
|
||||
<< Base::blanks(indent) << " Text2 { string \" " << text << "\" " << "} " << std::endl
|
||||
<< Base::blanks(indent) << "}" << std::endl;
|
||||
<< pos_x << " "<< pos_y << " "<< pos_z << "} \n"
|
||||
<< Base::blanks(indent) << " Text2 { string \" " << text << "\" " << "} \n"
|
||||
<< Base::blanks(indent) << "}\n";
|
||||
|
||||
}
|
||||
|
||||
@@ -567,17 +567,17 @@ void InventorBuilder::addSingleLine(const Vector3f& pt1, const Vector3f& pt2, sh
|
||||
//itoa(linePattern, buf, 16);
|
||||
//strcat(lp, buf);
|
||||
|
||||
result << " Separator { " << std::endl
|
||||
<< " Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} " << std::endl
|
||||
<< " DrawStyle { lineWidth " << lineSize << " linePattern " << lp << " } " << std::endl
|
||||
<< " Coordinate3 { " << std::endl
|
||||
result << " Separator { \n"
|
||||
<< " Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} \n"
|
||||
<< " DrawStyle { lineWidth " << lineSize << " linePattern " << lp << " } \n"
|
||||
<< " Coordinate3 { \n"
|
||||
<< " point [ "
|
||||
<< pt1.x << " " << pt1.y << " " << pt1.z << ","
|
||||
<< pt2.x << " " << pt2.y << " " << pt2.z
|
||||
<< " ] " << std::endl
|
||||
<< " } " << std::endl
|
||||
<< " LineSet { } " << std::endl
|
||||
<< " } " << std::endl;
|
||||
<< " ] \n"
|
||||
<< " } \n"
|
||||
<< " LineSet { } \n"
|
||||
<< " } \n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addSingleArrow(const Vector3f& pt1, const Vector3f& pt2, short lineSize,
|
||||
@@ -599,26 +599,26 @@ void InventorBuilder::addSingleArrow(const Vector3f& pt1, const Vector3f& pt2, s
|
||||
rot.Normalize();
|
||||
float a = Vector3f(0.0f, 1.0f, 0.0f).GetAngle(dir);
|
||||
|
||||
result << Base::blanks(indent) << "Separator { " << std::endl
|
||||
result << Base::blanks(indent) << "Separator { \n"
|
||||
<< Base::blanks(indent) << " Material { diffuseColor "
|
||||
<< color_r << " "<< color_g << " "<< color_b << "} " << std::endl
|
||||
<< color_r << " "<< color_g << " "<< color_b << "} \n"
|
||||
<< Base::blanks(indent) << " DrawStyle { lineWidth "
|
||||
<< lineSize << "} " << std::endl
|
||||
<< Base::blanks(indent) << " Coordinate3 { " << std::endl
|
||||
<< lineSize << "} \n"
|
||||
<< Base::blanks(indent) << " Coordinate3 { \n"
|
||||
<< Base::blanks(indent) << " point [ "
|
||||
<< pt1.x << " " << pt1.y << " " << pt1.z << ","
|
||||
<< pt2s.x << " " << pt2s.y << " " << pt2s.z
|
||||
<< " ] " << std::endl
|
||||
<< Base::blanks(indent) << " } " << std::endl
|
||||
<< Base::blanks(indent) << " LineSet { } " << std::endl
|
||||
<< Base::blanks(indent) << " Transform { " << std::endl
|
||||
<< " ] \n"
|
||||
<< Base::blanks(indent) << " } \n"
|
||||
<< Base::blanks(indent) << " LineSet { } \n"
|
||||
<< Base::blanks(indent) << " Transform { \n"
|
||||
<< Base::blanks(indent) << " translation "
|
||||
<< cpt.x << " " << cpt.y << " " << cpt.z << " " << std::endl
|
||||
<< cpt.x << " " << cpt.y << " " << cpt.z << " \n"
|
||||
<< Base::blanks(indent) << " rotation "
|
||||
<< rot.x << " " << rot.y << " " << rot.z << " " << a << std::endl
|
||||
<< Base::blanks(indent) << " } " << std::endl
|
||||
<< Base::blanks(indent) << " Cone { bottomRadius " << cr << " height " << cl << "} " << std::endl
|
||||
<< Base::blanks(indent) << "} " << std::endl;
|
||||
<< rot.x << " " << rot.y << " " << rot.z << " " << a << '\n'
|
||||
<< Base::blanks(indent) << " } \n"
|
||||
<< Base::blanks(indent) << " Cone { bottomRadius " << cr << " height " << cl << "} \n"
|
||||
<< Base::blanks(indent) << "} \n";
|
||||
}
|
||||
|
||||
/** Add a line defined by a list of points whereat always a pair (i.e. a point and the following point) builds a line.
|
||||
@@ -630,22 +630,22 @@ void InventorBuilder::addLineSet(const std::vector<Vector3f>& points, short line
|
||||
char lp[20];
|
||||
sprintf(lp, "0x%x", linePattern);
|
||||
|
||||
result << " Separator { " << std::endl
|
||||
<< " Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} " << std::endl
|
||||
<< " DrawStyle { lineWidth " << lineSize << " linePattern " << lp << " } " << std::endl
|
||||
<< " Coordinate3 { " << std::endl
|
||||
result << " Separator { \n"
|
||||
<< " Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} \n"
|
||||
<< " DrawStyle { lineWidth " << lineSize << " linePattern " << lp << " } \n"
|
||||
<< " Coordinate3 { \n"
|
||||
<< " point [ ";
|
||||
std::vector<Vector3f>::const_iterator it = points.begin();
|
||||
if ( it != points.end() )
|
||||
{
|
||||
result << it->x << " " << it->y << " " << it->z;
|
||||
for ( ++it ; it != points.end(); ++it )
|
||||
result << "," << std::endl << " " << it->x << " " << it->y << " " << it->z;
|
||||
result << ",\n " << it->x << " " << it->y << " " << it->z;
|
||||
}
|
||||
|
||||
result << " ] " << std::endl
|
||||
<< " } " << std::endl
|
||||
<< " LineSet { " << std::endl
|
||||
result << " ] \n"
|
||||
<< " } \n"
|
||||
<< " LineSet { \n"
|
||||
<< " numVertices [ ";
|
||||
/*size_t ct = points.size() / 2;
|
||||
if ( ct > 0 )
|
||||
@@ -655,14 +655,14 @@ void InventorBuilder::addLineSet(const std::vector<Vector3f>& points, short line
|
||||
{
|
||||
result << ",";
|
||||
if (i%16==0)
|
||||
result << std::endl << " ";
|
||||
result << "\n ";
|
||||
result << "2";
|
||||
}
|
||||
}*/
|
||||
result << " -1 ";
|
||||
result << " ] " << std::endl
|
||||
<< " } " << std::endl
|
||||
<< " } " << std::endl;
|
||||
result << " ] \n"
|
||||
<< " } \n"
|
||||
<< " } \n";
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
@@ -673,8 +673,8 @@ void InventorBuilder::addIndexedFaceSet(const std::vector<int>& indices)
|
||||
if (indices.size() < 4)
|
||||
return;
|
||||
|
||||
result << Base::blanks(indent) << "IndexedFaceSet { " << std::endl
|
||||
<< Base::blanks(indent) << " coordIndex [ " << std::endl;
|
||||
result << Base::blanks(indent) << "IndexedFaceSet { \n"
|
||||
<< Base::blanks(indent) << " coordIndex [ \n";
|
||||
|
||||
indent += 4;
|
||||
std::vector<int>::const_iterator it_last_f = indices.end()-1;
|
||||
@@ -685,19 +685,19 @@ void InventorBuilder::addIndexedFaceSet(const std::vector<int>& indices)
|
||||
if (it != it_last_f)
|
||||
result << *it << ", ";
|
||||
else
|
||||
result << *it << " ] " << std::endl;
|
||||
result << *it << " ] \n";
|
||||
if (++index % 8 == 0)
|
||||
result << std::endl;
|
||||
result << '\n';
|
||||
}
|
||||
indent -= 4;
|
||||
|
||||
result << Base::blanks(indent) << "} " << std::endl;
|
||||
result << Base::blanks(indent) << "} \n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addFaceSet(const std::vector<int>& vertices)
|
||||
{
|
||||
result << Base::blanks(indent) << "FaceSet { " << std::endl
|
||||
<< Base::blanks(indent) << " numVertices [ " << std::endl;
|
||||
result << Base::blanks(indent) << "FaceSet { \n"
|
||||
<< Base::blanks(indent) << " numVertices [ \n";
|
||||
|
||||
indent += 4;
|
||||
std::vector<int>::const_iterator it_last_f = vertices.end()-1;
|
||||
@@ -708,60 +708,60 @@ void InventorBuilder::addFaceSet(const std::vector<int>& vertices)
|
||||
if (it != it_last_f)
|
||||
result << *it << ", ";
|
||||
else
|
||||
result << *it << " ] " << std::endl;
|
||||
result << *it << " ] \n";
|
||||
if (++index % 8 == 0)
|
||||
result << std::endl;
|
||||
result << '\n';
|
||||
}
|
||||
indent -= 4;
|
||||
|
||||
result << Base::blanks(indent) << "} " << std::endl;
|
||||
result << Base::blanks(indent) << "} \n";
|
||||
}
|
||||
|
||||
void InventorBuilder::beginNormal()
|
||||
{
|
||||
result << Base::blanks(indent) << "Normal { " << std::endl;
|
||||
result << Base::blanks(indent) << "Normal { \n";
|
||||
indent += 2;
|
||||
result << Base::blanks(indent) << "vector [ " << std::endl;
|
||||
result << Base::blanks(indent) << "vector [ \n";
|
||||
indent += 2;
|
||||
}
|
||||
|
||||
void InventorBuilder::endNormal()
|
||||
{
|
||||
indent -= 2;
|
||||
result << Base::blanks(indent) << "]" << std::endl;
|
||||
result << Base::blanks(indent) << "]\n";
|
||||
indent -= 2;
|
||||
result << Base::blanks(indent) << "}" << std::endl;
|
||||
result << Base::blanks(indent) << "}\n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addNormalBinding(const char* binding)
|
||||
{
|
||||
result << Base::blanks(indent) << "NormalBinding {" << std::endl
|
||||
<< Base::blanks(indent) << " value " << binding << std::endl
|
||||
<< Base::blanks(indent) << "}" << std::endl;
|
||||
result << Base::blanks(indent) << "NormalBinding {\n"
|
||||
<< Base::blanks(indent) << " value " << binding << '\n'
|
||||
<< Base::blanks(indent) << "}\n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addSingleTriangle(const Vector3f& pt0, const Vector3f& pt1, const Vector3f& pt2,
|
||||
bool filled, short lineSize, float color_r, float color_g, float color_b)
|
||||
{
|
||||
std::string fs = "";
|
||||
if (filled)
|
||||
{
|
||||
fs = " FaceSet { } ";
|
||||
}
|
||||
std::string fs = "";
|
||||
if (filled)
|
||||
{
|
||||
fs = " FaceSet { } ";
|
||||
}
|
||||
|
||||
result << " Separator { " << std::endl
|
||||
<< " Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} " << std::endl
|
||||
<< " DrawStyle { lineWidth " << lineSize << "} " << std::endl
|
||||
<< " Coordinate3 { " << std::endl
|
||||
result << " Separator { \n"
|
||||
<< " Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} \n"
|
||||
<< " DrawStyle { lineWidth " << lineSize << "} \n"
|
||||
<< " Coordinate3 { \n"
|
||||
<< " point [ "
|
||||
<< pt0.x << " " << pt0.y << " " << pt0.z << ","
|
||||
<< pt1.x << " " << pt1.y << " " << pt1.z << ","
|
||||
<< pt2.x << " " << pt2.y << " " << pt2.z
|
||||
<< "] " << std::endl
|
||||
<< " } " << std::endl
|
||||
<< " IndexedLineSet { coordIndex[ 0, 1, 2, 0, -1 ] } " << std::endl
|
||||
<< fs << std::endl
|
||||
<< " } " << std::endl;
|
||||
<< "] \n"
|
||||
<< " } \n"
|
||||
<< " IndexedLineSet { coordIndex[ 0, 1, 2, 0, -1 ] } \n"
|
||||
<< fs << '\n'
|
||||
<< " } \n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addSinglePlane(const Vector3f& base, const Vector3f& eX, const Vector3f& eY,
|
||||
@@ -778,20 +778,20 @@ void InventorBuilder::addSinglePlane(const Vector3f& base, const Vector3f& eX, c
|
||||
fs = " FaceSet { } ";
|
||||
}
|
||||
|
||||
result << " Separator { " << std::endl
|
||||
<< " Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} " << std::endl
|
||||
<< " DrawStyle { lineWidth " << lineSize << "} " << std::endl
|
||||
<< " Coordinate3 { " << std::endl
|
||||
result << " Separator { \n"
|
||||
<< " Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} \n"
|
||||
<< " DrawStyle { lineWidth " << lineSize << "} \n"
|
||||
<< " Coordinate3 { \n"
|
||||
<< " point [ "
|
||||
<< pt0.x << " " << pt0.y << " " << pt0.z << ","
|
||||
<< pt1.x << " " << pt1.y << " " << pt1.z << ","
|
||||
<< pt2.x << " " << pt2.y << " " << pt2.z << ","
|
||||
<< pt3.x << " " << pt3.y << " " << pt3.z
|
||||
<< "] " << std::endl
|
||||
<< " } " << std::endl
|
||||
<< " IndexedLineSet { coordIndex[ 0, 1, 2, 3, 0, -1 ] } " << std::endl
|
||||
<< fs << std::endl
|
||||
<< " } " << std::endl;
|
||||
<< "] \n"
|
||||
<< " } \n"
|
||||
<< " IndexedLineSet { coordIndex[ 0, 1, 2, 3, 0, -1 ] } \n"
|
||||
<< fs << '\n'
|
||||
<< " } \n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -805,21 +805,21 @@ void InventorBuilder::addNurbsSurface(const std::vector<Base::Vector3f>& control
|
||||
const std::vector<float>& uKnots,
|
||||
const std::vector<float>& vKnots)
|
||||
{
|
||||
result << " Separator { " << std::endl
|
||||
<< " Coordinate3 { " << std::endl
|
||||
result << " Separator { \n"
|
||||
<< " Coordinate3 { \n"
|
||||
<< " point [ ";
|
||||
for (std::vector<Base::Vector3f>::const_iterator it =
|
||||
controlPoints.begin(); it != controlPoints.end(); ++it) {
|
||||
if (it != controlPoints.begin())
|
||||
result << "," << std::endl << " ";
|
||||
result << ",\n ";
|
||||
result << it->x << " " << it->y << " " << it->z;
|
||||
}
|
||||
|
||||
result << " ]" << std::endl
|
||||
<< " }" << std::endl;
|
||||
result << " NurbsSurface { " << std::endl
|
||||
<< " numUControlPoints " << numUControlPoints << std::endl
|
||||
<< " numVControlPoints " << numVControlPoints << std::endl
|
||||
result << " ]\n"
|
||||
<< " }\n";
|
||||
result << " NurbsSurface { \n"
|
||||
<< " numUControlPoints " << numUControlPoints << '\n'
|
||||
<< " numVControlPoints " << numVControlPoints << '\n'
|
||||
<< " uKnotVector [ ";
|
||||
int index = 0;
|
||||
for (std::vector<float>::const_iterator it = uKnots.begin(); it != uKnots.end(); ++it) {
|
||||
@@ -827,26 +827,26 @@ void InventorBuilder::addNurbsSurface(const std::vector<Base::Vector3f>& control
|
||||
index++;
|
||||
if ((it+1) < uKnots.end()) {
|
||||
if (index % 4 == 0)
|
||||
result << "," << std::endl << " ";
|
||||
result << ",\n ";
|
||||
else
|
||||
result << ", ";
|
||||
}
|
||||
}
|
||||
result << " ]" << std::endl
|
||||
result << " ]\n"
|
||||
<< " vKnotVector [ ";
|
||||
for (std::vector<float>::const_iterator it = vKnots.begin(); it != vKnots.end(); ++it) {
|
||||
result << *it;
|
||||
index++;
|
||||
if ((it+1) < vKnots.end()) {
|
||||
if (index % 4 == 0)
|
||||
result << "," << std::endl << " ";
|
||||
result << ",\n ";
|
||||
else
|
||||
result << ", ";
|
||||
}
|
||||
}
|
||||
result << " ]" << std::endl
|
||||
<< " }" << std::endl
|
||||
<< " }" << std::endl;
|
||||
result << " ]\n"
|
||||
<< " }\n"
|
||||
<< " }\n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addCylinder(float radius, float height)
|
||||
@@ -878,10 +878,10 @@ void InventorBuilder::addBoundingBox(const Vector3f& pt1, const Vector3f& pt2, s
|
||||
pt[6].Set(pt2.x, pt2.y, pt1.z);
|
||||
pt[7].Set(pt2.x, pt2.y, pt2.z);
|
||||
|
||||
result << " Separator { " << std::endl
|
||||
<< " Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} " << std::endl
|
||||
<< " DrawStyle { lineWidth " << lineWidth << "} " << std::endl
|
||||
<< " Coordinate3 { " << std::endl
|
||||
result << " Separator { \n"
|
||||
<< " Material { diffuseColor " << color_r << " "<< color_g << " "<< color_b << "} \n"
|
||||
<< " DrawStyle { lineWidth " << lineWidth << "} \n"
|
||||
<< " Coordinate3 { \n"
|
||||
<< " point [ "
|
||||
<< " " << pt[0].x << " " << pt[0].y << " " << pt[0].z << ",\n"
|
||||
<< " " << pt[1].x << " " << pt[1].y << " " << pt[1].z << ",\n"
|
||||
@@ -891,15 +891,15 @@ void InventorBuilder::addBoundingBox(const Vector3f& pt1, const Vector3f& pt2, s
|
||||
<< " " << pt[5].x << " " << pt[5].y << " " << pt[5].z << ",\n"
|
||||
<< " " << pt[6].x << " " << pt[6].y << " " << pt[6].z << ",\n"
|
||||
<< " " << pt[7].x << " " << pt[7].y << " " << pt[7].z
|
||||
<< "] " << std::endl
|
||||
<< " } " << std::endl
|
||||
<< "] \n"
|
||||
<< " } \n"
|
||||
<< " IndexedLineSet { coordIndex[ 0, 2, 6, 4, 0, -1\n"
|
||||
" 1, 5, 7, 3, 1, -1,\n"
|
||||
" 5, 4, 6, 7, 5, -1,\n"
|
||||
" 7, 6, 2, 3, 7, -1,\n"
|
||||
" 3, 2, 0, 1, 3, -1,\n"
|
||||
" 5, 1, 0, 4, 5, -1 ] } " << std::endl
|
||||
<< " } " << std::endl;
|
||||
" 5, 1, 0, 4, 5, -1 ] } \n"
|
||||
<< " } \n";
|
||||
}
|
||||
|
||||
void InventorBuilder::addTransformation(const Matrix4D& transform)
|
||||
@@ -915,13 +915,13 @@ void InventorBuilder::addTransformation(const Matrix4D& transform)
|
||||
|
||||
void InventorBuilder::addTransformation(const Vector3f& translation, const Vector3f& rotationaxis, float fAngle)
|
||||
{
|
||||
result << Base::blanks(indent) << "Transform {" << std::endl;
|
||||
result << Base::blanks(indent) << "Transform {\n";
|
||||
result << Base::blanks(indent) << " translation "
|
||||
<< translation.x << " " << translation.y << " " << translation.z << std::endl;
|
||||
<< translation.x << " " << translation.y << " " << translation.z << '\n';
|
||||
result << Base::blanks(indent) << " rotation "
|
||||
<< rotationaxis.x << " " << rotationaxis.y << " " << rotationaxis.z
|
||||
<< " " << fAngle << std::endl;
|
||||
result << Base::blanks(indent) << "}" << std::endl;
|
||||
<< " " << fAngle << '\n';
|
||||
result << Base::blanks(indent) << "}" << '\n';
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user