File indexing completed on 2026-05-02 08:23:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _RWObj_TriangulationReader_HeaderFile
0016 #define _RWObj_TriangulationReader_HeaderFile
0017
0018 #include <RWObj_Reader.hxx>
0019
0020 #include <Poly_Triangulation.hxx>
0021 #include <TopoDS_Compound.hxx>
0022
0023
0024 class RWObj_IShapeReceiver
0025 {
0026 public:
0027
0028
0029
0030
0031 virtual void BindNamedShape(const TopoDS_Shape& theShape,
0032 const TCollection_AsciiString& theName,
0033 const RWObj_Material* theMaterial,
0034 const Standard_Boolean theIsRootShape) = 0;
0035 };
0036
0037
0038 class RWObj_TriangulationReader : public RWObj_Reader
0039 {
0040 DEFINE_STANDARD_RTTIEXT(RWObj_TriangulationReader, RWObj_Reader)
0041 public:
0042
0043 RWObj_TriangulationReader()
0044 : myShapeReceiver(NULL),
0045 myToCreateShapes(Standard_True)
0046 {
0047 }
0048
0049
0050 void SetCreateShapes(Standard_Boolean theToCreateShapes) { myToCreateShapes = theToCreateShapes; }
0051
0052
0053 void SetShapeReceiver(RWObj_IShapeReceiver* theReceiver) { myShapeReceiver = theReceiver; }
0054
0055
0056 Standard_EXPORT virtual Handle(Poly_Triangulation) GetTriangulation();
0057
0058
0059 Standard_EXPORT TopoDS_Shape ResultShape();
0060
0061 protected:
0062
0063 Standard_EXPORT virtual Standard_Boolean addMesh(const RWObj_SubMesh& theMesh,
0064 const RWObj_SubMeshReason theReason)
0065 Standard_OVERRIDE;
0066
0067
0068 virtual gp_Pnt getNode(Standard_Integer theIndex) const Standard_OVERRIDE
0069 {
0070 return myNodes.Value(theIndex - 1);
0071 }
0072
0073
0074 virtual Standard_Integer addNode(const gp_Pnt& thePnt) Standard_OVERRIDE
0075 {
0076 myNodes.Append(thePnt);
0077 return myNodes.Size();
0078 }
0079
0080
0081 virtual void setNodeNormal(const Standard_Integer theIndex,
0082 const Graphic3d_Vec3& theNormal) Standard_OVERRIDE
0083 {
0084 myNormals.SetValue(theIndex - 1, theNormal);
0085 }
0086
0087
0088 virtual void setNodeUV(const Standard_Integer theIndex,
0089 const Graphic3d_Vec2& theUV) Standard_OVERRIDE
0090 {
0091 myNodesUV.SetValue(theIndex - 1, theUV);
0092 }
0093
0094
0095 virtual void addElement(Standard_Integer theN1,
0096 Standard_Integer theN2,
0097 Standard_Integer theN3,
0098 Standard_Integer theN4) Standard_OVERRIDE
0099 {
0100 myTriangles.Append(Poly_Triangle(theN1, theN2, theN3));
0101 if (theN4 != -1)
0102 {
0103 myTriangles.Append(Poly_Triangle(theN1, theN3, theN4));
0104 }
0105 }
0106
0107 protected:
0108
0109 Standard_EXPORT Standard_Boolean addSubShape(TopoDS_Shape& theParent,
0110 const TopoDS_Shape& theSubShape,
0111 const Standard_Boolean theToExpandCompound);
0112
0113 protected:
0114 NCollection_Vector<gp_Pnt> myNodes;
0115 NCollection_Vector<Graphic3d_Vec3> myNormals;
0116 NCollection_Vector<Graphic3d_Vec2> myNodesUV;
0117 NCollection_Vector<Poly_Triangle> myTriangles;
0118
0119 RWObj_IShapeReceiver* myShapeReceiver;
0120 TopoDS_Compound myResultShape;
0121 TopoDS_Compound myLastObjectShape;
0122
0123 TopoDS_Shape myLastGroupShape;
0124
0125 TCollection_AsciiString myLastGroupName;
0126 TCollection_AsciiString myLastFaceMaterial;
0127 Standard_Boolean myToCreateShapes;
0128 };
0129
0130 #endif