File indexing completed on 2026-05-14 08:30:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _RWMesh_FaceIterator_HeaderFile
0015 #define _RWMesh_FaceIterator_HeaderFile
0016
0017 #include <RWMesh_ShapeIterator.hxx>
0018
0019 #include <BRepLProp_SLProps.hxx>
0020 #include <Poly_Triangulation.hxx>
0021 #include <TopoDS_Face.hxx>
0022
0023 #include <algorithm>
0024
0025 class TDF_Label;
0026
0027
0028
0029
0030
0031
0032 class RWMesh_FaceIterator : public RWMesh_ShapeIterator
0033 {
0034 public:
0035
0036
0037
0038
0039
0040 Standard_EXPORT RWMesh_FaceIterator(const TDF_Label& theLabel,
0041 const TopLoc_Location& theLocation,
0042 const Standard_Boolean theToMapColors = false,
0043 const XCAFPrs_Style& theStyle = XCAFPrs_Style());
0044
0045
0046
0047
0048 Standard_EXPORT RWMesh_FaceIterator(const TopoDS_Shape& theShape,
0049 const XCAFPrs_Style& theStyle = XCAFPrs_Style());
0050
0051
0052 bool More() const Standard_OVERRIDE { return !myPolyTriang.IsNull(); }
0053
0054
0055 Standard_EXPORT void Next() Standard_OVERRIDE;
0056
0057
0058 const TopoDS_Face& Face() const { return myFace; }
0059
0060
0061 const TopoDS_Shape& Shape() const Standard_OVERRIDE { return myFace; }
0062
0063
0064 const Handle(Poly_Triangulation)& Triangulation() const { return myPolyTriang; }
0065
0066
0067 bool IsEmptyMesh() const { return IsEmpty(); }
0068
0069
0070 bool IsEmpty() const Standard_OVERRIDE
0071 {
0072 return myPolyTriang.IsNull()
0073 || (myPolyTriang->NbNodes() < 1 && myPolyTriang->NbTriangles() < 1);
0074 }
0075
0076 public:
0077
0078 const XCAFPrs_Style& FaceStyle() const { return myStyle; }
0079
0080
0081 bool HasFaceColor() const { return myHasColor; }
0082
0083
0084 const Quantity_ColorRGBA& FaceColor() const { return myColor; }
0085
0086 public:
0087
0088 Standard_Integer NbTriangles() const { return myPolyTriang->NbTriangles(); }
0089
0090
0091 Standard_Integer ElemLower() const Standard_OVERRIDE { return 1; }
0092
0093
0094 Standard_Integer ElemUpper() const Standard_OVERRIDE { return myPolyTriang->NbTriangles(); }
0095
0096
0097 Poly_Triangle TriangleOriented(Standard_Integer theElemIndex) const
0098 {
0099 Poly_Triangle aTri = triangle(theElemIndex);
0100 if ((myFace.Orientation() == TopAbs_REVERSED) ^ myIsMirrored)
0101 {
0102 return Poly_Triangle(aTri.Value(1), aTri.Value(3), aTri.Value(2));
0103 }
0104 return aTri;
0105 }
0106
0107 public:
0108
0109 bool HasNormals() const { return myHasNormals; }
0110
0111
0112 bool HasTexCoords() const { return !myPolyTriang.IsNull() && myPolyTriang->HasUVNodes(); }
0113
0114
0115
0116 gp_Dir NormalTransformed(Standard_Integer theNode) const
0117 {
0118 gp_Dir aNorm = normal(theNode);
0119 if (myTrsf.Form() != gp_Identity)
0120 {
0121 aNorm.Transform(myTrsf);
0122 }
0123 if (myFace.Orientation() == TopAbs_REVERSED)
0124 {
0125 aNorm.Reverse();
0126 }
0127 return aNorm;
0128 }
0129
0130
0131 Standard_Integer NbNodes() const Standard_OVERRIDE
0132 {
0133 return !myPolyTriang.IsNull() ? myPolyTriang->NbNodes() : 0;
0134 }
0135
0136
0137 Standard_Integer NodeLower() const Standard_OVERRIDE { return 1; }
0138
0139
0140 Standard_Integer NodeUpper() const Standard_OVERRIDE { return myPolyTriang->NbNodes(); }
0141
0142
0143 gp_Pnt2d NodeTexCoord(const Standard_Integer theNode) const
0144 {
0145 return myPolyTriang->HasUVNodes() ? myPolyTriang->UVNode(theNode) : gp_Pnt2d();
0146 }
0147
0148 public:
0149
0150 gp_Pnt node(const Standard_Integer theNode) const Standard_OVERRIDE
0151 {
0152 return myPolyTriang->Node(theNode);
0153 }
0154
0155
0156 Standard_EXPORT gp_Dir normal(Standard_Integer theNode) const;
0157
0158
0159 Poly_Triangle triangle(Standard_Integer theElemIndex) const
0160 {
0161 return myPolyTriang->Triangle(theElemIndex);
0162 }
0163
0164 private:
0165
0166 void resetFace()
0167 {
0168 myPolyTriang.Nullify();
0169 myFace.Nullify();
0170 myHasNormals = false;
0171 resetShape();
0172 }
0173
0174
0175 void initFace();
0176
0177 private:
0178
0179 TopoDS_Face myFace;
0180 Handle(Poly_Triangulation) myPolyTriang;
0181 mutable BRepLProp_SLProps mySLTool;
0182 BRepAdaptor_Surface myFaceAdaptor;
0183 Standard_Boolean myHasNormals;
0184 Standard_Boolean myIsMirrored;
0185
0186 };
0187
0188 #endif