File indexing completed on 2026-09-13 09:18:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef VrmlData_ShapeConvert_HeaderFile
0017 #define VrmlData_ShapeConvert_HeaderFile
0018
0019 #include <VrmlData_Geometry.hxx>
0020 #include <VrmlData_Group.hxx>
0021 #include <NCollection_List.hxx>
0022 #include <NCollection_DataMap.hxx>
0023 #include <TopoDS_Shape.hxx>
0024
0025 class VrmlData_Scene;
0026 class VrmlData_Coordinate;
0027 class TopoDS_Face;
0028 class Poly_Polygon3D;
0029 class Poly_Triangulation;
0030 class XCAFPrs_Style;
0031 class TDocStd_Document;
0032 class TDF_Label;
0033
0034
0035
0036
0037
0038 class VrmlData_ShapeConvert
0039 {
0040 public:
0041 typedef struct
0042 {
0043 TCollection_AsciiString Name;
0044 TopoDS_Shape Shape;
0045 occ::handle<VrmlData_Node> Node;
0046 } ShapeData;
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058 inline VrmlData_ShapeConvert(VrmlData_Scene& theScene, const double theScale = 1.)
0059 : myScene(theScene),
0060 myScale(theScale),
0061 myDeflection(0.0),
0062 myDeflAngle(0.0)
0063 {
0064 }
0065
0066
0067
0068
0069
0070 Standard_EXPORT void AddShape(const TopoDS_Shape& theShape, const char* theName = nullptr);
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 Standard_EXPORT void Convert(const bool theExtractFaces,
0087 const bool theExtractEdges,
0088 const double theDeflection = 0.01,
0089 const double theDeflAngle = 20. * M_PI / 180.);
0090
0091
0092
0093
0094
0095
0096 Standard_EXPORT void ConvertDocument(const occ::handle<TDocStd_Document>& theDoc);
0097
0098 protected:
0099
0100
0101 occ::handle<VrmlData_Geometry> triToIndexedFaceSet(const occ::handle<Poly_Triangulation>&,
0102 const TopoDS_Face&,
0103 const occ::handle<VrmlData_Coordinate>&);
0104
0105 occ::handle<VrmlData_Geometry> polToIndexedLineSet(const occ::handle<Poly_Polygon3D>&);
0106
0107 occ::handle<VrmlData_Appearance> defaultMaterialFace() const;
0108
0109 occ::handle<VrmlData_Appearance> defaultMaterialEdge() const;
0110
0111 occ::handle<VrmlData_Geometry> makeTShapeNode(const TopoDS_Shape& theShape,
0112 const TopAbs_ShapeEnum theShapeType,
0113 TopLoc_Location& theLoc);
0114
0115 void addAssembly(const occ::handle<VrmlData_Group>& theParent,
0116 const TDF_Label& theLabel,
0117 const occ::handle<TDocStd_Document>& theDoc,
0118 const bool theNeedCreateGroup);
0119
0120 void addInstance(const occ::handle<VrmlData_Group>& theParent,
0121 const TDF_Label& theLabel,
0122 const occ::handle<TDocStd_Document>& theDoc);
0123
0124 void addShape(const occ::handle<VrmlData_Group>& theParent,
0125 const TDF_Label& theLabel,
0126 const occ::handle<TDocStd_Document>& theDoc);
0127
0128 occ::handle<VrmlData_Appearance> makeMaterialFromStyle(const XCAFPrs_Style& theStyle,
0129 const TDF_Label& theAttribLab) const;
0130
0131 private:
0132
0133
0134 VrmlData_Scene& myScene;
0135 double myScale;
0136 NCollection_List<ShapeData> myShapes;
0137
0138 double myDeflection;
0139 double myDeflAngle;
0140 NCollection_DataMap<TopoDS_Shape, occ::handle<VrmlData_Geometry>> myRelMap;
0141
0142
0143 void operator=(const VrmlData_ShapeConvert&) = delete;
0144 };
0145
0146 #endif