File indexing completed on 2025-01-18 10:04:43
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
0044 RWObj_TriangulationReader() : myShapeReceiver (NULL), myToCreateShapes (Standard_True) {}
0045
0046
0047 void SetCreateShapes (Standard_Boolean theToCreateShapes) { myToCreateShapes = theToCreateShapes; }
0048
0049
0050 void SetShapeReceiver (RWObj_IShapeReceiver* theReceiver) { myShapeReceiver = theReceiver; }
0051
0052
0053 Standard_EXPORT virtual Handle(Poly_Triangulation) GetTriangulation();
0054
0055
0056 Standard_EXPORT TopoDS_Shape ResultShape();
0057
0058 protected:
0059
0060
0061 Standard_EXPORT virtual Standard_Boolean addMesh (const RWObj_SubMesh& theMesh,
0062 const RWObj_SubMeshReason theReason) Standard_OVERRIDE;
0063
0064
0065 virtual gp_Pnt getNode (Standard_Integer theIndex) const Standard_OVERRIDE
0066 {
0067 return myNodes.Value (theIndex - 1);
0068 }
0069
0070
0071 virtual Standard_Integer addNode (const gp_Pnt& thePnt) Standard_OVERRIDE
0072 {
0073 myNodes.Append (thePnt);
0074 return myNodes.Size();
0075 }
0076
0077
0078 virtual void setNodeNormal (const Standard_Integer theIndex,
0079 const Graphic3d_Vec3& theNormal) Standard_OVERRIDE
0080 {
0081 myNormals.SetValue (theIndex - 1, theNormal);
0082 }
0083
0084
0085 virtual void setNodeUV (const Standard_Integer theIndex,
0086 const Graphic3d_Vec2& theUV) Standard_OVERRIDE
0087 {
0088 myNodesUV.SetValue (theIndex - 1, theUV);
0089 }
0090
0091
0092 virtual void addElement (Standard_Integer theN1, Standard_Integer theN2, Standard_Integer theN3, Standard_Integer theN4) Standard_OVERRIDE
0093 {
0094 myTriangles.Append (Poly_Triangle (theN1, theN2, theN3));
0095 if (theN4 != -1)
0096 {
0097 myTriangles.Append (Poly_Triangle (theN1, theN3, theN4));
0098 }
0099 }
0100
0101 protected:
0102
0103
0104 Standard_EXPORT Standard_Boolean addSubShape (TopoDS_Shape& theParent,
0105 const TopoDS_Shape& theSubShape,
0106 const Standard_Boolean theToExpandCompound);
0107
0108 protected:
0109
0110 NCollection_Vector<gp_Pnt> myNodes;
0111 NCollection_Vector<Graphic3d_Vec3> myNormals;
0112 NCollection_Vector<Graphic3d_Vec2> myNodesUV;
0113 NCollection_Vector<Poly_Triangle> myTriangles;
0114
0115 RWObj_IShapeReceiver* myShapeReceiver;
0116 TopoDS_Compound myResultShape;
0117 TopoDS_Compound myLastObjectShape;
0118 TopoDS_Shape myLastGroupShape;
0119 TCollection_AsciiString myLastGroupName;
0120 TCollection_AsciiString myLastFaceMaterial;
0121 Standard_Boolean myToCreateShapes;
0122
0123 };
0124
0125 #endif