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