diff --git a/src/Base/Builder3D.cpp b/src/Base/Builder3D.cpp index 6d0af1d0a4..dbb81e6b4d 100644 --- a/src/Base/Builder3D.cpp +++ b/src/Base/Builder3D.cpp @@ -851,175 +851,6 @@ void InventorBuilder::endSeparator() result << indent << "}\n"; } -void InventorBuilder::addInfo(const char* text) -{ - result << indent << "Info { \n"; - result << indent << " string \"" << text << "\"\n"; - result << indent << "} \n"; -} - -void InventorBuilder::addLabel(const char* text) -{ - result << indent << "Label { \n"; - result << indent << " label \"" << text << "\"\n"; - result << indent << "} \n"; -} - -void InventorBuilder::addBaseColor(const ColorRGB& rgb) -{ - result << indent << "BaseColor { \n"; - result << indent << " rgb " - << rgb.red() << " " << rgb.green() << " " << rgb.blue() << '\n'; - result << indent << "} \n"; -} - -void InventorBuilder::addMaterial(const ColorRGB& rgb, float transparency) -{ - result << indent << "Material { \n"; - result << indent << " diffuseColor " - << rgb.red() << " " << rgb.green() << " " << rgb.blue() << '\n'; - if (transparency > 0) - result << indent << " transparency " << transparency << '\n'; - result << indent << "} \n"; -} - -void InventorBuilder::beginMaterial() -{ - result << indent << "Material { \n"; - increaseIndent(); - result << indent << "diffuseColor [\n"; - increaseIndent(); -} - -void InventorBuilder::endMaterial() -{ - decreaseIndent(); - result << indent << "]\n"; - decreaseIndent(); - result << indent << "}\n"; -} - -void InventorBuilder::addColor(const ColorRGB& rgb) -{ - result << rgb.red() << " " << rgb.green() << " " << rgb.blue() << '\n'; -} - -void InventorBuilder::addMaterialBinding(BindingElement bind) -{ - result << indent << "MaterialBinding { value " - << bind.bindingAsString() << " } \n"; -} - -void InventorBuilder::addDrawStyle(DrawStyle drawStyle) -{ - result << indent << "DrawStyle {\n" - << indent << " style " << drawStyle.styleAsString() << '\n' - << indent << " pointSize " << drawStyle.pointSize << '\n' - << indent << " lineWidth " << drawStyle.lineWidth << '\n' - << indent << " linePattern " << drawStyle.linePattern << '\n' - << indent << "}\n"; -} - -void InventorBuilder::addShapeHints(float creaseAngle) -{ - result << indent << "ShapeHints {\n" - << indent << " creaseAngle " << creaseAngle << '\n' - << indent << "}\n"; -} - -void InventorBuilder::addPolygonOffset(PolygonOffset polygonOffset) -{ - result << indent << "PolygonOffset {\n" - << indent << " factor " << polygonOffset.factor << '\n' - << indent << " units " << polygonOffset.units << '\n' - << indent << " styles " << polygonOffset.styleAsString() << '\n' - << indent << " on " << (polygonOffset.on ? "TRUE" : "FALSE") << '\n' - << indent << "}\n"; -} - -/** - * Starts the definition of point set. - * If possible don't make too many beginPoints() and endPoints() calls. - * Try to put all points in one set. - * @see endPoints() - */ -void InventorBuilder::beginPoints() -{ - result << indent << "Coordinate3 { \n"; - increaseIndent(); - result << indent << "point [ \n"; - increaseIndent(); -} - -/// insert a point in a point set -void InventorBuilder::addPoint(const Vector3f& pnt) -{ - result << indent << pnt.x << " " << pnt.y << " " << pnt.z << ",\n"; -} - -void InventorBuilder::addPoints(const std::vector& points) -{ - for (const auto& pnt : points) { - addPoint(pnt); - } -} - -/** - * Ends the point set operations and write the resulting inventor string. - * @see beginPoints() - */ -void InventorBuilder::endPoints() -{ - decreaseIndent(); - result << indent << "]\n"; - decreaseIndent(); - result << indent << "}\n"; -} - -/** - * Adds an SoPointSet node after creating an SoCordinate3 node with - * beginPoints() and endPoints(). - * @see beginPoints() - * @see endPoints() - */ -void InventorBuilder::addPointSet() -{ - result << indent << "PointSet { } \n"; -} - -void InventorBuilder::addSinglePoint(const Base::Vector3f &point, DrawStyle drawStyle, const ColorRGB& color) -{ - result << indent << "Separator { "; - result << indent << " Material { "; - result << indent << " diffuseColor " << color.red() << " "<< color.green() << " "<< color.blue(); - result << indent << " }"; - result << indent << " MaterialBinding { value PER_PART } "; - result << indent << " DrawStyle { pointSize " << drawStyle.pointSize << "} "; - result << indent << " Coordinate3 { "; - result << indent << " point [ "; - result << point.x << " " << point.y << " " << point.z << ","; - result << indent << " ] "; - result << indent << " }"; - result << indent << " PointSet { } "; - result << indent <<"}"; -} - -/** - * Adds a SoLineSet node after creating a SoCordinate3 node with - * beginPoints() and endPoints(). - * @see beginPoints() - * @see endPoints() - */ -void InventorBuilder::addLineSet() -{ - result << indent << "LineSet { } \n"; -} - -void InventorBuilder::addText(const char * text) -{ - result << indent << " Text2 { string \" " << text << "\" " << "} \n"; -} - /** * Add a Text with a given position to the 3D set. The origin is the * lower leftmost corner. @@ -1127,82 +958,6 @@ void InventorBuilder::addLineSet(const std::vector& points, DrawStyle << " } \n"; } -void InventorBuilder::addIndexedFaceSet(const std::vector& indices) -{ - if (indices.size() < 4) - return; - - result << indent << "IndexedFaceSet { \n" - << indent << " coordIndex [ \n"; - - increaseIndent(); - increaseIndent(); - std::vector::const_iterator it_last_f = indices.end()-1; - int index=0; - for (std::vector::const_iterator it = indices.begin(); it != indices.end(); ++it) { - if (index % 8 == 0) - result << indent; - if (it != it_last_f) - result << *it << ", "; - else - result << *it << " ] \n"; - if (++index % 8 == 0) - result << '\n'; - } - decreaseIndent(); - decreaseIndent(); - - result << indent << "} \n"; -} - -void InventorBuilder::addFaceSet(const std::vector& vertices) -{ - result << indent << "FaceSet { \n" - << indent << " numVertices [ \n"; - - increaseIndent(); - increaseIndent(); - std::vector::const_iterator it_last_f = vertices.end()-1; - int index=0; - for (std::vector::const_iterator it = vertices.begin(); it != vertices.end(); ++it) { - if (index % 8 == 0) - result << indent; - if (it != it_last_f) - result << *it << ", "; - else - result << *it << " ] \n"; - if (++index % 8 == 0) - result << '\n'; - } - decreaseIndent(); - decreaseIndent(); - - result << indent << "} \n"; -} - -void InventorBuilder::beginNormal() -{ - result << indent << "Normal { \n"; - increaseIndent(); - result << indent << "vector [ \n"; - increaseIndent(); -} - -void InventorBuilder::endNormal() -{ - decreaseIndent(); - result << indent << "]\n"; - decreaseIndent(); - result << indent << "}\n"; -} - -void InventorBuilder::addNormalBinding(const char* binding) -{ - result << indent << "NormalBinding {\n" - << indent << " value " << binding << '\n' - << indent << "}\n"; -} - void InventorBuilder::addSingleTriangle(const Triangle& triangle, DrawStyle drawStyle, const ColorRGB& rgb) { std::string fs = ""; @@ -1253,82 +1008,6 @@ void InventorBuilder::addSinglePlane(const Vector3f& base, const Vector3f& eX, c << " } \n"; } -/** - * The number of control points must be numUControlPoints * numVControlPoints. - * The order in u or v direction of the NURBS surface is implicitly given by - * number of elements in uKnots - numUControlPoints or - * number of elements in vKnots - numVControlPoints. - */ -void InventorBuilder::addNurbsSurface(const std::vector& controlPoints, - int numUControlPoints, int numVControlPoints, - const std::vector& uKnots, - const std::vector& vKnots) -{ - result << " Separator { \n" - << " Coordinate3 { \n" - << " point [ "; - for (std::vector::const_iterator it = - controlPoints.begin(); it != controlPoints.end(); ++it) { - if (it != controlPoints.begin()) - result << ",\n "; - result << it->x << " " << it->y << " " << it->z; - } - - result << " ]\n" - << " }\n"; - result << " NurbsSurface { \n" - << " numUControlPoints " << numUControlPoints << '\n' - << " numVControlPoints " << numVControlPoints << '\n' - << " uKnotVector [ "; - int index = 0; - for (std::vector::const_iterator it = uKnots.begin(); it != uKnots.end(); ++it) { - result << *it; - index++; - if ((it+1) < uKnots.end()) { - if (index % 4 == 0) - result << ",\n "; - else - result << ", "; - } - } - result << " ]\n" - << " vKnotVector [ "; - for (std::vector::const_iterator it = vKnots.begin(); it != vKnots.end(); ++it) { - result << *it; - index++; - if ((it+1) < vKnots.end()) { - if (index % 4 == 0) - result << ",\n "; - else - result << ", "; - } - } - result << " ]\n" - << " }\n" - << " }\n"; -} - -void InventorBuilder::addCone(float bottomRadius, float height) -{ - result << indent << " Cone { bottomRadius " << bottomRadius << " height " << height << "} \n"; -} - -void InventorBuilder::addCylinder(float radius, float height) -{ - result << indent << "Cylinder {\n" - << indent << " radius " << radius << "\n" - << indent << " height " << height << "\n" - << indent << " parts (SIDES | TOP | BOTTOM)\n" - << indent << "}\n"; -} - -void InventorBuilder::addSphere(float radius) -{ - result << indent << "Sphere {\n" - << indent << " radius " << radius << "\n" - << indent << "}\n"; -} - void InventorBuilder::addBoundingBox(const Vector3f& pt1, const Vector3f& pt2, DrawStyle drawStyle, const ColorRGB& rgb) { Base::Vector3f pt[8]; diff --git a/src/Base/Builder3D.h b/src/Base/Builder3D.h index 68e3d584bc..eba757ca98 100644 --- a/src/Base/Builder3D.h +++ b/src/Base/Builder3D.h @@ -566,88 +566,7 @@ public: * \brief Closes the last added separator node. */ void endSeparator(); - /*! - * \brief Sets an info node. - * \param str - text set to the info node - */ - void addInfo(const char* str); - /*! - * \brief Sets a label node. - * \param str - text set to the label node - */ - void addLabel(const char* str); /** @name Appearance handling */ - //@{ - /*! - * \brief Sets a base color node. The colors are in the range [0, 1]. - */ - void addBaseColor(const ColorRGB& rgb); - /*! - * \brief Sets a material node. The colors are in the range [0, 1]. - */ - void addMaterial(const ColorRGB& rgb, float transparency=0); - /*! - * \brief Starts a material node. The node must be closed with \ref endMaterial - * and the colors must be added with \ref addColor(). - */ - void beginMaterial(); - /*! - * \brief Closes a material node. - */ - void endMaterial(); - /*! - * \brief Adds a color to a material node. The colors are in the range [0, 1]. - */ - void addColor(const ColorRGB& rgb); - /*! - * \brief Sets a material binding node. - * \param binding - binding of the material. - */ - void addMaterialBinding(BindingElement); - /*! - * \brief Sets a draw style node. - */ - void addDrawStyle(DrawStyle drawStyle); - /*! - * \brief Sets a shape hints node. - * \param crease - the crease angle in radians - */ - void addShapeHints(float creaseAngle=0.0f); - /*! - * \brief Sets a polygon offset node. - */ - void addPolygonOffset(PolygonOffset polygonOffset); - //@} - - /** @name Add coordinates */ - //@{ - /// add a single point - void addPoint(const Vector3f& pnt); - /// add a list of points - void addPoints(const std::vector& points); - //@} - - /** @name Point set handling */ - //@{ - /// starts a point set - void beginPoints(); - /// ends the points set operation - void endPoints(); - /// add an SoPointSet node - void addPointSet(); - /// add a single point (without startPoints() & endPoints() ) - void addSinglePoint(const Base::Vector3f& point, DrawStyle drawStyle, const ColorRGB& color = ColorRGB{1.0F, 1.0F, 1.0F}); - //@} - - /** @name Normal handling */ - //@{ - /// starts a point set - void beginNormal(); - /// ends the points set operation - void endNormal(); - /// add normal binding node - void addNormalBinding(const char*); - //@} /** @name Line/Direction handling */ //@{ @@ -657,8 +576,6 @@ public: void addSingleArrow(const Base::Line3f& line, DrawStyle drawStyle, const ColorRGB& rgb = ColorRGB{1.0F, 1.0F, 1.0F}); /// add a line defined by a list of points whereat always a pair (i.e. a point and the following point) builds a line. void addLineSet(const std::vector& points, DrawStyle drawStyle, const ColorRGB& rgb = ColorRGB{1.0F, 1.0F, 1.0F}); - /// add an SoLineSet node - void addLineSet(); //@} /** @name Triangle handling */ @@ -667,18 +584,6 @@ public: void addSingleTriangle(const Triangle& triangle, DrawStyle drawStyle, const ColorRGB& rgb = ColorRGB{1.0F, 1.0F, 1.0F}); void addSinglePlane(const Vector3f& base, const Vector3f& eX, const Vector3f& eY, float length, float width, DrawStyle drawStyle, const ColorRGB& rgb = ColorRGB{1.0F, 1.0F, 1.0F}); - void addIndexedFaceSet(const std::vector& indices); - void addFaceSet(const std::vector& vertices); - //@} - - /** @name Surface handling */ - //@{ - void addNurbsSurface(const std::vector& controlPoints, - int numUControlPoints, int numVControlPoints, - const std::vector& uKnots, const std::vector& vKnots); - void addCone(float bottomRadius, float height); - void addCylinder(float radius, float height); - void addSphere(float radius); //@} /** @name Bounding Box handling */ @@ -697,7 +602,6 @@ public: /** @name Text handling */ //@{ /// add a text - void addText(const char * text); void addText(const Vector3f &vec,const char * text, const ColorRGB& rgb = ColorRGB{1.0F, 1.0F, 1.0F}); //@}