00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef StdMeshers_FaceSide_HeaderFile
00029 #define StdMeshers_FaceSide_HeaderFile
00030
00031 #include <gp_Pnt2d.hxx>
00032 #include <TopoDS_Edge.hxx>
00033 #include <TopoDS_Vertex.hxx>
00034 #include <Geom2d_Curve.hxx>
00035 #include <TopExp.hxx>
00036
00037 #include "SMESH_StdMeshers.hxx"
00038 #include "SMESH_Algo.hxx"
00039
00040 #include <vector>
00041 #include <list>
00042 #include <boost/shared_ptr.hpp>
00043
00044 class SMDS_MeshNode;
00045 class SMESH_Mesh;
00046 class Adaptor2d_Curve2d;
00047 class Adaptor3d_Curve;
00048 class BRepAdaptor_CompCurve;
00049 class TopoDS_Face;
00050 struct SMESH_ComputeError;
00051
00052 typedef struct uvPtStruct
00053 {
00054 double param;
00055
00056 double normParam;
00057 double u;
00058 double v;
00059 double x;
00060 double y;
00061 const SMDS_MeshNode * node;
00062 } UVPtStruct;
00063
00064 class StdMeshers_FaceSide;
00065 typedef boost::shared_ptr< StdMeshers_FaceSide > StdMeshers_FaceSidePtr;
00066 typedef boost::shared_ptr< uvPtStruct > UVPtStructPtr;
00067 typedef std::vector< StdMeshers_FaceSidePtr > TSideVector;
00068 typedef boost::shared_ptr< SMESH_ComputeError > TError;
00069
00070
00075
00076
00077 class STDMESHERS_EXPORT StdMeshers_FaceSide
00078 {
00079 public:
00083 StdMeshers_FaceSide(const TopoDS_Face& theFace,
00084 const TopoDS_Edge& theEdge,
00085 SMESH_Mesh* theMesh,
00086 const bool theIsForward,
00087 const bool theIgnoreMediumNodes);
00091 StdMeshers_FaceSide(const TopoDS_Face& theFace,
00092 std::list<TopoDS_Edge>& theEdges,
00093 SMESH_Mesh* theMesh,
00094 const bool theIsForward,
00095 const bool theIgnoreMediumNodes);
00099 StdMeshers_FaceSide(const SMDS_MeshNode* theNode,
00100 const gp_Pnt2d thePnt2d,
00101 const StdMeshers_FaceSide* theSide);
00105 static TSideVector GetFaceWires(const TopoDS_Face& theFace,
00106 SMESH_Mesh & theMesh,
00107 const bool theIgnoreMediumNodes,
00108 TError & theError);
00109
00113 void Reverse();
00117 int NbPoints() const { return myNbPonits; }
00121 int NbSegments() const { return myNbSegments; }
00125 SMESH_Mesh* GetMesh() const { return myMesh; }
00129 bool MissVertexNode() const { return myMissingVertexNodes; }
00137 const std::vector<UVPtStruct>& GetUVPtStruct(bool isXConst =0, double constValue =0) const;
00143 const std::vector<UVPtStruct>& SimulateUVPtStruct(int nbSeg,
00144 bool isXConst = 0,
00145 double constValue = 0) const;
00149 inline double Parameter(double U, TopoDS_Edge & edge) const;
00153 gp_Pnt2d Value2d(double U) const;
00157 Adaptor2d_Curve2d* GetCurve2d() const;
00161 BRepAdaptor_CompCurve* GetCurve3d() const;
00165 int NbEdges() const { return myEdge.size(); }
00169 const TopoDS_Edge& Edge(int i) const { return myEdge[i]; }
00173 inline TopoDS_Vertex FirstVertex(int i=0) const;
00177 inline TopoDS_Vertex LastVertex(int i=-1) const;
00181 inline double FirstParameter(int i) const;
00185 inline double LastParameter(int i) const;
00189 double Length() const { return myLength; }
00193 inline int EdgeIndex( double U ) const;
00194
00195
00196
00197 void dump(const char* msg=0) const;
00198
00199
00200 protected:
00201 std::vector<uvPtStruct> myPoints, myFalsePoints;
00202 std::vector<TopoDS_Edge> myEdge;
00203 std::vector<Handle(Geom2d_Curve)> myC2d;
00204 std::vector<double> myFirst, myLast;
00205 std::vector<double> myNormPar;
00206 double myLength;
00207 int myNbPonits, myNbSegments;
00208 SMESH_Mesh* myMesh;
00209 bool myMissingVertexNodes, myIgnoreMediumNodes;
00210 gp_Pnt2d myDefaultPnt2d;
00211 };
00212
00213
00214
00220
00221
00222 inline int StdMeshers_FaceSide::EdgeIndex( double U ) const
00223 {
00224 int i = myNormPar.size() - 1;
00225 while ( i > 0 && U < myNormPar[ i-1 ] ) --i;
00226 return i;
00227 }
00228
00229
00235
00236
00237 inline double StdMeshers_FaceSide::Parameter(double U, TopoDS_Edge & edge) const
00238 {
00239 int i = EdgeIndex( U );
00240 edge = myEdge[ i ];
00241 double prevU = i ? myNormPar[ i-1 ] : 0;
00242 double r = ( U - prevU )/ ( myNormPar[ i ] - prevU );
00243 return myFirst[i] * ( 1 - r ) + myLast[i] * r;
00244 }
00245
00246
00250
00251
00252 inline TopoDS_Vertex StdMeshers_FaceSide::FirstVertex(int i) const
00253 {
00254 return i < myEdge.size() ? TopExp::FirstVertex( myEdge[i], 1 ) : TopoDS_Vertex();
00255 }
00256
00257
00261
00262
00263 inline TopoDS_Vertex StdMeshers_FaceSide::LastVertex(int i) const
00264 {
00265 return i<0 ? TopExp::LastVertex( myEdge.back(), 1) : i<myEdge.size() ? TopExp::LastVertex( myEdge[i], 1 ) : TopoDS_Vertex();
00266 }
00267
00268
00272
00273
00274 inline double StdMeshers_FaceSide::FirstParameter(int i) const
00275 {
00276 return i==0 ? 0. : i<myNormPar.size() ? myNormPar[i-1] : 1.;
00277 }
00278
00279
00283
00284
00285 inline double StdMeshers_FaceSide::LastParameter(int i) const
00286 {
00287 return i<myNormPar.size() ? myNormPar[i] : 1;
00288 }
00289
00290 #endif