File indexing completed on 2026-06-15 08:30:52
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 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 Standard_Real 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 = 0L);
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 Standard_EXPORT void Convert(const Standard_Boolean theExtractFaces,
0087 const Standard_Boolean theExtractEdges,
0088 const Standard_Real theDeflection = 0.01,
0089 const Standard_Real theDeflAngle = 20. * M_PI / 180.);
0090
0091
0092
0093
0094
0095
0096 Standard_EXPORT void ConvertDocument(const Handle(TDocStd_Document)& theDoc);
0097
0098 protected:
0099
0100
0101 Handle(VrmlData_Geometry) triToIndexedFaceSet(const Handle(Poly_Triangulation)&,
0102 const TopoDS_Face&,
0103 const Handle(VrmlData_Coordinate)&);
0104
0105 Handle(VrmlData_Geometry) polToIndexedLineSet(const Handle(Poly_Polygon3D)&);
0106
0107 Handle(VrmlData_Appearance) defaultMaterialFace() const;
0108
0109 Handle(VrmlData_Appearance) defaultMaterialEdge() const;
0110
0111 Handle(VrmlData_Geometry) makeTShapeNode(const TopoDS_Shape& theShape,
0112 const TopAbs_ShapeEnum theShapeType,
0113 TopLoc_Location& theLoc);
0114
0115 void addAssembly(const Handle(VrmlData_Group)& theParent,
0116 const TDF_Label& theLabel,
0117 const Handle(TDocStd_Document)& theDoc,
0118 const Standard_Boolean theNeedCreateGroup);
0119
0120 void addInstance(const Handle(VrmlData_Group)& theParent,
0121 const TDF_Label& theLabel,
0122 const Handle(TDocStd_Document)& theDoc);
0123
0124 void addShape(const Handle(VrmlData_Group)& theParent,
0125 const TDF_Label& theLabel,
0126 const Handle(TDocStd_Document)& theDoc);
0127
0128 Handle(VrmlData_Appearance) makeMaterialFromStyle(const XCAFPrs_Style& theStyle,
0129 const TDF_Label& theAttribLab) const;
0130
0131 private:
0132
0133
0134 VrmlData_Scene& myScene;
0135 Standard_Real myScale;
0136 NCollection_List<ShapeData> myShapes;
0137
0138 Standard_Real myDeflection;
0139 Standard_Real myDeflAngle;
0140 NCollection_DataMap<TopoDS_Shape, Handle(VrmlData_Geometry)> myRelMap;
0141
0142
0143 void operator=(const VrmlData_ShapeConvert&);
0144 };
0145
0146 #endif